| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005 |
- <template>
- <view class="">
- <u-sticky offset-top="50">
- <u-subsection fontSize='25' mode='subsection' :list="list" :current="curNow" @change="sectionChange"
- activeColor='#157A2C'></u-subsection>
- </u-sticky>
- <view v-show="curNow===0">
- <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
- <u-form-item label="收货单编码" prop="receiveNo" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.receiveNo"></u--input>
- </u-form-item>
- <u-form-item label="订单编码" prop="orderNo" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.orderNo"></u--input>
- </u-form-item>
- <u-form-item label="制单人" prop="makerName" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.makerName"></u--input>
- </u-form-item>
- <u-form-item label="供应商名称" prop="supplierName" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.supplierName"></u--input>
- </u-form-item>
- <u-form-item label="供应商联系人" prop="linkName" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.linkName"></u--input>
- </u-form-item>
- <u-form-item label="供应商电话" prop="linkPhone" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.linkPhone"></u--input>
- </u-form-item>
- <u-form-item label="车牌" prop="carNo" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.carNo"></u--input>
- </u-form-item>
- <u-form-item label="收货日期" prop="receiveDate" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.receiveDate"></u--input>
- </u-form-item>
- <u-form-item label="委外发货单编码" prop="outsourceSendCode" borderBottom>
- <u--input style="width: 100%;" disabled v-model="form.outsourceSendCode"></u--input>
- </u-form-item>
- <u-form-item label="附件" prop="receiveFiles" borderBottom>
- <fileMain v-model="form.receiveFiles" type="view"></fileMain>
- </u-form-item>
- </u--form>
- </view>
- <view v-show="curNow===1">
- <view v-for="(item,index) in form['productList']" :key="index">
- <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
- <u-row v-for="(key,index1) in tableField" :key="index1">
- <u-col :span="12">
- <u-form-item :label="key.label" prop="categoryName" borderBottom>
- <text>{{ key.formatter ? key.formatter(item) : (item[key.field] || '-') }}</text>
- </u-form-item>
- </u-col>
- </u-row>
- </u--form>
- <u-gap height="40" bgColor="#f0f0f0"></u-gap>
- </view>
- </view>
- <view v-show="curNow===2">
- <u--form style="margin: 0 20px;" labelPosition="left" :model="formData" ref="outForm" :rules="outRules" labelWidth='140rpx'>
- <u-form-item label="物品类型" prop="extInfo.assetType" borderBottom>
- <u--input style="width: 100%;" disabled v-model="formData.extInfo.assetTypeName"></u--input>
- </u-form-item>
- <u-form-item label="入库类型" prop="bizType" borderBottom>
- <u--input style="width: 100%;" disabled v-model="formData.bizTypeStr"></u--input>
- </u-form-item>
- <u-form-item label="单据来源" prop="sourceBizNo" borderBottom>
- <u--input style="width: 100%;" disabled v-model="formData.sourceBizNo"></u--input>
- </u-form-item>
- <u-form-item label="入库时间" prop="storageTime" borderBottom>
- <uni-datetime-picker type="datetime" v-model="formData.storageTime" />
- </u-form-item>
- <u-form-item label="入库登记人" prop="extInfo.createUserName" borderBottom>
- <u--input style="width: 100%;" disabled v-model="formData.extInfo.createUserName"></u--input>
- </u-form-item>
- <u-form-item label="审核人" prop="approvalUserName" borderBottom>
- <u--input disabled style="width: 100%;" v-model="formData.approvalUserName"></u--input>
- </u-form-item>
- <u-form-item label="备注" prop="remark" borderBottom>
- <u--input style="width: 100%;" v-model="formData.remark"></u--input>
- </u-form-item>
- </u--form>
- </view>
- <view class="tab-content" v-show="curNow===3">
- <!-- 批量操作按钮 -->
- <view class="batch-actions" v-if="productList.length > 0">
- <u-button type="success" plain size="small" text="批量保存" @click="listSaveArrs" :disabled="packingList.length > 0"></u-button>
- <picker v-if="packingList.length === 0" class="info-picker" :value="warehouseIndex" :range="warehouseListOption" range-key="name" @change="handleWareHouse">
- <u-button type="success" plain size="small" text="批量选择仓库" v-if="packingList.length === 0"></u-button>
- </picker>
- </view>
-
- <view v-if="productList.length === 0" class="empty-tip" style="text-align: center; color: #999; font-size: 28rpx; padding: 100rpx 0;">
- 暂无产品信息
- </view>
- <view v-else>
- <view class="product-card" v-for="(row, index) in productList" :key="index">
- <view class="card-header">
- <text class="product-name">{{ row.categoryName || '-' }}</text>
- <text class="product-code">{{ row.categoryCode || '-' }}</text>
- <!-- <text class="card-index">{{ index + 1 }}</text> -->
- </view>
- <view class="card-body">
- <!-- 批次号 - isSave为false时可编辑 -->
- <view class="info-row edit-row">
- <text class="info-label">批次号 <text class="required">*</text></text>
- <u--input v-if="!row.isSave" class="info-input" type="text" v-model="row.batchNo" placeholder="请输入批次号" />
- <text v-else class="info-value">{{ row.batchNo || '-' }}</text>
- </view>
- <!-- 数量 - isSave为false时可编辑 -->
- <view class="info-row edit-row">
- <text class="info-label">数量 <text class="required">*</text></text>
- <u--input v-if="!row.isSave" class="info-input" type="number" v-model="row.packingQuantity" placeholder="请输入数量" @input="computeNum(row, index, true)" />
- <text v-else class="info-value">{{ row.packingQuantity || '-' }}</text>
- </view>
- <!-- 单位选择 -->
- <view class="info-row edit-row">
- <text class="info-label">单位 <text class="required">*</text></text>
- <picker v-if="!row.isSave" class="info-picker" :value="row.packingUnitIndex" :range="row.packingSpecificationOption" range-key="conversionUnit" @change="(e) => onPackingUnitChange(e, row, index)">
- <view class="picker-value">{{ row.packingUnit || '请选择单位' }}</view>
- </picker>
- <text v-else class="info-value">{{ row.packingUnit || '-' }}</text>
- </view>
- <!-- 包装完好与否 -->
- <view class="info-row edit-row" v-if="isShowPackage">
- <text class="info-label">包装完好 <text class="required">*</text></text>
- <picker v-if="!row.isSave" class="info-picker" :value="row.ifPackageOkIndex" :range="packageOkOptions" range-key="label" @change="(e) => onPackageOkChange(e, index)">
- <view class="picker-value">{{ row.ifPackageOkLabel || '请选择' }}</view>
- </picker>
- <text v-else class="info-value">{{ row.ifPackageOk == 1 ? '是' : row.ifPackageOk == 0 ? '否' : '-' }}</text>
- </view>
- <!-- 拆包装责任人 -->
- <view class="info-row edit-row" v-if="isShowPackage">
- <text class="info-label">拆包责任人 <text class="required">*</text></text>
- <input v-if="!row.isSave" class="info-input" type="text" v-model="row.unpackUserName" placeholder="请选择" readonly @click="handHead(row, index)" />
- <text v-else class="info-value">{{ row.unpackUserName || '-' }}</text>
- </view>
- <!-- 只读字段 -->
- <view class="info-row">
- <text class="info-label">计量数量</text>
- <text class="info-value">{{ row.measureQuantity || '0' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">计量单位</text>
- <text class="info-value">{{ row.measureUnit || '-' }}</text>
- </view>
- <!-- 单重 -->
- <view class="info-row edit-row">
- <text class="info-label">单重</text>
- <u--input v-if="!row.isSave" class="info-input" type="digit" v-model="row.singleWeight" placeholder="请输入单重" :disabled="row.weightUnit == row.packingUnit" @input="inputsingleWeight(row, index)" />
- <text v-else class="info-value">{{ row.singleWeight || '0' }} {{ row.weightUnit || '' }}</text>
- </view>
- <!-- 总重 -->
- <view class="info-row edit-row">
- <text class="info-label">总重</text>
- <u--input v-if="!row.isSave" class="info-input" type="digit" v-model="row.weight" placeholder="请输入总重" :disabled="row.weightUnit == row.packingUnit" @input="inputWeight(row, index)" />
- <text v-else class="info-value">{{ row.weight || '0' }} {{ row.weightUnit || '' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">重量单位</text>
- <text class="info-value">{{ row.weightUnit || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">生产要求</text>
- <text class="info-value">{{ row.productionRequirements || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">包装规格</text>
- <text class="info-value">{{ row.packingSpecificationLabel ? row.packingSpecificationLabel.join(', ') : '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">允许拆包</text>
- <text class="info-value">{{ row.isUnpack == 1 ? '是' : '否' }}</text>
- </view>
- <!-- 仓库 - 必填 -->
- <view class="info-row edit-row">
- <text class="info-label">仓库 <text class="required">*</text></text>
- <picker v-if="!row.isSave" class="info-picker" :value="row.warehouseIndex" :range="warehouseListOption" range-key="name" @change="(e) => onWarehouseChange(e, index)">
- <view class="picker-value">{{ row.warehouseName || '请选择仓库' }}</view>
- </picker>
- <text v-else class="info-value" :class="{ 'red-text': !row.warehouseName }">{{ row.warehouseName || '请选择仓库' }}</text>
- </view>
- <!-- 供应商 -->
- <view class="info-row edit-row">
- <text class="info-label">供应商</text>
- <picker v-if="!row.isSave" class="info-picker" :value="row.supplierIndex" :range="row.supplierListOptions" range-key="name" @change="(e) => onSupplierChange(e, index)">
- <view class="picker-value">{{ row.supplierName || '请选择供应商' }}</view>
- </picker>
- <text v-else class="info-value">{{ row.supplierName || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">供应商代号</text>
- <text class="info-value">{{ row.supplierCode || '-' }}</text>
- </view>
- <!-- 采购原因 -->
- <view class="info-row edit-row">
- <text class="info-label">采购原因</text>
- <u--input v-if="!row.isSave" class="info-input" type="text" v-model="row.purpose" placeholder="请输入采购原因" />
- <text v-else class="info-value">{{ row.purpose || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">是否质检</text>
- <text class="info-value">{{ row.qualityControl == 1 ? '是' : '否' }}</text>
- </view>
- <!-- 生产日期 -->
- <view class="info-row edit-row">
- <text class="info-label">生产日期</text>
- <!-- <picker v-if="!row.isSave" class="info-picker" mode="date" :value="row.detailProductionDate" @change="(e) => onDateChange(e, row, 'detailProductionDate')">
- <view class="picker-value" :class="{ 'placeholder': !row.detailProductionDate }">{{ row.detailProductionDate || '请选择日期' }}</view>
- </picker> -->
- <uni-datetime-picker v-if="!row.isSave" type="datetime" v-model="row.detailProductionDate" />
- <text v-else class="info-value">{{ row.detailProductionDate || '-' }}</text>
- </view>
- <!-- 采购日期 -->
- <view class="info-row edit-row">
- <text class="info-label">采购日期</text>
- <!-- <picker v-if="!row.isSave" class="info-picker" mode="date" :value="row.detailPurchaseDate" @change="(e) => onDateChange(e, row, 'detailPurchaseDate')">
- <view class="picker-value" :class="{ 'placeholder': !row.detailPurchaseDate }">{{ row.detailPurchaseDate || '请选择日期' }}</view>
- </picker> -->
- <uni-datetime-picker v-if="!row.isSave" type="datetime" v-model="row.detailPurchaseDate" />
- <text v-else class="info-value">{{ row.detailPurchaseDate || '-' }}</text>
- </view>
- <!-- 失效日期 -->
- <view class="info-row edit-row">
- <text class="info-label">失效日期</text>
- <!-- <picker v-if="!row.isSave" class="info-picker" mode="date" :value="row.detailExpireDate" @change="(e) => onDateChange(e, row, 'detailExpireDate')">
- <view class="picker-value" :class="{ 'placeholder': !row.detailExpireDate }">{{ row.detailExpireDate || '请选择日期' }}</view>
- </picker> -->
- <uni-datetime-picker v-if="!row.isSave" type="datetime" v-model="row.detailExpireDate" />
- <text v-else class="info-value">{{ row.detailExpireDate || '-' }}</text>
- </view>
- <!-- 机型 - 单选 -->
- <view class="info-row edit-row">
- <text class="info-label">机型</text>
- <picker v-if="!row.isSave" class="info-picker" mode="selector" :value="row.modelIndex" :range="modelOptions" range-key="dictValue" @change="(e) => onModelChange(e, index)">
- <view class="picker-value">{{ row.modelKeyName || '请选择机型' }}</view>
- </picker>
- <text v-else class="info-value">{{ row.modelKeyName || '-' }}</text>
- </view>
- <!-- 颜色 - 单选 -->
- <view class="info-row edit-row">
- <text class="info-label">颜色</text>
- <picker v-if="!row.isSave" class="info-picker" mode="selector" :value="row.colorIndex" :range="colorOptions" range-key="dictValue" @change="(e) => onColorChange(e, index)">
- <view class="picker-value">{{ row.colorKeyName || '请选择颜色' }}</view>
- </picker>
- <text v-else class="info-value">{{ row.colorKeyName || '-' }}</text>
- </view>
- </view>
- <view class="card-footer">
- <view class="action-buttons">
- <u-button v-if="!row.isSave" type="primary" size="small" text="保存" @click="listSave(row, index)"></u-button>
- <u-button v-else type="primary" size="small" text="编辑" @click="editProductList(row, index)"></u-button>
- <u-button type="error" size="small" text="删除" @click="listDel(row, index)"></u-button>
- </view>
- </view>
- </view>
- </view>
-
- <view class="add" @click="addProduct">
- <u-icon name="plus" color="#fff"></u-icon>
- </view>
- </view>
- <view class="tab-content" v-show="curNow===4">
- <!-- 包装明细 -->
- <view v-if="showPackingList.length > 0" class="packing-section">
- <view class="packing-card" v-for="(item, idx) in showPackingList" :key="'pkg-' + idx">
- <!-- <view class="card_title">包装 {{ idx + 1 }}</view> -->
- <view class="info-row">
- <text class="info-label">编码</text>
- <text class="info-value">{{ item.categoryCode || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">名称</text>
- <text class="info-value">{{ item.categoryName || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">批次号</text>
- <text class="info-value">{{ item.batchNo || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">包装编码</text>
- <text class="info-value">{{ item.packageNo || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">包装数量</text>
- <text class="info-value">{{ formatPackingValue(item.packingQuantity, item.packingUnit) }}</text>
- </view>
- <view class="info-row edit-row">
- <text class="info-label">计量数量</text>
- <u--input class="info-input" type="digit" v-model="item.measureQuantity" placeholder="请输入计量数量" />
- </view>
- <view class="info-row">
- <text class="info-label">计量单位</text>
- <text class="info-value">{{ item.measureUnit || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">仓库</text>
- <text class="info-value">{{ item.warehouseName || '-' }}</text>
- </view>
- <view class="info-row edit-row">
- <text class="info-label">物料代号</text>
- <u--input class="info-input" type="text" v-model="item.materielDesignation" placeholder="请输入物料代号" />
- </view>
- <view class="info-row edit-row">
- <text class="info-label">客户代号</text>
- <u--input class="info-input" type="text" v-model="item.clientCode" placeholder="请输入客户代号" />
- </view>
- <view class="info-row">
- <text class="info-label">牌号</text>
- <text class="info-value">{{ item.brandNum || '-' }}</text>
- </view>
- <!-- 机型 - 单选 -->
- <view class="info-row edit-row">
- <text class="info-label">机型</text>
- <picker class="info-picker" mode="selector" :value="item.modelIndex" :range="modelOptions" range-key="dictValue" @change="(e) => onPackingModelChange(e, item)">
- <view class="picker-value">{{ item.modelKeyName || '请选择机型' }}</view>
- </picker>
- </view>
- <!-- 颜色 - 单选 -->
- <view class="info-row edit-row">
- <text class="info-label">颜色</text>
- <picker class="info-picker" mode="selector" :value="item.colorIndex" :range="colorOptions" range-key="dictValue" @change="(e) => onPackingColorChange(e, item)">
- <view class="picker-value">{{ item.colorKeyName || '请选择颜色' }}</view>
- </picker>
- </view>
- <view class="info-row edit-row">
- <text class="info-label">发货条码</text>
- <text class="info-value">{{ item.barcodes || '-' }}</text>
- </view>
- <view class="info-row edit-row">
- <text class="info-label">刻码</text>
- <u--input class="info-input" type="text" v-model="item.engrave" placeholder="请输入刻码" />
- </view>
- <view class="info-row edit-row">
- <text class="info-label">重量</text>
- <u--input class="info-input" type="digit" v-model="item.weight" placeholder="请输入重量" />
- <text class="info-unit">{{ item.weightUnit || '' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">供应商</text>
- <text class="info-value">{{ item.supplierName || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">供应商代号</text>
- <text class="info-value">{{ item.supplierCode || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">序列号</text>
- <text class="info-value">{{ item.serialNo || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">是否质检</text>
- <text class="info-value">{{ item.qualityControl == 1 ? '是' : '否' }}</text>
- </view>
- <view class="info-row">
- <text class="info-label">质检状态</text>
- <text class="info-value">{{ qualityStatus[item.status] || '-' }}</text>
- </view>
- <!-- 质检结果 - 单选 -->
- <view class="info-row edit-row">
- <text class="info-label">质检结果</text>
- <picker class="info-picker" mode="selector" :value="getResultIndex(item.result)" :range="qualityResultsOptions" range-key="label" @change="(e) => onPackingResultChange(e, item)">
- <view class="picker-value">{{ qualityResults[item.result] || '请选择' }}</view>
- </picker>
- </view>
- <!-- 生产日期 -->
- <view class="info-row edit-row">
- <text class="info-label">生产日期</text>
- <uni-datetime-picker type="date" v-model="item.productionDate" />
- </view>
- <!-- 采购日期 -->
- <view class="info-row edit-row">
- <text class="info-label">采购日期</text>
- <uni-datetime-picker type="date" v-model="item.purchaseDate" />
- </view>
- <!-- 失效日期 -->
- <view class="info-row edit-row">
- <text class="info-label">失效日期</text>
- <uni-datetime-picker type="date" v-model="item.expireDate" />
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- purchaseOrderReceiveGetByIdAPI
- } from '@/api/wt/index.js'
- import { sceneState } from '@/enum/dict.js'
- import fileMain from "@/pages/doc/index.vue"
- import { parameterGetByCode } from '@/api/mainData/index.js'
- import { getListByNameOrModeType, getCode, contactQueryByCategoryIdsAPI, getCategoryPackageDisposition, getProduceTreeByPid, warehouseDefinitionList, getAssetNum, getWarehouseList, isVerifyRepeatIsStock } from '@/api/warehouseManagement/index.js'
- import { mapGetters, mapActions } from 'vuex'
- import { unary } from 'lodash'
- // 质检结果映射
- const qualityResults = {
- 1: '合格',
- 2: '不合格',
- };
- // 质检状态映射
- const qualityStatus = {
- 0: '未质检',
- 1: '待检',
- 2: '已质检',
- };
- // 质检结果 picker 选项
- const qualityResultsOptions = [
- { value: 1, label: '合格' },
- { value: 2, label: '不合格' },
- ];
- export default {
- components: {
- fileMain
- },
- props: {
- businessId: {
- default: ''
- },
- taskDefinitionKey: {
- default: ''
- },
- },
- computed: {
- ...mapGetters(['dict', 'getDict', 'getDictValue']),
- // 颜色选项(数组)
- colorOptions() {
- return this.dict?.product_color_key || []
- },
- // 机型选项(数组)
- modelOptions() {
- return this.dict?.product_model_key || []
- },
- list() {
- return this.showPackingList.length > 0 ? ['收货信息', '物品清单', '入库信息', '产品信息', '包装明细'] : ['收货信息', '物品清单', '入库信息', '产品信息']
- },
- tableField() {
- const priceField = [
- { label: '单价', field: 'singlePrice' },
- { label: '不含税单价', field: 'notaxSinglePrice' },
- { label: '折后单价', field: 'discountSinglePrice' },
- { label: '合计', field: 'totalPrice' },
- { label: '折后合计', field: 'discountTotalPrice' },
- ]
- const baseField = [
- { label: '名称', field: 'productName' },
- { label: '编码', field: 'productCode' },
- { label: '类型', field: 'productCategoryName' },
- { label: '批次号', field: 'batchNo' },
- { label: '规格', field: 'specification' },
- { label: '型号', field: 'modelType' },
- { label: '包装规格', field: 'packingSpecification' },
- { label: '供应商代号', field: 'supplierMark' },
- { label: '仓库名称', field: 'warehouseName' },
- { label: '收货数量', field: 'purchaseCount', formatter: (row) => (row.purchaseCount || '-') + row.purchaseUnit },
- { label: '单重', field: 'singleWeight', formatter: (row) => row.singleWeight ? row.singleWeight + ' ' + row.weightUnit : '-' },
- { label: '发货总重', field: 'sendTotalWeight', formatter: (row) => row.sendTotalWeight ? row.sendTotalWeight + ' ' + row.weightUnit : '-' },
- { label: '收货总重', field: 'receiveTotalWeight', formatter: (row) => row.receiveTotalWeight ? row.receiveTotalWeight + ' ' + row.weightUnit : '-' },
- { label: '增重重量', field: 'increaseTotalWeight', formatter: (row) => row.increaseTotalWeight ? row.increaseTotalWeight + ' ' + row.weightUnit : '-' },
- { label: '计量数量', field: 'totalCount', formatter: (row) => (row.totalCount || '-') + row.measuringUnit },
- { label: '是否来料检验', field: 'isComeCheck', formatter: (row) => row.isComeCheck == 1 ? '是' : '否' },
- ]
- return this.taskDefinitionKey == 'storeManagerApprove' && this.isHidePrice == 0 ? baseField : [...baseField, ...priceField]
- },
- tableField2() {
- return [
- { label: '名称', field: 'categoryName' },
- { label: '编码', field: 'categoryCode' },
- { label: '型号', field: 'categoryModel' },
- { label: '规格', field: 'specification' },
- { label: '牌号', field: 'brandNum' },
- { label: '批次号', field: 'batchNo' },
- { label: '数量', field: 'packingQuantity' },
- { label: '单位', field: 'packingUnit' },
- { label: '单重', field: 'singleWeight' },
- { label: '总重', field: 'weight' },
- { label: '重量单位', field: 'weightUnit' },
- { label: '供应商', field: 'supplierId' },
- { label: '仓库', field: 'warehouseName' },
- { label: '颜色', field: 'colorKey' },
- { label: '机型', field: 'modelKey' },
- { label: '采购原因', field: 'purpose' },
- { label: '生产日期', field: 'detailProductionDate' },
- { label: '采购日期', field: 'detailPurchaseDate' },
- { label: '失效日期', field: 'detailExpireDate' },
- { label: '是否质检', field: 'qualityControl' },
- { label: '包装规格', field: 'packingSpecificationLabel' },
- { label: '允许拆包', field: 'isUnpack' },
- { label: '计量数量', field: 'measureQuantity' },
- { label: '计量单位', field: 'measureUnit' },
- { label: '生产要求', field: 'weightUnit' },
- { label: '供应商名称', field: 'supplierName' },
- { label: '供应商代号', field: 'supplierCode' },
- { label: '产地', field: 'supplierCode' },
- ]
- }
- },
- data() {
- return {
- form: {},
- userInfo: {},
- formData: {
- bizType: '',
- bizTypeStr: '',
- storageTime: '',
- qualityControl: '',
- extInfo: {
- assetType: [],
- assetTypeName: ''
- }
- },
- isHidePrice: 0,
- warehouseIndex: 0,
- curNow: 0,
- packingSpecificationOption: [],
- productList: [],
- packingList: [],
- showPackingList: [],
- goodsLists: [],
- outRules: {},
- sceneState,
- qualityResultsOptions,
- qualityStatus,
- qualityResults,
- isWrapTable: true,
- pageSize: 20,
- pickingPageNum: 1,
- visibleDialog: false,
- title: '选择产品',
- loadTree: true,
- isShowPackage: false,
- packageOkOptions: [
- { label: '是', value: 1 },
- { label: '否', value: 0 }
- ],
- }
- },
- beforeDestroy() {
- uni.$off('setSelectList')
- },
- created() {
- uni.$on('setSelectList', async data => {
- // uni.removeStorageSync('productList')
- console.log('setSelectList~~~', data)
- if (data?.length) {
- // 获取批次号
- const batchNo = await getCode('lot_number_code');
- // 获取供应商
- const supplierList = await contactQueryByCategoryIdsAPI({
- categoryIds: data.map((item) => item.id)
- });
- // 获取包装规格
- let packingSpecification = await getCategoryPackageDisposition({
- categoryIds: data.map((item) => item.id)
- });
- this.packingSpecificationOption = data.map((item) => {
- return packingSpecification
- .filter((ite) => item.id == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- });
- const newSpecificationOption = this.packingSpecificationOption;
- let productList = data.map((item, index) => {
- // 显示规格
- let packingSpecificationLabel = this.packingSpecificationOption[index].map((item) => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
- }
- }).filter((item) => !!item);
- return {
- index:
- this.productList.length - 1 > -1
- ? this.productList[this.productList.length - 1].index + index + 1 : this.productList.length + index,
- categoryId: item.id, // 物品id
- categoryName: item.name, // 物品名称
- categoryCode: item.code, // 物品编码
- categoryModel: item.modelType, // 物品型号
- specification: item.specification, // 规格
- modelKey: item.modelKey ? item.modelKey : '', // 机型
- modelKeyName: item.modelKey ? (this.modelOptions.find(o => o.dictCode === item.modelKey)?.dictValue || '') : '',
- modelIndex: item.modelKey ? this.modelOptions.findIndex(o => o.dictCode === item.modelKey) : -1,
- colorKey: item.colorKey ? item.colorKey : '', // 颜色
- colorKeyName: item.colorKey ? (this.colorOptions.find(o => o.dictCode === item.colorKey)?.dictValue || '') : '',
- colorIndex: item.colorKey ? this.colorOptions.findIndex(o => o.dictCode === item.colorKey) : -1,
- brandNum: item.brandNum, // 牌号
- batchNo: batchNo, // 批次号
- supplierListOptions: supplierList[item.id], // 供应商列表
- supplierId: '', // 供应商id
- supplierIndex: -1, // 供应商索引
- supplierCode: item.supplierCode, // 供应商代号
- supplierName: item.supplierName, // 供应商名称
- measureType: item.measureType, // 计量类型
- approvalNumber: item.approvalNumber, // 批准文号
- packingSpecification: item.packingSpecification, // 包装规格
- packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- minPackingQuantity: '', // 最小包装单元数量
- packingQuantity: '', // 包装数量
- packingUnit: item.measuringUnit, // 单位
- packingUnitId: newSpecificationOption[index].find(
- (v) => v.conversionUnit == item.measuringUnit
- )?.id, // 单位
- measureQuantity: 0, // 计量数量
- measureUnit: item.measuringUnit, // 计量单位
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- weight: 0, // 重量
- singleWeight: item.measuringUnit != 'KG' ? item.netWeight : 0, // 单重
- pricingWay: item.pricingWay,
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: item.totalPrice, // 总价
- unitPrice: item.unitPrice, // 单价
- purpose: '', // 用途
- isUnpack: item.isUnpack, // 是否允许拆包
- warehouseIndex: -1, // 仓库索引
- packingUnitIndex: newSpecificationOption[index]?.findIndex(v => v.conversionUnit == item.measuringUnit) ?? -1, // 单位索引
- isSave: false, // 是否已保存
- ifPackageOk: '', // 包装完好
- ifPackageOkIndex: -1, // 包装完好索引
- ifPackageOkLabel: '' // 包装完好标签
- };
- });
- this.productList = this.productList.concat(productList);
- }
- })
- },
- async mounted() {
- this.userInfo = uni.getStorageSync('userInfo')
- await this.requestDict('产地')
- await this.requestDict('不拆物料层规格')
- await this.requestDict('物品颜色')
- await this.requestDict('物品机型')
- await this.getListItems()
- await this.getwarehouseList()
- await parameterGetByCode({ code: 'eom_purchase_invoice_approval_price' }).then((res) => {
- this.isHidePrice = res.value;
- });
- await this.getDetailData(this.businessId);
- await this.getNowFormatDate();
- },
- watch: {
- packingList: {
- handler(newVal) {
- console.log('packingList~~', newVal)
- this.showPackingList = newVal.slice(0, this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1));
- this.pickingPageNum = Math.ceil(this.showPackingList.length / this.pageSize);
- },
- deep: true
- }
- },
- methods: {
- ...mapActions('dict', ['requestDict']),
- // 获取当前时间 YYYY-MM-DD HH:mm:ss
- getCurrentTime() {
- const now = new Date();
- const year = now.getFullYear();
- const month = String(now.getMonth() + 1).padStart(2, '0');
- const day = String(now.getDate()).padStart(2, '0');
- const hours = String(now.getHours()).padStart(2, '0');
- const minutes = String(now.getMinutes()).padStart(2, '0');
- const seconds = String(now.getSeconds()).padStart(2, '0');
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
- },
- //获取仓库
- async getwarehouseList() {
- let res = await getWarehouseList()
- this.warehouseListOption = res.data.map(item => {
- return {
- id: item.id,
- name: item.name
- }
- })
- },
- handleWareHouse(e) {
- const val = Number(e.detail.value);
- this.warehouseIndex = val;
- const warehouseItem = this.warehouseListOption[val];
- if (warehouseItem) {
- this.productList.forEach((item, index) => {
- this.$set(this.productList[index], 'warehouseId', warehouseItem.id);
- this.$set(this.productList[index], 'warehouseName', warehouseItem.name);
- this.$set(this.productList[index], 'warehouseIds', [warehouseItem.id]);
- this.$set(this.productList[index], 'warehouseNames', [warehouseItem.name]);
- this.$set(this.productList[index], 'warehouseIndex', val);
- });
- }
- },
- // 获取物品列表
- async getListItems() {
- const res = await getProduceTreeByPid({});
- this.goodsLists = res;
- },
- sectionChange(index) {
- this.curNow = index;
- },
- async getDetailData(id) {
- const data = await purchaseOrderReceiveGetByIdAPI(id);
- this.form = data;
- this.initFormData()
- },
- initFormData() {
- const defaultTime = '00:00:00';
- this.formData.type = 1;
- this.formData.bizType = this.form.outsourceSendCode ? 10 : 2;
- const currentTime = this.getCurrentTime();
- if (this.formData.bizType == 2 || this.formData.bizType == 6) {
- this.formData.storageTime = this.form.receiveDate
- ? `${this.form.receiveDate} ${defaultTime}`
- : currentTime;
- } else {
- this.formData.storageTime = currentTime;
- }
- this.formData.bizTypeStr = sceneState.find(item => item.code == this.formData.bizType)?.label || ''
- if (this.form.receiveNo != null && this.form.receiveNo != '') {
- this.$set(this.formData, 'sourceBizNo', this.form.receiveNo);
- } else {
- uni.showToast({ title: '未获取到单据来源!', icon: 'none' });
- }
- this.formData.extInfo.createUserId = this.form.createUserId || this.userInfo.userId || '';
- this.formData.extInfo.createUserName = this.form.createUserName || this.userInfo.name || '';
- this.formData.extInfo.deliveryPhone = this.userInfo.phone || '';
- this.formData.createUserId = this.form.createUserId || this.userInfo.userId || '';
- this.formData.createUserName = this.form.createUserName || this.userInfo.name || '';
- this.formData.extInfo.deptName = this.form.deptName || this.userInfo.deptName || '';
- this.formData.approvalUserName = this.form.approvalUserName || this.userInfo.name;
- this.formData.approvalUserId = this.form.approvalUserId || this.userInfo.userId;
- if (this.form.productList?.length > 0) {
- let detailPurchaseDate;
- if (this.formData.bizType == '2' || this.formData.bizType == '10') {
- detailPurchaseDate = this.form.purchaseDate || `${this.form.receiveDate} ${defaultTime}`;
- }
- let codeList = this.form.productList.map((item) => item.productCode || item.categoryCode);
- getListByNameOrModeType({ codeList }).then(async (res) => {
- if (res.length <= 0) {
- uni.showToast({ title: '未获取到物品信息!', icon: 'none' });
- return;
- }
- this.formData.extInfo.assetType = Array.from(new Set(res.map((item) => item.categoryLevelPathIdParent)));
- this.formData.extInfo.assetTypeName = this.formData.extInfo.assetType.map(id => {
- const item = this.goodsLists.find(g => g.id == id);
- return item?.name || id;
- }).join(',');
- const batchNo1 = await getCode('lot_number_code');
- const supplierList = await contactQueryByCategoryIdsAPI({ categoryIds: res.map((item) => item.id) });
- let packingSpecification = await getCategoryPackageDisposition({ categoryIds: res.map((item) => item.id) });
- // 构建包装规格数组(按 res 顺序)和查找表(按 categoryId)
- this.packingSpecificationOption = res.map((item) => {
- return packingSpecification.filter((ite) => item.id == ite.categoryId).sort((a, b) => a.sort - b.sort);
- });
- const packingSpecMap = {};
- res.forEach((item, idx) => {
- packingSpecMap[item.id] = this.packingSpecificationOption[idx];
- });
- // 以 form.productList 为主循环,通过 res 适配补充品类字段
- this.productList = this.form.productList.map((formItem, index) => {
- let categoryItem = res.find(
- (r) => r.code === (formItem.productCode || formItem.categoryCode)
- );
- if (!categoryItem) return null;
- let filtersItem = formItem;
- const categorySpecs = packingSpecMap[categoryItem.id] || [];
- let packingSpecificationLabel = categorySpecs.map((item) => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
- }
- }).filter((item) => !!item);
- let warehouseId = filtersItem.warehouseId;
- let warehouseName = filtersItem.warehouseName;
- let measureQuantity = filtersItem.totalCountNew || filtersItem.totalCount || 0;
- if ((filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight) && categoryItem.weightUnit == categoryItem.measuringUnit) {
- measureQuantity = filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight;
- }
- let packingQuantity = filtersItem.totalCountNew || filtersItem.purchaseCount || filtersItem.totalCount || 0;
- let packingUnit = filtersItem.purchaseUnit || filtersItem.measuringUnit || '';
- let unitPrice = filtersItem.singlePrice || 0;
- let pricingWay = filtersItem.pricingWay || '';
- let singleWeight = filtersItem.singleWeight || 0;
- let weight = filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight || singleWeight * measureQuantity;
- let warehouseIds = [];
- let warehouseNames = [];
- for (let i = 0; i < filtersItem.totalCount; i++) {
- warehouseIds.push(filtersItem.warehouseId);
- warehouseNames.push(filtersItem.warehouseName);
- }
- let totalMoney = filtersItem.totalPrice || 0;
- let batchNo = filtersItem.batchNo || batchNo1;
- return {
- index: this.productList.length + index,
- categoryId: categoryItem.id,
- categoryName: categoryItem.name,
- categoryCode: categoryItem.code,
- categoryModel: categoryItem.modelType,
- specification: categoryItem.specification,
- brandNum: categoryItem.brandNum,
- batchNo: batchNo,
- supplierListOptions: supplierList[categoryItem.id],
- supplierId: this.form.supplierId,
- supplierIndex: this.form.supplierId ? (supplierList[categoryItem.id]?.findIndex(s => s.id == this.form.supplierId) ?? -1) : -1,
- productionRequirements: filtersItem.productionRequirements,
- supplierCode: this.formData.bizType == 2 || this.formData.bizType == 7 ? filtersItem.supplierMark : categoryItem.supplierCode,
- supplierName: this.form.supplierName,
- approvalNumber: categoryItem.approvalNumber,
- packingSpecification: categoryItem.packingSpecification,
- packingSpecificationOption: categorySpecs,
- packingSpecificationLabel: packingSpecificationLabel,
- packingQuantity: filtersItem?.isAllPackageData == 1
- ? filtersItem.packingCount : packingQuantity,
- packingUnit: filtersItem?.isAllPackageData == 1
- ? filtersItem.packingUnit : packingUnit,
- measureQuantity: filtersItem?.isAllPackageData == 1
- ? filtersItem.quantity : measureQuantity,
- measureUnit: filtersItem?.isAllPackageData == 1
- ? filtersItem.measuringUnit : categoryItem.measuringUnit,
- packingUnitId: filtersItem.purchaseUnitId || filtersItem.saleUnitId,
- modelKey: filtersItem.modelKey ? filtersItem.modelKey : '',
- modelKeyName: filtersItem.modelKey ? (this.modelOptions.find(o => o.dictCode === filtersItem.modelKey)?.dictValue || '') : '',
- modelIndex: filtersItem.modelKey ? this.modelOptions.findIndex(o => o.dictCode === filtersItem.modelKey) : -1,
- colorKey: filtersItem.colorKey ? filtersItem.colorKey : '',
- colorKeyName: filtersItem.colorKey ? (this.colorOptions.find(o => o.dictCode === filtersItem.colorKey)?.dictValue || '') : '',
- colorIndex: filtersItem.colorKey ? this.colorOptions.findIndex(o => o.dictCode === filtersItem.colorKey) : -1,
- measureType: categoryItem.measureType,
- netWeight: categoryItem.netWeight > -1 ? categoryItem.netWeight : 0,
- singleWeight: singleWeight || 0,
- weight: weight || 0,
- weightUnit: categoryItem.weightUnit,
- totalMoney: totalMoney,
- unitPrice: categoryItem.unitPrice || unitPrice,
- pricingWay: pricingWay,
- purpose: '',
- detailPurchaseDate,
- detailExpireDate: filtersItem?.guaranteePeriodDeadline,
- detailProductionDate: filtersItem?.productionDate,
- provenance: filtersItem.provenance,
- isUnpack: categoryItem.isUnpack,
- warehouseId,
- warehouseName,
- warehouseIds,
- warehouseNames,
- warehouseIndex: this.warehouseListOption?.findIndex(w => w.id == warehouseId) ?? -1,
- packingUnitIndex: categorySpecs?.findIndex(v => v.id == (filtersItem.purchaseUnitId || filtersItem.saleUnitId)) ?? -1,
- isSave: false,
- ifPackageOk: '',
- ifPackageOkIndex: -1,
- ifPackageOkLabel: '',
- qualityControl: filtersItem?.isComeCheck
- };
- }).filter(Boolean);
-
- this.$nextTick(() => {
- this.batchSave();
- });
- });
- }
- },
- // 赋值入库时间
- getNowFormatDate() {
- const obj = this.getNowDate();
- const defaultTime = '00:00:00';
- const currentTime = `${obj.hour}:${obj.minute}:${obj.second}`;
- if (this.formData.bizType === 2 || this.formData.bizType === '2' || this.formData.bizType === 6 || this.formData.bizType === '6') {
- this.formData.storageTime = this.form.receiveDate
- ? `${this.form.receiveDate} ${defaultTime}`
- : `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
- } else {
- this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
- }
- },
- // 获取当前时间函数
- getNowDate() {
- let date = new Date(),
- obj = {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- strDate: date.getDate(),
- hour: date.getHours(),
- minute: date.getMinutes(),
- second: date.getSeconds()
- };
- Object.keys(obj).forEach((key) => {
- if (obj[key] < 10) obj[key] = `0${obj[key]}`;
- });
- return obj;
- },
- changeCount(number) {
- // 移动端兼容的数字转字符串方法,避免浮点数精度显示问题
- const num = Number(number || 0);
- return isNaN(num) ? '0' : String(num);
- },
- // 格式化包装数量/计量数量/重量(带单位)
- formatPackingValue(value, unit) {
- if (value === null || value === undefined || value === '') return '-';
- return this.changeCount(value) + ' ' + (unit || '');
- },
- selectSupplier(val, row) {
- row.supplierId = val;
- row.supplierName = row.supplierListOptions.filter((item) => item.id == val)[0]?.name;
- row.supplierCode = row.supplierListOptions.filter((item) => item.id == val)[0]?.serialNo;
- },
- inputsingleWeight(row, index) {
- if (row.measureUnit == row.weightUnit) {
- this.$set(this.productList[index], 'weight', row.singleWeight * row.packingQuantity);
- this.$set(this.productList[index], 'measureQuantity', row.weight);
- } else {
- this.$set(this.productList[index], 'weight', row.singleWeight * row.measureQuantity);
- }
- },
- inputWeight(row, index) {
- if (row.measureUnit == row.weightUnit) {
- this.$set(this.productList[index], 'measureQuantity', row.weight);
- this.$set(this.productList[index], 'singleWeight', Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) / 10000);
- } else {
- this.$set(this.productList[index], 'singleWeight', row.measureQuantity ? row.weight / row.measureQuantity : 0);
- }
- },
- // 计算最小单元数量
- async computeNum(row, index, isClear) {
- let data = row.packingSpecificationOption.find((item) => item.id == row.packingUnitId);
- if (data) {
- this.$set(this.productList[index], 'packingUnit', data.conversionUnit);
- }
- if (isClear && row.packingQuantity < 0) {
- this.$set(this.productList[index], 'packingQuantity', 1);
- }
- if (row.packingQuantity && row.packingUnit) {
- const res = await warehouseDefinitionList({});
- if (res.length == 1) {
- let name = res[0]?.factoryName + '-' + res[0]?.name;
- this.$set(this.productList[index], 'warehouseId', res[0].id);
- this.$set(this.productList[index], 'warehouseName', name);
- this.$set(this.productList[index], 'warehouseIndex', this.warehouseListOption?.findIndex(w => w.id == res[0].id) ?? -1);
- } else {
- this.$set(this.productList[index], 'warehouseId', '');
- this.$set(this.productList[index], 'warehouseName', '');
- }
- let endIndex = row.packingSpecificationOption.findIndex((ite) => data.id == ite.id);
- let total = Number(row.packingQuantity);
- if (row.packingUnit == row.measureUnit && row.measureUnit == '立方' && row.netWeight) {
- total = Number(row.packingQuantity) * row.netWeight;
- } else {
- for (; 0 < endIndex; endIndex--) {
- total = row.packingSpecificationOption[endIndex].packageCell * total;
- }
- }
- this.$set(this.productList[index], 'measureQuantity', this.changeCount(total));
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)?.dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)?.dictValue;
- if (packingBoolen && measureBoolen && row.packingUnit != 'L') {
- this.$set(this.productList[index], 'weight', total);
- }
- let weight = 0;
- if (row.measureUnit == row.weightUnit) {
- weight = row.measureQuantity;
- if (row.weightUnit == row.packageUnit) {
- this.$set(this.productList[index], 'singleWeight', 0);
- } else {
- this.$set(this.productList[index], 'singleWeight', Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) / 10000);
- }
- } else if (row.singleWeight) {
- weight = row.measureQuantity * Number(row.singleWeight);
- }
- this.$set(this.productList[index], 'weight', weight);
- }
- },
- // 添加产品
- addProduct() {
- if (this.formData.extInfo.assetType.length <= 0) {
- return uni.showToast({ title: '请选择物品类型', icon: 'none' });
- }
- if (!this.formData.bizType) {
- return uni.showToast({ title: '请选择入库类型', icon: 'none' });
- }
- this.visibleDialog = true;
- uni.navigateTo({
- url: '/pages/warehouse/enterHouse/selectEnterType?assetType=' + this.formData.extInfo.assetType
- })
- },
- // 批量保存
- async batchSave() {
- try {
- for (let i = 0; i < this.productList.length; i++) {
- const row = this.productList[i];
- if (!row.isSave) {
- await this.listSave(row, i);
- }
- }
- } catch (error) {
- console.log('保存失败', error);
- }
- },
- // 单行校验
- validateSingleRow(row, rowNum) {
- if (!row.batchNo) {
- uni.showToast({ title: rowNum !== undefined ? `第${rowNum}行:请填写批次号` : '请填写批次号', icon: 'none' });
- return false;
- }
- if (!row.packingQuantity && row.packingQuantity !== 0) {
- uni.showToast({ title: rowNum !== undefined ? `第${rowNum}行:请填写数量` : '请填写数量', icon: 'none' });
- return false;
- }
- if (!row.packingUnit) {
- uni.showToast({ title: rowNum !== undefined ? `第${rowNum}行:请选择单位` : '请选择单位', icon: 'none' });
- return false;
- }
- if (!row.warehouseId) {
- uni.showToast({ title: rowNum !== undefined ? `第${rowNum}行:请选择仓库` : '请选择仓库', icon: 'none' });
- return false;
- }
- return true;
- },
- // 计算包装参数(提取重复的 packingBoolen/measureBoolen/num 逻辑)
- computePackagingParams(row) {
- const packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)?.dictValue;
- const measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)?.dictValue;
- let num = row.packingQuantity;
- // 处理单位为KG类的情况
- if (packingBoolen) {
- const filterArr = row.packingSpecificationOption?.filter((item) => {
- return item.packageUnit == row.packingUnit && item.packageUnit != item.conversionUnit;
- });
- if (filterArr?.length) {
- num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
- }
- } else if (measureBoolen) {
- // 处理单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption?.findIndex((item) =>
- item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- num = num * row.packingSpecificationOption[splitIndex].packageCell;
- }
- }
- return { packingBoolen, measureBoolen, num };
- },
- // 物品批量保存前校验
- validateForm() {
- return new Promise((resolve, reject) => {
- for (let i = 0; i < this.productList.length; i++) {
- const row = this.productList[i];
- if (row.isSave) continue;
- if (!this.validateSingleRow(row, i + 1)) {
- reject(new Error('校验不通过'));
- return;
- }
- }
- resolve();
- });
- },
- listSave(row, index) {
- // 必填项校验
- if (!this.validateSingleRow(row)) {
- return;
- }
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)?.dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)?.dictValue;
- let packingNum = 0;
- if (packingBoolen) {
- if (!row.isUnpack && row.packingUnit == '立方') {
- packingNum = 1;
- } else {
- let filterArr = row.packingSpecificationOption.filter((item) => {
- return item.packageUnit == row.packingUnit && item.packageUnit != item.conversionUnit;
- });
- if (filterArr?.length) {
- packingNum = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
- }
- }
- }
-
- let measureNum = row.packingQuantity;
- let num = 0;
- if (measureBoolen) {
- let splitIndex = row.packingSpecificationOption.findIndex((item) =>
- item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- measureNum = measureNum * row.packingSpecificationOption[splitIndex].packageCell;
- }
- } else {
- if (row.packingSpecificationOption[1]?.packageCell) {
- num = Math.ceil(row.measureQuantity / row.packingSpecificationOption[1]?.packageCell);
- } else {
- num = row.packingQuantity;
- }
- }
- if (row.packingSpecificationLabel?.length < 1) {
- uni.showToast({ title: '请到主数据维护包装组信息!', icon: 'none' });
- return;
- }
-
- // 不拆包
- if (!row.isUnpack) {
- if (row.packingUnit != row.measureUnit) {
- getAssetNum([{ assetCode: row.categoryCode + row.index, batchNum: row.batchNo, num: row.packingQuantity }]).then(() => {});
- } else {
- getAssetNum([{ assetCode: row.categoryCode + row.index, batchNum: row.batchNo, num: 0 }]).then(() => {});
- }
- } else {
- if (!packingNum) {
- if (row.packingUnitId) {
- let splitIndex = row.packingSpecificationOption.findIndex((item) => item.id == row.packingUnitId);
- if (splitIndex == 0) {
- packingNum = Math.ceil(row.measureQuantity / row.packingSpecificationOption[1]?.packageCell);
- }
- if (splitIndex == 1) {
- packingNum = row.packingQuantity;
- }
- for (; splitIndex > 1; splitIndex--) {
- packingNum = Math.ceil(row.packingQuantity * row.packingSpecificationOption[splitIndex].packageCell);
- }
- } else {
- packingNum = Math.ceil(row.measureQuantity / row.packingSpecificationOption[1]?.packageCell);
- }
- }
- getAssetNum([{ assetCode: row.categoryCode + row.index, batchNum: row.batchNo, num: packingNum }]).then((res) => {
- this.generateWrappers(row, index, res.data || []);
- });
- }
-
- this.$set(this.productList[index], 'isSave', true);
- this.$set(this.productList[index], 'warehouseId', row.warehouseId);
- this.$set(this.productList[index], 'warehouseName', row.warehouseName);
- this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
- this.$set(this.productList[index], 'warehouseNames', row.warehouseName);
- },
- editProductList(row, index) {
- this.$set(this.productList[index], 'isSave', false);
- },
- deleteProductList(row, index) {
- uni.showModal({
- title: '提示',
- content: '确定删除该产品吗?',
- success: (res) => {
- if (res.confirm) {
- this.productList.splice(index, 1);
- }
- }
- });
- },
- saveProductList(row, index) {
- this.listSave(row, index);
- },
- addStock() {
- this.addProduct();
- },
- // 入库
- async getReturnStorage() {
- if (this.productList.length <= 0) {
- uni.showToast({ title: '请先添加产品信息', icon: 'none' });
- return;
- }
- let boolen = this.productList.every((item) => item.isSave);
- if (!boolen) {
- uni.showToast({ title: '请先保存所有产品信息', icon: 'none' });
- return;
- }
- if (this.isShowPackage) {
- const userNameLength = this.productList.filter(
- (item) => !item.unpackUserName
- ).length;
- const packgeLength = this.productList.filter(
- (item) => !item.ifPackageOk
- ).length;
- if (userNameLength || packgeLength) {
- uni.showToast({ title: '请先填写拆包装责任人和包装完好与否', icon: 'none' });
- return;
- }
- }
- // 处理包装数据
- let _packingList = [];
- _packingList = this.packingList.map((packingItem) => {
- let _taskId = null;
- let _workOrderId = null;
- // if ([1].includes(this.formData.bizType)) {
- // _workOrderId = this.detailList[0]?.workOrderId;
- // _taskId = this.detailList[0]?.taskId;
- // } else {
- _workOrderId = this.form.productList[0]?.workOrderId;
- _taskId = this.form.productList[0]?.taskId;
- // }
- // if (packingItem.modelKey) {
- // packingItem.modelKey = packingItem.modelKey.toString();
- // }
- // if (packingItem.colorKey) {
- // packingItem.colorKey = packingItem.colorKey.toString();
- // }
- return {
- ...packingItem,
- workOrderId: _workOrderId,
- taskId: _taskId,
- outsourceBatchNo: this.form.productList[0]?.batchNo,
- outsourceCode: this.form.productList[0]?.sourceCode,
- // materialDetailList: this.materialList.filter(
- // (item) => item.parentIndex === packingItem.index
- // )
- };
- });
- // 处理产品数据
- this.productList = this.productList.map((productItem) => {
- // if (productItem.modelKey) {
- // productItem.modelKey = productItem.modelKey.toString();
- // }
- // if (productItem.colorKey) {
- // productItem.colorKey = productItem.colorKey.toString();
- // }
- return {
- ...productItem,
- outInDetailRecordRequestList: _packingList.filter(
- (item) => item.parentIndex === productItem.index
- )
- };
- });
- this.formData.outInDetailList = this.productList;
- let obj = uni.$u.deepClone(this.formData);
- // 处理物品类型assetType
- obj.extInfo.assetType = obj.extInfo.assetType.join(',');
- obj.extInfo.documentSource = this.formData.sourceBizNo;
- obj.extInfo.deptName = this.formData.extInfo.deptName;
- obj.extInfo.supplierName = this.form.supplierName;
- obj.extInfo.deliveryPhone = this.formData.extInfo.deliveryPhone;
- // 处理仓库id
- let warehouseId = [];
- let warehouseName = [];
- let warehouseIds = this.productList.map((item) => item.warehouseIds).flat();
- let warehouseNames = this.productList.map((item) => item.warehouseNames).flat();
- warehouseIds.forEach((item, index) => {
- if (!warehouseId.includes(item)) {
- warehouseId.push(item);
- warehouseName.push(warehouseNames[index]);
- }
- });
- obj.warehouseIds = warehouseId;
- obj.warehouseNames = warehouseName;
- obj._packingList = _packingList;
- const isVerifyData = await isVerifyRepeatIsStock({
- categoryCodes: this.productList.map((item) => item.categoryCode),
- batchNos: this.productList.map((item) => item.batchNo)
- });
- return new Promise((resolve, reject) => {
- if (isVerifyData?.length) {
- uni.showModal({
- title: '提示',
- content: `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
- .map((item) => item.categoryName)
- .join(',')}已有入库记录,是否继续入库!`,
- confirmText: '是',
- cancelText: '否',
- success: (res) => {
- if (res.confirm) {
- resolve(obj);
- } else {
- resolve(false);
- }
- }
- });
- } else {
- resolve(obj);
- }
- });
- },
- // 获取表数据
- getTableValue() {
- return new Promise(async (resolve, reject) => {
- try {
- const returnStorageData = await this.getReturnStorage();
- resolve({
- form: this.form,
- returnStorageData,
- });
- } catch(e) {
- reject(e);
- }
- });
- },
- // 单位选择变化
- onPackingUnitChange(e, row, index) {
- const val = Number(e.detail.value);
- const item = row.packingSpecificationOption[val];
- if (item) {
- this.$set(this.productList[index], 'packingUnitId', item.id);
- this.$set(this.productList[index], 'packingUnit', item.conversionUnit);
- this.$set(this.productList[index], 'packingUnitIndex', val);
- this.computeNum(row, index);
- }
- },
- // 包装完好选择变化
- onPackageOkChange(e, index) {
- const val = Number(e.detail.value);
- const item = this.packageOkOptions[val];
- if (item) {
- this.$set(this.productList[index], 'ifPackageOkIndex', val);
- this.$set(this.productList[index], 'ifPackageOk', item.value);
- this.$set(this.productList[index], 'ifPackageOkLabel', item.label);
- }
- },
- // 仓库选择变化
- onWarehouseChange(e, index) {
- const val = Number(e.detail.value);
- const item = this.warehouseListOption[val];
- if (item) {
- this.$set(this.productList[index], 'warehouseId', item.id);
- this.$set(this.productList[index], 'warehouseName', item.name);
- this.$set(this.productList[index], 'warehouseIndex', val);
- this.$set(this.productList[index], 'warehouseIds', [item.id]);
- this.$set(this.productList[index], 'warehouseNames', [item.name]);
- }
- },
- // 供应商选择变化
- onSupplierChange(e, index) {
- const val = Number(e.detail.value);
- const item = this.productList[index].supplierListOptions[val];
- if (item) {
- this.$set(this.productList[index], 'supplierId', item.id);
- this.$set(this.productList[index], 'supplierName', item.name);
- this.$set(this.productList[index], 'supplierCode', item.serialNo);
- this.$set(this.productList[index], 'supplierIndex', val);
- }
- },
- // 颜色选择变化
- onColorChange(e, index) {
- const val = Number(e.detail.value);
- const item = this.colorOptions[val];
- if (item) {
- this.$set(this.productList[index], 'colorKey', item.dictCode);
- this.$set(this.productList[index], 'colorKeyName', item.dictValue);
- this.$set(this.productList[index], 'colorIndex', val);
- }
- },
- // 机型选择变化
- onModelChange(e, index) {
- const val = Number(e.detail.value);
- const item = this.modelOptions[val];
- if (item) {
- this.$set(this.productList[index], 'modelKey', item.dictCode);
- this.$set(this.productList[index], 'modelKeyName', item.dictValue);
- this.$set(this.productList[index], 'modelIndex', val);
- }
- },
- // 包装明细-颜色选择变化
- onPackingColorChange(e, packingItem) {
- const val = Number(e.detail.value);
- const item = this.colorOptions[val];
- if (item) {
- this.$set(packingItem, 'colorKey', item.dictCode);
- this.$set(packingItem, 'colorKeyName', item.dictValue);
- this.$set(packingItem, 'colorIndex', val);
- }
- },
- // 包装明细-机型选择变化
- onPackingModelChange(e, packingItem) {
- const val = Number(e.detail.value);
- const item = this.modelOptions[val];
- if (item) {
- this.$set(packingItem, 'modelKey', item.dictCode);
- this.$set(packingItem, 'modelKeyName', item.dictValue);
- this.$set(packingItem, 'modelIndex', val);
- }
- },
- // 包装明细-质检结果选择变化
- onPackingResultChange(e, packingItem) {
- const val = Number(e.detail.value);
- const item = this.qualityResultsOptions[val];
- if (item) {
- this.$set(packingItem, 'result', item.value);
- }
- },
- // 获取质检结果的 picker index
- getResultIndex(result) {
- return this.qualityResultsOptions.findIndex(o => o.value === result);
- },
- // 日期选择变化
- onDateChange(e, row, field) {
- row[field] = e.detail.value;
- },
- //入库明细删除
- listDel(row, index) {
- this.productList.splice(index, 1);
- this.deletePackingAndMaterial(row);
- },
- // 根据产品信息删除包装和物料
- deletePackingAndMaterial(row) {
- // 删除包装(去掉不相同的包装)
- this.packingList = this.packingList.filter(
- (item) => item.parentIndex !== row.index
- );
- this.showPackingList = this.showPackingList.filter(
- (item) => item.parentIndex !== row.index
- );
- this.pickingPageNum = Math.ceil(
- this.showPackingList.length / this.pageSize
- );
- // 删除物料(获取相同物料)
- // let packingIndexs = this.packingList.map((item) => item.index);
- // this.materialList = this.materialList.filter((item) =>
- // packingIndexs.includes(item.parentIndex)
- // // );
- // this.showMaterialList = this.showMaterialList.filter((item) =>
- // packingIndexs.includes(item.parentIndex)
- // );
- // this.materielPageNum = Math.ceil(
- // this.showMaterialList.length / this.pageSize
- // );
- },
- // 产品批量保存
- async listSaveArrs() {
- this.validateForm()
- .then(async () => {
- // 批量获取包装编码并处理
- let packingCodePrams = this.productList.map((row) => {
- if (row.isSave) return {};
- const { packingBoolen, measureBoolen, num: baseNum } = this.computePackagingParams(row);
- let num = baseNum;
- // 处理单位为KG类的情况
- if (packingBoolen) {
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num
- };
- } else {
- if (row.isUnpack == 1) {
- if (measureBoolen) {
- // 处理单位不为KG类,计量单位为KG类的情况
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: baseNum
- };
- } else {
- // 处理拆包到最小包装单元数量的情况
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: row.measureQuantity
- };
- }
- } else {
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num
- };
- }
- }
- });
- console.log('packingCodePrams', packingCodePrams);
- let filterPackingCodePrams = packingCodePrams.filter(
- (item) => item.assetCode
- );
- console.log('filterPackingCodePrams', filterPackingCodePrams);
- let { data } = await getAssetNum(filterPackingCodePrams);
- let packingCodeList = [];
- packingCodePrams.forEach((item, index) => {
- packingCodeList[index] = data.filter(
- (ite) => ite.assetCode == item.assetCode
- );
- });
- // 批量生成包装
- this.productList.map((row, index) => {
- if (!row.isSave) {
- this.generateWrappers(row, index, packingCodeList[index]);
- this.$set(this.productList[index], 'isSave', true);
- }
- });
- // 加载虚拟列表数据(分页)
- // this.pickingFetchData();
- // this.materielFetchData();
- })
- .catch((err) => {
- console.log(err);
- });
- },
- // 生成包装
- generateWrappers(row, productIndex, packingCodeList) {
- console.log(packingCodeList, 'packingCodeList', row.measureType);
- if (!row.measureType)
- return uni.showToast({
- title: '请到主数据维计量类型!',
- icon: 'none'
- });
- if (!packingCodeList?.length) return;
- console.log('包装数据--------', row);
- // console.log('包装规格----', row.packingSpecificationOption);
- console.log('计量单位----', row.measureUnit);
- let packingList = [];
- // let obj = this.getNowDate();
- let productionDate = row.detailProductionDate || '';
- let purchaseDate = row.detailPurchaseDate || '';
- let expireDate = row.detailExpireDate || '';
- console.log(expireDate, 'expireDate');
- console.log(
- this.formData.bizType,
- 'bizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizType'
- );
- if (this.formData.bizType == '1') {
- // 生产入库
- productionDate = this.getNowDate();
- // this.curDateType = 'productionDate';
- }
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit).dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit).dictValue;
- console.log('packingBoolen', packingBoolen, measureBoolen);
- let num = row.packingQuantity;
- let filterArr = [];
- // 处理单位为KG类的情况
- if (packingBoolen) {
- console.log(
- packingBoolen,
- 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
- );
- if (!row.isUnpack && row.packingUnit == '立方') {
- num = 1;
- } else {
- filterArr = row.packingSpecificationOption.filter((item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- });
- num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
- }
- } else {
- // if (row.isUnpack == 1) {
- if (measureBoolen) {
- // 处理单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- num = num * row.packingSpecificationOption[splitIndex].packageCell;
- }
- } else {
- if (row.packingSpecificationOption[1]?.packageCell) {
- num = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- filterArr = row.packingSpecificationOption.filter((item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- });
- }
- }
- }
- console.log('num-----------', num);
- for (let index = 0; index < packingCodeList.length; index++) {
- let measureQuantity = 1;
- let packingQuantity = 1;
- let packingUnit = row.packingUnit;
- // 处理单位为KG类,计算每桶KG值
- if (packingBoolen) {
- measureQuantity = Number(row.packingQuantity) > filterArr[0].packageCell * (index + 1) ? filterArr[0].packageCell : Number(row.packingQuantity) - filterArr[0].packageCell * index;
- console.log(measureQuantity, 'measureQuantit1111y');
- } else {
- console.log('1 拆--------', measureBoolen);
- //计量单位等于重量单位并且有总重 计量数量=总重/包装数
- if (row.weightUnit == row.measureUnit && row.weight) {
- measureQuantity = Math.trunc((row.weight / packingCodeList.length) * 10000) / 10000;
- } else if (measureBoolen) {
- let splitIndex = row.packingSpecificationOption.findIndex((item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 0; splitIndex--) {
- measureQuantity = measureQuantity *
- row.packingSpecificationOption[splitIndex].packageCell;
- }
- } else {
- measureQuantity = row.packingSpecificationOption[1].packageCell;
- }
- console.log(measureQuantity, 'measureQuantity');
- }
- let clientCode = '';
- if (this.bizType == 2) {
- clientCode = row?.customerMark;
- } else if (this.bizType != 2) {
- clientCode = row.extInfo?.clientCode;
- }
- console.log(filterArr[0], 'filterArr[0]');
- let status = null;
- if (row.qualityControl == 1) {
- status = 0;
- } else {
- status = 2;
- }
- let item = {
- index: row.index + '-' + index, // 包装索引
- warehouseId: row.warehouseId, // 仓库id
- warehouseName: row.warehouseName, // 仓库名称
- categoryName: row.categoryName, // 产品名称
- categoryCode: row.categoryCode, // 产品编码
- categoryModel: row.categoryModel, // 物品型号
- specification: row.specification, // 规格
- supplierCode: row.supplierCode, // 供应商编码
- supplierName: row.supplierName, // 供应商名称
- brandNum: row.brandNum, // 牌号
- parentIndex: row.index, // 产品索引
- batchNo: row.batchNo, // 批次号
- packageNo: packingCodeList[index]?.onlyCode, // 包装编码
- packingQuantity: packingQuantity, // 包装数量
- packingUnit: row.packingUnit, // 包装单位(默认)
- modelKey: row.modelKey, // 机型
- modelKeyName: row.modelKey ? (this.modelOptions.find(o => o.dictCode === row.modelKey)?.dictValue || '') : '',
- modelIndex: row.modelKey ? this.modelOptions.findIndex(o => o.dictCode === row.modelKey) : -1,
- colorKey: row.colorKey, //颜色
- colorKeyName: row.colorKey ? (this.colorOptions.find(o => o.dictCode === row.colorKey)?.dictValue || '') : '',
- colorIndex: row.colorKey ? this.colorOptions.findIndex(o => o.dictCode === row.colorKey) : -1,
- measureQuantity: measureQuantity, // 计量数量
- measureUnit: row.isUnpack
- ? measureBoolen
- ? row.packingSpecificationOption[1]
- ? row.packingSpecificationOption[1].packageUnit
- : row.packingSpecificationOption[0].packageUnit
- : row.measureUnit
- : row.measureUnit, // 计量单位
- weight: 0, // 重量
- packingSpecificationOption: row.packingSpecificationOption, // 包装规格
- weightUnit: row.weightUnit, // 重量单位
- netWeight: row.netWeight, // 净重
- barcodes: '', // 发货条码
- clientCode: clientCode, // 客户代号
- materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
- engrave: '', // 刻码
- isUnpack: row.isUnpack, // 是否允许拆包
- productionDate: productionDate, // 生产日期
- purchaseDate: purchaseDate, // 采购时间
- expireDate: expireDate, //失效日期
- serialNo: '', // 序列号
- result: 1, // 结果(1合格 2不合格)
- qualityControl: row.qualityControl,
- status: status // 状态(0=未质检 1待检 2已检)
- };
- if (row.isUnpack) {
- // 第二层条件: packingBoolen
- if (packingBoolen) {
- // 空值保护: 确保 filterArr[0] 存在
- item.packingUnit = row.packingSpecificationOption[1].conversionUnit;
- } else {
- // 第三层条件: measureBoolen
- if (measureBoolen) {
- // 处理 packingSpecificationOption 的索引
- const option =
- row.packingSpecificationOption?.[1] ||
- row.packingSpecificationOption?.[0];
- item.packingUnit = option?.conversionUnit;
- } else {
- item.packingUnit =
- row.packingSpecificationOption[1].conversionUnit;
- }
- }
- }
- let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit).dictValue;
- //计量单位等于重量单位
- if (row.weightUnit == row.measureUnit) {
- item.weight = item.measureQuantity
- ? Number(item.measureQuantity)
- : 0;
- } else if (outBoolen) {
- // 计量单位为KG类,直接替换
- item.weight = item.measureQuantity
- ? Number(item.measureQuantity)
- : 0;
- } else {
- console.log('计量单位为不为KG类======================');
- // 计量单位为不为KG类,重新统计计算
- let inBoolen = !!this.getDict('不拆物料层规格', item.packingSpecificationOption[0].packageUnit).dictValue;
- let startIndex = item.packingSpecificationOption.findIndex(
- (ite) => {
- return (
- item.measureUnit == ite.packingUnit &&
- ite.packingUnit != ite.conversionUnit
- );
- }
- );
- let endIndex = item.packingSpecificationOption.findIndex(
- (ite) => item.packingUnit == ite.conversionUnit
- );
- if (measureBoolen) {
- let total = item.packingQuantity ? Number(item.packingQuantity) : 0;
- for (; startIndex < endIndex; endIndex--) {
- total = item.packingSpecificationOption[endIndex].packageCell * total;
- }
- if (inBoolen) {
- // 第二层为KG类
- item.weight = total ? Number(total) : 0;
- } else {
- // 第二层不为KG类
- item.weight = total * item.netWeight;
- }
- } else if (!measureBoolen) {
- if (inBoolen) {
- // 第二层为KG类
- item.weight = item.measureQuantity ? Number(item.measureQuantity) : 0;
- } else {
- // 第二层不为KG类
- if (row.singleWeight && item.measureQuantity) {
- item.weight = Number(item.measureQuantity) * Number(row.singleWeight);
- } else {
- item.weight = 0;
- }
- }
- }
- }
- packingList.push(item);
- console.log(
- packingList,
- 'packingList!!!!!!!!!!!!!!!!!!拆'
- );
- }
- // 单独点击保存并插入对应位置(包装)
- if (productIndex == 0) {
- this.packingList.splice(productIndex, 0, ...packingList);
- } else {
- let packingIndex = this.packingList.findLastIndex(
- (item) =>
- item.parentIndex == this.productList[productIndex - 1].index
- );
- this.packingList.splice(packingIndex + 1, 0, ...packingList);
- }
- let remainder = 0;
- if (row.weightUnit != row.measureUnit) {
- remainder =
- row.measureQuantity %
- row.packingSpecificationOption[1]?.packageCell;
- }
- if (remainder > 0 && packingCodeList?.length) {
- let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
- let idx = this.packingList.findIndex(
- (packingItem) => packingItem.packageNo == onlyCode
- );
- if (idx !== -1) {
- this.$set(this.packingList[idx], 'measureQuantity', remainder);
- if (row.singleWeight) {
- this.$set(
- this.packingList[idx],
- 'weight',
- row.singleWeight * remainder
- );
- }
- }
- }
- },
- }
- }
- </script>
- <style scoped>
- .add {
- width: 96rpx;
- height: 96rpx;
- border-radius: 48rpx;
- background: #3c9cff;
- position: fixed;
- bottom: 100rpx;
- right: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 99;
- }
- /* 产品卡片样式 */
- .product-card {
- background: #fff;
- margin: 20rpx;
- border-radius: 12rpx;
- padding: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
- }
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding-bottom: 20rpx;
- border-bottom: 1rpx solid #eee;
- margin-bottom: 20rpx;
- }
- .product-name {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- }
- .product-code {
- font-size: 26rpx;
- color: #333;
- }
- .card-body {
- padding: 0;
- }
- .info-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 16rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .info-row:last-child {
- border-bottom: none;
- }
- .info-label {
- font-size: 28rpx;
- color: #666;
- min-width: 160rpx;
- }
- .info-value {
- font-size: 28rpx;
- color: #333;
- text-align: right;
- flex: 1;
- }
- .red-text {
- color: #ff0000 !important;
- }
- .card-footer {
- margin-top: 20rpx;
- padding-top: 20rpx;
- border-top: 1rpx solid #eee;
- }
- .action-buttons {
- display: flex;
- gap: 20rpx;
- }
- /* 包装明细样式 */
- .packing-section {
- margin-top: 40rpx;
- padding: 0 20rpx;
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- padding: 20rpx 0;
- }
- .packing-card {
- background: #fff;
- border-radius: 12rpx;
- padding: 24rpx;
- margin-bottom: 20rpx;
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
- }
- /* 包装卡片标题 */
- .card_title {
- font-size: 30rpx;
- font-weight: bold;
- color: #1890FF;
- padding-bottom: 16rpx;
- border-bottom: 1rpx solid #eee;
- margin-bottom: 16rpx;
- }
- /* 单位后缀 */
- .info-unit {
- font-size: 26rpx;
- color: #999;
- margin-left: 8rpx;
- }
- /* 批量操作按钮 */
- .batch-actions {
- display: flex;
- gap: 20rpx;
- padding: 20rpx;
- background: #f8f8f8;
- margin-bottom: 20rpx;
- }
- /* 卡片序号 */
- .card-index {
- font-size: 24rpx;
- color: #999;
- background: #f0f0f0;
- padding: 4rpx 16rpx;
- border-radius: 20rpx;
- }
- /* 编辑行样式 */
- .edit-row {
- background: #fafafa;
- }
- /* 必填标识 */
- .required {
- color: #ff0000;
- }
- /* 输入框样式 */
- .info-input {
- flex: 1;
- text-align: right;
- font-size: 28rpx;
- color: #333;
- padding: 8rpx 0;
- }
- /* picker选择器样式 */
- .info-picker {
- flex: 1;
- /* text-align: right; */
- }
- .picker-value {
- font-size: 28rpx;
- color: #333;
- padding: 16rpx 32rpx 16rpx 16rpx;
- /* background: #f0f0f0; */
- border-radius: 8rpx;
- display: inline-block;
- min-width: 160rpx;
- /* text-align: center; */
- position: relative;
- width: 100%;
- border: 1rpx solid #dadbde;
- }
- .picker-value::after {
- content: '';
- position: absolute;
- right: 8rpx;
- top: 50%;
- transform: translateY(-50%);
- border: 8rpx solid transparent;
- border-top-color: #666;
- }
- .picker-value.placeholder {
- color: #999;
- /* background: #e8e8e8; */
- }
- /* 仓库选择样式 */
- .warehouse-select {
- flex: 1;
- text-align: right;
- padding: 8rpx 0;
- }
- /* 多选组件样式 */
- .multi-select-container {
- flex: 1;
- display: flex;
- flex-wrap: wrap;
- gap: 16rpx;
- padding: 8rpx 0;
- }
- .multi-select-item {
- display: flex;
- align-items: center;
- gap: 8rpx;
- background: #f0f0f0;
- padding: 8rpx 16rpx;
- border-radius: 8rpx;
- font-size: 24rpx;
- }
- .multi-select-label {
- color: #333;
- }
- /* 颜色选择器触发器样式 */
- .color-picker-trigger {
- flex: 1;
- display: flex;
- justify-content: flex-end;
- }
- </style>
|