informationList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div class="app-container">
  3. <div v-show="!informationDetailState.show && !informationViewState.show && !informationApprovalState.show">
  4. <transition name="fade">
  5. <div v-show="showSearch">
  6. <el-form ref="queryFormRef" :model="queryParams" label-width="100px">
  7. <el-row :gutter="20">
  8. <el-col :span="7">
  9. <el-segmented v-model="queryParams.dispose_status" :options="disposeStatusOptions" size="large" block @change="handleDisposeStatus" />
  10. </el-col>
  11. </el-row>
  12. <el-row :gutter="20">
  13. <el-col :span="5">
  14. <el-form-item label="发布单位:">
  15. <el-input v-model="queryParams.publish_group" placeholder="请输入内容" clearable></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="5">
  19. <el-form-item label="发布状态:">
  20. <el-select v-model="queryParams.publish_status" placeholder="请选择">
  21. <el-option v-for="item in publishStatusOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="5">
  26. <el-form-item label="审批状态:">
  27. <el-select v-model="queryParams.examine_status" placeholder="请选择">
  28. <el-option v-for="item in approvalStatusOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="4">
  33. <el-form-item>
  34. <el-button type="primary" @click="handleSearch">查询</el-button>
  35. <el-button @click="resetSearch">重置</el-button>
  36. </el-form-item>
  37. </el-col>
  38. </el-row>
  39. </el-form>
  40. </div>
  41. </transition>
  42. <!-- 表格组件 -->
  43. <el-table ref="multipleTable" v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
  44. <el-table-column label="序号" align="center" width="60">
  45. <template #default="scope">
  46. {{ (queryParams.page - 1) * queryParams.page_size + (scope.$index + 1) }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="发布单位" align="center" prop="publish_group" />
  50. <el-table-column label="信息内容" align="center" prop="content" />
  51. <el-table-column label="发布时间" align="center" prop="publish_time" />
  52. <el-table-column label="发布渠道" align="center" prop="publish_channel" />
  53. <el-table-column label="发布申请人" align="center" prop="nick_name" />
  54. <el-table-column label="待处理人" align="center" prop="examine_user" />
  55. <el-table-column label="发布状态" align="center" prop="publish_status">
  56. <template #default="scope">
  57. <div class="common-flex">
  58. <i :class="getStatusClass(scope.row.publish_status)"></i>
  59. <dict-tag :options="publishStatusOptions" :value="scope.row.publish_status" />
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="审批状态" align="center" prop="examine_status">
  64. <template #default="scope">
  65. <div class="common-flex">
  66. <i :class="getStatusClass2(scope.row.examine_status)"></i>
  67. <dict-tag :options="approvalStatusOptions" :value="scope.row.examine_status" />
  68. </div>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="发布统计" align="center" prop="statistics">
  72. <template #default="scope">
  73. <div class="statistics-container">
  74. <p>选择人数: {{ scope.row.user_count }}</p>
  75. <p>成功: {{ scope.row.user_ok_count }}</p>
  76. <p>失败: {{ scope.row.user_err_count }}</p>
  77. <p>发送中: {{ scope.row.user_sending_count }}</p>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  82. <template #default="scope">
  83. <el-text class="common-btn-text-primary" @click="handleView(scope.row)">查看</el-text>
  84. <el-text v-if="scope.row && scope.row.is_my_edit" class="common-btn-text-primary" @click="handleUpdate(scope.row)">编辑</el-text>
  85. <el-text v-if="scope.row && scope.row.is_my_examine" class="common-btn-text-primary" @click="handleApproval(scope.row)">审批</el-text>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <pagination v-show="total > 0" v-model:page="queryParams.page" v-model:limit="queryParams.page_size" :total="total" @pagination="tableData" />
  90. </div>
  91. <InformationDetail v-if="informationDetailState.show" :event-id="informationDetailState.eventId" @close="handleCancel" />
  92. <InformationView v-if="informationViewState.show" :event-id="informationViewState.eventId" @close="handleCancel" />
  93. <InformationApproval v-if="informationApprovalState.show" :event-id="informationApprovalState.eventId" @close="handleCancel" />
  94. </div>
  95. </template>
  96. <script setup lang="ts">
  97. import { ref, reactive, toRefs, onMounted } from 'vue';
  98. import { getInformation } from '@/api/informationissue/informationissue';
  99. import InformationDetail from './informationDetail.vue';
  100. import InformationView from './informationView.vue';
  101. import InformationApproval from './informationApproval.vue';
  102. const showSearch = ref(true);
  103. const queryFormRef = ref();
  104. const tableData = ref([]);
  105. const loading = ref(true);
  106. const ids = ref([]);
  107. const selectedRow = ref(null);
  108. const initFormData = reactive({
  109. publish_group: '',
  110. publish_status: '',
  111. examine_status: '',
  112. dispose_status: '',
  113. content: '',
  114. publish_time: '',
  115. publish_channel: '',
  116. nick_name: '',
  117. examine_user: '',
  118. user_count: '',
  119. user_ok_count: '',
  120. user_err_count: '',
  121. user_sending_count: '',
  122. id: ''
  123. });
  124. // 表单数据
  125. const data = reactive({
  126. form: { ...initFormData },
  127. queryParams: {
  128. page: 1,
  129. page_size: 10,
  130. publish_group: '',
  131. publish_status: '',
  132. examine_status: '',
  133. dispose_status: '0'
  134. }
  135. });
  136. const { queryParams, form } = toRefs(data);
  137. const total = ref(0);
  138. const publishStatusOptions = reactive([
  139. { value: '0', label: '全部' },
  140. { value: '1', label: '草稿' },
  141. { value: '2', label: '审批中' },
  142. { value: '3', label: '发布中' },
  143. { value: '4', label: '已发布' }
  144. ]);
  145. const approvalStatusOptions = reactive([
  146. { value: '0', label: '全部' },
  147. { value: '1', label: '待审批' },
  148. { value: '2', label: '审批中' },
  149. { value: '3', label: '审批通过' },
  150. { value: '9', label: '审批不通过' }
  151. ]);
  152. const disposeStatusOptions = reactive([
  153. { value: '0', label: '全部' },
  154. { value: '1', label: '待处理' },
  155. { value: '2', label: '已处理' }
  156. ]);
  157. const getStatusClass = (value) => {
  158. if (['发布中', '已发布'].includes(value)) {
  159. return 'dot-green';
  160. } else if (value === '未提交') {
  161. return 'dot-orange';
  162. } else if (value === '审批中') {
  163. return 'dot-red';
  164. }
  165. };
  166. const getStatusClass2 = (value) => {
  167. if (['审批通过'].includes(value)) {
  168. return 'dot-green';
  169. } else if (value === '待审批') {
  170. return 'dot-blue';
  171. } else if (['审批中'].includes(value)) {
  172. return 'dot-red';
  173. } else if (['未提交'].includes(value)) {
  174. return 'dot-grey';
  175. }
  176. };
  177. const handleDisposeStatus = (val: any) => {
  178. queryParams.value.dispose_status = val;
  179. handleSearch();
  180. };
  181. const handleSearch = () => {
  182. queryParams.value.page = 1;
  183. getList();
  184. };
  185. const resetSearch = () => {
  186. queryParams.value = { page: 1, page_size: 10, publish_group: '', publish_status: '', examine_status: '', dispose_status: '0' };
  187. handleSearch();
  188. };
  189. const handleSelectionChange = (selection) => {
  190. ids.value = selection.map((item) => item.eventId);
  191. selectedRow.value = selection.length === 1 ? selection[0] : null;
  192. };
  193. // 查看详情对话框
  194. let informationDetailState = reactive({
  195. show: false,
  196. eventId: ''
  197. });
  198. // 编辑对话框
  199. let informationViewState = reactive({
  200. show: false,
  201. eventId: ''
  202. });
  203. // 审批对话框
  204. let informationApprovalState = reactive({
  205. show: false,
  206. eventId: ''
  207. });
  208. const handleView = (row) => {
  209. if (row) {
  210. informationViewState.eventId = row.id; // 假设eventId是id字段
  211. informationViewState.show = true;
  212. }
  213. };
  214. const handleUpdate = (row) => {
  215. if (row) {
  216. informationDetailState.eventId = row.id; // 假设eventId是id字段
  217. informationDetailState.show = true;
  218. }
  219. };
  220. const handleApproval = (row) => {
  221. if (row) {
  222. informationApprovalState.eventId = row.id; // 假设eventId是id字段
  223. informationApprovalState.show = true;
  224. }
  225. };
  226. const handleCancel = () => {
  227. informationDetailState.show = false;
  228. informationViewState.show = false;
  229. informationApprovalState.show = false;
  230. };
  231. const getList = () => {
  232. loading.value = true;
  233. getInformation(queryParams.value) // 假设 getInformation 已经定义好
  234. .then((res) => {
  235. if (res.code === 200) {
  236. // 映射返回的数据到 tableData
  237. tableData.value = res.data.map((item) => ({
  238. id: item.id,
  239. publish_group: item.publish_group || '未知',
  240. content: item.content || '未知',
  241. publish_time: item.publish_time || '未知',
  242. publish_channel: item.publish_channel || '未知',
  243. nick_name: item.nick_name || '未知',
  244. examine_user: item.examine_user || '未知',
  245. publish_status: item.publish_status,
  246. examine_status: item.examine_status,
  247. user_count: item.user_count || 0,
  248. user_ok_count: item.user_ok_count || 0,
  249. user_err_count: item.user_err_count || 0,
  250. user_sending_count: item.user_sending_count || 0,
  251. is_my_examine: item.is_my_examine || false,
  252. is_my_edit: item.is_my_edit || false
  253. }));
  254. total.value = res.total;
  255. } else {
  256. console.error(res.msg);
  257. }
  258. })
  259. .catch((error) => {
  260. console.error('请求错误:', error);
  261. })
  262. .finally(() => {
  263. loading.value = false;
  264. });
  265. };
  266. onMounted(() => {
  267. getList();
  268. });
  269. </script>
  270. <style scoped>
  271. /* Add your custom styles here */
  272. </style>