qms/src/views/modules/mutual/components/dataDictionary-add.vue
2023-05-11 16:22:07 +08:00

190 lines
5.1 KiB
Vue

<!--
* @Author: zhp
* @Date: 2023-02-14 15:02:26
* @LastEditTime: 2023-05-09 13:56:57
* @LastEditors: zhp
* @Description:
-->
<template>
<div>
<el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="150px">
<el-form-item prop="dataDictionaryName" :label="$t('dictionary.name')">
<el-input v-model="dataForm.dataDictionaryName" :placeholder="$t('dictionary.name')">
</el-input>
</el-form-item>
<el-form-item prop="dataDictionaryCode" :label="$t('dictionary.code')">
<el-input v-model="dataForm.dataDictionaryCode" :placeholder="$t('dictionary.code')">
</el-input>
</el-form-item>
</el-form>
</div>
</template>
<script>
import debounce from "lodash/debounce"
import basicAdd from "@/mixins/basic-add"
// import inputArea from './inputArea'
// import selectArea from './selectArea'
import i18n from "@/i18n"
// import { kStringMaxLength } from "buffer"
export default {
// mixins: [basicAdd],
data() {
return {
urlOptions: {
submitURL: "/mutual/qmsDataDictionary",
infoURL: "/mutual/qmsDataDictionary/{ id }",
},
visible: false,
addButtonShow:'新增',
dataForm: {
id: null,
dataDictionaryCode: null,
dataDictionaryName: null,
moduleDataDictionaryId:null
},
};
},
mixins: [
basicAdd
],
computed: {
dataRule() {
return {
// dictLabel: [
// {
// required: true,
// message: this.$t("validate.required"),
// trigger: "blur",
// },
// ],
// dictValue: [
// {
// required: true,
// message: this.$t("validate.required"),
// trigger: "blur",
// },
// ],
// sort: [
// {
// required: true,
// message: this.$t("validate.required"),
// trigger: "blur",
// },
// ],
};
},
},
methods: {
init(id, moduleDataDictionaryId ) {
this.dataForm.id = id || ""
this.dataForm.moduleDataDictionaryId = moduleDataDictionaryId || ""
// console.log(11111)
// this.dataForm.dictTypeId = dictTypeId || "";
this.visible = true
this.$nextTick(() => {
this.$refs["dataForm"].resetFields();
if (this.dataForm.id) {
this.getInfo()
} else {
// this.getCode()
}
});
},
// getData() {
// // this.$http
// // .get(this.urlOptions.getTypeListURL, this.listQuery)
// // .then(({ data: res }) => {
// // if (res.code === 0) {
// // console.log(res.data);
// // this.typeList = res.data.list
// // }
// // })
// // .catch(() => {
// // });
// this.$http
// .get(this.urlOptions.getSupplierListURL, this.listQuery)
// .then(({ data: res }) => {
// if (res.code === 0) {
// console.log(res.data);
// this.supplierList = res.data.list
// }
// })
// .catch(() => {
// })
// this.$http
// .get(this.urlOptions.getProductURL, {
// params: this.listQuery,
// })
// .then(({ data: res }) => {
// if (res.code === 0) {
// console.log(res.data)
// this.productList = res.data.list
// }
// })
// .catch(() => {
// })
// },
// getCode() {
// this.$http.post(this.urlOptions.getCodeURL)
// .then(({ data: res }) => {
// if (res.code === 0) {
// console.log(res);
// this.dataForm.customSamplingCode = res.data
// }
// })
// .catch(() => {
// });
// },
// 获取信息
getInfo() {
this.$http
.get(`/mutual/qmsDataDictionary/${this.dataForm.id}`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
this.dataForm = {
...this.dataForm,
...res.data,
};
})
.catch(() => { })
},
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 }
),
formClear() {
this.$refs.dataForm.resetFields()
this.tableData = []
}
// 表单提交
},
};
</script>