newQualityContentTabs.vue 37 KB

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