| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268 |
- <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="padding-left: 20rpx;">{{ formData.warehouseName }}{{ formData.cargoSpace ? '(' + formData.cargoSpace + ')' : '' }}</text>
- </u-form-item>
- <u-form-item label="调入仓库" prop="inWarehouseName" borderBottom>
- <text style="padding-left: 20rpx;">{{ 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>
|