edit.vue 19 KB

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