| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270 |
- <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">
- <u-form labelPosition="left" :model="formData" :rules="rules" ref="formRef" labelWidth="180"
- labelAlign="right" class="baseForm">
- <u-form-item label="调拨条数" prop="createUserName" borderBottom>
- <view class="flex-center" style="width: 100%;">
- <view>
- <text> {{ assetsList.length + preAssetsList.length }}</text>
- </view>
- <view class="btn required" @click="$refs.typeSettingRef.open(formData)">调拨类型设置</view>
- </view>
- </u-form-item>
- <u-form-item label="调拨编码" prop="code" borderBottom>
- <u-input disableColor="#ffffff" v-model="formData.code" disabled type="text" />
- </u-form-item>
- <u-form-item label="调拨单名称" prop="name" borderBottom class="required-form">
- <u-input disableColor="#ffffff" v-model="formData.name" placeholder="请输入" type="text" />
- </u-form-item>
- <u-form-item label="调拨类型" prop="dialType" borderBottom>
- <u-input disableColor="#ffffff" v-model="dialTypeOptions[formData.dialType]" disabled type="text" />
- </u-form-item>
- <u-form-item label="调出仓库" prop="warehouseName" borderBottom>
- <text
- style="height: 24px;padding:6px 9px;">{{ formData.warehouseName }}{{ formData.cargoSpace ? '(' + formData.cargoSpace + ')' : '' }}</text>
- </u-form-item>
- <u-form-item label="调入仓库" prop="inWarehouseName" borderBottom>
- <text
- style="height: 24px;padding:6px 9px;">{{ formData.inWarehouseName }}{{ formData.inCargoSpace ? '(' + formData.inCargoSpace + ')' : '' }}</text>
- </u-form-item>
- </u-form>
- <!-- <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> -->
- <view 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>
- <!-- <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 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" :index="index+Number(1)"
- @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" :index="index+Number(1)"
- type="input">
- </AssetsCard>
- </view>
- <!-- <u-button type="success" class="preview-box" :plain="true" @click="handlePreview">预览</u-button> -->
- <u-button type="" 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: '',
- rules: {
- name: {
- required: true,
- errorMessage: '请输入调拨名称',
- }
- }
- }
- },
- 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: $theme-color;
- 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: $theme-color;
- }
- .search-box {
- padding: 10rpx;
- }
- .select-box {
- border-bottom: 1rpx solid #d7d7d7;
- white-space: nowrap;
- }
- }
- /deep/.baseForm {
- .u-form-item__body {
- padding: 4px !important;
- }
- .assetType_box {
- padding: 12rpx 18rpx;
- width: 100%;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- font-size: 30rpx;
- }
- }
- /deep/.required-form .u-form-item__body__left__content__label::before {
- content: '*';
- color: red;
- }
- /deep/.u-form-item__body {
- padding: 0 !important;
- }
- /deep/.u-input__content__field-wrapper__field,
- /deep/.u-form-item {
- font-size: 28rpx !important;
- }
- .isOut .list-container {
- // padding-top: $fixedHeightOut;
- margin-top: 10px;
- }
- .list-container {
- padding-top: $fixedHeight;
- padding-bottom: 80rpx;
- }
- .preview-box {
- position: fixed;
- bottom: 0;
- width: 100vw !important;
- border: 1px solid $theme-color;
- color: $theme-color;
- }
- </style>
|