informationList.vue 11 KB

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