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

325 lines
8.9 KiB
Vue

<!--
* @Author: zhp
* @Date: 2023-02-14 15:02:26
* @LastEditTime: 2023-05-11 09:50:14
* @LastEditors: zhp
* @Description:
-->
<template>
<el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="150px">
<el-form-item prop="client" :label="$t('gage.client')">
<el-input v-model="dataForm.client" :placeholder="$t('gage.client')">
</el-input>
</el-form-item>
</el-form-item>
<el-form-item prop="certificateCode" :label="$t('gage.certificateCode')">
<el-input v-model="dataForm.certificateCode" :placeholder="$t('gage.certificateCode')">
</el-input>
</el-form-item>
<el-form-item prop="verificationFee" :label="$t('gage.verificationFee')">
<el-input v-model="dataForm.verificationFee" :placeholder="$t('gage.verificationFee')">
</el-input>
</el-form-item>
<el-form-item prop="calibrationUnit" :label="$t('gage.calibrationUnit')">
<el-input v-model="dataForm.calibrationUnit" :placeholder="$t('gage.calibrationUnit')">
</el-input>
</el-form-item>
<el-form-item prop="measure" :label="$t('gage.measure')">
<el-select v-model="dataForm.measure" :placeholder="$t('gage.measure')">
<el-option v-for="item in measureList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="gageId" :label="$t('gage.gageName')">
<el-select v-model="dataForm.gageId" :placeholder="$t('gage.gageName')">
<el-option v-for="item in gageList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="inspectionTime" :label="$t('gage.inspectionTime')">
<el-date-picker v-model="dataForm.inspectionTime" type="datetime" :placeholder="$t('gage.inspectionTime')"
format='yyyy-MM-dd HH:mm:ss' valueFormat='yyyy-MM-ddTHH:mm:ss'>
</el-date-picker>
</el-form-item>
<el-form-item prop="calibrationDepartment" :label="$t('gage.calibrationDepartment')">
<el-select v-model="dataForm.calibrationDepartment" :placeholder="$t('gage.calibrationDepartment')">
<el-option v-for="item in departmentList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="parityBit" :label="$t('gage.parityBit')">
<el-radio-group v-model="dataForm.parityBit">
<el-radio :label="0">内部校验</el-radio>
<el-radio :label="1">外部校验</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="checker" :label="$t('gage.checker')">
<el-select v-model="dataForm.checker" :placeholder="$t('gage.checker')">
<el-option v-for="item in userList" :key="item.id" :label="item.realName" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="verificationResult" :label="$t('gage.verificationResult')">
<el-input v-model="dataForm.verificationResult" :placeholder="$t('gage.verificationResult')">
</el-input>
</el-form-item>
<el-form-item prop="remark" :label="$t('gage.remark')">
<el-input v-model="dataForm.remark" :placeholder="$t('gage.remark')">
</el-input>
</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: "/gage/qmsGageVerification",
infoURL: "/gage/qmsGageVerification/{ id }",
dictionaryDetailList: '/mutual/qmsDataDictionaryDetail/page',
getUserList: '/sys/user/page',
getGageList: '/gage/qmsGage/page',
},
gageList: [],
userList: [],
gageTypeList:[],
departmentList: [],
processList: [
{
id: 0,
name: '未审核'
},
{
id: 1,
name: '不同意'
},
{
id: 2,
name: '同意'
}
],
measureList: [
{
id: 0,
name: 'a'
},
{
id: 1,
name: 'b'
},
{
id: 2,
name: 'c'
}
],
listQuery: {
limit: 999,
gape: 1
},
gageStatusList: [
{
id: 0,
name:'在用'
},
{
id: 1,
name: '备用'
},
{
id: 2,
name: '停用'
},
{
id: 3,
name: '封存'
},
{
id: 4,
name: '报废'
},
{
id: 5,
name: '降级使用'
}
],
certificateTypeList: [
{
id: 0,
name: '检定证书'
},
{
id: 1,
name: '校准证书'
},
{
id: 2,
name: '检测报告'
},
{
id: 3,
name: '自校报告'
}
],
gageList: [],
visible: false,
dataForm: {
calibrationDepartment:null,
calibrationUnit: null,
certificateNo: null,
checker: null,
client: null,
createDate: null,
gageCode: null,
gageId: null,
id: null,
inspectionTime: null,
measure: null,
measuringToolAccuracy: null,
parityBit: null,
remark: null,
valid: null,
verificationFee: null,
verificationResult: null
},
};
},
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",
// },
// ],
};
},
},
mounted () {
this.getData();
},
methods: {
init(id, ) {
this.dataForm.id = id || ""
// 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.getUserList, this.listQuery)
.then(({ data: res }) => {
if (res.code === 0) {
console.log(res.data);
this.userList = res.data.list
}
})
.catch(() => {
});
this.$http
.get(this.urlOptions.dictionaryDetailList, this.listQuery)
.then(({ data: res }) => {
if (res.code === 0) {
console.log(res.data);
this.departmentList = res.data.list
}
})
.catch(() => {
})
this.$http
.get(this.urlOptions.getGageList, this.listQuery)
.then(({ data: res }) => {
if (res.code === 0) {
console.log(res.data);
this.gageList = 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(`/gage/qmsGageVerification/${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 }
),
},
};
</script>