|
|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="printwrap">
|
|
|
|
|
<Modal v-model="isShow" width="70" title="出库">
|
|
|
|
|
<div class="printwrap">
|
|
|
|
|
|
|
|
|
|
<Modal v-model="isShow" width="70" title="出库" :loading="showLoading">
|
|
|
|
|
<!-- :class="{'watermark':!showwatermark}" -->
|
|
|
|
|
<div id="printmodal" class="print">
|
|
|
|
|
<div class="print" id="printmodal">
|
|
|
|
|
<div class="printtitle">苏州市河道管理处物资出库记录单</div>
|
|
|
|
|
<div class="printtop">
|
|
|
|
|
<span>业务科室:{{ form.jieyongbumen }}</span>
|
|
|
|
|
@ -12,27 +13,39 @@
|
|
|
|
|
<tr>
|
|
|
|
|
<td>出库日期</td>
|
|
|
|
|
<td>物资名称</td>
|
|
|
|
|
<td>批次</td>
|
|
|
|
|
<td>物资类型</td>
|
|
|
|
|
<td>批次</td>
|
|
|
|
|
<td>批内序号</td>
|
|
|
|
|
<td>数量</td>
|
|
|
|
|
<td>规格</td>
|
|
|
|
|
<td>型号</td>
|
|
|
|
|
<td>型号</td>
|
|
|
|
|
<td v-if="isChange">操作</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr v-for="item in mingxiList">
|
|
|
|
|
<td>{{ form.chukushijian }}</td>
|
|
|
|
|
<td>{{ item.zichanmingcheng }}</td>
|
|
|
|
|
<td>{{ item.rukupici }}</td>
|
|
|
|
|
<td>{{ item.jieyongshuliang }}</td>
|
|
|
|
|
<td>{{ item.zichanmingcheng }}</td>
|
|
|
|
|
<td>{{ item.wuzileixing }}</td>
|
|
|
|
|
<td>{{ item.rukupici }}</td>
|
|
|
|
|
<td>
|
|
|
|
|
<div v-for="inven in item.inventorys">
|
|
|
|
|
{{inven?inven.shunxuhao:''}}
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td>{{ item.wuzileixing==='一物一码'?item.inventorys.length:item.jieyongshuliang }}</td>
|
|
|
|
|
<td>{{ item.wuziguige }}</td>
|
|
|
|
|
<td>{{ item.guigexinghao }}</td>
|
|
|
|
|
<td>{{ item.guigexinghao }}</td>
|
|
|
|
|
<td v-if="isChange" @click="changeWz(item)">
|
|
|
|
|
<el-button size="small" type="primary">更改出库序号</el-button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="6">
|
|
|
|
|
<td :colspan="isChange?9:8">
|
|
|
|
|
<p>备注</p>
|
|
|
|
|
<p>{{form.beizhu}}</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class="printbottom">
|
|
|
|
|
<td colspan="3" rowspan="3">
|
|
|
|
|
<td :colspan="isChange?4:4" rowspan="4">
|
|
|
|
|
<p>经办人签字区</p>
|
|
|
|
|
<p>
|
|
|
|
|
<span>年</span>
|
|
|
|
|
@ -40,7 +53,7 @@
|
|
|
|
|
<span>日</span>
|
|
|
|
|
</p>
|
|
|
|
|
</td>
|
|
|
|
|
<td colspan="3" rowspan="3">
|
|
|
|
|
<td :colspan="isChange?5:4" rowspan="4">
|
|
|
|
|
<p>仓库管理员签字区</p>
|
|
|
|
|
<p><span>年</span>
|
|
|
|
|
<span>月</span>
|
|
|
|
|
@ -112,21 +125,45 @@
|
|
|
|
|
</div> -->
|
|
|
|
|
<template v-slot:footer>
|
|
|
|
|
<Button type="info" style="margin-left:5px;margin-bottom:5px;" @click="isShow=false">取消</Button>
|
|
|
|
|
<Button v-print="'#printmodal'" type="primary" style="margin-left:5px;margin-bottom:5px;">打印</Button>
|
|
|
|
|
<Button ref="prints" v-print="'#printmodal'" @click="clickPrint" type="primary" style="margin-left:5px;margin-bottom:5px;">打印</Button>
|
|
|
|
|
<Button type="primary" style="margin-left:5px;margin-bottom:5px;" @click="submit">出库</Button>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
v-model="isShowMingxi"
|
|
|
|
|
width="600"
|
|
|
|
|
title="更改出库序号"
|
|
|
|
|
>
|
|
|
|
|
<div class="mingxiwrap">
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">
|
|
|
|
|
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>出库序号:
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-select multiple v-model="mingxiObj.inventorys_id" style="width: 300px;" placeholder="请选择">
|
|
|
|
|
<el-option v-for="item in sxhList" :key="item.id" :label="item.shunxuhao" :value="item.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<template v-slot:footer>
|
|
|
|
|
<Button type="info" style="margin-left:5px;margin-bottom:5px;" @click="mingxiCancel">取消</Button>
|
|
|
|
|
<Button type="primary" style="margin-left:5px;margin-bottom:5px;" @click="mingxiConfirm">确认更改</Button>
|
|
|
|
|
</template>
|
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// import {
|
|
|
|
|
// show,
|
|
|
|
|
// save,
|
|
|
|
|
// } from '@/api/system/baseForm.js'
|
|
|
|
|
import {
|
|
|
|
|
show,
|
|
|
|
|
save,
|
|
|
|
|
} from '@/api/system/baseForm.js'
|
|
|
|
|
import {
|
|
|
|
|
saveOutbounds
|
|
|
|
|
saveOutbounds,
|
|
|
|
|
show
|
|
|
|
|
} from '@/api/outbounds.js'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
@ -137,17 +174,24 @@ import {
|
|
|
|
|
} from '@/api/system/log.js'
|
|
|
|
|
import {
|
|
|
|
|
getToken
|
|
|
|
|
} from '@/utils/auth'
|
|
|
|
|
} from '@/utils/auth'
|
|
|
|
|
import {
|
|
|
|
|
index
|
|
|
|
|
} from '@/api/inventory.js'
|
|
|
|
|
import {deepCopy} from "@/utils/index.js"
|
|
|
|
|
export default {
|
|
|
|
|
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
isShow: false,
|
|
|
|
|
isShow: false,
|
|
|
|
|
showLoading:false,
|
|
|
|
|
isShowMingxi:false,
|
|
|
|
|
type: 'print',
|
|
|
|
|
id: '',
|
|
|
|
|
chukuType: '',
|
|
|
|
|
tableName: 'outbounds',
|
|
|
|
|
showwatermark: true,
|
|
|
|
|
showwatermark: true,
|
|
|
|
|
isChange:true,
|
|
|
|
|
form: {
|
|
|
|
|
chukushijian: '',
|
|
|
|
|
chukuleixing: '',
|
|
|
|
|
@ -157,13 +201,16 @@ export default {
|
|
|
|
|
jilurenyuan: '',
|
|
|
|
|
beizhu: '',
|
|
|
|
|
chukumingxi: ''
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
ywymList:[], //更改的 序号 数组
|
|
|
|
|
sxhList:[],
|
|
|
|
|
mingxiList: [],
|
|
|
|
|
fileList: [],
|
|
|
|
|
action: process.env.VUE_APP_UPLOAD_API,
|
|
|
|
|
headers: {
|
|
|
|
|
token: ''
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
mingxiObj:{},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
@ -176,16 +223,22 @@ export default {
|
|
|
|
|
this.id = ''
|
|
|
|
|
this.type = 'print'
|
|
|
|
|
this.showwatermark = true
|
|
|
|
|
this.isChange = true
|
|
|
|
|
this.form = {}
|
|
|
|
|
this.fileList = []
|
|
|
|
|
this.mingxiList = []
|
|
|
|
|
this.mingxiList = []
|
|
|
|
|
this.ywymList = []
|
|
|
|
|
this.sxhList = []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.headers.token = getToken()
|
|
|
|
|
this.headers.token = getToken()
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
methods: {
|
|
|
|
|
clickPrint(){
|
|
|
|
|
this.isChange = false
|
|
|
|
|
},
|
|
|
|
|
beforeUpload(file) {
|
|
|
|
|
// if (file.size / 1000 > 500) {
|
|
|
|
|
// this.$message({
|
|
|
|
|
@ -223,16 +276,162 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
async getDetail() {
|
|
|
|
|
const res = await show({
|
|
|
|
|
id: this.id,
|
|
|
|
|
table_name: this.tableName
|
|
|
|
|
id: this.id
|
|
|
|
|
})
|
|
|
|
|
this.form = res
|
|
|
|
|
// if (res.zhuangtai == 2) {
|
|
|
|
|
// this.showwatermark = true
|
|
|
|
|
// } else {
|
|
|
|
|
// this.showwatermark = false
|
|
|
|
|
// }
|
|
|
|
|
this.mingxiList = res.id_outbounds_items_outbounds_id_relation
|
|
|
|
|
// }
|
|
|
|
|
// res.id_outbounds_items_outbounds_id_relation.map(item=>{
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
this.ywymList = deepCopy(res.id_outbounds_items_outbounds_id_relation)
|
|
|
|
|
this.mingxiList = this.mergeSameWuzibianma(res.id_outbounds_items_outbounds_id_relation)
|
|
|
|
|
console.log("this.mingxiList",this.mingxiList,this.ywymList)
|
|
|
|
|
},
|
|
|
|
|
//
|
|
|
|
|
mergeSameWuzibianma(arr) {
|
|
|
|
|
// 1. 筛选出 wuzileixing = "一物一码" 的数据
|
|
|
|
|
const yiwuData = arr.filter(item => item.wuzileixing === "一物一码");
|
|
|
|
|
|
|
|
|
|
// 2. 筛选出 wuzileixing = "一类一码" 的数据(不处理,直接保留)
|
|
|
|
|
const yileiData = arr.filter(item => item.wuzileixing === "一类一码");
|
|
|
|
|
|
|
|
|
|
// 3. 按 wuzibianma 分组
|
|
|
|
|
const groups = yiwuData.reduce((acc, item) => {
|
|
|
|
|
const key = item.wuzibianma; // 以 wuzibianma 为分组键
|
|
|
|
|
if (!acc[key]) {
|
|
|
|
|
acc[key] = []; // 初始化分组
|
|
|
|
|
}
|
|
|
|
|
acc[key].push(item);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
// 4. 合并每组数据:相同字段保留,差异字段合并为数组
|
|
|
|
|
const mergedYiwuData = Object.values(groups).map(group => {
|
|
|
|
|
// 取组内第一条数据作为基础(其他字段相同,任意一条均可)
|
|
|
|
|
const base = { ...group[0] };
|
|
|
|
|
|
|
|
|
|
// 收集差异字段(id、inventorys_id、inventorys)
|
|
|
|
|
const ids = group.map(item => item.id);
|
|
|
|
|
const inventorysIds = group.map(item => Number(item.inventorys_id));
|
|
|
|
|
const inventorysList = group.map(item => item.inventorys);
|
|
|
|
|
|
|
|
|
|
// 替换基础数据中的差异字段为数组
|
|
|
|
|
return {
|
|
|
|
|
...base,
|
|
|
|
|
id: ids, // 合并所有id为数组
|
|
|
|
|
inventorys_id: inventorysIds, // 合并所有inventorys_id为数组
|
|
|
|
|
inventorys: inventorysList // 合并所有inventorys为数组
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 5. 合并处理后的“一物一码”和未处理的“一类一码”数据
|
|
|
|
|
return [...mergedYiwuData, ...yileiData];
|
|
|
|
|
},
|
|
|
|
|
changeWz(row){
|
|
|
|
|
this.showLoading = true
|
|
|
|
|
this.mingxiObj = deepCopy(row)
|
|
|
|
|
console.log("this.mingxiObj",this.mingxiObj)
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
this.getInventory(row.wuzibianma)
|
|
|
|
|
this.isShowMingxi = true
|
|
|
|
|
this.showLoading = false
|
|
|
|
|
},
|
|
|
|
|
async getInventory(wzbm){
|
|
|
|
|
const res = await index({
|
|
|
|
|
page:1,
|
|
|
|
|
page_size:999,
|
|
|
|
|
filter: [ {
|
|
|
|
|
'key': 'wuzibianma',
|
|
|
|
|
'op': 'like',
|
|
|
|
|
'value': wzbm
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
this.sxhList = res.list.data.filter(item=> (Number(item.zaikushuliang) - item.wait_num)>0)
|
|
|
|
|
},
|
|
|
|
|
mingxiConfirm(){
|
|
|
|
|
console.log("obj",this.mingxiObj)
|
|
|
|
|
if(this.mingxiObj.inventorys_id.length>this.mingxiObj.inventorys.length || this.mingxiObj.inventorys_id.length<this.mingxiObj.inventorys.length){
|
|
|
|
|
Message({
|
|
|
|
|
type: 'warning',
|
|
|
|
|
message: `需出库${this.mingxiObj.inventorys.length}件物资`
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log("list",this.replaceAndSplit(this.mingxiList,this.mingxiObj))
|
|
|
|
|
let list = this.replaceAndSplit(this.mingxiList,this.mingxiObj)
|
|
|
|
|
saveOutbounds({
|
|
|
|
|
...this.form,
|
|
|
|
|
id_outbounds_items_outbounds_id_relation:list
|
|
|
|
|
}).then(res => {
|
|
|
|
|
Message({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '更改成功'
|
|
|
|
|
})
|
|
|
|
|
this.mingxiObj = {}
|
|
|
|
|
this.mingxiList = []
|
|
|
|
|
this.getDetail()
|
|
|
|
|
this.isShowMingxi = false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
mingxiCancel(){
|
|
|
|
|
this.mingxiObj = {}
|
|
|
|
|
this.mingxiList = []
|
|
|
|
|
this.isShowMingxi = false
|
|
|
|
|
},
|
|
|
|
|
replaceAndSplit(mergedArr, mingxiObj) {
|
|
|
|
|
// 1. 复制合并数组(避免修改原数组)
|
|
|
|
|
const newMergedArr = [...mergedArr];
|
|
|
|
|
|
|
|
|
|
// 2. 找到需要替换的项的索引(根据 wuzibianma 匹配)
|
|
|
|
|
const targetIndex = newMergedArr.findIndex(
|
|
|
|
|
item => item.wuzibianma === mingxiObj.wuzibianma
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 3. 如果找到匹配项,则替换
|
|
|
|
|
if (targetIndex !== -1) {
|
|
|
|
|
newMergedArr[targetIndex] = mingxiObj;
|
|
|
|
|
} else {
|
|
|
|
|
console.warn('未找到匹配的 wuzibianma,无法替换');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. 执行拆分逻辑(复用之前的拆分函数)
|
|
|
|
|
return this.splitMergedArray(newMergedArr);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 复用之前的拆分函数
|
|
|
|
|
splitMergedArray(mergedArr) {
|
|
|
|
|
const result = [];
|
|
|
|
|
|
|
|
|
|
mergedArr.forEach(item => {
|
|
|
|
|
if (item.wuzileixing === "一类一码") {
|
|
|
|
|
result.push(item);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.wuzileixing === "一物一码") {
|
|
|
|
|
const len = Math.min(
|
|
|
|
|
item.id?.length || 0,
|
|
|
|
|
item.inventorys_id?.length || 0,
|
|
|
|
|
item.inventorys?.length || 0
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
|
const splitItem = { ...item };
|
|
|
|
|
splitItem.id = item.id[i];
|
|
|
|
|
splitItem.inventorys_id = item.inventorys_id[i];
|
|
|
|
|
splitItem.inventorys = item.inventorys[i];
|
|
|
|
|
result.push(splitItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
handlePrint() {
|
|
|
|
|
if (this.chukuType == '领用') {
|
|
|
|
|
|