edit.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal :title="title" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
  4. :close-on-press-escape="false" append-to-body width="80%" :maxable="true">
  5. <header-title title="基本信息"></header-title>
  6. <base-info ref="baseInfoRefs" v-if="baseForm" :form="baseForm" :btnType="btnType" @resetTable="resetTable"
  7. @getList="getList" @changeModel="changeModel" @changeNumber="changeNumber" @table2="table2"></base-info>
  8. <el-row>
  9. <header-title title="质检内容"></header-title>
  10. <el-tabs v-model="activeName" @tab-click="handleClick">
  11. <el-tab-pane label="来源清单" name="1"></el-tab-pane>
  12. <el-tab-pane label="样品清单" name="2"></el-tab-pane>
  13. <el-tab-pane label="质检方案" name="3"></el-tab-pane>
  14. </el-tabs>
  15. </el-row>
  16. <el-row style="margin-top: 24px">
  17. <!-- 来料列表表格 -->
  18. <el-table v-show="activeName === '1'" v-if="packingList.length > 0" ref="showPackingListTable"
  19. :data="paginatedPackingList" tooltip-effect="dark" :max-height="300" border
  20. @selection-change="handleSelectionChange" row-key="id">
  21. <el-table-column type="selection" width="55" align="center" :reserve-selection="true"
  22. :selectable="checkSelectable"></el-table-column>
  23. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  24. <!-- label-class-name="DisabledSelection" -->
  25. <template v-for="column in tableColumns">
  26. <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true" :width="column.width"
  27. :align="column.align"></el-table-column>
  28. </template>
  29. </el-table>
  30. <!-- 分页 -->
  31. <el-pagination v-show="activeName === '1' && packingList.length > 0" @size-change="handleSizeChange"
  32. @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 20, 50, 100]"
  33. :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next" :total="packingList.length"
  34. style="margin-top: 16px" />
  35. <!-- 样品列表表格 -->
  36. <el-table v-show="activeName === '2'" v-if="sampleList.length > 0" ref="showSampleListTable"
  37. :data="paginatedSampleList" tooltip-effect="dark" :max-height="300" border row-key="id">
  38. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  39. <template v-for="column in tableColumns">
  40. <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true" :width="column.width"
  41. :align="column.align"></el-table-column>
  42. </template>
  43. </el-table>
  44. <el-pagination v-show="activeName === '2' && sampleList.length > 0" @size-change="handleSampleSizeChange"
  45. @current-change="handleSampleCurrentChange" :current-page="samplePagination.currentPage"
  46. :page-sizes="[10, 20, 50, 100]" :page-size="samplePagination.pageSize"
  47. layout="total, sizes, prev, pager, next, jumper" :total="sampleList.length"
  48. style="margin-top: 10px"></el-pagination>
  49. <!-- 质检方案 -->
  50. <el-table v-show="activeName === '3'" v-if="schemeList.length > 0" ref="showSchemeListTable"
  51. :data="paginatedSchemeList" tooltip-effect="dark" :max-height="300" border row-key="id">
  52. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  53. <el-table-column label="质检方案编码" prop="qualitySchemeTemplateCode" align="center">
  54. </el-table-column>
  55. <el-table-column label="质检方案名称" prop="qualitySchemeTemplateName" align="center"></el-table-column>
  56. <el-table-column label="质检类型" prop="categoryLevelClassName" align="center"></el-table-column>
  57. <el-table-column label="质检项编码" prop="inspectionCode" align="center"></el-table-column>
  58. <el-table-column label="质检项名称" prop="inspectionName" align="center"></el-table-column>
  59. <el-table-column label="工艺参数" prop="defaultValue" align="center">
  60. </el-table-column>
  61. </el-table>
  62. <el-pagination v-show="activeName === '3' && schemeList.length > 0" @size-change="handleSchemeSizeChange"
  63. @current-change="handleSchemeCurrentChange" :current-page="schemePagination.currentPage"
  64. :page-sizes="[10, 20, 50, 100]" :page-size="schemePagination.pageSize"
  65. layout="total, sizes, prev, pager, next, jumper" :total="schemeList.length"
  66. style="margin-top: 10px"></el-pagination>
  67. </el-row>
  68. <!-- <div class="add-product" @click="addProduct" v-if="btnType != 'detail'">
  69. <i class="el-icon-circle-plus-outline"></i>
  70. </div> -->
  71. <template v-slot:footer>
  72. <el-button @click="handleClose">取消</el-button>
  73. <el-button v-if="btnType != 'detail' && btnType != 'issued'" type="primary" :loading="loading"
  74. @click="handleSave">
  75. 保存
  76. </el-button>
  77. <el-button v-if="btnType != 'detail'" type="primary" :loading="loading" @click="handleIssued">
  78. 下发
  79. </el-button>
  80. </template>
  81. </ele-modal>
  82. </template>
  83. <script>
  84. import baseInfo from './baseInfo.vue';
  85. import { getCode } from '@/api/login';
  86. import { save, update, planIssued } from '@/api/inspectionPlan';
  87. import {
  88. getPurchaseWarehouseGoods,
  89. getQualityTemplateList,
  90. getTemplateListByPlanId,
  91. getSampleListByPlanId,
  92. getInventoryListByPlanId,
  93. outInRecordsPage,
  94. getByCategoryId,
  95. getBatchInfoData
  96. } from '@/api/inspectionPlan/index.js';
  97. export default {
  98. components: {
  99. baseInfo
  100. },
  101. data() {
  102. const defaultForm = function () {
  103. return {
  104. id: '',
  105. code: '',
  106. name: '',
  107. type: '',
  108. qualityMode: '',
  109. inspectionStandards: '',
  110. autoOrder: '',
  111. groupId: '',
  112. groupName: '',
  113. executeId: '',
  114. executeName: '',
  115. planStartTime: '',
  116. planEndTime: '',
  117. standard: '',
  118. planSource: '',
  119. planSourceCode: '',
  120. productName: '',
  121. productCode: '',
  122. batchNo: '',
  123. specification: '',
  124. modelType: '',
  125. brandNo: '',
  126. productNumber: '',
  127. qualifiedNumber: '',
  128. unqualifiedNumber: '',
  129. qualificationRate: '',
  130. totalWeight: '',
  131. sampleNumber: null,
  132. sampleProportion: '',
  133. supplierMark: '',
  134. // planReceiveId: '',
  135. remark: '',
  136. accessory: []
  137. };
  138. };
  139. return {
  140. defaultForm,
  141. // 表单数据
  142. baseForm: { ...defaultForm() },
  143. tableColumns: [
  144. {
  145. label: '编码',
  146. prop: 'categoryCode',
  147. width: '150',
  148. align: 'center'
  149. },
  150. {
  151. label: '名称',
  152. prop: 'categoryName',
  153. width: '150',
  154. align: 'center'
  155. },
  156. { label: '批次号', prop: 'batchNo', align: 'center' },
  157. { label: '发货条码', prop: 'barcodes', align: 'center' },
  158. { label: '包装编码', prop: 'packageNo', align: 'center' },
  159. // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  160. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  161. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  162. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  163. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  164. { label: '客户代号', prop: 'clientCode', align: 'center' },
  165. { label: '供应商名称', prop: 'supplierName', align: 'center' ,width: '120' },
  166. { label: '供应商代号', prop: 'supplierCode', align: 'center' ,width: '120'},
  167. { label: '刻码', prop: 'engrave', align: 'center' },
  168. { label: '重量', prop: 'weight', align: 'center' },
  169. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  170. { label: '仓库', prop: 'warehouseName', align: 'center' },
  171. { label: '货区', prop: 'areaName', align: 'center' },
  172. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  173. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  174. { label: '生产日期', prop: 'productionDate', align: 'center' },
  175. { label: '采购日期', prop: 'purchaseDate', align: 'center' }
  176. ],
  177. packingList: [],
  178. pagination: {
  179. currentPage: 1,
  180. pageSize: 10,
  181. total: 0
  182. },
  183. sampleList: [],
  184. samplePagination: {
  185. currentPage: 1,
  186. pageSize: 10,
  187. total: 0
  188. },
  189. schemeList: [],
  190. schemePagination: {
  191. currentPage: 1,
  192. pageSize: 10,
  193. total: 0
  194. },
  195. // 表单验证规则
  196. visible: false,
  197. btnType: null,
  198. title: null,
  199. loading: false,
  200. listPage: [],
  201. activeName: '1',
  202. selectedList: [],
  203. isCheck: false
  204. };
  205. },
  206. computed: {
  207. paginatedPackingList() {
  208. const start =
  209. (this.pagination.currentPage - 1) * this.pagination.pageSize;
  210. const end = start + this.pagination.pageSize;
  211. return this.packingList.slice(start, end);
  212. },
  213. // 分页后的样品列表
  214. paginatedSampleList() {
  215. const { currentPage, pageSize } = this.samplePagination;
  216. const start = (currentPage - 1) * pageSize;
  217. const end = start + pageSize;
  218. return this.sampleList.slice(start, end);
  219. },
  220. // 分页后的质检方案列表
  221. paginatedSchemeList() {
  222. const { currentPage, pageSize } = this.schemePagination;
  223. const start = (currentPage - 1) * pageSize;
  224. const end = start + pageSize;
  225. return this.schemeList.slice(start, end);
  226. }
  227. },
  228. created() { },
  229. methods: {
  230. // 切换质检内容
  231. handleClick(tab) {
  232. this.activeName = tab.name;
  233. },
  234. checkSelectable(row, index) {
  235. // 只有当质检方式为抽检(qualityMode=2)时才可选
  236. return this.btnType != 'issued' || this.baseForm.qualityMode === 2;
  237. },
  238. async open(type, row) {
  239. this.activeName = '1';
  240. this.btnType = type;
  241. this.title =
  242. type == 'add'
  243. ? '新增'
  244. : type == 'edit'
  245. ? '编辑'
  246. : type == 'issued'
  247. ? '下发'
  248. : '详情';
  249. if (this.btnType != 'add') {
  250. row.accessory = row.accessory || [];
  251. console.log('row====', row);
  252. this.baseForm.groupId = row.groupId;
  253. this.baseForm.qualityMode = row.qualityMode;
  254. this.baseForm = JSON.parse(JSON.stringify(row));
  255. //根据类型获取计划来源
  256. if (this.baseForm.type) {
  257. this.$nextTick(() => {
  258. if (this.$refs.baseInfoRefs) {
  259. this.$refs.baseInfoRefs.typeChange(this.baseForm.type);
  260. }
  261. });
  262. }
  263. // 获取人员
  264. if (this.baseForm.groupId) {
  265. this.$nextTick(() => {
  266. if (this.$refs.baseInfoRefs) {
  267. this.$refs.baseInfoRefs.getUserList({
  268. groupId: this.baseForm.groupId
  269. });
  270. }
  271. });
  272. }
  273. // 如果是编辑或者详情,则查询物料清单、质检方案和样品列表
  274. if (row.id) {
  275. // this.getGoodsList(
  276. // this.baseForm?.planSourceCode,
  277. // this.baseForm?.productCode,
  278. // row?.id
  279. // );
  280. //操作行点击时查询清单
  281. await this.getInventoryList(row?.id);
  282. //操作行点击时查询质检
  283. await this.getTemplateList(row?.id);
  284. //操作行点击时查询样品
  285. await this.getSampleList(row?.id);
  286. if (this.baseForm.qualityMode == 1) {
  287. this.sampleList = this.packingList;
  288. this.samplePagination.currentPage = 1;
  289. this.samplePagination.total = this.packingList.length;
  290. } else {
  291. this.sampleList = [];
  292. }
  293. }
  294. } else {
  295. const code = await getCode('qms_plan_code');
  296. this.baseForm.code = code;
  297. }
  298. this.visible = true;
  299. },
  300. async getInventoryList(id) {
  301. let res = await getInventoryListByPlanId({
  302. planId: id
  303. });
  304. console.log(res.list, 'yyyyyyyyyyyyyy清单----------------------------');
  305. this.packingList = res?.list || [];
  306. this.pagination.currentPage = 1;
  307. this.pagination.total = this.packingList.length;
  308. },
  309. async getSampleList(id) {
  310. let res = await getSampleListByPlanId({
  311. planId: id
  312. });
  313. console.log(res.list, 'yyyyyyyyyyyyyy样品----------------------------');
  314. this.sampleList = res?.list || [];
  315. this.samplePagination.currentPage = 1;
  316. this.samplePagination.total = this.sampleList.length;
  317. },
  318. async getTemplateList(id) {
  319. let res = await getTemplateListByPlanId({
  320. planId: id
  321. });
  322. console.log(res.list, 'fffffffffffffff方案--------------------------');
  323. this.schemeList = res?.list || [];
  324. this.schemePagination.currentPage = 1;
  325. this.schemePagination.total = this.schemeList.length;
  326. },
  327. async getList(receiveNo, productCode, productCategoryId, productCategoryName, categoryid, batchNo,supplierName, supplierMark) {
  328. //通过来源和产品 获取来料清单
  329. await this.getGoodsList(receiveNo, productCode, null, productCategoryId, productCategoryName, categoryid, batchNo,supplierName, supplierMark);
  330. //通过来源和产品 获取质检方案
  331. this.getQualityTemplate(productCode);
  332. },
  333. async getGoodsList(receiveNo, productCode, ids, productCategoryId, productCategoryName, categoryid, batchNo,supplierName, supplierMark) {
  334. let res;
  335. const res1 = await outInRecordsPage({
  336. sourceBizNo: receiveNo,
  337. categoryCode: productCode,
  338. categoryId: categoryid,
  339. qualityQlanId: ids,
  340. size: -1
  341. });
  342. console.log(res1, 'res1')
  343. if (res1.list.length > 0) {
  344. console.log(res1.list[0].status, 'status=2 不赋值')
  345. if (res1.list[0].status != 2) {
  346. // res1.list.forEach(item => ({
  347. // ...item,
  348. // supplierName :supplierName,
  349. // supplierMark :supplierMark,
  350. // }))
  351. res = res1.list
  352. this.isCheck = true;
  353. } else {
  354. res = []
  355. this.$message.error('此数据已质检,无需再次质检!');
  356. return
  357. }
  358. } else {
  359. let resData = await getBatchInfoData({
  360. sourceBizNo: receiveNo,
  361. categoryCode: productCode,
  362. batchNo: batchNo,
  363. });
  364. console.log(resData, 'resData')
  365. if (resData) {
  366. if (resData.qualityControl != 2) {
  367. this.isCheck = false;
  368. // resData.supplierName = supplierName;
  369. // resData.supplierMark = supplierMark;
  370. res = [resData];
  371. } else {
  372. res = []
  373. this.$message.error('此数据已质检,无需再次质检!');
  374. return
  375. }
  376. }
  377. }
  378. console.log(res, '来料清单');
  379. if (res.length > 0) {
  380. let _arr1 = [];
  381. _arr1 = res.map((m) => {
  382. m.sourceId = m.id;
  383. m.productCategoryId = productCategoryId;
  384. m.productCategoryName = productCategoryName;
  385. delete m.id;
  386. return {
  387. ...m
  388. };
  389. });
  390. this.packingList = _arr1;
  391. this.pagination.total = this.packingList.length;
  392. console.log(this.packingList, '来料清单');
  393. if (this.packingList.length > 1) {
  394. this.baseForm.productNumber = this.packingList.length;
  395. } else {
  396. this.baseForm.productNumber = this.packingList[0].measureQuantity;
  397. }
  398. this.aaa();
  399. } else {
  400. this.packingList = [];
  401. }
  402. },
  403. aaa() {
  404. console.log('aaa')
  405. if (this.baseForm.qualityMode == 1) {
  406. this.sampleList = [];
  407. if (this.baseForm.isUnpack != null && this.baseForm.isUnpack != undefined && this.baseForm.isUnpack != '') {
  408. if (this.baseForm.isUnpack == 2) {
  409. const num = Number(this.baseForm.productNumber || 0);
  410. if (num) {
  411. this.getUnpackSamList(this.packingList, num)
  412. }
  413. } else if (this.baseForm.isUnpack == 1) {
  414. if (this.baseForm.qualityMode == 1) {
  415. this.sampleList = this.packingList;
  416. this.samplePagination.currentPage = 1;
  417. this.samplePagination.total = this.packingList.length;
  418. } else {
  419. this.sampleList = [];
  420. }
  421. }
  422. } else {
  423. if (!this.isCheck) {
  424. const num = Number(this.baseForm.productNumber || 0);
  425. if (num) {
  426. this.getUnpackSamList(this.packingList, num)
  427. }
  428. } else {
  429. if (this.baseForm.qualityMode == 1) {
  430. this.sampleList = this.packingList;
  431. this.samplePagination.currentPage = 1;
  432. this.samplePagination.total = this.packingList.length;
  433. } else {
  434. this.sampleList = [];
  435. }
  436. }
  437. }
  438. } else {
  439. this.sampleList = [];
  440. }
  441. },
  442. getUnpackSamList(list, num) {
  443. let data = [];
  444. list.forEach(oldItem => {
  445. const newMeasureQuantity = oldItem.measureQuantity / this.baseForm.productNumber;
  446. const newWeight = parseFloat((oldItem.weight / this.baseForm.productNumber).toFixed(2))
  447. delete oldItem.id;
  448. for (let i = 0; i < num; i++) {
  449. data.push({
  450. ...oldItem,
  451. measureQuantity: newMeasureQuantity,
  452. weight: newWeight
  453. });
  454. }
  455. });
  456. console.log(data, 'datadatadatadatadatadata', num)
  457. this.sampleList = data;
  458. this.samplePagination.currentPage = 1;
  459. this.samplePagination.total = data.length;
  460. },
  461. async getQualityTemplate(productCode, ids) {
  462. await getQualityTemplateList({
  463. productCode: productCode,
  464. qualityQlanId: ids
  465. }).then((res) => {
  466. if (Object.keys(res).length === 0) {
  467. this.$message.error('请确认该物品是否配置质检方案!');
  468. return;
  469. }
  470. this.baseForm.sampleProportion = res.checkProportion;
  471. this.baseForm.inspectionStandards = res?.inspectionStandards;
  472. let combinedList = [];
  473. for (let i = 0; i < res.qualityTemplateVOList.length; i++) {
  474. res.qualityTemplateVOList[i].inspectionItemVOList = res.qualityTemplateVOList[i]?.inspectionItemVOList.map(
  475. (item) => {
  476. item.templateId = res.qualityTemplateVOList[i]?.id;
  477. item.qualitySchemeTemplateCode =
  478. res.qualityTemplateVOList[i]?.qualitySchemeTemplateCode;
  479. item.qualitySchemeTemplateName =
  480. res.qualityTemplateVOList[i]?.qualitySchemeTemplateName;
  481. delete item.id;
  482. return {
  483. ...item
  484. };
  485. }
  486. );
  487. combinedList = combinedList.concat(res.qualityTemplateVOList[i].inspectionItemVOList);
  488. console.log(combinedList, '质检方案');
  489. this.schemeList = combinedList;
  490. this.schemePagination.currentPage = 1;
  491. this.schemePagination.total = this.schemeList.length;
  492. }
  493. });
  494. },
  495. handleSelectionChange(selection) {
  496. if (this.baseForm.qualityMode === 2) {
  497. this.selectedList = selection;
  498. this.sampleList = selection;
  499. // console.log(this.sampleList, 'sampleList勾选列表')
  500. // this.samplePagination.currentPage = 1;
  501. // this.samplePagination.total = selection.length;
  502. this.baseForm.sampleNumber = selection.length;
  503. }
  504. },
  505. // 来料清单列表分页方法
  506. handleSizeChange(val) {
  507. this.pagination.pageSize = val;
  508. this.pagination.currentPage = 1;
  509. },
  510. handleCurrentChange(val) {
  511. this.pagination.currentPage = val;
  512. },
  513. // 样品列表分页方法
  514. handleSampleSizeChange(val) {
  515. this.samplePagination.pageSize = val;
  516. this.samplePagination.currentPage = 1;
  517. },
  518. handleSampleCurrentChange(val) {
  519. this.samplePagination.currentPage = val;
  520. },
  521. // 质检方案分页方法
  522. handleSchemeSizeChange(val) {
  523. this.schemePagination.pageSize = val;
  524. this.schemePagination.currentPage = 1;
  525. },
  526. handleSchemeCurrentChange(val) {
  527. this.schemePagination.currentPage = val;
  528. },
  529. changeModel(val) {
  530. this.baseForm.qualityMode = val;
  531. console.log(this.baseForm.productNumber, 'productNumberproductNumber数量')
  532. if (this.baseForm.qualityMode == 1) {
  533. this.aaa()
  534. } else {
  535. this.sampleList = [];
  536. }
  537. },
  538. changeNumber(val) {
  539. if (this.baseForm.qualityMode !== 2) {
  540. return;
  541. }
  542. if (val <= 0) {
  543. this.$refs.showPackingListTable.clearSelection();
  544. return;
  545. }
  546. console.log('取样数量', val, this.isCheck)
  547. if (this.isCheck) {
  548. if (val > this.packingList.length) {
  549. this.$message.warning('取样数量不能大于来源清单数量!');
  550. return;
  551. }
  552. const rows = this.packingList.slice(0, val);
  553. rows.forEach((row) => {
  554. this.$refs.showPackingListTable.toggleRowSelection(row);
  555. });
  556. if (this.baseForm.qualityMode == 1) {
  557. this.sampleList = this.packingList;
  558. this.samplePagination.currentPage = 1;
  559. this.samplePagination.total = this.packingList.length;
  560. } else {
  561. this.sampleList = this.selectedList;
  562. }
  563. } else {
  564. if (val > this.packingList[0].measureQuantity) {
  565. this.$message.warning('取样数量不能大于计量数量!');
  566. return;
  567. }
  568. const num = Number(val);
  569. if (num) {
  570. this.getUnpackSamList(this.packingList, num);
  571. }
  572. }
  573. },
  574. resetTable() {
  575. this.$nextTick(() => {
  576. this.table1();
  577. this.table2();
  578. });
  579. },
  580. table1() {
  581. this.packingList = [];
  582. this.schemeList = [];
  583. },
  584. table2() {
  585. this.$nextTick(() => {
  586. this.sampleList = [];
  587. });
  588. },
  589. resetForm() {
  590. this.baseForm = { ...this.defaultForm() };
  591. },
  592. handleClose() {
  593. this.resetForm();
  594. this.resetTable();
  595. this.visible = false;
  596. },
  597. /* 保存编辑 */
  598. handleSave() {
  599. this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
  600. if (!valid) {
  601. return false;
  602. }
  603. this.loading = true;
  604. if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
  605. this.baseForm.isUnpack = this.isCheck ? 1 : 2;
  606. }
  607. let params = {
  608. ...this.baseForm,
  609. qualityInventoryList: this.packingList,
  610. sampleList: this.sampleList,
  611. planTemplateList: this.schemeList,
  612. };
  613. console.log(params, 'params');
  614. if (this.btnType == 'issued' && this.schemeList.length < 1) {
  615. this.$message.warning('质检方案不能为空!');
  616. return;
  617. }
  618. let URL =
  619. this.btnType == 'add' ? save : this.btnType == 'edit' ? update : '';
  620. console.log(params, 'params')
  621. URL(params)
  622. .then((msg) => {
  623. this.loading = false;
  624. this.$message.success(msg);
  625. this.handleClose();
  626. this.$emit('done');
  627. })
  628. .catch((e) => {
  629. this.loading = false;
  630. });
  631. });
  632. this.loading = false;
  633. },
  634. handleIssued() {
  635. if (this.sampleList.length == 0) {
  636. this.$message.warning('样品清单为空!先进行修改操作再下发!');
  637. return;
  638. }
  639. this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
  640. if (!valid) {
  641. return false;
  642. }
  643. this.loading = true;
  644. if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
  645. this.baseForm.isUnpack = this.isCheck ? 1 : 2;
  646. }
  647. let params = {
  648. ...this.baseForm,
  649. qualityInventoryList: this.packingList,
  650. sampleList: this.sampleList,
  651. planTemplateList: this.schemeList,
  652. };
  653. console.log(params, 'params');
  654. if (this.btnType == 'issued' && this.schemeList.length < 1) {
  655. this.$message.warning('质检方案不能为空!');
  656. return;
  657. }
  658. planIssued(params)
  659. .then((msg) => {
  660. this.loading = false;
  661. this.$message.success(msg);
  662. this.handleClose();
  663. this.$emit('done');
  664. })
  665. .catch((e) => {
  666. this.loading = false;
  667. });
  668. });
  669. this.loading = false;
  670. }
  671. }
  672. };
  673. </script>
  674. <style lang="scss" scoped>
  675. .location-warp {
  676. display: flex;
  677. .detail {
  678. margin-left: 10px;
  679. }
  680. }
  681. :deep(.el-form-item__content .el-input-group__prepend) {
  682. background-color: #fff;
  683. }
  684. :deep(.el-dialog:not(.ele-dialog-form) .el-dialog__body .el-form .el-form-item:last-child) {
  685. margin-bottom: 22px;
  686. }
  687. .add-product {
  688. width: 100%;
  689. display: flex;
  690. align-items: center;
  691. justify-content: flex-end;
  692. font-size: 30px;
  693. color: #1890ff;
  694. margin: 10px 0;
  695. cursor: pointer;
  696. }
  697. .el-pagination {
  698. padding: 12px 16px;
  699. background: #fff;
  700. border: 1px solid#ebeef5;
  701. border-top: none;
  702. }
  703. </style>