模型属性 is_index

This commit is contained in:
wang-liang0615 2023-07-17 17:19:44 +08:00
parent b0c21fe735
commit e31fee9f6d
2 changed files with 59 additions and 45 deletions

View File

@ -33,24 +33,22 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col :span="12"
:span="12" ><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="别名">
><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="别名"> <a-input name="alias" v-decorator="['alias', { rules: [] }]" /> </a-form-item
<a-input name="alias" v-decorator="['alias', { rules: [] }]" /> </a-form-item
></a-col> ></a-col>
<a-col <a-col :span="12"
:span="12" ><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="数据类型">
><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="数据类型"> <a-select
<a-select :disabled="true"
:disabled="true" name="value_type"
name="value_type" style="width: 100%"
style="width: 100%" v-decorator="['value_type', { rules: [{ required: true }] }]"
v-decorator="['value_type', { rules: [{ required: true }] }]" @change="handleChangeValueType"
@change="handleChangeValueType" >
> <a-select-option :value="key" :key="key" v-for="(value, key) in valueTypeMap">{{ value }}</a-select-option>
<a-select-option :value="key" :key="key" v-for="(value, key) in valueTypeMap">{{ value }}</a-select-option> </a-select>
</a-select> </a-form-item></a-col
</a-form-item></a-col
> >
<a-col :span="currentValueType === '6' ? 24 : 12"> <a-col :span="currentValueType === '6' ? 24 : 12">
<a-form-item <a-form-item
@ -156,12 +154,15 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6'"> <a-col :span="currentValueType === '2' ? 6 : 0" v-if="currentValueType !== '6'">
<a-form-item :label-col="horizontalFormItemLayout.labelCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"> <a-form-item
:hidden="currentValueType === '2' ? false : true"
:label-col="horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol"
>
<template slot="label"> <template slot="label">
<span <span style="position: relative; white-space: pre"
style="position: relative; white-space: pre" >{{ `索引` }}
>{{ `索引` }}
<a-tooltip title="字段可被用于检索,加速查询"> <a-tooltip title="字段可被用于检索,加速查询">
<a-icon <a-icon
style="position: absolute; top: 3px; left: -17px; color: #2f54eb" style="position: absolute; top: 3px; left: -17px; color: #2f54eb"
@ -186,11 +187,13 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol"> <a-form-item
:label-col="currentValueType === '2' ? { span: 8 } : horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol"
>
<template slot="label"> <template slot="label">
<span <span style="position: relative; white-space: pre"
style="position: relative; white-space: pre" >{{ `显示` }}
>{{ `显示` }}
<a-tooltip title="CI实例表格默认展示该字段"> <a-tooltip title="CI实例表格默认展示该字段">
<a-icon <a-icon
style="position: absolute; top: 3px; left: -17px; color: #2f54eb" style="position: absolute; top: 3px; left: -17px; color: #2f54eb"
@ -215,7 +218,7 @@
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6'"> <a-col :span="6" v-if="currentValueType !== '6'">
<a-form-item <a-form-item
:label-col="horizontalFormItemLayout.labelCol" :label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }"
:wrapper-col="horizontalFormItemLayout.wrapperCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"
label="排序" label="排序"
> >
@ -229,11 +232,13 @@
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6'"> <a-col :span="6" v-if="currentValueType !== '6'">
<a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol"> <a-form-item
:label-col="currentValueType === '2' ? { span: 8 } : horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol"
>
<template slot="label"> <template slot="label">
<span <span style="position: relative; white-space: pre"
style="position: relative; white-space: pre" >{{ `多值` }}
>{{ `多值` }}
<a-tooltip title="字段的值是1个或者多个接口返回的值的类型是list"> <a-tooltip title="字段的值是1个或者多个接口返回的值的类型是list">
<a-icon <a-icon
style="position: absolute; top: 3px; left: -17px; color: #2f54eb" style="position: absolute; top: 3px; left: -17px; color: #2f54eb"
@ -297,9 +302,8 @@
<a-col :span="24" v-if="currentValueType !== '6'"> <a-col :span="24" v-if="currentValueType !== '6'">
<a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }"> <a-form-item :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
<template slot="label"> <template slot="label">
<span <span style="position: relative; white-space: pre"
style="position: relative; white-space: pre" >{{ `计算属性` }}
>{{ `计算属性` }}
<a-tooltip <a-tooltip
:title="`该属性的值是通过模型的其它属性构建的表达式或者执行一段代码的方式计算而来,属性的引用方法为: {{ 属性名 }}`" :title="`该属性的值是通过模型的其它属性构建的表达式或者执行一段代码的方式计算而来,属性的引用方法为: {{ 属性名 }}`"
> >
@ -342,11 +346,7 @@
<script> <script>
import moment from 'moment' import moment from 'moment'
import vueJsonEditor from 'vue-json-editor' import vueJsonEditor from 'vue-json-editor'
import { import { updateAttributeById, updateCITypeAttributesById, canDefineComputed } from '@/modules/cmdb/api/CITypeAttr'
updateAttributeById,
updateCITypeAttributesById,
canDefineComputed,
} from '@/modules/cmdb/api/CITypeAttr'
import { valueTypeMap } from '../../utils/const' import { valueTypeMap } from '../../utils/const'
import ComputedArea from './computedArea.vue' import ComputedArea from './computedArea.vue'
import PreValueArea from './preValueArea.vue' import PreValueArea from './preValueArea.vue'
@ -432,13 +432,13 @@ export default {
this.form.setFieldsValue({ this.form.setFieldsValue({
is_list: false, is_list: false,
is_unique: false, is_unique: false,
is_index: false,
is_sortable: false, is_sortable: false,
}) })
if (this.currentValueType === '2') { if (this.currentValueType === '2') {
this.form.setFieldsValue({ this.form.setFieldsValue({
is_password: false, is_password: false,
is_link: false, is_link: false,
is_index: true,
}) })
} }
} }

View File

@ -149,7 +149,7 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6'"> <a-col :span="6" v-if="currentValueType === '2'">
<a-form-item :label-col="horizontalFormItemLayout.labelCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"> <a-form-item :label-col="horizontalFormItemLayout.labelCol" :wrapper-col="horizontalFormItemLayout.wrapperCol">
<template slot="label"> <template slot="label">
<span <span
@ -174,12 +174,15 @@
:disabled="isShowComputedArea" :disabled="isShowComputedArea"
@change="onChange" @change="onChange"
name="is_index" name="is_index"
v-decorator="['is_index', { rules: [], valuePropName: 'checked' }]" v-decorator="['is_index', { rules: [], valuePropName: 'checked', initialValue: true }]"
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol"> <a-form-item
:label-col="currentValueType === '2' ? { span: 8 } : horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol"
>
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
@ -208,7 +211,7 @@
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6'"> <a-col :span="6" v-if="currentValueType !== '6'">
<a-form-item <a-form-item
:label-col="horizontalFormItemLayout.labelCol" :label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }"
:wrapper-col="horizontalFormItemLayout.wrapperCol" :wrapper-col="horizontalFormItemLayout.wrapperCol"
label="排序" label="排序"
> >
@ -222,7 +225,10 @@
</a-col> </a-col>
<a-col :span="6" v-if="currentValueType !== '6'"> <a-col :span="6" v-if="currentValueType !== '6'">
<a-form-item :label-col="{ span: 8 }" :wrapper-col="horizontalFormItemLayout.wrapperCol"> <a-form-item
:label-col="currentValueType === '2' ? { span: 8 } : horizontalFormItemLayout.labelCol"
:wrapper-col="horizontalFormItemLayout.wrapperCol"
>
<template slot="label"> <template slot="label">
<span <span
style="position:relative;white-space:pre;" style="position:relative;white-space:pre;"
@ -420,6 +426,14 @@ export default {
} }
const fontOptions = this.$refs.fontArea.getData() const fontOptions = this.$refs.fontArea.getData()
// is_index true
// 5 is_index=true
// json is_index=false
if (values.value_type === '6') {
values.is_index = false
} else if (values.value_type !== '2') {
values.is_index = true
}
const { attr_id } = await createAttribute({ ...values, option: { fontOptions } }) const { attr_id } = await createAttribute({ ...values, option: { fontOptions } })
this.form.resetFields() this.form.resetFields()