| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179 |
- <template>
- <view class="mainBox" :class="{ isOut: activeName === 'output' }">
- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="调拨明细" @clickLeft="back" v-if="navShow">
- <template slot="right"><text class="text-danger" @click="handleDelete" v-if="id">删除调拨</text></template>
- </uni-nav-bar>
- <view class="tool-wrapper">
- <view class="flex-center">
- <!-- <text>调拨单号 {{ formData.dialNumber }}</text> -->
- <view>
- <text>调拨条数 {{ assetsList.length + preAssetsList.length }}</text>
- </view>
- <text class="btn required" @click="$refs.typeSettingRef.open(formData)">调拨类型设置</text>
- </view>
- <view class="flex-center info">
- <text>调拨编码:{{ formData.code }}</text>
- </view>
- <view class="flex-center info">
- <view class="flex_input">
- <text class="required" @click="$refs.typeSettingRef.open(formData)">调拨名称:</text>
- <view>
- <u--input style="padding: 0" placeholder="请输入内容" border="surround" v-model="formData.name"></u--input>
- </view>
- </view>
- </view>
- <view class="flex-center info">
- <text class="">调拨类型:{{ dialTypeOptions[formData.dialType] }}</text>
- </view>
- <view class="flex-center info">
- <text>调出仓库:{{ formData.warehouseName }}{{ formData.cargoSpace ? '(' + formData.cargoSpace + ')' : '' }}</text>
- </view>
- <view class="flex-center info">
- <text>调入仓库:{{ formData.inWarehouseName }}{{ formData.inCargoSpace ? '(' + formData.inCargoSpace + ')' : '' }}</text>
- </view>
- <!-- <view class="tabs">
- <view class="tab-item" :class="{ active: activeName === 'output' }" @click="activeName = 'output'">待调出({{ assetsList.length }})</view>
- <view class="tab-item" :class="{ active: activeName === 'input' }" @click="activeName = 'input'">预调入({{ preAssetsList.length }})</view>
- </view> -->
- <template v-if="activeName === 'output'">
- <view class="operations flex-center">
- <text @click="goScanCode">扫码添加</text>
- <text @click="handleWarehouseChoose('output')">手动添加</text>
- <text @click="handleWarehouseChoose('input')">调入货位</text>
- <!-- <text @click="deleteMaterial">删除选中</text> -->
- </view>
- <!-- <view class="wrapper">
- <u-list class="listContent">
- <view class="listBox" v-for="(item, index) in assetsList">
- <view class="listBox-con">
- <view class="listBox-top">
- <view class="listBox-name">
- {{ item.categoryName }}
- </view>
- <view class="listBox-code">
- {{ item.categoryCode }}
- </view>
- </view>
- <view class="listBox-bottom">
- <view>牌号:{{ item.brandNum }}</view>
- <view>型号:{{ item.modelType }}</view>
- <view>规格:{{ item.specification }}</view>
- <view>批次号:{{ item.batchNo }}</view>
- <view>计量数量:{{ item.measureQuantity }}({{ item.measureUnit }})</view>
- <view class="w100">包装编码:{{ item.packageNo }}</view>
- <view>包装数量:{{ item.packingQuantity }}({{ item.packingUnit }})</view>
- <view>重量:{{ item.weight }}({{ item.weightUnit }})</view>
- <view>发货条码:{{ item.barcodes }}</view>
- <view>物料代号:{{ item.materielDesignation }}</view>
- <view>客户代号:{{ item.clientCode }}</view>
- <view>刻码:{{ item.engrave }}</view>
- <view>仓库:{{ item.warehouseName }}</view>
- </view>
- </view>
- </view>
- <u-empty class="noDate" style="margin-top: 20vh" v-if="!assetsList.length"></u-empty>
- </u-list>
- </view> -->
- <!-- <view class="search-box">
- <uni-easyinput prefixIcon="search" v-model="outputFilter" placeholder="编码、名称、货位"></uni-easyinput>
- </view> -->
- <!-- <view class="select-box flex-center">
- <text
- >已选{{ assetsList.filter(i => i.checked).length }}/{{
- assetsList.length
- }}</text
- >
- <text class="btn" @click="assetsSelectAll = !assetsSelectAll"
- >全选</text
- >
- </view> -->
- </template>
- <template v-else>
- <view class="operations">
- <text @click="removeOutput" style="margin-right: 20rpx">移除选中</text>
- <text @click="deleteOutput">删除选中</text>
- </view>
- <view class="search-box">
- <uni-easyinput prefixIcon="search" v-model="inputFilter" placeholder="编码、名称、货位"></uni-easyinput>
- </view>
- <view class="select-box flex-center">
- <text>已选 {{ preAssetsList.filter(i => i.inputChecked).length }}/{{ preAssetsList.length }}</text>
- <text class="btn" @click="preAssetsSelectAll = !preAssetsSelectAll">全选</text>
- </view>
- </template>
- </view>
- <view class="list-container" v-if="activeName === 'output'">
- <AssetsCard v-for="(item, index) in assetsList" :key="index" :item="item" @deleteItem="deleteItem(item)" type="output"></AssetsCard>
- </view>
- <view class="list-container" v-if="activeName === 'input'">
- <AssetsCard v-for="(item, index) in preAssetsListRender" :key="index" :item="item" type="input"></AssetsCard>
- </view>
- <!-- <u-button type="success" class="preview-box" :plain="true" @click="handlePreview">预览</u-button> -->
- <u-button type="success" class="preview-box" :plain="true" @click="add">调入</u-button>
- <WarehouseChoose ref="warehouseChooseRef" :selfClose="selfClose" />
- <!-- <CargoSpaceInfoDialog ref="cargoSpaceInfoDialogRef" @cancel="navShow = true" @success="cargoSpaceInfoConfirm" :assetsList="assetsList" :preAssetsList="preAssetsList" /> -->
- <CargoSpaceInfoDialog ref="cargoSpaceInfoDialogRef" @cancel="navShow = true" @success="cargoSpaceInfoConfirm" />
- <TypeSetting ref="typeSettingRef" @getPopupInfo="getPopupInfo" />
- <PreInventory ref="preInventoryRef" />
- <!-- <ScanCode @scancodedate="scancodedate"></ScanCode> -->
- </view>
- </template>
- <script>
- import ScanCode from '@/components/ScanCode.vue'
- import PreInventory from './components/PreInventory'
- import AssetsCard from './components/AssetsCard'
- import TypeSetting from './components/TypeSetting'
- import WarehouseChoose from '@/components/WarehouseChoose'
- import CargoSpaceInfoDialog from './components/CargoSpaceInfoDialog'
- import { getCode, allotApplySave } from '@/api/warehouseManagement'
- export default {
- components: {
- TypeSetting,
- ScanCode,
- PreInventory,
- AssetsCard,
- WarehouseChoose,
- CargoSpaceInfoDialog
- },
- data() {
- return {
- transferOrderId: '', // 调拨单ID
- searchVal: '',
- activeName: 'output',
- selfClose: true,
- dialTypeOptions: {
- 1: '库内调拨',
- 2: '库外调拨'
- },
- formData: {
- // dialNumber: getRuleNo('ALLOT'),
- dialType: '',
- warehouseId: '',
- warehouseName: '',
- inWarehouseId: '',
- inWarehouseName: '',
- deptCode: '',
- deptName: '',
- verifyId: '',
- verifyName: '',
- warehouse: {},
- inWarehouse: {}
- },
- assetsList: [], //已选资产列表
- preAssetsList: [], //预调入资产列表
- inputFilter: '',
- outputFilter: '',
- navShow: true,
- isCamera: false,
- id: ''
- }
- },
- async onLoad(options) {
- if (options.id) {
- this.id = options.id
- this._getDetail(options.id)
- }
- const code = await getCode('transfer_no')
- console.log('code---', code)
- this.formData.code = code
- uni.$on('setSelectList', async data => {
- if (data?.length) {
- console.log('setSelectList--data------------', data)
- this.assetsList = data
- }
- })
- this.$forceUpdate()
- console.log(this.formData.code)
- },
- onShow() {
- const _this = this
- uni.$off('inventoryAllocationScanView') // 每次进来先 移除全局自定义事件监听器
- uni.$on('inventoryAllocationScanView', function (data) {
- _this.setScanMaterial(data)
- })
- console.log('onShow')
- uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
- uni.$on('scancodedate', function (data) {
- _this.scancodedate(data)
- })
- },
- onUnload() {
- uni.$off('scancodedate')
- },
- onHide() {
- uni.$off('scancodedate')
- },
- computed: {
- assetsSelectAll: {
- set(val) {
- this.assetsList.forEach(item => {
- item.checked = val
- })
- return val
- },
- get() {
- return !this.assetsList.some(item => !item.checked)
- }
- },
- preAssetsSelectAll: {
- set(val) {
- this.preAssetsList.forEach(item => {
- item.inputChecked = val
- })
- return val
- },
- get() {
- return !this.preAssetsList.some(item => !item.inputChecked)
- }
- },
- // 做前端过滤 编码areaName、名称assetCode、货位shelfCode、批次
- assetsListRender() {
- return this.assetsList.filter(({ assetName = '', assetCode = '', outWarehouseAreaName = '', outWarehouseAreaGoodsCode = '', outGoodsAllocationCode = '' }) => {
- if (this.outputFilter) {
- if (
- assetName.indexOf(this.outputFilter) !== -1 ||
- assetCode.indexOf(this.outputFilter) !== -1 ||
- outWarehouseAreaName.indexOf(this.outputFilter) !== -1 ||
- outWarehouseAreaGoodsCode.indexOf(this.outputFilter) !== -1 ||
- outGoodsAllocationCode.indexOf(this.outputFilter) !== -1
- ) {
- return true
- }
- return false
- }
- return true
- })
- },
- // 做前端过滤 编码、名称、货位、批次
- preAssetsListRender() {
- return this.preAssetsList.filter(({ areaName = '', assetCode = '', inWarehouseAreaName = '', inWarehouseAreaGoodsCode = '', inGoodsAllocationCode = '' }) => {
- if (this.inputFilter) {
- if (
- areaName.indexOf(this.inputFilter) !== -1 ||
- assetCode.indexOf(this.inputFilter) !== -1 ||
- inWarehouseAreaName.indexOf(this.inputFilter) !== -1 ||
- inWarehouseAreaGoodsCode.indexOf(this.inputFilter) !== -1 ||
- inGoodsAllocationCode.indexOf(this.inputFilter) !== -1
- ) {
- return true
- }
- return false
- }
- return true
- })
- }
- },
- beforeDestroy() {
- uni.$off('setSelectList')
- },
- methods: {
- goScanCode() {
- if (!this.formData.warehouseId) {
- uni.showToast({
- title: '请设置调拨类型!',
- icon: 'none'
- })
- return
- }
- let warehouse = {}
- warehouse.id = this.formData.warehouseId
- warehouse.name = this.formData.warehouseName
- this.$refs.warehouseChooseRef.open({ ...warehouse, type: 'output' }, res => {
- if (this.formData.dialType === 1) {
- if (!res.areaId) {
- uni.showToast({
- title: '请选择库区',
- icon: 'none'
- })
- return
- }
- }
- this.formData.cargoSpace = this.getLocation(res)
- this.formData.warehouse = res
- this.$refs.warehouseChooseRef.cancel()
- this.$forceUpdate()
- uni.navigateTo({
- url: '/pages/warehouse/components/scanCodeList'
- })
- })
- },
- add() {
- if (!this.formData.name) {
- uni.showToast({
- title: '请填入调拨名称!',
- icon: 'none'
- })
- return
- }
- console.log('---------this.assetsList---------------')
- console.log(this.assetsList)
- console.log(this.formData)
- let isBoolen = true
- if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId && this.formData.warehouse.cargoSpaceId) {
- isBoolen = this.assetsList.every(
- item =>
- item.warehouseId == this.formData.warehouseId &&
- item.areaId == this.formData.warehouse.areaId &&
- item.goodsShelfId == this.formData.warehouse.shelfId &&
- item.goodsAllocationId == this.formData.warehouse.cargoSpaceId
- )
- } else if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId) {
- isBoolen = this.assetsList.every(
- item => item.warehouseId == this.formData.warehouseId && item.areaId == this.formData.warehouse.areaId && item.goodsShelfId == this.formData.warehouse.shelfId
- )
- } else if (this.formData.warehouse.areaId) {
- isBoolen = this.assetsList.every(item => item.warehouseId == this.formData.warehouseId && item.areaId == this.formData.warehouse.areaId)
- } else {
- isBoolen = this.assetsList.every(item => item.warehouseId == this.formData.warehouseId)
- }
- if (!isBoolen) {
- uni.showToast({
- title: '请检查调拨明细!',
- icon: 'none'
- })
- return
- }
- if (this.assetsList.length > 0) {
- if (this.formData.dialType == 1) {
- // 库内
- this.submit(2)
- } else {
- // 库外
- this.submit(1)
- }
- } else {
- uni.showToast({
- title: '请选择调出物品!',
- icon: 'none'
- })
- }
- },
- submit(status) {
- if (this.assetsList.length > 0) {
- let params = {
- categoryCode: this.assetsList.map(item => item.categoryCode).join(','),
- categoryName: this.assetsList.map(item => item.categoryName).join(','),
- allotApplyAddPOBuilders: this.assetsList.map(item => {
- return {
- outInDetailRecordId: item.id,
- warehouseId: this.formData.warehouseId,
- warehouseName: this.formData.warehouseName,
- areaId: this.formData.warehouse.areaId,
- areaName: this.formData.warehouse.areaName,
- goodsAllocationId: this.formData.warehouse.cargoSpaceCode,
- goodsAllocationName: this.formData.warehouse.cargoSpaceId,
- goodsShelfId: this.formData.warehouse.shelfId,
- goodsShelfName: this.formData.warehouse.shelfCode,
- targetAreaId: this.formData.inWarehouse.areaId,
- targetAreaName: this.formData.inWarehouse.areaName,
- targetGoodsAllocationId: this.formData.inWarehouse.cargoSpaceId,
- targetGoodsAllocationName: this.formData.inWarehouse.cargoSpaceCode,
- targetGoodsShelfId: this.formData.inWarehouse.shelfId,
- targetGoodsShelfName: this.formData.inWarehouse.shelfCode,
- targetWarehouseId: this.formData.inWarehouseId,
- targetWarehouseName: this.formData.inWarehouseName
- }
- }),
- allotCode: this.formData.code,
- name: this.formData.name,
- id: this.transferOrderId,
- sourceWarehouse: this.formData.warehouseName,
- sourceWarehouseId: this.formData.warehouseId,
- targetWarehouse: this.formData.inWarehouseName,
- targetWarehouseId: this.formData.inWarehouseId,
- status: status,
- type: this.formData.dialType
- }
- console.log('params------------', params)
- uni.showLoading({
- title: '保存中...'
- })
- allotApplySave(params).then(() => {
- uni.hideLoading()
- uni.navigateTo({
- url: '/pages/warehouse/inventoryAllocation/index'
- })
- })
- }
- },
- scancodedate(data) {
- this.qrContent = data.code.trim()
- this.getData()
- },
- handleScan() {
- const _this = this
- uni.scanCode({
- onlyFromCamera: true,
- success: function (res) {
- console.log('条码类型:' + res.scanType)
- console.log('条码内容:' + res.result)
- _this.isCamera = true
- _this.qrContent = res.result.trim()
- _this.getData()
- }
- })
- },
- // 根据条码请求设备数据 @_@
- getData() {
- if (!this.formData.warehouseId) {
- uni.showToast({
- title: '请设置调拨类型!',
- icon: 'none'
- })
- return
- }
- 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?.warehouseDetail?.bizStatus != 1) {
- // uni.showModal({
- // title: '提示',
- // content: `当前物品不在仓库内`,
- // success: async res => {}
- // })
- // return
- // } else if (data.underApproval) {
- // uni.showModal({
- // title: '提示',
- // content: `【${data.assetCode}】正在待审批单据中`,
- // success: async res => {}
- // })
- // return
- // } else if (data.information.takeStockPattern) {
- // uni.showModal({
- // title: '提示',
- // content:
- // '该物品为批量盘点模式,不可扫码。如需扫码,请将该物品类型在物品信息表中修改为逐个模式。',
- // success: async res => {}
- // })
- // return
- // } else if (
- // data.warehouseDetail?.warehouseId !== this.formData.warehouseId
- // ) {
- // uni.showToast({
- // title: `请选择${this.formData.warehouseName}仓库下的物品`,
- // icon: 'none'
- // })
- // return
- // }
- // uni.setStorageSync('inventoryAllocationScan', data)
- // uni.navigateTo({
- // url: '/pages/warehouse/inventoryAllocation/scanView?emitName=inventoryAllocationScanView&key=inventoryAllocationScan'
- // })
- // })
- // .finally(() => {
- // uni.hideLoading()
- // })
- },
- setScanMaterial(data) {
- console.log(data, '--------------------')
- const curMap = {
- assetId: 'id',
- assetCode: 'informationCode', //编码
- assetName: 'informationName', //名称
- materialId: 'id',
- materialName: 'informationName',
- batchNo: 'batchNum', //批次号
- unit: 'measuringUnit', //单位
- minPackUnit: 'packingUnit' //最小包装单位
- }
- let detail = {}
- for (const key in curMap) {
- detail[key] = (curMap[key] && data.information[curMap[key]]) || ''
- }
- const obj = {
- ...data.information,
- ...data.warehouseDetail,
- specification: data.information?.specification || data.warehouseDetail?.specification,
- detailReqList: [
- {
- ...data.warehouseDetail,
- ...detail,
- onlyCode: data.assetCode,
- batchNo: data.warehouseDetail?.batchNum
- }
- ],
- amount: 1,
- curId: data.warehouseDetail?.cargoSpaceId + data.warehouseDetail?.assetCode
- }
- const item = this.assetsList.find(itm => itm.curId === obj.curId)
- const preItem = this.preAssetsList.find(itm => itm.curId === obj.curId)
- const detailReqList = item?.detailReqList || []
- const preDetailReqList = preItem?.detailReqList || []
- if (item && detailReqList.find(i => i.onlyCode === data.assetCode)) {
- uni.showModal({
- title: '提示',
- content: '该物品已添加至待调入,请勿重复添加',
- success: async res => {}
- })
- return
- }
- if (preItem && preDetailReqList.find(i => i.onlyCode === data.assetCode)) {
- uni.showModal({
- title: '提示',
- content: '该物品已添加至预调入,请勿重复添加',
- success: async res => {}
- })
- return
- }
- console.log('this.obj-----------', obj)
- // if (item) {
- // if (obj.takeStockPattern) {
- // obj.amount = 1
- // } else {
- // obj.detailReqList.push(...detailReqList)
- // obj.amount = 1
- // }
- // }
- this.cargoSpaceInfoConfirm([obj])
- },
- // 带调出删除
- deleteItem(item) {
- uni.showModal({
- title: '提示',
- content: '确定删除当前数据?',
- success: async res => {
- if (res.confirm) {
- const index = this.assetsList.findIndex(i => i.curId === item.curId)
- if (index > -1) {
- this.assetsList.splice(index, 1)
- }
- }
- }
- })
- },
- handleDelete() {
- // uni.showModal({
- // title: '提示',
- // content: '确定删除当前调拨?',
- // success: async res => {
- // if (res.confirm) {
- // const res = await get(
- // this.apiUrl + `/conventionalStockTransfer/delete/${this.id}`,
- // {},
- // true
- // )
- // if (res.success) {
- // uni.showToast({
- // title: '删除成功!',
- // mask: true
- // })
- // setTimeout(() => {
- // uni.navigateBack({
- // delta: 1
- // })
- // }, 1500)
- // }
- // }
- // }
- // })
- },
- async _getDetail(id) {
- // const res = await get(
- // this.apiUrl +
- // `/conventionalStockTransfer/details/conventionalStockTransfer/${id}`
- // )
- if (res?.success) {
- this.formData = res.data.conventionalStockTransfer
- const assetsList = [],
- preAssetsList = []
- res.data.stockTransferInfoList.forEach(item => {
- let obj = {
- batchNum: item.batchNo,
- curId: item.outGoodsAllocationId + item.assetCode,
- ...item
- }
- if (obj.inGoodsAllocationId) {
- obj.inputChecked = false
- preAssetsList.push(obj)
- } else {
- if (!obj.takeStockPattern) {
- obj.curDetailReqList = uni.$u.deepClone(obj.detailReqList)
- }
- assetsList.push(obj)
- }
- })
- this.assetsList = assetsList
- this.preAssetsList = preAssetsList
- }
- },
- handleDetail(item) {
- this.$refs.detailRef.open(item, this.cargoSpaceId, res => {
- if (this.type === 'output') {
- this.$set(item, 'curDetailReqList', res)
- } else {
- this.$set(
- item,
- 'detailReqList',
- res.filter(i => i.checked)
- )
- }
- })
- },
- //退回待调出
- removeOutput() {
- if (!this.preAssetsList.some(i => i.inputChecked)) {
- uni.showToast({
- title: '请选择数据',
- icon: 'none'
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '确定移除当前选中?',
- success: res => {
- if (res.confirm) {
- for (let i = 0; i < this.preAssetsList.length; i++) {
- console.log(this.preAssetsList[i])
- if (this.preAssetsList[i].inputChecked) {
- const index = this.assetsList.findIndex(itm => itm.curId == this.preAssetsList[i].curId)
- if (index > -1) {
- if (this.preAssetsList[i].takeStockPattern) {
- this.assetsList[index].amount += this.preAssetsList[i].amount
- } else {
- this.assetsList[index].detailReqList.push(
- ...this.preAssetsList[i].detailReqList.map(itm => {
- itm.checked = false
- return itm
- })
- )
- this.assetsList[index].curDetailReqList = uni.$u.deepClone(this.assetsList[index].detailReqList)
- this.assetsList[index].amount = this.assetsList[index].detailReqList.length
- }
- } else {
- const obj = uni.$u.deepClone(this.preAssetsList[i])
- if (obj.takeStockPattern) {
- obj.curAmount = obj.amount
- } else {
- obj.curDetailReqList = obj.detailReqList
- obj.amount = obj.curDetailReqList.length
- }
- this.assetsList.push(obj)
- }
- this.preAssetsList.splice(i, 1)
- i--
- }
- }
- }
- }
- })
- },
- // 删除数据
- deleteOutput() {
- if (!this.preAssetsList.some(i => i.inputChecked)) {
- uni.showToast({
- title: '请选择数据',
- icon: 'none'
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '确定删除当前选中?',
- success: res => {
- if (res.confirm) {
- this.preAssetsList = this.preAssetsList.filter(i => !i.inputChecked)
- }
- }
- })
- },
- // 删除物料
- deleteMaterial() {
- this.assetsList = this.assetsList.filter(i => !i.checked)
- },
- // 预览
- handlePreview() {
- if (!this.preAssetsList.length) {
- uni.showToast({
- title: '请选择调拨资产',
- icon: 'none'
- })
- return
- }
- if (!this.formData.createUserName) {
- const userInfo = uni.getStorageSync('userInfo')
- ;(this.formData.createUserId = userInfo.id), (this.formData.createUserName = userInfo.name)
- }
- const params = {
- conventionalStockTransferReq: this.formData,
- infoReqList: this.preAssetsList.map(i => {
- delete i.curDetailReqList
- if (!i.takeStockPattern) {
- i.detailReqList = i.detailReqList.map(itm => {
- itm.dialType = this.formData.dialType
- let obj = {
- ...i,
- ...itm,
- produceId: itm.id
- }
- delete obj.detailReqList
- return obj
- })
- }
- return {
- batchNo: i.batchNum,
- ...i
- }
- })
- }
- delete params.conventionalStockTransferReq.createTime
- const storageKey = Date.now() + ''
- uni.removeStorageSync('inventoryAllocation_preview')
- uni.setStorageSync('inventoryAllocation_preview', {
- [storageKey]: { params, assetsList: this.assetsList }
- })
- if (!this.preAssetsList.length) {
- return this.$message.error('请选择调拨资产')
- }
- uni.navigateTo({
- url: '/pages/warehouse/inventoryAllocation/preview?id=' + storageKey
- })
- },
- // 获取当前调入调出信息
- getLocation(warehouse) {
- let cargoSpace = ''
- if (warehouse.areaName) {
- if (warehouse.shelfCode) {
- if (warehouse.cargoSpaceCode) {
- cargoSpace = warehouse.areaName + '-' + warehouse.shelfCode + '-' + warehouse.cargoSpaceCode
- } else {
- cargoSpace = warehouse.areaName + '-' + warehouse.shelfCode
- }
- } else {
- cargoSpace = warehouse.areaName
- }
- }
- return cargoSpace
- },
- //获取仓库信息
- handleWarehouseChoose(type) {
- if (!this.formData.warehouseId) {
- uni.showToast({
- title: '请设置调拨类型!',
- icon: 'none'
- })
- return
- }
- let warehouse = {}
- if (this.formData.dialType === 1) {
- warehouse.id = this.formData.warehouseId
- warehouse.name = this.formData.warehouseName
- this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
- console.log('库内调拨好了~~~')
- console.log(res)
- if (type === 'output') {
- // 调出货位
- if (!res.areaId) {
- uni.showToast({
- title: '请选择库区',
- icon: 'none'
- })
- return
- }
- this.navShow = false
- this.formData.cargoSpace = this.getLocation(res)
- this.formData.warehouse = res
- this.$refs.cargoSpaceInfoDialogRef.open(res)
- } else {
- // 调入货位
- if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId && this.formData.warehouse.cargoSpaceId) {
- // 调出库区/货架/货位
- console.log(res)
- console.log(this.formData)
- if (res.areaId && res.shelfId && res.cargoSpaceId) {
- if (this.formData.warehouse.areaId == res.areaId && this.formData.warehouse.shelfId == res.shelfId && this.formData.warehouse.cargoSpaceId == res.cargoSpaceId) {
- uni.showToast({
- title: '库区/货架/货位重复',
- icon: 'none'
- })
- return
- }
- } else {
- uni.showToast({
- title: '库区/货架/货位不能为空',
- icon: 'none'
- })
- return
- }
- } else if (this.formData.warehouse.areaId && this.formData.warehouse.shelfId && !this.formData.warehouse.cargoSpaceId) {
- // 调出库区/货架
- if (res.areaId && res.shelfId) {
- if (this.formData.warehouse.areaId == res.areaId && this.formData.warehouse.shelfId == res.shelfId) {
- uni.showToast({
- title: '库区/货架重复',
- icon: 'none'
- })
- return
- }
- } else {
- uni.showToast({
- title: '库区/货架不能为空',
- icon: 'none'
- })
- return
- }
- } else if (this.formData.warehouse.areaId && !this.formData.warehouse.shelfId && !this.formData.warehouse.cargoSpaceId) {
- // 调出库区
- if (res.areaId) {
- if (this.formData.warehouse.areaId == res.areaId) {
- uni.showToast({
- title: '库区重复',
- icon: 'none'
- })
- return
- }
- } else {
- uni.showToast({
- title: '请选择库区',
- icon: 'none'
- })
- return
- }
- }
- this.formData.inCargoSpace = this.getLocation(res)
- this.formData.inWarehouse = res
- }
- this.$refs.warehouseChooseRef.cancel()
- this.$forceUpdate()
- console.log(this.formData)
- })
- } else if (this.formData.dialType === 2) {
- if (type == 'output') {
- warehouse.id = this.formData.warehouseId
- warehouse.name = this.formData.warehouseName
- } else {
- warehouse.id = this.formData.inWarehouseId
- warehouse.name = this.formData.inWarehouseName
- }
- this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
- console.log('库外调拨好了~~~')
- console.log(res)
- if (type === 'output') {
- this.navShow = false
- this.formData.cargoSpace = this.getLocation(res)
- this.formData.warehouse = res
- this.$refs.cargoSpaceInfoDialogRef.open(res)
- } else {
- this.formData.inCargoSpace = this.getLocation(res)
- this.formData.inWarehouse = res
- }
- this.$refs.warehouseChooseRef.cancel()
- this.$forceUpdate()
- console.log(this.formData)
- })
- }
- },
- // handleWarehouseChoose(type) {
- // if (!this.formData.warehouseId) {
- // uni.showToast({
- // title: '请设置调拨类型!',
- // icon: 'none'
- // })
- // return
- // }
- // if (
- // type == 'input' &&
- // !this.assetsList.filter(item => {
- // return (item.takeStockPattern && item.curAmount > 0) || (!item.takeStockPattern && item.curDetailReqList?.filter(p => p.checked).length > 0)
- // }).length
- // ) {
- // uni.showToast({
- // title: '请选择待调入资产!',
- // icon: 'none'
- // })
- // return
- // }
- // let warehouse = {}
- // if (this.formData.dialType === 1) {
- // warehouse.id = this.formData.warehouseId
- // warehouse.name = this.formData.warehouseName
- // this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
- // if (type === 'output') {
- // this.navShow = false
- // this.$refs.cargoSpaceInfoDialogRef.open(res)
- // } else {
- // this.inputConfirm(res)
- // }
- // })
- // } else if (this.formData.dialType === 2) {
- // if (type == 'output') {
- // warehouse.id = this.formData.warehouseId
- // warehouse.name = this.formData.warehouseName
- // } else {
- // warehouse.id = this.formData.inWarehouseId
- // warehouse.name = this.formData.inWarehouseName
- // }
- // this.$refs.warehouseChooseRef.open({ ...warehouse, type }, res => {
- // if (type === 'output') {
- // this.navShow = false
- // this.$refs.cargoSpaceInfoDialogRef.open(res)
- // } else {
- // this.inputConfirm(res)
- // }
- // })
- // }
- // },
- // 选中调入库区
- inputConfirm(data) {
- this.$refs.warehouseChooseRef.cancel()
- this.navShow = false
- this.$refs.preInventoryRef
- .open(this.assetsList, data)
- .then(() => {
- for (let i = 0; i < this.assetsList.length; i++) {
- const item = this.assetsList[i]
- let obj = uni.$u.deepClone(item)
- if (item.takeStockPattern && item.curAmount > 0) {
- obj.amount = obj.curAmount
- delete obj.curAmount
- if (item.curAmount == item.amount) {
- this.assetsList.splice(i, 1)
- i--
- } else {
- item.amount -= item.curAmount
- item.curAmount = 0
- }
- this.preAssetsList.push({
- ...obj,
- inGoodsAllocationCode: data.cargoSpaceCode,
- inGoodsAllocationId: data.cargoSpaceId,
- inWarehouseAreaGoodsCode: data.shelfCode,
- inWarehouseAreaGoodsId: data.shelfId,
- inWarehouseAreaId: data.areaId,
- inWarehouseAreaName: data.areaName,
- inWarehouseId: data.warehouseId,
- inWarehouseName: data.warehouseName,
- inputChecked: false
- })
- }
- if (!item.takeStockPattern && item.curDetailReqList.filter(p => p.checked)?.length) {
- obj.detailReqList = obj.curDetailReqList.filter(p => p.checked)
- obj.amount = obj.detailReqList.length
- if (obj.amount === item.detailReqList.length) {
- this.assetsList.splice(i, 1)
- i--
- } else {
- item.curDetailReqList = item.curDetailReqList.filter(p => !p.checked)
- item.detailReqList = uni.$u.deepClone(item.curDetailReqList)
- item.amount = item.detailReqList.length
- }
- this.preAssetsList.push({
- ...obj,
- inGoodsAllocationCode: data.cargoSpaceCode,
- inGoodsAllocationId: data.cargoSpaceId,
- inWarehouseAreaGoodsCode: data.shelfCode,
- inWarehouseAreaGoodsId: data.shelfId,
- inWarehouseAreaId: data.areaId,
- inWarehouseAreaName: data.areaName,
- inWarehouseId: data.warehouseId,
- inWarehouseName: data.warehouseName,
- inputChecked: false
- })
- }
- }
- this.activeName = 'input'
- })
- .finally(() => (this.navShow = true))
- },
- //调出资产
- cargoSpaceInfoConfirm(assetsList) {
- console.log('assetsList-------', assetsList)
- this.$refs.warehouseChooseRef.cancel()
- this.assetsList = assetsList
- // // 已添加物品
- // this.assetsList.forEach(item => {
- // const index = assetsList.findIndex(i => i.curId === item.curId)
- // if (index > -1) {
- // let obj = assetsList.splice(index, 1)[0]
- // item.amount += obj.amount
- // if (obj.takeStockPattern) {
- // item.curAmount += obj.amount
- // } else {
- // const list = obj.detailReqList.filter(i => item.detailReqList.find(itm => i.onlyCode !== itm.onlyCode))
- // if (list.length > 0) {
- // item.detailReqList.push(...list)
- // item.curDetailReqList.push(...uni.$u.deepClone(list).map(i => ({ ...i, checked: true })))
- // }
- // }
- // }
- // })
- // // 未添加
- // this.assetsList.push(
- // ...assetsList.map(i => {
- // if (!i.takeStockPattern) {
- // i.curDetailReqList = uni.$u.deepClone(i.detailReqList).map(i => ({ ...i, checked: true }))
- // } else {
- // i.curAmount = i.amount
- // }
- // return {
- // ...i,
- // outGoodsAllocationCode: i.cargoSpaceCode,
- // outGoodsAllocationId: i.cargoSpaceId,
- // outWarehouseAreaGoodsCode: i.shelfCode,
- // outWarehouseAreaGoodsId: i.shelfId,
- // outWarehouseAreaId: i.areaId,
- // outWarehouseAreaName: i.areaName,
- // outWarehouseId: i.warehouseId,
- // outWarehouseName: i.warehouseName
- // }
- // })
- // )
- // console.log('this.assetsList-----------', this.assetsList)
- },
- getPopupInfo(warehouse) {
- // if (warehouse.warehouseName !== this.formData.warehouseName) {
- // this.assetsList = []
- // this.preAssetsList = []
- // }
- this.assetsList = []
- this.formData.cargoSpace = ''
- this.formData.inCargoSpace = ''
- this.formData.warehouse = {}
- this.formData.inWarehouse = {}
- Object.assign(this.formData, warehouse)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- $fixedHeight: 580rpx;
- $fixedHeightOut: 480rpx;
- .flex-center {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 10rpx 20rpx;
- box-sizing: border-box;
- .flex_input {
- flex: 1;
- display: flex;
- align-items: center;
- .u-input {
- padding: 0 !important;
- }
- }
- }
- .btn {
- color: #70b603;
- font-size: 32rpx;
- }
- .isOut .tool-wrapper {
- height: $fixedHeightOut;
- }
- .tool-wrapper {
- position: fixed;
- left: 0;
- height: $fixedHeight;
- width: 100vw;
- font-size: 28rpx;
- color: #333;
- background-color: #fff;
- z-index: 1;
- .required::before {
- content: '*';
- color: red;
- }
- .info {
- background-color: rgba(242, 242, 242, 0.792156862745098);
- margin: 8rpx 0;
- }
- .tabs {
- background-color: rgba(242, 242, 242, 0.792156862745098);
- padding-top: 20rpx;
- display: flex;
- justify-content: space-between;
- margin-bottom: 20rpx;
- .tab-item {
- padding-top: 20rpx;
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- &.active {
- background: linear-gradient(180deg, rgba(75, 121, 2, 1) 0%, rgba(255, 255, 255, 1) 12%);
- }
- }
- }
- .operations {
- font-size: 32rpx;
- padding: 10rpx 40rpx;
- color: rgba(75, 121, 2, 1);
- }
- .search-box {
- padding: 10rpx;
- }
- .select-box {
- border-bottom: 1rpx solid #d7d7d7;
- white-space: nowrap;
- }
- }
- .isOut .list-container {
- padding-top: $fixedHeightOut;
- }
- .list-container {
- padding-top: $fixedHeight;
- padding-bottom: 80rpx;
- }
- .preview-box {
- position: fixed;
- bottom: 0;
- width: 100vw !important;
- }
- </style>
|