<template>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled">
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
<a-row>
|
<a-col :span="24">
|
<a-form-model-item label="所属大纲" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outlineId">
|
<a-input v-model="model.outlineId" placeholder="请输入所属大纲" v-show='false' ></a-input>
|
<a-input :value="model.outlineName" disabled ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="num">
|
<a-input-number v-model="model.num" placeholder="请输入编号" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="code">
|
<a-input v-model="model.code" placeholder="请输入编码" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
|
<a-input v-model="model.name" placeholder="请输入名称" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="测试说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description">
|
<a-textarea
|
v-model="model.description"
|
placeholder="请输入测试说明"
|
:auto-size="{ minRows: 5, maxRows: 20 }"
|
/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="排序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sort">
|
<a-input-number v-model="model.sort" placeholder="请输入排序" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-model-item label="启用状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="enabled">
|
<j-switch v-model='model.enabled'></j-switch>
|
</a-form-model-item>
|
</a-col>
|
<!-- <a-col :span="24">
|
<a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
|
<a-input v-model="model.remark" placeholder="请输入备注" ></a-input>
|
</a-form-model-item>
|
</a-col>-->
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
</template>
|
|
<script>
|
|
import { httpAction, getAction,deleteAction } from '@/api/manage'
|
import { validateDuplicateValue } from '@/utils/util'
|
|
export default {
|
name: 'LimsTestingCategoryForm',
|
components: {
|
},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
},
|
|
/* model: {
|
type: Object,
|
required:true
|
},*/
|
},
|
data () {
|
return {
|
model:{
|
|
},
|
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
validatorRules: {
|
code: [{ required: true, message: '鉴定大纲编号不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '鉴定大纲名称不能为空', trigger: 'blur' }],
|
sort: [{ required: true, message: '鉴定大纲排序不能为空', trigger: 'blur' }],
|
enabled: [{ required: true, message: '鉴定大纲启用状态不能为空', trigger: 'blur' }]
|
},
|
url: {
|
add: "/lims/testing/cat/add",
|
edit: "/lims/testing/cat/edit",
|
del: "/lims/testing/cat/delete",
|
queryById: "/lims/testing/cat/queryById"
|
}
|
}
|
},
|
computed: {
|
formDisabled(){
|
return this.disabled
|
},
|
},
|
created () {
|
//备份model原始值
|
|
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
},
|
methods: {
|
add () {
|
|
this.edit(this.modelDefault);
|
},
|
edit (record) {
|
console.info(record)
|
this.model = Object.assign({}, record);
|
this.visible = true;
|
},
|
setData(parent,model){
|
this.model = model
|
this.model.enabled = 1
|
this.model.outlineId = parent.outlineId
|
this.model.outlineName = parent.outlineName
|
|
//如果存在id 查询数据
|
if(this.model.id){
|
this.queryCatById(this.model.id,parent)
|
}
|
|
},
|
|
del(id){
|
deleteAction(this.url.del,{id:id}).then(res=>{
|
if(res.success){
|
this.$message.success('操作成功!')
|
this.$emit('ok');
|
}else {
|
this.$message.error('操作失败!')
|
}
|
})
|
},
|
//根据id查询
|
queryCatById(id,parent){
|
getAction(this.url.queryById,{id:id}).then(res=>{
|
console.info(res)
|
if(res.success){
|
this.model = Object.assign(res.result, parent);
|
|
console.info(this.model)
|
}
|
|
})
|
|
},
|
submitForm () {
|
const that = this;
|
// 触发表单验证
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
that.confirmLoading = true;
|
let httpurl = '';
|
let method = '';
|
if(!this.model.id){
|
httpurl+=this.url.add;
|
method = 'post';
|
}else{
|
httpurl+=this.url.edit;
|
method = 'put';
|
}
|
httpAction(httpurl,this.model,method).then((res)=>{
|
if(res.success){
|
that.$message.success(res.message);
|
that.$emit('ok');
|
}else{
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.confirmLoading = false;
|
})
|
}
|
|
})
|
},
|
resetForm(){
|
this.model ={outlineId:this.model.outlineId,outlineName:this.model.outlineName}
|
}
|
}
|
}
|
</script>
|