newQualityContentTabs.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. <!-- 质检内容 -->
  2. <template>
  3. <el-row>
  4. <!-- 选择质检方案 -->
  5. <inspectionTemplateDialog
  6. ref="inspectionTemplateRef"
  7. @choose="inspectionTemplateSuccess"
  8. ></inspectionTemplateDialog>
  9. <header-title title="质检内容">
  10. <el-button
  11. type="primary"
  12. :loading="loading"
  13. v-if="type != 'detail'"
  14. @click="$emit('batch-quality')"
  15. >批量质检</el-button
  16. >
  17. <!-- <el-button
  18. type="primary"
  19. :loading="loading"
  20. v-if="type != 'detail'"
  21. @click="$emit('batch-dispose')"
  22. >批量处置</el-button
  23. > -->
  24. </header-title>
  25. <el-tabs v-model="activeNameKK" @tab-click="handleClick">
  26. <!-- -->
  27. <el-tab-pane label="来源清单" name="1">
  28. <ele-pro-table
  29. ref="sourceTable"
  30. :columns="tableColumns1"
  31. :datasource="datasource"
  32. @selection-change="handleSelectionChange"
  33. :initLoad="false"
  34. :pagination="true"
  35. >
  36. <template
  37. v-slot:toolbar
  38. v-if="form.qualityMode == 2 && type != 'detail'"
  39. >
  40. <el-dropdown trigger="click" @command="handleSampleNumber">
  41. <el-link type="primary" icon="el-icon-plus">取样</el-link>
  42. <el-dropdown-menu slot="dropdown">
  43. <el-dropdown-item command="1">取整样</el-dropdown-item>
  44. <el-dropdown-item command="2">取小样</el-dropdown-item>
  45. </el-dropdown-menu>
  46. </el-dropdown>
  47. </template>
  48. <template v-slot:toolkit v-if="form.qualityMode == 2">
  49. <el-row>
  50. <el-form
  51. ref="ruleForm"
  52. :model="formData"
  53. label-width="60px"
  54. size="mini"
  55. :rules="rules"
  56. class="flex"
  57. :show-message="false"
  58. >
  59. <el-col :span="6" v-if="conditionType == 2">
  60. <el-form-item
  61. prop="number"
  62. label-width="0"
  63. style="margin-bottom: 0"
  64. >
  65. <el-input
  66. v-model="formData.number"
  67. placeholder="请输入"
  68. size="mini"
  69. ></el-input>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="6" v-if="conditionType == 2">
  73. <el-form-item
  74. prop="sampleUnit"
  75. label-width="0"
  76. style="margin: 0"
  77. >
  78. <DictSelection
  79. dictName="计量单位"
  80. clearable
  81. v-model="formData.sampleUnit"
  82. size="mini"
  83. @change="changeSamUnit"
  84. >
  85. </DictSelection>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="8" v-if="conditionType == 2">
  89. <el-form-item prop="portion" label="数量" style="margin: 0">
  90. <el-input
  91. v-model="formData.portion"
  92. placeholder="请输入"
  93. size="mini"
  94. ></el-input>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="10" v-if="conditionType == 1">
  98. <el-form-item prop="portion" label="数量" style="margin: 0">
  99. <el-input
  100. v-model="formData.portion"
  101. placeholder="请输入"
  102. size="mini"
  103. ></el-input>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="10" v-if="conditionType == 1">
  107. <el-form-item
  108. prop="packingUnit"
  109. label="单位"
  110. style="margin: 0"
  111. >
  112. <el-select
  113. v-model="formData.packingUnit"
  114. placeholder="请选择"
  115. >
  116. <el-option
  117. v-for="item in packingSpecificationOption"
  118. :key="item.id"
  119. :label="item.conversionUnit"
  120. :value="item.id"
  121. >
  122. </el-option>
  123. </el-select>
  124. </el-form-item>
  125. </el-col>
  126. <el-col
  127. :span="4"
  128. style="text-align: right"
  129. v-if="conditionType == 2"
  130. >
  131. <el-button
  132. type="primary"
  133. size="mini"
  134. @click="handleSampleSubmit"
  135. style="margin-right: 12px"
  136. >确认</el-button
  137. >
  138. </el-col>
  139. <el-col
  140. :span="4"
  141. style="text-align: right"
  142. v-if="conditionType == 1"
  143. >
  144. <el-button
  145. type="primary"
  146. size="mini"
  147. @click="handleSampleSubmit"
  148. style="margin-right: 12px"
  149. >确认</el-button
  150. >
  151. </el-col>
  152. </el-form>
  153. </el-row>
  154. </template>
  155. <template v-slot:materielDesignation="{ row }">
  156. <el-input
  157. v-model="row.materielDesignation"
  158. placeholder="请输入"
  159. ></el-input>
  160. </template>
  161. <template v-slot:clientCode="{ row }">
  162. <el-input v-model="row.clientCode" placeholder="请输入"></el-input>
  163. </template>
  164. <template v-slot:engrave="{ row }">
  165. <el-input v-model="row.engrave" placeholder="请输入"></el-input>
  166. </template>
  167. <template v-slot:weight="{ row }">
  168. <el-input v-model="row.weight" placeholder="请输入"></el-input>
  169. </template>
  170. </ele-pro-table>
  171. </el-tab-pane>
  172. <!-- -->
  173. <el-tab-pane label="样品清单" name="2">
  174. <el-table
  175. v-if="sampleList.length > 0"
  176. ref="showSampleListTable"
  177. :data="paginatedSampleList"
  178. tooltip-effect="dark"
  179. :max-height="300"
  180. border
  181. row-key="id"
  182. >
  183. <el-table-column
  184. label="序号"
  185. type="index"
  186. width="50"
  187. align="center"
  188. fixed="left"
  189. ></el-table-column>
  190. <template v-for="column in tableColumns">
  191. <el-table-column
  192. :key="column.prop"
  193. :label="column.label"
  194. :prop="column.prop"
  195. :fixed="column.fixed"
  196. :show-overflow-tooltip="true"
  197. :width="column.width"
  198. :align="column.align"
  199. >
  200. <template slot-scope="scope">
  201. <template v-if="column.prop === 'categoryCode'">
  202. <el-link
  203. type="primary"
  204. :underline="false"
  205. @click="handleDetail(scope.$index, scope.row, 'detail')"
  206. >
  207. {{ scope.row.categoryCode }}
  208. </el-link>
  209. </template>
  210. <template v-else-if="column.prop === 'materielDesignation'">
  211. <el-input
  212. :disabled="status"
  213. v-model="scope.row.materielDesignation"
  214. size="mini"
  215. v-direction="{ x: 0, y: scope.$index }"
  216. ></el-input>
  217. </template>
  218. <template v-else-if="column.prop === 'clientCode'">
  219. <el-input
  220. :disabled="status"
  221. v-model="scope.row.clientCode"
  222. size="mini"
  223. v-direction="{ x: 1, y: scope.$index }"
  224. ></el-input>
  225. </template>
  226. <template v-else-if="column.prop === 'engrave'">
  227. <el-input
  228. :disabled="status"
  229. v-model="scope.row.engrave"
  230. size="mini"
  231. v-direction="{ x: 2, y: scope.$index }"
  232. ></el-input>
  233. </template>
  234. <template v-else-if="column.prop === 'weight'">
  235. <el-input
  236. v-model="scope.row.weight"
  237. :disabled="status"
  238. oninput="value = value.replace(/[^\d.]/g, '')"
  239. :min="0"
  240. @input="inputWeight(scope.row, scope.$index)"
  241. size="mini"
  242. v-direction="{ x: 3, y: scope.$index }"
  243. ></el-input>
  244. </template>
  245. <template v-else>
  246. {{ scope.row[column.prop] }}
  247. </template>
  248. </template>
  249. </el-table-column>
  250. </template>
  251. <!-- *** fixed="right" -->
  252. <el-table-column
  253. label="处置状态"
  254. prop="disposeType"
  255. align="center"
  256. :show-overflow-tooltip="true"
  257. >
  258. <template slot-scope="scope">
  259. <span>{{ disposeTypeList[scope.row.disposeType] }}</span>
  260. </template>
  261. </el-table-column>
  262. <!-- *** fixed="right" -->
  263. <el-table-column
  264. label="处置时间"
  265. prop="disposeTime"
  266. align="center"
  267. :show-overflow-tooltip="true"
  268. >
  269. </el-table-column>
  270. <!-- *** fixed="right" -->
  271. <el-table-column
  272. label="质检状态"
  273. prop="qualityStatus"
  274. align="center"
  275. :show-overflow-tooltip="true"
  276. >
  277. <template slot-scope="scope">
  278. <span v-if="scope.row.qualityStatus == 0">未检</span>
  279. <span v-if="scope.row.qualityStatus == 1">已检</span>
  280. <span v-if="scope.row.qualityStatus == 2">待检</span>
  281. </template>
  282. </el-table-column>
  283. <el-table-column
  284. label="质检结果"
  285. prop="qualityResults"
  286. align="center"
  287. width="180"
  288. fixed="right"
  289. :show-overflow-tooltip="true"
  290. >
  291. <template slot-scope="scope">
  292. <el-select
  293. @change="selectQualityResultsChange"
  294. v-model="scope.row.qualityResults"
  295. placeholder="请选择"
  296. style="width: 100%"
  297. :disabled="type == 'detail'"
  298. size="mini"
  299. >
  300. <el-option
  301. v-for="item in qualityResultsList"
  302. :key="item.value"
  303. :label="item.label"
  304. :value="item.value"
  305. >
  306. </el-option>
  307. </el-select>
  308. </template>
  309. </el-table-column>
  310. <el-table-column
  311. label="操作"
  312. align="center"
  313. width="120"
  314. fixed="right"
  315. v-if="type != 'detail'"
  316. >
  317. <template slot-scope="scope">
  318. <el-link
  319. :type="scope.row.isValid ? 'primary' : 'danger'"
  320. :underline="false"
  321. @click="handleDetail(scope.$index, scope.row, 'report')"
  322. >
  323. 质检
  324. </el-link>
  325. <!-- <el-link
  326. type="primary"
  327. :underline="false"
  328. @click="handleDispose(scope.$index, scope.row, 'dispose')"
  329. >处置
  330. </el-link> -->
  331. </template>
  332. </el-table-column>
  333. </el-table>
  334. <el-pagination
  335. @size-change="handleSampleSizeChange"
  336. @current-change="handleSampleCurrentChange"
  337. :current-page="samplePagination.currentPage"
  338. :page-sizes="[10, 20, 50, 100]"
  339. :page-size="samplePagination.pageSize"
  340. layout="total, sizes, prev, pager, next, jumper"
  341. :total="sampleList.length"
  342. />
  343. </el-tab-pane>
  344. <!-- -->
  345. <el-tab-pane label="质检方案" name="3">
  346. <el-button
  347. v-if="type !== 'detail'"
  348. @click="addInspectionTemplate"
  349. type="primary"
  350. style="margin-top: 5px"
  351. >选择质检方案</el-button
  352. >
  353. <el-table
  354. :data="paginatedSchemeList"
  355. tooltip-effect="dark"
  356. :max-height="300"
  357. border
  358. row-key="id"
  359. >
  360. <el-table-column
  361. label="序号"
  362. type="index"
  363. width="50"
  364. align="center"
  365. ></el-table-column>
  366. <el-table-column
  367. label="质检方案编码"
  368. prop="qualitySchemeTemplateCode"
  369. align="center"
  370. >
  371. </el-table-column>
  372. <el-table-column
  373. label="质检方案名称"
  374. prop="qualitySchemeTemplateName"
  375. align="center"
  376. ></el-table-column>
  377. <el-table-column
  378. label="质检类型"
  379. prop="categoryLevelClassName"
  380. align="center"
  381. ></el-table-column>
  382. <el-table-column
  383. label="质检项编码"
  384. prop="inspectionCode"
  385. align="center"
  386. ></el-table-column>
  387. <el-table-column
  388. label="质检项名称"
  389. prop="inspectionName"
  390. align="center"
  391. ></el-table-column>
  392. <el-table-column label="工艺参数" prop="defaultValue" align="center">
  393. <template slot-scope="scope">
  394. <div style="display: flex; justify-content: center">
  395. <span>{{ scope.row.symbol }}</span>
  396. <span v-if="scope.row.textType == 3">
  397. {{ scope.row.minValue }}-{{ scope.row.maxValue }}
  398. </span>
  399. <span v-else>
  400. <span>{{ scope.row.defaultValue }}</span>
  401. </span>
  402. {{ scope.row.unitName }}
  403. </div>
  404. </template>
  405. </el-table-column>
  406. <el-table-column
  407. fixed="right"
  408. label="操作"
  409. width="80"
  410. v-if="type !== 'detail'"
  411. >
  412. <template slot-scope="scope">
  413. <el-popconfirm
  414. class="ele-action"
  415. title="确定要删除当前方案吗?"
  416. @confirm="handDel(scope.$index)"
  417. >
  418. <template v-slot:reference>
  419. <el-link
  420. type="danger"
  421. :underline="false"
  422. icon="el-icon-delete"
  423. >
  424. 删除
  425. </el-link>
  426. </template>
  427. </el-popconfirm>
  428. </template>
  429. </el-table-column>
  430. </el-table>
  431. <el-pagination
  432. @size-change="handleSchemeSizeChange"
  433. @current-change="handleSchemeCurrentChange"
  434. :current-page="schemePagination.currentPage"
  435. :page-sizes="[10, 20, 50, 100]"
  436. :page-size="schemePagination.pageSize"
  437. layout="total, sizes, prev, pager, next, jumper"
  438. :total="schemeList.length"
  439. />
  440. </el-tab-pane>
  441. </el-tabs>
  442. </el-row>
  443. </template>
  444. <script>
  445. import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
  446. import {
  447. getDetails,
  448. getCategoryPackageDisposition
  449. } from '@/api/classifyManage/itemInformation';
  450. import {
  451. save,
  452. update,
  453. getById,
  454. exeReportWork,
  455. queryQualitySamplContent,
  456. queryQualityTempleContent,
  457. queryQualityInventory
  458. } from '@/api/inspectionWork';
  459. import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
  460. export default {
  461. components: {
  462. inspectionTemplateDialog
  463. },
  464. watch: {
  465. schemeList: {
  466. handler(newVal, oldVal) {
  467. this.templateList = newVal;
  468. // console.log(newVal, 'schemeList');
  469. },
  470. deep: true,
  471. immediate: true
  472. },
  473. activeName: {
  474. handler(newVal) {
  475. this.activeNameKK = newVal;
  476. // console.log(newVal);
  477. }
  478. }
  479. },
  480. props: {
  481. type: String,
  482. packingList: Array,
  483. sampleList: Array,
  484. schemeList: Array,
  485. loading: Boolean,
  486. form: Object,
  487. ids: String,
  488. activeName: String,
  489. status: Boolean,
  490. productId: {
  491. type: String,
  492. default: ''
  493. }
  494. },
  495. data() {
  496. return {
  497. disposeTypeList: {
  498. 1: '返工',
  499. 2: '返修',
  500. 3: '报废',
  501. 4: '降级使用',
  502. 5: '让步接收',
  503. 6: '留样',
  504. 7: '消耗',
  505. 8: '回用/归批',
  506. 9: '转试销',
  507. 10: '退货'
  508. },
  509. templateList: [],
  510. planTemplateList: [],
  511. activeNameKK: '',
  512. samplePagination: { currentPage: 1, pageSize: 10 },
  513. schemePagination: { currentPage: 1, pageSize: 10 },
  514. qualityResultsList: [
  515. {
  516. value: 1,
  517. label: '合格'
  518. },
  519. {
  520. value: 2,
  521. label: '不合格'
  522. },
  523. {
  524. value: 3,
  525. label: '让步接收'
  526. }
  527. ],
  528. tableColumns: [
  529. {
  530. label: '样品编码',
  531. prop: 'sampleCode',
  532. width: '200',
  533. align: 'center',
  534. fixed: 'left'
  535. },
  536. {
  537. label: '编码',
  538. prop: 'categoryCode',
  539. align: 'center',
  540. fixed: 'left'
  541. },
  542. {
  543. label: '名称',
  544. prop: 'categoryName',
  545. align: 'center'
  546. },
  547. { label: '批次号', prop: 'batchNo', align: 'center' },
  548. { label: '发货条码', prop: 'barcodes', align: 'center' },
  549. { label: '包装编码', prop: 'packageNo', align: 'center' },
  550. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  551. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  552. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  553. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  554. {
  555. label: '供应商名称',
  556. prop: 'supplierName',
  557. align: 'center',
  558. width: '120'
  559. },
  560. {
  561. label: '供应商代号',
  562. prop: 'supplierCode',
  563. align: 'center',
  564. width: '120'
  565. },
  566. {
  567. label: '物料代号',
  568. prop: 'materielDesignation',
  569. align: 'center',
  570. slot: 'materielDesignation',
  571. width: '120'
  572. },
  573. {
  574. label: '客户代号',
  575. prop: 'clientCode',
  576. align: 'center',
  577. slot: 'clientCode',
  578. width: '120'
  579. },
  580. {
  581. label: '刻码',
  582. prop: 'engrave',
  583. align: 'center',
  584. slot: 'engrave',
  585. width: '120'
  586. },
  587. {
  588. label: '重量',
  589. prop: 'weight',
  590. align: 'center',
  591. slot: 'weight',
  592. width: '120'
  593. },
  594. {
  595. label: '重量单位',
  596. prop: 'weightUnit',
  597. align: 'center',
  598. width: 100
  599. },
  600. { label: '仓库', prop: 'warehouseName', align: 'center', width: 100 },
  601. { label: '货区', prop: 'areaName', align: 'center' },
  602. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  603. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  604. { label: '生产日期', prop: 'productionDate', align: 'center' },
  605. { label: '采购日期', prop: 'purchaseDate', align: 'center' }
  606. ],
  607. conditionType: null,
  608. formData: {
  609. number: 1,
  610. sampleUnit: '',
  611. portion: null,
  612. packingUnit: ''
  613. },
  614. rules: {
  615. number: [
  616. {
  617. required: true,
  618. message: '请输入',
  619. trigger: 'blur'
  620. }
  621. ],
  622. sampleUnit: [
  623. {
  624. required: true,
  625. message: '请选择样品单位',
  626. trigger: 'change'
  627. }
  628. ],
  629. portion: [
  630. {
  631. required: true,
  632. message: '请输入',
  633. trigger: 'blur'
  634. }
  635. ],
  636. packingUnit: [
  637. {
  638. required: true,
  639. message: '请选择',
  640. trigger: 'change'
  641. }
  642. ]
  643. },
  644. packingSpecificationOption: [] // 包装规格下拉
  645. };
  646. },
  647. computed: {
  648. showBtn() {
  649. return this.$route.query.qualityType == 2;
  650. },
  651. tableColumns1() {
  652. let arr = [
  653. // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
  654. // ? {
  655. // columnKey: 'selection',
  656. // type: 'selection',
  657. // width: 45,
  658. // align: 'center'
  659. // }
  660. // : null,
  661. {
  662. columnKey: 'selection',
  663. type: 'selection',
  664. width: 45,
  665. align: 'center'
  666. },
  667. {
  668. columnKey: 'index',
  669. label: '序号',
  670. type: 'index',
  671. width: 55,
  672. align: 'center',
  673. fixed: 'left'
  674. },
  675. {
  676. label: '编码',
  677. prop: 'categoryCode',
  678. width: 150,
  679. align: 'center',
  680. showOverflowTooltip: true
  681. },
  682. {
  683. label: '名称',
  684. prop: 'categoryName',
  685. width: '150',
  686. align: 'center',
  687. width: 120,
  688. showOverflowTooltip: true
  689. },
  690. { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
  691. { label: '发货条码', prop: 'barcodes', align: 'center' },
  692. {
  693. label: '包装编码',
  694. prop: 'packageNo',
  695. align: 'center',
  696. width: 120,
  697. showOverflowTooltip: true
  698. },
  699. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  700. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  701. // {
  702. // label: '包装规格',
  703. // prop: 'packingSpecification',
  704. // align: 'center',
  705. // width: 180
  706. // },
  707. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  708. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  709. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  710. { label: '客户代号', prop: 'clientCode', align: 'center' },
  711. {
  712. label: '供应商名称',
  713. prop: 'supplierName',
  714. align: 'center',
  715. width: 120,
  716. showOverflowTooltip: true
  717. },
  718. {
  719. label: '供应商代号',
  720. prop: 'supplierCode',
  721. align: 'center',
  722. width: '120'
  723. },
  724. { label: '刻码', prop: 'engrave', align: 'center' },
  725. { label: '重量', prop: 'weight', align: 'center' },
  726. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  727. {
  728. label: '仓库',
  729. prop: 'warehouseName',
  730. align: 'center',
  731. width: 120,
  732. showOverflowTooltip: true
  733. },
  734. { label: '货区', prop: 'areaName', align: 'center' },
  735. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  736. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  737. {
  738. label: '生产日期',
  739. prop: 'productionDate',
  740. align: 'center',
  741. width: 120,
  742. showOverflowTooltip: true
  743. },
  744. {
  745. label: '采购日期',
  746. prop: 'purchaseDate',
  747. align: 'center',
  748. width: 120,
  749. showOverflowTooltip: true
  750. }
  751. ];
  752. return arr;
  753. },
  754. // 分页后的样品列表
  755. paginatedSampleList() {
  756. const { currentPage, pageSize } = this.samplePagination;
  757. const start = (currentPage - 1) * pageSize;
  758. const end = start + pageSize;
  759. return this.sampleList?.slice(start, end);
  760. },
  761. // 分页后的质检方案列表
  762. paginatedSchemeList() {
  763. const { currentPage, pageSize } = this.schemePagination;
  764. const start = (currentPage - 1) * pageSize;
  765. const end = start + pageSize;
  766. return this.templateList?.slice(start, end);
  767. // return this.schemeList?.slice(start, end);
  768. }
  769. },
  770. created() {
  771. this.activeNameKK = this.activeName;
  772. this.reload({ qualityWorkerId: this.ids });
  773. let direction = this.$getDirection();
  774. direction.on('keyup', function (e, val) {
  775. if (e.keyCode == 39) {
  776. direction.next();
  777. }
  778. if (e.keyCode == 37) {
  779. direction.previous();
  780. }
  781. if (e.keyCode == 38) {
  782. direction.previousLine();
  783. }
  784. if (e.keyCode == 40) {
  785. direction.nextLine();
  786. }
  787. });
  788. },
  789. methods: {
  790. async datasource({ page, limit, where }) {
  791. const res = await queryQualityInventory({
  792. ...where,
  793. pageNum: page,
  794. size: limit
  795. });
  796. if (res.list.length == 0) {
  797. return res;
  798. }
  799. // 包装数量的字段
  800. // if (!this.productId) {
  801. // return res;
  802. // }
  803. // const result = await getCategoryPackageDisposition({
  804. // categoryIds: [this.productId]
  805. // });
  806. // let str = '';
  807. // if (result.length) {
  808. let o = res.list[0];
  809. let listArr = [];
  810. if (o.measureUnit) {
  811. listArr.push({
  812. packageCellTotal: 1,
  813. conversionUnit: o.measureUnit,
  814. id: '111'
  815. });
  816. }
  817. if (o.packingUnit) {
  818. listArr.push({
  819. packageCellTotal: o.measureQuantity - 0,
  820. conversionUnit: o.packingUnit,
  821. id: '222'
  822. });
  823. }
  824. // result.map((el, index) => {
  825. // // let Unit = el.conversionUnit.trim();
  826. // // if (Unit == o.packingUnit.trim() || Unit == o.measureUnit.trim()) {
  827. // // listArr.push(el);
  828. // // }
  829. // if (index == 0) {
  830. // // el.packageCellTotal = el.packageCell - 0;
  831. // return;
  832. // }
  833. // if (index === result.length - 1) {
  834. // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit}`;
  835. // } else {
  836. // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit},`;
  837. // }
  838. // // if (index == 1) {
  839. // // el.packageCellTotal = el.packageCell - 0;
  840. // // return;
  841. // // }
  842. // // 计算乘法的规则
  843. // // el.packageCellTotal =
  844. // // el.packageCell * result[index - 1].packageCellTotal;
  845. // });
  846. res.list.map((el) => {
  847. el.weightProportion = el.weight
  848. ? (el.weight / el.measureQuantity).toFixed(4)
  849. : 0;
  850. el.weightProportion = el.weightProportion - 0;
  851. });
  852. this.packingSpecificationOption = listArr;
  853. return res;
  854. },
  855. reload(where) {
  856. this.$nextTick(() => {
  857. if (this.$refs.sourceTable && this.$refs.sourceTable.reload)
  858. this.$refs.sourceTable.reload({ page: 1, where: where });
  859. });
  860. },
  861. tableSelClear() {
  862. this.$refs.sourceTable.clearSelection();
  863. },
  864. handleSelectionChange(selection) {
  865. if (this.form.conditionType == 2) {
  866. if (this.form.isUnpack == 2) {
  867. this.$set(this.form, 'sampleNumber', this.formData.portion);
  868. } else {
  869. this.formData.portion = selection.length;
  870. this.$set(this.form, 'sampleNumber', selection.length);
  871. }
  872. this.formData.sampleUnit = selection[0]?.measureUnit;
  873. this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  874. } else if (this.form.conditionType == 1) {
  875. this.$set(this.form, 'sampleNumber', this.formData.portion);
  876. }
  877. // this.formData.portion = selection.length;
  878. // this.formData.sampleUnit = selection[0]?.measureUnit;
  879. //
  880. // this.$set(this.form, 'sampleNumber', selection.length);
  881. // this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  882. this.$emit('handleSelectionChange', selection);
  883. },
  884. handleSampleNumber(val) {
  885. this.conditionType = val;
  886. this.form.sampleUnit = '';
  887. this.$emit('getConditionType', val);
  888. //取整样
  889. // let data = this.$refs.sourceTable.getData()
  890. // this.$emit('getSelectedList')
  891. // if (this.selectedList.length == 0) {
  892. // this.$message.warning('请先选择样品!');
  893. // }
  894. // if (val == 1) {
  895. // // this.activeName = '2'
  896. // this.$emit('handleSample1', val, data)
  897. // } else if (val == 2) {
  898. // this.tableSelClear();
  899. // this.$emit('handleSample1', val, data)
  900. // }
  901. },
  902. handleInputNumber(val) {
  903. let packingList = this.$refs.sourceTable.getData();
  904. const maxValue =
  905. packingList.length > 1
  906. ? packingList.length
  907. : packingList[0].measureQuantity;
  908. if (val > maxValue) {
  909. this.$message.warning('数量不能大于计量数量!');
  910. this.formData.number = maxValue;
  911. return;
  912. }
  913. },
  914. handleInput(val) {
  915. if (val == 0 || val == '' || val == null) {
  916. this.$refs.sourceTable.clearSelection();
  917. return;
  918. }
  919. let packingList = this.$refs.sourceTable.getData();
  920. if (!packingList || packingList.length === 0) {
  921. return;
  922. }
  923. // 计算 packingList 中 measureQuantity 字段的总和
  924. const measureQuantitySum = packingList.reduce((sum, item) => {
  925. const quantity = Number(item.measureQuantity) || 0;
  926. return sum + quantity;
  927. }, 0);
  928. const portion = Number(this.formData.portion);
  929. // 清空当前选中
  930. this.$refs.sourceTable.clearSelection();
  931. if (this.form.conditionType == 2) {
  932. // 确保 portion 不超过数据列表长度
  933. const safePortion = Math.min(portion, packingList.length);
  934. if (this.form.isUnpack == 2) {
  935. const maxQuantity = Number(packingList[0].measureQuantity);
  936. if (portion > maxQuantity) {
  937. this.$message.warning('取样数量不能大于计量数量!');
  938. this.formData.portion = maxQuantity;
  939. }
  940. } else if (this.form.isUnpack == 1) {
  941. if (portion > packingList.length) {
  942. this.$message.warning('取样数量不能大于来源清单数量!');
  943. this.formData.portion = packingList.length;
  944. }
  945. }
  946. packingList.slice(0, safePortion).forEach((row) => {
  947. this.$refs.sourceTable.toggleRowSelection(row);
  948. });
  949. } else if (this.form.conditionType == 1) {
  950. // 确保 portion 不超过数据列表长度
  951. const safePortion = Math.min(portion, measureQuantitySum);
  952. if (portion > measureQuantitySum) {
  953. this.$message.warning('取样数量不能大于计量数量!');
  954. this.formData.portion = measureQuantitySum;
  955. }
  956. // 选中前 safePortion 行
  957. packingList.slice(0, safePortion).forEach((row) => {
  958. this.$refs.sourceTable.toggleRowSelection(row, true);
  959. });
  960. }
  961. // if (packingList.length > 1) {
  962. // if (portion > packingList.length) {
  963. // this.$message.warning('取样数量不能大于来源清单数量!');
  964. // this.formData.portion = packingList.length;
  965. // return;
  966. // }
  967. // packingList.slice(0, this.formData.portion).forEach(row => {
  968. // this.$refs.table12.toggleRowSelection(row);
  969. // });
  970. // } else {
  971. // const maxQuantity = Number(packingList[0].measureQuantity);
  972. // if (portion > maxQuantity) {
  973. // this.$message.warning('取样数量不能大于计量数量!');
  974. // this.formData.portion = maxQuantity;
  975. // return;
  976. // }
  977. // }
  978. },
  979. changeSamUnit(val) {
  980. this.$emit('changeSamUnit', val);
  981. },
  982. handleSampleSubmit() {
  983. this.$refs.ruleForm.validate((valid) => {
  984. if (valid) {
  985. //取小样 赋值右上角单位
  986. this.changeSamUnit(this.formData.sampleUnit);
  987. let params = {
  988. conditionType: this.conditionType,
  989. measureQ: this.formData.number,
  990. sampleUnit: this.formData.sampleUnit,
  991. portion: this.formData.portion
  992. };
  993. let specifications = this.packingSpecificationOption.find(
  994. (el) => el.id == this.formData.packingUnit
  995. );
  996. console.log('执行这里没', params, '---');
  997. this.$emit('handleSampleSubmit', params, specifications);
  998. }
  999. });
  1000. },
  1001. handleClick(tab) {
  1002. this.activeNameKK = tab.name;
  1003. },
  1004. tabsChange(val) {
  1005. this.activeNameKK = val;
  1006. },
  1007. tabsConditionType(val) {
  1008. this.conditionType = val;
  1009. },
  1010. checkSelectable(row, index) {
  1011. // 只有当质检方式为抽检(qualityMode=2)时 类型不是生产检验 才可选
  1012. return this.form.qualityType != 2 && this.form.qualityMode === 2;
  1013. },
  1014. handleDetail(index, row, type) {
  1015. this.$emit('handleDetail', index, row, type);
  1016. },
  1017. inputWeight(row, index) {
  1018. this.$emit('inputWeight', row, index);
  1019. },
  1020. handleDispose(index, row, type) {
  1021. this.$emit('handleDispose', { row, index });
  1022. },
  1023. handleSampleSizeChange(val) {
  1024. this.samplePagination.pageSize = val;
  1025. this.samplePagination.currentPage = 1;
  1026. },
  1027. handleSampleCurrentChange(val) {
  1028. this.samplePagination.currentPage = val;
  1029. },
  1030. handleSchemeSizeChange(val) {
  1031. this.schemePagination.pageSize = val;
  1032. this.schemePagination.currentPage = 1;
  1033. },
  1034. handleSchemeCurrentChange(val) {
  1035. this.schemePagination.currentPage = val;
  1036. },
  1037. selectQualityResultsChange() {
  1038. this.$emit('countQualityResults');
  1039. },
  1040. addInspectionTemplate() {
  1041. let type = this.form.qualityType || 1;
  1042. this.$refs.inspectionTemplateRef.open(type);
  1043. },
  1044. async inspectionTemplateSuccess(select) {
  1045. let data = await getQualityTemplateByIds({
  1046. templateIds: select.map((item) => item.id)
  1047. });
  1048. data.forEach((item) => {
  1049. item.id = null;
  1050. });
  1051. // 这里是选择方案后,数据新加,要改为覆盖
  1052. // this.templateList.push(...data);
  1053. // const strings = this.templateList.map((item) => JSON.stringify(item));
  1054. // const removeDupList = [...new Set(strings)];
  1055. // const result = removeDupList.map((item) => JSON.parse(item));
  1056. this.templateList = [];
  1057. this.templateList.push(...data);
  1058. this.templateList.forEach((item) => {
  1059. item['qualityResults'] = 1;
  1060. });
  1061. // this.templateList = result.map((item) => {
  1062. // item['qualityResults'] = 1;
  1063. // return item;
  1064. // });
  1065. this.sampleList.forEach((item, index) => {
  1066. this.$set(
  1067. this.sampleList[index],
  1068. 'qualitySampleTemplateList',
  1069. this.templateList
  1070. );
  1071. });
  1072. this.$set(this.form, 'templateList', this.templateList);
  1073. this.$emit('setSchemeList', this.templateList);
  1074. // this.schemeList = this.templateList;
  1075. this.schemePagination.total = this.templateList.length;
  1076. },
  1077. handDel(index) {
  1078. this.templateList.splice(index, 1);
  1079. this.sampleList.forEach((item, index) => {
  1080. this.$set(
  1081. this.sampleList[index],
  1082. 'qualitySampleTemplateList',
  1083. this.templateList.map((item) => {
  1084. item['qualityResults'] = 1;
  1085. return item;
  1086. })
  1087. );
  1088. });
  1089. }
  1090. }
  1091. };
  1092. </script>