newQualityContentTabs.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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. },
  472. activeName: {
  473. handler(newVal) {
  474. this.activeNameKK = newVal;
  475. // console.log(newVal);
  476. }
  477. }
  478. },
  479. props: {
  480. type: String,
  481. packingList: Array,
  482. sampleList: Array,
  483. schemeList: Array,
  484. loading: Boolean,
  485. form: Object,
  486. ids: String,
  487. activeName: String,
  488. status: Boolean,
  489. productId: {
  490. type: String,
  491. default: ''
  492. }
  493. },
  494. data() {
  495. return {
  496. disposeTypeList: {
  497. 1: '返工',
  498. 2: '返修',
  499. 3: '报废',
  500. 4: '降级使用',
  501. 5: '让步接收',
  502. 6: '留样',
  503. 7: '消耗',
  504. 8: '回用/归批',
  505. 9: '转试销',
  506. 10: '退货'
  507. },
  508. templateList: [],
  509. planTemplateList: [],
  510. activeNameKK: '',
  511. samplePagination: { currentPage: 1, pageSize: 10 },
  512. schemePagination: { currentPage: 1, pageSize: 10 },
  513. qualityResultsList: [
  514. {
  515. value: 1,
  516. label: '合格'
  517. },
  518. {
  519. value: 2,
  520. label: '不合格'
  521. },
  522. {
  523. value: 3,
  524. label: '让步接收'
  525. }
  526. ],
  527. tableColumns: [
  528. {
  529. label: '样品编码',
  530. prop: 'sampleCode',
  531. width: '200',
  532. align: 'center',
  533. fixed: 'left'
  534. },
  535. {
  536. label: '编码',
  537. prop: 'categoryCode',
  538. align: 'center',
  539. fixed: 'left'
  540. },
  541. {
  542. label: '名称',
  543. prop: 'categoryName',
  544. align: 'center'
  545. },
  546. { label: '批次号', prop: 'batchNo', align: 'center' },
  547. { label: '发货条码', prop: 'barcodes', align: 'center' },
  548. { label: '包装编码', prop: 'packageNo', align: 'center' },
  549. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  550. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  551. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  552. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  553. {
  554. label: '供应商名称',
  555. prop: 'supplierName',
  556. align: 'center',
  557. width: '120'
  558. },
  559. {
  560. label: '供应商代号',
  561. prop: 'supplierCode',
  562. align: 'center',
  563. width: '120'
  564. },
  565. {
  566. label: '物料代号',
  567. prop: 'materielDesignation',
  568. align: 'center',
  569. slot: 'materielDesignation',
  570. width: '120'
  571. },
  572. {
  573. label: '客户代号',
  574. prop: 'clientCode',
  575. align: 'center',
  576. slot: 'clientCode',
  577. width: '120'
  578. },
  579. {
  580. label: '刻码',
  581. prop: 'engrave',
  582. align: 'center',
  583. slot: 'engrave',
  584. width: '120'
  585. },
  586. {
  587. label: '重量',
  588. prop: 'weight',
  589. align: 'center',
  590. slot: 'weight',
  591. width: '120'
  592. },
  593. {
  594. label: '重量单位',
  595. prop: 'weightUnit',
  596. align: 'center',
  597. width: 100
  598. },
  599. { label: '仓库', prop: 'warehouseName', align: 'center', width: 100 },
  600. { label: '货区', prop: 'areaName', align: 'center' },
  601. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  602. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  603. { label: '生产日期', prop: 'productionDate', align: 'center' },
  604. { label: '采购日期', prop: 'purchaseDate', align: 'center' }
  605. ],
  606. conditionType: null,
  607. formData: {
  608. number: 1,
  609. sampleUnit: '',
  610. portion: null,
  611. packingUnit: ''
  612. },
  613. rules: {
  614. number: [
  615. {
  616. required: true,
  617. message: '请输入',
  618. trigger: 'blur'
  619. }
  620. ],
  621. sampleUnit: [
  622. {
  623. required: true,
  624. message: '请选择样品单位',
  625. trigger: 'change'
  626. }
  627. ],
  628. portion: [
  629. {
  630. required: true,
  631. message: '请输入',
  632. trigger: 'blur'
  633. }
  634. ],
  635. packingUnit: [
  636. {
  637. required: true,
  638. message: '请选择',
  639. trigger: 'change'
  640. }
  641. ]
  642. },
  643. packingSpecificationOption: [] // 包装规格下拉
  644. };
  645. },
  646. computed: {
  647. showBtn() {
  648. return this.$route.query.qualityType == 2;
  649. },
  650. tableColumns1() {
  651. let arr = [
  652. // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
  653. // ? {
  654. // columnKey: 'selection',
  655. // type: 'selection',
  656. // width: 45,
  657. // align: 'center'
  658. // }
  659. // : null,
  660. {
  661. columnKey: 'selection',
  662. type: 'selection',
  663. width: 45,
  664. align: 'center'
  665. },
  666. {
  667. columnKey: 'index',
  668. label: '序号',
  669. type: 'index',
  670. width: 55,
  671. align: 'center',
  672. fixed: 'left'
  673. },
  674. {
  675. label: '编码',
  676. prop: 'categoryCode',
  677. width: 150,
  678. align: 'center',
  679. showOverflowTooltip: true
  680. },
  681. {
  682. label: '名称',
  683. prop: 'categoryName',
  684. width: '150',
  685. align: 'center',
  686. width: 120,
  687. showOverflowTooltip: true
  688. },
  689. { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
  690. { label: '发货条码', prop: 'barcodes', align: 'center' },
  691. {
  692. label: '包装编码',
  693. prop: 'packageNo',
  694. align: 'center',
  695. width: 120,
  696. showOverflowTooltip: true
  697. },
  698. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  699. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  700. // {
  701. // label: '包装规格',
  702. // prop: 'packingSpecification',
  703. // align: 'center',
  704. // width: 180
  705. // },
  706. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  707. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  708. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  709. { label: '客户代号', prop: 'clientCode', align: 'center' },
  710. {
  711. label: '供应商名称',
  712. prop: 'supplierName',
  713. align: 'center',
  714. width: 120,
  715. showOverflowTooltip: true
  716. },
  717. {
  718. label: '供应商代号',
  719. prop: 'supplierCode',
  720. align: 'center',
  721. width: '120'
  722. },
  723. { label: '刻码', prop: 'engrave', align: 'center' },
  724. { label: '重量', prop: 'weight', align: 'center' },
  725. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  726. {
  727. label: '仓库',
  728. prop: 'warehouseName',
  729. align: 'center',
  730. width: 120,
  731. showOverflowTooltip: true
  732. },
  733. { label: '货区', prop: 'areaName', align: 'center' },
  734. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  735. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  736. {
  737. label: '生产日期',
  738. prop: 'productionDate',
  739. align: 'center',
  740. width: 120,
  741. showOverflowTooltip: true
  742. },
  743. {
  744. label: '采购日期',
  745. prop: 'purchaseDate',
  746. align: 'center',
  747. width: 120,
  748. showOverflowTooltip: true
  749. }
  750. ];
  751. return arr;
  752. },
  753. // 分页后的样品列表
  754. paginatedSampleList() {
  755. const { currentPage, pageSize } = this.samplePagination;
  756. const start = (currentPage - 1) * pageSize;
  757. const end = start + pageSize;
  758. return this.sampleList?.slice(start, end);
  759. },
  760. // 分页后的质检方案列表
  761. paginatedSchemeList() {
  762. const { currentPage, pageSize } = this.schemePagination;
  763. const start = (currentPage - 1) * pageSize;
  764. const end = start + pageSize;
  765. return this.templateList?.slice(start, end);
  766. // return this.schemeList?.slice(start, end);
  767. }
  768. },
  769. created() {
  770. this.activeNameKK = this.activeName;
  771. this.reload({ qualityWorkerId: this.ids });
  772. let direction = this.$getDirection();
  773. direction.on('keyup', function (e, val) {
  774. if (e.keyCode == 39) {
  775. direction.next();
  776. }
  777. if (e.keyCode == 37) {
  778. direction.previous();
  779. }
  780. if (e.keyCode == 38) {
  781. direction.previousLine();
  782. }
  783. if (e.keyCode == 40) {
  784. direction.nextLine();
  785. }
  786. });
  787. },
  788. methods: {
  789. async datasource({ page, limit, where }) {
  790. const res = await queryQualityInventory({
  791. ...where,
  792. pageNum: page,
  793. size: limit
  794. });
  795. if (res.list.length == 0) {
  796. return res;
  797. }
  798. // 包装数量的字段
  799. // if (!this.productId) {
  800. // return res;
  801. // }
  802. // const result = await getCategoryPackageDisposition({
  803. // categoryIds: [this.productId]
  804. // });
  805. // let str = '';
  806. // if (result.length) {
  807. let o = res.list[0];
  808. let listArr = [];
  809. if (o.measureUnit) {
  810. listArr.push({
  811. packageCellTotal: 1,
  812. conversionUnit: o.measureUnit,
  813. id: '111'
  814. });
  815. }
  816. if (o.packingUnit) {
  817. listArr.push({
  818. packageCellTotal: o.measureQuantity - 0,
  819. conversionUnit: o.packingUnit,
  820. id: '222'
  821. });
  822. }
  823. // result.map((el, index) => {
  824. // // let Unit = el.conversionUnit.trim();
  825. // // if (Unit == o.packingUnit.trim() || Unit == o.measureUnit.trim()) {
  826. // // listArr.push(el);
  827. // // }
  828. // if (index == 0) {
  829. // // el.packageCellTotal = el.packageCell - 0;
  830. // return;
  831. // }
  832. // if (index === result.length - 1) {
  833. // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit}`;
  834. // } else {
  835. // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit},`;
  836. // }
  837. // // if (index == 1) {
  838. // // el.packageCellTotal = el.packageCell - 0;
  839. // // return;
  840. // // }
  841. // // 计算乘法的规则
  842. // // el.packageCellTotal =
  843. // // el.packageCell * result[index - 1].packageCellTotal;
  844. // });
  845. res.list.map((el) => {
  846. el.weightProportion = el.weight
  847. ? (el.weight / el.measureQuantity).toFixed(4)
  848. : 0;
  849. el.weightProportion = el.weightProportion - 0;
  850. });
  851. this.packingSpecificationOption = listArr;
  852. return res;
  853. },
  854. reload(where) {
  855. this.$nextTick(() => {
  856. if (this.$refs.sourceTable && this.$refs.sourceTable.reload)
  857. this.$refs.sourceTable.reload({ page: 1, where: where });
  858. });
  859. },
  860. tableSelClear() {
  861. this.$refs.sourceTable.clearSelection();
  862. },
  863. handleSelectionChange(selection) {
  864. if (this.form.conditionType == 2) {
  865. if (this.form.isUnpack == 2) {
  866. this.$set(this.form, 'sampleNumber', this.formData.portion);
  867. } else {
  868. this.formData.portion = selection.length;
  869. this.$set(this.form, 'sampleNumber', selection.length);
  870. }
  871. this.formData.sampleUnit = selection[0]?.measureUnit;
  872. this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  873. } else if (this.form.conditionType == 1) {
  874. this.$set(this.form, 'sampleNumber', this.formData.portion);
  875. }
  876. // this.formData.portion = selection.length;
  877. // this.formData.sampleUnit = selection[0]?.measureUnit;
  878. //
  879. // this.$set(this.form, 'sampleNumber', selection.length);
  880. // this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  881. this.$emit('handleSelectionChange', selection);
  882. },
  883. handleSampleNumber(val) {
  884. this.conditionType = val;
  885. this.form.sampleUnit = '';
  886. this.$emit('getConditionType', val);
  887. //取整样
  888. // let data = this.$refs.sourceTable.getData()
  889. // this.$emit('getSelectedList')
  890. // if (this.selectedList.length == 0) {
  891. // this.$message.warning('请先选择样品!');
  892. // }
  893. // if (val == 1) {
  894. // // this.activeName = '2'
  895. // this.$emit('handleSample1', val, data)
  896. // } else if (val == 2) {
  897. // this.tableSelClear();
  898. // this.$emit('handleSample1', val, data)
  899. // }
  900. },
  901. handleInputNumber(val) {
  902. let packingList = this.$refs.sourceTable.getData();
  903. const maxValue =
  904. packingList.length > 1
  905. ? packingList.length
  906. : packingList[0].measureQuantity;
  907. if (val > maxValue) {
  908. this.$message.warning('数量不能大于计量数量!');
  909. this.formData.number = maxValue;
  910. return;
  911. }
  912. },
  913. handleInput(val) {
  914. if (val == 0 || val == '' || val == null) {
  915. this.$refs.sourceTable.clearSelection();
  916. return;
  917. }
  918. let packingList = this.$refs.sourceTable.getData();
  919. if (!packingList || packingList.length === 0) {
  920. return;
  921. }
  922. // 计算 packingList 中 measureQuantity 字段的总和
  923. const measureQuantitySum = packingList.reduce((sum, item) => {
  924. const quantity = Number(item.measureQuantity) || 0;
  925. return sum + quantity;
  926. }, 0);
  927. const portion = Number(this.formData.portion);
  928. // 清空当前选中
  929. this.$refs.sourceTable.clearSelection();
  930. if (this.form.conditionType == 2) {
  931. // 确保 portion 不超过数据列表长度
  932. const safePortion = Math.min(portion, packingList.length);
  933. if (this.form.isUnpack == 2) {
  934. const maxQuantity = Number(packingList[0].measureQuantity);
  935. if (portion > maxQuantity) {
  936. this.$message.warning('取样数量不能大于计量数量!');
  937. this.formData.portion = maxQuantity;
  938. }
  939. } else if (this.form.isUnpack == 1) {
  940. if (portion > packingList.length) {
  941. this.$message.warning('取样数量不能大于来源清单数量!');
  942. this.formData.portion = packingList.length;
  943. }
  944. }
  945. packingList.slice(0, safePortion).forEach((row) => {
  946. this.$refs.sourceTable.toggleRowSelection(row);
  947. });
  948. } else if (this.form.conditionType == 1) {
  949. // 确保 portion 不超过数据列表长度
  950. const safePortion = Math.min(portion, measureQuantitySum);
  951. if (portion > measureQuantitySum) {
  952. this.$message.warning('取样数量不能大于计量数量!');
  953. this.formData.portion = measureQuantitySum;
  954. }
  955. // 选中前 safePortion 行
  956. packingList.slice(0, safePortion).forEach((row) => {
  957. this.$refs.sourceTable.toggleRowSelection(row, true);
  958. });
  959. }
  960. // if (packingList.length > 1) {
  961. // if (portion > packingList.length) {
  962. // this.$message.warning('取样数量不能大于来源清单数量!');
  963. // this.formData.portion = packingList.length;
  964. // return;
  965. // }
  966. // packingList.slice(0, this.formData.portion).forEach(row => {
  967. // this.$refs.table12.toggleRowSelection(row);
  968. // });
  969. // } else {
  970. // const maxQuantity = Number(packingList[0].measureQuantity);
  971. // if (portion > maxQuantity) {
  972. // this.$message.warning('取样数量不能大于计量数量!');
  973. // this.formData.portion = maxQuantity;
  974. // return;
  975. // }
  976. // }
  977. },
  978. changeSamUnit(val) {
  979. this.$emit('changeSamUnit', val);
  980. },
  981. handleSampleSubmit() {
  982. this.$refs.ruleForm.validate((valid) => {
  983. if (valid) {
  984. //取小样 赋值右上角单位
  985. this.changeSamUnit(this.formData.sampleUnit);
  986. let params = {
  987. conditionType: this.conditionType,
  988. measureQ: this.formData.number,
  989. sampleUnit: this.formData.sampleUnit,
  990. portion: this.formData.portion
  991. };
  992. let specifications = this.packingSpecificationOption.find(
  993. (el) => el.id == this.formData.packingUnit
  994. );
  995. console.log('执行这里没', params, '---');
  996. this.$emit('handleSampleSubmit', params, specifications);
  997. }
  998. });
  999. },
  1000. handleClick(tab) {
  1001. this.activeNameKK = tab.name;
  1002. },
  1003. tabsChange(val) {
  1004. this.activeNameKK = val;
  1005. },
  1006. tabsConditionType(val) {
  1007. this.conditionType = val;
  1008. },
  1009. checkSelectable(row, index) {
  1010. // 只有当质检方式为抽检(qualityMode=2)时 类型不是生产检验 才可选
  1011. return this.form.qualityType != 2 && this.form.qualityMode === 2;
  1012. },
  1013. handleDetail(index, row, type) {
  1014. this.$emit('handleDetail', index, row, type);
  1015. },
  1016. inputWeight(row, index) {
  1017. this.$emit('inputWeight', row, index);
  1018. },
  1019. handleDispose(index, row, type) {
  1020. this.$emit('handleDispose', { row, index });
  1021. },
  1022. handleSampleSizeChange(val) {
  1023. this.samplePagination.pageSize = val;
  1024. this.samplePagination.currentPage = 1;
  1025. },
  1026. handleSampleCurrentChange(val) {
  1027. this.samplePagination.currentPage = val;
  1028. },
  1029. handleSchemeSizeChange(val) {
  1030. this.schemePagination.pageSize = val;
  1031. this.schemePagination.currentPage = 1;
  1032. },
  1033. handleSchemeCurrentChange(val) {
  1034. this.schemePagination.currentPage = val;
  1035. },
  1036. selectQualityResultsChange() {
  1037. this.$emit('countQualityResults');
  1038. },
  1039. addInspectionTemplate() {
  1040. let type = this.form.qualityType || 1;
  1041. this.$refs.inspectionTemplateRef.open(type);
  1042. },
  1043. async inspectionTemplateSuccess(select) {
  1044. let data = await getQualityTemplateByIds({
  1045. templateIds: select.map((item) => item.id)
  1046. });
  1047. data.forEach((item) => {
  1048. item.id = null;
  1049. });
  1050. // 这里是选择方案后,数据新加,要改为覆盖
  1051. // this.templateList.push(...data);
  1052. // const strings = this.templateList.map((item) => JSON.stringify(item));
  1053. // const removeDupList = [...new Set(strings)];
  1054. // const result = removeDupList.map((item) => JSON.parse(item));
  1055. this.templateList = [];
  1056. this.templateList.push(...data);
  1057. this.templateList.forEach((item) => {
  1058. item['qualityResults'] = 1;
  1059. });
  1060. // this.templateList = result.map((item) => {
  1061. // item['qualityResults'] = 1;
  1062. // return item;
  1063. // });
  1064. this.sampleList.forEach((item, index) => {
  1065. this.$set(
  1066. this.sampleList[index],
  1067. 'qualitySampleTemplateList',
  1068. this.templateList
  1069. );
  1070. });
  1071. this.$set(this.form, 'templateList', this.templateList);
  1072. this.$emit('setSchemeList', this.templateList);
  1073. // this.schemeList = this.templateList;
  1074. this.schemePagination.total = this.templateList.length;
  1075. },
  1076. handDel(index) {
  1077. this.templateList.splice(index, 1);
  1078. this.sampleList.forEach((item, index) => {
  1079. this.$set(
  1080. this.sampleList[index],
  1081. 'qualitySampleTemplateList',
  1082. this.templateList.map((item) => {
  1083. item['qualityResults'] = 1;
  1084. return item;
  1085. })
  1086. );
  1087. });
  1088. }
  1089. }
  1090. };
  1091. </script>