newQualityContentTabs.vue 38 KB

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