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

View File

@ -149,7 +149,7 @@
/>
</a-form-item>
</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">
<template slot="label">
<span
@ -174,12 +174,15 @@
:disabled="isShowComputedArea"
@change="onChange"
name="is_index"
v-decorator="['is_index', { rules: [], valuePropName: 'checked' }]"
v-decorator="['is_index', { rules: [], valuePropName: 'checked', initialValue: true }]"
/>
</a-form-item>
</a-col>
<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">
<span
style="position:relative;white-space:pre;"
@ -208,7 +211,7 @@
</a-col>
<a-col :span="6" v-if="currentValueType !== '6'">
<a-form-item
:label-col="horizontalFormItemLayout.labelCol"
:label-col="currentValueType === '2' ? horizontalFormItemLayout.labelCol : { span: 8 }"
:wrapper-col="horizontalFormItemLayout.wrapperCol"
label="排序"
>
@ -222,7 +225,10 @@
</a-col>
<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">
<span
style="position:relative;white-space:pre;"
@ -420,6 +426,14 @@ export default {
}
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 } })
this.form.resetFields()