edit.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息">
  5. <el-button @click="cancel">返回</el-button>
  6. <el-button type="primary" @click="save" :loading="loading" v-if="type != 'detail'">保存</el-button>
  7. <el-button type="primary" @click="handleReporting" :loading="loading" v-if="type != 'detail'">报工完成</el-button>
  8. </header-title>
  9. <base-info ref="baseInfoRefs" v-if="form" :form="form" :btnType="type" :qualityType1="qualityType"
  10. @changeModel="changeModel" @changeNumber="changeNumber"></base-info>
  11. <el-row>
  12. <header-title title="质检内容">
  13. <el-button type="primary" :loading="loading" v-if="type != 'detail'"
  14. @click="batchQuality(null, null, 'report')">批量质检</el-button>
  15. </header-title>
  16. <el-tabs v-model="activeName" @tab-click="handleClick">
  17. <el-tab-pane label="来源清单" name="1"></el-tab-pane>
  18. <el-tab-pane label="样品清单" name="2"></el-tab-pane>
  19. <el-tab-pane label="质检方案" name="3"></el-tab-pane>
  20. </el-tabs>
  21. </el-row>
  22. <!-- -->
  23. <el-row style="margin-top: 24px">
  24. <el-table v-show="activeName === '1'" v-if="packingList.length > 0" ref="showPackingListTable"
  25. :data="paginatedPackingList" tooltip-effect="dark" :max-height="300" border row-key="id"
  26. @selection-change="handleSelectionChange1">
  27. <el-table-column type="selection" width="55" align="center" :reserve-selection="true"
  28. :selectable="checkSelectable"></el-table-column>
  29. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  30. <template v-for="column in tableColumns">
  31. <el-table-column :label="column.label" :prop="column.prop" :show-overflow-tooltip="true"
  32. :width="column.width" :align="column.align"></el-table-column>
  33. </template>
  34. </el-table>
  35. <el-pagination v-show="activeName === '1' && packingList.length > 0" @size-change="handleSizeChange"
  36. @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 20, 50, 100]"
  37. :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next" :total="packingList.length"
  38. style="margin-top: 16px" />
  39. <!-- -->
  40. <el-table v-show="activeName === '2'" v-if="sampleList.length > 0" ref="showSampleListTable"
  41. :data="paginatedSampleList" tooltip-effect="dark" :max-height="300" border row-key="id">
  42. <el-table-column label="序号" type="index" width="50" align="center" fixed="left"></el-table-column>
  43. <template v-for="column in tableColumns">
  44. <el-table-column :key="column.prop" :label="column.label" :prop="column.prop" :fixed="column.fixed"
  45. :show-overflow-tooltip="true" :width="column.width" :align="column.align">
  46. <template slot-scope="scope">
  47. <template v-if="column.prop === 'categoryCode'">
  48. <el-link type="primary" :underline="false" @click="handleDetail(scope.$index, scope.row, 'detail')">
  49. {{ scope.row.categoryCode }}
  50. </el-link>
  51. </template>
  52. <template v-else>
  53. {{ scope.row[column.prop] }}
  54. </template>
  55. </template>
  56. </el-table-column>
  57. </template>
  58. <el-table-column label="重量" prop="weight" align="center" width="100" fixed="right"
  59. :show-overflow-tooltip="true">
  60. <template slot-scope="scope">
  61. <el-input type="number" v-model="scope.row.weight" :min="0"></el-input>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="重量单位" prop="weightUnit" align="center" width="80" fixed="right"
  65. :show-overflow-tooltip="true"></el-table-column>
  66. <el-table-column label="处置状态" prop="disposalStatus" align="center" width="80" fixed="right"
  67. :show-overflow-tooltip="true">
  68. <template slot-scope="scope">
  69. <span v-if="scope.row.disposalStatus == 1 && form.qualityType == 2">返工</span>
  70. <span v-if="scope.row.disposalStatus == 2 && form.qualityType == 2">返修</span>
  71. <span v-if="scope.row.disposalStatus == 3">报废</span>
  72. <span v-if="scope.row.disposalStatus == 4 && form.qualityType == 2">降级使用</span>
  73. <span v-if="scope.row.disposalStatus == 5 && form.qualityType == 2">让步接收</span>
  74. <span v-if="scope.row.disposalStatus == 6">留样</span>
  75. <span v-if="scope.row.disposalStatus == 7">消耗</span>
  76. <span v-if="scope.row.disposalStatus == 8">回用</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="处置时间" prop="disposeTime" align="center" width="100" fixed="right"
  80. :show-overflow-tooltip="true">
  81. </el-table-column>
  82. <el-table-column label="质检状态" prop="qualityStatus" align="center" width="120" fixed="right"
  83. :show-overflow-tooltip="true">
  84. <template slot-scope="scope">
  85. <span v-if="scope.row.qualityStatus == 0">未检</span>
  86. <span v-if="scope.row.qualityStatus == 1">已检</span>
  87. <span v-if="scope.row.qualityStatus == 2">待检</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="质检结果" prop="qualityResults" align="center" width="110" fixed="right"
  91. :show-overflow-tooltip="true">
  92. <template slot-scope="scope">
  93. <el-select v-model="scope.row.qualityResults" placeholder="请选择" style="width: 100%;"
  94. :disabled="type == 'detail'" size="mini">
  95. <el-option v-for="item in qualityResultsList" :key="item.value" :label="item.label" :value="item.value">
  96. </el-option>
  97. </el-select>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" align="center" width="120" fixed="right" v-if="type != 'detail'">
  101. <template slot-scope="scope">
  102. <el-link :type="scope.row.isValid ? 'primary' : 'danger'" :underline="false"
  103. @click="handleDetail(scope.$index, scope.row, 'report')">
  104. 质检
  105. </el-link>
  106. <el-link type='primary' :underline="false" @click="handleDispose(scope.$index, scope.row, 'dispose')"> 处置
  107. </el-link>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <el-pagination v-show="activeName === '2'" v-if="sampleList" @size-change="handleSampleSizeChange"
  112. @current-change="handleSampleCurrentChange" :current-page="samplePagination.currentPage"
  113. :page-sizes="[10, 20, 50, 100]" :page-size="samplePagination.pageSize"
  114. layout="total, sizes, prev, pager, next, jumper" :total="sampleList.length"
  115. style="margin-top: 10px"></el-pagination>
  116. <!-- -->
  117. <el-table v-show="activeName === '3'" ref="showSchemeListTable" :data="paginatedSchemeList"
  118. tooltip-effect="dark" :max-height="300" border row-key="id">
  119. <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
  120. <el-table-column label="质检方案编码" prop="qualitySchemeTemplateCode" align="center">
  121. </el-table-column>
  122. <el-table-column label="质检方案名称" prop="qualitySchemeTemplateName" align="center"></el-table-column>
  123. <el-table-column label="质检类型" prop="categoryLevelClassName" align="center"></el-table-column>
  124. <el-table-column label="质检项编码" prop="inspectionCode" align="center"></el-table-column>
  125. <el-table-column label="质检项名称" prop="inspectionName" align="center"></el-table-column>
  126. <el-table-column label="工艺参数" prop="defaultValue" align="center">
  127. </el-table-column>
  128. </el-table>
  129. <el-pagination v-show="activeName === '3'" @size-change="handleSchemeSizeChange"
  130. @current-change="handleSchemeCurrentChange" :current-page="schemePagination.currentPage"
  131. :page-sizes="[10, 20, 50, 100]" :page-size="schemePagination.pageSize"
  132. layout="total, sizes, prev, pager, next, jumper" :total="schemeList.length"
  133. style="margin-top: 10px"></el-pagination>
  134. </el-row>
  135. </el-card>
  136. <sampleListDialog ref="detailRef" @handleConfirm="handleConfirm" @handleDispose="handleDispose"></sampleListDialog>
  137. <sampleDisposeDialog ref="disposeRef" @handleDisposeConfirm="handleDisposeConfirm"></sampleDisposeDialog>
  138. </div>
  139. </template>
  140. <script>
  141. import baseInfo from './components/baseInfo.vue';
  142. import { getCode } from '@/api/login';
  143. import { save, update, getById, exeReportWork, queryQualitySamplContent, queryQualityTempleContent, queryQualityInventory } from '@/api/inspectionWork';
  144. import dictMixins from '@/mixins/dictMixins';
  145. // import term from './term';
  146. import sampleListDialog from './components/sampleListDialog.vue';
  147. import sampleDisposeDialog from './components/sampleDisposeDialog.vue';
  148. import { finishPageTab } from '@/utils/page-tab-util';
  149. export default {
  150. components: {
  151. baseInfo,
  152. // term
  153. sampleListDialog,
  154. sampleDisposeDialog
  155. },
  156. mixins: [dictMixins],
  157. data() {
  158. const defaultForm = function () {
  159. return {
  160. code: '',
  161. qualityType: null,
  162. qualityModeproduceRoutingId: '',
  163. produceRoutingName: '',
  164. produceTaskId: '',
  165. produceTaskName: '',
  166. productName: '',
  167. productCode: '',
  168. batchNo: '',
  169. specification: '',
  170. modelType: '',
  171. brandNo: '',
  172. total: '',
  173. qualifiedNumber: '',
  174. noQualifiedNumber: '',
  175. groupId: '',
  176. groupName: '',
  177. qualityId: '',
  178. qualityName: '',
  179. qualityTime: '',
  180. hours: '',
  181. qualificationRate: '',
  182. noQualificationRate: '',
  183. totalWeight: '',
  184. sampleNumber: '',
  185. imgUrl: [],
  186. qualityTimeStart: '',
  187. qualityTimeEnd: ''
  188. };
  189. };
  190. return {
  191. defaultForm,
  192. // 表单数据
  193. form: { ...defaultForm() },
  194. voList: [],
  195. // 表单验证规则
  196. categoryParamList: [],
  197. type: '',
  198. title: '',
  199. loading: false,
  200. tabTaskId: null,
  201. activeName: '2',
  202. qualityResultsList: [{
  203. value: 1,
  204. label: '合格'
  205. },
  206. {
  207. value: 2,
  208. label: '不合格'
  209. },
  210. {
  211. value: 3,
  212. label: '让步接收'
  213. }],
  214. tableColumns: [
  215. {
  216. label: '编码',
  217. prop: 'categoryCode',
  218. width: '160',
  219. align: 'center',
  220. fixed: 'left'
  221. },
  222. {
  223. label: '名称',
  224. prop: 'categoryName',
  225. width: '150',
  226. align: 'center'
  227. },
  228. { label: '批次号', prop: 'batchNo', align: 'center' },
  229. { label: '发货条码', prop: 'barcodes', align: 'center' },
  230. { label: '包装编码', prop: 'packageNo', align: 'center' },
  231. // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  232. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  233. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  234. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  235. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  236. { label: '客户代号', prop: 'clientCode', align: 'center' },
  237. { label: '刻码', prop: 'engrave', align: 'center' },
  238. { label: '重量', prop: 'weight', align: 'center' },
  239. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  240. { label: '仓库', prop: 'warehouseName', align: 'center' },
  241. { label: '货区', prop: 'areaName', align: 'center' },
  242. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  243. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  244. { label: '生产日期', prop: 'productionDate', align: 'center' },
  245. { label: '采购日期', prop: 'purchaseDate', align: 'center' },
  246. ],
  247. packingList: [],
  248. pagination: {
  249. currentPage: 1,
  250. pageSize: 10,
  251. total: 0
  252. },
  253. sampleList: [],
  254. samplePagination: {
  255. currentPage: 1,
  256. pageSize: 10,
  257. total: 0
  258. },
  259. schemeList: [],
  260. schemePagination: {
  261. currentPage: 1,
  262. pageSize: 10,
  263. total: 0
  264. },
  265. isValid: true,
  266. isStatus: true,
  267. SampleListbyReportList: [],
  268. qualityTimeStart: ''
  269. };
  270. },
  271. watch: {
  272. '$route.query.id': {
  273. handler(id) {
  274. if (id) {
  275. this.getDetail();
  276. } else {
  277. this.form = { ...defaultForm() };
  278. }
  279. }
  280. },
  281. },
  282. computed: {
  283. paginatedPackingList() {
  284. const start =
  285. (this.pagination.currentPage - 1) * this.pagination.pageSize;
  286. const end = start + this.pagination.pageSize;
  287. return this.packingList.slice(start, end);
  288. },
  289. // 分页后的样品列表
  290. paginatedSampleList() {
  291. const { currentPage, pageSize } = this.samplePagination;
  292. const start = (currentPage - 1) * pageSize;
  293. const end = start + pageSize;
  294. return this.sampleList?.slice(start, end);
  295. },
  296. // 分页后的质检方案列表
  297. paginatedSchemeList() {
  298. const { currentPage, pageSize } = this.schemePagination;
  299. const start = (currentPage - 1) * pageSize;
  300. const end = start + pageSize;
  301. return this.schemeList?.slice(start, end);
  302. }
  303. },
  304. created() {
  305. this.open()
  306. if (this.$route.query.id) {
  307. this.getDetail();
  308. }
  309. },
  310. methods: {
  311. checkSelectable(row, index) {
  312. // 只有当质检方式为抽检(qualityMode=2)时才可选
  313. return this.form.qualityMode === 2;
  314. },
  315. changeModel(val) {
  316. this.form.qualityMode = val;
  317. if (this.form.qualityMode == 1) {
  318. if (this.schemeList.length == 0) {
  319. for (let i = 0; i < this.packingList.length; i++) {
  320. console.log(this.packingList[i], 'selection[i]')
  321. this.$set(this.packingList[i], 'qualityStatus', 2)
  322. }
  323. }
  324. this.sampleList = this.packingList;
  325. this.samplePagination.currentPage = 1;
  326. this.samplePagination.total = this.packingList.length;
  327. } else {
  328. this.sampleList = [];
  329. }
  330. },
  331. changeNumber(val) {
  332. if (this.form.qualityMode !== 2) {
  333. return;
  334. }
  335. if (val <= 0) {
  336. this.$refs.showPackingListTable.clearSelection();
  337. return;
  338. }
  339. if (val > this.packingList.length) {
  340. this.$message.warning('取样数量不能大于物料明细总数!');
  341. return;
  342. }
  343. const rows = this.packingList.slice(0, val);
  344. rows.forEach((row) => {
  345. this.$refs.showPackingListTable.toggleRowSelection(row);
  346. });
  347. },
  348. getNowDate() {
  349. let date = new Date(),
  350. obj = {
  351. year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
  352. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  353. strDate: date.getDate(), // 获取当前日(1-31)
  354. hour: date.getHours(), //获取当前小时(0 ~ 23)
  355. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  356. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  357. };
  358. Object.keys(obj).forEach((key) => {
  359. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  360. });
  361. return obj;
  362. },
  363. handleSelectionChange1(selection) {
  364. console.log(selection, '勾选列表');
  365. if (this.form.qualityMode === 2) {
  366. this.selectedList = selection;
  367. if (this.schemeList.length == 0) {
  368. for (let i = 0; i < selection.length; i++) {
  369. console.log(selection[i], 'selection[i]')
  370. this.$set(selection[i], 'qualityStatus', 2)
  371. }
  372. }
  373. this.sampleList = selection;
  374. this.samplePagination.currentPage = 1;
  375. this.samplePagination.total = selection.length;
  376. this.form.sampleNumber = selection.length;
  377. }
  378. },
  379. async open() {
  380. this.type = this.$route.query.type;
  381. this.qualityType = this.$route.query.qualityType;
  382. this.title = this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
  383. if (this.type == 'add') {
  384. const code = await getCode('quality_work_order_code');
  385. this.form.code = code;
  386. } else {
  387. if (this.$route.query.qualityTimeStart != '' || this.$route.query.qualityTimeStart != null || this.$route.query.qualityTimeStart != undefined) {
  388. this.qualityTimeStart = this.getNowTime();
  389. console.log(this.qualityTimeStart, '开始报工时间')
  390. }
  391. }
  392. },
  393. getNowTime() {
  394. const nowDate = this.getNowDate()
  395. return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate + ' ' + nowDate.hour + ':' + nowDate.minute + ':' + nowDate.second
  396. },
  397. getNowTimes() {
  398. const nowDate = this.getNowDate()
  399. return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate
  400. },
  401. async getDetail() {
  402. getById(this.$route.query.id).then((res) => {
  403. this.form = res.data;
  404. this.tabTaskId =
  405. this.categoryParamList[0] && this.categoryParamList[0].id;
  406. if (this.form.groupId) {
  407. this.$nextTick(() => {
  408. if (this.$refs.baseInfoRefs) {
  409. this.$refs.baseInfoRefs.getUserList({
  410. groupId: this.form.groupId
  411. });
  412. this.$refs.baseInfoRefs.getTaskList();
  413. }
  414. });
  415. }
  416. });
  417. await this.queryQualityInventory()
  418. await this.queryQualitySamplContent()
  419. await this.queryQualityTempleContent()
  420. },
  421. async queryQualityInventory() {
  422. let res = await queryQualityInventory({ qualityWorkerId: this.$route.query.id });
  423. console.log(res, '清单列表');
  424. this.packingList = res;
  425. this.samplePagination.currentPage = 1;
  426. this.samplePagination.total = this.packingList.length;
  427. },
  428. async queryQualitySamplContent() {
  429. const res = await queryQualitySamplContent({ qualityWorkerId: this.$route.query.id })
  430. let addStatus = res.map((item) => {
  431. item.isValid = true;
  432. item.disposeTime = item.disposeTime ? item.disposeTime.split(' ')[0] : null;
  433. item.sampleDate = item.sampleDate ? item.sampleDate.split(' ')[0] : null;
  434. return {
  435. ...item
  436. }
  437. })
  438. console.log(addStatus, '样品清单')
  439. //样品
  440. this.sampleList = addStatus;
  441. this.samplePagination.currentPage = 1;
  442. this.samplePagination.total = this.sampleList.length;
  443. },
  444. async queryQualityTempleContent() {
  445. const res = await queryQualityTempleContent({ qualityWorkerId: this.$route.query.id })
  446. console.log(res, '222');
  447. // 方案
  448. this.schemeList = res;
  449. this.schemePagination.currentPage = 1;
  450. this.schemePagination.total = this.schemeList.length;
  451. },
  452. handleClick(tab) {
  453. this.activeName = tab.name;
  454. },
  455. // 来料清单列表分页方法
  456. handleSizeChange(val) {
  457. this.pagination.pageSize = val;
  458. this.pagination.currentPage = 1;
  459. },
  460. handleCurrentChange(val) {
  461. this.pagination.currentPage = val;
  462. },
  463. // 样品列表分页方法
  464. handleSampleSizeChange(val) {
  465. this.samplePagination.pageSize = val;
  466. this.samplePagination.currentPage = 1;
  467. },
  468. handleSampleCurrentChange(val) {
  469. this.samplePagination.currentPage = val;
  470. },
  471. // 质检方案分页方法
  472. handleSchemeSizeChange(val) {
  473. this.schemePagination.pageSize = val;
  474. this.schemePagination.currentPage = 1;
  475. },
  476. handleSchemeCurrentChange(val) {
  477. this.schemePagination.currentPage = val;
  478. },
  479. /* 保存编辑 */
  480. save() {
  481. this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
  482. if (!valid) {
  483. return false;
  484. }
  485. this.loading = true;
  486. let URL =
  487. this.type == 'add' ? save : this.type == 'edit' ? update : '';
  488. this.form.qualityTimeStart = new Date(this.qualityTimeStart)
  489. delete this.form['qualityTimeEnd']
  490. let params = {
  491. ...this.form,
  492. sampleList: this.sampleList,
  493. planTemplateList: this.schemeList,
  494. qualityInventoryList: this.packingList
  495. }
  496. URL(params)
  497. .then((msg) => {
  498. this.loading = false;
  499. this.$message.success(msg);
  500. this.cancel();
  501. this.$emit('done');
  502. })
  503. .catch((e) => {
  504. this.loading = false;
  505. });
  506. });
  507. },
  508. update() {
  509. this.loading = true;
  510. this.form['status'] = 1;
  511. update({ ...this.form })
  512. .then((msg) => {
  513. this.loading = false;
  514. this.$message.success(msg);
  515. this.$emit('done');
  516. })
  517. .catch((e) => {
  518. this.loading = false;
  519. });
  520. },
  521. restForm() {
  522. this.form = { ...this.defaultForm() };
  523. this.$nextTick(() => {
  524. this.$refs.baseInfoRefs.$refs.form1.clearValidate();
  525. });
  526. },
  527. cancel() {
  528. finishPageTab();
  529. this.$router.go(-1);
  530. },
  531. handleDetail(index, row, type) {
  532. if (!this.sampleList[index] || !this.schemeList) {
  533. return;
  534. }
  535. const selectedData = [];
  536. selectedData.push(this.sampleList[index])
  537. this.$refs.detailRef.openDia(index, row, type, selectedData, null);
  538. },
  539. handleDispose(index, row, type) {
  540. if (!this.sampleList[index]) {
  541. return;
  542. }
  543. this.sampleList[index].sampleDate = this.getNowTimes();
  544. this.sampleList[index].disposeTime = this.getNowTimes();
  545. console.log(index, row, type, this.qualityType)
  546. this.$refs.disposeRef.openDispose(index, row, type, this.qualityType);
  547. },
  548. // 报工
  549. handleReporting(index, row) {
  550. this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
  551. if (!valid) {
  552. return false;
  553. }
  554. for (let i = 0; i < this.sampleList.length; i++) {
  555. const qualityStatus = this.sampleList[i].qualityStatus;
  556. if (qualityStatus == '2') {
  557. this.$message.error('请完成以下样品质检!')
  558. this.loading = false;
  559. return
  560. }
  561. }
  562. this.form.qualityTimeEnd = new Date(this.getNowTime())
  563. this.form.qualityTimeStart = new Date(this.qualityTimeStart)
  564. let params = {
  565. ...this.form,
  566. sampleList: this.sampleList,
  567. planTemplateList: this.schemeList,
  568. qualityInventoryList: this.packingList
  569. }
  570. console.log(params, 'params')
  571. exeReportWork(params)
  572. .then((msg) => {
  573. this.loading = false;
  574. this.$message.success(msg);
  575. this.cancel();
  576. this.$emit('done');
  577. })
  578. .catch((e) => {
  579. this.loading = false;
  580. });
  581. })
  582. },
  583. // 处理确认事件
  584. handleDisposeConfirm(row, index) {
  585. if (index > -1) {
  586. this.$set(this.sampleList, index, row)
  587. }
  588. },
  589. //确认报工
  590. handleConfirm(list, index) {
  591. console.log(list)
  592. // 检查有效性
  593. for (const item of list) {
  594. for (const child of item.qualitySampleTemplateList) {
  595. console.log(child, 'child')
  596. if (!child.qualityResultContent || !child.qualityResults) {
  597. this.$message.error('请完善报工内容!');
  598. return;
  599. }
  600. }
  601. }
  602. console.log(list, 'listlistlistlist')
  603. list.forEach((item) => {
  604. if (item.qualitySampleTemplateList.some(child => child.qualityResults === 2)) {
  605. item.isValid = false;
  606. item.qualityResults = 2;
  607. } else {
  608. item.isValid = true;
  609. item.qualityResults = 1;
  610. }
  611. item.qualityStatus = 1;
  612. })
  613. if (index != null) {
  614. this.$set(this.sampleList, index, list[0]);
  615. } else {
  616. this.$set(this.sampleList, null, list);
  617. }
  618. console.log(this.sampleList, '222表')
  619. },
  620. // 批量质检
  621. batchQuality(index, row, type) {
  622. this.$refs.detailRef.openDia(null, null, type, this.sampleList, null)
  623. }
  624. }
  625. };
  626. </script>
  627. <style lang="scss" scoped></style>