<template>
|
<div class="add_wordshop">
|
<el-dialog :title="editConfig.dialogTitle + editConfig.dialogTitleType" :visible.sync="editConfig.visible" width="30%"
|
:before-close="handleClose">
|
<el-form :inline="true" label-width="20%" style="width: 100%;" :model="editConfig.infomitton" :rules="rules"
|
ref="ruleForm">
|
<template v-if="editConfig.infomitton.TabsIndex === 0 || editConfig.infomitton.TabsIndex === 1">
|
<el-form-item prop="number" label="编码" style="width: 100%;">
|
<el-input :disabled="editConfig.dialogTitle != '新增'" v-model="editConfig.infomitton.number"
|
placeholder="请输入"></el-input>
|
</el-form-item>
|
<el-form-item prop="name" label="名称" style="width: 100%;">
|
<el-input :disabled="editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.name"
|
placeholder="请输入字母或数字,不允许有空格、中文"></el-input>
|
</el-form-item>
|
</template>
|
|
<template v-if="editConfig.infomitton.TabsIndex === 2">
|
<el-form-item prop="name" label="带号颜色" style="width: 100%;">
|
<el-input :disabled="editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.name"
|
placeholder="请输入字母或数字,不允许有空格、中文"></el-input>
|
</el-form-item>
|
</template>
|
|
<template v-if="editConfig.infomitton.TabsIndex === 3">
|
<el-form-item prop="name" label="规格" style="width: 100%;">
|
<el-input :disabled="editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.name"
|
placeholder="请输入字母或数字,不允许有空格、中文"></el-input>
|
</el-form-item>
|
</template>
|
|
<el-form-item label="描述" style="width: 100%;">
|
<el-input :disabled="editConfig.dialogTitle === '查看'" v-model="editConfig.infomitton.remark" type="textarea"
|
:rows="4" style="resize: none !important;" placeholder="请输入">
|
</el-input>
|
</el-form-item>
|
|
</el-form>
|
<span slot="footer" class="dialog-footer" v-if="editConfig.dialogTitle != '查看'">
|
<el-button @click="editConfig.visible = false">取 消</el-button>
|
<el-button type="primary" @click="commitForm('ruleForm')">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { addDict, editDict } from "@/api/systemSetting/dataDictionary"
|
export default {
|
props: {
|
editDiaConfig: {
|
type: Object,
|
default: () => {
|
return {
|
visible: false,
|
dialogTitle: "添加",
|
infomitton: {
|
}
|
}
|
}
|
}
|
},
|
data() {
|
const checkSpace = (rule, value, callback) => {
|
if (value.includes(' ')) {
|
callback(new Error('名称不能包含空格'));
|
} else {
|
callback();
|
}
|
};
|
return {
|
editConfig: this.editDiaConfig,
|
rules: {
|
number: [
|
{ required: true, message: '请填写编码', trigger: 'change' }
|
],
|
name: [
|
{validator: checkSpace, required: true, message: '请填写名称并且不能有空格', trigger: 'change' }
|
]
|
}
|
};
|
},
|
computed: {
|
|
},
|
created() {
|
|
},
|
mounted() {
|
},
|
watch: {
|
|
},
|
methods: {
|
handleClose(done) {
|
done();
|
},
|
saveParams(type) {
|
let params = {}
|
if (type === 0 || type === 1) {
|
params = {
|
dictType: this.editConfig.infomitton.TabsIndex,
|
name: this.editConfig.infomitton.name,
|
number: this.editConfig.infomitton.number,
|
remark: this.editConfig.infomitton.remark,
|
}
|
} else if (type === 2) {
|
params = {
|
dictType: this.editConfig.infomitton.TabsIndex,
|
name: this.editConfig.infomitton.name,
|
remark: this.editConfig.infomitton.remark,
|
}
|
} else if (type === 3) {
|
params = {
|
dictType: this.editConfig.infomitton.TabsIndex,
|
name: this.editConfig.infomitton.name,
|
remark: this.editConfig.infomitton.remark,
|
}
|
}
|
return params
|
},
|
commitForm(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
let params = this.saveParams(this.editConfig.infomitton.TabsIndex)
|
if (this.editConfig.dialogTitle === "新增") {
|
addDict(params).then((res) => {
|
if (res && res.code === 200) {
|
this.editConfig.visible = false
|
this.$parent.getData()
|
this.$message({
|
message: `新增${this.editConfig.dialogTitleType}成功!`,
|
type: 'success'
|
});
|
}
|
})
|
} else if (this.editConfig.dialogTitle === "修改") {
|
editDict({ ...params, id: this.editConfig.infomitton.ID }).then((res) => {
|
if (res && res.code === 200) {
|
this.editConfig.visible = false
|
this.$parent.getData()
|
this.$message({
|
message: `修改${this.editConfig.dialogTitleType}成功!`,
|
type: 'success'
|
});
|
}
|
})
|
}
|
} else {
|
console.log('error submit!!');
|
return false;
|
}
|
});
|
|
}
|
},
|
components: {
|
|
},
|
};
|
</script>
|
|
<style scoped lang="scss">
|
::v-deep .el-form-item__content {
|
width: 70% !important;
|
}
|
</style>
|