inspectionProjectTaskSend.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <template>
  2. <ele-modal
  3. width="70%"
  4. :append-to-body="true"
  5. :close-on-click-modal="false"
  6. custom-class="ele-dialog-form"
  7. :title="type == 1 ? '检测派单' : '检测请托'"
  8. :visible.sync="visible"
  9. :maxable="true"
  10. @close="cancel"
  11. >
  12. <header-title
  13. :title="recordingMethod == 1 ? '检测项信息' : '样品信息'"
  14. ></header-title>
  15. <ele-pro-table
  16. :needPage="false"
  17. :columns="tableColumns"
  18. :datasource="list"
  19. :selection.sync="selection"
  20. rowKey="id"
  21. ref="table"
  22. ></ele-pro-table>
  23. <header-title title="派单信息"></header-title>
  24. <el-form
  25. ref="form"
  26. :model="form"
  27. :rules="rules"
  28. class="el-form-box"
  29. label-width="120px"
  30. >
  31. <el-row>
  32. <el-col :span="8">
  33. <el-form-item label="工单记录方法:" prop="recordingMethod">
  34. <el-select
  35. style="width: 100%"
  36. v-model="recordingMethod"
  37. placeholder="请选择"
  38. :disabled="isDisabled"
  39. @change="recordingMethodChange"
  40. >
  41. <el-option
  42. v-for="item in recordingMethodList"
  43. :label="item.label"
  44. :value="item.value"
  45. :key="item.value"
  46. ></el-option>
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="8" v-if="recordingMethod == 1">
  51. <el-form-item label="任务记录方法:" prop="recordingMethod1">
  52. <el-select
  53. style="width: 100%"
  54. v-model="recordingMethod1"
  55. placeholder="请选择"
  56. >
  57. <el-option
  58. v-for="item in recordingMethodList"
  59. :label="item.label"
  60. :value="item.value"
  61. :key="item.value"
  62. ></el-option>
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. <el-row>
  68. <el-col :span="8">
  69. <el-form-item
  70. :label="type == 1 ? '任务单号' : '检测请托单号'"
  71. prop="code"
  72. >
  73. <el-input
  74. v-model="form.code"
  75. placeholder=" "
  76. disabled
  77. ></el-input> </el-form-item
  78. ></el-col>
  79. <el-col :span="8">
  80. <el-form-item label="任务名称" prop="name">
  81. <el-input
  82. v-model="form.name"
  83. placeholder="请输入"
  84. ></el-input> </el-form-item></el-col
  85. ></el-row>
  86. <el-row v-if="type == 1">
  87. <el-col :span="8">
  88. <el-form-item label="执行部门" prop="executeDeptId">
  89. <deptSelect
  90. v-model="form.executeDeptId"
  91. @changeGroup="searchDeptNodeClick"
  92. filterable
  93. company-scope
  94. /> </el-form-item
  95. ></el-col>
  96. <el-col :span="8">
  97. <el-form-item label="执行人" prop="executeUserId">
  98. <userSelect
  99. v-model="form.executeUserId"
  100. :group-id="form.executeDeptId"
  101. :label="form.executeUserName"
  102. @change="changeExecutor"
  103. :placeholder="form.executeDeptId ? '请选择人员' : '请先选择部门'"
  104. /> </el-form-item></el-col
  105. ></el-row>
  106. <el-row v-else>
  107. <el-col :span="8">
  108. <el-form-item label="接收部门" prop="receiveDeptId">
  109. <deptSelect
  110. v-model="form.receiveDeptId"
  111. @changeGroup="searchDeptNodeClick"
  112. ref="deptSelect"
  113. filterable
  114. company-scope
  115. /> </el-form-item
  116. ></el-col>
  117. <el-col :span="8">
  118. <el-form-item label="接收人" prop="receiveUserId">
  119. <userSelect
  120. v-model="form.receiveUserId"
  121. :group-id="form.receiveDeptId"
  122. :label="form.receiveUserName"
  123. @change="changeExecutor"
  124. :placeholder="form.receiveDeptId ? '请选择人员' : '请先选择部门'"
  125. /> </el-form-item></el-col
  126. ></el-row>
  127. <el-row>
  128. <el-col :span="8">
  129. <el-form-item label="要求完成时间" prop="requiredCompletionTime">
  130. <el-date-picker
  131. v-model="form.requiredCompletionTime"
  132. style="width: 100%"
  133. type="datetime"
  134. value-format="yyyy-MM-dd HH:mm:ss"
  135. placeholder=" "
  136. >
  137. </el-date-picker> </el-form-item
  138. ></el-col>
  139. </el-row>
  140. </el-form>
  141. <template v-slot:footer>
  142. <el-button @click="cancel">取消</el-button>
  143. <el-button type="primary" :loading="loading" @click="save">
  144. 确认
  145. </el-button>
  146. </template>
  147. </ele-modal>
  148. </template>
  149. <script>
  150. import {
  151. qualityInspectionItemDispatching,
  152. qualityInspectionItemRequest
  153. } from '@/api/inspectionProjectTask';
  154. import { getById, updateRecordingMethod } from '@/api/inspectionWork';
  155. import {
  156. getById as getQualityInspectionItemById,
  157. updateRequestentrust
  158. } from '@/api/inspectionProjectRequest';
  159. import { inspectionProjectStatus } from '@/enum/dict.js';
  160. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  161. import userSelect from '@/components/CommomSelect/user-select.vue';
  162. import { recordingMethodList } from '@/utils/util.js';
  163. import { getCode } from '@/api/login/index.js';
  164. const defaultForm = {
  165. id: null,
  166. executeDeptId: '',
  167. executeDeptName: '',
  168. executeUserId: '',
  169. executeUserName: '',
  170. receiveUserId: '',
  171. receiveUserName: '',
  172. name: '',
  173. code: '',
  174. qualityWorkOrderId: '',
  175. requiredCompletionTime: '',
  176. type: 1
  177. };
  178. export default {
  179. components: { deptSelect, userSelect },
  180. data() {
  181. return {
  182. type: 1,
  183. recordingMethodList,
  184. pgaeName: '',
  185. form: { ...defaultForm },
  186. selection: [],
  187. list: [],
  188. templateLis: [],
  189. qualitySampleList: [],
  190. rules: {
  191. executeDeptId: [
  192. { required: true, message: '请选择部门', trigger: 'blur' }
  193. ],
  194. executeUserId: [
  195. { required: true, message: '请选择人员', trigger: 'blur' }
  196. ],
  197. receiveDeptId: [
  198. { required: true, message: '请选择部门', trigger: 'blur' }
  199. ],
  200. // receiveUserId: [
  201. // { required: true, message: '请选择人员', trigger: 'blur' }
  202. // ],
  203. name: [
  204. { required: true, message: '请输入任务名称', trigger: 'blur' }
  205. ],
  206. requiredCompletionTime: [
  207. { required: true, message: '请输入要求完成日期', trigger: 'blur' }
  208. ]
  209. },
  210. templateIdS: [],
  211. loading: false,
  212. visible: false,
  213. clientEnvironmentId: 0,
  214. recordingMethod: 1,
  215. recordingMethod1: 1
  216. };
  217. },
  218. computed: {
  219. isDisabled() {
  220. if (
  221. this.isUpdate == 1 ||
  222. this.list.filter((item) => item.status != 0).length
  223. ) {
  224. return true;
  225. }
  226. return false;
  227. },
  228. tableColumns() {
  229. return this.recordingMethod == 1
  230. ? [
  231. {
  232. width: 45,
  233. type: 'index',
  234. columnKey: 'index',
  235. align: 'center',
  236. fixed: 'left'
  237. },
  238. {
  239. width: 45,
  240. type: 'selection',
  241. columnKey: 'selection',
  242. align: 'center',
  243. selectable: (row, index) => {
  244. return row.status == 0 || this.templateIdS.includes(row.id);
  245. }
  246. },
  247. {
  248. minWidth: 150,
  249. prop: 'qualitySchemeTemplateCode',
  250. align: 'center',
  251. label: '检测方案编码',
  252. showOverflowTooltip: true
  253. },
  254. {
  255. minWidth: 120,
  256. prop: 'qualitySchemeTemplateName',
  257. align: 'center',
  258. label: '检测方案名称',
  259. showOverflowTooltip: true
  260. },
  261. {
  262. minWidth: 100,
  263. prop: 'categoryLevelClassName',
  264. align: 'center',
  265. label: '检测类型',
  266. showOverflowTooltip: true
  267. },
  268. {
  269. minWidth: 130,
  270. prop: 'inspectionCode',
  271. align: 'center',
  272. label: '检测项编码',
  273. showOverflowTooltip: true
  274. },
  275. {
  276. minWidth: 120,
  277. prop: 'inspectionName',
  278. align: 'center',
  279. label: '检测项名称',
  280. showOverflowTooltip: true
  281. },
  282. {
  283. minWidth: 150,
  284. prop: 'defaultValue',
  285. align: 'center',
  286. label: '工艺参数',
  287. showOverflowTooltip: true
  288. },
  289. {
  290. minWidth: 150,
  291. prop: 'status',
  292. align: 'center',
  293. formatter: (row) => {
  294. return (
  295. inspectionProjectStatus.find(
  296. (item) => item.value === row.status
  297. )?.label || ''
  298. );
  299. },
  300. label: '状态',
  301. showOverflowTooltip: true
  302. }
  303. ]
  304. : [
  305. {
  306. width: 45,
  307. type: 'index',
  308. columnKey: 'index',
  309. align: 'center',
  310. fixed: 'left'
  311. },
  312. {
  313. width: 45,
  314. type: 'selection',
  315. columnKey: 'selection',
  316. fixed: 'left',
  317. align: 'center',
  318. selectable: (row, index) => {
  319. return row.status == 0 || this.templateIdS.includes(row.id);
  320. }
  321. },
  322. {
  323. label: '样品编码',
  324. prop: 'sampleCode',
  325. minWidth: '200',
  326. align: 'center',
  327. fixed: 'left'
  328. },
  329. {
  330. label: '编码',
  331. minWidth: '200',
  332. prop: 'categoryCode',
  333. align: 'center',
  334. fixed: 'left'
  335. },
  336. {
  337. label: '名称',
  338. minWidth: '150',
  339. prop: 'categoryName',
  340. align: 'center'
  341. },
  342. {
  343. label: '批次号',
  344. minWidth: '150',
  345. prop: 'batchNo',
  346. align: 'center'
  347. },
  348. {
  349. label: '发货条码',
  350. minWidth: '150',
  351. prop: 'barcodes',
  352. align: 'center'
  353. },
  354. {
  355. label: '包装编码',
  356. minWidth: '150',
  357. prop: 'packageNo',
  358. align: 'center'
  359. },
  360. {
  361. label: '包装数量',
  362. minWidth: '150',
  363. prop: 'packingQuantity',
  364. align: 'center'
  365. },
  366. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  367. { label: '样品数量', prop: 'measureQuantity', align: 'center' },
  368. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  369. {
  370. label: '供应商名称',
  371. prop: 'supplierName',
  372. align: 'center',
  373. width: '120'
  374. },
  375. {
  376. label: '供应商代号',
  377. prop: 'supplierCode',
  378. align: 'center',
  379. width: '120'
  380. },
  381. {
  382. label: '物料代号',
  383. prop: 'materielDesignation',
  384. align: 'center',
  385. slot: 'materielDesignation',
  386. width: '120'
  387. },
  388. {
  389. label: '客户代号',
  390. prop: 'clientCode',
  391. align: 'center',
  392. slot: 'clientCode',
  393. width: '120'
  394. },
  395. {
  396. label: '刻码',
  397. prop: 'engrave',
  398. align: 'center',
  399. slot: 'engrave',
  400. width: '120'
  401. },
  402. {
  403. label: '机型',
  404. prop: 'modelKey',
  405. align: 'center',
  406. showOverflowTooltip: true
  407. },
  408. {
  409. label: '颜色',
  410. prop: 'colorKey',
  411. align: 'center',
  412. showOverflowTooltip: true
  413. },
  414. {
  415. label: '型号',
  416. prop: 'modelType',
  417. align: 'center',
  418. showOverflowTooltip: true
  419. },
  420. {
  421. label: '规格',
  422. prop: 'specification',
  423. align: 'center',
  424. showOverflowTooltip: true
  425. },
  426. {
  427. label: '电压等级',
  428. prop: 'voltage',
  429. align: 'center',
  430. showOverflowTooltip: true
  431. },
  432. {
  433. label: '重量',
  434. prop: 'weight',
  435. align: 'center',
  436. slot: 'weight',
  437. width: '120'
  438. },
  439. {
  440. label: '重量单位',
  441. prop: 'weightUnit',
  442. align: 'center',
  443. width: 100
  444. },
  445. {
  446. label: '仓库',
  447. prop: 'warehouseName',
  448. align: 'center',
  449. width: 100
  450. },
  451. { label: '货区', prop: 'areaName', align: 'center' },
  452. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  453. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  454. { label: '生产日期', prop: 'productionDate', align: 'center' },
  455. { label: '采购日期', prop: 'purchaseDate', align: 'center' },
  456. {
  457. minWidth: 150,
  458. prop: 'status',
  459. align: 'center',
  460. formatter: (row) => {
  461. return (
  462. inspectionProjectStatus.find(
  463. (item) => item.value === row.status
  464. )?.label || ''
  465. );
  466. },
  467. label: '状态',
  468. fixed: 'right',
  469. showOverflowTooltip: true
  470. }
  471. ];
  472. }
  473. },
  474. created() {},
  475. methods: {
  476. async open(row, type, pgaeName) {
  477. this.recordingMethod = row.recordingMethod;
  478. this.clientEnvironmentId =
  479. this.$store.state.user.info.clientEnvironmentId;
  480. this.type = type;
  481. this.pgaeName = pgaeName;
  482. this.visible = true;
  483. this.templateIdS = [];
  484. if (pgaeName == 'inspectionProjectRequest') {
  485. this.form = await getQualityInspectionItemById(row.id);
  486. const list =
  487. row.recordingMethod == 1
  488. ? this.form.templateList
  489. : this.form.sampleList;
  490. if (list.length) {
  491. this.templateIdS = list.map((item) => item.id);
  492. }
  493. } else {
  494. this.form.qualityWorkOrderId = row.id;
  495. if (this.type == 2 && this.clientEnvironmentId == 9) {
  496. this.$nextTick(() => {
  497. this.$refs.deptSelect?.locateByName('BM1801');
  498. });
  499. }
  500. }
  501. //获取工单检测方案
  502. await getById(this.form.qualityWorkOrderId).then(async (res) => {
  503. this.templateList = res.data.templateList;
  504. this.qualitySampleList = res.data.qualitySampleList;
  505. if (!this.form.name) {
  506. this.form.name = this.qualitySampleList[0].categoryName+ await getCode('inspection_project_task_name');
  507. }
  508. this.recordingMethodChange();
  509. this.$nextTick(() => {
  510. this.$refs.table.setSelectedRowKeys(this.templateIdS);
  511. });
  512. });
  513. },
  514. recordingMethodChange() {
  515. this.list =
  516. this.recordingMethod == 1
  517. ? this.templateList
  518. : this.qualitySampleList;
  519. },
  520. searchDeptNodeClick(info, row) {
  521. let depKey = this.type == 1 ? 'executeDeptId' : 'receiveDeptId';
  522. let depNameKey = this.type == 1 ? 'executeDeptName' : 'receiveDeptName';
  523. let userKey = this.type == 1 ? 'executeUserId' : 'receiveUserId';
  524. let userNameKey =
  525. this.type == 1 ? 'executeUserName' : 'receiveUserName';
  526. if (info) {
  527. this.form[depKey] = info;
  528. this.form[depNameKey] = row.name;
  529. } else {
  530. this.form[depKey] = null;
  531. this.form[depNameKey] = null;
  532. }
  533. // 部门变化后人员范围变化,清空已选人员
  534. this.form[userKey] = null;
  535. this.form[userNameKey] = null;
  536. },
  537. // 选中/清空人员
  538. changeExecutor(user) {
  539. let userKey = this.type == 1 ? 'executeUserId' : 'receiveUserId';
  540. let userNameKey =
  541. this.type == 1 ? 'executeUserName' : 'receiveUserName';
  542. if (user) {
  543. this.form[userKey] = user.id;
  544. this.form[userNameKey] = user.name;
  545. } else {
  546. this.form[userKey] = null;
  547. this.form[userNameKey] = null;
  548. }
  549. },
  550. save() {
  551. this.$refs.form.validate((valid) => {
  552. if (!valid) {
  553. return false;
  554. }
  555. if (this.selection.length == 0) {
  556. return this.$message.warning('请至少选择一条数据');
  557. }
  558. this.loading = true;
  559. let api =
  560. this.type == 1
  561. ? qualityInspectionItemDispatching
  562. : this.type == 2
  563. ? this.pgaeName == 'inspectionProjectRequest'
  564. ? updateRequestentrust
  565. : qualityInspectionItemRequest
  566. : '';
  567. if (this.recordingMethod == 2) {
  568. this.form.sampleQuantity = this.selection
  569. .map((item) => item.measureQuantity)
  570. .reduce((a, b) => a + Number(b), 0);
  571. }
  572. let data = {
  573. ...this.form,
  574. recordingMethod: this.recordingMethod,
  575. detailList: this.selection.map((item) => {
  576. return {
  577. [this.recordingMethod == 1
  578. ? 'qualityPlanTemplateId'
  579. : 'sampleId']: item.id
  580. };
  581. })
  582. };
  583. if (this.recordingMethod == 1 && this.recordingMethod1 == 2) {
  584. data.recordingMethodList = this.qualitySampleList.map((item) => {
  585. return {
  586. sampleId: item.id
  587. };
  588. });
  589. }
  590. api(data)
  591. .then((msg) => {
  592. this.loading = false;
  593. updateRecordingMethod({
  594. id: this.form.qualityWorkOrderId,
  595. recordingMethod: this.recordingMethod
  596. });
  597. this.$emit('reload');
  598. this.cancel();
  599. })
  600. .catch((e) => {
  601. this.loading = false;
  602. });
  603. });
  604. },
  605. cancel() {
  606. this.visible = false;
  607. this.$refs.form.clearValidate();
  608. this.form = { ...defaultForm };
  609. this.list = [];
  610. }
  611. }
  612. };
  613. </script>
  614. <style lang="scss" scoped></style>