|
|
|
|
@ -1,71 +1,29 @@ |
|
|
|
|
<template> |
|
|
|
|
<el-dialog title="新增" append-to-body :modelValue="openShow" width="70%" @close="closeDialog" fullscreen> |
|
|
|
|
<!-- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> |
|
|
|
|
<el-row :gutter="24"> |
|
|
|
|
|
|
|
|
|
<el-col :span="8"> |
|
|
|
|
<el-form-item label="申报人" prop="userId"> |
|
|
|
|
<el-select v-model="ruleForm.userId" placeholder="请选择" disabled> |
|
|
|
|
<el-option label="申报人一" value="1"> |
|
|
|
|
</el-option> |
|
|
|
|
<el-option label="申报人二" value="2"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
|
|
|
|
|
<el-col :span="8"> |
|
|
|
|
<el-form-item label="申报日期" prop="declareDate"> |
|
|
|
|
<el-date-picker v-model="ruleForm.declareDate" type="date" placeholder="选择日期" |
|
|
|
|
style="width: 100%;"> |
|
|
|
|
</el-date-picker> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="8"> |
|
|
|
|
<el-form-item label="需求日期" prop="needDate"> |
|
|
|
|
<el-date-picker v-model="ruleForm.needDate" type="date" placeholder="选择日期" style="width: 100%;"> |
|
|
|
|
</el-date-picker> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="8"> |
|
|
|
|
<el-form-item label="采购部门" prop="buyDept"> |
|
|
|
|
<el-select v-model="ruleForm.buyDept" placeholder="请选择"> |
|
|
|
|
<el-option label="采购部门一" value="1"> |
|
|
|
|
</el-option> |
|
|
|
|
<el-option label="采购部门二" value="2"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="8"> |
|
|
|
|
<el-form-item label="需求部门" prop="needDept"> |
|
|
|
|
<el-select v-model="ruleForm.needDept" placeholder="请选择"> |
|
|
|
|
<el-option label="需求部门一" value="1"> |
|
|
|
|
</el-option> |
|
|
|
|
<el-option label="需求部门二" value="2"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
|
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
</el-form> --> |
|
|
|
|
<div style="margin-bottom: 12px;" v-if="moldAddMore"> |
|
|
|
|
<el-dialog |
|
|
|
|
title="新增" |
|
|
|
|
append-to-body |
|
|
|
|
:modelValue="openShow" |
|
|
|
|
width="70%" |
|
|
|
|
@close="closeDialog" |
|
|
|
|
fullscreen |
|
|
|
|
> |
|
|
|
|
<div style="margin-bottom: 12px" v-if="moldAddMore"> |
|
|
|
|
<el-button type="primary" @click="addTable">插入一行</el-button> |
|
|
|
|
<el-button type="danger" @click="handleDelete">删除行</el-button> |
|
|
|
|
</div> |
|
|
|
|
<el-table :data="tableData" style="width: 100%" @select="selectChange" border> |
|
|
|
|
<el-table |
|
|
|
|
:data="tableData" |
|
|
|
|
:height="tableHeight" |
|
|
|
|
style="width: 100%" |
|
|
|
|
@select="selectChange" |
|
|
|
|
border |
|
|
|
|
> |
|
|
|
|
<el-table-column type="selection" width="55"></el-table-column> |
|
|
|
|
<el-table-column prop="goodsId" label="物料编号" align="center"> |
|
|
|
|
<template #header> |
|
|
|
|
<span><i style="color: red">*</i>物料编号</span> |
|
|
|
|
</template> |
|
|
|
|
<template #default="scope"> |
|
|
|
|
<!-- <el-select v-model="scope.row.goodsCode" placeholder="请选择" style="width: 100%" |
|
|
|
|
@change="(val) => changeGoods(val,scope.$index)"> |
|
|
|
|
<el-option v-for="item in goodsList" :key="item.id" :label="item.goodsCode" :value="item.goodsCode"></el-option> |
|
|
|
|
</el-select> --> |
|
|
|
|
<jhSelect |
|
|
|
|
v-model="scope.row.goodsCode" |
|
|
|
|
placeholder="请搜索选择" |
|
|
|
|
@ -82,7 +40,6 @@ |
|
|
|
|
:debounce-time="100" |
|
|
|
|
@change="(val, item) => changeGoods(val, item, scope.row, scope.$index)" |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="goodsName" label="物料名称" align="center"></el-table-column> |
|
|
|
|
@ -96,57 +53,86 @@ |
|
|
|
|
<span><i style="color: red">*</i>提请数量</span> |
|
|
|
|
</template> |
|
|
|
|
<template #default="scope"> |
|
|
|
|
<el-input-number v-model="scope.row.quantity" :min="1" controls-position="right" @change="handleChange" |
|
|
|
|
style="width: 100%" /> |
|
|
|
|
<el-input-number |
|
|
|
|
v-model="scope.row.quantity" |
|
|
|
|
:min="1" |
|
|
|
|
controls-position="right" |
|
|
|
|
@change="handleChange" |
|
|
|
|
style="width: 100%" |
|
|
|
|
/> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="woCode" label="关联订单号" align="center"> |
|
|
|
|
<template #default="scope"> |
|
|
|
|
<el-input v-model="scope.row.woCode" style="width: 100%" placeholder="请输入" /> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="memo" label="备注" align="center"> |
|
|
|
|
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
<el-input v-model="scope.row.memo" style="width: 100%" placeholder="请输入" /> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="approver" label="审批人" align="center"> |
|
|
|
|
<template #header> |
|
|
|
|
<span><i style="color: red">*</i>审批人</span> |
|
|
|
|
</template> |
|
|
|
|
<template #default="scope"> |
|
|
|
|
<el-select |
|
|
|
|
v-model="scope.row.approver" |
|
|
|
|
clearable |
|
|
|
|
filterable |
|
|
|
|
placeholder="请选择" |
|
|
|
|
style="width: 100%" |
|
|
|
|
@change="val => handleApproverChange(val, scope.row, scope.$index)" |
|
|
|
|
> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in approverList" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id" |
|
|
|
|
></el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column fixed="right" label="操作" min-width="40"> |
|
|
|
|
<template #default="scope"> |
|
|
|
|
<el-button link type="primary" size="small" @click.prevent="delTable(scope.row, scope.$index)"> |
|
|
|
|
<el-button |
|
|
|
|
link |
|
|
|
|
type="primary" |
|
|
|
|
size="small" |
|
|
|
|
@click.prevent="delTable(scope.row, scope.$index)" |
|
|
|
|
> |
|
|
|
|
删除 |
|
|
|
|
</el-button> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
|
|
</el-table> |
|
|
|
|
|
|
|
|
|
<template #footer> |
|
|
|
|
<span class="dialog-footer"> |
|
|
|
|
<el-button @click="closeDialog">取 消</el-button> |
|
|
|
|
<el-button type="primary" @click="submit">确 定</el-button> |
|
|
|
|
<el-button @click="closeDialog" :loading="submitLoading">取 消</el-button> |
|
|
|
|
<el-button type="primary" @click="submit" :loading="submitLoading">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</template> |
|
|
|
|
</el-dialog> |
|
|
|
|
</template> |
|
|
|
|
<script> |
|
|
|
|
import {getMaterialList,addRequests} from "@/api/storeManagement/teamRequest" |
|
|
|
|
import { getMaterialList, addRequests } from '@/api/storeManagement/teamRequest'; |
|
|
|
|
import { getUserByRoleAlias } from '@/api/storeManagement/warehouseMaintenance'; |
|
|
|
|
export default { |
|
|
|
|
props: { |
|
|
|
|
showDialog: { |
|
|
|
|
type: Boolean, |
|
|
|
|
default: false |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
moldAddMore: { |
|
|
|
|
type: Boolean, |
|
|
|
|
default: false |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
buyCycle: { |
|
|
|
|
type: Number, |
|
|
|
|
default: 0 |
|
|
|
|
} |
|
|
|
|
default: 0, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
@ -159,57 +145,67 @@ export default { |
|
|
|
|
needDept: null, |
|
|
|
|
}, |
|
|
|
|
rules: { |
|
|
|
|
userId: [ |
|
|
|
|
{ required: true, message: '请选择', trigger: 'blur' }, |
|
|
|
|
], |
|
|
|
|
declareDate: [ |
|
|
|
|
{ required: true, message: '请选择', trigger: 'blur' }, |
|
|
|
|
], |
|
|
|
|
needDate: [ |
|
|
|
|
{ required: true, message: '请选择', trigger: 'blur' }, |
|
|
|
|
], |
|
|
|
|
buyDept: [ |
|
|
|
|
{ required: true, message: '请选择', trigger: 'blur' }, |
|
|
|
|
], |
|
|
|
|
needDept: [ |
|
|
|
|
{ required: true, message: '请选择', trigger: 'blur' }, |
|
|
|
|
], |
|
|
|
|
userId: [{ required: true, message: '请选择', trigger: 'blur' }], |
|
|
|
|
declareDate: [{ required: true, message: '请选择', trigger: 'blur' }], |
|
|
|
|
needDate: [{ required: true, message: '请选择', trigger: 'blur' }], |
|
|
|
|
buyDept: [{ required: true, message: '请选择', trigger: 'blur' }], |
|
|
|
|
needDept: [{ required: true, message: '请选择', trigger: 'blur' }], |
|
|
|
|
approver: [{ required: true, message: '请选择', trigger: 'blur' }], |
|
|
|
|
}, |
|
|
|
|
tableData: [], |
|
|
|
|
boCode: 'BO-2025001', |
|
|
|
|
goodsList:[] |
|
|
|
|
} |
|
|
|
|
goodsList: [], |
|
|
|
|
tableHeight: 0, |
|
|
|
|
approverList: [], //审批人列表 |
|
|
|
|
submitLoading: false, |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
this.openShow = this.showDialog |
|
|
|
|
this.getMaterialList() |
|
|
|
|
this.openShow = this.showDialog; |
|
|
|
|
this.getApproverList(); |
|
|
|
|
this.getMaterialList(); |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.calcTableHeight(); |
|
|
|
|
}); |
|
|
|
|
window.addEventListener('resize', this.calcTableHeight); |
|
|
|
|
}, |
|
|
|
|
beforeDestroy() { |
|
|
|
|
window.removeEventListener('resize', this.calcTableHeight); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
getApproverList() { |
|
|
|
|
getUserByRoleAlias({ roleAlias: 'sj_craft,rb_craft' }).then(res => { |
|
|
|
|
this.approverList = res.data.data; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
handleApproverChange(val, row, index) { |
|
|
|
|
const selectedItem = this.approverList.find(item => item.id === val); |
|
|
|
|
const label = selectedItem ? selectedItem.name : ''; |
|
|
|
|
this.tableData[index].approverName = label; |
|
|
|
|
}, |
|
|
|
|
calcTableHeight() { |
|
|
|
|
const headerHeight = 50; // 估算头部按钮高度 |
|
|
|
|
const footerHeight = 60; // 估算底部 footer 高度 |
|
|
|
|
const padding = 40; // 估算 padding |
|
|
|
|
this.tableHeight = window.innerHeight - headerHeight - footerHeight - padding - 40; |
|
|
|
|
}, |
|
|
|
|
changeGoods(val, item, row, index) { |
|
|
|
|
console.log(val, item, row, index); |
|
|
|
|
if (item != undefined) { |
|
|
|
|
this.tableData[index].goodsName = item.goodsName; |
|
|
|
|
this.tableData[index].goodsId = item.id |
|
|
|
|
this.tableData[index].goodsId = item.id; |
|
|
|
|
this.tableData[index].specifications = item.specifications; |
|
|
|
|
this.tableData[index].currentQuantity = item.currentQuantity |
|
|
|
|
this.tableData[index].currentQuantity = item.currentQuantity; |
|
|
|
|
this.tableData[index].materialModel = item.materialModel; |
|
|
|
|
this.tableData[index].avlQuantity = item.avlQuantity |
|
|
|
|
this.tableData[index].avlQuantity = item.avlQuantity; |
|
|
|
|
} |
|
|
|
|
// let tmp = this.goodsList.find(item => item.goodsCode == val) |
|
|
|
|
// this.tableData[index].goodsName = tmp.goodsName |
|
|
|
|
// this.tableData[index].goodsId = tmp.id |
|
|
|
|
// this.tableData[index].materialModel = tmp.materialModel |
|
|
|
|
// this.tableData[index].specifications = tmp.specifications |
|
|
|
|
// this.tableData[index].currentQuantity = tmp.currentQuantity |
|
|
|
|
// this.tableData[index].avlQuantity = tmp.avlQuantity |
|
|
|
|
}, |
|
|
|
|
getMaterialList() { |
|
|
|
|
getMaterialList().then(res => { |
|
|
|
|
this.goodsList = res.data.data.records |
|
|
|
|
}) |
|
|
|
|
this.goodsList = res.data.data.records; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
closeDialog(val) { |
|
|
|
|
this.openShow = false |
|
|
|
|
this.openShow = false; |
|
|
|
|
this.$emit('closeDialog', val); |
|
|
|
|
}, |
|
|
|
|
// 插入一行 |
|
|
|
|
@ -226,7 +222,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
// 新增一行 |
|
|
|
|
const record = { _select: false, boCode, buyCycle: this.buyCycle, planArea: '洛阳新区' }; |
|
|
|
|
this.tableData.push(record) |
|
|
|
|
this.tableData.push(record); |
|
|
|
|
}, |
|
|
|
|
selectChange(list, row) { |
|
|
|
|
row._select = !row._select; |
|
|
|
|
@ -235,7 +231,7 @@ export default { |
|
|
|
|
let tmp = this.tableData.find(item => item._select === true); |
|
|
|
|
if (!tmp) { |
|
|
|
|
this.$message.error('请先选择数据'); |
|
|
|
|
return |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.$confirm('确定删除数据吗?', { |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
@ -243,7 +239,7 @@ export default { |
|
|
|
|
type: 'warning', |
|
|
|
|
}).then(() => { |
|
|
|
|
this.tableData = this.tableData.filter(row => !row._select); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 删除一行 |
|
|
|
|
delTable(row, index) { |
|
|
|
|
@ -252,23 +248,28 @@ export default { |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning', |
|
|
|
|
}).then(() => { |
|
|
|
|
this.tableData.splice(index, 1) |
|
|
|
|
}) |
|
|
|
|
this.tableData.splice(index, 1); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
submit() { |
|
|
|
|
if (this.tableData.length == 0) { |
|
|
|
|
this.$message.error('请至少添加数据'); |
|
|
|
|
return |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
console.log('提交数据:', this.tableData); |
|
|
|
|
addRequests(this.tableData).then(res =>{ |
|
|
|
|
this.submitLoading = true; |
|
|
|
|
addRequests(this.tableData) |
|
|
|
|
.then(res => { |
|
|
|
|
if (res.data.code == 200) { |
|
|
|
|
this.$message.success('新增成功') |
|
|
|
|
this.closeDialog(true) |
|
|
|
|
this.$message.success('新增成功'); |
|
|
|
|
this.closeDialog(true); |
|
|
|
|
this.submitLoading = false; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
this.submitLoading = false; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
<style lang="scss" scoped></style> |