releaseRulesDialog.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <ele-modal
  3. width="80%"
  4. :visible="visible"
  5. append-to-body
  6. custom-class="ele-dialog-form"
  7. :title="title"
  8. :close-on-click-modal="false"
  9. :before-close="handleBeforeClose"
  10. maxable
  11. >
  12. <header-title title="基本信息"></header-title>
  13. <el-form
  14. :model="addForm"
  15. :rules="formRules"
  16. ref="ruleFormRef"
  17. label-width="150px"
  18. v-loading="loading"
  19. >
  20. <el-row>
  21. <el-col :span="8">
  22. <el-form-item label="记录规则名称" required>
  23. <el-input
  24. v-model="addForm.ruleName"
  25. size="small"
  26. placeholder="自动带出"
  27. disabled
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8">
  32. <el-form-item label="记录规则分类" required>
  33. <DictSelection
  34. dictName="记录规则类型"
  35. clearable
  36. v-model="addForm.recordRulesClassify"
  37. disabled
  38. >
  39. </DictSelection>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="8">
  43. <el-form-item
  44. v-if="ruleInfo && ruleInfo.classify == 3"
  45. label="关联设备"
  46. >
  47. <el-input
  48. v-model="addForm.deviceName"
  49. size="small"
  50. placeholder="自动带出"
  51. disabled
  52. ></el-input>
  53. </el-form-item>
  54. <el-form-item v-else label="车间区域" prop="workshopArea">
  55. <el-input
  56. v-model="addForm.workshopArea"
  57. size="small"
  58. placeholder="请输入"
  59. ></el-input>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="8">
  63. <el-form-item label="检查完成时间" required prop="checkFinishTime">
  64. <el-date-picker
  65. v-model="addForm.checkFinishTime"
  66. type="datetime"
  67. format="yyyy-MM-dd HH:mm:ss"
  68. value-format="yyyy-MM-dd HH:mm:ss"
  69. placeholder="选择日期"
  70. style="width: 100%"
  71. >
  72. </el-date-picker>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="8">
  76. <el-form-item label="检查有效期" required prop="checkValidity">
  77. <el-input
  78. placeholder="请输入"
  79. v-model="addForm.checkValidity"
  80. type="text"
  81. >
  82. <template slot="append">
  83. <div style="width: 40px; box-sizing: border-box">
  84. <el-form-item required prop="checkValidityUnit">
  85. <DictSelection
  86. dictName="检查有效期单位"
  87. clearable
  88. v-model="addForm.checkValidityUnit"
  89. placeholder="单位"
  90. style="width: auto"
  91. >
  92. </DictSelection>
  93. </el-form-item>
  94. </div>
  95. </template>
  96. </el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="8">
  100. <el-form-item label="结论" required prop="conclution">
  101. <el-radio-group v-model="addForm.conclution">
  102. <el-radio :label="1">合格</el-radio>
  103. <el-radio :label="2">不合格</el-radio>
  104. </el-radio-group>
  105. </el-form-item>
  106. </el-col>
  107. </el-row>
  108. </el-form>
  109. <header-title title="检查项目"></header-title>
  110. <!-- 表格 -->
  111. <el-table v-loading="loading" :data="addForm.details" style="width: 100%">
  112. <el-table-column type="index" label="序号" width="50"> </el-table-column>
  113. <el-table-column label="检查内容">
  114. <template slot-scope="scope">
  115. <div>
  116. {{ scope.row.paramValue }}
  117. </div>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="检查工具">
  121. <template slot-scope="scope">
  122. <div>
  123. {{ scope.row.toolNames }}
  124. </div>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="检查人">
  128. <template slot-scope="scope">
  129. <div
  130. @click="openSelectUser(scope.row)"
  131. style="display: flex; align-items: center; cursor: pointer"
  132. >
  133. <div>{{ showCheckUserNames(scope.row.checkUsers) }}</div
  134. ><i class="el-icon-caret-bottom"></i>
  135. </div>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="检查情况">
  139. <template slot-scope="scope">
  140. <div>
  141. <div>
  142. <el-input
  143. v-if="ruleInfo && ruleInfo.classify == 3"
  144. type="textarea"
  145. :rows="1"
  146. v-model="scope.row.checkStatusDesc"
  147. ></el-input>
  148. <el-radio-group v-else v-model="scope.row.checkStatus">
  149. <el-radio :label="1">已检查</el-radio>
  150. <el-radio :label="0">未检查</el-radio>
  151. </el-radio-group>
  152. </div>
  153. </div>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="检查结果">
  157. <template slot-scope="scope">
  158. <div>
  159. <el-radio-group v-model="scope.row.checkResult">
  160. <el-radio :label="1">合格</el-radio>
  161. <el-radio :label="0">不合格</el-radio>
  162. </el-radio-group>
  163. </div>
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="异常描述">
  167. <template slot-scope="scope">
  168. <div>
  169. <el-input
  170. type="textarea"
  171. :rows="1"
  172. placeholder="请输入"
  173. v-model="scope.row.errorMsg"
  174. >
  175. </el-input>
  176. </div>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. <!-- 底部按钮 -->
  181. <template #footer>
  182. <div class="modal-footer">
  183. <el-button
  184. v-if="$hasPermission('mes:producetaskrecordrulesrecord:sus')"
  185. :loading="butLoading"
  186. type="primary"
  187. @click="submit('submit')"
  188. :disabled="productionInfo && productionInfo.executeStatus == 2"
  189. >
  190. 一键报工
  191. </el-button>
  192. <template
  193. v-if="$hasPermission('mes:producetaskrecordrulesrecord:logicdelete')"
  194. >
  195. <el-popconfirm
  196. v-if="
  197. productionInfo &&
  198. productionInfo.recordId != null &&
  199. productionInfo.executeStatus == 1
  200. "
  201. title="您确定要清空缓存吗?"
  202. @confirm="clearCache"
  203. >
  204. <el-button slot="reference" :loading="butLoading" type="primary">
  205. 清空缓存
  206. </el-button>
  207. </el-popconfirm>
  208. </template>
  209. <el-button
  210. v-if="$hasPermission('mes:producetaskrecordrulesrecord:saveorupdate')"
  211. :loading="butLoading"
  212. type="primary"
  213. @click="submit('cache')"
  214. :disabled="productionInfo && productionInfo.executeStatus == 2"
  215. >
  216. 缓存
  217. </el-button>
  218. <el-button
  219. v-if="productionInfo && productionInfo.executeStatus == 2"
  220. @click="handleBeforeClose"
  221. >
  222. 关闭
  223. </el-button>
  224. </div>
  225. </template>
  226. <!-- 选择用户 -->
  227. <SelectUser
  228. ref="SelectUserRef"
  229. v-model="showSelectUser"
  230. multipleSelect
  231. @selectUserFinished="selectUserFinished"
  232. ></SelectUser>
  233. </ele-modal>
  234. </template>
  235. <script>
  236. import { submit } from '@/api/entrust';
  237. import {
  238. recordRulesDetailPage,
  239. getRecordRulesDetail
  240. } from '@/api/recordRules/index.js';
  241. import DictSelection from '@/components/Dict/DictSelection.vue';
  242. import SelectUser from '@/components/select/SelectUser/index.vue';
  243. import {
  244. saveOrUpdateAndSubmit,
  245. saveOrUpdate,
  246. logicDelete,
  247. getById
  248. } from '@/api/producetaskrecordrulesrecord/index';
  249. import { tempSaveOrUpdateAndSubmit } from '@/api/producetaskrulerecord/index.js';
  250. export default {
  251. components: { SelectUser },
  252. emits: ['reload'],
  253. props: {
  254. isTempRecord: {
  255. type: Number,
  256. default: 0
  257. }
  258. },
  259. data() {
  260. const formDate = {
  261. id: null,
  262. workshopArea: '',
  263. checkFinishTime: '',
  264. checkValidity: null,
  265. checkValidityUnit: '',
  266. conclution: null,
  267. isTempRecord: this.isTempRecord,
  268. details: [],
  269. deviceId: 0,
  270. deviceName: '',
  271. batchNo: '',
  272. executeMethod: 0,
  273. formingNum: 0,
  274. itemType: 0,
  275. produceRoutingId: 0,
  276. produceRoutingName: '',
  277. produceTaskConfigId: 0,
  278. produceTaskId: 0,
  279. productCode: '',
  280. productModel: '',
  281. productName: '',
  282. recordRulesClassify: null,
  283. ruleId: 0,
  284. ruleName: '',
  285. reportWorkType: 0,
  286. specification: '',
  287. workOrderCode: '',
  288. workOrderId: 0
  289. };
  290. return {
  291. visible: false,
  292. formDate,
  293. addForm: JSON.parse(JSON.stringify(formDate)),
  294. formRules: {
  295. checkFinishTime: [
  296. { required: true, message: '请选择检查完成时间', trigger: 'blur' },
  297. { required: true, message: '请选择检查完成时间', trigger: 'change' }
  298. ],
  299. conclution: [
  300. { required: true, message: '请选择结论', trigger: 'blur' },
  301. { required: true, message: '请选择结论', trigger: 'change' }
  302. ],
  303. checkValidity: [
  304. { required: true, message: '请输入检查有效期', trigger: 'blur' },
  305. { required: true, message: '请输入检查有效期', trigger: 'change' }
  306. ],
  307. checkValidityUnit: [
  308. {
  309. required: true,
  310. message: '请选择检查有效期单位',
  311. trigger: 'blur'
  312. },
  313. {
  314. required: true,
  315. message: '请选择检查有效期单位',
  316. trigger: 'change'
  317. }
  318. ]
  319. },
  320. productionInfo: null,
  321. list: [],
  322. ruleInfo: null,
  323. showSelectUser: false,
  324. currentRow: null,
  325. butLoading: false,
  326. // 工艺路线
  327. workOrderInfo: null,
  328. //工序信息
  329. produceTaskInfo: null,
  330. // 加载中 loading
  331. loading: false
  332. };
  333. },
  334. computed: {
  335. title() {
  336. if (this.ruleInfo) {
  337. switch (this.ruleInfo.classify) {
  338. case 1:
  339. return '清场清洁类记录表';
  340. case 2:
  341. return '车间环境类记录表';
  342. default:
  343. return '设备检测类记录表';
  344. }
  345. }
  346. return '类记录表';
  347. }
  348. },
  349. methods: {
  350. open(productionInfo, workOrderInfo, produceTaskInfo) {
  351. this.visible = true;
  352. this.productionInfo = productionInfo;
  353. this.workOrderInfo = workOrderInfo;
  354. this.produceTaskInfo = produceTaskInfo;
  355. // 存在缓存记录
  356. if (this.productionInfo.recordId != null) {
  357. // 查询详情
  358. this.getCacheInfo();
  359. } else {
  360. this.addForm.batchNo = workOrderInfo.batchNo;
  361. this.addForm.executeMethod = productionInfo.executeMethod;
  362. this.addForm.formingNum = workOrderInfo.formingNum;
  363. this.addForm.itemType = productionInfo.itemType;
  364. this.addForm.produceRoutingId = workOrderInfo.produceRoutingId;
  365. this.addForm.produceRoutingName = workOrderInfo.produceRoutingName;
  366. this.addForm.produceTaskConfigId = productionInfo.produceTaskConfigId;
  367. this.addForm.produceTaskId = productionInfo.produceTaskId;
  368. this.addForm.productCode = workOrderInfo.productCode;
  369. this.addForm.productModel = workOrderInfo.model;
  370. this.addForm.productName = workOrderInfo.productName;
  371. this.addForm.reportWorkType = productionInfo.reportWorkType;
  372. this.addForm.specification = workOrderInfo.specification;
  373. this.addForm.workOrderCode = workOrderInfo.code;
  374. this.addForm.workOrderId = workOrderInfo.id;
  375. this.getRuleList();
  376. }
  377. console.log('this.productionInfo', this.productionInfo);
  378. console.log('this.addForm', this.addForm);
  379. this.getRuleInfo();
  380. },
  381. // 获取详情
  382. async getCacheInfo() {
  383. this.loading = true;
  384. try {
  385. const data = await getById(this.productionInfo.recordId);
  386. console.log('dat 缓存', data);
  387. this.$util.assignObject(this.addForm, data);
  388. this.addForm.recordRulesClassify += '';
  389. this.loading = false;
  390. } catch (error) {
  391. this.loading = false;
  392. }
  393. },
  394. // 规则信息
  395. async getRuleInfo() {
  396. const data = await getRecordRulesDetail(this.productionInfo.ruleId);
  397. this.ruleInfo = data;
  398. console.log('this.ruleInfo', this.ruleInfo);
  399. if (this.productionInfo.recordId == null) {
  400. // 赋值表单信息
  401. this.addForm.recordRulesClassify = this.ruleInfo.classify + '';
  402. this.addForm.ruleId = this.ruleInfo.id;
  403. this.addForm.ruleName = this.ruleInfo.name;
  404. this.addForm.deviceId = this.ruleInfo.deviceId;
  405. this.addForm.deviceName = this.ruleInfo.deviceName;
  406. }
  407. },
  408. // 查询记录规则 事项列表
  409. async getRuleList() {
  410. const { list } = await recordRulesDetailPage({
  411. rulesId: this.productionInfo.ruleId,
  412. pageNum: 1,
  413. size: 9999
  414. });
  415. // 添加必要参数
  416. this.addForm.details = list.map((i) => {
  417. return {
  418. checkResult: null,
  419. checkStatus: null,
  420. checkStatusDesc: '',
  421. errorMsg: '',
  422. checkUsers: [],
  423. paramValue: i.paramValue,
  424. toolNames: i.tools.map((i) => i.toolName).join(','),
  425. recordId: i.recordId
  426. };
  427. });
  428. console.log('this.addForm 添加规则', this.addForm);
  429. },
  430. openSelectUser(row) {
  431. this.currentRow = row;
  432. console.log('row', row);
  433. this.showSelectUser = true;
  434. console.log('this.showSelectUser', this.showSelectUser);
  435. },
  436. handleBeforeClose() {
  437. this.addForm = JSON.parse(JSON.stringify(this.formDate));
  438. console.log('this.$refs.ruleFormRef', this.addForm);
  439. this.$refs.ruleFormRef?.clearValidate();
  440. this.$nextTick(() => {
  441. this.visible = false;
  442. });
  443. },
  444. selectUserFinished(userInfo) {
  445. console.log('userInfo', userInfo);
  446. this.currentRow.checkUsers = userInfo.map((i) => {
  447. // 构建参数和接口的对应上
  448. return { ...i, userName: i.name, userId: i.id };
  449. });
  450. },
  451. showCheckUserNames(userList) {
  452. if (userList.length == 0) return '请选择部门-选择员工';
  453. return userList
  454. .map((i) => {
  455. return i.groupName + '-' + i.userName;
  456. })
  457. .join(',');
  458. },
  459. // 提交
  460. submit(type) {
  461. // 验证表单
  462. this.$refs.ruleFormRef.validate(async (valid) => {
  463. if (!valid) {
  464. return;
  465. }
  466. // 报工需要验证 缓存不验证
  467. if (type == 'submit') {
  468. // 验证检查项目
  469. const detailRequired = this.addForm.details.some((i) => {
  470. let qk = false;
  471. if (this.ruleInfo.classify == 3) {
  472. qk = Boolean(i.checkStatusDesc);
  473. } else {
  474. qk = i.checkStatus != null;
  475. }
  476. return i.checkResult == null || !qk || i.checkUsers?.length == 0;
  477. });
  478. if (detailRequired) {
  479. return this.$message.warning(
  480. '请先完善 检查人、检查情况、检查结果 内容!'
  481. );
  482. }
  483. }
  484. console.log('this.addForm', this.addForm);
  485. // 提交
  486. this.butLoading = true;
  487. try {
  488. if (this.isTempRecord) {
  489. if (type == 'submit') {
  490. await tempSaveOrUpdateAndSubmit(this.addForm);
  491. this.$message.success('报工成功!');
  492. } else {
  493. const id = await saveOrUpdate(this.addForm);
  494. this.addForm.id = id;
  495. this.$message.success('缓存成功!');
  496. }
  497. } else {
  498. if (type == 'submit') {
  499. await saveOrUpdateAndSubmit(this.addForm);
  500. this.$message.success('报工成功!');
  501. } else {
  502. const id = await saveOrUpdate(this.addForm);
  503. this.addForm.id = id;
  504. this.$message.success('缓存成功!');
  505. }
  506. }
  507. this.butLoading = false;
  508. // 返回
  509. this.$emit('reload');
  510. this.handleBeforeClose();
  511. } catch (error) {
  512. this.butLoading = false;
  513. }
  514. });
  515. },
  516. async clearCache() {
  517. try {
  518. this.butLoading = true;
  519. await logicDelete(this.productionInfo.recordId);
  520. this.butLoading = false;
  521. this.productionInfo.recordId == null;
  522. this.addForm.workshopArea = '';
  523. this.addForm.checkFinishTime = null;
  524. this.addForm.checkValidity = null;
  525. this.addForm.checkValidityUnit = null;
  526. this.addForm.conclution = null;
  527. this.addForm.id = null;
  528. this.getRuleList();
  529. this.$message.success('缓存清空成功!');
  530. this.productionInfo.executeStatus = 0;
  531. this.$emit('reload');
  532. } catch (error) {
  533. this.butLoading = false;
  534. }
  535. }
  536. }
  537. };
  538. </script>
  539. <style scoped>
  540. .modal-body {
  541. padding: 16px;
  542. min-height: 100px;
  543. }
  544. .modal-footer {
  545. display: flex;
  546. align-items: center;
  547. gap: 10px;
  548. justify-content: flex-end;
  549. }
  550. </style>