edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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. />
  183. </el-form-item>
  184. </el-col>
  185. </el-row>
  186. </el-form>
  187. <div class="title" v-if="title != '新增'">质检内容</div>
  188. <el-tabs
  189. v-model="tabTaskId"
  190. class="tab-box"
  191. type="border-card"
  192. >
  193. <el-tab-pane
  194. v-for="(item, index) in form.categoryParamList"
  195. :label="item.name"
  196. :name="item.id"
  197. :key="index"
  198. >
  199. <term
  200. :qualityParam="item.qualityParam"
  201. :isDetails="title == '详情'"
  202. ref="qualityParamRef"
  203. ></term>
  204. </el-tab-pane>
  205. </el-tabs>
  206. <div class="title" v-if="title != '新增'">不良品列表</div>
  207. <el-table :data="form.voList" border v-if="title != '新增'" height="25vh">
  208. <el-table-column label="序号" align="center" width="60">
  209. <template slot-scope="scope">
  210. <span>{{ scope.$index + 1 }}</span>
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="不良品编码" align="center" prop="code">
  214. </el-table-column>
  215. <el-table-column label="数量" align="center" prop="unqualifiedQuantity">
  216. </el-table-column>
  217. <el-table-column label="原因" align="center" prop="unqualifiedReason">
  218. </el-table-column>
  219. <el-table-column label="创建时间" align="center" prop="createTime">
  220. </el-table-column>
  221. <el-table-column label="创建人" align="center" prop="reviewerName">
  222. </el-table-column>
  223. <el-table-column label="处置类型" align="center" prop="type">
  224. <template slot-scope="scope">
  225. {{ getDictValue('不良品处理类型', scope.row.type + '') }}
  226. </template>
  227. </el-table-column>
  228. </el-table>
  229. <template v-slot:footer>
  230. <el-button @click="handleClose">返回</el-button>
  231. <el-button
  232. type="primary"
  233. :loading="loading"
  234. @click="update"
  235. v-if="title == '报工'"
  236. >
  237. 报工
  238. </el-button>
  239. <el-button
  240. type="primary"
  241. :loading="loading"
  242. @click="save"
  243. v-if="title == '新增'"
  244. >
  245. 保存
  246. </el-button>
  247. </template>
  248. <ProductionVersion ref="versionRefs" @changeProduct="changeProduct" />
  249. <EquipmentDialog ref="equipmentRefs" @choose="choose" />
  250. </el-dialog>
  251. </template>
  252. <script>
  253. import { save, update, getById } from '@/api/inspectionWork';
  254. import { getProduceTaskList } from '@/api/aps';
  255. import EquipmentDialog from './EquipmentDialog.vue';
  256. import ProductionVersion from './ProductionVersion.vue';
  257. import dictMixins from '@/mixins/dictMixins';
  258. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  259. import { getUserPage } from '@/api/system/organization';
  260. // import fileUpload from '@/components/upload/fileUpload';
  261. import fileUpload from '@/components/addDoc/index.vue';
  262. import term from './term';
  263. export default {
  264. components: {
  265. ProductionVersion,
  266. EquipmentDialog,
  267. deptSelect,
  268. fileUpload,
  269. term
  270. },
  271. mixins: [dictMixins],
  272. data() {
  273. const defaultForm = function () {
  274. return {
  275. produceRoutingName: '',
  276. produceRoutingId: '',
  277. produceTaskId: '',
  278. produceTaskName: '',
  279. code: '',
  280. workOrderCode: '',
  281. batchNo: '',
  282. productName: '',
  283. productCode: '',
  284. specification: '',
  285. brandNo: '',
  286. qualityType: '',
  287. total: '',
  288. qualifiedNumber: '',
  289. noQualifiedNumber: '',
  290. hours: '',
  291. qualityTime: '',
  292. qualityName: '',
  293. qualityId: '',
  294. voList: [],
  295. groupId: '',
  296. groupName: '',
  297. id: '',
  298. accessory: [],
  299. qualityMode: ''
  300. };
  301. };
  302. return {
  303. defaultForm,
  304. // 表单数据
  305. form: { ...defaultForm() },
  306. // 表单验证规则
  307. rules: {
  308. productName: [
  309. { required: true, message: '请输入', trigger: 'change' }
  310. ],
  311. qualifiedNumber: [
  312. { required: true, message: '请输入', trigger: 'blur' }
  313. ],
  314. noQualifiedNumber: [
  315. { required: true, message: '请输入', trigger: 'blur' }
  316. ],
  317. qualityTime: [{ required: true, message: '请输入', trigger: 'blur' }],
  318. groupId: [{ required: true, message: '请输入', trigger: 'change' }],
  319. qualityId: [{ required: true, message: '请输入', trigger: 'change' }]
  320. },
  321. visible: false,
  322. type: null,
  323. title: null,
  324. loading: false,
  325. produceTaskList: [],
  326. executorList: '',
  327. tabTaskId: null
  328. };
  329. },
  330. created() {},
  331. methods: {
  332. open(type, row) {
  333. this.title = type == 'add' ? '新增' : type == 'edit' ? '报工' : '详情';
  334. this.type = type;
  335. if (this.type == 'detail') {
  336. row.accessory = row.accessory || [];
  337. this.form = JSON.parse(JSON.stringify(row));
  338. this.tabTaskId =
  339. this.form.categoryParamList[0] && this.form.categoryParamList[0].id;
  340. if (this.form.groupId) {
  341. this.getUserList({ groupId: this.form.groupId });
  342. }
  343. this.getProduceTaskList();
  344. } else if (type == 'edit') {
  345. getById(row.id).then((res) => {
  346. row.accessory = row.accessory || [];
  347. this.form = res.data;
  348. this.tabTaskId =
  349. this.form.categoryParamList[0] &&
  350. this.form.categoryParamList[0].id;
  351. if (this.form.groupId) {
  352. this.getUserList({ groupId: this.form.groupId });
  353. }
  354. this.getProduceTaskList();
  355. });
  356. }
  357. this.visible = true;
  358. },
  359. inputValue() {
  360. if(!this.form.qualityPlanId) {
  361. this.form.total =
  362. Number(this.form.qualifiedNumber) +
  363. Number(this.form.noQualifiedNumber);
  364. }
  365. },
  366. addProduct() {
  367. this.$refs.equipmentRefs.open();
  368. },
  369. openVersion() {
  370. this.$refs.versionRefs.open();
  371. },
  372. //工艺路线回调
  373. changeProduct(data) {
  374. this.form.produceRoutingId = data.id;
  375. this.form.produceRoutingName = data.name;
  376. this.form.produceTaskId = '';
  377. this.form.produceTaskName = '';
  378. this.getProduceTaskList();
  379. },
  380. async getProduceTaskList() {
  381. if (!this.form.produceRoutingId) {
  382. return;
  383. }
  384. const res = await getProduceTaskList({
  385. isDetail: true,
  386. pageNum: 1,
  387. routingId: this.form.produceRoutingId,
  388. size: -1
  389. });
  390. this.produceTaskList = res.list;
  391. },
  392. produceTaskChange() {
  393. if (!this.form.produceTaskId) {
  394. return;
  395. }
  396. this.form.produceTaskName = this.produceTaskList.find(
  397. (item) => item.id == this.form.produceTaskId
  398. ).name;
  399. },
  400. choose(data) {
  401. this.form.productName = data[0].name;
  402. this.form.productCode = data[0].code;
  403. this.form.specification = data[0].specification;
  404. this.form.brandNo = data[0].brandNum;
  405. },
  406. //选择部门(搜索)
  407. searchDeptNodeClick(info, row) {
  408. if (info) {
  409. const params = { groupId: info };
  410. this.getUserList(params);
  411. this.form.groupName = row.name;
  412. } else {
  413. this.form.executeGroupId = null;
  414. }
  415. },
  416. // 获取审核人列表、巡点检人员
  417. async getUserList(params) {
  418. try {
  419. let data = { pageNum: 1, size: -1 };
  420. // 如果传了参数就是获取巡点检人员数据
  421. if (params) {
  422. data = Object.assign(data, params);
  423. }
  424. const res = await getUserPage(data);
  425. this.executorList = res.list;
  426. } catch (error) {}
  427. },
  428. // 执行人选择
  429. changeExecutor(val) {
  430. if (val) {
  431. this.form.qualityId = val;
  432. this.form.qualityName = this.executorList.filter(
  433. (item) => item.id === val
  434. )[0].name;
  435. }
  436. },
  437. /* 保存编辑 */
  438. save() {
  439. this.$refs.form.validate((valid) => {
  440. if (!valid) {
  441. return false;
  442. }
  443. this.loading = true;
  444. save(this.form)
  445. .then((msg) => {
  446. this.loading = false;
  447. this.$message.success(msg);
  448. this.handleClose();
  449. this.$emit('done');
  450. })
  451. .catch((e) => {
  452. this.loading = false;
  453. });
  454. });
  455. },
  456. update() {
  457. this.loading = true;
  458. this.form['status'] = 1;
  459. update({ ...this.form })
  460. .then((msg) => {
  461. this.loading = false;
  462. this.$message.success(msg);
  463. this.handleClose();
  464. this.$emit('done');
  465. })
  466. .catch((e) => {
  467. this.loading = false;
  468. });
  469. },
  470. restForm() {
  471. this.form = { ...this.defaultForm() };
  472. this.$nextTick(() => {
  473. this.$refs.form.clearValidate();
  474. });
  475. },
  476. handleClose() {
  477. this.restForm();
  478. this.visible = false;
  479. }
  480. }
  481. };
  482. </script>
  483. <style lang="scss" scoped>
  484. .title {
  485. font-size: 16px;
  486. line-height: 45px;
  487. }
  488. .location-warp {
  489. display: flex;
  490. .detail {
  491. margin-left: 10px;
  492. }
  493. }
  494. :deep(
  495. .el-dialog:not(.ele-dialog-form)
  496. .el-dialog__body
  497. .el-form
  498. .el-form-item:last-child
  499. ) {
  500. margin-bottom: 22px;
  501. }
  502. :deep(
  503. .el-dialog:not(.ele-dialog-form)
  504. .el-dialog__body
  505. .el-form
  506. .el-table__body
  507. .el-table__row
  508. .el-form-item:last-child
  509. ) {
  510. margin-bottom: 0 !important;
  511. }
  512. .add-product {
  513. width: 100%;
  514. display: flex;
  515. align-items: center;
  516. justify-content: flex-end;
  517. font-size: 30px;
  518. color: #1890ff;
  519. margin: 10px 0;
  520. cursor: pointer;
  521. }
  522. </style>