| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653 |
- <!-- 用户编辑弹窗 -->
- <template>
- <ele-modal
- :title="title"
- :visible.sync="visible"
- :before-close="handleClose"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- width="80%"
- :maxable="true"
- >
- <header-title title="基本信息"></header-title>
- <base-info
- ref="baseInfoRefs"
- v-if="baseForm"
- :form="baseForm"
- :btnType="btnType"
- :isChangeNumber="isChangeNumber"
- :isChangeType="isChangeType"
- @resetTable="resetTable"
- @changeModel="changeModel"
- @getList="getList"
- @table2="table2"
- @changeType="changeType"
- @changeSource="changeSource"
- @getInspectionStandards="getInspectionStandards"
- :packingLists="packingList"
- @getCategoryInfo="getCategoryInfo"
- @changeProductNumberModel="changeProductNumberModel"
- @changesStokledgerNumberModal="changesStokledgerNumberModal"
- @getQualityTemplate="getQualityTemplate"
- @setSourceData="setSourceData"
- ></base-info>
- <header-title title="样品信息"></header-title>
- <el-form label-width="110px">
- <el-row>
- <el-col :span="6">
- <el-form-item label="样品合格数:">
- <el-input
- type="number"
- :min="0"
- disabled
- v-model="baseForm.sampleQualifiedNumber"
- placeholder=""
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品不合格数:">
- <el-input
- type="number"
- :min="0"
- disabled
- v-model="baseForm.sampleNoQualifiedNumber"
- placeholder=""
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品合格率:">
- <el-input v-model="baseForm.sampleQualificationRate" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品不合格率:">
- <el-input v-model="baseForm.sampleNoQualificationRate" disabled />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="6">
- <el-form-item label="样品类型:">
- <el-input disabled :value="sampletypeVal(baseForm.conditionType)" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品数量:">
- <el-input
- type="number"
- disabled
- v-model="baseForm.sampleQuantity"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品重量:">
- <el-input type="number" disabled v-model="baseForm.sampleWeight" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <el-row>
- <header-title title="检测内容"></header-title>
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane label="来源清单" name="1">
- <!-- <ele-pro-table
- ref="table12"
- :columns="tableColumns"
- :datasource="datasource"
- :needPage="
- btnType == 'add' ||
- (btnType == 'edit' && !isFormNumber && !isOrder)
- ? false
- : true
- "
- @selection-change="handleSelectionChange"
- > -->
- <!-- :datasource="sourceList" -->
- <!-- :datasource="
- btnType == 'add' ||
- (btnType == 'edit' && (!isPackingList || !isSampleList))
- ? sourceList
- : datasource
- " -->
- <!-- 来料列表表格 -->
- <ele-pro-table
- ref="table12"
- :columns="tableColumns"
- :datasource="sourceList"
- :needPage="false"
- @selection-change="handleSelectionChange"
- height="500"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- >
- <!-- <template
- v-slot:toolbar
- v-if="this.baseForm.qualityMode == 2 && btnType != 'detail'"
- >
- <el-dropdown trigger="click" @command="handleSampleNumber">
- <el-link type="primary" icon="el-icon-plus">取样</el-link>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="1">取整样</el-dropdown-item>
- <el-dropdown-item command="2">取小样</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template> -->
- <template v-slot:toolkit v-if="this.baseForm.qualityMode == 2">
- <el-row>
- <el-form
- ref="ruleForm"
- :model="formData"
- label-width="60px"
- size="mini"
- :rules="rules"
- class="flex"
- :show-message="false"
- >
- <el-col :span="6" v-if="conditionType == 2">
- <el-form-item
- prop="number"
- label-width="0"
- style="margin-bottom: 0"
- >
- <el-input
- v-model="formData.number"
- placeholder="请输入"
- size="mini"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="conditionType == 2">
- <el-form-item
- prop="sampleUnit"
- label-width="0"
- style="margin: 0"
- >
- <DictSelection
- dictName="计量单位"
- clearable
- v-model="formData.sampleUnit"
- size="mini"
- @change="changeSamUnit"
- ></DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8" v-if="conditionType == 2">
- <el-form-item prop="portion" label="数量" style="margin: 0">
- <el-input
- v-model="formData.portion"
- placeholder="请输入"
- size="mini"
- clearable
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="10" v-if="conditionType == 1">
- <el-form-item prop="portion" label="数量" style="margin: 0">
- <el-input
- v-model="formData.portion"
- placeholder="请输入"
- size="mini"
- clearable
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="10" v-if="conditionType == 1">
- <el-form-item
- prop="packingUnit"
- label="单位"
- style="margin: 0"
- >
- <el-select
- v-model="formData.packingUnit"
- placeholder="请选择"
- >
- <el-option
- v-for="item in packingSpecificationOption"
- :key="item.id"
- :label="item.conversionUnit"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col
- :span="4"
- style="text-align: right"
- v-if="conditionType == 1"
- >
- <el-button
- type="primary"
- size="mini"
- @click="handleExtractFull"
- style="margin-right: 12px"
- >确认</el-button
- >
- </el-col>
- <el-col
- :span="4"
- style="text-align: right"
- v-if="conditionType == 2"
- >
- <el-button
- type="primary"
- size="mini"
- @click="handleExtractFull"
- style="margin-right: 12px"
- >确认</el-button
- >
- </el-col>
- </el-form>
- </el-row>
- </template>
- </ele-pro-table>
- </el-tab-pane>
- <!-- <el-tab-pane label="样品清单" name="2">
- <el-table
- v-show="activeName === '2'"
- v-if="sampleList.length > 0"
- ref="showSampleListTable"
- :data="paginatedSampleList"
- tooltip-effect="dark"
- height="500"
- border
- row-key="sampleCode"
- >
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- ></el-table-column>
- <template v-for="column in tableColumns2">
- <el-table-column
- :key="column.prop"
- :label="column.label"
- :prop="column.prop"
- :show-overflow-tooltip="true"
- :width="column.width"
- :align="column.align"
- ></el-table-column>
- </template>
- </el-table>
- </el-tab-pane> -->
- <el-tab-pane label="检测方案" name="3">
- <el-button
- @click="addInspectionTemplate(baseForm.type)"
- type="primary"
- style="margin-top: 5px"
- >选择检测方案</el-button
- >
- <el-table
- v-show="activeName === '3'"
- v-if="schemeList.length > 0"
- ref="showSchemeListTable"
- :data="paginatedSchemeList"
- tooltip-effect="dark"
- height="500"
- border
- row-key="id"
- >
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- ></el-table-column>
- <el-table-column
- label="检测方案编码"
- prop="qualitySchemeTemplateCode"
- align="center"
- width="170"
- ></el-table-column>
- <el-table-column
- label="检测方案名称"
- prop="qualitySchemeTemplateName"
- align="center"
- width="170"
- ></el-table-column>
- <el-table-column
- label="检测类型"
- prop="categoryLevelClassName"
- align="center"
- width="170"
- ></el-table-column>
- <el-table-column
- label="检测项编码"
- prop="inspectionCode"
- align="center"
- width="170"
- ></el-table-column>
- <el-table-column
- label="检测项名称"
- prop="inspectionName"
- align="center"
- width="150"
- ></el-table-column>
- <el-table-column
- label="工艺参数"
- prop="defaultValue"
- align="center"
- >
- <template slot-scope="scope">
- <div style="display: flex; flex-direction: row">
- <DictSelection
- v-if="btnType != 'detail'"
- style="width: 85px"
- clearable
- dictName="数学字符"
- v-model="scope.row.symbol"
- ></DictSelection>
- <el-input
- :disabled="btnType == 'detail'"
- v-model="scope.row.defaultValue"
- placeholder="请输入内容"
- style="width: 120px"
- ></el-input>
- <DictSelection
- v-if="btnType != 'detail'"
- dictName="工艺参数单位"
- clearable
- filterable
- v-model="scope.row.unitName"
- style="width: 100px"
- >
- </DictSelection>
- </div>
- </template>
- </el-table-column>
- <el-table-column fixed="right" label="操作" width="80">
- <template slot-scope="scope">
- <el-popconfirm
- class="ele-action"
- title="确定要删除当前方案吗?"
- @confirm="handDel(scope.$index)"
- >
- <template v-slot:reference>
- <el-link
- type="danger"
- :underline="false"
- icon="el-icon-delete"
- >
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- </el-tab-pane>
- </el-tabs>
- </el-row>
- <template v-slot:footer>
- <el-button @click="handleClose">取消</el-button>
- <el-button
- v-if="btnType != 'detail' && btnType != 'issued'"
- type="primary"
- :loading="loading"
- @click="handleSave"
- >保存</el-button
- >
- <el-button
- v-if="btnType != 'detail'"
- type="primary"
- :loading="loading"
- @click="handleIssued"
- >下发</el-button
- >
- <!-- 选择检测方案 -->
- <inspectionTemplateDialog
- v-if="baseForm"
- :type="baseForm.type"
- ref="inspectionTemplateRef"
- @choose="inspectionTemplateSuccess"
- ></inspectionTemplateDialog>
- </template>
- </ele-modal>
- </template>
- <script>
- // import baseInfo from './baseInfo.vue';
- import baseInfo from './new-baseInfo.vue';
- // 检测方案的弹窗
- import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
- import { getCode, getCodeList } from '@/api/login';
- import {
- save,
- update,
- planIssued,
- checkTemplateById,
- planDetails
- } from '@/api/inspectionPlan';
- import {
- getQualityTemplateList,
- getTemplateListByPlanId,
- getSampleListByPlanId,
- getInventoryListByPlanId,
- outInRecordsPage,
- getBatchInfoData,
- getProductOrder,
- getProductSteup
- } from '@/api/inspectionPlan/index.js';
- import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
- import tabMixins from '@/mixins/tableColumnsMixin';
- export default {
- components: {
- baseInfo,
- inspectionTemplateDialog
- },
- mixins: [tabMixins],
- data() {
- const defaultForm = function () {
- return {
- id: '',
- code: '',
- name: '',
- type: '',
- assignType: 0,
- teamId: '',
- productLineId: '',
- productLineName: '',
- qualityMode: 2,
- inspectionStandards: '',
- autoOrder: '',
- groupId: '',
- groupName: '',
- executeId: '',
- executeName: '',
- planStartTime: '',
- planEndTime: '',
- standard: '',
- planSource: '',
- planSourceCode: '',
- productName: '',
- productCode: '',
- batchNo: '',
- specification: '',
- modelType: '',
- brandNo: '',
- productNumber: '',
- qualifiedNumber: '',
- unqualifiedNumber: '',
- qualificationRate: '',
- totalWeight: '',
- sampleNumber: null,
- sampleMeasureUnit: '',
- sampleProportion: '',
- supplierMark: '',
- remark: '',
- accessory: [],
- cycleList: [],
- cycleType: '',
- cycleValue: '',
- conditionType: 1
- };
- };
- return {
- defaultForm,
- // 表单数据
- baseForm: { ...defaultForm() },
- cacheKeyUrl: 'qms-c2e9664a-inspectionPoint-components-new-edit',
- columnsVersion: 1,
- tableColumns2: [
- {
- label: '样品编码',
- prop: 'sampleCode',
- width: '150',
- align: 'center'
- },
- {
- label: '编码',
- prop: 'categoryCode',
- width: '150',
- align: 'center'
- },
- {
- label: '名称',
- prop: 'categoryName',
- width: '150',
- align: 'center'
- },
- { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
- { label: '发货条码', prop: 'barcodes', align: 'center' },
- { label: '包装编码', prop: 'packageNo', align: 'center' },
- { label: '包装数量', prop: 'packingQuantity', align: 'center' },
- { label: '包装单位', prop: 'packingUnit', align: 'center' },
- { label: '计量数量', prop: 'measureQuantity', align: 'center' },
- { label: '计量单位', prop: 'measureUnit', align: 'center' },
- { label: '物料代号', prop: 'materielDesignation', align: 'center' },
- { label: '客户代号', prop: 'clientCode', align: 'center' },
- { label: '刻码', prop: 'engrave', align: 'center' },
- {
- label: '机型',
- prop: 'modelKey',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '颜色',
- prop: 'colorKey',
- align: 'center',
- showOverflowTooltip: true
- },
- // { prop: 'specification', label: '规格', align: 'center', width: 100, showOverflowTooltip: true },
- // { prop: 'brandNum', label: '牌号', align: 'center', width: 100, showOverflowTooltip: true },
- // { prop: 'modelType', label: '型号', align: 'center', width: 100, showOverflowTooltip: true },
- { label: '重量', prop: 'weight', align: 'center' },
- { label: '重量单位', prop: 'weightUnit', align: 'center' },
- { label: '仓库', prop: 'warehouseName', align: 'center' },
- { label: '货区', prop: 'areaName', align: 'center' },
- { label: '货架', prop: 'goodsShelfName', align: 'center' },
- { label: '货位', prop: 'goodsAllocationName', align: 'center' },
- { label: '生产日期', prop: 'productionDate', align: 'center' },
- { label: '采购日期', prop: 'purchaseDate', align: 'center' }
- ],
- packingList: [],
- sourceList: [],
- sourcePagination: {
- currentPage: 1,
- pageSize: 10,
- total: 0
- },
- sampleList: [],
- samplePagination: {
- currentPage: 1,
- pageSize: 10,
- total: 0
- },
- schemeList: [],
- schemePagination: {
- currentPage: 1,
- pageSize: 10,
- total: 0
- },
- // 表单验证规则
- visible: false,
- btnType: null,
- title: null,
- loading: false,
- listPage: [],
- activeName: '1',
- selectedList: [],
- isCheck: false, // 是否拆包 false 不拆包 true 拆包
- rowIds: '',
- formData: {
- number: 1,
- sampleUnit: '',
- portion: null,
- packingUnit: ''
- },
- rules: {
- number: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ],
- sampleUnit: [
- {
- required: true,
- message: '请选择样品单位',
- trigger: 'change'
- }
- ],
- portion: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ],
- packingUnit: [
- {
- required: true,
- message: '请选择',
- trigger: 'change'
- }
- ]
- },
- isScheme: true,
- isOrder: true,
- isConsumable: '', //0 单件 1批量
- netWeight: '', // 净重
- conditionType: null,
- isFormNumber: true,
- sampleListCode: '',
- productItem: {}, //产品信息
- isUpdateData: true,
- isChangeNumber: true,
- isChangeType: true,
- isOnce: true,
- dimensionType: '',
- isSampleList: true,
- isPackingList: true,
- isSchemeList: true,
- newSampleList: [],
- kkconditionType: '',
- packingSpecificationOption: [] // 包装规格下拉
- };
- },
- watch: {
- // 样品清单
- sampleList: {
- handler: async function (newVal) {
- // 计算重量跟数量
- this.calculate(newVal);
- if (newVal && newVal.length > 0 && !newVal[0].sampleCode) {
- let count = newVal ? newVal.length : 0;
- const codeList = await this.batchCodes(count);
- newVal.map(async (el, index) => {
- if (!el.sampleCode) {
- this.$set(el, 'sampleCode', codeList[index]);
- }
- });
- }
- },
- deep: true,
- immediate: true
- }
- },
- computed: {
- tableColumns() {
- let columnsVersion = this.columnsVersion;
- return [
- // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
- // ? {
- // columnKey: 'selection',
- // type: 'selection',
- // width: 45,
- // align: 'center'
- // }
- // : null,
- {
- columnKey: 'selection',
- type: 'selection',
- width: 45,
- align: 'center'
- },
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- fixed: 'left'
- },
- {
- label: '编码',
- prop: 'categoryCode',
- width: 150,
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '名称',
- prop: 'categoryName',
- width: '150',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- { label: '批次号', prop: 'batchNo', align: 'center', width: 120 },
- { label: '发货条码', prop: 'barcodes', align: 'center' },
- {
- label: '包装编码',
- prop: 'packageNo',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '包装数量',
- prop: 'packingQuantity',
- align: 'center',
- formatter: (row) => {
- return row.packingQuantity || 0;
- }
- },
- { label: '包装单位', prop: 'packingUnit', align: 'center' },
- { label: '计量数量', prop: 'measureQuantity', align: 'center' },
- { label: '计量单位', prop: 'measureUnit', align: 'center' },
- { label: '物料代号', prop: 'materielDesignation', align: 'center' },
- { label: '客户代号', prop: 'clientCode', align: 'center' },
- {
- label: '供应商名称',
- prop: 'supplierName',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '供应商代号',
- prop: 'supplierCode',
- align: 'center',
- width: '120',
- showOverflowTooltip: true
- },
- { label: '刻码', prop: 'engrave', align: 'center' },
- {
- label: '机型',
- prop: 'modelKey',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '颜色',
- prop: 'colorKey',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '重量',
- prop: 'weight',
- align: 'center'
- },
- { label: '重量单位', prop: 'weightUnit', align: 'center' },
- {
- label: '仓库',
- prop: 'warehouseName',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- { label: '货区', prop: 'areaName', align: 'center' },
- { label: '货架', prop: 'goodsShelfName', align: 'center' },
- { label: '货位', prop: 'goodsAllocationName', align: 'center' },
- {
- label: '生产日期',
- prop: 'productionDate',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '采购日期',
- prop: 'purchaseDate',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- }
- ];
- },
- sampletypeVal() {
- return (row) => {
- if (row == 1) {
- return '整样';
- }
- return '小样';
- };
- },
- //分页后的来源列表
- paginatedSourceList() {
- console.log('分页', this.sourceList);
- // const { currentPage, pageSize } = this.sourcePagination;
- // const start = (currentPage - 1) * pageSize;
- // const end = start + pageSize;
- // return this.sourceList.slice(start, end);
- return this.sourceList;
- },
- // 分页后的样品列表
- paginatedSampleList() {
- return this.sampleList;
- // if (this.rowIds && this.isSampleList) {
- // console.log(this.sampleList, 'sampleList');
- // return this.sampleList;
- // }
- // const { currentPage, pageSize } = this.samplePagination;
- // const start = (currentPage - 1) * pageSize;
- // const end = start + pageSize;
- // return this.sampleList.slice(start, end);
- },
- // 分页后的检测方案列表
- paginatedSchemeList() {
- // if (this.rowIds && this.isScheme) {
- // console.log(this.schemeList, 'test');
- // return this.schemeList;
- // }
- // const { currentPage, pageSize } = this.schemePagination;
- // const start = (currentPage - 1) * pageSize;
- // const end = start + pageSize;
- // return this.schemeList.slice(start, end);
- return this.schemeList;
- }
- },
- created() {},
- methods: {
- //
- calculate(list) {
- let sampleQuantity = 0; // 样品数量
- let sampleWeight = 0; // 样品重量
- // list.forEach((el) => {
- // sampleQuantity += el.measureQuantity - 0;
- // sampleWeight += el.weight - 0;
- // });
- this.$set(this.baseForm, 'sampleQuantity', sampleQuantity); // 样品数量
- this.$set(this.baseForm, 'sampleWeight', sampleWeight); // 样品重量
- },
- //成品检验类型,计划来源主数据,修改数量生成来源清单
- changeProductNumberModel(num) {
- this.sourceList = [];
- this.packingList = [];
- this.isOrder = false;
- let nums = Number(num);
- let p = this.productItem;
- let list = [];
- if (this.isConsumable == 0) {
- for (let i = 0; i < nums; i++) {
- let obj = {
- id: p.id,
- batchNo: p.batchNo,
- categoryCode: p.code, //编码
- categoryName: p.name, //名称
- measureQuantity: 1,
- measureUnit: p.measuringUnit, //计量单位
- weightUnit: p.weightUnit, //重量单位
- weight: p.netWeight //重量
- };
- list.push(obj);
- }
- } else if (this.isConsumable == 1) {
- let obj = {
- id: p.id,
- batchNo: p.batchNo,
- categoryCode: p.code, //编码
- categoryName: p.name, //名称
- measureQuantity: nums, //计量数量
- measureUnit: p.measuringUnit, //计量单位
- weightUnit: p.weightUnit, //重量单位
- weight: p.netWeight * nums //重量
- };
- list.push(obj);
- }
- console.log('数据22222');
- console.log(this.isOrder);
- // this.$refs.table12.setData(list);
- console.log(list, 'list');
- this.sourceList = list;
- this.packingList = list;
- // *** 如果检验方式是全量的话 还需要同步样品清单数据
- if (
- this.baseForm.qualityMode == 1 &&
- this.baseForm.inspectionStandards
- ) {
- this.isFormNumber = false;
- console.log('+++++++++2');
- this.handleSampleList();
- }
- console.log(this.baseForm, 'form --');
- },
- // 受托收货单
- async setSourceData(data) {
- let params = {
- sourceBizNo: data.entrustedReceiveCode,
- categoryCode: data.productCode,
- categoryId: data.productId,
- size: -1
- };
- const res = await outInRecordsPage(params);
- this.sourceList = res.list || [];
- console.log(res, 'list333');
- // 在获取数据后执行后续操作:处理来源清单并设置样品清单
- if (this.sourceList && this.sourceList.length > 0) {
- // 处理来源清单数据
- const processedData = this.proceSources([...this.sourceList]);
- // 更新样品清单
- await this.updatePackingList(processedData);
- }
- },
- //成品类型检验类型,计划来源库存台账, 生成来源清单
- async changesStokledgerNumberModal(val, dimension, type) {
- val.map((el) => (el.sourceId = el.id));
- console.log(val, dimension, '获取成品检验订单数据', type);
- // this.$refs.table12.setData([]);
- val = this.proceSources(val);
- console.log(val, 'valvalvalvalvalvalval');
- this.sourceList = [];
- this.packingList = [];
- if (dimension) this.dimensionType = dimension;
- if (dimension == 3) {
- // this.$refs.table12.setData(val);
- this.sourceList = val;
- this.packingList = val;
- this.calculateWeightAndQuantity(val);
- if (this.baseForm.qualityMode == '1' || type) {
- this.handleUnpackCase(val);
- } else if (this.baseForm.qualityMode == '2' || type) {
- this.sampleList = [];
- }
- return;
- }
- console.log('其他', 'dimension');
- let item = val[0];
- let num = Number(item.outboundNum);
- let list = [];
- // let weight = (item.weight / item.measureQuantity).toFixed(2);
- let weight = (
- (item.weight / item.measureQuantity) *
- item.outboundNum
- ).toFixed(2);
- list.push({
- ...item,
- id: 1,
- packingQuantity: null,
- measureQuantity: item.outboundNum,
- weight
- });
- // for (let i = 0; i < num; i++) {
- // list.push({
- // ...item,
- // id: i + 1,
- // packingQuantity: null,
- // measureQuantity: 1,
- // weight
- // });
- // }
- // list.push({
- // ...item
- // });
- console.log(list, 'for循环成品检验订单数据');
- // this.$refs.table12.setData(list);
- this.sourceList = list;
- this.packingList = list;
- if (this.baseForm.qualityMode == '1' || type) {
- this.handleUnpackCase(list);
- } else if (this.baseForm.qualityMode == '2' || type) {
- this.sampleList = [];
- }
- },
- //获取基本信息中计量方式
- getInspectionStandards(data) {
- console.log(data, 'data');
- this.baseForm.inspectionStandards = data;
- if (this.baseForm.type == '3' && this.baseForm.planSource == '6') {
- // this.isOrder = false;
- this.handleSampleList();
- }
- if (this.btnType == 'edit' && !this.isOnce) {
- this.isOrder = false;
- this.handleSampleList();
- }
- this.isOnce = false;
- },
- async datasource({ page, limit, where }) {
- return await getInventoryListByPlanId({
- ...where,
- pageNum: page,
- size: limit
- });
- },
- // 切换检测内容
- handleClick(tab) {
- this.activeName = tab.name;
- },
- async open(type, row) {
- this.kkconditionType = row?.conditionType;
- this.visible = true;
- this.activeName = '1';
- this.btnType = type;
- this.title =
- type == 'add'
- ? '新增'
- : type == 'edit'
- ? '编辑'
- : type == 'issued'
- ? '下发'
- : '详情';
- if (this.btnType === 'add') {
- const code = await getCode('qms_plan_code');
- this.baseForm.code = code;
- this.rowIds = '';
- return;
- } else {
- await this.handleEditOrDetail(row);
- }
- if (type == 'issued') {
- checkTemplateById(row.id).then((res) => {
- if (res.message != '成功') {
- this.$message.warning(res.message);
- }
- });
- }
- },
- addInspectionTemplate(type) {
- this.$refs.inspectionTemplateRef.open(type);
- },
- async inspectionTemplateSuccess(select) {
- let data = await getQualityTemplateByIds({
- templateIds: select.map((item) => item.id)
- });
- this.isScheme = false;
- this.schemeList = data || [];
- this.schemePagination.total = this.schemeList.length;
- this.schemePagination.currentPage = 1;
- },
- async handleEditOrDetail(row) {
- console.log('row====', row);
- row.accessory = row.accessory || [];
- this.baseForm = {
- ...JSON.parse(JSON.stringify(row)),
- groupId: row.groupId,
- qualityMode: row.qualityMode
- };
- this.baseForm.assignType = this.baseForm.assignType || 0;
- this.$nextTick(() => {
- if (this.$refs.baseInfoRefs) {
- // 获取人员
- if (this.baseForm.groupId) {
- this.$refs.baseInfoRefs.getUserList({
- groupId: this.baseForm.groupId
- });
- }
- //根据类型获取计划来源
- if (this.baseForm.type) {
- this.$refs.baseInfoRefs.typeChange(this.baseForm.type, '1111');
- }
- if (this.baseForm.productId) {
- this.$refs.baseInfoRefs.getProductDetails(
- this.baseForm.productId
- );
- }
- this.$refs.baseInfoRefs.setRecordRulesCycleList();
- if (this.baseForm.teamId) {
- this.$refs.baseInfoRefs.teamChange(true);
- }
- }
- });
- // 如果是编辑或者详情,则查询物料清单、检测方案和样品列表
- if (row.id) {
- this.rowIds = row.id;
- this.isScheme = true;
- this.schemePagination.currentPage = 1;
- this.schemePagination.pageSize = 10;
- this.schemePagination.total = 0;
- this.samplePagination.pageSize = 10;
- this.samplePagination.currentPage = 1;
- this.samplePagination.total = 0;
- this.isFormNumber = true;
- this.isOrder = true;
- console.log('edit true');
- if (row.isUnpack === 1) {
- this.isCheck = true;
- } else {
- this.isCheck = false;
- }
- await this.getSourceList(row.id);
- //操作行点击时查询清单
- // await this.getInventoryList();
- await this.reload({ planId: row.id });
- //操作行点击时查询样品
- await this.getSampleList(row.id);
- //操作行点击时查询检测
- await this.getTemplateList(row.id);
- }
- console.log(this.baseForm, '00000000');
- },
- reload(where) {
- this.$nextTick(() => {
- if (this.$refs.table12 && this.$refs.table12.reload)
- this.$refs.table12.reload({ page: 1, where: where });
- });
- },
- async getSourceList(id) {
- const listData = await getInventoryListByPlanId({
- planId: id,
- pageNum: 1,
- size: -1
- });
- if (listData.list.length == 0) {
- this.sourceList = [];
- return;
- }
- listData.list = this.proceSources(listData.list);
- // this.packingSpecificationOption = listArr;
- this.sourceList = listData.list;
- },
- // 处理来源清单数据
- proceSources(arr) {
- console.log('方法调用没 443');
- let list = arr;
- let o = list[0];
- let listArr = [];
- if (o.measureUnit) {
- listArr.push({
- packageCellTotal: 1,
- conversionUnit: o.measureUnit,
- id: '111'
- });
- }
- if (o.packingUnit) {
- listArr.push({
- packageCellTotal: o.measureQuantity - 0,
- conversionUnit: o.packingUnit,
- id: '222'
- });
- }
- list.map((el) => {
- el.weightProportion = el.weight
- ? (el.weight / el.measureQuantity).toFixed(4)
- : 0;
- el.weightProportion = el.weightProportion - 0;
- });
- this.packingSpecificationOption = listArr;
- return list;
- },
- async getSampleList(id) {
- return;
- let newRes = await getSampleListByPlanId({
- planId: id,
- pageNum: 1,
- size: -1
- });
- this.sampleList = newRes?.list || [];
- this.newSampleList = newRes?.list || [];
- },
- async getTemplateList(id) {
- let res = await getTemplateListByPlanId({
- planId: id,
- pageNum: this.schemePagination.currentPage,
- // size: this.schemePagination.pageSize,
- size: 100000
- });
- this.schemeList = res?.list || [];
- this.schemePagination.total = res.count;
- },
- async getList(
- receiveNo,
- productCode,
- productCategoryId,
- productCategoryName,
- categoryid,
- batchNo,
- supplierName,
- supplierMark
- ) {
- //通过来源和产品 获取来料清单
- await this.getGoodsList(
- receiveNo,
- productCode,
- null,
- productCategoryId,
- productCategoryName,
- categoryid,
- batchNo,
- supplierName,
- supplierMark
- );
- //通过来源和产品 获取检测方案
- await this.getQualityTemplate(productCode);
- },
- async getGoodsList(
- receiveNo,
- productCode,
- ids,
- productCategoryId,
- productCategoryName,
- categoryid,
- batchNo,
- supplierName,
- supplierMark
- ) {
- // this.$refs.table12.setData([]);
- this.sourceList = [];
- this.packingList = [];
- let res;
- const res1 = await outInRecordsPage({
- sourceBizNo: receiveNo,
- categoryCode: productCode,
- categoryId: categoryid,
- qualityQlanId: ids,
- size: -1
- });
- console.log(res1, 'res1');
- if (res1.list.length > 0) {
- console.log(res1.list[0].status, 'status=2 不赋值');
- if (res1.list[0].status != 2) {
- res = res1.list;
- this.isCheck = true;
- console.log('this.isCheck=true', this.isCheck);
- } else {
- res = [];
- this.$message.error('此数据已检测,无需再次检测!');
- return;
- }
- } else {
- let resData = await getBatchInfoData({
- sourceBizNo: receiveNo,
- categoryCode: productCode,
- batchNo: batchNo
- });
- console.log(resData, 'resData');
- if (resData) {
- if (resData.qualityControl != 2) {
- this.isCheck = false;
- res = [resData];
- } else {
- res = [];
- this.$message.error('此数据已检测,无需再次检测!');
- return;
- }
- }
- }
- console.log(res, '来料清单');
- if (res.length > 0) {
- let _arr1 = res.map((m) => {
- m.sourceId = m.id;
- m.productCategoryId = productCategoryId;
- m.productCategoryName = productCategoryName;
- delete m.id;
- return { ...m };
- });
- this.packingList = _arr1;
- // this.$refs.table12.setData(_arr1); //赋值
- this.sourceList = _arr1;
- this.packingList = _arr1;
- this.baseForm.totalWeight = this.sourceList.reduce((acc, pre) => {
- return pre.weight ? acc + Number(pre.weight) : acc;
- }, 0);
- if (this.sourceList.length > 1) {
- this.baseForm.productNumber = this.sourceList.reduce((acc, pre) => {
- return pre.measureQuantity
- ? acc + Number(pre.measureQuantity)
- : acc;
- }, 0);
- } else {
- this.baseForm.productNumber = this.sourceList[0].measureQuantity;
- }
- //处理样品清单
- console.log('处理来源清单数据');
- // await this.handleSampleList();
- _arr1 = this.proceSources(_arr1);
- await this.updatePackingList(_arr1);
- } else {
- console.log('来料清单数据为空');
- // this.$refs.table12.setData([]);
- this.sourceList = val;
- this.packingList = [];
- }
- },
- async handleSampleList() {
- // let packingList = this.$refs.table12.getData();
- if (this.baseForm.type == '1' && this.btnType != 'detail') {
- if (this.baseForm.inspectionStandards == '2') {
- console.log(13131313213);
- this.sampleList = [];
- let list = [];
- if (this.baseForm.productNumber) {
- let p = this.productItem;
- console.log(p);
- let obj = {
- id: p.id,
- batchNo: p.batchNo,
- categoryCode: p.code, //编码
- categoryName: p.name, //名称
- measureQuantity: this.baseForm.productNumber, //计量数量
- measureUnit: p.measuringUnit, //计量单位
- weightUnit: p.weightUnit, //重量单位
- weight: p.netWeight * this.baseForm.productNumber //重量
- };
- list.push(obj);
- }
- if (list.length > 0 && list[0].categoryCode) {
- // this.$refs.table12.setData(list);
- this.sourceList = list;
- this.packingList = list;
- let packList = this.$refs.table12.getData();
- this.getFullInspectionWeight(packList);
- }
- } else {
- if (this.$refs.table12) {
- let packingList = this.$refs.table12.getData();
- if (
- Math.ceil(Number(this.baseForm.productNumber || 0)) ===
- packingList.length
- ) {
- console.log(
- '--->',
- Math.ceil(Number(this.baseForm.productNumber || 0))
- );
- console.log('--->', packingList.length);
- await this.handleUnpackCase(packingList);
- return;
- } else {
- this.getFullInspectionWeight(packingList);
- }
- }
- }
- }
- //全检时 计量时
- else if (
- this.baseForm.qualityMode == 1 &&
- this.baseForm.inspectionStandards == 1 &&
- this.btnType != 'detail'
- ) {
- this.sampleList = [];
- console.log(this.baseForm, '---isUnpack---');
- if (this.baseForm.productNumber) {
- console.log('数据777777');
- if (this.$refs.table12) {
- // this.$refs.table12.setData([]);
- this.sourceList = [];
- this.packingList = [];
- let nums = Number(this.baseForm.productNumber);
- let p = this.productItem;
- let list = [];
- for (let i = 0; i < nums; i++) {
- let obj = {
- id: p.id,
- batchNo: p.batchNo,
- categoryCode: p.code, //编码
- categoryName: p.name, //名称
- measureQuantity: 1,
- measureUnit: p.measuringUnit, //计量单位
- weightUnit: p.weightUnit, //重量单位
- weight: p.netWeight //重量
- };
- list.push(obj);
- }
- console.log('数据666666');
- // this.$refs.table12.setData(list);
- this.sourceList = list;
- this.packingList = list;
- let packList = this.$refs.table12.getData();
- await this.handleUnpackCase(packList);
- return;
- }
- }
- //全检 计重时
- } else if (
- this.baseForm.qualityMode == 1 &&
- this.baseForm.inspectionStandards == 2 &&
- this.btnType != 'detail'
- // (this.btnType != 'detail' || this.btnType != 'edit')
- // this.btnType == 'add'
- ) {
- this.sampleList = [];
- let list = [];
- if (this.baseForm.productNumber) {
- let p = this.productItem;
- let obj = {
- id: p.id,
- batchNo: p.batchNo,
- categoryCode: p.code, //编码
- categoryName: p.name, //名称
- measureQuantity: this.baseForm.productNumber, //计量数量
- measureUnit: p.measuringUnit, //计量单位
- weightUnit: p.weightUnit, //重量单位
- weight: p.netWeight * this.baseForm.productNumber //重量
- };
- list.push(obj);
- }
- console.log('数据55555');
- console.log(list);
- if (list.length > 0 && list[0].categoryCode) {
- // this.$refs.table12.setData(list);
- this.sourceList = list;
- this.packingList = list;
- let packList = this.$refs.table12.getData();
- this.getFullInspectionWeight(packList);
- }
- } else {
- console.log('进来了这里');
- this.sampleList = [];
- }
- },
- //全检 计重时生成样品清单
- async getFullInspectionWeight(packingList) {
- this.updatePackingList(packingList);
- },
- //拆包处理样品清单数据
- async handleUnpackCase(packingList) {
- if (this.baseForm.type == '3') {
- this.getFullInspectionWeight(packingList);
- } else {
- const num = Number(this.baseForm.productNumber || 0);
- console.log('num:' + num);
- if (num) {
- await this.getUnpackSamList(packingList, num);
- }
- }
- },
- //获取样品编码
- async getSampleCode() {
- return await getCode('sample_code');
- },
- // 创建计量数量为1的样品清单函数,用于计数类型的
- async createSampleList(list) {
- if (this.baseForm.qualityMode != null) {
- const ProductSampleList = [];
- console.log(list, 'list');
- for (const oldItem of list) {
- const count = oldItem.measureQuantity;
- const newMeasureQuantity = oldItem.measureQuantity / count;
- const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
- console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
- // 遍历新数组设置 qualityResults 默认值
- this.schemeList.forEach((item) => {
- if (typeof item === 'object' && item !== null) {
- item.qualityResults = 1; // 设置默认值
- }
- delete item.id;
- });
- console.log(oldItem, 'oldItem');
- console.log(count, newMeasureQuantity, newWeight);
- delete oldItem.id;
- if (
- oldItem.qualitySampleTemplateList == undefined ||
- oldItem.qualitySampleTemplateList == null ||
- oldItem.qualitySampleTemplateList.length == 0
- ) {
- oldItem.qualitySampleTemplateList = JSON.parse(
- JSON.stringify(this.schemeList)
- );
- for (let i = 0; i < count; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- )
- });
- }
- console.log(ProductSampleList, 'ProductSampleList');
- this.sampleList = ProductSampleList;
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.baseForm.totalWeight = parseFloat(pNum.toFixed(2));
- } else {
- for (let i = 0; i < count; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(oldItem.qualitySampleTemplateList)
- )
- });
- }
- console.log(ProductSampleList, 'ProductSampleList');
- this.sampleList = ProductSampleList;
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.baseForm.totalWeight = parseFloat(pNum.toFixed(2));
- }
- }
- }
- },
- // 批量生成编码 4444444 getCodeList
- async batchCodes(count) {
- if (count <= 0) return;
- let params = { count };
- const res = await getCodeList('sample_code', params);
- return res;
- },
- //更新样品清单数据
- async updatePackingList(list) {
- return;
- console.log('进来了没有 pppppp');
- // 计量类型1是数量,2是重量
- // if (this.baseForm.inspectionStandards == 1) {
- // this.createSampleList(list);
- // return;
- // }
- let count = list ? list.length : 0;
- const codeList = await this.batchCodes(count);
- if (this.baseForm.inspectionStandards == 2) {
- for (let i = 0; i < list.length; i++) {
- // list[i].sampleCode = await this.getSampleCode();
- list[i].sampleCode = codeList[i];
- }
- // this.updatePackingList(list, this.form.total);
- // this.handleWeightFullSample(this.form.total);
- }
- console.log(this.baseForm.inspectionStandards);
- console.log(list, 'list +++++++++++ 00000000000');
- this.sampleList = list;
- this.baseForm.sampleNumber = list.length;
- this.samplePagination.currentPage = 1;
- this.samplePagination.total = list.length;
- // const sampleProportion = this
- // this.samplePagination.total = this.sampleList.length;
- },
- async getUnpackSamList(list, num) {
- console.log(list, num);
- let data = [];
- list.forEach((oldItem, index) => {
- const newMeasureQuantity =
- oldItem.measureQuantity / this.baseForm.productNumber;
- const newWeight = parseFloat(
- (oldItem.weight / this.baseForm.productNumber).toFixed(2)
- );
- // 将 measureQuantity 转换为数字
- const measureQuantity = Number(oldItem.measureQuantity);
- // 判断是否有小数部分
- const hasDecimal = measureQuantity % 1 !== 0;
- let roundedQuantity;
- if (hasDecimal) {
- // 有小数部分,向上取整
- roundedQuantity = Math.ceil(measureQuantity);
- } else {
- roundedQuantity = measureQuantity;
- }
- delete oldItem.id;
- for (let i = 0; i < roundedQuantity; i++) {
- data.push({
- ...oldItem,
- // measureQuantity: 1,
- weight: this.netWeight || 0
- // weight:
- // num - index >= 1
- // ? this.netWeight
- // : ((num * 100000 - index * 100000) / 100000) * this.netWeight
- });
- }
- });
- console.log(data, '样品数据-条数', num);
- await this.updatePackingList(data);
- },
- async getQualityTemplate(productCode, ids) {
- await getQualityTemplateList({
- type: this.baseForm.type,
- productCode: productCode,
- qualityQlanId: ids
- }).then((res) => {
- if (Object.keys(res).length === 0) {
- return;
- }
- this.baseForm.sampleProportion = res.checkProportion;
- // this.baseForm.inspectionStandards = res?.inspectionStandards;
- let combinedList = [];
- for (let i = 0; i < res.qualityTemplateVOList.length; i++) {
- res.qualityTemplateVOList[i].inspectionItemVOList =
- res.qualityTemplateVOList[i]?.inspectionItemVOList.map((item) => {
- item.templateId = res.qualityTemplateVOList[i]?.id;
- item.qualitySchemeTemplateCode =
- res.qualityTemplateVOList[i]?.qualitySchemeTemplateCode;
- item.qualitySchemeTemplateName =
- res.qualityTemplateVOList[i]?.qualitySchemeTemplateName;
- delete item.id;
- return {
- ...item
- };
- });
- combinedList = combinedList.concat(
- res.qualityTemplateVOList[i].inspectionItemVOList
- );
- console.log(combinedList, '检测方案');
- this.schemeList = combinedList;
- this.schemePagination.currentPage = 1;
- this.schemePagination.total = this.schemeList.length;
- }
- });
- },
- //来料列表表格选择事件
- handleSelectionChange(selection) {
- console.log(selection, '勾选');
- this.selectedList = selection;
- //如果取小样
- if (this.conditionType == 2) {
- if (this.isCheck) {
- this.formData.portion = selection.length;
- this.baseForm.sampleNumber = selection.length;
- } else {
- this.baseForm.sampleNumber = this.formData.portion;
- }
- const data1 = this.$refs.table12.getData();
- this.$set(this.formData, 'sampleUnit', data1[0]?.measureUnit);
- this.$set(this.baseForm, 'sampleMeasureUnit', data1[0]?.measureUnit);
- } else if (this.conditionType == 1) {
- this.baseForm.sampleNumber = this.formData.portion;
- this.formData.number = 0;
- }
- },
- //取样方式选择
- async handleSampleNumber(val) {
- console.log(val, 'val');
- this.conditionType = val;
- //清空样品清单列表
- this.sampleList = [];
- },
- handleInputNumber(val) {
- let packingList = this.$refs.table12.getData();
- const maxValue =
- packingList.length > 1
- ? packingList.length
- : packingList[0].measureQuantity;
- if (val > maxValue) {
- this.$message.warning('数量不能大于计量数量!');
- this.formData.number = maxValue;
- return;
- }
- },
- // 整样输入框事件
- handleInput(val) {
- if (val == 0 || val == '' || val == null) {
- this.$refs.table12.clearSelection();
- return;
- }
- let packingList = this.$refs.table12.getData();
- if (!packingList || packingList.length === 0) {
- return;
- }
- // 计算 packingList 中 measureQuantity 字段的总和
- const measureQuantitySum = packingList.reduce((sum, item) => {
- const quantity = Number(item.measureQuantity) || 0;
- return sum + quantity;
- }, 0);
- const portion = Number(this.formData.portion);
- // 清空当前选中
- this.$refs.table12.clearSelection();
- if (this.conditionType == 2) {
- // 取小样
- // 确保 portion 不超过数据列表长度
- const safePortion = Math.min(portion, packingList.length);
- if (this.isCheck) {
- // 是否拆包 false 不拆包
- if (portion > packingList.length) {
- this.$message.warning('取样数量不能大于来源清单数量!');
- this.formData.portion = packingList.length;
- }
- } else {
- const maxQuantity = Number(packingList[0].measureQuantity);
- if (portion > maxQuantity) {
- this.$message.warning('取样数量不能大于计量数量!');
- this.formData.portion = maxQuantity;
- }
- }
- // 选中前 safePortion 行
- packingList.slice(0, safePortion).forEach((row) => {
- this.$refs.table12.toggleRowSelection(row, true);
- });
- } else if (this.conditionType == 1) {
- // 确保 portion 不超过数据列表长度
- const safePortion = Math.min(portion, measureQuantitySum);
- if (portion > measureQuantitySum) {
- this.$message.warning('取样数量不能大于计量数量!');
- this.formData.portion = measureQuantitySum;
- }
- // 选中前 safePortion 行
- packingList.slice(0, safePortion).forEach((row) => {
- this.$refs.table12.toggleRowSelection(row, true);
- });
- }
- },
- // 选中物品后触发了这个事件
- async getCategoryInfo(val) {
- console.log(this.baseForm.type, this.baseForm.planSource);
- // this.baseForm.isUnpack = val.categoryWms.isUnpack;
- console.log(val, '产品信息');
- console.log(this.baseForm, 'baseForm');
- if (this.baseForm.type == 2 && this.baseForm.planSource == '4') {
- if (val.category.id) {
- const res1 = await getProductSteup(val.category.id);
- const index = res1.findIndex(
- (item) => item.taskId == val.category.taskId
- );
- if (index) {
- const res2 = await getProductOrder({
- taskId: res1[index - 1].taskId,
- workOrderId: val.category.id
- });
- if (res2[0].semiProductList.length > 1) {
- this.baseForm.productNumber = res2[0].semiProductList.length;
- } else {
- this.baseForm.productNumber =
- res2[0].semiProductList.measureQuantity;
- }
- }
- this.isConsumable = val.category.isConsumable;
- this.netWeight = val.category.netWeight;
- this.productItem = val.category;
- console.log('+++++++++');
- this.handleSampleList();
- return;
- }
- }
- this.isConsumable = val.category.isConsumable;
- this.netWeight = val.category.netWeight;
- this.productItem = val.category; //产品信息
- },
- changeSamUnit(val) {
- console.log(val);
- this.$refs.baseInfoRefs.getsampleMeasureUnit(val);
- },
- calculateWeightAndQuantity(list) {
- console.log(list);
- this.baseForm.totalWeight = list.reduce((acc, pre) => {
- return pre.weight ? acc + Number(pre.weight) : acc;
- }, 0);
- this.baseForm.productNumber = list.reduce((acc, pre) => {
- return pre.measureQuantity ? acc + Number(pre.measureQuantity) : acc;
- }, 0);
- },
- //从来源数组取样到目标数组
- async getNewFullSampleList(
- sampleCount,
- sampleQuantity,
- sampleUnit,
- specifications
- ) {
- console.log(
- '从来源数组取样到目标数组',
- sampleCount,
- sampleQuantity,
- sampleUnit
- );
- const sourceArray = this.selectedList;
- // 检查单位是否匹配
- const isUnitMismatch =
- sourceArray.length > 0 && sourceArray[0].measureUnit !== sampleUnit;
- // 创建副本并计算初始可取样数量
- const items = sourceArray.map((item) => ({
- ...item,
- remainingQuantity: isUnitMismatch
- ? Infinity
- : item['measureQuantity'], // 剩余可取样数量
- maxPossible: item['measureQuantity'] / sampleQuantity // 最大取样次数
- }));
- console.log(items, 'items items items');
- console.log(sampleQuantity, 'sampleQuantity sampleQuantity [[[]]]');
- const result = [];
- let remainingCount = sampleCount;
- console.log(remainingCount, 'remainingCount ========');
- let count = Math.ceil(remainingCount);
- const codeList = await this.batchCodes(count);
- let codeIdx = 0;
- // 尽可能均匀地从各条目取样
- while (remainingCount > 0) {
- // 按剩余可取样比例排序
- items.sort(
- (a, b) =>
- b.remainingQuantity / b['measureQuantity'] -
- a.remainingQuantity / a['measureQuantity']
- );
- let distributed = false;
- for (const item of items) {
- console.log(
- remainingCount,
- 'remainingCount remainingCount remainingCount'
- );
- let values = remainingCount > 1 ? 1 : remainingCount;
- // sampleQuantity = remainingCount > 1 ? 1 : remainingCount;
- // console.log(sampleQuantity, 'sampleQuantity ----');
- if (
- (!isUnitMismatch && remainingCount > 0) ||
- (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
- ) {
- // 添加到结果数组
- this.samplePagination.total = 0;
- // let sampleCode = await this.getSampleCode();
- let sampleCode = codeList[codeIdx];
- if (
- this.conditionType == 1 &&
- this.baseForm.inspectionStandards == 1
- ) {
- console.log('进来1');
- result.push({
- ...item,
- // measureQuantity: values,
- measureQuantity: 1,
- sampleCode
- });
- } else if (
- this.conditionType == 2 &&
- (this.baseForm.inspectionStandards == 1 ||
- this.baseForm.inspectionStandards == 2)
- ) {
- console.log('进来2');
- let weight = (item.weight / item.maxPossible).toFixed(2);
- result.push({
- ...item,
- measureQuantity: sampleQuantity,
- measureUnit: sampleUnit,
- sampleCode,
- weight
- });
- }
- // 更新剩余数量
- if (!isUnitMismatch) {
- item.remainingQuantity -= sampleQuantity;
- }
- remainingCount = (remainingCount - 1).toFixed(2);
- codeIdx++;
- distributed = true;
- }
- }
- // 如果没有分配任何取样
- if (!distributed) {
- break;
- }
- }
- console.log('样品清单', this.sampleList);
- console.log('样品清单List', result);
- // 判断是不是取整样
- if (
- this.baseForm.conditionType == 1 &&
- specifications &&
- specifications.id
- ) {
- result.map((el) => {
- el.measureQuantity =
- el.measureQuantity * specifications.packageCellTotal;
- el.weight = this.formatNumber(
- el.measureQuantity,
- el.weightProportion
- );
- });
- }
- this.sampleList = result;
- this.samplePagination.total = result.length;
- this.baseForm.sampleNumber = this.sampleList.length; // 更新样品数量
- this.changeSamUnit(sampleUnit);
- },
- // 小数点数据判断
- formatNumber(a, b, maxDecimals = 4) {
- if (a == 0 || b == 0 || !a || !b) {
- return 0;
- }
- // 计算乘积
- const product = a * b;
- // 转换为固定小数位数,然后转换为数字以去除末尾零
- const rounded = Number(product.toFixed(maxDecimals));
- // 转换为字符串检查是否需要显示小数部分
- const str = rounded.toString();
- // 如果包含小数点
- if (str.indexOf('.') !== -1) {
- // 移除末尾的零和小数点(如果后面没有数字了)
- return str.replace(/\.?0+$/, '');
- }
- return str;
- },
- //抽样确认按钮事件-样品列表右上角确认按钮
- handleSampleSubmit() {
- this.$refs.ruleForm.validate((valid) => {
- if (valid) {
- this.sampleList = [];
- this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
- let measureQ = this.formData.number;
- let unit = this.formData.sampleUnit;
- let nums = Number(this.formData.portion);
- console.log(measureQ, unit, nums, 'measureQ, unit, nums');
- this.getNewFullSampleList(nums, measureQ, unit);
- this.activeName = '2';
- }
- });
- },
- //监听类型变化
- resetTable() {
- this.$nextTick(() => {
- this.table1();
- this.table2();
- });
- },
- table1() {
- this.$refs.table12.setData([]);
- this.sourceList = [];
- this.packingList = [];
- this.schemeList = [];
- },
- table2() {
- this.$nextTick(() => {
- // if (this.btnType == 'edit' && !this.isOnce) {
- // this.isOrder = false;
- this.sampleList = [];
- // }
- });
- },
- resetForm() {
- this.baseForm = { ...this.defaultForm() };
- },
- handleClose() {
- this.$nextTick(() => {
- // 关闭后,销毁所有的表单数据
- this.resetForm();
- this.resetTable();
- this.isScheme = true;
- this.isOrder = true;
- this.packingList = [];
- this.sampleList = [];
- this.samplePagination = {
- currentPage: 1,
- pageSize: 10,
- total: 0
- };
- (this.schemeList = []),
- (this.schemePagination = {
- currentPage: 1,
- pageSize: 10,
- total: 0
- });
- // 表单验证规则
- this.visible = false;
- this.btnType = null;
- this.title = null;
- this.loading = false;
- this.listPage = [];
- this.activeName = '1';
- this.selectedList = [];
- this.isCheck = false; // 是否拆包 false 不拆包 true 拆包
- this.rowIds = '';
- (this.formData = {
- number: 1,
- sampleUnit: '',
- portion: null
- }),
- (this.rules = {
- number: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ],
- sampleUnit: [
- {
- required: true,
- message: '请选择样品单位',
- trigger: 'change'
- }
- ],
- portion: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ]
- });
- this.isConsumable = ''; //0 单件 1批量
- this.netWeight = ''; // 净重
- this.conditionType = null;
- this.isFormNumber = true;
- this.sampleListCode = '';
- this.productItem = {}; //产品信息
- this.$refs['baseInfoRefs'] &&
- this.$refs['baseInfoRefs'].$refs.form1.resetFields();
- this.visible = false;
- this.baseForm.groupId = '';
- this.baseForm.qualityMode = '';
- this.baseForm = { ...this.defaultForm() };
- this.isChangeNumber = true;
- this.isChangeType = true;
- this.isOnce = true;
- this.dimensionType = '';
- this.isPackingList = true;
- this.isSampleList = true;
- });
- },
- /* 保存编辑 */
- handleSave() {
- this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
- if (!valid) {
- return false;
- }
- this.loading = true;
- if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
- this.baseForm.isUnpack = this.isCheck ? 1 : 2;
- }
- this.baseForm.conditionType =
- this.conditionType ?? this.kkconditionType;
- let cycleList =
- this.$refs.baseInfoRefs.$refs.cycleMultipleRef.recordRulesCycleList
- .map((i) => {
- // 根据月日时分排序计算权重排序
- let sortNum = 0;
- if (i.month) {
- sortNum += i.month * 60 * 24 * 30;
- }
- if (i.day) {
- sortNum += i.day * 60 * 24;
- }
- if (i.hour) {
- sortNum += i.hour * 60;
- }
- if (i.minute) {
- sortNum += i.minute * 1;
- }
- return { ...i, sortNum };
- })
- .sort((a, b) => a.sortNum - b.sortNum)
- .map((i, index) => {
- return { ...i, sortNum: index + 1 };
- });
- const qualityListData =
- this.btnType == 'add'
- ? this.sourceList
- : this.btnType == 'edit' && this.isPackingList
- ? []
- : this.sourceList;
- const sampleListData =
- this.btnType == 'add'
- ? this.sampleList
- : this.btnType == 'edit' && this.isSampleList
- ? this.newSampleList
- : this.sampleList;
- let params = {
- ...this.baseForm,
- qualityInventoryList: qualityListData,
- sampleList: sampleListData,
- planTemplateList: this.schemeList,
- cycleList
- };
- console.log(params, 'params');
- if (this.btnType == 'issued' && this.schemeList.length < 1) {
- this.$message.warning('检测方案不能为空!');
- this.loading = false;
- return;
- }
- let URL =
- this.btnType == 'add' ? save : this.btnType == 'edit' ? update : '';
- console.log(params, 'params');
- URL(params)
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- this.handleClose();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- handleIssued() {
- // if (this.sampleList.length == 0) {
- // this.$message.warning('样品清单为空!先进行修改操作再下发!');
- // return;
- // }
- this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
- if (!valid) {
- return false;
- }
- this.loading = true;
- if (this.baseForm.isUnpack == null || this.baseForm.isUnpack == '') {
- this.baseForm.isUnpack = this.isCheck ? 1 : 2;
- }
- this.baseForm.conditionType =
- this.conditionType ?? this.kkconditionType;
- let cycleList =
- this.$refs.baseInfoRefs.$refs.cycleMultipleRef.recordRulesCycleList
- .map((i) => {
- // 根据月日时分排序计算权重排序
- let sortNum = 0;
- if (i.month) {
- sortNum += i.month * 60 * 24 * 30;
- }
- if (i.day) {
- sortNum += i.day * 60 * 24;
- }
- if (i.hour) {
- sortNum += i.hour * 60;
- }
- if (i.minute) {
- sortNum += i.minute * 1;
- }
- return { ...i, sortNum };
- })
- .sort((a, b) => a.sortNum - b.sortNum)
- .map((i, index) => {
- return { ...i, sortNum: index + 1 };
- });
- const qualityListData = this.sourceList;
- const sampleListData =
- this.btnType == 'add'
- ? this.sampleList
- : this.btnType == 'issued' && this.isSampleList
- ? this.newSampleList
- : this.sampleList;
- let params = {
- ...this.baseForm,
- qualityInventoryList: qualityListData,
- sampleList: sampleListData,
- planTemplateList: this.schemeList,
- cycleList
- };
- console.log(params, 'params');
- if (this.btnType == 'issued' && this.schemeList.length < 1) {
- this.$message.warning('检测方案不能为空!');
- this.loading = false;
- return;
- }
- planIssued(params)
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- this.handleClose();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- // 样品列表分页方法
- async handleSampleSizeChange(val) {
- this.samplePagination.pageSize = val;
- this.samplePagination.currentPage = 1;
- if (this.rowIds && this.isOrder) {
- await this.getSampleList(this.rowIds);
- }
- //操作行点击时查询样品
- },
- async handleSampleCurrentChange(val) {
- this.samplePagination.currentPage = val;
- if (this.rowIds && this.isSampleList) {
- await this.getSampleList(this.rowIds);
- }
- },
- // 检测方案分页方法
- async handleSchemeSizeChange(val) {
- this.schemePagination.pageSize = val;
- this.schemePagination.currentPage = 1;
- //操作行点击时查询检测
- if (this.rowIds && this.isScheme) {
- await this.getTemplateList(this.rowIds);
- }
- },
- async handleSchemeCurrentChange(val) {
- this.schemePagination.currentPage = val;
- //操作行点击时查询检测
- if (this.rowIds && this.isScheme) {
- await this.getTemplateList(this.rowIds);
- }
- },
- //检验方式改变时,重新获取样品列表
- changeModel(val) {
- console.log('更改检验方式');
- this.baseForm.qualityMode = val;
- this.isSampleList = false;
- if (this.btnType != 'issued') {
- this.baseForm.sampleNumber = '';
- }
- console.log(this.baseForm, 'this.baseForm 0000000000000');
- if (this.baseForm.type == '3') {
- console.log(this.sourceList, this.dimensionType, '更改检验方式223');
- if (
- this.sourceList &&
- this.dimensionType &&
- this.baseForm.qualityMode == '1'
- ) {
- // const listData = this.$refs.table12.getData();
- console.log(this.sourceList, '成品检验订单数据');
- this.changesStokledgerNumberModal(
- this.sourceList,
- this.dimensionType,
- 'type'
- );
- return;
- } else if (
- this.sourceList &&
- this.dimensionType &&
- this.baseForm.qualityMode == '2'
- ) {
- this.sampleList = [];
- } else {
- if (
- this.baseForm.qualityMode == '1' &&
- this.sourceList.length > 1
- ) {
- this.changesStokledgerNumberModal(this.sourceList, '3', 'type');
- } else if (
- this.baseForm.qualityMode == '2' &&
- this.sourceList.length > 1
- ) {
- this.sampleList = [];
- } else if (
- this.baseForm.qualityMode == '1' &&
- this.sourceList.length > 0
- ) {
- this.changesStokledgerNumberModal(
- this.sourceList,
- this.dimensionType,
- 'type'
- );
- } else {
- this.sampleList = [];
- }
- }
- return;
- }
- // 全检
- if (this.baseForm.qualityMode == 1) {
- // console.log('+++++++++1');
- // this.handleSampleList();
- this.updatePackingList(this.sourceList);
- } else {
- this.sampleList = [];
- }
- },
- changeType() {
- this.isPackingList = false;
- },
- changeSource() {
- this.isSampleList = false;
- },
- //确定按钮
- handleExtractFull() {
- this.$refs.ruleForm.validate(async (valid) => {
- if (!valid || !this.validateSelection()) return;
- this.isSampleList = false;
- this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
- this.sampleList = [];
- const sampleCount = Number(this.formData.portion);
- console.log(sampleCount, 'sampleCount sampleCount == p');
- console.log(this.formData, 'this.formData 000');
- const measureQ = this.formData.number || 1;
- const unit = this.formData.sampleUnit;
- let specifications = this.packingSpecificationOption.find(
- (el) => el.id == this.formData.packingUnit
- );
- try {
- if (this.isStandard1OrWeightSample()) {
- // 新增校验 数量 取整样 ***
- console.log(this.baseForm.conditionType, '33333333333');
- if (this.conditionType == 1) {
- let isFlag = this.validateSampleQuantity(
- sampleCount,
- specifications
- );
- if (!isFlag) return;
- }
- // ***
- //抽检计量整样小样或者抽检计重小样
- if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
- return;
- if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
- return; // 若计量单位为重量,还需验证总重量是否足够
- console.log('getNewFullSampleList');
- if (this.conditionType == '1' && this.baseForm.type == '3') {
- console.log(1111111111111111111);
- await this.handleWeightFullSample(sampleCount, specifications);
- } else {
- console.log('2222222222222 --', Math.ceil(sampleCount));
- await this.getNewFullSampleList(
- Math.ceil(sampleCount),
- // sampleCount,
- measureQ,
- unit,
- specifications
- );
- }
- } else if (this.isWeightStandardFullSample()) {
- //抽检取计重取整样
- if (!this.validateSampleCount(sampleCount, specifications))
- return;
- await this.handleWeightFullSample(sampleCount, specifications);
- }
- this.activeName = '2';
- } catch (error) {
- console.error('取样处理失败:', error);
- this.$message.error('取样处理失败');
- }
- });
- },
- // 当计量类型 是数量的时候 取整样 校验
- validateSampleQuantity(sampleCount, specifications) {
- console.log(this.selectedList, 'this.selectedList 9999');
- console.log(specifications, 'specificationsspecifications');
- let packingUnit = this.selectedList[0].packingUnit?.trim() || '';
- console.log(packingUnit, 'packingUnitpackingUnit');
- let totalS = 0;
- let labelKey =
- packingUnit == specifications.conversionUnit.trim()
- ? 'packingQuantity'
- : 'measureQuantity';
- let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
- totalS = this.selectedList.reduce(
- (total, el) => total + el[labelKey],
- 0
- );
- if (sampleCount > totalS) {
- this.$message.info(
- `所填的条目数量不能超过所选${labelName}总和${totalS}`
- );
- return false;
- }
- return true;
- },
- validateSelection() {
- if (!this.selectedList?.length) {
- this.$message.warning('请先选择样品!');
- return false;
- }
- return true;
- },
- isStandard1OrWeightSample() {
- return (
- this.baseForm.inspectionStandards === 1 ||
- (this.baseForm.inspectionStandards === 2 && this.conditionType == 2)
- );
- },
- isWeightStandardFullSample() {
- return (
- this.baseForm.inspectionStandards === 2 && this.conditionType == 1
- );
- },
- validateMeasureQuantity(measureQ, unit, sampleCount) {
- if (this.conditionType == 2 && measureQ <= 0) {
- this.$message.info('取样计量数量必须大于0');
- return false;
- }
- const totalQuantity = this.selectedList.reduce(
- (sum, item) => sum + item.measureQuantity,
- 0
- );
- if (
- (this.selectedList[0].measureUnit === unit ||
- this.conditionType == 1) &&
- measureQ * sampleCount > totalQuantity
- ) {
- this.$message.info('取样计量数量不能大于总计量数量');
- return false;
- }
- console.log(this.selectedList, '33333333333');
- console.log(measureQ, 'measureQ 0000');
- const invalidItem = this.selectedList.find(
- (item) => item.measureQuantity < measureQ
- );
- if (invalidItem) {
- this.$message.info('条目计量数量小于取样计量数量');
- return false;
- }
- return true;
- },
- validateWeight(measureQ, sampleCount) {
- let totalMaxPossible = 0;
- this.selectedList.forEach((item) => {
- totalMaxPossible += item.measureQuantity / measureQ;
- });
- if (totalMaxPossible < sampleCount) {
- this.formData.portion = totalMaxPossible;
- this.$message.info(`最大取样条数为${totalMaxPossible}`);
- return false;
- }
- let totalWeight = this.selectedList.reduce(
- (sum, item) => sum + item.weight,
- 0
- );
- const weightUnit = this.selectedList[0].weightUnit;
- if (weightUnit === 'G') totalWeight /= 1000;
- console.log(measureQ * sampleCount, totalWeight);
- if (measureQ * sampleCount > totalWeight) {
- this.$message.info('取样计量重量不能大于总计量重量');
- return false;
- }
- const invalidItem = this.selectedList.find((item) => {
- const weight =
- item.weightUnit === 'G' ? item.weight / 1000 : item.weight;
- return weight < measureQ;
- });
- if (invalidItem) {
- this.$message.info('勾选条目重量小于取样重量');
- return false;
- }
- return true;
- },
- validateSampleCount(sampleCount, specifications) {
- // 新增校验 ***
- let isFlag = this.validateSampleQuantity(sampleCount, specifications);
- if (!isFlag) {
- return false;
- }
- // ***
- const chooseNumber = this.selectedList.reduce((acc, pro) => {
- return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
- }, 0);
- const invalidItem = chooseNumber < sampleCount;
- if (invalidItem) {
- this.$message.info('所选的条目计量数量小于取样计量数量');
- return false;
- }
- return true;
- },
- async handleWeightFullSample(sampleCount, specifications) {
- let currentNum = sampleCount - this.selectedList.length;
- let currentNum1 = sampleCount;
- let list = [];
- this.selectedList.forEach((item) => {
- if (sampleCount >= this.selectedList.length) {
- list.push({
- ...item,
- measureQuantity: 1, //作为计量数量
- weight: item.singleWeight
- ? (Number(item.singleWeight) * Number(sampleCount)).toFixed(2)
- : item.outboundNum
- ? (
- (Number(item.weight) / Number(item.outboundNum)) *
- Number(sampleCount)
- ).toFixed(2)
- : item.weight
- });
- } else {
- if (list.length < sampleCount) {
- list.push({
- ...item,
- measureQuantity: currentNum1 > 1 ? 1 : currentNum1, //作为计量数量
- weight: item.singleWeight
- ? (Number(item.singleWeight) * Number(sampleCount)).toFixed(2)
- : item.outboundNum
- ? (
- (Number(item.weight) / Number(item.outboundNum)) *
- Number(sampleCount)
- ).toFixed(2)
- : item.weight
- });
- currentNum1 -= 1;
- }
- }
- if (sampleCount > this.selectedList.length) {
- list.forEach((item) => {
- if (currentNum > 0) {
- let data = this.selectedList.find((val) => val.id == item.id);
- item['measureQuantity'] =
- data.measureQuantity - 1 - currentNum > 0
- ? currentNum + 1
- : data.measureQuantity;
- currentNum = currentNum - (data.measureQuantity - 1);
- }
- });
- }
- });
- // 更改 从新计算 样品清单 取整样 数据
- if (specifications && specifications.id) {
- // let proportion = (obj.weight / obj.measureQuantity).toFixed(2);
- console.log(specifications, 'specifications ===');
- list.map((el) => {
- el.measureQuantity =
- el.measureQuantity * specifications.packageCellTotal;
- el.weight = this.formatNumber(
- el.measureQuantity,
- el.weightProportion
- );
- });
- }
- await this.updatePackingList(list);
- },
- handDel(index) {
- console.log(index);
- this.schemeList.splice(index, 1);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .location-warp {
- display: flex;
- .detail {
- margin-left: 10px;
- }
- }
- :deep(.el-form-item__content .el-input-group__prepend) {
- background-color: #fff;
- }
- :deep(
- .el-dialog:not(.ele-dialog-form)
- .el-dialog__body
- .el-form
- .el-form-item:last-child
- ) {
- margin-bottom: 22px;
- }
- .add-product {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- font-size: 30px;
- color: #1890ff;
- margin: 10px 0;
- cursor: pointer;
- }
- .el-pagination {
- padding: 12px 16px;
- background: #fff;
- border: 1px solid#ebeef5;
- border-top: none;
- }
- .flex {
- display: flex;
- align-items: center;
- }
- </style>
|