<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="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="ver">
|
<a-input v-model="model.ver" placeholder="请输入版本"></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='24'>
|
<a-form-model-item label='产品' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='prodId'>
|
<j-search-select-tag v-model='model.prodId' :dictOptions='proOptions' />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='24'>
|
<a-form-model-item label='大纲' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='outlineId'>
|
<j-search-select-tag v-model='model.outlineId' :dictOptions='outOptions' />
|
</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-textarea>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='24'>
|
<a-form-model-item label='测试方法' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='method'>
|
<a-textarea v-model='model.method' placeholder='请输入测试方法'
|
:auto-size="{ minRows: 5, maxRows: 20 }"></a-textarea>
|
</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='status'>
|
<j-dict-select-tag disabled v-model="model.status" title="状态" dictCode="outline_status"
|
placeholder="请选择鉴定大纲状态" />
|
</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 } from '@/api/manage'
|
import { queryOutlineList, queryProductList } from '@api/lims'
|
|
export default {
|
name: 'LimsTestingStandardForm',
|
components: {},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
mounted() {
|
this.initOptions()
|
},
|
data() {
|
return {
|
model: {},
|
proOptions: [],
|
outOptions: [],
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
confirmLoading: false,
|
validatorRules: {
|
prodId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
|
code: [{ required: true, message: '技术标准编号不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '技术标准名称不能为空', trigger: 'blur' }],
|
ver: [{ required: true, message: '技术标准版本不能为空', trigger: 'blur' }],
|
status: [{ required: true, message: '技术标准状态不能为空', trigger: 'blur' }],
|
enabled: [{ required: true, message: '技术标准使用状态不能为空', trigger: 'blur' }],
|
outlineId: [{ required: true, message: '鉴定大纲不能为空', trigger: 'blur' }],
|
},
|
url: {
|
add: '/lims/testing/stand/add',
|
edit: '/lims/testing/stand/edit',
|
queryById: '/lims/testing/stand/queryById'
|
}
|
}
|
},
|
computed: {
|
formDisabled() {
|
return this.disabled
|
}
|
},
|
created() {
|
//备份model原始值
|
this.modelDefault = JSON.parse(JSON.stringify(this.model))
|
},
|
methods: {
|
add() {
|
//设置状态为新建
|
this.modelDefault.status = 0
|
this.modelDefault.enabled = 1
|
this.edit(this.modelDefault)
|
},
|
edit(record) {
|
this.model = Object.assign({}, record)
|
this.visible = true
|
},
|
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
|
})
|
}
|
|
})
|
},
|
initOptions() {
|
queryProductList({ 'pageNo': 1, 'pageSize': 1000 }).then(res => {
|
if (res.success) {
|
let result = res.result.records
|
if (result) {
|
result.forEach(item => {
|
this.proOptions.push({ 'text': item.name, 'value': item.id })
|
})
|
}
|
}
|
|
})
|
|
queryOutlineList({ 'pageNo': 1, 'pageSize': 1000 }).then(res => {
|
if (res.success) {
|
let result = res.result.records
|
if (result) {
|
//筛选已发布的大纲
|
result.filter(item => item.status != null && item.status == 1).forEach(item => {
|
this.outOptions.push({ 'text': item.name + '(v' + item.ver + ')', 'value': item.id })
|
})
|
|
result.filter(item => item.id == this.model.outlineId).forEach(item => {
|
this.outOptions.push({ 'text': item.name + '(v' + item.ver + ')', 'value': item.id, 'disabled': true })
|
})
|
}
|
}
|
|
})
|
|
|
}
|
}
|
}
|
</script>
|