| | |
| | | <template> |
| | | <div> |
| | | <el-dialog :title="operationType === 'add' ? '新增' : '编辑'" :visible.sync="editFormDia" width="500px" @close="closeDia"> |
| | | <el-dialog :title="operationType === 'add' ? '新增' : '编辑'" :visible.sync="editFormDia" width="500px" |
| | | @close="closeDia"> |
| | | <el-form ref="editForm" :model="editForm" :rules="editFormRules" label-width="120px" label-position="right"> |
| | | <el-form-item label="场所:" prop="laboratoryId"> |
| | | <el-select v-model="editForm.laboratoryId" clearable placeholder="请选择" size="small" style="width: 100%"> |
| | | <el-option v-for="item in laboratoryList" :key="item.value" :label="item.label" :value="item.value"></el-option> |
| | | <el-option v-for="item in laboratoryList" :key="item.value" :label="item.label" |
| | | :value="item.value"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="检验对象:" prop="specimenName"> |
| | |
| | | <el-form-item label="检验对象EN:" prop="specimenNameEn"> |
| | | <el-input v-model="editForm.specimenNameEn" clearable size="small"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="对象代号:" prop="code"> |
| | | <!-- <el-form-item label="对象代号:" prop="code"> |
| | | <el-input v-model="editForm.code" clearable size="small"></el-input> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <el-form-item label="对象类型:" prop="objectType"> |
| | | <el-select v-model="editForm.objectType" clearable placeholder="请选择" size="small" style="width: 100%"> |
| | | <el-option v-for="item in dict.type.object_type" :key="item.value" :label="item.label" :value="item.value"></el-option> |
| | | <el-option v-for="item in dict.type.product_classification" :key="item.value" :label="item.label" |
| | | :value="item.value"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="车间:" prop="objectType" v-if="editForm.objectType == '原辅材' || editForm.objectType == '包材'"> |
| | | <el-select v-model="editForm.workShopId" placeholder="请选择" size="small"> |
| | | <el-option v-for="item in workshopList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | |
| | | <script> |
| | | |
| | | import {obtainItemParameterList} from "@/api/structural/laboratoryScope"; |
| | | import {addTestObject, upTestObject} from "@/api/structural/capability"; |
| | | import { obtainItemParameterList } from "@/api/structural/laboratoryScope"; |
| | | import { addTestObject, upTestObject } from "@/api/structural/capability"; |
| | | import { selectWorkShop } from "@/api/structural/workshop.js" |
| | | |
| | | export default { |
| | | name: "EditForm", |
| | | // import 引入的组件需要注入到对象中才能使用 |
| | | dicts: ['object_type'], |
| | | dicts: ['product_classification'], |
| | | components: {}, |
| | | data() { |
| | | // 这里存放数据 |
| | |
| | | laboratoryId: '', // 场所 |
| | | specimenName: '', // 检验对象 |
| | | specimenNameEn: '', // 检验对象EN |
| | | code: '', // 对象代号 |
| | | // code: '', // 对象代号 |
| | | objectType: '', // 对象类型 |
| | | workShopId: '',//车间 |
| | | }, |
| | | laboratoryList: [], |
| | | editFormRules: { |
| | |
| | | specimenName: [ |
| | | { required: true, message: '请输入检验对象', trigger: 'blur' } |
| | | ], |
| | | code: [ |
| | | { required: true, message: '请输入对象代号', trigger: 'blur' } |
| | | objectType: [ |
| | | { required: true, message: '请输入对象类型', trigger: 'change' } |
| | | ], |
| | | workShopId: [ |
| | | { required: true, message: '请选择车间', trigger: 'change' } |
| | | ], |
| | | }, |
| | | operationType: '' |
| | | operationType: '', |
| | | workshopList: [] |
| | | } |
| | | }, |
| | | // 方法集合 |
| | | methods: { |
| | | openDia (type, row) { |
| | | selectWorkShop() { |
| | | selectWorkShop({ size: -1, current: -1 }).then(res => { |
| | | this.workshopList = res.data.records |
| | | }) |
| | | }, |
| | | openDia(type, row) { |
| | | this.operationType = type |
| | | this.obtainItemParameterList() |
| | | this.selectWorkShop() |
| | | this.editFormDia = true |
| | | if (type === 'add') { |
| | | this.resetForm("editForm"); |
| | | this.editForm = {} |
| | | } else { |
| | | this.editForm = {...row} |
| | | this.editForm = { ...row } |
| | | } |
| | | }, |
| | | // 提交编辑 |
| | | handleEdit () { |
| | | handleEdit() { |
| | | this.$refs.editForm.validate(valid => { |
| | | if (valid) { |
| | | this.editLoad = true |
| | | if(this.editForm.id){ |
| | | if (this.editForm.objectType != '原辅材' && this.editForm.objectType != '包材') { |
| | | this.editForm.workShopId = '' |
| | | } |
| | | this.editForm.workShopName = this.editForm.workShopId ? this.workshopList.find(m => m.id == this.editForm.workShopId).name : '' |
| | | if (this.editForm.id) { |
| | | // 修改 |
| | | upTestObject(this.editForm).then(res => { |
| | | this.editLoad = false |
| | |
| | | }).catch(e => { |
| | | this.editLoad = false |
| | | }) |
| | | }else{ |
| | | } else { |
| | | // 新增 |
| | | addTestObject(this.editForm).then(res => { |
| | | this.editLoad = false |
| | |
| | | }) |
| | | }, |
| | | // 关闭弹框 |
| | | closeDia () { |
| | | closeDia() { |
| | | this.editFormDia = false |
| | | this.resetForm("editForm"); |
| | | }, |
| | |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | | <style scoped></style> |