edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <el-dialog
  4. class="ele-dialog-form"
  5. :title="title"
  6. :visible.sync="visible"
  7. :before-close="handleClose"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. width="1200px"
  11. >
  12. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  13. <el-row>
  14. <el-col :span="8" v-if="title != '新增'">
  15. <el-form-item label="编码:">
  16. <el-input :maxlength="20" v-model="form.code" disabled />
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="8" v-if="title != '新增'">
  20. <el-form-item label="工单号:">
  21. <el-input :maxlength="20" v-model="form.workOrderCode" disabled />
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="8">
  25. <el-form-item label="类型:" prop="qualityType">
  26. <DictSelection
  27. dictName="质检计划类型"
  28. v-if="title != '详情'"
  29. v-model="form.qualityType"
  30. ></DictSelection>
  31. <el-input
  32. :value="getDictValue('质检计划类型', form.qualityType)"
  33. disabled
  34. v-if="title == '详情'"
  35. />
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-form-item label="取样类型:" prop="qualityMode">
  40. <DictSelection
  41. dictName="取样类型"
  42. v-model="form.qualityMode"
  43. clearable
  44. v-if="title != '详情'"
  45. ></DictSelection>
  46. <el-input
  47. :value="getDictValue('取样类型', form.qualityMode)"
  48. disabled
  49. v-if="title == '详情'"
  50. />
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="工艺路线:">
  55. <el-input
  56. @click.native="openVersion"
  57. clearable
  58. v-model="form.produceRoutingName"
  59. v-if="title != '详情'"
  60. />
  61. <el-input
  62. v-model="form.produceRoutingName"
  63. disabled
  64. v-if="title == '详情'"
  65. />
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="8">
  69. <el-form-item label="工序:" v-if="!form.qualityPlanId">
  70. <el-select
  71. style="width: 100%"
  72. v-model="form.produceTaskId"
  73. placeholder="请选择"
  74. clearable
  75. @change="produceTaskChange"
  76. v-if="title != '详情'"
  77. >
  78. <el-option
  79. v-for="item in produceTaskList"
  80. :key="item.id"
  81. :label="item.name"
  82. :value="item.id"
  83. >
  84. </el-option>
  85. </el-select>
  86. <el-input
  87. v-model="form.produceTaskName"
  88. disabled
  89. v-if="title == '详情'"
  90. />
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="8">
  94. <el-form-item label="产品名称:" prop="productName">
  95. <el-input
  96. v-model="form.productName"
  97. @click.native="addProduct"
  98. readonly
  99. v-if="title == '新增'"
  100. />
  101. <el-input
  102. v-model="form.productName"
  103. disabled
  104. v-if="title != '新增'"
  105. />
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="8">
  109. <el-form-item label="总数量:">
  110. <el-input v-model="form.total" disabled></el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="8">
  114. <el-form-item label="合格数:" prop="qualifiedNumber">
  115. <el-input
  116. v-model="form.qualifiedNumber"
  117. @input="inputValue"
  118. :disabled="title == '详情'"
  119. ></el-input>
  120. </el-form-item>
  121. </el-col>
  122. <el-col :span="8">
  123. <el-form-item label="不合格数:" prop="noQualifiedNumber">
  124. <el-input
  125. v-model="form.noQualifiedNumber"
  126. @input="inputValue"
  127. :disabled="title == '详情'"
  128. ></el-input>
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="8">
  132. <el-form-item label="工时(h):" prop="hours">
  133. <el-input
  134. v-model="form.hours"
  135. :disabled="title == '详情'"
  136. ></el-input>
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="8">
  140. <el-form-item label="质检时间:" prop="qualityTime">
  141. <el-date-picker
  142. class="w100"
  143. v-model="form.qualityTime"
  144. type="date"
  145. value-format="yyyy-MM-dd"
  146. :disabled="title == '详情'"
  147. ></el-date-picker>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="8">
  151. <el-form-item label="质检部门" prop="groupId">
  152. <deptSelect
  153. :disabled="title == '详情'"
  154. v-model="form.groupId"
  155. @changeGroup="searchDeptNodeClick"
  156. />
  157. </el-form-item>
  158. </el-col>
  159. <el-col :span="8">
  160. <el-form-item label="质检人" prop="qualityId">
  161. <el-select
  162. :disabled="title == '详情'"
  163. v-model="form.qualityId"
  164. @change="changeExecutor"
  165. size="small"
  166. style="width: 100%"
  167. filterable
  168. >
  169. <el-option
  170. v-for="item in executorList"
  171. :key="item.id"
  172. :value="item.id"
  173. :label="item.name"
  174. ></el-option>
  175. </el-select>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="24">
  179. <el-form-item label="附件:" prop="accessory">
  180. <fileUpload
  181. v-model="form.accessory"
  182. module="main"
  183. :showLib="false"
  184. :limit="1"
  185. :disabled="title == '详情'"
  186. />
  187. </el-form-item>
  188. </el-col>
  189. </el-row>
  190. </el-form>
  191. <div class="title" v-if="title != '新增'">质检内容</div>
  192. <el-tabs
  193. v-model="tabTaskId"
  194. class="tab-box"
  195. type="border-card"
  196. >
  197. <el-tab-pane
  198. v-for="(item, index) in form.categoryParamList"
  199. :label="item.name"
  200. :name="item.id"
  201. :key="index"
  202. >
  203. <term
  204. :qualityParam="item.qualityParam"
  205. :isDetails="title == '详情'"
  206. ref="qualityParamRef"
  207. ></term>
  208. </el-tab-pane>
  209. </el-tabs>
  210. <div class="title" v-if="title != '新增'">不良品列表</div>
  211. <el-table :data="form.voList" border v-if="title != '新增'" height="25vh">
  212. <el-table-column label="序号" align="center" width="60">
  213. <template slot-scope="scope">
  214. <span>{{ scope.$index + 1 }}</span>
  215. </template>
  216. </el-table-column>
  217. <el-table-column label="不良品编码" align="center" prop="code">
  218. </el-table-column>
  219. <el-table-column label="数量" align="center" prop="unqualifiedQuantity">
  220. </el-table-column>
  221. <el-table-column label="原因" align="center" prop="unqualifiedReason">
  222. </el-table-column>
  223. <el-table-column label="创建时间" align="center" prop="createTime">
  224. </el-table-column>
  225. <el-table-column label="创建人" align="center" prop="reviewerName">
  226. </el-table-column>
  227. <el-table-column label="处置类型" align="center" prop="type">
  228. <template slot-scope="scope">
  229. {{ getDictValue('不良品处理类型', scope.row.type + '') }}
  230. </template>
  231. </el-table-column>
  232. </el-table>
  233. <template v-slot:footer>
  234. <el-button @click="handleClose">返回</el-button>
  235. <el-button
  236. type="primary"
  237. :loading="loading"
  238. @click="update"
  239. v-if="title == '报工'"
  240. >
  241. 报工
  242. </el-button>
  243. <el-button
  244. type="primary"
  245. :loading="loading"
  246. @click="save"
  247. v-if="title == '新增'"
  248. >
  249. 保存
  250. </el-button>
  251. </template>
  252. <ProductionVersion ref="versionRefs" @changeProduct="changeProduct" />
  253. <EquipmentDialog ref="equipmentRefs" @choose="choose" />
  254. </el-dialog>
  255. </template>
  256. <script>
  257. import { save, update, getById } from '@/api/inspectionWork';
  258. import { getProduceTaskList } from '@/api/aps';
  259. import EquipmentDialog from './EquipmentDialog.vue';
  260. import ProductionVersion from './ProductionVersion.vue';
  261. import dictMixins from '@/mixins/dictMixins';
  262. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  263. import { getUserPage } from '@/api/system/organization';
  264. import fileUpload from '@/components/upload/fileUpload';
  265. import term from './term';
  266. export default {
  267. components: {
  268. ProductionVersion,
  269. EquipmentDialog,
  270. deptSelect,
  271. fileUpload,
  272. term
  273. },
  274. mixins: [dictMixins],
  275. data() {
  276. const defaultForm = function () {
  277. return {
  278. produceRoutingName: '',
  279. produceRoutingId: '',
  280. produceTaskId: '',
  281. produceTaskName: '',
  282. code: '',
  283. workOrderCode: '',
  284. batchNo: '',
  285. productName: '',
  286. productCode: '',
  287. specification: '',
  288. brandNo: '',
  289. qualityType: '',
  290. total: '',
  291. qualifiedNumber: '',
  292. noQualifiedNumber: '',
  293. hours: '',
  294. qualityTime: '',
  295. qualityName: '',
  296. qualityId: '',
  297. voList: [],
  298. groupId: '',
  299. groupName: '',
  300. id: '',
  301. accessory: [],
  302. qualityMode: ''
  303. };
  304. };
  305. return {
  306. defaultForm,
  307. // 表单数据
  308. form: { ...defaultForm() },
  309. // 表单验证规则
  310. rules: {
  311. productName: [
  312. { required: true, message: '请输入', trigger: 'change' }
  313. ],
  314. qualifiedNumber: [
  315. { required: true, message: '请输入', trigger: 'blur' }
  316. ],
  317. noQualifiedNumber: [
  318. { required: true, message: '请输入', trigger: 'blur' }
  319. ],
  320. qualityTime: [{ required: true, message: '请输入', trigger: 'blur' }],
  321. groupId: [{ required: true, message: '请输入', trigger: 'change' }],
  322. qualityId: [{ required: true, message: '请输入', trigger: 'change' }]
  323. },
  324. visible: false,
  325. type: null,
  326. title: null,
  327. loading: false,
  328. produceTaskList: [],
  329. executorList: '',
  330. tabTaskId: null
  331. };
  332. },
  333. created() {},
  334. methods: {
  335. open(type, row) {
  336. this.title = type == 'add' ? '新增' : type == 'edit' ? '报工' : '详情';
  337. this.type = type;
  338. if (this.type == 'detail') {
  339. row.accessory = row.accessory || [];
  340. this.form = JSON.parse(JSON.stringify(row));
  341. this.tabTaskId =
  342. this.form.categoryParamList[0] && this.form.categoryParamList[0].id;
  343. if (this.form.groupId) {
  344. this.getUserList({ groupId: this.form.groupId });
  345. }
  346. this.getProduceTaskList();
  347. } else if (type == 'edit') {
  348. getById(row.id).then((res) => {
  349. row.accessory = row.accessory || [];
  350. this.form = res.data;
  351. this.tabTaskId =
  352. this.form.categoryParamList[0] &&
  353. this.form.categoryParamList[0].id;
  354. if (this.form.groupId) {
  355. this.getUserList({ groupId: this.form.groupId });
  356. }
  357. this.getProduceTaskList();
  358. });
  359. }
  360. this.visible = true;
  361. },
  362. inputValue() {
  363. if(!this.form.qualityPlanId) {
  364. this.form.total =
  365. Number(this.form.qualifiedNumber) +
  366. Number(this.form.noQualifiedNumber);
  367. }
  368. },
  369. addProduct() {
  370. this.$refs.equipmentRefs.open();
  371. },
  372. openVersion() {
  373. this.$refs.versionRefs.open();
  374. },
  375. //工艺路线回调
  376. changeProduct(data) {
  377. this.form.produceRoutingId = data.id;
  378. this.form.produceRoutingName = data.name;
  379. this.form.produceTaskId = '';
  380. this.form.produceTaskName = '';
  381. this.getProduceTaskList();
  382. },
  383. async getProduceTaskList() {
  384. if (!this.form.produceRoutingId) {
  385. return;
  386. }
  387. const res = await getProduceTaskList({
  388. isDetail: true,
  389. pageNum: 1,
  390. routingId: this.form.produceRoutingId,
  391. size: -1
  392. });
  393. this.produceTaskList = res.list;
  394. },
  395. produceTaskChange() {
  396. if (!this.form.produceTaskId) {
  397. return;
  398. }
  399. this.form.produceTaskName = this.produceTaskList.find(
  400. (item) => item.id == this.form.produceTaskId
  401. ).name;
  402. },
  403. choose(data) {
  404. this.form.productName = data[0].name;
  405. this.form.productCode = data[0].code;
  406. this.form.specification = data[0].specification;
  407. this.form.brandNo = data[0].brandNum;
  408. },
  409. //选择部门(搜索)
  410. searchDeptNodeClick(info, row) {
  411. if (info) {
  412. const params = { groupId: info };
  413. this.getUserList(params);
  414. this.form.groupName = row.name;
  415. } else {
  416. this.form.executeGroupId = null;
  417. }
  418. },
  419. // 获取审核人列表、巡点检人员
  420. async getUserList(params) {
  421. try {
  422. let data = { pageNum: 1, size: -1 };
  423. // 如果传了参数就是获取巡点检人员数据
  424. if (params) {
  425. data = Object.assign(data, params);
  426. }
  427. const res = await getUserPage(data);
  428. this.executorList = res.list;
  429. } catch (error) {}
  430. },
  431. // 执行人选择
  432. changeExecutor(val) {
  433. if (val) {
  434. this.form.qualityId = val;
  435. this.form.qualityName = this.executorList.filter(
  436. (item) => item.id === val
  437. )[0].name;
  438. }
  439. },
  440. /* 保存编辑 */
  441. save() {
  442. this.$refs.form.validate((valid) => {
  443. if (!valid) {
  444. return false;
  445. }
  446. this.loading = true;
  447. save(this.form)
  448. .then((msg) => {
  449. this.loading = false;
  450. this.$message.success(msg);
  451. this.handleClose();
  452. this.$emit('done');
  453. })
  454. .catch((e) => {
  455. this.loading = false;
  456. });
  457. });
  458. },
  459. update() {
  460. this.loading = true;
  461. this.form['status'] = 1;
  462. update({ ...this.form })
  463. .then((msg) => {
  464. this.loading = false;
  465. this.$message.success(msg);
  466. this.handleClose();
  467. this.$emit('done');
  468. })
  469. .catch((e) => {
  470. this.loading = false;
  471. });
  472. },
  473. restForm() {
  474. this.form = { ...this.defaultForm() };
  475. this.$nextTick(() => {
  476. this.$refs.form.clearValidate();
  477. });
  478. },
  479. handleClose() {
  480. this.restForm();
  481. this.visible = false;
  482. }
  483. }
  484. };
  485. </script>
  486. <style lang="scss" scoped>
  487. .title {
  488. font-size: 16px;
  489. line-height: 45px;
  490. }
  491. .location-warp {
  492. display: flex;
  493. .detail {
  494. margin-left: 10px;
  495. }
  496. }
  497. :deep(
  498. .el-dialog:not(.ele-dialog-form)
  499. .el-dialog__body
  500. .el-form
  501. .el-form-item:last-child
  502. ) {
  503. margin-bottom: 22px;
  504. }
  505. :deep(
  506. .el-dialog:not(.ele-dialog-form)
  507. .el-dialog__body
  508. .el-form
  509. .el-table__body
  510. .el-table__row
  511. .el-form-item:last-child
  512. ) {
  513. margin-bottom: 0 !important;
  514. }
  515. .add-product {
  516. width: 100%;
  517. display: flex;
  518. align-items: center;
  519. justify-content: flex-end;
  520. font-size: 30px;
  521. color: #1890ff;
  522. margin: 10px 0;
  523. cursor: pointer;
  524. }
  525. </style>