index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <seek-page :seekList="seekList" @search="search"></seek-page>
  5. <el-tabs v-model="tabValue" type="card" @tab-click="handleTabClick">
  6. <el-tab-pane label="全部" name="99"></el-tab-pane>
  7. <el-tab-pane label="草稿" name="0"></el-tab-pane>
  8. <el-tab-pane label="审核中" name="1"></el-tab-pane>
  9. <el-tab-pane label="驳回" name="3"></el-tab-pane>
  10. <el-tab-pane label="办结" name="2"></el-tab-pane>
  11. </el-tabs>
  12. <!-- 数据表格 -->
  13. <ele-pro-table
  14. ref="table"
  15. :columns="columns"
  16. :datasource="datasource"
  17. row-key="code"
  18. :selection.sync="selection"
  19. @sort-change="onSortChange"
  20. autoAmendPage
  21. @columns-change="handleColumnChange"
  22. :cache-key="cacheKeyUrl"
  23. :pageSize="20"
  24. :height="tableHeight"
  25. @fullscreen-change="fullscreenChange"
  26. >
  27. <template v-slot:toolbar>
  28. <el-button type="primary" @click="toAdd()">新增</el-button>
  29. <el-button type="danger" @click="toDelAll()">批量删除</el-button>
  30. <!-- <el-button type="success" @click="toEnd()">导出</el-button> -->
  31. <el-button type="primary" @click="printing()">打印</el-button>
  32. </template>
  33. <template v-slot:docNo="{ row }">
  34. <el-link type="primary" :underline="false" @click="toEdit('detail', row)">
  35. {{ row.docNo }}
  36. </el-link>
  37. </template>
  38. <!-- 操作列 -->
  39. <template v-slot:action="{ row }">
  40. <template v-if="row.approvalStatus == 0 || row.approvalStatus == 3">
  41. <el-link
  42. type="primary"
  43. :underline="false"
  44. @click="toEdit('edit', row)"
  45. >
  46. 编辑
  47. </el-link>
  48. <el-link
  49. type="primary"
  50. :underline="false"
  51. @click="toSubmit(row)"
  52. >
  53. 提交
  54. </el-link>
  55. <el-popconfirm
  56. class="ele-action"
  57. title="确定要删除吗?"
  58. @confirm="
  59. toDel(row)
  60. "
  61. >
  62. <template v-slot:reference>
  63. <el-link type="danger" :underline="false"> 删除 </el-link>
  64. </template>
  65. </el-popconfirm>
  66. </template>
  67. <el-link
  68. v-if="row.approvalStatus == 2 && row.status == 1"
  69. type="primary"
  70. :underline="false"
  71. @click="toChangeStatus(row, 2)"
  72. >
  73. 发布
  74. </el-link>
  75. <el-link
  76. v-if="row.approvalStatus == 2 && row.status == 2"
  77. type="primary"
  78. @click="toChangeStatus(row, 3)"
  79. >作废</el-link
  80. >
  81. </template>
  82. </ele-pro-table>
  83. </el-card>
  84. <documentDialog ref="documentDialogRef" @done="handleSelectDone" />
  85. <process-submit-dialog
  86. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  87. v-if="processSubmitDialogFlag"
  88. ref="processSubmitDialogRef"
  89. @reload="reload"
  90. ></process-submit-dialog>
  91. </div>
  92. </template>
  93. <script>
  94. import processSubmitDialog from '@/BIZComponents/enventSubmitDialog/processSubmitDialog'
  95. import documentDialog from './components/documentDialog.vue';
  96. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  97. import { noticeDocumentPageV1API, noticeDocumentDeleteAPI, batchDeleteNotice, noticeStatusChange } from '@/api/documents/noticeIssuance/index.js';
  98. import {
  99. listOrganizations
  100. } from '@/api/system/organization';
  101. export default {
  102. mixins: [tableColumnsMixin],
  103. components: {
  104. documentDialog,
  105. processSubmitDialog
  106. },
  107. data() {
  108. return {
  109. organizationList: [],
  110. processSubmitDialogFlag: false,
  111. tabValue: '99',
  112. id: '',
  113. where: {},
  114. // 加载状态
  115. loading: false,
  116. urgencyLevelOp: [
  117. { label: '普通', value: '1' },
  118. { label: '紧急', value: '2' },
  119. { label: '特急', value: '3' }
  120. ],
  121. statusOpt: [
  122. { label: '待发布', value: '1' },
  123. { label: '已发布', value: '2' },
  124. { label: '作废', value: '3' }
  125. ],
  126. approvalStatusOp: [
  127. { label: '草稿', value: '0' },
  128. { label: '审核中', value: '1' },
  129. { label: '驳回', value: '3' },
  130. { label: '办结', value: '2' }
  131. ],
  132. selection: [],
  133. cacheKeyUrl: '7cc8e5d2-wt-noticeIssuance-index',
  134. columnsVersion: 0,
  135. tableHeight: 'calc(100vh - 375px)',
  136. };
  137. },
  138. computed: {
  139. // 表格列配置
  140. seekList() {
  141. return [
  142. {
  143. label: '标题:',
  144. value: 'title',
  145. type: 'input',
  146. placeholder: ''
  147. },
  148. {
  149. label: '发文字号:',
  150. value: 'docNumber',
  151. type: 'input',
  152. placeholder: '',
  153. labelWidth: 100
  154. },
  155. {
  156. label: '发文机关:',
  157. value: 'issuingAuthorityId',
  158. type: 'select',
  159. labelWidth: 100,
  160. planList: this.organizationList
  161. },
  162. {
  163. label: '紧急程度:',
  164. value: 'urgencyLevelId',
  165. type: 'select',
  166. width: 240,
  167. planList: this.urgencyLevelOp
  168. },
  169. ];
  170. },
  171. columns() {
  172. const num = this.columnsVersion;
  173. return [
  174. {
  175. width: 45,
  176. type: 'selection',
  177. columnKey: 'selection',
  178. align: 'center',
  179. fixed: 'left'
  180. },
  181. {
  182. columnKey: 'index',
  183. label: '序号',
  184. type: 'index',
  185. width: 55,
  186. align: 'center',
  187. showOverflowTooltip: true,
  188. fixed: 'left'
  189. },
  190. {
  191. prop: 'docNo',
  192. slot: 'docNo',
  193. label: '发文编码',
  194. align: 'center',
  195. minWidth: 130,
  196. showOverflowTooltip: true
  197. },
  198. {
  199. prop: 'title',
  200. label: '标题',
  201. align: 'center',
  202. minWidth: 110,
  203. showOverflowTooltip: true
  204. },
  205. {
  206. prop: 'docNumber',
  207. label: '发文字号',
  208. align: 'center',
  209. minWidth: 110,
  210. showOverflowTooltip: true
  211. },
  212. {
  213. prop: 'issuingAuthority',
  214. label: '发文机关',
  215. align: 'center',
  216. minWidth: 110,
  217. showOverflowTooltip: true
  218. },
  219. {
  220. prop: 'draftAuthor',
  221. label: '拟稿人',
  222. align: 'center',
  223. minWidth: 110,
  224. showOverflowTooltip: true
  225. },
  226. {
  227. prop: 'createTime',
  228. label: '拟稿日期',
  229. align: 'center',
  230. minWidth: 110,
  231. showOverflowTooltip: true
  232. },
  233. {
  234. prop: 'urgencyLevelId',
  235. label: '紧急程度',
  236. align: 'center',
  237. minWidth: 110,
  238. showOverflowTooltip: true,
  239. formatter: (row) => {
  240. const obj = this.urgencyLevelOp.find((i) => i.value == row.urgencyLevelId);
  241. return obj && obj.label;
  242. }
  243. },
  244. {
  245. prop: 'approvalStatus',
  246. label: '审批状态',
  247. align: 'center',
  248. minWidth: 110,
  249. showOverflowTooltip: true,
  250. formatter: (row) => {
  251. const obj = this.approvalStatusOp.find((i) => i.value == row.approvalStatus);
  252. return obj && obj.label;
  253. }
  254. },
  255. {
  256. prop: 'status',
  257. label: '发布状态',
  258. align: 'center',
  259. showOverflowTooltip: true,
  260. formatter: (row) => {
  261. const obj = this.statusOpt.find((i) => i.value == row.status);
  262. return obj && obj.label;
  263. }
  264. },
  265. {
  266. prop: 'action',
  267. label: '操作',
  268. align: 'center',
  269. slot: 'action',
  270. width: 180,
  271. showOverflowTooltip: true
  272. }
  273. ];
  274. },
  275. clientEnvironmentId() {
  276. return this.$store.state.user.info.clientEnvironmentId;
  277. }
  278. },
  279. watch: {
  280. },
  281. created() {
  282. this.getOrganizationList();
  283. },
  284. mounted() {
  285. // this.reload();
  286. },
  287. methods: {
  288. // 获取部门列表
  289. getOrganizationList() {
  290. listOrganizations()
  291. .then((list) => {
  292. let _list = list.filter((i) => i.name != '超级管理员');
  293. // 转换为树形结构
  294. this.organizationList = _list.map((i) => ({
  295. label: i.name,
  296. value: i.id
  297. }));
  298. })
  299. .catch((e) => {
  300. console.error('获取部门列表失败:', e);
  301. this.$message.error('获取部门列表失败');
  302. });
  303. },
  304. toSubmit(res) {
  305. this.processSubmitDialogFlag = true;
  306. this.$nextTick(() => {
  307. let params = {
  308. businessId: res.id,
  309. businessKey: 'fm_notice_document_approval',
  310. formCreateUserId: res.createUserId,
  311. variables: {
  312. businessCode: res.docNo,
  313. businessName: res.title,
  314. businessType: '通知公文'
  315. }
  316. };
  317. this.$refs.processSubmitDialogRef.init(params);
  318. });
  319. },
  320. toAdd() {
  321. this.$refs.documentDialogRef.open();
  322. },
  323. toEdit(type, row = {}) {
  324. this.current = row;
  325. this.$router.push({
  326. path: '/documents/noticeIssuance/add-or-edit',
  327. // query
  328. query: {
  329. id: this.current.id,
  330. type: type
  331. }
  332. });
  333. },
  334. toDel(row) {
  335. const loading = this.$loading({ lock: true });
  336. noticeDocumentDeleteAPI(row.id)
  337. .then((msg) => {
  338. loading.close();
  339. this.$message.success('操作成功');
  340. this.reload();
  341. })
  342. .catch((e) => {
  343. loading.close();
  344. // this.$message.error(e.message);
  345. });
  346. },
  347. handleSelectDone(list) {
  348. this.current = list[0];
  349. this.$router.push({
  350. path: '/documents/noticeIssuance/add-or-edit',
  351. // query
  352. query: {
  353. id: this.current.id,
  354. type: 'add'
  355. }
  356. });
  357. },
  358. toChangeStatus(row, status) {
  359. noticeStatusChange({id: row.id, status: status})
  360. .then((msg) => {
  361. this.$message.success('操作成功');
  362. this.reload();
  363. })
  364. .catch((e) => {
  365. this.$message.error(e.message);
  366. });
  367. },
  368. search(e) {
  369. this.reload(e);
  370. },
  371. handleTabClick() {
  372. this.reload();
  373. },
  374. toDelAll() {
  375. if (!this.selection.length) {
  376. return this.$message.warning('请至少选择一条通知!');
  377. }
  378. batchDeleteNotice({
  379. ids: this.selection.map((i) => i.id)
  380. }).then((res) => {
  381. if (res) {
  382. this.$message.success('删除成功');
  383. this.reload();
  384. }
  385. }).catch((err) => {
  386. this.$message.error(err.message);
  387. });
  388. },
  389. /* 表格数据源 */
  390. datasource({ page, limit, where, order }) {
  391. console.log(this.tabValue, '888');
  392. let params = {
  393. ...where,
  394. ...order,
  395. approvalStatus: this.tabValue == 99 ? '' : this.tabValue,
  396. pageNum: page,
  397. size: limit,
  398. };
  399. return noticeDocumentPageV1API({ ...params });
  400. },
  401. onSortChange(e) {
  402. let sort = {
  403. orderBy: e.order,
  404. sortName: e.prop
  405. };
  406. this.sort = sort;
  407. this.reload();
  408. },
  409. fullscreenChange(fullscreen) {
  410. if (fullscreen) {
  411. this.tableHeight = 'calc(100vh - 120px)';
  412. } else {
  413. this.tableHeight = 'calc(100vh - 375px)';
  414. }
  415. },
  416. /* 刷新表格 */
  417. reload(where = {}) {
  418. this.$nextTick(() => {
  419. this.$refs.table.reload({ page: 1, where, approvalStatus: this.tabValue == 99 ? '' : this.tabValue });
  420. });
  421. },
  422. printing() {
  423. // 检查是否有选中的数据
  424. if (!this.selection || this.selection.length === 0 || this.selection.length > 1) {
  425. this.$message.warning('请选择一条要打印的数据');
  426. return;
  427. }
  428. // 获取第一条选中的数据
  429. const row = this.selection[0];
  430. if (row.content) {
  431. // 打开打印窗口
  432. this.openPrintWindow(row.content);
  433. } else {
  434. this.$message.warning('选中的数据没有可打印的内容');
  435. }
  436. },
  437. // 打开打印窗口
  438. openPrintWindow(content) {
  439. // 创建新窗口
  440. const printWindow = window.open('', '_blank');
  441. if (!printWindow) {
  442. this.$message.error('请允许弹出窗口以进行打印');
  443. return;
  444. }
  445. // 构建打印页面的 HTML
  446. const printHtml = `
  447. <!DOCTYPE html>
  448. <html>
  449. <head>
  450. <meta charset="utf-8">
  451. <title>打印</title>
  452. <style>
  453. body {
  454. margin: 0;
  455. padding: 20px;
  456. font-family: 'SimSun', '宋体', serif;
  457. font-size: 16px;
  458. line-height: 1.8;
  459. }
  460. .print-content {
  461. max-width: 800px;
  462. margin: 0 auto;
  463. }
  464. @media print {
  465. body {
  466. padding: 0;
  467. }
  468. }
  469. </style>
  470. </head>
  471. <body>
  472. <div class="print-content">
  473. ${content}
  474. </div>
  475. <script>
  476. window.onload = function() {
  477. setTimeout(function() {
  478. window.print();
  479. }, 500);
  480. };
  481. <\/script>
  482. </body>
  483. </html>
  484. `;
  485. // 写入内容并打印
  486. printWindow.document.write(printHtml);
  487. printWindow.document.close();
  488. },
  489. }
  490. };
  491. </script>
  492. <style scoped>
  493. </style>