QualityContentTabs.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. <template>
  2. <el-row>
  3. <header-title title="质检内容">
  4. <el-button
  5. type="primary"
  6. :loading="loading"
  7. v-if="type != 'detail'"
  8. @click="$emit('batch-quality')"
  9. >批量质检</el-button
  10. >
  11. <el-button
  12. type="primary"
  13. :loading="loading"
  14. v-if="type != 'detail'"
  15. @click="$emit('batch-dispose')"
  16. >批量处置</el-button
  17. >
  18. </header-title>
  19. <el-tabs v-model="activeName" @tab-click="handleClick">
  20. <!-- -->
  21. <el-tab-pane label="来源清单" name="1">
  22. <ele-pro-table
  23. ref="sourceTable"
  24. :columns="tableColumns1"
  25. :datasource="datasource"
  26. @selection-change="handleSelectionChange"
  27. :initLoad="false"
  28. :pagination="true"
  29. >
  30. <template
  31. v-slot:toolbar
  32. v-if="
  33. form.qualityMode == 2 && form.qualityType == 2 && type != 'detail'
  34. "
  35. >
  36. <el-dropdown trigger="click" @command="handleSampleNumber">
  37. <el-link type="primary" icon="el-icon-plus">取样</el-link>
  38. <el-dropdown-menu slot="dropdown">
  39. <el-dropdown-item command="1">取整样</el-dropdown-item>
  40. <el-dropdown-item command="2">取小样</el-dropdown-item>
  41. </el-dropdown-menu>
  42. </el-dropdown>
  43. </template>
  44. <template
  45. v-slot:toolkit
  46. v-if="form.qualityMode == 2 && form.qualityType == 2"
  47. >
  48. <el-row>
  49. <el-form
  50. ref="ruleForm"
  51. :model="formData"
  52. label-width="60px"
  53. size="mini"
  54. :rules="rules"
  55. class="flex"
  56. :show-message="false"
  57. >
  58. <el-col :span="6" v-if="conditionType == 2">
  59. <el-form-item
  60. prop="number"
  61. label-width="0"
  62. style="margin-bottom: 0"
  63. >
  64. <el-input
  65. v-model="formData.number"
  66. placeholder="请输入"
  67. size="mini"
  68. ></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="6" v-if="conditionType == 2">
  72. <el-form-item
  73. prop="sampleUnit"
  74. label-width="0"
  75. style="margin: 0"
  76. >
  77. <DictSelection
  78. dictName="计量单位"
  79. clearable
  80. v-model="formData.sampleUnit"
  81. size="mini"
  82. @change="changeSamUnit"
  83. >
  84. </DictSelection>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="8" v-if="conditionType == 2">
  88. <el-form-item prop="portion" label="数量" style="margin: 0">
  89. <el-input
  90. v-model="formData.portion"
  91. placeholder="请输入"
  92. size="mini"
  93. ></el-input>
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="20" v-if="conditionType == 1">
  97. <el-form-item prop="portion" label="数量" style="margin: 0">
  98. <el-input
  99. v-model="formData.portion"
  100. placeholder="请输入"
  101. size="mini"
  102. ></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col
  106. :span="4"
  107. style="text-align: right"
  108. v-if="conditionType == 2"
  109. >
  110. <el-button
  111. type="primary"
  112. size="mini"
  113. @click="handleSampleSubmit"
  114. style="margin-right: 12px"
  115. >确认</el-button
  116. >
  117. </el-col>
  118. <el-col
  119. :span="4"
  120. style="text-align: right"
  121. v-if="conditionType == 1"
  122. >
  123. <el-button
  124. type="primary"
  125. size="mini"
  126. @click="handleSampleSubmit"
  127. style="margin-right: 12px"
  128. >确认</el-button
  129. >
  130. </el-col>
  131. </el-form>
  132. </el-row>
  133. </template>
  134. <template v-slot:materielDesignation="{ row }">
  135. <el-input
  136. v-model="row.materielDesignation"
  137. placeholder="请输入"
  138. ></el-input>
  139. </template>
  140. <template v-slot:clientCode="{ row }">
  141. <el-input v-model="row.clientCode" placeholder="请输入"></el-input>
  142. </template>
  143. <template v-slot:engrave="{ row }">
  144. <el-input v-model="row.engrave" placeholder="请输入"></el-input>
  145. </template>
  146. <template v-slot:weight="{ row }">
  147. <el-input v-model="row.weight" placeholder="请输入"></el-input>
  148. </template>
  149. </ele-pro-table>
  150. </el-tab-pane>
  151. <!-- -->
  152. <el-tab-pane label="样品清单" name="2">
  153. <el-table
  154. v-if="sampleList.length > 0"
  155. ref="showSampleListTable"
  156. :data="paginatedSampleList"
  157. tooltip-effect="dark"
  158. :max-height="300"
  159. border
  160. row-key="id"
  161. >
  162. <el-table-column
  163. label="序号"
  164. type="index"
  165. width="50"
  166. align="center"
  167. fixed="left"
  168. ></el-table-column>
  169. <template v-for="column in tableColumns">
  170. <el-table-column
  171. :key="column.prop"
  172. :label="column.label"
  173. :prop="column.prop"
  174. :fixed="column.fixed"
  175. :show-overflow-tooltip="true"
  176. :width="column.width"
  177. :align="column.align"
  178. >
  179. <template slot-scope="scope">
  180. <template v-if="column.prop === 'categoryCode'">
  181. <el-link
  182. type="primary"
  183. :underline="false"
  184. @click="handleDetail(scope.$index, scope.row, 'detail')"
  185. >
  186. {{ scope.row.categoryCode }}
  187. </el-link>
  188. </template>
  189. <template v-else-if="column.prop === 'materielDesignation'">
  190. <el-input
  191. :disabled="scope.row.isMaterielDesignationEmpty"
  192. v-model="scope.row.materielDesignation"
  193. size="mini"
  194. ></el-input>
  195. </template>
  196. <template v-else-if="column.prop === 'clientCode'">
  197. <el-input
  198. :disabled="scope.row.isClientCodeEmpty"
  199. v-model="scope.row.clientCode"
  200. size="mini"
  201. ></el-input>
  202. </template>
  203. <template v-else-if="column.prop === 'engrave'">
  204. <el-input
  205. :disabled="scope.row.isEngraveEmpty"
  206. v-model="scope.row.engrave"
  207. size="mini"
  208. ></el-input>
  209. </template>
  210. <template v-else-if="column.prop === 'weight'">
  211. <el-input
  212. type="number"
  213. v-model="scope.row.weight"
  214. :min="0"
  215. @input="inputWeight(scope.row, scope.$index)"
  216. size="mini"
  217. ></el-input>
  218. </template>
  219. <template v-else>
  220. {{ scope.row[column.prop] }}
  221. </template>
  222. </template>
  223. </el-table-column>
  224. </template>
  225. <!-- *** fixed="right" -->
  226. <el-table-column
  227. label="处置状态"
  228. prop="disposalStatus"
  229. align="center"
  230. :show-overflow-tooltip="true"
  231. >
  232. <template slot-scope="scope">
  233. <span
  234. v-if="scope.row.disposalStatus == 1 && form.qualityType == 2"
  235. >返工</span
  236. >
  237. <span
  238. v-if="scope.row.disposalStatus == 2 && form.qualityType == 2"
  239. >返修</span
  240. >
  241. <span v-if="scope.row.disposalStatus == 3">报废</span>
  242. <span
  243. v-if="scope.row.disposalStatus == 4 && form.qualityType == 2"
  244. >降级使用</span
  245. >
  246. <span
  247. v-if="scope.row.disposalStatus == 5 && form.qualityType == 2"
  248. >让步接收</span
  249. >
  250. <span v-if="scope.row.disposalStatus == 6">留样</span>
  251. <span v-if="scope.row.disposalStatus == 7">消耗</span>
  252. <span v-if="scope.row.disposalStatus == 8">回用</span>
  253. </template>
  254. </el-table-column>
  255. <!-- *** fixed="right" -->
  256. <el-table-column
  257. label="处置时间"
  258. prop="disposeTime"
  259. align="center"
  260. :show-overflow-tooltip="true"
  261. >
  262. </el-table-column>
  263. <!-- *** fixed="right" -->
  264. <el-table-column
  265. label="质检状态"
  266. prop="qualityStatus"
  267. align="center"
  268. :show-overflow-tooltip="true"
  269. >
  270. <template slot-scope="scope">
  271. <span v-if="scope.row.qualityStatus == 0">未检</span>
  272. <span v-if="scope.row.qualityStatus == 1">已检</span>
  273. <span v-if="scope.row.qualityStatus == 2">待检</span>
  274. </template>
  275. </el-table-column>
  276. <el-table-column
  277. label="质检结果"
  278. prop="qualityResults"
  279. align="center"
  280. fixed="right"
  281. :show-overflow-tooltip="true"
  282. >
  283. <template slot-scope="scope">
  284. <el-select
  285. @change="selectQualityResultsChange"
  286. v-model="scope.row.qualityResults"
  287. placeholder="请选择"
  288. style="width: 100%"
  289. :disabled="type == 'detail'"
  290. size="mini"
  291. >
  292. <el-option
  293. v-for="item in qualityResultsList"
  294. :key="item.value"
  295. :label="item.label"
  296. :value="item.value"
  297. >
  298. </el-option>
  299. </el-select>
  300. </template>
  301. </el-table-column>
  302. <el-table-column
  303. label="操作"
  304. align="center"
  305. width="120"
  306. fixed="right"
  307. v-if="type != 'detail'"
  308. >
  309. <template slot-scope="scope">
  310. <el-link
  311. :type="scope.row.isValid ? 'primary' : 'danger'"
  312. :underline="false"
  313. @click="handleDetail(scope.$index, scope.row, 'report')"
  314. >
  315. 质检
  316. </el-link>
  317. <el-link
  318. type="primary"
  319. :underline="false"
  320. @click="handleDispose(scope.$index, scope.row, 'dispose')"
  321. >处置
  322. </el-link>
  323. </template>
  324. </el-table-column>
  325. </el-table>
  326. <el-pagination
  327. @size-change="handleSampleSizeChange"
  328. @current-change="handleSampleCurrentChange"
  329. :current-page="samplePagination.currentPage"
  330. :page-sizes="[10, 20, 50, 100]"
  331. :page-size="samplePagination.pageSize"
  332. layout="total, sizes, prev, pager, next, jumper"
  333. :total="sampleList.length"
  334. />
  335. </el-tab-pane>
  336. <!-- -->
  337. <el-tab-pane label="质检方案" name="3">
  338. <el-table
  339. :data="paginatedSchemeList"
  340. tooltip-effect="dark"
  341. :max-height="300"
  342. border
  343. row-key="id"
  344. >
  345. <el-table-column
  346. label="序号"
  347. type="index"
  348. width="50"
  349. align="center"
  350. ></el-table-column>
  351. <el-table-column
  352. label="质检方案编码"
  353. prop="qualitySchemeTemplateCode"
  354. align="center"
  355. >
  356. </el-table-column>
  357. <el-table-column
  358. label="质检方案名称"
  359. prop="qualitySchemeTemplateName"
  360. align="center"
  361. ></el-table-column>
  362. <el-table-column
  363. label="质检类型"
  364. prop="categoryLevelClassName"
  365. align="center"
  366. ></el-table-column>
  367. <el-table-column
  368. label="质检项编码"
  369. prop="inspectionCode"
  370. align="center"
  371. ></el-table-column>
  372. <el-table-column
  373. label="质检项名称"
  374. prop="inspectionName"
  375. align="center"
  376. ></el-table-column>
  377. <el-table-column label="工艺参数" prop="defaultValue" align="center">
  378. <template slot-scope="scope">
  379. <div style="display: flex; justify-content: center">
  380. <span>{{ scope.row.symbol }}</span>
  381. <span v-if="scope.row.textType == 3">
  382. {{ scope.row.minValue }}-{{ scope.row.maxValue }}
  383. </span>
  384. <span v-else>
  385. <span>{{ scope.row.defaultValue }}</span>
  386. </span>
  387. {{ scope.row.unitName }}
  388. </div>
  389. </template>
  390. </el-table-column>
  391. </el-table>
  392. <el-pagination
  393. @size-change="handleSchemeSizeChange"
  394. @current-change="handleSchemeCurrentChange"
  395. :current-page="schemePagination.currentPage"
  396. :page-sizes="[10, 20, 50, 100]"
  397. :page-size="schemePagination.pageSize"
  398. layout="total, sizes, prev, pager, next, jumper"
  399. :total="schemeList.length"
  400. />
  401. </el-tab-pane>
  402. </el-tabs>
  403. </el-row>
  404. </template>
  405. <script>
  406. import {
  407. save,
  408. update,
  409. getById,
  410. exeReportWork,
  411. queryQualitySamplContent,
  412. queryQualityTempleContent,
  413. queryQualityInventory
  414. } from '@/api/inspectionWork';
  415. export default {
  416. props: {
  417. type: String,
  418. packingList: Array,
  419. sampleList: Array,
  420. schemeList: Array,
  421. loading: Boolean,
  422. form: Object,
  423. ids: String,
  424. activeName: String
  425. },
  426. data() {
  427. return {
  428. activeName: this.activeName,
  429. samplePagination: { currentPage: 1, pageSize: 10 },
  430. schemePagination: { currentPage: 1, pageSize: 10 },
  431. qualityResultsList: [
  432. {
  433. value: 1,
  434. label: '合格'
  435. },
  436. {
  437. value: 2,
  438. label: '不合格'
  439. },
  440. {
  441. value: 3,
  442. label: '让步接收'
  443. }
  444. ],
  445. tableColumns: [
  446. {
  447. label: '样品编码',
  448. prop: 'sampleCode',
  449. width: '200',
  450. align: 'center',
  451. fixed: 'left'
  452. },
  453. {
  454. label: '编码',
  455. prop: 'categoryCode',
  456. align: 'center',
  457. fixed: 'left'
  458. },
  459. {
  460. label: '名称',
  461. prop: 'categoryName',
  462. align: 'center'
  463. },
  464. { label: '批次号', prop: 'batchNo', align: 'center' },
  465. { label: '发货条码', prop: 'barcodes', align: 'center' },
  466. { label: '包装编码', prop: 'packageNo', align: 'center' },
  467. // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  468. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  469. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  470. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  471. {
  472. label: '供应商名称',
  473. prop: 'supplierName',
  474. align: 'center',
  475. width: '120'
  476. },
  477. {
  478. label: '供应商代号',
  479. prop: 'supplierCode',
  480. align: 'center',
  481. width: '120'
  482. },
  483. {
  484. label: '物料代号',
  485. prop: 'materielDesignation',
  486. align: 'center',
  487. slot: 'materielDesignation',
  488. width: '120'
  489. },
  490. {
  491. label: '客户代号',
  492. prop: 'clientCode',
  493. align: 'center',
  494. slot: 'clientCode',
  495. width: '120'
  496. },
  497. {
  498. label: '刻码',
  499. prop: 'engrave',
  500. align: 'center',
  501. slot: 'engrave',
  502. width: '120'
  503. },
  504. {
  505. label: '重量',
  506. prop: 'weight',
  507. align: 'center',
  508. slot: 'weight',
  509. width: '120'
  510. },
  511. {
  512. label: '重量单位',
  513. prop: 'weightUnit',
  514. align: 'center',
  515. width: 100
  516. },
  517. { label: '仓库', prop: 'warehouseName', align: 'center', width: 100 },
  518. { label: '货区', prop: 'areaName', align: 'center' },
  519. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  520. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  521. { label: '生产日期', prop: 'productionDate', align: 'center' },
  522. { label: '采购日期', prop: 'purchaseDate', align: 'center' }
  523. ],
  524. conditionType: null,
  525. formData: {
  526. number: 1,
  527. sampleUnit: '',
  528. portion: null
  529. },
  530. rules: {
  531. number: [
  532. {
  533. required: true,
  534. message: '请输入',
  535. trigger: 'blur'
  536. }
  537. ],
  538. sampleUnit: [
  539. {
  540. required: true,
  541. message: '请选择样品单位',
  542. trigger: 'change'
  543. }
  544. ],
  545. portion: [
  546. {
  547. required: true,
  548. message: '请输入',
  549. trigger: 'blur'
  550. }
  551. ]
  552. }
  553. };
  554. },
  555. computed: {
  556. tableColumns1() {
  557. let arr = [
  558. // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
  559. // ? {
  560. // columnKey: 'selection',
  561. // type: 'selection',
  562. // width: 45,
  563. // align: 'center'
  564. // }
  565. // : null,
  566. {
  567. columnKey: 'selection',
  568. type: 'selection',
  569. width: 45,
  570. align: 'center'
  571. },
  572. {
  573. columnKey: 'index',
  574. label: '序号',
  575. type: 'index',
  576. width: 55,
  577. align: 'center',
  578. fixed: 'left'
  579. },
  580. {
  581. label: '编码',
  582. prop: 'categoryCode',
  583. width: 150,
  584. align: 'center',
  585. showOverflowTooltip: true
  586. },
  587. {
  588. label: '名称',
  589. prop: 'categoryName',
  590. width: '150',
  591. align: 'center',
  592. width: 120,
  593. showOverflowTooltip: true
  594. },
  595. { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
  596. { label: '发货条码', prop: 'barcodes', align: 'center' },
  597. {
  598. label: '包装编码',
  599. prop: 'packageNo',
  600. align: 'center',
  601. width: 120,
  602. showOverflowTooltip: true
  603. },
  604. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  605. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  606. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  607. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  608. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  609. { label: '客户代号', prop: 'clientCode', align: 'center' },
  610. {
  611. label: '供应商名称',
  612. prop: 'supplierName',
  613. align: 'center',
  614. width: 120,
  615. showOverflowTooltip: true
  616. },
  617. {
  618. label: '供应商代号',
  619. prop: 'supplierCode',
  620. align: 'center',
  621. width: '120'
  622. },
  623. { label: '刻码', prop: 'engrave', align: 'center' },
  624. { label: '重量', prop: 'weight', align: 'center' },
  625. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  626. {
  627. label: '仓库',
  628. prop: 'warehouseName',
  629. align: 'center',
  630. width: 120,
  631. showOverflowTooltip: true
  632. },
  633. { label: '货区', prop: 'areaName', align: 'center' },
  634. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  635. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  636. {
  637. label: '生产日期',
  638. prop: 'productionDate',
  639. align: 'center',
  640. width: 120,
  641. showOverflowTooltip: true
  642. },
  643. {
  644. label: '采购日期',
  645. prop: 'purchaseDate',
  646. align: 'center',
  647. width: 120,
  648. showOverflowTooltip: true
  649. }
  650. ];
  651. return arr;
  652. },
  653. // 分页后的样品列表
  654. paginatedSampleList() {
  655. const { currentPage, pageSize } = this.samplePagination;
  656. const start = (currentPage - 1) * pageSize;
  657. const end = start + pageSize;
  658. return this.sampleList?.slice(start, end);
  659. },
  660. // 分页后的质检方案列表
  661. paginatedSchemeList() {
  662. const { currentPage, pageSize } = this.schemePagination;
  663. const start = (currentPage - 1) * pageSize;
  664. const end = start + pageSize;
  665. return this.schemeList?.slice(start, end);
  666. }
  667. },
  668. created() {
  669. this.reload({ qualityWorkerId: this.ids });
  670. },
  671. methods: {
  672. async datasource({ page, limit, where }) {
  673. const res = await queryQualityInventory({ ...where, page, limit });
  674. return res;
  675. },
  676. reload(where) {
  677. this.$nextTick(() => {
  678. if (this.$refs.sourceTable && this.$refs.sourceTable.reload)
  679. this.$refs.sourceTable.reload({ page: 1, where: where });
  680. });
  681. },
  682. tableSelClear() {
  683. console.log('清空勾选');
  684. this.$refs.sourceTable.clearSelection();
  685. },
  686. handleSelectionChange(selection) {
  687. if (this.form.conditionType == 2) {
  688. if (this.form.isUnpack == 2) {
  689. this.$set(this.form, 'sampleNumber', this.formData.portion);
  690. } else {
  691. this.formData.portion = selection.length;
  692. this.$set(this.form, 'sampleNumber', selection.length);
  693. }
  694. this.formData.sampleUnit = selection[0]?.measureUnit;
  695. this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  696. } else if (this.form.conditionType == 1) {
  697. this.$set(this.form, 'sampleNumber', this.formData.portion);
  698. }
  699. // this.formData.portion = selection.length;
  700. // this.formData.sampleUnit = selection[0]?.measureUnit;
  701. //
  702. // this.$set(this.form, 'sampleNumber', selection.length);
  703. // this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
  704. this.$emit('handleSelectionChange', selection);
  705. },
  706. handleSampleNumber(val) {
  707. console.log('取样方式选择', this.form.isUnpack);
  708. console.log(val, 'val');
  709. this.conditionType = val;
  710. this.form.sampleUnit = '';
  711. this.$emit('getConditionType', val);
  712. //取整样
  713. // let data = this.$refs.sourceTable.getData()
  714. // this.$emit('getSelectedList')
  715. // if (this.selectedList.length == 0) {
  716. // this.$message.warning('请先选择样品!');
  717. // }
  718. // if (val == 1) {
  719. // // this.activeName = '2'
  720. // this.$emit('handleSample1', val, data)
  721. // } else if (val == 2) {
  722. // this.tableSelClear();
  723. // this.$emit('handleSample1', val, data)
  724. // }
  725. },
  726. handleInputNumber(val) {
  727. let packingList = this.$refs.sourceTable.getData();
  728. const maxValue =
  729. packingList.length > 1
  730. ? packingList.length
  731. : packingList[0].measureQuantity;
  732. if (val > maxValue) {
  733. this.$message.warning('数量不能大于计量数量!');
  734. this.formData.number = maxValue;
  735. return;
  736. }
  737. },
  738. handleInput(val) {
  739. debugger;
  740. if (val == 0 || val == '' || val == null) {
  741. this.$refs.sourceTable.clearSelection();
  742. return;
  743. }
  744. let packingList = this.$refs.sourceTable.getData();
  745. if (!packingList || packingList.length === 0) {
  746. return;
  747. }
  748. // 计算 packingList 中 measureQuantity 字段的总和
  749. const measureQuantitySum = packingList.reduce((sum, item) => {
  750. const quantity = Number(item.measureQuantity) || 0;
  751. return sum + quantity;
  752. }, 0);
  753. const portion = Number(this.formData.portion);
  754. // 清空当前选中
  755. this.$refs.sourceTable.clearSelection();
  756. debugger;
  757. if (this.form.conditionType == 2) {
  758. // 确保 portion 不超过数据列表长度
  759. const safePortion = Math.min(portion, packingList.length);
  760. if (this.form.isUnpack == 2) {
  761. const maxQuantity = Number(packingList[0].measureQuantity);
  762. if (portion > maxQuantity) {
  763. this.$message.warning('取样数量不能大于计量数量!');
  764. this.formData.portion = maxQuantity;
  765. }
  766. } else if (this.form.isUnpack == 1) {
  767. if (portion > packingList.length) {
  768. this.$message.warning('取样数量不能大于来源清单数量!');
  769. this.formData.portion = packingList.length;
  770. }
  771. }
  772. packingList.slice(0, safePortion).forEach((row) => {
  773. this.$refs.sourceTable.toggleRowSelection(row);
  774. });
  775. } else if (this.form.conditionType == 1) {
  776. // 确保 portion 不超过数据列表长度
  777. const safePortion = Math.min(portion, measureQuantitySum);
  778. if (portion > measureQuantitySum) {
  779. this.$message.warning('取样数量不能大于计量数量!');
  780. this.formData.portion = measureQuantitySum;
  781. }
  782. // 选中前 safePortion 行
  783. packingList.slice(0, safePortion).forEach((row) => {
  784. this.$refs.sourceTable.toggleRowSelection(row, true);
  785. });
  786. }
  787. // if (packingList.length > 1) {
  788. // if (portion > packingList.length) {
  789. // this.$message.warning('取样数量不能大于来源清单数量!');
  790. // this.formData.portion = packingList.length;
  791. // return;
  792. // }
  793. // packingList.slice(0, this.formData.portion).forEach(row => {
  794. // this.$refs.table12.toggleRowSelection(row);
  795. // });
  796. // } else {
  797. // const maxQuantity = Number(packingList[0].measureQuantity);
  798. // if (portion > maxQuantity) {
  799. // this.$message.warning('取样数量不能大于计量数量!');
  800. // this.formData.portion = maxQuantity;
  801. // return;
  802. // }
  803. // }
  804. },
  805. changeSamUnit(val) {
  806. console.log(val, 'dddd');
  807. this.$emit('changeSamUnit', val);
  808. },
  809. handleSampleSubmit() {
  810. this.$refs.ruleForm.validate((valid) => {
  811. if (valid) {
  812. //取小样 赋值右上角单位
  813. this.changeSamUnit(this.formData.sampleUnit);
  814. let params = {
  815. conditionType: this.conditionType,
  816. measureQ: this.formData.number,
  817. sampleUnit: this.formData.sampleUnit,
  818. portion: this.formData.portion
  819. };
  820. this.$emit('handleSampleSubmit', params);
  821. }
  822. });
  823. },
  824. handleClick(tab) {
  825. console.log(tab, 'tab');
  826. this.activeName = tab.name;
  827. },
  828. tabsChange(val) {
  829. this.activeName = val;
  830. },
  831. tabsConditionType(val) {
  832. this.conditionType = val;
  833. },
  834. checkSelectable(row, index) {
  835. // 只有当质检方式为抽检(qualityMode=2)时 类型不是生产检验 才可选
  836. return this.form.qualityType != 2 && this.form.qualityMode === 2;
  837. },
  838. handleDetail(index, row, type) {
  839. this.$emit('handleDetail', index, row, type);
  840. },
  841. inputWeight(row, index) {
  842. this.$emit('inputWeight', row, index);
  843. },
  844. handleDispose(index, row, type) {
  845. this.$emit('handleDispose', index, row, type);
  846. },
  847. handleSampleSizeChange(val) {
  848. this.samplePagination.pageSize = val;
  849. this.samplePagination.currentPage = 1;
  850. },
  851. handleSampleCurrentChange(val) {
  852. this.samplePagination.currentPage = val;
  853. },
  854. handleSchemeSizeChange(val) {
  855. this.schemePagination.pageSize = val;
  856. this.schemePagination.currentPage = 1;
  857. },
  858. handleSchemeCurrentChange(val) {
  859. this.schemePagination.currentPage = val;
  860. },
  861. selectQualityResultsChange() {
  862. this.$emit('countQualityResults');
  863. }
  864. }
  865. };
  866. </script>