基础数据-分派规则维护-优化编辑功能

dev-scheduling
ysn 1 day ago
parent 7cbb7f38ef
commit c4624518e6
  1. 11
      src/api/basicData/ruleMaintenance.js
  2. 305
      src/views/basicData/components/addRuleDialog.vue

@ -57,7 +57,7 @@ export const getLimitRule = () => {
});
};
// 保存分派规则
// 新增保存分派规则
export const saveRules = (data) => {
return request({
url: '/api/blade-desk/bsAssign/saveBat',
@ -65,7 +65,14 @@ export const saveRules = (data) => {
data,
});
};
// 修改分派规则
export const updateRules = (data) => {
return request({
url: '/api/blade-desk/bsAssign/update',
method: 'post',
data,
});
};
// 删除分派规则
export const deleteRules = (params) => {
return request({

@ -1,18 +1,19 @@
<template>
<el-dialog title="新增" append-to-body :modelValue="openShow" fullscreen @close="closeDialog">
<el-dialog
:title="row.id ? '编辑' : '新增'"
append-to-body
:modelValue="openShow"
fullscreen
@close="closeDialog"
>
<div style="margin-bottom: 12px" v-if="moldAddMore">
<el-button type="primary" @click="addTable">插入一行</el-button>
<el-button type="danger" @click="delTable">删除选中行</el-button>
</div>
<!-- 单个 Form 包裹整个表格 -->
<el-form
ref="tableForm"
:model="form"
:rules="formRules"
label-width="0px"
>
<el-form ref="tableForm" :model="form" :rules="formRules" label-width="0px">
<!-- 全局错误提示 -->
<div v-if="formError" class="error-message" style="color: #f56c6c; margin-bottom: 10px;">
<div v-if="formError" class="error-message" style="color: #f56c6c; margin-bottom: 10px">
{{ formError }}
</div>
<el-table :data="form.tableData" @select="selectChange" border>
@ -22,13 +23,15 @@
<span><i style="color: red">*</i>工艺能力</span>
</template>
<template #default="scope">
<el-form-item :prop="`tableData[${scope.$index}].craftAbilityId`" :rules="formRules.craftAbilityId">
<el-form-item
:prop="`tableData[${scope.$index}].craftAbilityId`"
:rules="formRules.craftAbilityId"
>
<el-select
v-model="scope.row.craftAbilityId"
placeholder="请选择"
style="width: 100%"
filterable
>
<el-option
v-for="item in capabilityData"
@ -47,12 +50,15 @@
</el-form-item>
</template>
</el-table-column>
<el-table-column align="center" label="生产标识" prop="prodMarkId">
<el-table-column align="center" label="生产标识" prop="prodMarkIds">
<template #default="scope">
<el-form-item :prop="`tableData[${scope.$index}].prodMarkId`" :rules="formRules.prodMarkId">
<el-form-item
:prop="`tableData[${scope.$index}].prodMarkIds`"
:rules="formRules.prodMarkIds"
>
<el-select
multiple
v-model="scope.row.prodMarkId"
v-model="scope.row.prodMarkIds"
placeholder="请选择生产标识"
style="width: 100%"
filterable
@ -83,15 +89,27 @@
</el-table-column>
<el-table-column align="center" label="单批面积下限(dm²)" prop="singleDownArea">
<template #default="scope">
<el-form-item :prop="`tableData[${scope.$index}].singleDownArea`" :rules="formRules.singleDownArea">
<el-input v-model="scope.row.singleDownArea" placeholder="请输入单批面积下限"></el-input>
<el-form-item
:prop="`tableData[${scope.$index}].singleDownArea`"
:rules="formRules.singleDownArea"
>
<el-input
v-model="scope.row.singleDownArea"
placeholder="请输入单批面积下限"
></el-input>
</el-form-item>
</template>
</el-table-column>
<el-table-column align="center" label="单批面积上限(dm²)" prop="singleUpArea">
<template #default="scope">
<el-form-item :prop="`tableData[${scope.$index}].singleUpArea`" :rules="formRules.singleUpArea">
<el-input v-model="scope.row.singleUpArea" placeholder="请输入单批面积上限"></el-input>
<el-form-item
:prop="`tableData[${scope.$index}].singleUpArea`"
:rules="formRules.singleUpArea"
>
<el-input
v-model="scope.row.singleUpArea"
placeholder="请输入单批面积上限"
></el-input>
</el-form-item>
</template>
</el-table-column>
@ -100,13 +118,21 @@
<span><i style="color: red">*</i>限制类型</span>
</template>
<template #default="scope">
<el-form-item :prop="`tableData[${scope.$index}].limitType`" :rules="formRules.limitType">
<el-form-item
:prop="`tableData[${scope.$index}].limitType`"
:rules="formRules.limitType"
>
<el-select
v-model="scope.row.limitType"
placeholder="请选择限制类型"
style="width: 100%"
>
<el-option v-for="item in limitRule" :key="item.id" :value="item.dictKey" :label="item.dictValue"></el-option>
<el-option
v-for="item in limitRule"
:key="item.id"
:value="item.dictKey"
:label="item.dictValue"
></el-option>
<!-- <el-option label="必须" :value="1"></el-option> -->
</el-select>
</el-form-item>
@ -117,13 +143,21 @@
<span><i style="color: red">*</i>指定类型</span>
</template>
<template #default="scope">
<el-form-item :prop="`tableData[${scope.$index}].pointType`" :rules="formRules.pointType">
<el-form-item
:prop="`tableData[${scope.$index}].pointType`"
:rules="formRules.pointType"
>
<el-select
v-model="scope.row.pointType"
placeholder="请选择指定类型"
style="width: 100%"
>
<el-option v-for="item in pointRule" :key="item.id" :value="item.dictKey" :label="item.dictValue"></el-option>
<el-option
v-for="item in pointRule"
:key="item.id"
:value="item.dictKey"
:label="item.dictValue"
></el-option>
<!-- <el-option label="厂内" value="1"></el-option>
<el-option label="外协" value="2"></el-option> -->
</el-select>
@ -143,7 +177,12 @@
filterable
clearable
>
<el-option v-for="item in companyData" :label="item.ocName" :key="item.id" :value="item.id"></el-option>
<el-option
v-for="item in companyData"
:label="item.ocName"
:key="item.id"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</template>
@ -161,7 +200,12 @@
filterable
clearable
>
<el-option v-for="item in workCenterData" :label="item.wcName" :key="item.id" :value="item.id"></el-option>
<el-option
v-for="item in workCenterData"
:label="item.wcName"
:key="item.id"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</template>
@ -185,82 +229,91 @@
</template>
<script>
import {getCapability,getProduction,getOutsourcing,getWorkCenter,getLimitRule,
getPointRule,saveRules} from "@/api/basicData/ruleMaintenance"
import {
getCapability,
getProduction,
getOutsourcing,
getWorkCenter,
getLimitRule,
getPointRule,
saveRules,
updateRules,
} from '@/api/basicData/ruleMaintenance';
export default {
props:{
isOpen:{
type:Boolean,
default:false
props: {
isOpen: {
type: Boolean,
default: false,
},
moldAddMore:{
type:Boolean,
default:false
moldAddMore: {
type: Boolean,
default: false,
},
row:{
type:Object,
default:{}
}
row: {
type: Object,
default: {},
},
data(){
return{
openShow:false,
formError:'',
showOem:false,
showCenter:false,
form:{
tableData:[]
},
craftloading:false,
formRules:{
craftAbilityId:[
{ required: true, message: '请选择工艺能力', trigger: ['change', 'submit'] }
],
limitType:[
{ required: true, message: '请选择限制类型', trigger: ['change', 'submit'] }
],
pointType:[
{ required: true, message: '请选择指定类型', trigger: ['change', 'submit'] }
data() {
return {
openShow: false,
formError: '',
showOem: false,
showCenter: false,
form: {
tableData: [],
},
craftloading: false,
formRules: {
craftAbilityId: [
{ required: true, message: '请选择工艺能力', trigger: ['change', 'submit'] },
],
limitType: [{ required: true, message: '请选择限制类型', trigger: ['change', 'submit'] }],
pointType: [{ required: true, message: '请选择指定类型', trigger: ['change', 'submit'] }],
},
capabilityData:[],
identificationData:[],
companyData:[],
workCenterData:[],
pointRule:[],
limitRule:[]
}
capabilityData: [],
identificationData: [],
companyData: [],
workCenterData: [],
pointRule: [],
limitRule: [],
};
},
async mounted(){
async mounted() {
// this.getCapability();
// this.getProduction();
// this.getOutsourcing();
// this.getWorkCenter();
// this.getPointRule()
// this.getLimitRule()
const pointData = await getPointRule()
this.pointRule = pointData.data.data
const limitData = await getLimitRule()
this.limitRule = limitData.data.data
const capaRes = await getCapability()
this.capabilityData = capaRes.data.data
const companyRes = await getOutsourcing()
this.companyData = companyRes.data.data
const idenRes = await getProduction()
this.identificationData = idenRes.data.data
const worlRes = await getWorkCenter()
this.workCenterData = worlRes.data.data
if(JSON.stringify(this.row) != '{}'){
this.row.craftAbilityId = this.row.craftAbilityId + ''
this.row.centerId = this.row.centerId == -1 ? '' : this.row.centerId + ''
this.row.oemId = this.row.oemId == -1 ? '' : this.row.oemId + ''
this.form.tableData[0] = this.row
const pointData = await getPointRule();
this.pointRule = pointData.data.data;
const limitData = await getLimitRule();
this.limitRule = limitData.data.data;
const capaRes = await getCapability();
this.capabilityData = capaRes.data.data;
const companyRes = await getOutsourcing();
this.companyData = companyRes.data.data;
const idenRes = await getProduction();
this.identificationData = idenRes.data.data;
const worlRes = await getWorkCenter();
this.workCenterData = worlRes.data.data;
if (JSON.stringify(this.row) != '{}') {
this.row.craftAbilityId = this.row.craftAbilityId + '';
this.row.centerId = this.row.centerId == -1 ? '' : this.row.centerId + '';
this.row.oemId = this.row.oemId == -1 ? '' : this.row.oemId + '';
// prodMarkId
if (this.row.prodMarkId && this.row.prodMarkId !== '') {
this.row.prodMarkIds = this.row.prodMarkId.split(',');
} else {
this.row.prodMarkIds = [];
}
this.form.tableData[0] = this.row;
}
console.log('this.row', this.row)
console.log('this.row', this.row);
this.openShow = this.isOpen;
},
methods:{
methods: {
// remoteMethodCraft(query){
// console.log('query', query)
// if(query){
@ -271,35 +324,35 @@ export default {
// })
// }
// },
getPointRule(){
getPointRule().then(res =>{
this.pointRule = res.data.data
})
getPointRule() {
getPointRule().then(res => {
this.pointRule = res.data.data;
});
},
getLimitRule(){
getLimitRule().then(res =>{
this.limitRule = res.data.data
})
getLimitRule() {
getLimitRule().then(res => {
this.limitRule = res.data.data;
});
},
getCapability(){
getCapability().then(res =>{
getCapability() {
getCapability().then(res => {
this.capabilityData = res.data.data;
})
});
},
getProduction(){
getProduction().then(res =>{
getProduction() {
getProduction().then(res => {
this.identificationData = res.data.data;
})
});
},
getOutsourcing(){
getOutsourcing().then(res =>{
getOutsourcing() {
getOutsourcing().then(res => {
this.companyData = res.data.data;
})
});
},
getWorkCenter(){
getWorkCenter().then(res =>{
getWorkCenter() {
getWorkCenter().then(res => {
this.workCenterData = res.data.data;
})
});
},
selectChange(list, row) {
row._select = !row._select;
@ -308,12 +361,12 @@ export default {
delTable() {
this.form.tableData = this.form.tableData.filter(row => !row._select);
},
addTable(){
addTable() {
this.form.tableData.push({
_select:false
})
_select: false,
});
},
submit(){
submit() {
this.formError = '';
// Form
this.$refs.tableForm.validate((isValid, invalidFields) => {
@ -339,32 +392,46 @@ export default {
// return
// }
// })
console.log('form----------',this.form.tableData)
//
const submitData = this.form.tableData.map(row => {
row.prodMarkId = row.prodMarkId && row.prodMarkId.length != 0 && row.prodMarkId.join(',')
if (Array.isArray(row.prodMarkIds) && row.prodMarkIds.length > 0) {
row.prodMarkId = row.prodMarkIds.join(',');
} else {
row.prodMarkId = '';
}
const { _select, ...validData } = row; //
return validData;
});
saveRules(submitData).then(res =>{
if(res.data.code == 200){
console.log('submitData', submitData, this.row);
if (this.row.id) {
//
updateRules(submitData[0]).then(res => {
if (res.data.code == 200) {
this.$message.success('修改成功');
this.closeDialog(true);
}
});
} else {
//
saveRules(submitData).then(res => {
if (res.data.code == 200) {
this.$message.success('保存成功');
this.closeDialog(true);
}
})
})
});
}
});
},
closeDialog(val){
closeDialog(val) {
this.openShow = false;
this.$emit('closeDialog',val);
}
}
}
this.$emit('closeDialog', val);
},
},
};
</script>
<style lang="scss" scoped>
::v-deep .el-form-item{
::v-deep .el-form-item {
margin-top: 15px !important;
}
</style>
Loading…
Cancel
Save