From e31fee9f6dc1d0e89431e73b2f067da6f364df8c Mon Sep 17 00:00:00 2001 From: wang-liang0615 <dhuwl0615@163.com> Date: Mon, 17 Jul 2023 17:19:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=B1=9E=E6=80=A7=20is=5Find?= =?UTF-8?q?ex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cmdb/views/ci_types/attributeEditForm.vue | 80 +++++++++---------- .../cmdb/views/ci_types/ceateNewAttribute.vue | 24 ++++-- 2 files changed, 59 insertions(+), 45 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue index 8bf4a6e..b6d940c 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue @@ -33,24 +33,22 @@ /> </a-form-item> </a-col> - <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 :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-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="数据类型"> - <a-select - :disabled="true" - name="value_type" - style="width: 100%" - v-decorator="['value_type', { rules: [{ required: true }] }]" - @change="handleChangeValueType" - > - <a-select-option :value="key" :key="key" v-for="(value, key) in valueTypeMap">{{ value }}</a-select-option> - </a-select> - </a-form-item></a-col + <a-col :span="12" + ><a-form-item :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" label="数据类型"> + <a-select + :disabled="true" + name="value_type" + style="width: 100%" + v-decorator="['value_type', { rules: [{ required: true }] }]" + @change="handleChangeValueType" + > + <a-select-option :value="key" :key="key" v-for="(value, key) in valueTypeMap">{{ value }}</a-select-option> + </a-select> + </a-form-item></a-col > <a-col :span="currentValueType === '6' ? 24 : 12"> <a-form-item @@ -156,12 +154,15 @@ /> </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 style="position: absolute; top: 3px; left: -17px; color: #2f54eb" @@ -186,11 +187,13 @@ </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 style="position: absolute; top: 3px; left: -17px; color: #2f54eb" @@ -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,11 +232,13 @@ </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 style="position: absolute; top: 3px; left: -17px; color: #2f54eb" @@ -297,9 +302,8 @@ <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, }) } } diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue index f8dc32d..c2ef359 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue @@ -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()