newQualityContentTabs.vue 33 KB

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