| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891 |
- <template>
- <ele-modal :visible.sync="visible" title="生产入库" width="80%" :maxable="true">
- <div class="productionWarehousing">
- <el-card shadow="never">
- <header-title title="基本信息"></header-title>
- <el-form
- :model="formData"
- ref="formName"
- label-width="110px"
- :rules="rules"
- >
- <el-row :gutter="20">
- <el-col :span="8">
- <el-form-item label="物品类型" prop="extInfo.assetType">
- <selectTree
- ref="tree"
- class="form-ipt"
- size="medium"
- style="width: 100%"
- :isBindPlan="true"
- :value="formData.extInfo.assetType"
- clearable
- :options="codeList"
- :props="{
- value: 'id',
- label: 'name',
- children: 'children'
- }"
- @getValue="codeListValue"
- :isAll="false"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="入库类型" prop="bizType">
- <span>生产入库</span>
- </el-form-item></el-col
- >
- <el-col :span="8">
- <el-form-item label="生产工单" prop="documentSource">
- <el-input
- v-model="formData.extInfo.documentSource"
- disabled
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="权属部门" prop="deptName">
- <el-input
- placeholder="权属部门"
- disabled
- v-model="formData.extInfo.deptName"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="入库登记人">
- <el-input
- placeholder="登记人"
- disabled
- v-model="formData.extInfo.createUserName"
- clearable /></el-form-item
- ></el-col>
- <el-col :span="8">
- <el-form-item label="送货人" prop="fromUser">
- <el-input
- placeholder="请输入"
- v-model="formData.fromUser"
- clearable
- /> </el-form-item
- ></el-col>
- <el-col :span="8">
- <el-form-item label="送货人联系方式" prop="deliveryPhone">
- <el-input
- placeholder="请输入"
- v-model="formData.extInfo.deliveryPhone"
- clearable /></el-form-item
- ></el-col>
- <el-col :span="24">
- <el-form-item label="备注" prop="remark">
- <el-input
- v-model="formData.remark"
- clearable
- type="textarea"
- placeholder="请详细说明"
- :rows="4"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="material">
- <header-title title="产品信息">
- <el-button type="primary" @click="addStock" v-if="!isTask"
- >添加</el-button
- >
- </header-title>
- <div class="mt10 form-table">
- <el-form
- ref="warehousingMaterialListRef"
- :model="{ warehousingMaterialList: warehousingMaterialList }"
- :show-message="false"
- >
- <el-button
- v-if="warehousingMaterialList.length != 0"
- type="success"
- plain
- style="margin-bottom: 20px; float: right; margin-right: 20px"
- size="mini"
- @click="listSaveArrs"
- >批量保存</el-button
- >
- <el-table
- v-if="isWeight"
- :header-cell-style="rowClass"
- ref="warehousingMaterialListTable"
- :key="formData.extInfo.assetType"
- :data="warehousingMaterialList"
- tooltip-effect="dark"
- style="width: 100%"
- stripe
- >
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- >
- </el-table-column>
- <el-table-column
- label="编码"
- prop="assetCode"
- align="center"
- width="130"
- ></el-table-column>
- <el-table-column
- label="名称"
- align="center"
- width="200"
- prop="assetName"
- ></el-table-column>
- <el-table-column
- v-for="(item, index) in tableHeader"
- :key="index"
- align="center"
- :label="item.label"
- width="150"
- :prop="item.prop"
- >
- <template slot-scope="{ row }">
- <template v-if="item.formatter">{{
- item.formatter(row)
- }}</template>
- <template v-else>{{ row[item.prop] }}</template>
- </template>
- </el-table-column>
- <el-table-column label="批次号" width="100" prop="assetName">
- <template slot-scope="{ row, $index }">
- <template>
- {{ row.manualBatchNo }}
- </template>
- </template>
- </el-table-column>
- <el-table-column
- label="批次号"
- prop="batchNo"
- width="70"
- align="center"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.batchNo }}
- </template>
- <el-form-item
- v-else
- :prop="`warehousingMaterialList.${$index}.batchNo`"
- required
- >
- {{ row.batchNo }}
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="最小包装单元"
- align="center"
- prop="minPackingCount"
- width="100"
- >
- <el-table-column label="" prop="minPackingCount" width="100">
- <template slot-scope="{ row, $index }">
- <template>
- {{ row.minPackingCount }}
- </template>
- </template>
- </el-table-column>
- <el-table-column label="" prop="minPackingCount">
- <template slot-scope="{ row, $index }">
- {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
- </template>
- </el-table-column>
- </el-table-column>
- <el-table-column
- label="包装数量"
- prop="outInNum"
- width="150"
- align="center"
- >
- <template slot-scope="{ row, $index }">
- <template>
- {{ row.outInNum }} {{ row.minPackUnit }}
- </template>
- </template>
- </el-table-column>
- <el-table-column label="计量数量" prop="counts">
- <template slot-scope="{ row, $index }">
- {{ isBaoyue?tableHandle(row):$math.format(row.minPackingCount * row.outInNum, 14) }}
- </template>
- </el-table-column>
- <el-table-column
- label="计量单位"
- prop="batchNo"
- width="100"
- align="center"
- >
- <!-- v-if="formData.extInfo.assetType == 1" -->
- <template slot-scope="{ row, $index }">
- <template>
- {{ row.measuringUnit }}
- </template>
- </template>
- </el-table-column>
- <el-table-column
- label="重量"
- align="center"
- prop="contentImage"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- {{ row.weight }}
- <template slot="append">
- {{ handleRowUnit(row) }}
- </template>
- </template>
- </el-table-column>
- <el-table-column
- label="重量单位"
- align="center"
- prop="contentImage"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- {{ row.weightUnit }}
- <template slot="append"> </template>
- </template>
- </el-table-column>
- <el-table-column
- label="单价"
- prop="univalence"
- width="150"
- align="center"
- >
- <template slot-scope="{ row, $index }">
- <div v-if="row.isSave"
- >{{ row.univalence }}元/{{ handleRowUnit(row) }}</div
- >
- <el-form-item
- v-else
- :prop="`warehousingMaterialList.${$index}.univalence`"
- >
- <el-input
- v-model="row.univalence"
- placeholder="非必填"
- @input="
- (value) =>
- (row.univalence = value.replace(/[^0-9.]+/g, ''))
- "
- >
- <template slot="append">
- 元/{{ handleRowUnit(row) }}
- </template>
- </el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="金额"
- align="center"
- prop="contentImage"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- {{
- calcSumTotal(
- row.outInNum,
- row.minPackingCount,
- row.univalence,
- row
- )
- }}
- </template>
- </el-table-column>
- <el-table-column
- label="货位"
- prop="warehouseName"
- :show-overflow-tooltip="true"
- width="250"
- required
- >
- <template slot-scope="{ row, $index }">
- <el-form-item
- :prop="`warehousingMaterialList.${$index}.houseList`"
- :required="true"
- >
- <div @click="handleWareHouse(row, $index)">
- <div
- style="color: #ff4949"
- v-if="row.houseList.length == 0"
- >
- ---(必填)
- </div>
- <div v-else>
- <div
- class="fontOmitted"
- v-for="(item, index) in row.houseList"
- :key="index"
- >
- {{ item.warehouseName }}- {{ item.areaName }}-
- {{ item.shelfCode }}- {{ item.cargoSpaceCode
- }}<span style="color: #ff4949" v-if="item.num">
- - {{ item.num }}(数)</span
- >
- <br />
- </div>
- </div>
- </div>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- width="200"
- fixed="right"
- align="center"
- >
- <template slot="header" slot-scope="scope"> 操作 </template>
- <template slot-scope="{ row, $index }">
- <el-button
- type="text"
- v-show="!row.isSave"
- @click="listSave(row, $index)"
- >保存</el-button
- >
- <el-button
- type="text"
- v-show="row.isSave"
- @click="listEdit(row, $index)"
- >编辑</el-button
- >
- <el-button
- type="text"
- @click="listDel(row, $index)"
- v-if="!isTask"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- </div>
- <div class="mt20">
- <header-title :title="`包装明细`">
- <div class="switch_right">
- <span v-if="materialCodeReqList.length != 0">
- 分拆<el-switch
- v-model="isSplit"
- active-color="#13ce66"
- inactive-color="#ff4949"
- @change="handleIsDetail"
- style="margin-left: 10px"
- >
- </el-switch>
- </span>
- <!-- <el-button
- style="margin-left: 20px"
- type="text"
- @click="dateSetting"
- v-if="formData.bizType != 5"
- >批量设置{{
- curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
- }}</el-button
- > -->
- </div>
- </header-title>
- <!-- <el-button
- v-if="materialCodeReqList.length != 0"
- type="success"
- plain
- style="margin-bottom: 20px; float: right; margin-right: 20px"
- size="mini"
- @click="wrapListSave"
- >批量保存</el-button
- > -->
- <el-table
- ref="materialCodeReqListTable"
- :data="materialCodeReqList"
- tooltip-effect="dark"
- :key="formData.bizType"
- :header-cell-style="rowClass"
- style="width: 100%"
- stripe
- height="300px"
- @selection-change="handleSelectionChange"
- >
- <el-table-column
- label=""
- type="selection"
- align="center"
- width="50"
- v-if="formData.bizType != 5"
- >
- </el-table-column>
- <el-table-column label="序号" type="index" width="50">
- </el-table-column>
- <el-table-column
- label="编码"
- prop="assetCode"
- width="130"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="名称"
- prop="assetName"
- width="150"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="批次号"
- prop="manualBatchNo"
- width="100"
- ></el-table-column>
- <el-table-column
- label="批次号"
- prop="batchNo"
- width="70"
- ></el-table-column>
- <el-table-column
- label="发货条码"
- prop="barcodes"
- width="80"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- :label="`包装编码`"
- prop="onlyCode"
- width="130"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="包装数量"
- prop="packingCount"
- width="80"
- ></el-table-column>
- <el-table-column
- label="包装单位"
- prop="packingUnit"
- ></el-table-column>
- <el-table-column
- label="计量数量"
- prop="minPackingCount"
- ></el-table-column>
- <el-table-column
- label="计量单位"
- prop="measuringUnit"
- ></el-table-column>
- <el-table-column label="物料代号" prop="materielCode" width="130">
- <template slot-scope="{ row }">
- <span>{{ row.materielCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="客户代号" prop="clientCode">
- <template slot-scope="{ row }">
- <span> {{ row.clientCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="刻码" prop="engrave">
- <template slot-scope="{ row }">
- <span>{{ row.engrave }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量" prop="weight" width="100">
- <template slot-scope="{ row }">
- <span>{{ row.weight }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量单位" prop="weightUtil">
- <template slot-scope="{ row }">
- {{ row.weightUtil }}
- </template>
- </el-table-column>
- <el-table-column label="质检结果" prop="result" width="120">
- <template slot-scope="{ row }">
- <span>{{ qualityResults[row.result] }}</span>
- </template>
- </el-table-column>
- <el-table-column label="质检状态" prop="status" width="120">
- <template slot-scope="{ row }">
- <span>{{ qualityStatus[row.status] }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="生产日期"
- width="150"
- prop="createTime"
- ></el-table-column>
- </el-table>
- <!-- </el-tab-pane>
- </el-tabs> -->
- </div>
- <div class="mt20" v-if="isSplit">
- <header-title :title="`物料明细`"> </header-title>
- <el-table
- ref="resultArrayTable"
- :data="resultArray"
- tooltip-effect="dark"
- :key="formData.bizType"
- :header-cell-style="rowClass"
- style="width: 100%"
- stripe
- height="300px"
- @selection-change="handleSelectionChange"
- >
- <el-table-column label="序号" type="index" width="50">
- </el-table-column>
- <el-table-column
- label="编码"
- prop="assetCode"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="名称"
- prop="assetName"
- width="200"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="批次号"
- prop="manualBatchNo"
- width="100"
- ></el-table-column>
- <el-table-column
- label="批次号"
- prop="batchNo"
- width="80"
- ></el-table-column>
- <el-table-column
- label="物料编码"
- prop="no"
- width="200"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="发货条码"
- prop="barcodes"
- width="80"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="计量数量"
- prop="minPackingCount"
- width="90"
- ></el-table-column>
- <el-table-column
- width="80"
- label="计量单位"
- prop="measuringUnit"
- ></el-table-column>
- <el-table-column label="物料代号" prop="meterielCode" width="130">
- <template slot-scope="{ row }">
- <span>{{ row.materialCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="客户代号" prop="clientCode">
- <template slot-scope="{ row }">
- <span> {{ row.clientCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="刻码" prop="engrave">
- <template slot-scope="{ row }">
- <span> {{ row.engrave }}</span>
- </template>
- </el-table-column>
- <el-table-column width="100" label="重量" prop="weight">
- <template slot-scope="{ row }">
- <span>{{ row.weight }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量单位" prop="weightUnit" width="100">
- </el-table-column>
- <el-table-column label="质检结果" prop="result" width="120">
- <template slot-scope="{ row }">
- <span>{{ qualityResults[row.result] }}</span>
- </template>
- </el-table-column>
- <el-table-column label="质检状态" prop="status" width="120">
- <template slot-scope="{ row }">
- <span>{{ qualityStatus[row.status] }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </el-card>
- <selectType
- :visibleDialog.sync="visibleDialog"
- :title="title"
- :tableHeader="tableHeader"
- :bizScene="formData.bizType"
- :type="[selectEquiType]"
- :loadTree.sync="loadTree"
- @selectTableData="addProduct"
- />
- <WareHouseDailog
- ref="wareHouseDailogRef"
- @houseData="houseData"
- ></WareHouseDailog>
- <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
- <el-date-picker
- size="small"
- v-model="batchTime"
- type="datetime"
- style="width: 320px"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker>
- <div style="text-align: right; margin-top: 20px">
- <el-button @click="dateVisible = false">取消</el-button>
- <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
- >确认</el-button
- >
- </div>
- </el-dialog>
- </div>
- <div style="text-align: right; margin-top: 20px">
- <el-button @click="visible = false">取消</el-button>
- <el-button type="primary" @click="save" :loading="isLoading"
- >入库</el-button
- >
- </div>
- </ele-modal>
- </template>
- <script>
- import { getLoginUser } from '@/api/login';
- import outin from '@/api/warehouseManagement/outin';
- import { allCategoryLevel } from '@/api/classifyManage';
- import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
- import { sceneState } from '@/utils/dict/index';
- import selectTree from './selectTree';
- import selectType from './selectType.vue';
- import WareHouseDailog from './WareHouseDailog.vue';
- import { tableHeader } from './common';
- import { getCode } from '@/api/codeManagement/index.js';
- import { deepClone } from 'ele-admin/lib/utils/core';
- import { updateApprovalStatus } from '@/api/warehousing/index.js';
- export default {
- components: {
- selectTree,
- selectType,
- WareHouseDailog
- },
- data() {
- return {
- visible: false,
- isLoading: false,
- isSplit: false, // 是否拆分到物料明细
- qualityStatus: {
- 0: '未检',
- 1: '已检',
- 2: '部分检'
- }, // 质检状态 0未检 1已检
- qualityResults: {
- 0: '合格',
- 1: '不合格',
- 3: '让步接收'
- }, // 质检结果 0合格 1不合格 3让步接收
- isTask: false,
- isWeight: true,
- resultArray: [],
- pickerRow: {},
- codeList: [],
- sceneState,
- isBaoyue: false, //是否是宝悦
- visibleDialog: false,
- curDateType: 'manufactureTime',
- materialCodeReqListSelected: [],
- title: '',
- warehousingMaterialList: [],
- loadTree: true,
- selectEquiType: '',
- batchTime: '',
- dateVisible: false,
- formData: {
- extInfo: {
- assetType: '', //物品类型
- deptCode: '', //部门code
- deptName: '', //部门名称
- verifyDeptCode: '', //审核部门编码
- verifyDeptName: '', //审核部门名称
- deliveryName: '', //送货人名称
- deliveryPhone: '', //送货人电话
- documentSource: '', //销售订单
- urgent: '', //紧急状态
- supplierId: '', //供应商ID
- supplierName: '', //供应商名称
- createUserName: '', //创建人名字
- contentImage: [] //图片数组
- },
- fromUser: '', //送货人
- bizType: '', //物品类型
- verifyId: '', //审核人Id
- verifyName: '', //审核人名称
- createUserId: '',
- remark: ''
- },
- rules: {
- 'extInfo.assetType': {
- required: true,
- message: '请选择物品类型',
- trigger: 'change'
- },
- bizType: {
- required: true,
- message: '请选择入库场景',
- trigger: 'change'
- }
- }
- };
- },
- props: ['inboundType'],
- computed: {
- // 条码信息
- materialCodeReqList() {
- console.log(this.warehousingMaterialList, 'fdfdf');
- return this.warehousingMaterialList
- .map((i) => i.warehouseLedgerDetails || [])
- .flat();
- },
- tableHeader() {
- return tableHeader(this.selectEquiType);
- }
- },
- methods: {
- // 包装维度最小包装单元改变——>总重量
- minPackingCountChange(row, value) {
- if (value >= 0) {
- row.minPackingCount = value;
- } else {
- row.minPackingCount = 0;
- }
- // row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
- if (row.outInNum >= 0 && value >= 0) {
- this.packNum(row, row.outInNum);
- }
- },
- // 选择质检结果改变质检状态
- changeWrapStatus(resultValue, row) {
- switch (resultValue) {
- case '':
- // 清空质检状态
- row.status = '0';
- break;
- default:
- // 默认已检质检状态
- row.status = '1';
- break;
- }
- },
- weightInput(value, row) {
- const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
- const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
- if (decimalCount > 1) {
- // 如果小数点个数大于1,移除多余的小数点
- const lastIndex = newValue.lastIndexOf('.');
- row.weight =
- newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
- } else if (decimalCount === 1) {
- // 如果小数点个数等于1,允许小数点的输入
- row.weight = newValue;
- } else {
- row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
- }
- },
- // 拆分物料
- handleIsDetail(event) {
- this.isSplit = event;
- const list = this.materialCodeReqList;
- if (event) {
- let resultArray = [];
- list.forEach((item) => {
- // 包装维度改成已保存状态
- item.isPack = true;
- // 拆分物料维度并生成列表
- for (let i = 1; i <= Number(item.minPackingCount); i++) {
- resultArray.push({
- onlyCode: item.onlyCode,
- no: item.onlyCode + i.toString().padStart(4, '0'),
- assetCode: item.assetCode,
- assetName: item.assetName,
- barcodes: item.barcodes,
- manualBatchNo: item.manualBatchNo,
- batchNo: item.batchNo,
- minPackingCount: 1,
- measuringUnit: item.measuringUnit,
- materielCode: item.materielCode,
- clientCode: item.clientCode,
- weight: this.$math.format(
- item.weight / Number(item.minPackingCount),
- 14
- ),
- initWeight: this.$math.format(
- item.weight / Number(item.minPackingCount),
- 14
- ),
- weightUnit: item.weightUnit,
- engrave: item.engrave,
- result: item.result,
- status: item.status,
- isPack: false
- });
- }
- });
- this.resultArray = resultArray;
- // 批量修改包装明细
- this.isWeight = false;
- this.bulkEditingWrap();
- this.$nextTick(() => {
- this.isWeight = true;
- });
- } else {
- // 包装维度改成编辑状态
- list.forEach((item) => {
- item.isPack = false;
- });
- // 清空物料维度列表
- this.resultArray = [];
- }
- },
- //包装明细保存
- packCout(row) {
- //true保存==》反之
- if (!row.isPack) {
- row.isPack = true;
- const code = row.assetCode;
- const batchNo = row.batchNo;
- //做防护,防止weight字符串类型
- this.materialCodeReqList.forEach((ele) => {
- ele.weight = Number(ele.weight);
- });
- // 修改产品信息重量(包装维度累计)
- this.isWeight = false;
- this.warehousingMaterialList.forEach((item) => {
- if (item.assetCode == code && item.batchNo == batchNo) {
- let arr = [];
- for (const key in this.materialCodeReqList) {
- if (
- this.materialCodeReqList[key].assetCode == item.assetCode &&
- this.materialCodeReqList[key].batchNo == item.batchNo
- ) {
- arr.push({ ...this.materialCodeReqList[key] });
- }
- }
- const count = arr.reduce((acc, curr) => {
- if (curr.isPack) {
- this.$set(curr, 'initWeight', +curr.weight);
- return Number(this.$math.format(+acc + +curr.weight, 14));
- } else {
- return Number(this.$math.format(+acc + +curr.initWeight, 14));
- }
- }, 0);
- this.$set(item, 'weight', count);
- }
- });
- this.$nextTick(() => {
- this.isWeight = true;
- });
- } else {
- row.isPack = false;
- }
- },
- // 批量修改包装明细
- bulkEditingWrap() {
- // 批量修改包装明细列表状态(已保存)
- this.materialCodeReqList.forEach((item) => {
- item.isPack = true;
- });
- // 改变产品明细重量
- this.warehousingMaterialList.forEach((outItem) => {
- let arr = [];
- this.materialCodeReqList.forEach((inneritem) => {
- if (
- inneritem.assetCode == outItem.assetCode &&
- inneritem.batchNo == outItem.batchNo
- ) {
- arr.push(inneritem);
- }
- });
- const count = arr.reduce((acc, curr) => {
- if (curr.isPack) {
- this.$set(curr, 'initWeight', +curr.weight);
- return Number(this.$math.format(+acc + +curr.weight, 14));
- } else {
- return Number(this.$math.format(+acc + +curr.initWeight, 14));
- }
- }, 0);
- this.$set(outItem, 'weight', count);
- });
- },
- // 批量修改物料明细
- bulkEditingMaterial() {
- // 批量修改物料明细列表状态(已保存)
- this.resultArray.forEach((item) => {
- item.isPack = true;
- });
- // 改变包装明细重量
- this.materialCodeReqList.forEach((outItem) => {
- let arr = [];
- this.resultArray.forEach((inneritem) => {
- if (
- inneritem.assetCode == outItem.assetCode &&
- inneritem.batchNo == outItem.batchNo
- ) {
- arr.push(inneritem);
- }
- });
- const count = arr.reduce((acc, curr) => {
- if (curr.isPack) {
- this.$set(curr, 'initWeight', +curr.weight);
- return Number(this.$math.format(+acc + +curr.weight, 14));
- } else {
- return Number(this.$math.format(+acc + +curr.initWeight, 14));
- }
- }, 0);
- this.$set(outItem, 'weight', count);
- });
- },
- // 物料明细保存
- materialBtn(row) {
- console.log(row);
- console.log(this.resultArray);
- console.log(this.materialCodeReqList);
- // true保存 false编辑
- if (!row.isPack) {
- row.isPack = true;
- // 物料维度修改质检改变包装维度质检(结果和状态)
- this.materialCodeReqList.forEach((outItem) => {
- let arr = [];
- this.resultArray.forEach((inneritem) => {
- if (inneritem.onlyCode == outItem.onlyCode) {
- arr.push(inneritem);
- }
- });
- console.log(arr);
- // 首先判断是未填/合格不合格
- let boolen = arr.every((item) => {
- return (
- item.result === '' ||
- item.result === undefined ||
- item.result === null
- );
- });
- // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
- if (boolen) {
- this.$set(outItem, 'result', '');
- this.$set(outItem, 'status', '0');
- } else {
- // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
- let boolen = arr.some((item) => {
- return item.result === '1';
- });
- if (boolen) {
- this.$set(outItem, 'result', '1');
- this.$set(outItem, 'status', '1');
- } else {
- // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
- let boolen = arr.some((item) => {
- return item.result === '3';
- });
- if (boolen) {
- // 让步接收 已检
- this.$set(outItem, 'result', '3');
- this.$set(outItem, 'status', '1');
- } else {
- // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
- let boolen = arr.every((item) => {
- return item.result === '0';
- });
- if (boolen) {
- // 合格 已检
- this.$set(outItem, 'result', '0');
- this.$set(outItem, 'status', '1');
- } else {
- // 合格 部分检
- this.$set(outItem, 'result', '0');
- this.$set(outItem, 'status', '2');
- }
- }
- }
- }
- // this.$set(outItem, 'result', boolen ? '1' : '0');
- });
- // 物料维度修改重量改变包装维度重量
- let onlyCode = row.onlyCode;
- this.materialCodeReqList.forEach((item) => {
- if (item.onlyCode === onlyCode) {
- let arr = [];
- for (const key in this.resultArray) {
- if (this.resultArray[key].onlyCode == item.onlyCode) {
- arr.push(this.resultArray[key]);
- }
- }
- const count = arr.reduce((acc, curr) => {
- if (curr.isPack) {
- this.$set(curr, 'initWeight', +curr.weight);
- return Number(this.$math.format(+acc + +curr.weight, 14));
- } else {
- return Number(this.$math.format(+acc + +curr.initWeight, 14));
- }
- }, 0);
- this.$set(item, 'weight', count);
- }
- });
- // 包装维度修改重量改变产品信息
- this.isWeight = false;
- // 批量修改包装明细
- this.bulkEditingWrap();
- this.$nextTick(() => {
- this.isWeight = true;
- });
- } else {
- row.isPack = false;
- }
- },
- // 重量计算
- packNum(row, value) {
- const total = {
- packingCount: Number(row.minPackingCount > 0 ? row.minPackingCount : 0),
- outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
- };
- if (row.measuringUnit == row.weightUnit) {
- row.weight = Number(
- this.$math.format(
- total.packingCount * 1 * total.outInNum.toFixed(2),
- 14
- )
- );
- } else {
- const totals = Number(
- this.$math.format(total.packingCount * total.outInNum, 14)
- );
- row.weight = Number(
- this.$math.format(
- totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
- 14
- )
- );
- }
- return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
- },
- // 根据单据信息初始化产品信息(外部调用)
- async pickerSuccess(row) {
- this.warehousingMaterialList=[]
- this.isBaoyue = false;
- if (
- row.categoryName.includes('砌块') ||
- row.categoryName.includes('板材')
- ) {
- this.isBaoyue = true;
- }
- this.visible = true;
- await this.initData();
- this.formData.bizType = '1'; // 生产入库
- this.formData.extInfo.assetType = row.rootCategoryLevelId;
- this.title = row.categoryLevelName;
- this.selectEquiType = row.rootCategoryLevelId;
- this.isTask = true;
- this.pickerRow = row;
- this.formData.sourceBizNo = row.code;
- if (this.warehousingMaterialList.length == 0) {
- this.createDataByWrap(row);
- }
- },
- async createDataByWrap(wrapData) {
- let list = deepClone(wrapData);
- const batchNo = await getCode('lot_number_code'); // 生成批次号
- let sameItemWraplist = []; // 储存分类数据
- let sameItemWrapInfolist = []; // 用来判断去重
- // 先过滤同一种物品下面包装
- list.detailList.forEach((item) => {
- if (sameItemWraplist.length > 0) {
- let filterArr = sameItemWrapInfolist.filter(
- (it) =>
- item.categoryCode == it.categoryCode &&
- item.quantity == it.quantity
- );
- if (filterArr.length > 0) {
- sameItemWraplist[filterArr[0].index].push(item);
- } else {
- sameItemWraplist.push([item]);
- sameItemWrapInfolist.push({
- categoryCode: item.categoryCode,
- quantity: item.quantity,
- index: sameItemWrapInfolist.length
- });
- }
- } else {
- sameItemWraplist.push([item]);
- sameItemWrapInfolist.push({
- categoryCode: item.categoryCode,
- quantity: item.quantity,
- index: 0
- });
- }
- });
- // 添加包装批次号丶包装编码丶包装数量
- const onlyCodeList = await outin.getAssetNum({
- assetCode: list.detailList[0].categoryCode,
- batchNum: batchNo,
- num: list.detailList.length
- });
- Promise.all(
- sameItemWraplist.map(async (goodsItem) => {
- goodsItem = goodsItem.map((wrapItem) => {
- return {
- ...wrapItem,
- assetCode: wrapData.categoryCode,
- assetName: wrapData.categoryName,
- manualBatchNo: wrapData.manualBatchNo,
- batchNo,
- barcodes: wrapItem.sendCode,
- weight: this.isBaoyue?0:wrapItem.packingWeight,
- initWeight: wrapItem.packingWeight,
- weightUtil: wrapItem.weightUnit,
- engrave: wrapItem.extInfo.engrave,
- materielCode: wrapItem.extInfo.materielCode,
- clientCode: wrapItem.extInfo.clientCode,
- num: this.isBaoyue ?this.tableHandle(wrapItem):wrapItem.quantity,
- isPack: false,
- packingCount: this.isBaoyue ? wrapItem.quantity : 1,
- minPackingCount:this.isBaoyue?this.tableHandle(wrapItem):wrapItem.quantity,
- onlyCode: onlyCodeList.shift().onlyCode,
- result: '0',
- status: '1',
- modelType: wrapData.modelType,
- specification: wrapData.specification,
- brandNum: wrapData.brandNum
- };
- });
- console.log(goodsItem);
- return goodsItem;
- })
- ).then((sameItemWraplist) => {
- console.log(sameItemWraplist.flat());
- console.log(sameItemWraplist);
- console.log(sameItemWrapInfolist);
- this.warehousingMaterialList = sameItemWraplist.map((goodsItem) => {
- return {
- assetCode: wrapData.categoryCode,
- assetName: wrapData.categoryName,
- manualBatchNo: wrapData.manualBatchNo,
- modelType: wrapData.modelType,
- specification: wrapData.specification,
- brandNum: wrapData.brandNum,
- batchNo,
- categoryId: goodsItem[0].categoryId,
- minPackingCount: this.isBaoyue ?( this.tableHandle(wrapData)/wrapData.totalPackage).toFixed(5) : goodsItem[0].num,
- outInNum: this.isBaoyue ?wrapData.totalPackage:goodsItem.length,
- minPackUnit: goodsItem[0].packingUnit,
- measuringUnit: goodsItem[0].measuringUnit,
- weight: this.isBaoyue?0:goodsItem.reduce((num, pre) => (num += pre.weight), 0),
- weightUnit: goodsItem[0].weightUnit,
- univalence: wrapData.univalence > 0 ? wrapData.univalence : '',
- warehouseId: goodsItem[0].warehouseId,
- houseList: [],
- warehouseLedgerDetails: goodsItem
- };
- });
- });
- },
- // //宝悦换算
- tableHandle(data) {
- console.log(data,'dsdsds')
- let modelArr = data.specification.split('*');
- let modelLong = modelArr[0]; // model规格长度
- let modeWide = modelArr[1]; // model规格宽度
- let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
-
- return (
- (Number(data.quantity||data.outInNum||data.totalPackage) * modelLong * modeWide * modeHight) /
- 1000000
- ).toFixed(5);
- },
- // 物品类型选择
- codeListValue(val) {
- this.formData.extInfo.assetType = val.id || val;
- this.$forceUpdate();
- this.title = val?.name;
- this.selectEquiType = val?.id || val;
- },
- //计算金额
- calcSumTotal(PackingCount, outInNum, univalence) {
- //最小包装单元,包装数量,单价
- const total = {
- PackingCount: Number(PackingCount > 0 ? PackingCount : 0),
- outInNum: Number(outInNum > 0 ? outInNum : 0),
- univalence: Number(univalence == undefined ? 0 : univalence)
- };
- return Number(
- this.$math.format(
- total.PackingCount * total.outInNum * total.univalence,
- 14
- )
- );
- },
- handleRowUnit(row) {
- return row.measuringUnit;
- },
- rowClass({ row, column, rowIndex, columnIndex }) {
- if (rowIndex === 1) {
- return {
- display: 'none',
- background: '#EEEEEE',
- border: 'none'
- };
- }
- return { background: '#EEEEEE', border: 'none' };
- },
- // 仓库编辑
- handleWareHouse(row, idx) {
- this.$refs.wareHouseDailogRef.open(row, idx, true);
- },
- // 入库操作
- listEdit(row) {
- this.$set(row, 'isSave', false);
- // row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
- // row.warehouseLedgerDetails = [];
- // // 重置重量
- // this.packNum(row, row.outInNum);
- // // 清空物料明细防止数据错乱
- // if (this.isSplit && this.resultArray?.length > 0) {
- // this.handleIsDetail(false);
- // }
- },
- // 产品单个保存
- listSave(row, index) {
- // 清空物料明细防止数据错乱
- if (this.isSplit && this.resultArray?.length > 0) {
- this.handleIsDetail(false);
- }
- const fileds = [
- // `warehousingMaterialList.${index}.cargoSpaceCode`,
- // `warehousingMaterialList.${index}.batchNo`,
- `warehousingMaterialList.${index}.houseList`
- ];
- if (this.formData.bizType == 1) {
- // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
- } else if (this.formData.bizType == 2) {
- // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
- }
- if (this.formData.bizType != 5) {
- // fileds.push(
- // ...[
- // `warehousingMaterialList.${index}.outInNum`,
- // `warehousingMaterialList.${index}.minPackingCount`
- // ]
- // );
- } else if (
- this.warehousingMaterialList.some(
- (i) => !i.selfWarehouseLedgerDetails?.length
- )
- ) {
- this.$message.error('请选择资产编号!');
- return;
- }
- Promise.all(
- fileds.map(
- (item) =>
- new Promise(async (resolve, rej) => {
- this.$refs.warehousingMaterialListRef.validateField(
- item,
- (err) => {
- if (err) {
- rej(err);
- } else {
- resolve();
- }
- }
- );
- })
- )
- )
- .then((res) => {
- console.log('-------------');
- this.$set(row, 'isSave', true);
- // this.createMaterialCode(row);
- })
- .catch((err) => {
- this.$message.error('请填入必填项!');
- });
- },
- // 产品批量保存
- listSaveArrs() {
- // 已经拆分(还原到未拆封编辑状态)
- if (this.isSplit && this.resultArray.length > 0) {
- this.handleIsDetail(false);
- }
- const rows = this.warehousingMaterialList;
- const indexes = Array.from(
- { length: this.warehousingMaterialList.length },
- (_, index) => index
- );
- let showMessage = true;
- rows.forEach((row, i) => {
- const index = indexes[i];
- const fileds = [
- // `warehousingMaterialList.${index}.cargoSpaceCode`,
- // `warehousingMaterialList.${index}.batchNo`,
- `warehousingMaterialList.${index}.houseList`
- ];
- if (this.formData.bizType == 1) {
- // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
- } else if (this.formData.bizType == 2) {
- // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
- }
- if (this.formData.bizType != 5) {
- // fileds.push(
- // ...[
- // `warehousingMaterialList.${index}.outInNum`,
- // `warehousingMaterialList.${index}.minPackingCount`
- // ]
- // );
- } else if (
- this.warehousingMaterialList.some(
- (i) => !i.selfWarehouseLedgerDetails?.length
- )
- ) {
- this.$message.error('请选择资产编号!');
- return;
- }
- Promise.all(
- fileds.map(
- (item) =>
- new Promise(async (resolve, rej) => {
- this.$refs.warehousingMaterialListRef.validateField(
- item,
- (err) => {
- if (err) {
- rej(err);
- } else {
- resolve();
- }
- }
- );
- })
- )
- )
- .then((res) => {
- this.$set(row, 'isSave', true);
- // this.createMaterialCode(row);
- })
- .catch((err) => {
- if (showMessage) {
- showMessage = false;
- this.$message.error('请填入必填项!');
- }
- });
- });
- },
- // 批量设置生产日期
- handleSelectionChange(val) {
- this.materialCodeReqListSelected = val;
- },
- dateSetting() {
- if (!this.materialCodeReqListSelected.length) {
- return this.$message.error(`请选择${this.title}明细!`);
- }
- this.dateVisible = true;
- },
- dateConfirm() {
- this.materialCodeReqListSelected.forEach((item) => {
- this.$set(item, this.curDateType, this.batchTime);
- });
- this.dateVisible = false;
- },
- //入库明细删除
- listDel(row, index) {
- this.warehousingMaterialList.splice(index, 1);
- if (this.isSplit && this.resultArray?.length > 0) {
- this.handleIsDetail(false);
- }
- },
- // 入库明细生成条码信息
- async createMaterialCode(row) {
- // 添加相同物品、批次号重新更新明细 原料编码
- const list = this.warehousingMaterialList.filter(
- (i) =>
- i.assetCode === row.assetCode && i.batchNo === row.batchNo && i.isSave
- );
- const num = list.reduce((num, pre) => {
- num += row.isUnpack
- ? pre.outInNum * pre.minPackingCount
- : pre.outInNum - 0;
- return num;
- }, 0);
- const nums = list.reduce((num, pre) => {
- num += pre.outInNum * pre.minPackingCount;
- return num;
- }, 0);
- const res = await outin.getAssetNum({
- assetCode: row.assetCode,
- batchNum: row.batchNo,
- num: num
- });
- // row.measuringUnit == 'PCS' ? nums :
- list.forEach((item) => {
- if (item.warehouseLedgerDetails?.length) {
- item.warehouseLedgerDetails.forEach((i) => {
- i.onlyCode = res.shift().onlyCode;
- });
- } else {
- this.$set(
- item,
- 'warehouseLedgerDetails',
- Array.from(
- new Array(
- item.isUnpack
- ? item.outInNum * item.minPackingCount
- : // : item.measuringUnit == 'PCS'
- // ? +item.outInNum * parseInt(item.minPackingCount)
- +item.outInNum
- ),
- (val, idx) => {
- return {
- ...item,
- onlyCode: res.shift().onlyCode,
- bizStatus: 1,
- contentImage: []
- };
- }
- )
- );
- }
- });
- // 添加相同物品,重复批次号 重新更新明细 包装编码
- const batchList = this.warehousingMaterialList.filter(
- (i) => i.batchNo === row.batchNo && i.isSave
- );
- if (batchList.length) {
- const num = batchList.reduce((num, pre) => {
- num += +pre.outInNum;
- return num;
- }, 0);
- const res1 = await outin.getAssetNum({
- batchNum: row.batchNo,
- num
- });
- if (res1) {
- batchList.forEach((item) => {
- let num = res1.shift()?.num;
- let minPackingCount = item.minPackingCount;
- if (item.warehouseLedgerDetails?.length) {
- item.warehouseLedgerDetails.forEach((i, index) => {
- this.$set(i, 'num', num);
- if (row.code == i.code) {
- if (item.measuringUnit == item.weightUnit) {
- this.$set(i, 'weight', item.minPackingCount);
- this.$set(i, 'initWeight', item.minPackingCount);
- } else {
- this.$set(
- i,
- 'weight',
- Number(
- this.$math.format(
- 1 * item.minPackingCount * item.netWeight,
- 14
- )
- )
- );
- this.$set(
- i,
- 'initWeight',
- Number(
- this.$math.format(
- 1 * item.minPackingCount * item.netWeight,
- 14
- )
- )
- );
- }
- }
- this.$set(i, 'weightUtil', item.weightUnit);
- this.$set(i, 'packingCount', 1);
- this.$set(i, 'packingUnit ', item.packingUnit);
- this.$set(i, 'minPackingCount ', item.minPackingCount);
- this.$set(i, 'measuringUnit', item.measuringUnit);
- this.$set(i, 'isPack', false);
- console.log('inboundType------------', this.inboundType);
- if (this.inboundType == '1') {
- // 生产性采购(未检)
- this.$set(i, 'result', '');
- this.$set(i, 'status', '0');
- } else {
- // 非生产性采购(已检合格)
- this.$set(i, 'result', '0');
- this.$set(i, 'status', '1');
- }
- if (!item.isUnpack) {
- if (index < item.warehouseLedgerDetails.length - 1) {
- num = res1.shift()?.num;
- }
- } else {
- // 拆包的包装编码一致
- minPackingCount--;
- if (
- minPackingCount === 0 &&
- index < item.warehouseLedgerDetails.length - 1
- ) {
- minPackingCount = item.minPackingCount;
- num = res1.shift()?.num;
- }
- }
- });
- }
- });
- }
- }
- },
- // 包装批量保存
- wrapListSave() {
- // 批量修改包装明细
- this.isWeight = false;
- this.bulkEditingWrap();
- this.$nextTick(() => {
- this.isWeight = true;
- });
- },
- // 物料批量保存
- materialListSave() {
- this.resultArray.forEach((item) => {
- if (!item.isPack) {
- this.materialBtn(item);
- }
- });
- },
- // 入库
- save() {
- this.$refs.formName.validate(async (valid) => {
- if (valid) {
- if (!this.warehousingMaterialList?.length) {
- return this.$message.error('请添加入库明细!');
- } else if (
- this.warehousingMaterialList.some((item) => !item.isSave)
- ) {
- return this.$message.error('请保存入库明细!');
- }
- // 默认全部保存
- // if (this.resultArray?.length > 0) {
- // // 物料批量保存
- // this.materialListSave();
- // } else {
- // // 包装批量保存
- // this.wrapListSave();
- // }
- this.formatWarehouseMaterialList();
- let arr = this.warehousingMaterialList.map((item) => {
- console.log(item, 'item');
- return {
- netWeight: item.netWeight > 0 ? item.netWeight : 0,
- num: item.num > 0 ? item.num : 0,
- manualBatchNo: item.manualBatchNo,
- batchNo: item.batchNo,
- categoryId: item.categoryId,
- count:
- item.outInNum > 0 && item.minPackingCount > 0
- ? this.$math.format(
- parseInt(item.outInNum) * parseInt(item.minPackingCount),
- 14
- )
- : 0,
- minPackingCount:
- item.minPackingCount > 0 ? item.minPackingCount : 0,
- packingCount: item.outInNum > 0 ? item.outInNum : 0,
- price: item.univalence > 0 ? item.univalence : 0,
- outInDetailRecordAddPOList: item.warehouseLedgerDetails,
- manualBatchNo: item.manualBatchNo,
- position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
- remark: '',
- pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
- pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
- totalMoney:
- item.outInNum > 0 &&
- item.minPackingCount > 0 &&
- item.univalence > 0
- ? this.$math.format(
- item.outInNum * item.minPackingCount * item.univalence,
- 14
- )
- : 0,
- weightUnit: item.weightUnit,
- customCode: item.customCode,
- supplierCode: item.supplierCode,
- weight: item.weight > 0 ? item.weight : 0,
- houseList: [
- `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`
- ]
- };
- });
- arr.forEach((item) => {
- if (item.outInDetailRecordAddPOList.length > 0) {
- let list = item.outInDetailRecordAddPOList.map((it) => {
- return this.formatOutInDetailRecordAddPO(it, item);
- });
- item.outInDetailRecordAddPOList = list;
- }
- });
- let obj = { ...this.formData, type: 1 };
- obj.outInDetailAddPOList = arr;
- obj.storageSource = 1;
- this.isLoading = true;
- outin
- .save(obj)
- .then( async (res) => {
- if (res.code == 0) {
- await updateApprovalStatus(this.pickerRow.id)
- this.$emit('success')
- this.isLoading = false;
- this.visible = false;
- this.$message.success('入库成功!');
- }
- })
- .catch((err) => {
- this.isLoading = false;
- });
- }
- });
- },
- // 格式化产品信息入库数据
- formatWarehouseMaterialList() {
- for (let key in this.warehousingMaterialList) {
- for (let k in this.warehousingMaterialList[key].houseList) {
- let house = this.warehousingMaterialList[key].houseList[k];
- this.warehousingMaterialList[key].warehouseName = house.warehouseName;
- this.warehousingMaterialList[key].areaName = house.areaName;
- this.warehousingMaterialList[key].shelfCode = house.shelfCode;
- this.warehousingMaterialList[key].cargoSpaceCode =
- house.cargoSpaceCode;
- this.warehousingMaterialList[key].warehouseId = house.warehouseId;
- this.warehousingMaterialList[key].areaId = house.areaId;
- this.warehousingMaterialList[key].shelfId = house.shelfId;
- this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
- this.warehousingMaterialList[key].num = house.num;
- }
- }
- },
- // 格式化包装明细入库数据
- formatOutInDetailRecordAddPO(it, item) {
- return {
- code: it.onlyCode,
- dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
- dateValue: it[this.curDateType],
- minUnit: it.minPackingCount,
- minPositionId: it.cargoSpaceId,
- minPackingCount: it.minPackingCount,
- name: it.assetName,
- pathIds: item.pathIds,
- unit: it.unit,
- barcodes: it.barcodes,
- manualBatchNo: it.manualBatchNo,
- packageNo: it.num,
- clientCode: it.clientCode,
- materielCode: it.materielCode,
- weight: it.weight,
- weightUtil: it.weightUtil,
- engrave: it.engrave,
- materialDetails: this.materialDetails(it.onlyCode),
- packingCount: it.packingCount,
- status: it.status,
- result: it.result
- };
- },
- // 过滤物料明细入库数据
- materialDetails(onlyCode) {
- return this.resultArray.filter((item) => item.onlyCode === onlyCode);
- },
- // 添加物品明细
- addProduct(val) {
- // 已经拆分(还原到未拆封编辑状态)
- if (this.isSplit && this.resultArray.length > 0) {
- this.handleIsDetail(false);
- }
- this.onSelectTableData(val);
- },
- //添加产品明细
- async onSelectTableData(val) {
- const res = await getCode('lot_number_code');
- this.warehousingMaterialList.push(
- ...val.map((next) => {
- next.batchNo = res;
- let cur = {};
- next.realInventoryAmount = next.realInventoryAmount || 0;
- cur = {
- ...next,
- cargoSpaceCode: '', //货位编码
- cargoSpaceId: '', //货位id
- shelfId: '', //货架id
- shelfCode: '', //货架名称
- areaId: '', //库区id
- areaName: '', //库区名称
- warehouseId: '', //仓库id
- warehouseName: '', //仓库名称
- assetType: this.formData.extInfo.assetType,
- expirationDate: '',
- outInNum: '',
- minPackingCount: '',
- bizStatus: 1,
- contentImage: [],
- warehouseLedgerDetails: [],
- houseList: []
- };
- return cur;
- })
- );
- },
- async initData() {
- const { data } = await allCategoryLevel();
- this.codeList = data;
- console.log(this.codeList, 'codeList--------------');
- const res = await warehouseDefinition.tree();
- const info = await getLoginUser();
- let obj = res.find(
- (item) => item.id === info.deptIds[info.deptIds.length - 1]
- );
- if (!obj) return;
- this.formData.extInfo.deptCode = obj.id;
- this.formData.extInfo.deptName = obj.name;
- this.formData.extInfo.createUserName = info.name;
- this.formData.createUserId = info.id;
- },
- // 添加产品信息
- addStock() {
- if (!this.title) {
- return this.$message.error('请选择入库产品类型');
- }
- if (!this.formData.bizType) {
- return this.$message.error('请选择入库场景');
- }
- this.visibleDialog = true;
- },
- upload(data) {
- this.formData.contentImage = data;
- this.$refs.formName.validateField('contentImage');
- },
- houseData(argum, idx) {
- this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
- },
- },
- watch: {
- // 解决右侧悬浮操作栏不对称问题
- warehousingMaterialList: {
- handler() {
- this.$nextTick(() => {
- this.$refs.warehousingMaterialListTable?.doLayout();
- });
- },
- deep: true
- },
- // 解决右侧悬浮操作栏不对称问题
- materialCodeReqList: {
- handler() {
- this.$nextTick(() => {
- this.$refs.materialCodeReqListTable?.doLayout();
- });
- },
- deep: true
- },
-
- // 解决右侧悬浮操作栏不对称问题
- resultArray: {
- handler() {
- this.$nextTick(() => {
- this.$refs.resultArrayTable?.doLayout();
- });
- },
- deep: true
- }
- }
-
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep.form-table {
- .el-form-item {
- margin-bottom: 0;
- }
- .el-input__inner {
- padding: 0 10px;
- }
- ::-webkit-scrollbar {
- width: 8px;
- height: 8px;
- background-color: transparent;
- }
- }
- .p20 {
- padding: 20px;
- }
- .el-select,
- .el-date-editor {
- width: 100%;
- }
- .el-form-item {
- margin-bottom: 22px;
- }
- .material {
- margin-top: 20px;
- .flex {
- display: flex;
- justify-content: space-between;
- font-size: 14px;
- align-items: center;
- .red {
- color: #ff4949;
- }
- }
- }
- .mt10 {
- margin-top: 10px;
- }
- .mt20 {
- margin-top: 20px;
- }
- .center {
- text-align: center;
- }
- .switch_left li {
- border-right: 1px solid rgba(222, 222, 222, 1);
- border-left: 1px solid rgba(222, 222, 222, 1);
- }
- .fontOmitted {
- text-overflow: ellipsis;
- overflow: hidden;
- word-break: break-all;
- white-space: nowrap;
- }
- .table-fixed {
- .el-table__fixed-right {
- height: 100% !important;
- }
- .el-table__fixed-left {
- height: 100% !important;
- }
- .el-table__fixed {
- height: 100% !important;
- }
- }
- </style>
|