edit copy.vue 26 KB

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