|
@@ -1,25 +1,25 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
- :title="titleStr"
|
|
|
+ title="新增"
|
|
|
:visible.sync="data.bSwitch"
|
|
|
width="30%"
|
|
|
>
|
|
|
<el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
|
|
|
<el-form-item label="数据库表" prop="table">
|
|
|
- <el-select v-model="ruleForm.table" filterable placeholder="请选择" style="width: 100%;" :disabled="data.row.id" @change="handleTableChange">
|
|
|
+ <el-select v-model="ruleForm.table" filterable placeholder="请选择" style="width: 100%;" @change="handleTableChange">
|
|
|
<el-option v-for="item of table" :key="item.id" :label="item.field" :value="item.id" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="ruleForm.table" label="表字段" prop="table_field">
|
|
|
<el-select v-model="ruleForm.table_field" filterable placeholder="请选择" style="width: 100%;">
|
|
|
- <el-option v-for="item of table_field" :key="item.id" :label="item.field_name" :value="item.id" :disabled="data.row.id" />
|
|
|
+ <el-option v-for="item of table_field" :key="item.id" :label="item.field_name" :value="item.id" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="名称" prop="field_name">
|
|
|
<el-input v-model="ruleForm.field_name" placeholder="请输入" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="值" prop="field">
|
|
|
- <el-input v-model="ruleForm.field" :disabled="data.row.id && data.type === 1" placeholder="请输入" />
|
|
|
+ <el-input v-model="ruleForm.field" placeholder="请输入" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
<el-input v-model="ruleForm.remark" placeholder="请输入" />
|
|
@@ -86,39 +86,8 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- titleStr() {
|
|
|
- return this.data.row.id ? '编辑' : '新增'
|
|
|
- }
|
|
|
- },
|
|
|
async created() {
|
|
|
await this.getData(0, null)
|
|
|
- if (this.data.row.id) {
|
|
|
- await this.getData2(this.data.row.field, null)
|
|
|
-
|
|
|
- // 'id': 44,
|
|
|
- // 'parent_field': 'attending_group',
|
|
|
- // 'field': 'id',
|
|
|
- // 'field_name': '',
|
|
|
- // 'status': 1,
|
|
|
- // 'type': 0,
|
|
|
- // 'remark': '',
|
|
|
- // 'parent_fildname': '病案首页主诊组'
|
|
|
- const { status, remark, field, parent_field } = this.data.row
|
|
|
- const tableId = this.table.filter(item => item.field === parent_field)[0].id
|
|
|
- this.ruleForm = {
|
|
|
- table: tableId,
|
|
|
- table_field: field,
|
|
|
- status,
|
|
|
- remark
|
|
|
- }
|
|
|
- // table: '',
|
|
|
- // table_field: '',
|
|
|
- // field: '',
|
|
|
- // field_name: '',
|
|
|
- // remark: '',
|
|
|
- // status: 1
|
|
|
- }
|
|
|
},
|
|
|
methods: {
|
|
|
getData(field, field_name) {
|
|
@@ -131,7 +100,7 @@ export default {
|
|
|
}
|
|
|
get_field_detail(params).then(res => {
|
|
|
const { p } = res
|
|
|
- this.table = p
|
|
|
+ this.table = Array.isArray(p) ? p : []
|
|
|
})
|
|
|
},
|
|
|
getData2(field, field_name) {
|
|
@@ -144,7 +113,7 @@ export default {
|
|
|
}
|
|
|
get_field_detail(params).then(res => {
|
|
|
const { p } = res
|
|
|
- this.table_field = p
|
|
|
+ this.table_field = Array.isArray(p) ? p : []
|
|
|
})
|
|
|
},
|
|
|
handleTableChange(val) {
|
|
@@ -153,19 +122,11 @@ export default {
|
|
|
submitForm(formName) {
|
|
|
this.$refs[formName].validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
- if (this.ruleForm.id) {
|
|
|
- add_dict(this.ruleForm).then(res => {
|
|
|
- this.data.bSwitch = false
|
|
|
- this.$emit('refresh')
|
|
|
- this.$message.success(res.m || '操作成功')
|
|
|
- })
|
|
|
- } else {
|
|
|
- add_dict(this.ruleForm).then(res => {
|
|
|
- this.data.bSwitch = false
|
|
|
- this.$emit('refresh')
|
|
|
- this.$message.success(res.m || '操作成功')
|
|
|
- })
|
|
|
- }
|
|
|
+ add_dict(this.ruleForm).then(res => {
|
|
|
+ this.data.bSwitch = false
|
|
|
+ this.$emit('refresh')
|
|
|
+ this.$message.success(res.m || '操作成功')
|
|
|
+ })
|
|
|
} else {
|
|
|
return false
|
|
|
}
|