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

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) => { export const saveRules = (data) => {
return request({ return request({
url: '/api/blade-desk/bsAssign/saveBat', url: '/api/blade-desk/bsAssign/saveBat',
@ -65,7 +65,14 @@ export const saveRules = (data) => {
data, data,
}); });
}; };
// 修改分派规则
export const updateRules = (data) => {
return request({
url: '/api/blade-desk/bsAssign/update',
method: 'post',
data,
});
};
// 删除分派规则 // 删除分派规则
export const deleteRules = (params) => { export const deleteRules = (params) => {
return request({ return request({

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