qms/src/views/modules/customerquality/components/qmsKnowledgeBase-add.vue
2023-07-14 15:36:21 +08:00

172 lines
5.2 KiB
Vue

<!--
* @Author: zhp
* @Date: 2023-02-14 15:02:26
* @LastEditTime: 2023-07-14 10:06:39
* @LastEditors: zhp
* @Description:
-->
<template>
<el-form :model="dataForm" ref="dataForm" :rules="dataRule" @keyup.enter.native="dataFormSubmitHandle()"
label-width="120px">
<el-form-item prop="code" :label="$t('customerquality.code')">
<el-input v-model="dataForm.code" :placeholder="$t('customerquality.code')"></el-input>
</el-form-item>
<el-form-item prop="knowledgeBaseName" :label="$t('customerquality.knowledgeBaseName')">
<el-input v-model="dataForm.knowledgeBaseName" :placeholder="$t('customerquality.knowledgeBaseName')"></el-input>
</el-form-item>
<!-- <el-form-item prop="knowledgeBaseName" :label="$t('basic.status')">
<el-select v-model="dataForm.currentStage" :placeholder="$t('basic.status')">
<el-option v-for="item in currentStageList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="serialNumber" :label="$t('customerquality.serialNumber')">
<el-input v-model="dataForm.serialNumber" :placeholder="$t('customerquality.serialNumber')"></el-input>
</el-form-item>
<el-form-item prop="description" :label="$t('customerquality.description')">
<el-input v-model="dataForm.description" :placeholder="$t('customerquality.description')"></el-input>
</el-form-item>
<el-form-item prop="questionType" :label="$t('customerquality.questionType')">
<el-select v-model="dataForm.questionType" :placeholder="$t('customerquality.questionType')">
<el-option v-for="item in questionTypeList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item> -->
<el-form-item prop="category" :label="$t('customerquality.category')">
<el-select v-model="dataForm.category" :placeholder="$t('customerquality.category')">
<el-option v-for="item in categoryList" :key="item.id" :label="item.dataDictionaryDetailName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
</template>
<script>
import debounce from "lodash/debounce";
import basicAdd from "@/mixins/basic-add";
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
submitURL: "/customerquality/qmsKnowledgeBase",
infoURL: "/customerquality/qmsKnowledgeBase//{id}",
getDictDataDetail: '/mutual/qmsDataDictionaryDetail/page'
},
categoryList:[],
typeList:[],
visible: false,
listQuery: {
limit: 999,
page:1
},
dataForm: {
id: "",
code: null,
category: null,
knowledgeBaseName:null
},
};
},
computed: {
dataRule() {
return {
code: [
{
required: true,
message: this.$t("validate.required"),
trigger: "blur",
},
],
knowledgeBaseName: [
{
required: true,
message: this.$t("validate.required"),
trigger: "blur",
},
]
};
},
},
mounted () {
this.getDict()
},
methods: {
init(id) {
this.dataForm.id = id || ""
// this.dataForm.dictTypeId = dictTypeId || "";
this.visible = true;
this.$nextTick(() => {
this.$refs["dataForm"].resetFields()
if (this.dataForm.id) {
this.getInfo();
} else {
// this.getCode()
}
});
},
// 获取信息
getInfo() {
this.$http
.get(`/customerquality/qmsKnowledgeBase/${this.dataForm.id}`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
this.dataForm = {
...this.dataForm,
...res.data,
};
})
.catch(() => {});
},
getDict() {
this.$http
.get(this.urlOptions.getDictDataDetail, {
params: {
limit: 999,
page: 1,
dataDictionaryId:'1679670942635122690',
}
})
.then(({ data: res }) => {
this.dataListLoading = false;
if (res.code === 0) {
this.categoryList = res.data.list
}
})
},
// 表单提交
dataFormSubmitHandle: debounce(
function () {
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
this.$http[!this.dataForm.id ? "post" : "put"](this.urlOptions.submitURL, this.dataForm)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
this.$message({
message: this.$t("prompt.success"),
type: "success",
duration: 500,
onClose: () => {
console.log(1111);
this.visible = false;
this.$emit("successSubmit");
},
});
})
.catch(() => {});
});
},
1000,
{ leading: true, trailing: false }
),
},
};
</script>