edit.vue 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. :title="title"
  5. :visible.sync="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="80%"
  11. :maxable="true"
  12. >
  13. <header-title title="基本信息"></header-title>
  14. <base-info
  15. ref="baseInfoRefs"
  16. v-if="baseForm"
  17. :form="baseForm"
  18. :btnType="btnType"
  19. :isChangeNumber="isChangeNumber"
  20. :isChangeType="isChangeType"
  21. @resetTable="resetTable"
  22. @changeModel="changeModel"
  23. @getList="getList"
  24. @table2="table2"
  25. @getInspectionStandards="getInspectionStandards"
  26. :packingLists="packingList"
  27. @getCategoryInfo="getCategoryInfo"
  28. @changeProductNumberModel="changeProductNumberModel"
  29. @changesStokledgerNumberModal="changesStokledgerNumberModal"
  30. @getQualityTemplate="getQualityTemplate"
  31. ></base-info>
  32. <el-row>
  33. <header-title title="质检内容"></header-title>
  34. <el-tabs v-model="activeName" @tab-click="handleClick">
  35. <el-tab-pane label="来源清单" name="1">
  36. <!-- 来料列表表格 -->
  37. <ele-pro-table
  38. ref="table12"
  39. :columns="tableColumns"
  40. :datasource="datasource"
  41. :needPage="
  42. btnType == 'add' || (btnType == 'edit' && (!isScheme || !isOrder))
  43. ? false
  44. : true
  45. "
  46. @selection-change="handleSelectionChange"
  47. >
  48. <template
  49. v-slot:toolbar
  50. v-if="this.baseForm.qualityMode == 2 && btnType != 'detail'"
  51. >
  52. <el-dropdown trigger="click" @command="handleSampleNumber">
  53. <el-link type="primary" icon="el-icon-plus">取样</el-link>
  54. <el-dropdown-menu slot="dropdown">
  55. <el-dropdown-item command="1">取整样</el-dropdown-item>
  56. <el-dropdown-item command="2">取小样</el-dropdown-item>
  57. </el-dropdown-menu>
  58. </el-dropdown>
  59. </template>
  60. <template v-slot:toolkit v-if="this.baseForm.qualityMode == 2">
  61. <el-row>
  62. <el-form
  63. ref="ruleForm"
  64. :model="formData"
  65. label-width="60px"
  66. size="mini"
  67. :rules="rules"
  68. class="flex"
  69. :show-message="false"
  70. >
  71. <el-col :span="6" v-if="conditionType == 2">
  72. <el-form-item
  73. prop="number"
  74. label-width="0"
  75. style="margin-bottom: 0"
  76. >
  77. <el-input
  78. v-model="formData.number"
  79. placeholder="请输入"
  80. size="mini"
  81. ></el-input>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="6" v-if="conditionType == 2">
  85. <el-form-item
  86. prop="sampleUnit"
  87. label-width="0"
  88. style="margin: 0"
  89. >
  90. <DictSelection
  91. dictName="计量单位"
  92. clearable
  93. v-model="formData.sampleUnit"
  94. size="mini"
  95. @change="changeSamUnit"
  96. ></DictSelection>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="8" v-if="conditionType == 2">
  100. <el-form-item prop="portion" label="数量" style="margin: 0">
  101. <el-input
  102. v-model="formData.portion"
  103. placeholder="请输入"
  104. size="mini"
  105. clearable
  106. ></el-input>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="24" v-if="conditionType == 1">
  110. <el-form-item prop="portion" label="数量" style="margin: 0">
  111. <el-input
  112. v-model="formData.portion"
  113. placeholder="请输入"
  114. size="mini"
  115. clearable
  116. ></el-input>
  117. </el-form-item>
  118. </el-col>
  119. <el-col
  120. :span="4"
  121. style="text-align: right"
  122. v-if="conditionType == 1"
  123. >
  124. <el-button
  125. type="primary"
  126. size="mini"
  127. @click="handleExtractFull"
  128. style="margin-right: 12px"
  129. >确认</el-button
  130. >
  131. </el-col>
  132. <el-col
  133. :span="4"
  134. style="text-align: right"
  135. v-if="conditionType == 2"
  136. >
  137. <el-button
  138. type="primary"
  139. size="mini"
  140. @click="handleExtractFull"
  141. style="margin-right: 12px"
  142. >确认</el-button
  143. >
  144. </el-col>
  145. </el-form>
  146. </el-row>
  147. </template>
  148. </ele-pro-table>
  149. </el-tab-pane>
  150. <el-tab-pane label="样品清单" name="2">
  151. <el-table
  152. v-show="activeName === '2'"
  153. v-if="sampleList.length > 0"
  154. ref="showSampleListTable"
  155. :data="paginatedSampleList"
  156. tooltip-effect="dark"
  157. :max-height="300"
  158. border
  159. row-key="id"
  160. >
  161. <el-table-column
  162. label="序号"
  163. type="index"
  164. width="50"
  165. align="center"
  166. ></el-table-column>
  167. <template v-for="column in tableColumns2">
  168. <el-table-column
  169. :key="column.prop"
  170. :label="column.label"
  171. :prop="column.prop"
  172. :show-overflow-tooltip="true"
  173. :width="column.width"
  174. :align="column.align"
  175. ></el-table-column>
  176. </template>
  177. </el-table>
  178. <el-pagination
  179. v-show="activeName === '2' && sampleList.length > 0"
  180. @size-change="handleSampleSizeChange"
  181. @current-change="handleSampleCurrentChange"
  182. :current-page="samplePagination.currentPage"
  183. :page-sizes="[10, 20, 50, 100]"
  184. :page-size="samplePagination.pageSize"
  185. layout="total, sizes, prev, pager, next, jumper"
  186. :total="samplePagination.total"
  187. style="margin-top: 10px"
  188. ></el-pagination>
  189. </el-tab-pane>
  190. <el-tab-pane label="质检方案" name="3">
  191. <el-button
  192. @click="addInspectionTemplate"
  193. type="primary"
  194. style="margin-top: 5px"
  195. >选择质检方案</el-button
  196. >
  197. <el-table
  198. v-show="activeName === '3'"
  199. v-if="schemeList.length > 0"
  200. ref="showSchemeListTable"
  201. :data="paginatedSchemeList"
  202. tooltip-effect="dark"
  203. :max-height="300"
  204. border
  205. row-key="id"
  206. >
  207. <el-table-column
  208. label="序号"
  209. type="index"
  210. width="50"
  211. align="center"
  212. ></el-table-column>
  213. <el-table-column
  214. label="质检方案编码"
  215. prop="qualitySchemeTemplateCode"
  216. align="center"
  217. width="170"
  218. ></el-table-column>
  219. <el-table-column
  220. label="质检方案名称"
  221. prop="qualitySchemeTemplateName"
  222. align="center"
  223. width="170"
  224. ></el-table-column>
  225. <el-table-column
  226. label="质检类型"
  227. prop="categoryLevelClassName"
  228. align="center"
  229. width="170"
  230. ></el-table-column>
  231. <el-table-column
  232. label="质检项编码"
  233. prop="inspectionCode"
  234. align="center"
  235. width="170"
  236. ></el-table-column>
  237. <el-table-column
  238. label="质检项名称"
  239. prop="inspectionName"
  240. align="center"
  241. ></el-table-column>
  242. <el-table-column
  243. label="工艺参数"
  244. prop="defaultValue"
  245. align="center"
  246. >
  247. <template slot-scope="scope">
  248. <div style="display: flex; flex-direction: row">
  249. <DictSelection
  250. v-if="btnType != 'detail'"
  251. style="width: 85px"
  252. clearable
  253. dictName="数学字符"
  254. v-model="scope.row.symbol"
  255. ></DictSelection>
  256. <el-input
  257. :disabled="btnType == 'detail'"
  258. v-model="scope.row.defaultValue"
  259. placeholder="请输入内容"
  260. style="width: 120px"
  261. ></el-input>
  262. <DictSelection
  263. v-if="btnType != 'detail'"
  264. dictName="工艺参数单位"
  265. clearable
  266. filterable
  267. v-model="scope.row.unitName"
  268. style="width: 100px"
  269. >
  270. </DictSelection>
  271. </div>
  272. </template>
  273. </el-table-column>
  274. </el-table>
  275. <el-pagination
  276. v-show="activeName === '3' && schemeList.length > 0"
  277. @size-change="handleSchemeSizeChange"
  278. @current-change="handleSchemeCurrentChange"
  279. :current-page="schemePagination.currentPage"
  280. :page-sizes="[10, 20, 50, 100]"
  281. :page-size="schemePagination.pageSize"
  282. layout="total, sizes, prev, pager, next, jumper"
  283. :total="schemePagination.total"
  284. style="margin-top: 10px"
  285. ></el-pagination>
  286. </el-tab-pane>
  287. </el-tabs>
  288. </el-row>
  289. <template v-slot:footer>
  290. <el-button @click="handleClose">取消</el-button>
  291. <el-button
  292. v-if="btnType != 'detail' && btnType != 'issued'"
  293. type="primary"
  294. :loading="loading"
  295. @click="handleSave"
  296. >保存</el-button
  297. >
  298. <el-button
  299. v-if="btnType != 'detail'"
  300. type="primary"
  301. :loading="loading"
  302. @click="handleIssued"
  303. >下发</el-button
  304. >
  305. <inspectionTemplateDialog
  306. ref="inspectionTemplateRef"
  307. @choose="inspectionTemplateSuccess"
  308. ></inspectionTemplateDialog>
  309. </template>
  310. </ele-modal>
  311. </template>
  312. <script>
  313. import baseInfo from './baseInfo.vue';
  314. import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
  315. import { getCode } from '@/api/login';
  316. import { save, update, planIssued } from '@/api/inspectionPlan';
  317. import {
  318. getQualityTemplateList,
  319. getTemplateListByPlanId,
  320. getSampleListByPlanId,
  321. getInventoryListByPlanId,
  322. outInRecordsPage,
  323. getBatchInfoData,
  324. getProductOrder,
  325. getProductSteup
  326. } from '@/api/inspectionPlan/index.js';
  327. import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
  328. export default {
  329. components: {
  330. baseInfo,
  331. inspectionTemplateDialog
  332. },
  333. data() {
  334. const defaultForm = function () {
  335. return {
  336. id: '',
  337. code: '',
  338. name: '',
  339. type: '',
  340. qualityMode: '',
  341. inspectionStandards: '',
  342. autoOrder: '',
  343. groupId: '',
  344. groupName: '',
  345. executeId: '',
  346. executeName: '',
  347. planStartTime: '',
  348. planEndTime: '',
  349. standard: '',
  350. planSource: '',
  351. planSourceCode: '',
  352. productName: '',
  353. productCode: '',
  354. batchNo: '',
  355. specification: '',
  356. modelType: '',
  357. brandNo: '',
  358. productNumber: '',
  359. qualifiedNumber: '',
  360. unqualifiedNumber: '',
  361. qualificationRate: '',
  362. totalWeight: '',
  363. sampleNumber: null,
  364. sampleMeasureUnit: '',
  365. sampleProportion: '',
  366. supplierMark: '',
  367. remark: '',
  368. accessory: [],
  369. conditionType: 1
  370. };
  371. };
  372. return {
  373. defaultForm,
  374. // 表单数据
  375. baseForm: { ...defaultForm() },
  376. tableColumns2: [
  377. {
  378. label: '样品编码',
  379. prop: 'sampleCode',
  380. width: '150',
  381. align: 'center'
  382. },
  383. {
  384. label: '编码',
  385. prop: 'categoryCode',
  386. width: '150',
  387. align: 'center'
  388. },
  389. {
  390. label: '名称',
  391. prop: 'categoryName',
  392. width: '150',
  393. align: 'center'
  394. },
  395. { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
  396. { label: '发货条码', prop: 'barcodes', align: 'center' },
  397. { label: '包装编码', prop: 'packageNo', align: 'center' },
  398. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  399. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  400. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  401. { label: '客户代号', prop: 'clientCode', align: 'center' },
  402. { label: '刻码', prop: 'engrave', align: 'center' },
  403. // { prop: 'specification', label: '规格', align: 'center', width: 100, showOverflowTooltip: true },
  404. // { prop: 'brandNum', label: '牌号', align: 'center', width: 100, showOverflowTooltip: true },
  405. // { prop: 'modelType', label: '型号', align: 'center', width: 100, showOverflowTooltip: true },
  406. { label: '重量', prop: 'weight', align: 'center' },
  407. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  408. { label: '仓库', prop: 'warehouseName', align: 'center' },
  409. { label: '货区', prop: 'areaName', align: 'center' },
  410. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  411. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  412. { label: '生产日期', prop: 'productionDate', align: 'center' },
  413. { label: '采购日期', prop: 'purchaseDate', align: 'center' }
  414. ],
  415. packingList: [],
  416. sampleList: [],
  417. samplePagination: {
  418. currentPage: 1,
  419. pageSize: 10,
  420. total: 0
  421. },
  422. schemeList: [],
  423. schemePagination: {
  424. currentPage: 1,
  425. pageSize: 10,
  426. total: 0
  427. },
  428. // 表单验证规则
  429. visible: false,
  430. btnType: null,
  431. title: null,
  432. loading: false,
  433. listPage: [],
  434. activeName: '1',
  435. selectedList: [],
  436. isCheck: false, // 是否拆包 false 不拆包 true 拆包
  437. rowIds: '',
  438. formData: {
  439. number: 1,
  440. sampleUnit: '',
  441. portion: null
  442. },
  443. rules: {
  444. number: [
  445. {
  446. required: true,
  447. message: '请输入',
  448. trigger: 'blur'
  449. }
  450. ],
  451. sampleUnit: [
  452. {
  453. required: true,
  454. message: '请选择样品单位',
  455. trigger: 'change'
  456. }
  457. ],
  458. portion: [
  459. {
  460. required: true,
  461. message: '请输入',
  462. trigger: 'blur'
  463. }
  464. ]
  465. },
  466. isScheme: true,
  467. isOrder: true,
  468. isConsumable: '', //0 单件 1批量
  469. netWeight: '', // 净重
  470. conditionType: null,
  471. isFormNumber: true,
  472. sampleListCode: '',
  473. productItem: {}, //产品信息
  474. isUpdateData: true,
  475. isChangeNumber: true,
  476. isChangeType: true
  477. };
  478. },
  479. computed: {
  480. tableColumns() {
  481. let arr = [
  482. // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
  483. // ? {
  484. // columnKey: 'selection',
  485. // type: 'selection',
  486. // width: 45,
  487. // align: 'center'
  488. // }
  489. // : null,
  490. {
  491. columnKey: 'selection',
  492. type: 'selection',
  493. width: 45,
  494. align: 'center'
  495. },
  496. {
  497. columnKey: 'index',
  498. label: '序号',
  499. type: 'index',
  500. width: 55,
  501. align: 'center',
  502. fixed: 'left'
  503. },
  504. {
  505. label: '编码',
  506. prop: 'categoryCode',
  507. width: 150,
  508. align: 'center',
  509. showOverflowTooltip: true
  510. },
  511. {
  512. label: '名称',
  513. prop: 'categoryName',
  514. width: '150',
  515. align: 'center',
  516. width: 120,
  517. showOverflowTooltip: true
  518. },
  519. { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
  520. { label: '发货条码', prop: 'barcodes', align: 'center' },
  521. {
  522. label: '包装编码',
  523. prop: 'packageNo',
  524. align: 'center',
  525. width: 120,
  526. showOverflowTooltip: true
  527. },
  528. { label: '包装数量', prop: 'packingQuantity', align: 'center' },
  529. { label: '包装单位', prop: 'packingUnit', align: 'center' },
  530. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  531. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  532. { label: '物料代号', prop: 'materielDesignation', align: 'center' },
  533. { label: '客户代号', prop: 'clientCode', align: 'center' },
  534. {
  535. label: '供应商名称',
  536. prop: 'supplierName',
  537. align: 'center',
  538. width: 120,
  539. showOverflowTooltip: true
  540. },
  541. {
  542. label: '供应商代号',
  543. prop: 'supplierCode',
  544. align: 'center',
  545. width: '120'
  546. },
  547. { label: '刻码', prop: 'engrave', align: 'center' },
  548. { label: '重量', prop: 'weight', align: 'center' },
  549. { label: '重量单位', prop: 'weightUnit', align: 'center' },
  550. {
  551. label: '仓库',
  552. prop: 'warehouseName',
  553. align: 'center',
  554. width: 120,
  555. showOverflowTooltip: true
  556. },
  557. { label: '货区', prop: 'areaName', align: 'center' },
  558. { label: '货架', prop: 'goodsShelfName', align: 'center' },
  559. { label: '货位', prop: 'goodsAllocationName', align: 'center' },
  560. {
  561. label: '生产日期',
  562. prop: 'productionDate',
  563. align: 'center',
  564. width: 120,
  565. showOverflowTooltip: true
  566. },
  567. {
  568. label: '采购日期',
  569. prop: 'purchaseDate',
  570. align: 'center',
  571. width: 120,
  572. showOverflowTooltip: true
  573. }
  574. ];
  575. return arr;
  576. },
  577. // 分页后的样品列表
  578. paginatedSampleList() {
  579. if (this.rowIds && this.isOrder) {
  580. return this.sampleList;
  581. }
  582. const { currentPage, pageSize } = this.samplePagination;
  583. const start = (currentPage - 1) * pageSize;
  584. const end = start + pageSize;
  585. return this.sampleList.slice(start, end);
  586. },
  587. // 分页后的质检方案列表
  588. paginatedSchemeList() {
  589. if (this.rowIds && this.isScheme) {
  590. return this.schemeList;
  591. }
  592. const { currentPage, pageSize } = this.schemePagination;
  593. const start = (currentPage - 1) * pageSize;
  594. const end = start + pageSize;
  595. return this.schemeList.slice(start, end);
  596. }
  597. },
  598. created() {},
  599. methods: {
  600. //成品检验类型,计划来源主数据,修改数量生成来源清单
  601. changeProductNumberModel(num) {
  602. // if (
  603. // this.btnType == 'add' ||
  604. // (this.btnType == 'edit' && !this.isUpdateData)
  605. // ) {
  606. // this.$refs.table12.setData([]);
  607. // this.isOrder = false;
  608. // let nums = Number(num);
  609. // let p = this.productItem;
  610. // let list = [];
  611. // if (this.isConsumable == 0) {
  612. // for (let i = 0; i < nums; i++) {
  613. // let obj = {
  614. // id: p.id,
  615. // batchNo: p.batchNo,
  616. // categoryCode: p.code, //编码
  617. // categoryName: p.name, //名称
  618. // measureQuantity: 1,
  619. // measureUnit: p.measuringUnit, //计量单位
  620. // weightUnit: p.weightUnit, //重量单位
  621. // weight: p.netWeight //重量
  622. // };
  623. // list.push(obj);
  624. // }
  625. // } else if (this.isConsumable == 1) {
  626. // let obj = {
  627. // id: p.id,
  628. // batchNo: p.batchNo,
  629. // categoryCode: p.code, //编码
  630. // categoryName: p.name, //名称
  631. // measureQuantity: nums, //计量数量
  632. // measureUnit: p.measuringUnit, //计量单位
  633. // weightUnit: p.weightUnit, //重量单位
  634. // weight: p.netWeight * nums //重量
  635. // };
  636. // list.push(obj);
  637. // }
  638. // this.$refs.table12.setData(list);
  639. // // *** 如果检验方式是全量的话 还需要同步样品清单数据
  640. // if (
  641. // this.baseForm.qualityMode == 1 &&
  642. // this.baseForm.inspectionStandards
  643. // ) {
  644. // this.isFormNumber = false;
  645. // this.handleSampleList();
  646. // }
  647. // console.log(this.baseForm, 'form --');
  648. // }
  649. console.log('数据33333');
  650. this.$refs.table12.setData([]);
  651. this.isOrder = false;
  652. let nums = Number(num);
  653. let p = this.productItem;
  654. let list = [];
  655. if (this.isConsumable == 0) {
  656. for (let i = 0; i < nums; i++) {
  657. let obj = {
  658. id: p.id,
  659. batchNo: p.batchNo,
  660. categoryCode: p.code, //编码
  661. categoryName: p.name, //名称
  662. measureQuantity: 1,
  663. measureUnit: p.measuringUnit, //计量单位
  664. weightUnit: p.weightUnit, //重量单位
  665. weight: p.netWeight //重量
  666. };
  667. list.push(obj);
  668. }
  669. } else if (this.isConsumable == 1) {
  670. let obj = {
  671. id: p.id,
  672. batchNo: p.batchNo,
  673. categoryCode: p.code, //编码
  674. categoryName: p.name, //名称
  675. measureQuantity: nums, //计量数量
  676. measureUnit: p.measuringUnit, //计量单位
  677. weightUnit: p.weightUnit, //重量单位
  678. weight: p.netWeight * nums //重量
  679. };
  680. list.push(obj);
  681. }
  682. console.log('数据22222');
  683. this.$refs.table12.setData(list);
  684. // *** 如果检验方式是全量的话 还需要同步样品清单数据
  685. if (
  686. this.baseForm.qualityMode == 1 &&
  687. this.baseForm.inspectionStandards
  688. ) {
  689. this.isFormNumber = false;
  690. this.handleSampleList();
  691. }
  692. console.log(this.baseForm, 'form --');
  693. },
  694. //成品类型检验类型,计划来源库存台账, 生成来源清单
  695. changesStokledgerNumberModal(val, dimension) {
  696. console.log('数据11111');
  697. this.$refs.table12.setData([]);
  698. if (dimension == 3) return this.$refs.table12.setData(val);
  699. let item = val[0];
  700. let num = Number(item.outboundNum);
  701. let list = [];
  702. let weight = (item.weight / item.measureQuantity).toFixed(2);
  703. for (let i = 0; i < num; i++) {
  704. list.push({
  705. ...item,
  706. id: i + 1,
  707. packingQuantity: null,
  708. measureQuantity: 1,
  709. weight
  710. });
  711. }
  712. console.log('数据1221212121');
  713. this.$refs.table12.setData(list);
  714. },
  715. //获取基本信息中计量方式
  716. getInspectionStandards(data) {
  717. console.log(data, 'data');
  718. this.baseForm.inspectionStandards = data;
  719. this.isOrder = false;
  720. console.log(1313322);
  721. this.handleSampleList();
  722. },
  723. async datasource({ page, limit, where }) {
  724. console.log(this.btnType);
  725. console.log(this.isScheme, this.isOrder);
  726. const res = await getInventoryListByPlanId({
  727. ...where,
  728. pageNum: page,
  729. size: limit
  730. });
  731. this.packingList = res.list;
  732. return res;
  733. },
  734. // 切换质检内容
  735. handleClick(tab) {
  736. this.activeName = tab.name;
  737. },
  738. async open(type, row) {
  739. this.visible = true;
  740. this.activeName = '1';
  741. this.btnType = type;
  742. this.title =
  743. type == 'add'
  744. ? '新增'
  745. : type == 'edit'
  746. ? '编辑'
  747. : type == 'issued'
  748. ? '下发'
  749. : '详情';
  750. if (this.btnType === 'add') {
  751. const code = await getCode('qms_plan_code');
  752. this.baseForm.code = code;
  753. this.rowIds = '';
  754. return;
  755. } else {
  756. await this.handleEditOrDetail(row);
  757. }
  758. },
  759. addInspectionTemplate() {
  760. this.$refs.inspectionTemplateRef.open();
  761. },
  762. async inspectionTemplateSuccess(select) {
  763. let data = await getQualityTemplateByIds({
  764. templateIds: select.map((item) => item.id)
  765. });
  766. console.log('---------------------------');
  767. this.isScheme = false;
  768. this.schemeList.push(...data);
  769. this.schemePagination.total = this.schemeList.length;
  770. },
  771. async handleEditOrDetail(row) {
  772. console.log('row====', row);
  773. row.accessory = row.accessory || [];
  774. this.baseForm = {
  775. ...JSON.parse(JSON.stringify(row)),
  776. groupId: row.groupId,
  777. qualityMode: row.qualityMode
  778. };
  779. console.log('baseInfo:' + this.baseForm);
  780. this.$nextTick(() => {
  781. if (this.$refs.baseInfoRefs) {
  782. // 获取人员
  783. if (this.baseForm.groupId) {
  784. this.$refs.baseInfoRefs.getUserList({
  785. groupId: this.baseForm.groupId
  786. });
  787. }
  788. //根据类型获取计划来源
  789. if (this.baseForm.type) {
  790. this.$refs.baseInfoRefs.typeChange(this.baseForm.type);
  791. }
  792. if (this.baseForm.productId) {
  793. this.$refs.baseInfoRefs.getProductDetails(
  794. this.baseForm.productId
  795. );
  796. }
  797. }
  798. });
  799. // 如果是编辑或者详情,则查询物料清单、质检方案和样品列表
  800. if (row.id) {
  801. this.rowIds = row.id;
  802. this.isScheme = true;
  803. this.schemePagination.currentPage = 1;
  804. this.schemePagination.pageSize = 10;
  805. this.schemePagination.total = 0;
  806. this.samplePagination.pageSize = 10;
  807. this.samplePagination.currentPage = 1;
  808. this.samplePagination.total = 0;
  809. this.isFormNumber = true;
  810. this.isOrder = true;
  811. if (row.isUnpack === 1) {
  812. this.isCheck = true;
  813. } else {
  814. this.isCheck = false;
  815. }
  816. //操作行点击时查询清单
  817. // await this.getInventoryList();
  818. await this.reload({ planId: row.id });
  819. //操作行点击时查询样品
  820. await this.getSampleList(row.id);
  821. //操作行点击时查询质检
  822. await this.getTemplateList(row.id);
  823. }
  824. },
  825. reload(where) {
  826. this.$nextTick(() => {
  827. if (this.$refs.table12 && this.$refs.table12.reload)
  828. this.$refs.table12.reload({ page: 1, where: where });
  829. });
  830. },
  831. async getSampleList(id) {
  832. let res = await getSampleListByPlanId({
  833. planId: id,
  834. pageNum: this.samplePagination.currentPage,
  835. size: this.samplePagination.pageSize
  836. });
  837. console.log(res.list, 'yyyyyyyyyyyyyy样品----------------------------');
  838. this.sampleList = res?.list || [];
  839. console.log(this.sampleList);
  840. this.samplePagination.total = res.count;
  841. },
  842. async getTemplateList(id) {
  843. let res = await getTemplateListByPlanId({
  844. planId: id,
  845. pageNum: this.schemePagination.currentPage,
  846. size: this.schemePagination.pageSize
  847. });
  848. console.log(res.list, 'fffffffffffffff方案--------------------------');
  849. this.schemeList = res?.list || [];
  850. this.schemePagination.total = res.count;
  851. },
  852. async getList(
  853. receiveNo,
  854. productCode,
  855. productCategoryId,
  856. productCategoryName,
  857. categoryid,
  858. batchNo,
  859. supplierName,
  860. supplierMark
  861. ) {
  862. //通过来源和产品 获取来料清单
  863. console.log(999999);
  864. await this.getGoodsList(
  865. receiveNo,
  866. productCode,
  867. null,
  868. productCategoryId,
  869. productCategoryName,
  870. categoryid,
  871. batchNo,
  872. supplierName,
  873. supplierMark
  874. );
  875. //通过来源和产品 获取质检方案
  876. await this.getQualityTemplate(productCode);
  877. },
  878. async getGoodsList(
  879. receiveNo,
  880. productCode,
  881. ids,
  882. productCategoryId,
  883. productCategoryName,
  884. categoryid,
  885. batchNo,
  886. supplierName,
  887. supplierMark
  888. ) {
  889. console.log('数据1-1-1-1-1');
  890. this.$refs.table12.setData([]);
  891. console.log(999999);
  892. let res;
  893. const res1 = await outInRecordsPage({
  894. sourceBizNo: receiveNo,
  895. categoryCode: productCode,
  896. categoryId: categoryid,
  897. qualityQlanId: ids,
  898. size: -1
  899. });
  900. console.log(res1, 'res1');
  901. if (res1.list.length > 0) {
  902. console.log(res1.list[0].status, 'status=2 不赋值');
  903. if (res1.list[0].status != 2) {
  904. res = res1.list;
  905. this.isCheck = true;
  906. console.log('this.isCheck=true', this.isCheck);
  907. } else {
  908. res = [];
  909. this.$message.error('此数据已质检,无需再次质检!');
  910. return;
  911. }
  912. } else {
  913. let resData = await getBatchInfoData({
  914. sourceBizNo: receiveNo,
  915. categoryCode: productCode,
  916. batchNo: batchNo
  917. });
  918. console.log(resData, 'resData');
  919. if (resData) {
  920. if (resData.qualityControl != 2) {
  921. this.isCheck = false;
  922. res = [resData];
  923. } else {
  924. res = [];
  925. this.$message.error('此数据已质检,无需再次质检!');
  926. return;
  927. }
  928. }
  929. }
  930. console.log(res, '来料清单');
  931. if (res.length > 0) {
  932. const _arr1 = res.map((m) => {
  933. m.sourceId = m.id;
  934. m.productCategoryId = productCategoryId;
  935. m.productCategoryName = productCategoryName;
  936. delete m.id;
  937. return { ...m };
  938. });
  939. console.log(_arr1, '1234567890');
  940. this.packingList = _arr1;
  941. console.log('数据1010101010');
  942. this.$refs.table12.setData(_arr1); //赋值
  943. const _arr2 = this.$refs.table12.getData();
  944. if (_arr2.length > 1) {
  945. this.baseForm.productNumber = _arr2.length;
  946. } else {
  947. this.baseForm.productNumber = _arr2[0].measureQuantity;
  948. }
  949. //处理样品清单
  950. await this.handleSampleList();
  951. } else {
  952. console.log('数据99999');
  953. this.$refs.table12.setData([]);
  954. }
  955. },
  956. async handleSampleList() {
  957. // let packingList = this.$refs.table12.getData();
  958. console.log(
  959. this.baseForm.qualityMode,
  960. this.baseForm.inspectionStandards,
  961. this.btnType
  962. );
  963. if (this.baseForm.type == '1') {
  964. if (this.baseForm.inspectionStandards == '2') {
  965. console.log(13131313213);
  966. this.sampleList = [];
  967. let list = [];
  968. if (this.baseForm.productNumber) {
  969. let p = this.productItem;
  970. console.log(p);
  971. let obj = {
  972. id: p.id,
  973. batchNo: p.batchNo,
  974. categoryCode: p.code, //编码
  975. categoryName: p.name, //名称
  976. measureQuantity: this.baseForm.productNumber, //计量数量
  977. measureUnit: p.measuringUnit, //计量单位
  978. weightUnit: p.weightUnit, //重量单位
  979. weight: p.netWeight * this.baseForm.productNumber //重量
  980. };
  981. list.push(obj);
  982. }
  983. this.$refs.table12.setData(list);
  984. let packList = this.$refs.table12.getData();
  985. // console.log(list);
  986. // console.log(1654646);
  987. this.getFullInspectionWeight(packList);
  988. // this.getFullInspectionWeight(list);
  989. } else {
  990. let packingList = this.$refs.table12.getData();
  991. if (
  992. Math.ceil(Number(this.baseForm.productNumber || 0)) ===
  993. packingList.length
  994. ) {
  995. await this.handleUnpackCase(packingList);
  996. return;
  997. } else {
  998. this.getFullInspectionWeight(packingList);
  999. }
  1000. }
  1001. }
  1002. //全检时 计量时
  1003. else if (
  1004. this.baseForm.qualityMode == 1 &&
  1005. this.baseForm.inspectionStandards == 1 &&
  1006. this.btnType != 'detail'
  1007. ) {
  1008. this.sampleList = [];
  1009. console.log(this.baseForm, '---isUnpack---');
  1010. if (this.baseForm.productNumber) {
  1011. console.log('数据777777');
  1012. this.$refs.table12.setData([]);
  1013. let nums = Number(this.baseForm.productNumber);
  1014. let p = this.productItem;
  1015. let list = [];
  1016. for (let i = 0; i < nums; i++) {
  1017. let obj = {
  1018. id: p.id,
  1019. batchNo: p.batchNo,
  1020. categoryCode: p.code, //编码
  1021. categoryName: p.name, //名称
  1022. measureQuantity: 1,
  1023. measureUnit: p.measuringUnit, //计量单位
  1024. weightUnit: p.weightUnit, //重量单位
  1025. weight: p.netWeight //重量
  1026. };
  1027. list.push(obj);
  1028. }
  1029. console.log('数据666666');
  1030. this.$refs.table12.setData(list);
  1031. let packList = this.$refs.table12.getData();
  1032. await this.handleUnpackCase(packList);
  1033. return;
  1034. }
  1035. // if (this.rowIds) {
  1036. // const res = await getInventoryListByPlanId({
  1037. // planId: this.rowIds,
  1038. // pageNum: 1,
  1039. // size: 5000
  1040. // });
  1041. // // console.log(res.list);
  1042. // if (res.list.length > 0) {
  1043. // await this.handleUnpackCase(res.list);
  1044. // }
  1045. // } else {
  1046. // await this.handleUnpackCase(packingList);
  1047. // }
  1048. // if (this.baseForm.isUnpack != null && this.baseForm.isUnpack != undefined && this.baseForm.isUnpack != '') {
  1049. // //拆包
  1050. // if (this.baseForm.isUnpack == 1) {
  1051. // await this.handleUnpackCase(packingList);
  1052. // } else if (this.baseForm.isUnpack == 0) {
  1053. // await this.updatePackingList(packingList);
  1054. // }
  1055. // } else {
  1056. // console.log(this.isCheck, 'this.isCheck')
  1057. // if (!this.isCheck) {
  1058. // await this.handleUnpackCase(packingList);
  1059. // } else {
  1060. // await this.updatePackingList(packingList);
  1061. // }
  1062. // }
  1063. //全检 计重时
  1064. } else if (
  1065. this.baseForm.qualityMode == 1 &&
  1066. this.baseForm.inspectionStandards == 2 &&
  1067. this.btnType != 'detail'
  1068. // (this.btnType != 'detail' || this.btnType != 'edit')
  1069. // this.btnType == 'add'
  1070. ) {
  1071. this.sampleList = [];
  1072. let list = [];
  1073. if (this.baseForm.productNumber) {
  1074. let p = this.productItem;
  1075. let obj = {
  1076. id: p.id,
  1077. batchNo: p.batchNo,
  1078. categoryCode: p.code, //编码
  1079. categoryName: p.name, //名称
  1080. measureQuantity: this.baseForm.productNumber, //计量数量
  1081. measureUnit: p.measuringUnit, //计量单位
  1082. weightUnit: p.weightUnit, //重量单位
  1083. weight: p.netWeight * this.baseForm.productNumber //重量
  1084. };
  1085. list.push(obj);
  1086. }
  1087. console.log('数据55555');
  1088. console.log(list);
  1089. if (list[0].categoryCode) {
  1090. this.$refs.table12.setData(list);
  1091. let packList = this.$refs.table12.getData();
  1092. this.getFullInspectionWeight(packList);
  1093. }
  1094. // this.$refs.table12.setData(list);
  1095. // let packList = this.$refs.table12.getData();
  1096. // this.getFullInspectionWeight(packList);
  1097. // this.getFullInspectionWeight(packList);
  1098. } else {
  1099. this.sampleList = [];
  1100. }
  1101. },
  1102. //全检 计重时生成样品清单
  1103. async getFullInspectionWeight(packingList) {
  1104. this.updatePackingList(packingList);
  1105. },
  1106. //拆包处理样品清单数据
  1107. async handleUnpackCase(packingList) {
  1108. const num = Number(this.baseForm.productNumber || 0);
  1109. console.log('num:' + num);
  1110. if (num) {
  1111. await this.getUnpackSamList(packingList, num);
  1112. }
  1113. },
  1114. //获取样品编码
  1115. async getSampleCode() {
  1116. return await getCode('sample_code');
  1117. },
  1118. //更新样品清单数据
  1119. async updatePackingList(list) {
  1120. console.log(list);
  1121. for (let i = 0; i < list.length; i++) {
  1122. list[i].sampleCode = await this.getSampleCode();
  1123. }
  1124. this.sampleList = list;
  1125. this.baseForm.sampleNumber = list.length;
  1126. this.samplePagination.currentPage = 1;
  1127. this.samplePagination.total = list.length;
  1128. // this.samplePagination.total = this.sampleList.length;
  1129. },
  1130. async getUnpackSamList(list, num) {
  1131. console.log(list, num);
  1132. let data = [];
  1133. list.forEach((oldItem, index) => {
  1134. const newMeasureQuantity =
  1135. oldItem.measureQuantity / this.baseForm.productNumber;
  1136. const newWeight = parseFloat(
  1137. (oldItem.weight / this.baseForm.productNumber).toFixed(2)
  1138. );
  1139. // 将 measureQuantity 转换为数字
  1140. const measureQuantity = Number(oldItem.measureQuantity);
  1141. // 判断是否有小数部分
  1142. const hasDecimal = measureQuantity % 1 !== 0;
  1143. let roundedQuantity;
  1144. if (hasDecimal) {
  1145. // 有小数部分,向上取整
  1146. roundedQuantity = Math.ceil(measureQuantity);
  1147. } else {
  1148. roundedQuantity = measureQuantity;
  1149. }
  1150. delete oldItem.id;
  1151. for (let i = 0; i < roundedQuantity; i++) {
  1152. data.push({
  1153. ...oldItem,
  1154. measureQuantity: 1,
  1155. weight: this.netWeight || 0
  1156. // weight:
  1157. // num - index >= 1
  1158. // ? this.netWeight
  1159. // : ((num * 100000 - index * 100000) / 100000) * this.netWeight
  1160. });
  1161. }
  1162. });
  1163. console.log(data, '样品数据-条数', num);
  1164. await this.updatePackingList(data);
  1165. },
  1166. async getQualityTemplate(productCode, ids) {
  1167. await getQualityTemplateList({
  1168. productCode: productCode,
  1169. qualityQlanId: ids
  1170. }).then((res) => {
  1171. if (Object.keys(res).length === 0) {
  1172. return;
  1173. }
  1174. this.baseForm.sampleProportion = res.checkProportion;
  1175. // this.baseForm.inspectionStandards = res?.inspectionStandards;
  1176. let combinedList = [];
  1177. for (let i = 0; i < res.qualityTemplateVOList.length; i++) {
  1178. res.qualityTemplateVOList[i].inspectionItemVOList =
  1179. res.qualityTemplateVOList[i]?.inspectionItemVOList.map((item) => {
  1180. item.templateId = res.qualityTemplateVOList[i]?.id;
  1181. item.qualitySchemeTemplateCode =
  1182. res.qualityTemplateVOList[i]?.qualitySchemeTemplateCode;
  1183. item.qualitySchemeTemplateName =
  1184. res.qualityTemplateVOList[i]?.qualitySchemeTemplateName;
  1185. delete item.id;
  1186. return {
  1187. ...item
  1188. };
  1189. });
  1190. combinedList = combinedList.concat(
  1191. res.qualityTemplateVOList[i].inspectionItemVOList
  1192. );
  1193. console.log(combinedList, '质检方案');
  1194. this.schemeList = combinedList;
  1195. this.schemePagination.currentPage = 1;
  1196. this.schemePagination.total = this.schemeList.length;
  1197. }
  1198. });
  1199. },
  1200. //来料列表表格选择事件
  1201. handleSelectionChange(selection) {
  1202. console.log(selection, '勾选');
  1203. this.selectedList = selection;
  1204. //如果取小样
  1205. if (this.conditionType == 2) {
  1206. if (this.isCheck) {
  1207. this.formData.portion = selection.length;
  1208. this.baseForm.sampleNumber = selection.length;
  1209. } else {
  1210. this.baseForm.sampleNumber = this.formData.portion;
  1211. }
  1212. const data1 = this.$refs.table12.getData();
  1213. this.$set(this.formData, 'sampleUnit', data1[0]?.measureUnit);
  1214. this.$set(this.baseForm, 'sampleMeasureUnit', data1[0]?.measureUnit);
  1215. } else if (this.conditionType == 1) {
  1216. this.baseForm.sampleNumber = this.formData.portion;
  1217. this.formData.number = 0;
  1218. }
  1219. },
  1220. //取样方式选择
  1221. async handleSampleNumber(val) {
  1222. console.log(val, 'val');
  1223. this.conditionType = val;
  1224. //清空样品清单列表
  1225. this.sampleList = [];
  1226. // const dataS = this.$refs.table12.getData();
  1227. //取整样
  1228. // if (val == 1) {
  1229. // if (this.selectedList.length == 0) {
  1230. // this.$message.warning('请先选择样品!');
  1231. // } else {
  1232. // if (this.isCheck) {
  1233. // for (let i = 0; i < this.selectedList.length; i++) {
  1234. // for (let j = 0; j < this.selectedList[i].measureQuantity; j++) {
  1235. // // this.selectedList[i].sampleCode = await this.getSampleCode();
  1236. // this.sampleList.push({
  1237. // ...this.selectedList[i],
  1238. // sampleCode: await this.getSampleCode(),
  1239. // measureQuantity: 1,
  1240. // weight: this.selectedList[i].weight / this.selectedList[i].measureQuantity
  1241. // });
  1242. // }
  1243. // }
  1244. // } else {
  1245. // for (let i = 0; i < this.selectedList.length; i++) {
  1246. // let forNum = 0;
  1247. // if (this.formData.portion != null && this.formData.portion != '') {
  1248. // forNum = this.formData.portion;
  1249. // } else {
  1250. // forNum = this.selectedList[i].measureQuantity;
  1251. // }
  1252. // for (let j = 0; j < forNum; j++) {
  1253. // // this.selectedList[i].sampleCode = await this.getSampleCode();
  1254. // this.sampleList.push({
  1255. // ...this.selectedList[i],
  1256. // sampleCode: await this.getSampleCode(),
  1257. // measureQuantity: 1,
  1258. // weight: this.selectedList[i].weight / this.selectedList[i].measureQuantity
  1259. // });
  1260. // }
  1261. // }
  1262. // }
  1263. // this.formData.portion = this.sampleList.length;
  1264. // this.activeName = '2';
  1265. // this.$message.success('取样成功!');
  1266. // }
  1267. // } else if (val == 2) {
  1268. // this.formData.sampleUnit = dataS[0].measureUnit;
  1269. // this.$refs.table12.clearSelection();
  1270. // //小样
  1271. // if (this.selectedList.length == 0) {
  1272. // this.$message.warning('请先选择样品!');
  1273. // } else {
  1274. // if (this.formData.number == null || this.formData.sampleUnit == '') {
  1275. // this.$message.warning('请先选择取样的数量和单位!');
  1276. // }
  1277. // }
  1278. // }
  1279. },
  1280. handleInputNumber(val) {
  1281. let packingList = this.$refs.table12.getData();
  1282. const maxValue =
  1283. packingList.length > 1
  1284. ? packingList.length
  1285. : packingList[0].measureQuantity;
  1286. if (val > maxValue) {
  1287. this.$message.warning('数量不能大于计量数量!');
  1288. this.formData.number = maxValue;
  1289. return;
  1290. }
  1291. },
  1292. // 整样输入框事件
  1293. handleInput(val) {
  1294. if (val == 0 || val == '' || val == null) {
  1295. this.$refs.table12.clearSelection();
  1296. return;
  1297. }
  1298. let packingList = this.$refs.table12.getData();
  1299. if (!packingList || packingList.length === 0) {
  1300. return;
  1301. }
  1302. // 计算 packingList 中 measureQuantity 字段的总和
  1303. const measureQuantitySum = packingList.reduce((sum, item) => {
  1304. const quantity = Number(item.measureQuantity) || 0;
  1305. return sum + quantity;
  1306. }, 0);
  1307. const portion = Number(this.formData.portion);
  1308. // 清空当前选中
  1309. this.$refs.table12.clearSelection();
  1310. if (this.conditionType == 2) {
  1311. // 取小样
  1312. // 确保 portion 不超过数据列表长度
  1313. const safePortion = Math.min(portion, packingList.length);
  1314. if (this.isCheck) {
  1315. // 是否拆包 false 不拆包
  1316. if (portion > packingList.length) {
  1317. this.$message.warning('取样数量不能大于来源清单数量!');
  1318. this.formData.portion = packingList.length;
  1319. }
  1320. } else {
  1321. const maxQuantity = Number(packingList[0].measureQuantity);
  1322. if (portion > maxQuantity) {
  1323. this.$message.warning('取样数量不能大于计量数量!');
  1324. this.formData.portion = maxQuantity;
  1325. }
  1326. }
  1327. // 选中前 safePortion 行
  1328. packingList.slice(0, safePortion).forEach((row) => {
  1329. this.$refs.table12.toggleRowSelection(row, true);
  1330. });
  1331. } else if (this.conditionType == 1) {
  1332. // 确保 portion 不超过数据列表长度
  1333. const safePortion = Math.min(portion, measureQuantitySum);
  1334. if (portion > measureQuantitySum) {
  1335. this.$message.warning('取样数量不能大于计量数量!');
  1336. this.formData.portion = measureQuantitySum;
  1337. }
  1338. // 选中前 safePortion 行
  1339. packingList.slice(0, safePortion).forEach((row) => {
  1340. this.$refs.table12.toggleRowSelection(row, true);
  1341. });
  1342. }
  1343. },
  1344. async getCategoryInfo(val) {
  1345. console.log(this.baseForm.type, this.baseForm.planSource);
  1346. // this.baseForm.isUnpack = val.categoryWms.isUnpack;
  1347. console.log(val, '产品信息');
  1348. if (this.baseForm.type == 2 && this.baseForm.planSource == '4') {
  1349. const res1 = await getProductSteup(val.category.id);
  1350. const index = res1.findIndex(
  1351. (item) => item.taskId == val.category.taskId
  1352. );
  1353. if (index) {
  1354. const res2 = await getProductOrder({
  1355. taskId: res1[index - 1].taskId,
  1356. workOrderId: val.category.id
  1357. });
  1358. if (res2[0].semiProductList.length > 1) {
  1359. this.baseForm.productNumber = res2[0].semiProductList.length;
  1360. } else {
  1361. this.baseForm.productNumber =
  1362. res2[0].semiProductList.measureQuantity;
  1363. }
  1364. }
  1365. this.isConsumable = val.category.isConsumable;
  1366. this.netWeight = val.category.netWeight;
  1367. this.productItem = val.category;
  1368. this.handleSampleList();
  1369. return;
  1370. }
  1371. this.isConsumable = val.category.isConsumable;
  1372. this.netWeight = val.category.netWeight;
  1373. this.productItem = val.category; //产品信息
  1374. },
  1375. changeSamUnit(val) {
  1376. this.$refs.baseInfoRefs.getsampleMeasureUnit(val);
  1377. },
  1378. //整样确认按钮-样品列表右上角确认按钮
  1379. // handleExtractFull() {
  1380. // this.$refs.ruleForm.validate((valid) => {
  1381. // if (valid) {
  1382. // if (!this.selectedList || this.selectedList.length == 0) {
  1383. // this.$message.warning('请先选择样品!');
  1384. // return;
  1385. // }
  1386. // this.sampleList = []
  1387. // //取样条数
  1388. // let safePortion = Number(this.formData.portion);
  1389. // //计量数量
  1390. // let measureQ = this.formData.number || 1;
  1391. // //计量单位
  1392. // let unit = this.formData.sampleUnit;
  1393. // //抽检计量整样小样或者抽检计重小样
  1394. // if ((this.baseForm.inspectionStandards === 1) || (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)) {
  1395. // if (this.conditionType == 2) {
  1396. // if (measureQ <= 0) {
  1397. // this.$message.info('取样计量数量必须大于0');
  1398. // return
  1399. // }
  1400. // }
  1401. // // 计算总计量数量
  1402. // const totalQuantity = this.selectedList.reduce((sum, item) => sum + item['measureQuantity'], 0);
  1403. // // 验证取样总量不超过总计量数量,只有计量单位相同才进行验证
  1404. // if (this.selectedList[0].measureUnit == unit || this.conditionType == 1) {
  1405. // if (measureQ * safePortion > totalQuantity) {
  1406. // this.$message.info('取样计量数量不能大于总计量数量');
  1407. // return
  1408. // }
  1409. // // 验证每条数据的计量数量都大于等于取样计量数量
  1410. // for (const item of this.selectedList) {
  1411. // if (item['measureQuantity'] < measureQ) {
  1412. // this.$message.info(`条目计量数量小于取样计量数量`);
  1413. // return
  1414. // }
  1415. // }
  1416. // }
  1417. // if (unit === 'KG') {
  1418. // let totalMaxPossible = 0;
  1419. // this.selectedList.map(item => {
  1420. // const maxPossible = item['measureQuantity'] / measureQ;
  1421. // totalMaxPossible += maxPossible;});
  1422. // if (totalMaxPossible < safePortion) {
  1423. // this.formData.portion = totalMaxPossible;
  1424. // return this.$message.info(`最大取样条数为${totalMaxPossible}`);
  1425. // }
  1426. // // 计算总重量
  1427. // let totalWeight = this.selectedList.reduce((sum, item) => sum + item['weight'], 0);
  1428. // let weightUnit = this.selectedList[0].weightUnit;
  1429. // if (weightUnit === 'G') {
  1430. // totalWeight = totalWeight / 1000
  1431. // }
  1432. // if (measureQ * safePortion > totalWeight) {
  1433. // this.$message.info('取样计量重量不能大于总计量重量');
  1434. // return
  1435. // }
  1436. // for (const item of this.selectedList) {
  1437. // let weight = weightUnit === 'G' ? item.weight / 1000 : item.weight
  1438. // if (weight < measureQ) {
  1439. // this.$message.info(`勾选条目重量小于取样重量`);
  1440. // return
  1441. // }
  1442. // }
  1443. // }
  1444. // this.getNewFullSampleList(Math.ceil(safePortion), measureQ, unit);
  1445. // //抽检计重整样
  1446. // } else if (this.baseForm.inspectionStandards === 2 && this.conditionType == 1) {
  1447. // for (const item of this.selectedList) {
  1448. // if (item['measureQuantity'] < safePortion) {
  1449. // this.$message.info(`所选的条目计量数量小于取样计量数量`);
  1450. // return
  1451. // }
  1452. // }
  1453. // let list = [];
  1454. // for (let i = 0; i < this.selectedList.length; i++) {
  1455. // list.push({
  1456. // ...this.selectedList[i],
  1457. // measureQuantity: safePortion, //作为计量数量
  1458. // });
  1459. // }
  1460. // this.updatePackingList(list);
  1461. // }
  1462. // this.activeName = '2'
  1463. // }
  1464. // });
  1465. // },
  1466. //从来源数组取样到目标数组
  1467. async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
  1468. console.log('从来源数组取样到目标数组');
  1469. const sourceArray = this.selectedList;
  1470. // 检查单位是否匹配
  1471. const isUnitMismatch =
  1472. sourceArray.length > 0 && sourceArray[0].measureUnit !== sampleUnit;
  1473. // 创建副本并计算初始可取样数量
  1474. const items = sourceArray.map((item) => ({
  1475. ...item,
  1476. remainingQuantity: isUnitMismatch
  1477. ? Infinity
  1478. : item['measureQuantity'], // 剩余可取样数量
  1479. maxPossible: item['measureQuantity'] / sampleQuantity // 最大取样次数
  1480. }));
  1481. const result = [];
  1482. let remainingCount = sampleCount;
  1483. // 尽可能均匀地从各条目取样
  1484. while (remainingCount > 0) {
  1485. // 按剩余可取样比例排序
  1486. items.sort(
  1487. (a, b) =>
  1488. b.remainingQuantity / b['measureQuantity'] -
  1489. a.remainingQuantity / a['measureQuantity']
  1490. );
  1491. let distributed = false;
  1492. for (const item of items) {
  1493. if (
  1494. (!isUnitMismatch && remainingCount > 0) ||
  1495. (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
  1496. ) {
  1497. // 添加到结果数组
  1498. let sampleCode = await this.getSampleCode();
  1499. if (
  1500. this.conditionType == 1 &&
  1501. this.baseForm.inspectionStandards == 1
  1502. ) {
  1503. result.push({ ...item, measureQuantity: 1, sampleCode });
  1504. } else if (
  1505. this.conditionType == 2 &&
  1506. (this.baseForm.inspectionStandards == 1 ||
  1507. this.baseForm.inspectionStandards == 2)
  1508. ) {
  1509. let weight = (item.weight / item.maxPossible).toFixed(2);
  1510. result.push({
  1511. ...item,
  1512. measureQuantity: sampleQuantity,
  1513. measureUnit: sampleUnit,
  1514. sampleCode,
  1515. weight
  1516. });
  1517. }
  1518. // 更新剩余数量
  1519. if (!isUnitMismatch) {
  1520. item.remainingQuantity -= sampleQuantity;
  1521. }
  1522. remainingCount--;
  1523. distributed = true;
  1524. }
  1525. }
  1526. // 如果没有分配任何取样
  1527. if (!distributed) {
  1528. break;
  1529. }
  1530. }
  1531. console.log('样品清单', this.sampleList);
  1532. this.sampleList = result;
  1533. this.baseForm.sampleNumber = this.sampleList.length; // 更新样品数量
  1534. this.changeSamUnit(sampleUnit);
  1535. },
  1536. //抽样确认按钮事件-样品列表右上角确认按钮
  1537. handleSampleSubmit() {
  1538. this.$refs.ruleForm.validate((valid) => {
  1539. if (valid) {
  1540. this.sampleList = [];
  1541. this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
  1542. let measureQ = this.formData.number;
  1543. let unit = this.formData.sampleUnit;
  1544. let nums = Number(this.formData.portion);
  1545. console.log(measureQ, unit, nums, 'measureQ, unit, nums');
  1546. this.getNewFullSampleList(nums, measureQ, unit);
  1547. // if (this.conditionType == 1) {
  1548. // this.sampleList = this.selectedList
  1549. // } else {
  1550. // let measureQ = this.formData.number;
  1551. // let unit = this.formData.sampleUnit;
  1552. // let nums = Number(this.formData.portion);
  1553. //
  1554. // console.log(measureQ, unit, nums, 'measureQ, unit, nums')
  1555. // this.getNewSampleList(measureQ, unit, nums)
  1556. // }
  1557. this.activeName = '2';
  1558. }
  1559. });
  1560. },
  1561. //更新计量数量、单位后重新生成样品列表数据
  1562. // async getNewSampleList(measureQ, unit, nums) {
  1563. // this.sampleList = [];
  1564. // if (!this.selectedList || this.selectedList.length == 0) {
  1565. // this.$message.warning('请先选择样品!');
  1566. // return;
  1567. // }
  1568. // if (!this.isCheck) {
  1569. // let measureQuantity = 1;
  1570. // if (this.conditionType == 2) {
  1571. // measureQuantity = this.formData.number;
  1572. // }
  1573. // for (let i = 0; i < nums; i++) {
  1574. // this.sampleList.push({
  1575. // ...this.selectedList[0],
  1576. // sampleCode: await this.getSampleCode(),
  1577. // measureQuantity: measureQuantity,
  1578. // measureUnit: unit,
  1579. // weight: this.netWeight || 0
  1580. // });
  1581. // }
  1582. // } else {
  1583. // if (this.conditionType == 1) {
  1584. // measureQ = 1;
  1585. // }
  1586. // for (let i = 0; i < this.selectedList.length; i++) {
  1587. // this.sampleList.push({
  1588. // ...this.selectedList[i],
  1589. // sampleCode: await this.getSampleCode(),
  1590. // measureQuantity: measureQ,
  1591. // measureUnit: unit,
  1592. // weight: this.netWeight || 0
  1593. // });
  1594. // }
  1595. // }
  1596. // },
  1597. //监听类型变化
  1598. resetTable() {
  1599. this.$nextTick(() => {
  1600. this.table1();
  1601. this.table2();
  1602. });
  1603. },
  1604. table1() {
  1605. console.log('数据44444');
  1606. this.$refs.table12.setData([]);
  1607. this.schemeList = [];
  1608. },
  1609. table2() {
  1610. this.$nextTick(() => {
  1611. this.sampleList = [];
  1612. });
  1613. },
  1614. resetForm() {
  1615. this.baseForm = { ...this.defaultForm() };
  1616. },
  1617. handleClose() {
  1618. this.$nextTick(() => {
  1619. // 关闭后,销毁所有的表单数据
  1620. this.resetForm();
  1621. this.resetTable();
  1622. this.isScheme = true;
  1623. this.isOrder = true;
  1624. this.packingList = [];
  1625. this.sampleList = [];
  1626. this.samplePagination = {
  1627. currentPage: 1,
  1628. pageSize: 10,
  1629. total: 0
  1630. };
  1631. (this.schemeList = []),
  1632. (this.schemePagination = {
  1633. currentPage: 1,
  1634. pageSize: 10,
  1635. total: 0
  1636. });
  1637. // 表单验证规则
  1638. this.visible = false;
  1639. this.btnType = null;
  1640. this.title = null;
  1641. this.loading = false;
  1642. this.listPage = [];
  1643. this.activeName = '1';
  1644. this.selectedList = [];
  1645. this.isCheck = false; // 是否拆包 false 不拆包 true 拆包
  1646. this.rowIds = '';
  1647. (this.formData = {
  1648. number: 1,
  1649. sampleUnit: '',
  1650. portion: null
  1651. }),
  1652. (this.rules = {
  1653. number: [
  1654. {
  1655. required: true,
  1656. message: '请输入',
  1657. trigger: 'blur'
  1658. }
  1659. ],
  1660. sampleUnit: [
  1661. {
  1662. required: true,
  1663. message: '请选择样品单位',
  1664. trigger: 'change'
  1665. }
  1666. ],
  1667. portion: [
  1668. {
  1669. required: true,
  1670. message: '请输入',
  1671. trigger: 'blur'
  1672. }
  1673. ]
  1674. });
  1675. this.isConsumable = ''; //0 单件 1批量
  1676. this.netWeight = ''; // 净重
  1677. this.conditionType = null;
  1678. this.isFormNumber = true;
  1679. this.sampleListCode = '';
  1680. this.productItem = {}; //产品信息
  1681. this.$refs['baseInfoRefs'] &&
  1682. this.$refs['baseInfoRefs'].$refs.form1.resetFields();
  1683. this.visible = false;
  1684. this.baseForm.groupId = '';
  1685. this.baseForm.qualityMode = '';
  1686. this.baseForm = { ...this.defaultForm() };
  1687. this.isChangeNumber = true;
  1688. this.isChangeType = true;
  1689. });
  1690. },
  1691. /* 保存编辑 */
  1692. handleSave() {
  1693. this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
  1694. if (!valid) {
  1695. return false;
  1696. }
  1697. this.loading = true;
  1698. if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
  1699. this.baseForm.isUnpack = this.isCheck ? 1 : 2;
  1700. }
  1701. this.baseForm.conditionType = this.conditionType;
  1702. let params = {
  1703. ...this.baseForm,
  1704. qualityInventoryList: this.$refs.table12.getData(),
  1705. sampleList: this.sampleList,
  1706. planTemplateList: this.schemeList
  1707. };
  1708. console.log(params, 'params');
  1709. if (this.btnType == 'issued' && this.schemeList.length < 1) {
  1710. this.$message.warning('质检方案不能为空!');
  1711. this.loading = false;
  1712. return;
  1713. }
  1714. let URL =
  1715. this.btnType == 'add' ? save : this.btnType == 'edit' ? update : '';
  1716. console.log(params, 'params');
  1717. URL(params)
  1718. .then((msg) => {
  1719. this.loading = false;
  1720. this.$message.success(msg);
  1721. this.handleClose();
  1722. this.$emit('done');
  1723. })
  1724. .catch((e) => {
  1725. this.loading = false;
  1726. });
  1727. });
  1728. },
  1729. handleIssued() {
  1730. if (this.sampleList.length == 0) {
  1731. this.$message.warning('样品清单为空!先进行修改操作再下发!');
  1732. return;
  1733. }
  1734. this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
  1735. if (!valid) {
  1736. return false;
  1737. }
  1738. this.loading = true;
  1739. if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
  1740. this.baseForm.isUnpack = this.isCheck ? 1 : 2;
  1741. }
  1742. this.baseForm.conditionType = this.conditionType;
  1743. let params = {
  1744. ...this.baseForm,
  1745. qualityInventoryList: this.$refs.table12.getData(),
  1746. sampleList: this.sampleList,
  1747. planTemplateList: this.schemeList
  1748. };
  1749. console.log(params, 'params');
  1750. if (this.btnType == 'issued' && this.schemeList.length < 1) {
  1751. this.$message.warning('质检方案不能为空!');
  1752. this.loading = false;
  1753. return;
  1754. }
  1755. planIssued(params)
  1756. .then((msg) => {
  1757. this.loading = false;
  1758. this.$message.success(msg);
  1759. this.handleClose();
  1760. this.$emit('done');
  1761. })
  1762. .catch((e) => {
  1763. this.loading = false;
  1764. });
  1765. });
  1766. },
  1767. // 样品列表分页方法
  1768. async handleSampleSizeChange(val) {
  1769. this.samplePagination.pageSize = val;
  1770. this.samplePagination.currentPage = 1;
  1771. if (this.rowIds && this.isOrder) {
  1772. await this.getSampleList(this.rowIds);
  1773. }
  1774. //操作行点击时查询样品
  1775. },
  1776. async handleSampleCurrentChange(val) {
  1777. this.samplePagination.currentPage = val;
  1778. if (this.rowIds && this.isOrder) {
  1779. await this.getSampleList(this.rowIds);
  1780. }
  1781. },
  1782. // 质检方案分页方法
  1783. async handleSchemeSizeChange(val) {
  1784. this.schemePagination.pageSize = val;
  1785. this.schemePagination.currentPage = 1;
  1786. //操作行点击时查询质检
  1787. if (this.rowIds && this.isScheme) {
  1788. await this.getTemplateList(this.rowIds);
  1789. }
  1790. },
  1791. async handleSchemeCurrentChange(val) {
  1792. this.schemePagination.currentPage = val;
  1793. //操作行点击时查询质检
  1794. if (this.rowIds && this.isScheme) {
  1795. await this.getTemplateList(this.rowIds);
  1796. }
  1797. },
  1798. //检验方式改变时,重新获取样品列表
  1799. changeModel(val) {
  1800. this.baseForm.qualityMode = val;
  1801. if (this.btnType != 'issued') {
  1802. this.baseForm.sampleNumber = '';
  1803. }
  1804. console.log(
  1805. this.baseForm.productNumber,
  1806. 'productNumberproductNumber数量'
  1807. );
  1808. if (this.baseForm.qualityMode == 1) {
  1809. this.handleSampleList();
  1810. } else {
  1811. this.sampleList = [];
  1812. }
  1813. },
  1814. //确定按钮
  1815. handleExtractFull() {
  1816. this.$refs.ruleForm.validate(async (valid) => {
  1817. if (!valid || !this.validateSelection()) return;
  1818. this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
  1819. this.sampleList = [];
  1820. const sampleCount = Number(this.formData.portion);
  1821. const measureQ = this.formData.number || 1;
  1822. const unit = this.formData.sampleUnit;
  1823. console.log(this.conditionType, this.baseForm.inspectionStandards);
  1824. try {
  1825. if (this.isStandard1OrWeightSample()) {
  1826. //抽检计量整样小样或者抽检计重小样
  1827. if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
  1828. return;
  1829. if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
  1830. return; // 若计量单位为重量,还需验证总重量是否足够
  1831. console.log('getNewFullSampleList');
  1832. await this.getNewFullSampleList(
  1833. Math.ceil(sampleCount),
  1834. measureQ,
  1835. unit
  1836. );
  1837. } else if (this.isWeightStandardFullSample()) {
  1838. console.log('handleWeightFullSample');
  1839. //抽检取计重取整样
  1840. if (!this.validateSampleCount(sampleCount)) return;
  1841. await this.handleWeightFullSample(sampleCount);
  1842. }
  1843. this.activeName = '2';
  1844. } catch (error) {
  1845. console.error('取样处理失败:', error);
  1846. this.$message.error('取样处理失败');
  1847. }
  1848. });
  1849. },
  1850. validateSelection() {
  1851. if (!this.selectedList?.length) {
  1852. this.$message.warning('请先选择样品!');
  1853. return false;
  1854. }
  1855. return true;
  1856. },
  1857. isStandard1OrWeightSample() {
  1858. return (
  1859. this.baseForm.inspectionStandards === 1 ||
  1860. (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)
  1861. // this.baseForm.inspectionStandards === 1 ||
  1862. // (this.baseForm.inspectionStandards === 2 &&
  1863. // this.conditionType == 2) ||
  1864. // (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)
  1865. );
  1866. },
  1867. isWeightStandardFullSample() {
  1868. return (
  1869. this.baseForm.inspectionStandards === 2 && this.conditionType == 1
  1870. );
  1871. },
  1872. validateMeasureQuantity(measureQ, unit, sampleCount) {
  1873. if (this.conditionType == 2 && measureQ <= 0) {
  1874. this.$message.info('取样计量数量必须大于0');
  1875. return false;
  1876. }
  1877. const totalQuantity = this.selectedList.reduce(
  1878. (sum, item) => sum + item.measureQuantity,
  1879. 0
  1880. );
  1881. if (
  1882. (this.selectedList[0].measureUnit === unit ||
  1883. this.conditionType == 1) &&
  1884. measureQ * sampleCount > totalQuantity
  1885. ) {
  1886. this.$message.info('取样计量数量不能大于总计量数量');
  1887. return false;
  1888. }
  1889. const invalidItem = this.selectedList.find(
  1890. (item) => item.measureQuantity < measureQ
  1891. );
  1892. if (invalidItem) {
  1893. this.$message.info('条目计量数量小于取样计量数量');
  1894. return false;
  1895. }
  1896. return true;
  1897. },
  1898. validateWeight(measureQ, sampleCount) {
  1899. let totalMaxPossible = 0;
  1900. this.selectedList.forEach((item) => {
  1901. totalMaxPossible += item.measureQuantity / measureQ;
  1902. });
  1903. if (totalMaxPossible < sampleCount) {
  1904. this.formData.portion = totalMaxPossible;
  1905. this.$message.info(`最大取样条数为${totalMaxPossible}`);
  1906. return false;
  1907. }
  1908. let totalWeight = this.selectedList.reduce(
  1909. (sum, item) => sum + item.weight,
  1910. 0
  1911. );
  1912. const weightUnit = this.selectedList[0].weightUnit;
  1913. if (weightUnit === 'G') totalWeight /= 1000;
  1914. console.log(measureQ * sampleCount, totalWeight);
  1915. if (measureQ * sampleCount > totalWeight) {
  1916. this.$message.info('取样计量重量不能大于总计量重量');
  1917. return false;
  1918. }
  1919. const invalidItem = this.selectedList.find((item) => {
  1920. const weight =
  1921. item.weightUnit === 'G' ? item.weight / 1000 : item.weight;
  1922. return weight < measureQ;
  1923. });
  1924. if (invalidItem) {
  1925. this.$message.info('勾选条目重量小于取样重量');
  1926. return false;
  1927. }
  1928. return true;
  1929. },
  1930. validateSampleCount(sampleCount) {
  1931. const invalidItem = this.selectedList.find(
  1932. (item) => item.measureQuantity < sampleCount
  1933. );
  1934. if (invalidItem) {
  1935. this.$message.info('所选的条目计量数量小于取样计量数量');
  1936. return false;
  1937. }
  1938. return true;
  1939. },
  1940. async handleWeightFullSample(sampleCount) {
  1941. const list = this.selectedList.map((item) => ({
  1942. ...item,
  1943. measureQuantity: sampleCount
  1944. }));
  1945. await this.updatePackingList(list);
  1946. }
  1947. }
  1948. };
  1949. </script>
  1950. <style lang="scss" scoped>
  1951. .location-warp {
  1952. display: flex;
  1953. .detail {
  1954. margin-left: 10px;
  1955. }
  1956. }
  1957. :deep(.el-form-item__content .el-input-group__prepend) {
  1958. background-color: #fff;
  1959. }
  1960. :deep(
  1961. .el-dialog:not(.ele-dialog-form)
  1962. .el-dialog__body
  1963. .el-form
  1964. .el-form-item:last-child
  1965. ) {
  1966. margin-bottom: 22px;
  1967. }
  1968. .add-product {
  1969. width: 100%;
  1970. display: flex;
  1971. align-items: center;
  1972. justify-content: flex-end;
  1973. font-size: 30px;
  1974. color: #1890ff;
  1975. margin: 10px 0;
  1976. cursor: pointer;
  1977. }
  1978. .el-pagination {
  1979. padding: 12px 16px;
  1980. background: #fff;
  1981. border: 1px solid#ebeef5;
  1982. border-top: none;
  1983. }
  1984. .flex {
  1985. display: flex;
  1986. align-items: center;
  1987. }
  1988. </style>