| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088 |
- <template>
- <view class="mainBox">
- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="新增入库单" @clickLeft="back">
- <!-- @clickRight="handleScan"
- right-icon="scan"
- > -->
- <!--右菜单-->
- <template slot="float">
- <!-- <view class="nav-icon-caozuo rightNav" @click="getsure">
- <u-button type="success" size="small" class="u-reset-button" text="确定"></u-button>
- </view> -->
- </template>
- </uni-nav-bar>
- <u-form labelPosition="left" :model="formData" :rules="rules" ref="formRef" labelWidth="260" labelAlign="right" class="baseForm">
- <u-form-item label="物品类型" class="required-form" borderBottom prop="assetType">
- <view class="assetType_box" @click="openPicker">{{ assetTypeName ? assetTypeName : '请选择产品类型' }}</view>
- </u-form-item>
- <u-form-item label="入库场景" class="required-form" prop="bizType" borderBottom>
- <uni-data-select v-model="formData.bizType" :localdata="sceneState"></uni-data-select>
- <!-- <picker :disabled="!!(productList && productList.length)" @change="e => handlePicker(e, sceneState, 'bizType')" :value="pickerIndex" :range="sceneState" range-key="text">
- <u-input :value="sceneStateFilter(formData.bizType)" :disableColor="!!(productList && productList.length) ? '#F5F7FA' : '#fff'" placeholder="请选择" disabled type="select" />
- </picker>
- <u-icon slot="right" name="arrow-right"></u-icon> -->
- </u-form-item>
- <u-form-item label="来源单据" prop="documentSource" borderBottom>
- <u-input type="text" placeholder="请输入" v-model="formData.sourceBizNo" @click.native="goToRequisition" />
- </u-form-item>
- <u-form-item label="入库时间" prop="storageTime" borderBottom>
- <view class="assetType_box" @click="timeShow = true">{{ storageTime ? formatter(storageTime) : '请选择' }}</view>
- </u-form-item>
- <u-form-item label="入库登记人" prop="createUserName" borderBottom>
- <u-input disableColor="#ffffff" :value="formData.extInfo.createUserName" placeholder="请选择" disabled type="text" />
- </u-form-item>
- <u-form-item label="送货人" prop="deliveryName" borderBottom>
- <u-input type="text" placeholder="请输入" v-model="formData.fromUser" />
- </u-form-item>
- <u-form-item label="送货人联系方式" prop="deliveryPhone" borderBottom>
- <u-input type="text" placeholder="请输入" v-model="formData.extInfo.deliveryPhone" />
- </u-form-item>
- <u-form-item label="备注" prop="remark" borderBottom>
- <u-input disableColor="#ffffff" v-model="formData.remark" placeholder="请输入内容" type="text" />
- </u-form-item>
- </u-form>
- <uni-collapse ref="collapse" v-model="collapseOpen">
- <uni-collapse-item :typeOpen="1" title="" name="collapse1" :open="true" :key="detailOpen" :show-animation="true">
- <template v-slot:title>
- <view class="detail-box">
- <view data-v-41027c34="" class="uni-collapse-item__title-wrap">
- <view data-v-41027c34="" class="uni-collapse-item__title-box uni-collapse-item__title-box-base">
- <text data-v-41027c34="" class="tag tag-base"><text></text></text>
- <text data-v-41027c34="" class="uni-collapse-item__title-text"><text>入库明细</text></text>
- </view>
- </view>
- <!-- <u-button type="primary" size="small" text="扫码添加" @click.native.stop="selectType"></u-button> -->
- <u-button type="success" size="small" class="selectEnterType" text="手动添加" @click.native.stop="selectType"></u-button>
- </view>
- </template>
- <u-form
- labelPosition="left"
- :model="{ productList: productList }"
- ref="lisrFormRef"
- labelWidth="150"
- :rules="listRules"
- errorType="none"
- labelAlign="right"
- :labelStyle="{
- fontSize: '28rpx'
- }">
- <view class="listContent">
- <view class="listBox" v-for="(item, index) in productList" :key="index">
- <view class="listTit">
- <view class="name">{{ item.categoryName }}</view>
- <view class="btn">
- <u-button v-if="item.isSave" type="primary" size="small" :hairline="true" text="编辑" @click="listEdit(index)"></u-button>
- <u-button v-else type="primary" size="small" :hairline="true" text="保存" @click="listSave(item, index)"></u-button>
- <u-button type="error" size="small" :hairline="true" text="删除" @click="getDelete(index)"></u-button>
- </view>
- </view>
- <view class="listCont" :class="{ save: item.isSave }">
- <view class="item w100">
- <u-form-item :label="`物品编码`">
- {{ item.categoryCode }}
- </u-form-item>
- </view>
- <view class="item w100">
- <u-form-item label="包装规格" prop="packingSpecificationLabel">
- <u-tag style="margin-right: 5rpx" v-for="ite in item.packingSpecificationLabel" :text="ite"></u-tag>
- </u-form-item>
- </view>
- <view class="item">
- <u-form-item label="批次号" :prop="`productList.${index}.batchNo`" required>
- <u--input :disabled="item.isSave" placeholder="请输入" border="surround" v-model="item.batchNo"></u--input>
- </u-form-item>
- </view>
- <view class="item">
- <u-form-item label="数量" :prop="`productList.${index}.packingQuantity`" required>
- <u--input :disabled="item.isSave" placeholder="请输入" border="surround" v-model="item.packingQuantity" @change="computeNum(item, index, true)"></u--input>
- </u-form-item>
- </view>
- <view class="item">
- <u-form-item label="包装单位" :prop="`productList.${index}.packingUnit`" required>
- <u--input :disabled="item.isSave" placeholder="请选择" border="surround" v-model="item.packingUnit" @click.native="showPackingUnitPicker(item, index)"></u--input>
- </u-form-item>
- </view>
- <view class="item">
- <u-form-item label="仓库" :prop="`productList.${index}.warehouseId`" required>
- <u--input :disabled="item.isSave" placeholder="请选择" border="surround" v-model="item.warehouseName" @click.native="showWarehousePicker(index)"></u--input>
- </u-form-item>
- </view>
- <view class="item w100">
- <u-form-item label="供应商" :prop="`productList.${index}.supplierName`">
- <u--input :disabled="item.isSave" placeholder="请选择" border="surround" v-model="item.supplierName" @click.native="showSupplierPicker(item, index)"></u--input>
- </u-form-item>
- </view>
- <view class="item">
- <u-form-item label="计量数量" prop="measureQuantity">{{ item.measureQuantity }}</u-form-item>
- </view>
- <view class="item">
- <u-form-item label="计量单位" prop="measureUnit">{{ item.measureUnit }}</u-form-item>
- </view>
- <view class="item">
- <u-form-item label="重量" prop="weight">{{ item.weight }}</u-form-item>
- </view>
- <view class="item">
- <u-form-item label="重量单位" prop="weightUnit">{{ item.weightUnit }}</u-form-item>
- </view>
- <view class="item">
- <u-form-item label="是否拆包" prop="isUnpack">{{ item.isUnpack ? '是' : '否' }}</u-form-item>
- </view>
- </view>
- <view class="selectTime" v-if="item.outInDetailRecordRequestList.length > 0">
- <view class="title">包装列表</view>
- <view class="timeBox">
- <u-button class="firstBtn" size="small" type="primary" text="选择时间类型" @click="timeTypeShow = true"></u-button>
- <u-button type="warning" size="small" :text="`批量设置${curDateTypeLabel[curDateType]}`" @click="typeTimeClick(index)"></u-button>
- </view>
- </view>
- <u-list @scrolltolower="scrolltolower" class="z_list" style="height: 100% !important">
- <view class="material rx-ss" v-for="(ite, idx) in item.outInDetailRecordRequestList" :key="idx">
- <!-- <view class="left rx-ss" @click="deletePacking(index, idx)">
- <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
- </view> -->
- <view class="content_table">
- <view class="item">
- <view class="lable rx-cc">序号</view>
- <view class="content">{{ idx + 1 }}</view>
- </view>
- <view class="item">
- <view class="lable rx-cc">包装编码</view>
- <view class="content">{{ ite.packageNo }}</view>
- </view>
- <view class="item">
- <view class="lable rx-cc">包装数量({{ ite.packingUnit }})</view>
- <view class="content">{{ ite.packingQuantity }}</view>
- </view>
- <view class="item">
- <view class="lable rx-cc">计量数量({{ ite.measureUnit }})</view>
- <view class="content">{{ ite.measureQuantity }}</view>
- </view>
- <view class="item">
- <view class="lable rx-cc">物料代号</view>
- <view class="content input_box"><u--input clearable placeholder="请输入" border="surround" v-model="ite.materielDesignation"></u--input></view>
- </view>
- <view class="item">
- <view class="lable rx-cc">客户代号</view>
- <view class="content input_box"><u--input clearable placeholder="请输入" border="surround" v-model="ite.clientCode"></u--input></view>
- </view>
- <view class="item">
- <view class="lable rx-cc">刻码</view>
- <view class="content input_box"><u--input clearable placeholder="请输入" border="surround" v-model="ite.engrave"></u--input></view>
- </view>
- <view class="item">
- <view class="lable rx-cc">重量({{ ite.weightUnit }})</view>
- <view class="content input_box">
- <u--input clearable placeholder="请输入" border="surround" v-model="ite.weight" @change="weightInput($event, ite, index)"></u--input>
- </view>
- </view>
- <view class="item">
- <view class="lable rx-cc">质检状态</view>
- <view class="content" @click="statusClick(index, idx)">
- {{ qualityResults[ite.status] }}
- </view>
- </view>
- <view class="item">
- <view class="lable rx-cc">{{ curDateTypeLabel[curDateType] }}</view>
- <view class="content input_box">
- <u--input clearable placeholder="请选择" border="surround" v-model="ite[curDateType]" @click.native="typeTimeClick(index, idx)"></u--input>
- </view>
- </view>
- </view>
- </view>
- </u-list>
- </view>
- </view>
- </u-form>
- </uni-collapse-item>
- </uni-collapse>
- <view class="footBox">
- <view class="reg" @click="submit">
- <uni-icons custom-prefix="iconfont" size="20" color="#fff"></uni-icons>
- 提交
- </view>
- </view>
- <!-- 选择物品类型 -->
- <ba-tree-picker ref="treePicker" :multiple="true" @select-change="confirm" title="选择物品类型" :localdata="goodsLists" valueKey="id" textKey="name" childrenKey="child" />
- <!-- 选择入库时间 -->
- <u-datetime-picker @confirm="timeConfirm" @cancel="timeCancel" :show="timeShow" v-model="storageTime" mode="datetime"></u-datetime-picker>
- <!-- 选择包装单位 -->
- <u-picker
- :show="packingUnitsShow"
- visibleItemCount="10"
- :columns="currentPackingSpecificationOption"
- keyName="conversionUnit"
- @confirm="selectPackingUnitInfo"
- @cancel="packingUnitsShow = false"
- title="选择包装单位"></u-picker>
- <!-- 选择供应商单位 -->
- <u-picker
- :show="suppliersShow"
- visibleItemCount="10"
- :columns="currentSupplierListOption"
- keyName="name"
- @confirm="selectSuppliersInfo"
- @cancel="suppliersShow = false"
- title="选择供应商"></u-picker>
- <!-- 选择仓库 -->
- <u-picker :show="warehouseShow" visibleItemCount="10" :columns="warehouseListOption" keyName="name" @confirm="selectWarehouseInfo" @cancel="warehouseShow = false" title="选择仓库"></u-picker>
- <!-- 选择时间类型 -->
- <u-picker :show="timeTypeShow" visibleItemCount="10" :columns="timeTypeOption" keyName="name" @confirm="selectTimeTypeInfo" @cancel="timeTypeShow = false" title="选择时间类型"></u-picker>
- <!-- 选择生产/采购日期 -->
- <u-datetime-picker @confirm="typeTimeConfirm" @cancel="typeTimeShow = false" :show="typeTimeShow" v-model="currentTypeTime" mode="datetime"></u-datetime-picker>
- <!-- 选择质检状态 -->
- <u-picker :show="statusShow" visibleItemCount="10" :columns="qualityResultsOption" keyName="label" @confirm="selectStautsInfo" @cancel="statusShow = false" title="选择质检状态"></u-picker>
- </view>
- </template>
- <script>
- // import ScanCode from '@/components/ScanCode.vue'
- import {
- getTreeByGroup,
- contactQueryByCategoryIdsAPI,
- getCode,
- getCategoryPackageDisposition,
- getWarehouseList,
- getAssetNum,
- storage,
- qualityInspectionTwo,
- submitTwo
- } from '@/api/warehouseManagement'
- import { getByCode } from '@/api/pda/common'
- import dayjs from 'dayjs'
- import { sceneState } from '../common'
- import { post, postJ, get, getJ } from '@/utils/api.js'
- import WarehouseChoose from '@/components/WarehouseChoose'
- import { warehousingType, inputStatus, emergencyState, warehousingMaterialListTable, getDictName, materialType } from '../enum.js'
- import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
- // import addDetails from '@/components/addDetails'
- import UploadFileNew from '@/components/UploadFileNew'
- // import { getRuleNo } from '@/utils/utils.js'
- import { tableHeader } from '../common'
- // import dictMixins from '@/mixins/dictMixins.js'
- export default {
- components: {
- WarehouseChoose,
- baTreePicker,
- UploadFileNew
- },
- // mixins: [dictMixins],
- data() {
- return {
- goodsLists: [], // 物品类型
- assetTypeName: '', // 物品类型名称
- timeShow: false,
- packingSpecificationOption: [], // 包装规格
- currentPackingSpecificationOption: [], // 当前包装规格
- currentSupplierListOption: [], // 当前供货商
- warehouseListOption: [], // 仓库列表
- currentTypeTime: Number(new Date()), // 当前时间类型的时间
- storageTime: '', // 入库时间
- currentProductIndex: null, // 当前产品索引
- currentPackingIndex: null, // 当前包装索引
- packingUnitsShow: false,
- typeTimeShow: false,
- suppliersShow: false,
- warehouseShow: false,
- timeTypeShow: false,
- statusShow: false,
- dictCodeList: [], // 字典列表
- curDateType: 'purchaseDate',
- qualityResultsOption: [
- [
- {
- label: '合格',
- value: 1
- },
- {
- label: '不合格',
- value: 2
- }
- ]
- ], // 质检状态 0未检 1已检
- qualityResults: {
- 1: '合格',
- 2: '不合格'
- }, // 质检结果 1合格 2不合格
- curDateTypeLabel: {
- purchaseDate: '采购日期',
- productionDate: '生产日期'
- },
- timeTypeOption: [
- [
- {
- name: '采购日期',
- prop: 'purchaseDate'
- },
- {
- name: '生产日期',
- prop: 'productionDate'
- }
- ]
- ], // 时间类型
- collapseOpen: 'collapse1',
- emergencyState,
- warehousingType,
- materialType,
- sceneState,
- inputStatus,
- getDictName,
- detailOpen: false,
- codeOpen: false,
- deptList: [], //部门
- supplierList: [], //供应商
- formData: {
- type: 1, // 入库
- bizType: '', // 入库场景
- storageTime: '', // 入库时间
- extInfo: {}, // 扩展信息
- sourceBizNo: '', // 来源单据编号
- fromUser: '', // 送货人
- remark: '' // 备注
- },
- statusList: [
- {
- id: 1,
- name: '紧急'
- },
- {
- id: 2,
- name: '中等'
- },
- {
- id: 1,
- name: '普通'
- }
- ], //紧急状态
- pickerIndex: 0,
- productList: [],
- userList: [],
- rules: {
- assetType: {
- type: 'number',
- required: true,
- message: '请选择入库产品类型',
- trigger: ['blur', 'change']
- },
- bizType: {
- type: 'number',
- required: true,
- message: '请选择入库场景',
- trigger: ['blur', 'change']
- }
- // contentImage: {
- // type: 'array',
- // required: true,
- // message: '请上传附件',
- // trigger: ['blur', 'change']
- // }
- },
- settingIndex: 0
- }
- },
- onShow() {
- // const _this = this
- // uni.$off('scancode') // 每次进来先 移除全局自定义事件监听器
- // uni.$on('scancode', function (data) {
- // uni.navigateBack({
- // delta: 1
- // })
- // _this.qrContent = data.code.trim()
- // _this.handleScan()
- // })
- this.collapseOpen = 'collapse1'
- },
- beforeDestroy() {
- uni.$off('setSelectList')
- uni.$off('requisitionSelect')
- },
- async onLoad(options) {
- await this.getListItems() // 物品类型
- await this.getwarehouseList() // 仓库列表
- await this.requireDictCode() // 字典列表
- // this.requestDict('物品类型')
- // this.getDept()
- // this.getSupplier()
- const userInfo = uni.getStorageSync('userInfo')
- console.log()
- this.formData.extInfo.createUserName = userInfo.name
- this.formData.createUserId = userInfo.name
- this.storageTime = Number(new Date())
- this.formData.storageTime = this.formatter(this.storageTime)
- // this.formData.registerId = userInfo.id
- uni.$on('setSelectList', async data => {
- if (data?.length) {
- this.formData.sourceBizNo = ''
- // 获取批次号
- 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)
- })
- 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, // 规格
- brandNum: item.brandNum, // 牌号
- batchNo: batchNo, // 批次号
- supplierListOptions: supplierList[item.id], // 供应商列表
- supplierId: '', // 供应商id
- supplierName: '', // 供应商名称
- approvalNumber: item.approvalNumber, // 批准文号
- packingSpecification: item.packingSpecification, // 包装规格
- packingSpecificationOption: this.packingSpecificationOption[index], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- minPackingQuantity: '', // 最小包装单元数量
- packingQuantity: '', // 包装数量
- packingUnit: '', // 包装单位
- measureQuantity: 0, // 计量数量
- measureUnit: item.measuringUnit, // 计量单位
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- weight: 0, // 重量
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: '', // 总价
- price: item.price, // 单价
- purpose: '', // 用途
- isUnpack: item.isUnpack, // 是否允许拆包
- outInDetailRecordRequestList: []
- }
- })
- this.productList = this.productList.concat(productList)
- console.log(this.productList, '------------------this.productList----111-----')
- setTimeout(() => {
- this.detailOpen = !this.detailOpen
- this.$refs.collapse && this.$refs.collapse.resize()
- }, 0)
- }
- })
- uni.$on('requisitionSelect', async (data, query) => {
- console.log(data)
- console.log(query)
- this.formData.sourceBizNo = query.sourceBizNo
- this.formData.bizType = query.bizType
- this.formData.extInfo.assetType = query.assetType.split(',')
- let filterArray = this.formData.extInfo.assetType.map(item => {
- return this.goodsLists.find(ite => ite.id == item).name
- })
- this.assetTypeName = Array.from(new Set(filterArray)).join('/')
- const batchNo = await getCode('lot_number_code')
- // 获取包装规格
- let packingSpecification = await getCategoryPackageDisposition({
- categoryIds: data.map(item => item.categoryId)
- })
- this.packingSpecificationOption = data.map(item => {
- return packingSpecification.filter(ite => item.categoryId == ite.categoryId).sort((a, b) => a.sort - b.sort)
- })
- this.productList = data.map((productItem, productIndex) => {
- // 显示规格
- let packingSpecificationLabel = this.packingSpecificationOption[productIndex]
- .map(item => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`
- }
- })
- .filter(item => !!item)
- return {
- ...productItem,
- index: this.productList.length + productIndex,
- isSave: productItem.outInDetailRecordRequestList?.length > 0 ? true : false,
- batchNo: batchNo, // 批次号
- warehouseIds: [productItem.warehouseId], // 仓库Id
- warehouseNames: [productItem.warehouseName], // 仓库名称
- packingSpecificationOption: this.packingSpecificationOption[productIndex], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- outInDetailRecordRequestList:
- productItem.outInDetailRecordRequestList?.length > 0
- ? productItem.outInDetailRecordRequestList.map((packingItem, packingIndex) => {
- return {
- ...packingItem,
- index: this.productList.length + productIndex + '-' + packingIndex, // 包装索引
- batchNo: batchNo, // 批次号
- parentIndex: this.productList.length + productIndex, // 物品索引
- categoryName: productItem.categoryName,
- categoryCode: productItem.categoryCode,
- materialDetailList: packingItem.materialDetailList.map((materialItem, materialIndex) => {
- return {
- ...materialItem,
- index: this.productList.length + productIndex + '-' + packingIndex + '——' + materialIndex, // 包装索引
- parentIndex: this.productList.length + productIndex + '-' + packingIndex, // 物品索引
- batchNo: batchNo, // 批次号
- categoryName: productItem.categoryName,
- categoryCode: productItem.categoryCode
- }
- })
- }
- })
- : []
- }
- })
- setTimeout(() => {
- this.detailOpen = !this.detailOpen
- this.$refs.collapse && this.$refs.collapse.resize()
- }, 0)
- })
- // 明细信息填写
- uni.$on('batchNumBack', productList => {
- if (productList?.length) {
- this.productList = productList
- }
- })
- },
- mounted() {
- // this.getAddDetails();
- },
- computed: {
- tableHeader() {
- return tableHeader(this.formData.assetType)
- },
- materialCodeReqList() {
- return this.productList.map(i => i.warehouseLedgerDetails || []).flat()
- },
- isMaterial() {
- return this.formData.assetType == 3
- },
- warehousingName() {
- return []
- this.productList = []
- return this.getDictValue('物品类型', this.formData.assetType)
- },
- listRules() {
- return this.productList.reduce((cur, pre, index) => {
- return {
- ...cur,
- [`productList.${index}.batchNo`]: {
- type: 'string',
- required: true,
- trigger: ['blur', 'change']
- },
- [`productList.${index}.packingQuantity`]: {
- type: 'number',
- required: true,
- trigger: ['blur', 'change']
- },
- [`productList.${index}.packingUnit`]: {
- type: 'string',
- required: true,
- trigger: ['blur', 'change']
- },
- [`productList.${index}.warehouseId`]: {
- type: 'string',
- required: true,
- trigger: ['blur', 'change']
- }
- }
- }, {})
- }
- },
- methods: {
- goToRequisition() {
- uni.navigateTo({
- url: '/pages/warehouse/components/requisitionList?type=' + 1
- })
- },
- // 入库
- submit() {
- if (this.productList.length <= 0) {
- uni.showToast({
- icon: 'none',
- title: '请添加产品!'
- })
- return
- }
- let boolen = this.productList.every(item => item.isSave)
- if (!boolen) {
- uni.showToast({
- icon: 'none',
- title: '请先保存所有产品信息!'
- })
- return
- }
- uni.showLoading({
- title: '保存中...'
- })
- this.formData.outInDetailList = this.productList
- let obj = uni.$u.deepClone(this.formData)
- // 处理物品类型assetType
- obj.extInfo.assetType = obj.extInfo.assetType.join(',')
- // 处理仓库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
- // 是否需要审核(0审核 1跳过审核)
- if (obj.bizType == '12') {
- obj.isSkip = 1
- } else {
- obj.isSkip = 0
- }
- // obj.isSkip = 1;
- console.log(obj)
- storage(obj)
- .then(async res => {
- console.log('入库成功', res)
- if (res.code == 0) {
- try {
- // 委外入库(非采购)
- if (obj.bizType == '12') {
- await qualityInspectionTwo({
- outInId: res.data[0]
- })
- } else {
- await submitTwo({ outInId: res.data[0] })
- }
- uni.hideLoading()
- uni.showToast({
- icon: 'none',
- title: '入库成功',
- duration: 1500
- })
- uni.navigateBack({
- delta: 1
- })
- } catch (error) {
- uni.hideLoading()
- console.log('提交流程失败', error)
- }
- }
- })
- .catch(err => {
- console.log('入库失败', err)
- uni.hideLoading()
- uni.showToast({
- icon: 'none',
- title: '入库失败',
- duration: 2000
- })
- })
- },
- // 重量限制
- weightInput(value, row, productIndex) {
- const newValue = value.replace(/[^\d.]/g, '') // 保留数字和小数点
- const decimalCount = (newValue.match(/\./g) || []).length // 计算小数点的个数
- if (row.weight < 0) {
- row.weight = 0
- } else if (row.weight > 9999) {
- row.weight = 9999
- } else {
- 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
- }
- }
- this.packingWeightCahnge(productIndex)
- },
- // 包装重量修改
- packingWeightCahnge(productIndex) {
- // 修改物品重量
- let totalWeight = this.productList[productIndex].outInDetailRecordRequestList.reduce((accumulator, currentValue) => {
- return Number(accumulator) + Number(currentValue.weight)
- }, 0)
- this.$set(this.productList[productIndex], 'weight', totalWeight)
- },
- scrolltolower() {
- console.log('滑动了~~~')
- },
- typeTimeClick(index, idx) {
- console.log('index-----', index)
- console.log('idx----', idx)
- this.currentProductIndex = index
- this.currentPackingIndex = idx > -1 ? idx : -1
- this.typeTimeShow = true
- },
- statusClick(index, idx) {
- this.currentProductIndex = index
- this.currentPackingIndex = idx > -1 ? idx : -1
- this.statusShow = true
- },
- selectStautsInfo(e) {
- this.productList[this.currentProductIndex].outInDetailRecordRequestList[this.currentPackingIndex].status = e.value[0]?.value
- this.statusShow = false
- },
- typeTimeConfirm() {
- this.typeTimeShow = false
- this.$nextTick(() => {
- console.log(this.currentPackingIndex)
- if (this.currentPackingIndex > -1) {
- // 单独
- this.productList[this.currentProductIndex].outInDetailRecordRequestList[this.currentPackingIndex][this.curDateType] = this.formatter(this.currentTypeTime)
- } else {
- // 批量
- this.productList[this.currentProductIndex].outInDetailRecordRequestList = this.productList[this.currentProductIndex].outInDetailRecordRequestList.map(item => {
- console.log(this.currentTypeTime)
- console.log(this.formatter(this.currentTypeTime))
- return {
- ...item,
- [this.curDateType]: this.formatter(this.currentTypeTime)
- }
- })
- }
- })
- },
- // 物品保存验证表单(单独)
- validateFormIndividually(index) {
- return new Promise(async resolve => {
- console.log('index----------------', index)
- let fileds = [`productList.${index}.batchNo`, `productList.${index}.packingQuantity`, `productList.${index}.packingUnit`, `productList.${index}.warehouseId`]
- Promise.all(
- fileds.map(
- item =>
- new Promise(async (res, rej) => {
- this.$refs.lisrFormRef.validateField(item, err => {
- console.log('err--', err)
- if (err?.length) {
- rej(err)
- } else {
- res(true)
- }
- })
- })
- )
- )
- .then(() => {
- resolve()
- })
- .catch(err => {
- uni.showToast({
- icon: 'none',
- title: '请填入必填项!'
- })
- })
- })
- },
- // 产品编辑
- listEdit(index) {
- this.currentProductIndex = index
- this.productList[index].isSave = false
- this.productList[index].outInDetailRecordRequestList = []
- },
- listSave(row, index) {
- console.log('index------', index)
- this.validateFormIndividually(index).then(async () => {
- console.log('通过了!!!')
- // 判断包装单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict(row.packingUnit).dictValue
- let measureBoolen = !!this.getDict(row.measureUnit).dictValue
- let packingNum = 0
- // 处理包装单位为KG类的情况
- if (packingBoolen) {
- let filterArr = row.packingSpecificationOption.filter(item => {
- return item.packageUnit == row.packingUnit && item.packageUnit != item.conversionUnit
- })
- packingNum = Math.ceil(row.packingQuantity / filterArr[0].packageCell)
- }
- // 处理包装单位不为KG类,计量单位为KG类的情况
- let measureNum = row.packingQuantity
- 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
- }
- }
- // 获取包装编码列表
- const { data } = await getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: packingBoolen ? packingNum : row.isUnpack ? (measureBoolen ? measureNum : row.measureQuantity) : row.packingQuantity
- }
- ])
- this.generateWrappers(row, index, data)
- this.$set(this.productList[index], 'isSave', true)
- })
- },
- // 获取当前时间函数
- getNowDate() {
- let date = new Date(),
- obj = {
- year: date.getFullYear(), //获取完整的年份(4位)
- month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
- strDate: date.getDate(), // 获取当前日(1-31)
- hour: date.getHours(), //获取当前小时(0 ~ 23)
- minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
- second: date.getSeconds() //获取当前秒数(0 ~ 59)
- }
- Object.keys(obj).forEach(key => {
- if (obj[key] < 10) obj[key] = `0${obj[key]}`
- })
- return obj
- },
- // 生成包装
- generateWrappers(row, productIndex, packingCodeList) {
- console.log('是否拆包----', row.isUnpack)
- console.log('包装规格----', row.packingSpecificationOption)
- console.log('计量单位----', row.measureUnit)
- console.log('包装数量----', row.packingQuantity)
- console.log('包装编码----', packingCodeList)
- let obj = this.getNowDate()
- let productionDate = ''
- let purchaseDate = ''
- if (this.formData.bizType == '1') {
- // 生产入库
- productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`
- this.curDateType = 'productionDate'
- } else if (this.formData.bizType == '2') {
- // 采购入库
- purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`
- this.curDateType = 'purchaseDate'
- }
- // 判断包装单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict(row.packingUnit).dictValue
- let measureBoolen = !!this.getDict(row.measureUnit).dictValue
- let num = row.packingQuantity
- let filterArr = []
- // 处理包装单位为KG类的情况
- if (packingBoolen) {
- 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) {
- if (measureBoolen) {
- // 处理包装单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit)
- for (; splitIndex > 1; splitIndex--) {
- // num = this.$math.format(num * row.packingSpecificationOption[splitIndex].packageCell, 14)
- num = num * row.packingSpecificationOption[splitIndex].packageCell
- }
- } else {
- console.log(row.packingSpecificationOption)
- let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit)
- console.log(splitIndex)
- for (; splitIndex > 0; splitIndex--) {
- console.log(splitIndex)
- // num = this.$math.format(num * row.packingSpecificationOption[splitIndex].packageCell, 14)
- num = num * row.packingSpecificationOption[splitIndex].packageCell
- }
- }
- } else {
- num = row.packingQuantity
- }
- }
- for (let index = 0; index < num; index++) {
- let measureQuantity = 1
- // 处理包装单位为KG类,计算每桶KG值
- if (packingBoolen) {
- // console.log(this.$math.format(filterArr[0].packageCell * (index + 1), 14))
- console.log(filterArr[0].packageCell * (index + 1))
- console.log(row.packingQuantity)
- // measureQuantity =
- // Number(row.packingQuantity) > this.$math.format(filterArr[0].packageCell * (index + 1), 14)
- // ? filterArr[0].packageCell
- // : Number(row.packingQuantity) - this.$math.format(filterArr[0].packageCell * index, 14)
- measureQuantity = Number(row.packingQuantity) > filterArr[0].packageCell * (index + 1) ? filterArr[0].packageCell : Number(row.packingQuantity) - filterArr[0].packageCell * index
- } else {
- if (!row.isUnpack) {
- if (measureBoolen) {
- // 处理包装单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit)
- for (; splitIndex > 0; splitIndex--) {
- // measureQuantity = this.$math.format(measureQuantity * row.packingSpecificationOption[splitIndex].packageCell, 14)
- measureQuantity = measureQuantity * row.packingSpecificationOption[splitIndex].packageCell
- }
- } else {
- let splitIndex = row.packingSpecificationOption.findIndex(item => item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit)
- for (; splitIndex > 0; splitIndex--) {
- console.log(splitIndex)
- // measureQuantity = this.$math.format(measureQuantity * row.packingSpecificationOption[splitIndex].packageCell, 14)
- measureQuantity = measureQuantity * row.packingSpecificationOption[splitIndex].packageCell
- }
- }
- }
- }
- let item = {
- index: row.index + '-' + index, // 包装索引
- warehouseId: row.warehouseIds[0], // 仓库id
- warehouseName: row.warehouseNames[0], // 仓库名称
- categoryName: row.categoryName, // 产品名称
- categoryCode: row.categoryCode, // 产品编码
- categoryModel: row.categoryModel, // 物品型号
- specification: row.specification, // 规格
- brandNum: row.brandNum, // 牌号
- parentIndex: row.index, // 产品索引
- batchNo: row.batchNo, // 批次号
- packageNo: packingCodeList[index].onlyCode, // 包装编码
- packingQuantity: 1, // 包装数量
- packingUnit: row.isUnpack
- ? packingBoolen
- ? filterArr[0].conversionUnit
- : measureBoolen
- ? row.packingSpecificationOption[1].conversionUnit
- : row.measureUnit
- : packingBoolen
- ? filterArr[0].conversionUnit
- : row.packingUnit,
- measureQuantity: row.isUnpack ? (packingBoolen ? measureQuantity : measureBoolen ? row.packingSpecificationOption[1].packageCell : measureQuantity) : measureQuantity, // 计量数量
- measureUnit: row.isUnpack ? (measureBoolen ? row.packingSpecificationOption[1].packageUnit : row.measureUnit) : row.measureUnit, // 计量单位
- weight: 0, // 重量
- packingSpecificationOption: row.packingSpecificationOption, // 包装规格
- weightUnit: row.weightUnit, // 重量单位
- netWeight: row.netWeight, // 净重
- barcodes: '', // 发货条码
- clientCode: '', // 客户代号
- materielDesignation: '', // 物料代号
- engrave: '', // 刻码
- isUnpack: row.isUnpack, // 是否允许拆包
- productionDate: productionDate, // 生产日期
- purchaseDate: purchaseDate, // 采购时间
- result: 1, // 结果(1合格 2不合格)
- status: 1 // 状态(0=未质检 1已质检)
- }
- let outBoolen = !!this.getDict(item.measureUnit).dictValue
- console.log('this.dictCodeList-------', this.dictCodeList)
- console.log('item.measureUnit-------', item)
- console.log('!!this.getDict(item.measureUnit).dictValue--------', this.getDict(item.measureUnit))
- if (outBoolen) {
- // 计量单位为KG类,直接替换
- item.weight = item.measureQuantity
- } else {
- // 计量单位为不为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
- })
- console.log(startIndex)
- let endIndex = item.packingSpecificationOption.findIndex(ite => item.packingUnit == ite.conversionUnit)
- console.log(endIndex)
- let total = item.packingQuantity
- for (; startIndex < endIndex; endIndex--) {
- // total = this.$math.format(item.packingSpecificationOption[endIndex].packageCell * total, 14)
- total = item.packingSpecificationOption[endIndex].packageCell * total
- }
- if (inBoolen) {
- // 第二层为KG类
- item.weight = total
- } else {
- // 第二层不为KG类
- // item.weight = this.$math.format(total * item.netWeight, 14)
- item.weight = total * item.netWeight
- }
- }
- row.outInDetailRecordRequestList.push(item)
- }
- // // 单独点击保存并插入对应位置(包装)
- // 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)
- // }
- },
- async requireDictCode() {
- // 不拆物料层规格列表
- const res = await getByCode('material_layer')
- this.dictCodeList = res.map(item => {
- const arr = Object.entries(item)
- return {
- dictCode: arr[0][0],
- dictValue: arr[0][1]
- }
- })
- },
- getDict(dictCode) {
- // 不拆物料层规格列表
- if (this.dictCodeList.length > 0) {
- return this.dictCodeList.find(item => item.dictCode == dictCode) || {}
- } else {
- return {}
- }
- },
- async computeNum(row, index, isClear) {
- console.log(row)
- console.log(row.packingQuantity)
- console.log(row.packingUnit)
- // 清空仓库(包装数量输入)
- if (isClear) {
- // this.$set(this.productList[index], 'warehouseId', '')
- // this.$set(this.productList[index], 'warehouseName', '')
- if (row.packingQuantity < 1) {
- this.$set(this.productList[index], 'packingQuantity', 1)
- } else if (row.packingQuantity > 9999) {
- this.$set(this.productList[index], 'packingQuantity', 9999)
- } else {
- this.$set(this.productList[index], 'packingQuantity', row.packingQuantity.replace(/[^\d\.{2,}]/g, ''))
- }
- }
- if (row.packingQuantity && row.packingUnit) {
- let startIndex = row.packingSpecificationOption.findIndex(ite => {
- return row.measuringUnit == ite.packingUnit && ite.packingUnit != ite.conversionUnit
- })
- console.log(startIndex)
- let endIndex = row.packingSpecificationOption.findIndex(ite => row.packingUnit == ite.conversionUnit)
- console.log(endIndex)
- let total = row.packingQuantity
- for (; startIndex < endIndex; endIndex--) {
- total = row.packingSpecificationOption[endIndex].packageCell * total
- }
- row.measureQuantity = total
- // 判断包装单位和计量单位是否为不拆物料层规格
- console.log(this.getDict(row.packingUnit))
- let packingBoolen = !!this.getDict(row.packingUnit).dictValue
- let measureBoolen = !!this.getDict(row.measureUnit).dictValue
- if (packingBoolen || measureBoolen) {
- row.weight = total
- } else {
- row.weight = total * row.netWeight
- }
- }
- },
- //获取仓库
- async getwarehouseList() {
- let res = await getWarehouseList()
- this.warehouseListOption = [res.data]
- },
- showWarehousePicker(index) {
- this.currentProductIndex = index
- this.warehouseShow = true
- },
- showPackingUnitPicker(data, index) {
- this.currentProductIndex = index
- this.currentPackingSpecificationOption = [data.packingSpecificationOption]
- this.packingUnitsShow = true
- },
- showSupplierPicker(data, index) {
- this.currentProductIndex = index
- this.currentSupplierListOption = [data.supplierListOptions]
- this.suppliersShow = true
- },
- selectPackingUnitInfo(e) {
- this.productList[this.currentProductIndex].packingUnit = e.value[0]?.conversionUnit
- this.computeNum(this.productList[this.currentProductIndex], this.currentProductIndex)
- this.packingUnitsShow = false
- },
- selectSuppliersInfo(e) {
- this.productList[this.currentProductIndex].supplierName = e.value[0]?.name
- this.productList[this.currentProductIndex].supplierId = e.value[0]?.id
- this.suppliersShow = false
- },
- selectWarehouseInfo(e) {
- this.productList[this.currentProductIndex].warehouseName = e.value[0]?.name
- this.productList[this.currentProductIndex].warehouseId = e.value[0]?.id
- this.productList[this.currentProductIndex].warehouseNames = [e.value[0]?.name]
- this.productList[this.currentProductIndex].warehouseIds = [e.value[0]?.id]
- this.warehouseShow = false
- },
- selectTimeTypeInfo(e) {
- this.curDateType = e.value[0]?.prop
- this.timeTypeShow = false
- },
- sceneStateFilter(bizType) {
- if (bizType) {
- return this.sceneState.filter(item => item.value == bizType)[0].text
- }
- },
- formatter(dataTime) {
- return dayjs(dataTime).format('YYYY-MM-DD HH:mm:ss')
- },
- timeConfirm() {
- this.timeShow = false
- this.$nextTick(() => {
- console.log(this.storageTime)
- console.log(this.formatter(this.storageTime))
- this.formData.storageTime = this.formatter(this.storageTime)
- console.log(this.formData)
- })
- },
- timeCancel() {
- this.timeShow = false
- },
- openPicker() {
- this.$refs.treePicker._show()
- },
- // 获取物品列表
- async getListItems() {
- this.goodsLists = await getTreeByGroup({ type: 2 })
- },
- confirm(data, name, allList) {
- console.log('name-------', name)
- this.assetTypeName = name
- this.formData.extInfo.assetType = allList.map(item => item.id)
- },
- handleScan() {
- if (this.formData.bizType !== '' && this.formData.bizType != 5) {
- uni.showModal({
- title: '提示',
- content: '仅退还入库支持扫码,是否清除已选明细并切换至退还入库?',
- success: async res => {
- if (res.confirm) {
- this.productList = []
- this.formData.bizType = 5
- this.getData()
- }
- }
- })
- return
- }
- this.getData()
- },
- // goScan () {
- // uni.navigateTo({
- // url: '/pages/ScanCode/ScanCode'
- // })
- // },
- // 根据条码请求设备数据 @_@
- getData() {
- let par = {
- barType: this.qrContent.split('@_@')[1] || 0,
- qrContent: this.qrContent
- }
- // uni.showLoading({
- // title: '加载中',
- // mask: true
- // })
- // postJ(this.apiUrl + '/scan/getAssetInfo', par)
- // .then(res => {
- // let data = res.data
- // console.log(data, 'qrContent')
- // if (data.assetType === undefined) {
- // uni.showToast({
- // title: '请扫码物品码',
- // icon: 'none'
- // })
- // return
- // } else if (data.source == 2) {
- // uni.showModal({
- // title: '提示',
- // content: '当前物品已在库',
- // success: async res => {}
- // })
- // return
- // } else if (this.warehousingName && this.formData.assetType != data.assetType) {
- // uni.showToast({
- // title: `当前物品不属于${this.warehousingName}分类`,
- // icon: 'none'
- // })
- // return
- // }
- // this.setScanMaterial(data)
- // })
- // .finally(() => {
- // uni.hideLoading()
- // })
- },
- async setScanMaterial(data) {
- this.formData.assetType = data.assetType
- this.formData.bizType = 5
- const curMap = {
- assetId: 'id',
- assetCode: 'informationCode', //编码
- assetName: 'informationName', //名称
- materialId: 'id',
- materialName: 'informationName',
- batchNo: '', //批次号
- unit: 'measuringUnit', //单位
- minPackUnit: 'packingUnit' //最小包装单位
- }
- let obj = {}
- for (const key in curMap) {
- obj[key] = (curMap[key] && data.information[curMap[key]]) || ''
- }
- let detailObj = uni.$u.deepClone(obj)
- detailObj.onlyCode = data.assetCode
- obj = {
- ...data.information,
- ...obj,
- ...{
- cargoSpaceCode: '', //货位编码
- cargoSpaceId: '', //货位id
- shelfId: '', //货架id
- shelfCode: '', //货架名称
- areaId: '', //库区id
- areaName: '', //库区名称
- warehouseId: '', //仓库id
- warehouseName: '', //仓库名称
- measurementUnit: '',
- bizStatus: 1,
- contentImage: []
- }
- }
- let warehouseLedgerDetails = [detailObj]
- this.productList.push(obj)
- this.$set(this.productList[this.productList.length - 1], 'warehouseLedgerDetails', warehouseLedgerDetails)
- this.$set(this.productList[this.productList.length - 1], 'selfWarehouseLedgerDetails', uni.$u.deepClone(warehouseLedgerDetails))
- this.handleBatchSetting(obj, this.productList.length - 1, true)
- },
- calcSum(a, b, c, row) {
- if ((Number.isNaN(+a) && a !== '') || (Number.isNaN(+b) && b !== '') || (Number.isNaN(+c) && c !== '')) {
- return ''
- }
- return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
- },
- handleBatchSetting(item, index, isScan = false) {
- this.settingIndex = index
- uni.setStorageSync('inputData', item)
- uni.setStorageSync('productList', this.productList || [])
- uni.navigateTo({
- url: '/pages/warehouse/enterHouse/batchNumEdit?bizType=' + this.formData.bizType + '&assetType=' + this.formData.assetType + '&index=' + index + '&isScan=' + isScan
- })
- },
- chooseFile(file) {
- console.log(file)
- this.$refs.lFile.upload({
- //替换为你的上传接口地址
- url: this.apiUrl + '/data/doc/add',
- // 服务端接收附件的key
- name: 'file',
- //根据你接口需求自定义 (优先不传content-type,安卓端无法收到参数再传)
- header: {
- Authorization: 'bearer eyJhbGciO',
- uid: '27682',
- client: 'app'
- }
- // 限制选择附件的大小上限,默认10M
- // maxSize: 20,
- // 若需要在body单独添加附件名或附件大小如下方式传入组件:
- // addName: '后端要的附件名称字段key,此处请勿写name的同值如(file),会覆盖name',
- // addSize: '后端要的附件大小字段key'
- // body参数直接写key,value,如:
- // date: '2020-1-1',
- // key2: 'value2',
- })
- },
- // 抬头下拉信息保存
- handlePicker(e, list, idKey, nameKey) {
- console.log('e?.detail--------------', e)
- if (idKey) {
- this.formData[idKey] = list[e?.detail.value]?.value
- }
- if (nameKey) {
- this.formData[nameKey] = list[e?.detail.value]?.text
- }
- this.$nextTick(() => {
- if (idKey === 'assetType' || idKey === 'bizType') {
- this.$refs.formRef.validateField(idKey)
- }
- console.log('this.formData.bizType---', this.formData.bizType)
- })
- },
- // 抬头下拉信息保存
- handleDictPicker(e, list, idKey, nameKey) {
- if (idKey) {
- this.formData[idKey] = list[e?.detail.value]?.dictCode
- }
- if (nameKey) {
- this.formData[nameKey] = list[e?.detail.value]?.dictValue
- }
- this.$nextTick(() => {
- if (idKey === 'assetType' || idKey === 'bizType') {
- this.$refs.formRef.validateField(idKey)
- }
- })
- },
- // 明细下拉信息保存
- handleListPicker(e, list, item, idKey, nameKey) {
- if (idKey) {
- item[idKey] = list[e.detail.value].id
- }
- if (nameKey) {
- item[nameKey] = list[e.detail.value].name
- }
- },
- //获取仓库信息
- handleWarehouseChoose(item) {
- this.$refs.warehouseChooseRef.openDefault(item, res => {
- Object.assign(item, res)
- })
- },
- //状态
- getstatus(e) {
- this.formData.houseType = this.statusList[e.detail.value].name
- },
- //上传附件
- getUpFlie(res) {
- console.log(res)
- let arr = []
- res.forEach(item => {
- let obj = {
- accessUrl: item.accessUrl,
- docId: item.docId,
- name: item.name,
- size: item.size,
- url: item.url,
- type: 1
- }
- // obj.type.id = item.type.id;
- // obj.type.value = item.type.name;
- arr.push(obj)
- })
- this.formData.attaments = arr
- },
- //选择入库类别跳转
- selectType() {
- if (!this.formData.extInfo.assetType) {
- uni.showToast({
- title: '请选择物品类型',
- icon: 'none'
- })
- return
- }
- if (!this.formData.bizType) {
- uni.showToast({
- title: '请选择入库场景',
- icon: 'none'
- })
- return
- }
- uni.navigateTo({
- url: '/pages/warehouse/enterHouse/selectEnterType?assetType=' + this.formData.extInfo.assetType
- })
- },
- //删除
- getDelete(index) {
- uni.showModal({
- title: '提示',
- content: '是否删除当前物品',
- success: res => {
- if (res.confirm) {
- this.productList.splice(index, 1)
- }
- }
- })
- },
- deletePacking(index, idx) {
- uni.showModal({
- title: '提示',
- content: '是否删除当前包装',
- success: res => {
- if (res.confirm) {
- this.productList[index].outInDetailRecordRequestList.splice(idx, 1)
- this.productList[index].packingQuantity = this.productList[index].packingQuantity - 1
- }
- }
- })
- },
- // 入库操作
- // listEdit(row) {
- // this.$set(row, 'isSave', false)
- // },
- // listSave(row, index) {
- // const fileds = [`productList.${index}.cargoSpaceCode`, `productList.${index}.batchNum`]
- // if (this.formData.bizType != 5) {
- // fileds.push(...[`productList.${index}.outInNum`, `productList.${index}.measurementUnit`])
- // } else if (this.productList.some(i => !i.selfWarehouseLedgerDetails?.length)) {
- // uni.showToast({
- // title: '请选择资产编号!',
- // icon: 'none'
- // })
- // return
- // }
- // Promise.all(
- // fileds.map(
- // item =>
- // new Promise(async (resolve, rej) => {
- // this.$refs.lisrFormRef.validateField(item, err => {
- // if (err?.length) {
- // rej(err)
- // } else {
- // resolve()
- // }
- // })
- // })
- // )
- // )
- // .then(res => {
- // this.$set(row, 'isSave', true)
- // if (this.formData.bizType != 5) {
- // this.createMaterialCode(row)
- // } else {
- // // 退还
- // this.createMaterialCodeReturn(row)
- // }
- // })
- // .catch(err => {
- // uni.showToast({
- // icon: 'error',
- // title: '请填入必填项!'
- // })
- // })
- // },
- //入库明细删除
- listDel(row, index) {
- this.productList.splice(index, 1)
- },
- // 入库明细生成条码信息
- async createMaterialCode(row) {
- return
- // 添加相同物品重新更新明细 原料编码
- const list = this.productList.filter(i => i.assetCode === row.assetCode && i.batchNum === row.batchNum && i.isSave)
- const num = list.reduce((num, pre) => {
- num += row.isUnpack ? pre.outInNum * pre.measurementUnit : pre.outInNum
- return num
- }, 0)
- const res = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
- batchNum: row.batchNum,
- assetCode: row.assetCode,
- num
- })
- if (res?.success) {
- list.forEach(item => {
- if (item.warehouseLedgerDetails?.length) {
- item.warehouseLedgerDetails.forEach(i => {
- i.onlyCode = res.data.shift().onlyCode
- })
- } else {
- this.$set(
- item,
- 'warehouseLedgerDetails',
- Array.from(new Array(item.isUnpack ? item.outInNum * item.measurementUnit : +item.outInNum), (val, idx) => {
- return {
- ...item,
- onlyCode: res.data.shift().onlyCode,
- bizStatus: 1,
- contentImage: []
- }
- })
- )
- }
- })
- }
- // 添加相同物品,重复批次号 重新更新明细 包装编码
- const batchList = this.productList.filter(i => i.batchNum === row.batchNum && i.isSave)
- if (batchList.length) {
- const num = batchList.reduce((num, pre) => {
- num += +pre.outInNum
- return num
- }, 0)
- const res1 = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
- batchNum: row.batchNum,
- num
- })
- if (res1?.success) {
- batchList.forEach(item => {
- let num = res1.data.shift()?.num
- let measurementUnit = item.measurementUnit
- if (item.warehouseLedgerDetails?.length) {
- item.warehouseLedgerDetails.forEach((i, index) => {
- this.$set(i, 'num', num)
- if (!item.isUnpack) {
- if (index < item.warehouseLedgerDetails.length - 1) {
- num = res1.data.shift()?.num
- }
- } else {
- // 拆包的包装编码一致
- measurementUnit--
- if (measurementUnit === 0 && index < item.warehouseLedgerDetails.length - 1) {
- measurementUnit = item.measurementUnit
- num = res1.data.shift()?.num
- }
- }
- })
- }
- })
- }
- }
- },
- // 入库明细生成条码信息 退还
- async createMaterialCodeReturn(row) {
- return
- // 添加相同物品重新更新明细 原料编码
- const list = this.productList.filter(i => i.batchNum === row.batchNum && i.isSave)
- // 退还
- const res = await postJ(this.apiUrl + '/outInWarehouse/getAssetNum', {
- batchNum: row.batchNum,
- num: list.reduce((num, pre) => {
- num += pre.selfWarehouseLedgerDetails.length
- return num
- }, 0)
- })
- if (res?.success) {
- list.forEach(item => {
- const num = res.data.shift().num
- if (item.warehouseLedgerDetails?.length) {
- item.warehouseLedgerDetails.forEach(i => {
- i.num = num
- if (!item.isUnpack) {
- // 拆包的包装编码一致
- num = res.data.shift()?.num
- }
- })
- } else {
- this.$set(
- item,
- 'warehouseLedgerDetails',
- item.selfWarehouseLedgerDetails.map((val, idx) => {
- let obj = {
- ...val,
- bizStatus: 1,
- batchNum: item.batchNum,
- cargoSpaceCode: item.cargoSpaceCode, //货位编码
- cargoSpaceId: item.cargoSpaceId, //货位id
- shelfId: item.shelfId, //货架id
- shelfCode: item.shelfCode, //货架名称
- areaId: item.areaId, //库区id
- areaName: item.areaName, //库区名称
- warehouseId: item.warehouseId, //仓库id
- warehouseName: item.warehouseName, //仓库名称
- num
- }
- if (!item.isUnpack) {
- // 拆包的包装编码一致
- num = res.data.shift()?.num
- }
- return obj
- })
- )
- }
- })
- }
- },
- //确定提交
- getsure() {
- return
- this.$refs.formRef.validate().then(res => {
- if (!this.productList?.length) {
- uni.showToast({
- icon: 'error',
- title: '请添加明细!'
- })
- return
- } else if (this.productList.some(item => !item.warehouseLedgerDetails?.length)) {
- uni.showToast({
- icon: 'error',
- title: '请完善明细信息!'
- })
- return
- }
- const params = {
- outInWarehouse: { ...this.formData, bizStatus: 1 },
- warehouseLedgerInfos: this.productList
- }
- postJ(this.apiUrl + '/outInWarehouse/add', params).then(res => {
- if (res?.success) {
- uni.showToast({
- icon: 'success',
- title: '保存成功'
- })
- setTimeout(() => {
- uni.navigateBack({
- delta: 1
- })
- }, 1500)
- }
- })
- })
- },
- // 部门确认
- deptConfirm(data, name) {
- this.formData.deptName = name
- this.formData.deptCode = data[0]
- },
- // 部门确认
- verifyDeptConfirm(data, name) {
- this.formData.verifyDeptCode = data[0]
- this.formData.verifyDeptName = name
- this.formData.verifyId = ''
- this.formData.verifyName = ''
- this.getUser(data[0])
- },
- // 获取部门
- getDept() {
- return
- get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
- if (res?.success) {
- this.deptList = res.data
- }
- })
- },
- // 获取供应商
- getSupplier() {
- // post(this.apiUrl + `/main/supplier/list?page=1&size=999`, {
- // page: 1,
- // size: 999
- // }).then(res => {
- // if (res?.success) {
- // this.supplierList = res.data.items
- // }
- // })
- },
- // 获取人员
- getUser(deptCode) {
- // post(this.apiUrl + '/main/user/list', {
- // deptCode,
- // page: 1,
- // size: 9999
- // }).then(res => {
- // if (res?.success) {
- // this.userList = res.data.items.map(item => {
- // item.name = item.trueName
- // item.id = item.userId
- // return item
- // })
- // }
- // })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .mainBox {
- padding-bottom: 120rpx;
- /deep/.required-form .u-form-item__body__left__content__label::before {
- content: '*';
- color: red;
- }
- }
- .required-form-text {
- /deep/ .u-form-item__body__right {
- overflow: hidden;
- .u-form-item__body__right__content {
- width: 100%;
- display: inline-block !important;
- width: 100%;
- }
- }
- }
- .picList {
- display: flex;
- align-items: center;
- justify-items: flex-start;
- flex-wrap: wrap;
- }
- /deep/.baseForm {
- .u-form-item__body {
- padding: 0px !important;
- }
- .assetType_box {
- padding: 12rpx 18rpx;
- width: 100%;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- }
- /deep/.picList .u-image {
- margin-right: 10rpx;
- margin-bottom: 10rpx;
- }
- /deep/.cLine .u-line:nth-child(1) {
- border-bottom: none !important;
- }
- .detail-box {
- position: relative;
- display: flex;
- justify-content: space-between;
- align-items: center;
- /deep/uni-button {
- margin: 0 !important;
- width: 180rpx;
- }
- .selectEnterType {
- margin-left: 10rpx !important;
- }
- }
- .footBox {
- position: fixed;
- left: 0px;
- bottom: 0px;
- height: 100rpx;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- view {
- width: 100%;
- height: 100%;
- text-align: center;
- color: #fff;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .reg {
- background: $u-success-dark;
- }
- .add {
- background: $uni-color-primary;
- }
- .uni-icons {
- margin-right: 8rpx !important;
- }
- }
- .listBox {
- padding: 20rpx 10rpx;
- border-bottom: 1px #f2f2f2 solid;
- position: relative;
- &.code {
- .label {
- width: 120rpx !important;
- }
- }
- .listTit {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- /deep/uni-button {
- margin-right: 20rpx;
- width: 100rpx;
- &.assets {
- width: 180rpx;
- }
- }
- .name {
- width: 50%;
- margin-left: 10px;
- overflow: hidden;
- white-space: nowrap;
- -o-text-overflow: ellipsis;
- text-overflow: ellipsis;
- font-size: 30rpx;
- }
- .btn {
- display: flex;
- justify-content: flex-end;
- }
- .weight {
- width: 30%;
- font-size: 30rpx;
- margin-left: auto;
- margin-right: 60rpx;
- position: relative;
- display: flex;
- input {
- margin-right: 10rpx;
- border: 1px solid black;
- width: 40%;
- height: 20rpx;
- }
- }
- .weight::after {
- position: absolute;
- right: -30rpx;
- top: 50%;
- content: '';
- background: #eee;
- width: 1px;
- height: 28rpx;
- margin-top: -14rpx;
- }
- }
- .z_list {
- height: 100% !important;
- max-height: 500rpx;
- .material {
- margin-top: 10rpx;
- .left {
- width: 40rpx;
- }
- .zdy_check {
- width: 30rpx;
- height: 30rpx;
- border: 2rpx solid #c8c9cc;
- border-radius: 4rpx;
- }
- .check_active {
- background: $theme-color;
- border: 2rpx solid $theme-color;
- /deep/ .u-icon__icon {
- color: #fff !important;
- }
- }
- .content_table {
- width: 670rpx;
- border: 2rpx solid $border-color;
- .item {
- display: flex;
- border-bottom: 2rpx solid $border-color;
- .lable {
- width: 200rpx;
- text-align: center;
- background-color: #f7f9fa;
- font-size: 26rpx;
- border-right: 2rpx solid $border-color;
- flex-shrink: 0;
- }
- .ww80 {
- width: 80rpx;
- }
- .content {
- width: 500rpx;
- min-height: 64rpx;
- font-size: 28rpx;
- line-height: 28rpx;
- font-style: normal;
- font-weight: 400;
- padding: 18rpx 8rpx;
- box-sizing: border-box;
- word-wrap: break-word;
- flex-grow: 1 !important;
- }
- .input_box {
- padding: 0 !important;
- }
- .content_num {
- display: flex;
- align-items: center;
- padding: 0 4rpx;
- /deep/ .uni-input-input {
- width: 200rpx;
- border: 2rpx solid #f0f8f2;
- background: #f0f8f2;
- color: $theme-color;
- }
- .unit {
- padding: 0 4rpx;
- font-size: 24rpx;
- color: #404446;
- }
- }
- .ww400 {
- /deep/ .uni-input-input {
- width: 400rpx;
- }
- }
- .pd4 {
- padding: 4rpx 8rpx;
- }
- &:last-child {
- border-bottom: none;
- }
- }
- .ww55 {
- width: 55%;
- }
- .ww45 {
- width: 45%;
- }
- .ww50 {
- width: 50%;
- }
- .ww30 {
- width: 30%;
- }
- .ww70 {
- width: 70%;
- }
- .ww80 {
- width: 80%;
- }
- .ww20 {
- width: 20%;
- }
- .check {
- width: 30rpx;
- height: 30rpx;
- }
- .tag_box {
- padding: 2rpx 10rpx;
- margin-right: 12rpx;
- background: #e6a23c;
- font-size: 22rpx;
- color: #fff;
- border-radius: 4rpx;
- }
- }
- }
- }
- .more {
- position: absolute;
- bottom: 26rpx;
- right: 30rpx;
- font-size: 28rpx;
- color: #666;
- }
- }
- .listCont {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- margin-top: 20rpx;
- margin-left: 10rpx;
- &.save {
- .u-input {
- border: none;
- }
- }
- .u-input {
- border: 1px solid rgb(229, 229, 229);
- height: 15rpx !important;
- }
- .item {
- width: 47%;
- font-size: 28rpx;
- margin-bottom: 10rpx;
- margin-right: 3%;
- // line-height: 45rpx;
- // overflow: hidden;
- // white-space: nowrap;
- // text-overflow: ellipsis;
- // -o-text-overflow: ellipsis;
- // color: #000;
- // display: flex;
- /deep/.u-form-item__body {
- padding: 0 !important;
- }
- /deep/.u-input__content__field-wrapper__field,
- /deep/.u-form-item {
- font-size: 28rpx !important;
- }
- text.label {
- width: 120rpx;
- display: inline-block;
- text-align: right;
- margin-right: 20rpx;
- margin-bottom: 20rpx;
- }
- /deep/.uni-date__x-input {
- height: 40rpx;
- font-size: 28rpx;
- }
- /deep/.uni-date {
- width: 48%;
- display: inline-block;
- .uni-icons {
- display: none !important;
- }
- .uni-date-x {
- padding: 0 !important;
- }
- }
- }
- .item text {
- color: #666;
- }
- }
- .selectTime {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- margin-bottom: 10rpx;
- .title {
- flex: 1;
- font-size: 30rpx;
- }
- .timeBox {
- display: flex;
- width: 500rpx;
- .firstBtn {
- margin-right: 10rpx;
- }
- }
- }
- .listBox:last-child {
- border: none !important;
- }
- .textBox {
- border: 1px #f2f2f2 solid;
- height: 160px;
- display: block;
- width: auto !important;
- }
- .saveBtn {
- width: 50%;
- margin: 40rpx auto;
- }
- .top-css {
- border-bottom: 1px solid rgb(207, 204, 204);
- }
- </style>
|