index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <seek-page
  5. :seekList="seekList"
  6. @search="search"
  7. ref="search"
  8. :keyValue="'qms-inspectionReport-index-search'"
  9. ></seek-page>
  10. <ele-pro-table
  11. ref="table"
  12. :columns="columns"
  13. :datasource="datasource"
  14. :pageSize="20"
  15. :pageSizes="[20, 30, 40, 50, 100]"
  16. @columns-change="handleColumnChange"
  17. :cache-key="cacheKeyUrl"
  18. row-key="id"
  19. @selection-change="selectionChangeHandle"
  20. >
  21. <!-- 表头工具栏 -->
  22. <template v-slot:toolbar>
  23. <!-- <el-button
  24. size="small"
  25. type="primary"
  26. class="ele-btn-icon"
  27. @click="batchClose"
  28. :disabled="selection.length === 0"
  29. >
  30. 批量关闭
  31. </el-button> -->
  32. </template>
  33. <template v-slot:reportNumber="{ row }">
  34. <el-link
  35. type="primary"
  36. :underline="false"
  37. @click="openDetails(row)"
  38. >{{ row.reportNumber }}</el-link
  39. >
  40. </template>
  41. <!-- 操作列 -->
  42. <template v-slot:action="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. v-if="
  47. (row.reportApprovalStatus == 0 ||
  48. row.reportApprovalStatus == 3) &&
  49. $hasPermission('qms:inspectionReport:update')
  50. "
  51. @click="openEdit(row)"
  52. >编辑</el-link
  53. >
  54. <el-link
  55. v-if="
  56. isReportApproval == 1 &&
  57. (row.reportApprovalStatus == 0 ||
  58. row.reportApprovalStatus == 3) &&
  59. $hasPermission('qms:inspectionReport:submit')
  60. "
  61. type="primary"
  62. :underline="false"
  63. @click="reportApprovalSubmit(row)"
  64. >提交</el-link
  65. >
  66. <el-popconfirm
  67. class="ele-action"
  68. title="确定要删除吗?"
  69. @confirm="deleteReportBtn(row)"
  70. v-if="
  71. (row.reportApprovalStatus == 0 ||
  72. row.reportApprovalStatus == 3) &&
  73. $hasPermission('qms:inspectionReport:delete')
  74. "
  75. >
  76. <template v-slot:reference>
  77. <el-link type="danger" :underline="false"> 删除 </el-link>
  78. </template>
  79. </el-popconfirm>
  80. </template>
  81. </ele-pro-table>
  82. </el-card>
  83. <component
  84. v-if="targetVisible"
  85. :is="targetComponent"
  86. :key="targetComponent"
  87. :isView="isView"
  88. :visible.sync="targetVisible"
  89. :row="currentRow"
  90. :item="currentItem"
  91. @reload="search"
  92. ></component>
  93. <process-submit-dialog
  94. api-fun-name="qmsReportApprovalAPI"
  95. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  96. :isCloseRefresh="false"
  97. v-if="processSubmitDialogFlag"
  98. ref="processSubmitDialogRef"
  99. @reload="search"
  100. ></process-submit-dialog>
  101. <QualityReportDetail
  102. ref="qualityReportDetailRef"
  103. :visible.sync="detailVisible"
  104. :row="currentRow"
  105. ></QualityReportDetail>
  106. </div>
  107. </template>
  108. <script>
  109. import search from './components/search.vue';
  110. import jimureportBrowse from '@/components/jimureport/browseModal.vue';
  111. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  112. import { closeWorkList } from '@/api/inspectionWork';
  113. import { queryTodo } from '@/api/bpm/task';
  114. import dictMixins from '@/mixins/dictMixins';
  115. import { getFile } from '@/api/system/file';
  116. import { parameterGetByCode } from '@/api/main/index';
  117. import tabMixins from '@/mixins/tableColumnsMixin';
  118. import { getCategoryByCode } from '@/api/main/index';
  119. import { getList, deleteReport } from '@/api/inspectionReport';
  120. import inspection_report1 from '../inspectionReport/template/inspection_report1.vue';
  121. import inspection_report2 from '../inspectionReport/template/inspection_report2.vue';
  122. import QualityReportDetail from '../inspectionReport/components/detailDialog.vue';
  123. import { recordingMethodList } from '@/utils/util.js';
  124. export default {
  125. mixins: [dictMixins, tabMixins],
  126. components: {
  127. search,
  128. jimureportBrowse,
  129. inspection_report1,
  130. inspection_report2,
  131. processSubmitDialog,
  132. QualityReportDetail
  133. },
  134. data() {
  135. return {
  136. cacheKeyUrl: 'qsm-c2e9664a-inspectionReport-index',
  137. targetComponent: null,
  138. targetVisible: false,
  139. detailVisible: false,
  140. isView: false,
  141. currentRow: {},
  142. currentItem: {},
  143. columns: [
  144. // 新增多选列
  145. {
  146. width: 45,
  147. type: 'selection',
  148. columnKey: 'selection',
  149. align: 'center',
  150. reserveSelection: true
  151. },
  152. {
  153. type: 'index',
  154. columnKey: 'index',
  155. align: 'center',
  156. label: '序号',
  157. width: 55,
  158. showOverflowTooltip: true,
  159. fixed: 'left'
  160. },
  161. {
  162. prop: 'reportNumber',
  163. label: '报告编码',
  164. slot: 'reportNumber',
  165. align: 'center',
  166. width: 180,
  167. showOverflowTooltip: true,
  168. fixed: 'left'
  169. },
  170. {
  171. prop: 'code',
  172. label: '检测工单编码',
  173. // slot: 'code',
  174. align: 'center',
  175. width: 180,
  176. showOverflowTooltip: true
  177. },
  178. {
  179. prop: 'productCode',
  180. width: 120,
  181. label: '产品编码',
  182. align: 'center',
  183. showOverflowTooltip: true
  184. },
  185. {
  186. prop: 'productName',
  187. width: 120,
  188. label: '产品名称',
  189. align: 'center',
  190. showOverflowTooltip: true
  191. },
  192. {
  193. prop: 'specification',
  194. label: '规格',
  195. align: 'center',
  196. showOverflowTooltip: true
  197. },
  198. {
  199. prop: 'brandNo',
  200. label: '牌号',
  201. align: 'center',
  202. showOverflowTooltip: true
  203. },
  204. {
  205. prop: 'recordingMethod',
  206. label: '记录方法',
  207. align: 'center',
  208. formatter: (row) => {
  209. return (
  210. recordingMethodList.find(
  211. (item) => item.value == row.recordingMethod
  212. )?.label || ''
  213. );
  214. },
  215. width: 130,
  216. showOverflowTooltip: true
  217. },
  218. {
  219. label: '创建时间',
  220. prop: 'reportDate',
  221. align: 'center',
  222. width: 160
  223. },
  224. {
  225. label: '创建人',
  226. prop: 'reportTemplateCreateUserName',
  227. align: 'center',
  228. width: 160
  229. },
  230. {
  231. label: '审批时间',
  232. prop: 'reportApprovalTime',
  233. align: 'center',
  234. width: 160
  235. },
  236. {
  237. label: '审批人',
  238. prop: 'reportApprovalUserName',
  239. align: 'center',
  240. width: 160
  241. },
  242. {
  243. prop: 'reportApprovalStatus',
  244. label: '审批状态',
  245. align: 'center',
  246. width: 80,
  247. formatter: (row, column, cellValue) => {
  248. switch (cellValue) {
  249. case 0:
  250. return '未提交';
  251. case 1:
  252. return '审核中';
  253. case 2:
  254. return '已审核';
  255. case 3:
  256. return '审核不通过';
  257. case 7:
  258. return '作废';
  259. default:
  260. return '';
  261. }
  262. }
  263. },
  264. {
  265. columnKey: 'action',
  266. label: '操作',
  267. align: 'center',
  268. width: 200,
  269. resizable: false,
  270. slot: 'action',
  271. fixed: 'right'
  272. }
  273. ],
  274. formData: {
  275. certificateNumber: ''
  276. },
  277. processSubmitDialogFlag: false,
  278. rowData: {},
  279. typeList: [], //类型列表
  280. qualityMode: [], //取样类型
  281. statusList: [
  282. { value: 0, label: '未提交' },
  283. { value: 1, label: '审核中' },
  284. { value: 2, label: '已审核' },
  285. { value: 3, label: '审核不通过' },
  286. { value: 7, label: '作废' }
  287. ],
  288. addOpen: false,
  289. transferVisible: false,
  290. transferId: '',
  291. isReportApproval: 0,
  292. selection: [] // 存储选中的行数据
  293. };
  294. },
  295. created() {
  296. this.getCode();
  297. },
  298. computed: {
  299. seekList() {
  300. return [
  301. {
  302. label: '报告编码:',
  303. value: 'reportNumber',
  304. type: 'input',
  305. placeholder: ''
  306. },
  307. {
  308. label: '工单编码:',
  309. value: 'code',
  310. type: 'input',
  311. placeholder: ''
  312. },
  313. {
  314. label: '工单名称:',
  315. value: 'name',
  316. type: 'input',
  317. placeholder: ''
  318. },
  319. {
  320. label: '产品编码:',
  321. value: 'productCode',
  322. type: 'input',
  323. placeholder: ''
  324. },
  325. {
  326. label: '产品名称:',
  327. value: 'productName',
  328. type: 'input',
  329. placeholder: ''
  330. },
  331. {
  332. label: '型号:',
  333. value: 'modelType',
  334. type: 'input',
  335. placeholder: ''
  336. },
  337. {
  338. label: '规格:',
  339. value: 'specification',
  340. type: 'input',
  341. placeholder: ''
  342. },
  343. {
  344. label: '牌号:',
  345. value: 'brandNo',
  346. type: 'input',
  347. placeholder: ''
  348. },
  349. {
  350. label: '审批状态:',
  351. value: 'reportApprovalStatus',
  352. type: 'select',
  353. placeholder: '',
  354. planList: this.statusList
  355. },
  356. {
  357. label: '记录方法:',
  358. value: 'recordingMethod',
  359. type: 'select',
  360. placeholder: '',
  361. planList: recordingMethodList
  362. }
  363. ];
  364. },
  365. clientEnvironmentId() {
  366. return this.$store.state.user.info.clientEnvironmentId;
  367. }
  368. },
  369. methods: {
  370. selectionChangeHandle(val) {
  371. this.selection = val;
  372. },
  373. addSampleOpen(row) {
  374. this.$refs.addSampleRef.open(row);
  375. },
  376. // 批量关闭
  377. batchClose() {
  378. const validRows = this.selection.filter(
  379. (row) => row.status === 0 && row.qualityType === 2
  380. );
  381. if (validRows.length === 0) {
  382. this.$message.warning('所选工单中没有可关闭的工单');
  383. return;
  384. }
  385. this.$confirm(`确定关闭选中的 ${validRows.length} 个工单吗?`, '提示', {
  386. confirmButtonText: '确定',
  387. cancelButtonText: '取消',
  388. type: 'warning'
  389. }).then(async () => {
  390. try {
  391. await closeWorkList(validRows.map((row) => row.id));
  392. this.$refs.table.clearSelection();
  393. this.search();
  394. } catch (err) {
  395. this.$message.error('批量关闭失败:' + (err.message || '操作异常'));
  396. }
  397. });
  398. },
  399. reportApprovalSubmit(res) {
  400. this.processSubmitDialogFlag = true;
  401. this.$nextTick(async () => {
  402. let params = {
  403. businessId: res.id,
  404. businessKey: 'qms_report_approval',
  405. formCreateUserId: res.createUserId,
  406. variables: {
  407. businessCode: res.code,
  408. businessName: res.reportNumber,
  409. businessType: '检测报告单'
  410. }
  411. };
  412. if (this.clientEnvironmentId == 5) {
  413. const data = await getCategoryByCode(res.productCode);
  414. if (data && data.categoryLevelCodePath?.includes('W3-209')) {
  415. params.businessKey = 'qms_report_approval1';
  416. } else {
  417. params.businessKey = 'qms_report_approval';
  418. }
  419. }
  420. this.$refs.processSubmitDialogRef.init(params);
  421. });
  422. },
  423. getCode() {
  424. parameterGetByCode({
  425. code: 'qms_report_approval'
  426. }).then((res) => {
  427. this.isReportApproval = res.value;
  428. });
  429. },
  430. async datasource({ page, where, limit }) {
  431. try {
  432. await queryTodo({});
  433. } catch (err) {
  434. console.error('调用queryTodo失败:', err);
  435. }
  436. return getList({
  437. ...where,
  438. pageNum: page,
  439. size: limit
  440. });
  441. },
  442. search(where) {
  443. this.$refs.table.reload({
  444. where: where
  445. // page: 1
  446. });
  447. },
  448. async openEdit(row) {
  449. console.log(row);
  450. this.isView = false;
  451. this.targetComponent = row.reportTemplateCode;
  452. this.currentRow = row;
  453. this.$nextTick(() => {
  454. this.targetVisible = true;
  455. });
  456. },
  457. openDetails(row) {
  458. this.isView = true;
  459. this.currentRow = row;
  460. this.targetComponent = row.reportTemplateCode;
  461. console.log('currentRow', this.currentRow, this.targetComponent);
  462. this.$nextTick(() => {
  463. this.targetVisible = true;
  464. console.log('targetVisible~~~~', this.targetVisible);
  465. });
  466. },
  467. async deleteReportBtn(row) {
  468. try {
  469. await deleteReport(row.id);
  470. this.$message.success('删除成功');
  471. this.done();
  472. } catch (err) {
  473. // this.$message.error('删除失败:' + (err.message || '操作异常'));
  474. }
  475. },
  476. downloadFile(file) {
  477. getFile({ objectName: file.storePath }, file.name);
  478. },
  479. done() {
  480. this.$refs.search.search();
  481. }
  482. }
  483. };
  484. </script>