<template>
|
<el-container>
|
<el-main>
|
<basic-container>
|
<avue-crud
|
ref="userCrud"
|
:data="tableData"
|
:option="option"
|
:page.sync="page"
|
:table-loading="tableLoading"
|
@on-load="getTableList"
|
@refresh-change="handleRefresh"
|
@search-change="handleSearch"
|
@search-reset="handleReset"
|
@selection-change="selectChange"
|
@row-click="rowClickHandler"
|
@size-change="sizeChange"
|
@current-change="currentChange"
|
>
|
<template slot="menuLeft" slot-scope="scope">
|
<el-button icon="el-icon-plus" size="small" type="primary" @click="rowSaveHandlerClick">创建</el-button>
|
<el-button icon="el-icon-delete" plain size="small" type="danger" @click="allDelHandler">删除</el-button>
|
<el-button icon="el-icon-view" plain size="small" type="primary" @click="chekView">查看使用范围</el-button>
|
<el-button icon="el-icon-download" plain size="small" type="primary" @click="downloadTemplateHandler">下载导入模板
|
</el-button>
|
<el-button icon="el-icon-upload2" plain size="small" type="primary" @click="upLoadHandler">导入</el-button>
|
<el-button icon="el-icon-download" plain size="small" type="primary" @click="downLoadHandler">导出</el-button>
|
</template>
|
|
<template slot="menu" slot-scope="scope">
|
<el-button icon="el-icon-edit" size="small" type="text" @click="editBtnClick(scope.row)">编辑
|
</el-button>
|
<el-button icon="el-icon-delete" size="small" type="text" @click="rowDeleteHandler(scope.row)">删除
|
</el-button>
|
</template>
|
</avue-crud>
|
</basic-container>
|
</el-main>
|
<!-- 右侧信息 -->
|
<el-aside width="30%">
|
<basic-container>
|
<div style="height: 85vh; overflow-y: auto">
|
<el-descriptions :column="1" border size="medium" title="属性项">
|
<el-descriptions-item>
|
<template slot="label">
|
名称
|
</template>
|
{{ lastItem.id }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
标签
|
</template>
|
{{ lastItem.name }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
描述
|
</template>
|
{{ lastItem.description }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
操作类型
|
</template>
|
{{ lastItem.attributeDataType }}
|
</el-descriptions-item>
|
</el-descriptions>
|
|
<!-- 值域 -->
|
<el-descriptions v-if="!isSpecialDataType" :column="1" :title="lastItem.attributeDataType" border
|
class="margin-top"
|
size="medium">
|
<el-descriptions-item>
|
<template slot="label">
|
允许为空
|
</template>
|
<el-tag :type="lastItem.nullableFlag ? 'success' : 'danger'">
|
{{ lastItem.nullableFlag ? '是' : '否' }}
|
</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item v-if="accuracy">
|
<template slot="label">
|
精度
|
</template>
|
精度
|
</el-descriptions-item>
|
<el-descriptions-item v-if="length">
|
<template slot="label">
|
长度
|
</template>
|
{{ lastItem.attrLength }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
默认值
|
</template>
|
{{ lastItem.defaultValue }}
|
</el-descriptions-item>
|
</el-descriptions>
|
|
<!-- VTString -->
|
<el-descriptions v-if="lastItem.attributeDataType === 'VTString' || !lastItem.attributeDataType"
|
:column="1" border class="margin-top" size="medium" title="值域">
|
<el-descriptions-item>
|
<template slot="label">
|
当前类型
|
</template>
|
{{ lastItem.version ? '链接类型' : '业务类型' }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
当前类型值
|
</template>
|
{{ lastItem.version ? lastItem.linkTypeName : lastItem.btmTypeId }}
|
</el-descriptions-item>
|
<el-descriptions-item v-if="lastItem.version">
|
<template slot="label">
|
当前版本次
|
</template>
|
{{ lastItem.version }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
使用枚举
|
</template>
|
<el-tag :type="lastItem.enumId ? 'success' : 'danger'">
|
{{ lastItem.enumId ? '是' : '否' }}
|
</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
当前枚举类型
|
</template>
|
{{ lastItem.enumId }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
取值范围
|
</template>
|
<div style="width: 330px; height: 80px;overflow: auto">
|
<el-tag v-for="item in rangeList" plain style="margin: 5px">{{ item }}</el-tag>
|
</div>
|
</el-descriptions-item>
|
|
</el-descriptions>
|
<!-- VTInteger && VTInteger -->
|
<el-descriptions
|
v-if="lastItem.attributeDataType === 'VTInteger' || lastItem.attributeDataType === 'VTInteger'"
|
:column="1" border class="margin-top" size="medium" title="值域">
|
|
<el-descriptions-item>
|
<template slot="label">
|
使用枚举
|
</template>
|
<el-tag :type="lastItem.enumFlag ? 'success' : 'danger'">
|
{{ lastItem.enumFlag ? '是' : '否' }}
|
</el-tag>
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
枚举类型
|
</template>
|
{{ lastItem.enumFlag }}
|
</el-descriptions-item>
|
<el-descriptions-item>
|
<template slot="label">
|
取值范围
|
</template>
|
<div style="width: 330px; height: 80px;overflow: auto">
|
<el-tag v-for="item in rangeList" plain style="margin: 5px">{{ item }}</el-tag>
|
</div>
|
</el-descriptions-item>
|
|
</el-descriptions>
|
<!-- VTDouble -->
|
<el-descriptions v-if="lastItem.attributeDataType === 'VTDouble'"
|
:column="1" border class="margin-top" size="medium" title="值域">
|
|
<el-descriptions-item>
|
<template slot="label">
|
取值范围
|
</template>
|
<div style="width: 330px; height: 80px;overflow: auto">
|
<el-tag v-for="item in rangeList" plain style="margin: 5px">{{ item }}</el-tag>
|
</div>
|
</el-descriptions-item>
|
|
</el-descriptions>
|
<!-- VTDate VTTime VTDateTime VTNote VTFilePath VTClob均不显示 VTBoolean不显示值域 只显示类型 -->
|
</div>
|
</basic-container>
|
</el-aside>
|
<!-- 新增对话框 -->
|
<el-dialog
|
v-dialogDrag
|
v-loading="addLoading"
|
:title="dialogTitle === 'add' ? '创建' : '编辑'"
|
:visible.sync="addVisible"
|
append-to-body="true"
|
class="avue-dialog"
|
width="65%"
|
@close="addEscHandler"
|
>
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-row>
|
<div class="addDialog">
|
<div>
|
|
<h3>属性项</h3>
|
|
<el-col :span="12">
|
<el-form-item label="名称:" prop="id">
|
<el-input v-model="form.id"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="标签:" prop="name">
|
<el-input v-model="form.name"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="属性类型:" prop="attributeDataType">
|
<el-select v-model="form.attributeDataType" placeholder="请选择属性类型" @change="attributeDataTypeChange">
|
<el-option v-for="item in typeSelectList" :label="item" :value="item"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="描述:" prop="description">
|
<el-input v-model="form.description" :rows="2" type="textarea"></el-input>
|
</el-form-item>
|
</el-col>
|
|
</div>
|
<div v-if="!hideType" class="addDialogBottom">
|
<div class="left">
|
<h3>{{ form.attributeDataType }}</h3>
|
|
<el-form-item
|
v-if="form.attributeDataType !== 'VTInteger' && form.attributeDataType !== 'VTLong'
|
&& form.attributeDataType !== 'VTDouble' && form.attributeDataType !== 'VTBoolean'"
|
label="长度:" prop="attrLength">
|
<el-input v-model="form.attrLength"></el-input>
|
</el-form-item>
|
|
<el-form-item v-if="form.attributeDataType === 'VTDouble'" label="精度:" prop="precisionLength">
|
<el-input v-model="form.precisionLength"></el-input>
|
</el-form-item>
|
|
<el-form-item v-if="form.attributeDataType === 'VTDouble'" label="长度:" prop="scaleLength">
|
<el-input v-model="form.scaleLength"></el-input>
|
</el-form-item>
|
|
|
<el-form-item v-if="form.attributeDataType !== 'VTBoolean' && !form.enumSwitch" label="默认值:"
|
prop="defaultValue">
|
<el-input v-model="form.defaultValue"></el-input>
|
</el-form-item>
|
|
<el-form-item v-if="form.attributeDataType === 'VTBoolean'" label="默认值:" prop="defaultValue">
|
<el-select v-model="form.defaultValue">
|
<el-option label="false" value="false"></el-option>
|
<el-option label="true" value="true"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item v-if="form.attributeDataType !== 'VTBoolean' && form.enumSwitch" label="默认值:"
|
prop="defaultValue">
|
<el-select v-model="form.defaultValue">
|
<el-option v-for="(item,index) in rangeOptionValue" :key="index" :label="item"
|
:value="item"></el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="允许为空:" prop="nullableFlag">
|
<el-switch v-model="form.nullableFlag"></el-switch>
|
</el-form-item>
|
|
</div>
|
<el-divider direction="vertical"></el-divider>
|
<!-- VTString -->
|
<div v-if="form.attributeDataType === 'VTString'" class="right">
|
<h3>值域</h3>
|
<el-form-item label="当前值域类型:" prop="attributeSelectType">
|
<el-select v-model="form.attributeSelectType" placeholder="请选择属性类型"
|
@change="attributeSelectTypeChange">
|
<el-option label="业务类型" value="business"></el-option>
|
<el-option label="链接类型" value="link"></el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item v-if="form.attributeSelectType === 'link'" label="版本次:" prop="version">
|
<el-select v-model="form.version" placeholder="请选择版本次">
|
<el-option :value="1" label="当前版本次"></el-option>
|
<el-option :value="3" label="最新版本次"></el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="选择参照类型:" prop="referValue">
|
<el-input v-model="form.referValue" @focus="referFormFocusHandler"></el-input>
|
</el-form-item>
|
|
<span v-if="!form.referValue">
|
<el-form-item label="使用枚举:" prop="enumSwitch">
|
<el-switch v-model="form.enumSwitch" @change="switchEnumChange"></el-switch>
|
</el-form-item>
|
|
|
<el-form-item :label="form.enumSwitch ? '枚举选择:' : '添加值域:'" prop="enumSwitch">
|
<el-select v-if="form.enumSwitch" v-model="form.enumId" placeholder="请选择枚举类型"
|
@change="enumSelectChange">
|
<el-option v-for="(item,index) in attributeDataTypePickList" :key="index" :label="item.key"
|
:value="item.key"></el-option>
|
</el-select>
|
<el-input v-if="!form.enumSwitch" v-model="form.enumAddValue">
|
</el-input>
|
</el-form-item>
|
<el-form-item v-if="!form.enumSwitch" label="运算符:">
|
<div>
|
<el-button size="mini" @click="enumAddHandler"> = </el-button>
|
</div>
|
</el-form-item>
|
<el-form-item :label="form.enumSwitch ? '当前枚举值:' : '当前值域:'" prop="rangeValue">
|
<textarea v-model="form.rangeValue" :readonly="form.enumSwitch"
|
style="width: 330px; height: 80px; border: 1px solid #DCDFE6; overflow: auto; text-align: left;resize: none;">
|
</textarea>
|
</el-form-item>
|
</span>
|
</div>
|
<!-- VTInteger VTLong -->
|
<div v-if="form.attributeDataType === 'VTInteger' || form.attributeDataType === 'VTLong' " class="right">
|
<h3>值域</h3>
|
|
<el-form-item label="使用枚举:" prop="enumSwitch">
|
<el-switch v-model="form.enumSwitch" @change="switchEnumChange"></el-switch>
|
</el-form-item>
|
|
|
<el-form-item :label="form.enumSwitch ? '枚举选择:' : '添加值域:'" prop="enumSwitch">
|
<el-select v-if="form.enumSwitch" v-model="form.enumId" placeholder="请选择枚举类型"
|
@change="enumSelectChange">
|
<el-option v-for="(item,index) in attributeDataTypePickList" :key="index" :label="item.key"
|
:value="item.key"></el-option>
|
</el-select>
|
<el-input v-if="!form.enumSwitch" v-model="form.enumAddValue">
|
</el-input>
|
</el-form-item>
|
<el-form-item v-if="!form.enumSwitch" label="运算符:">
|
<div>
|
<el-button size="mini" @click="operationHandler('>')"> > </el-button>
|
<el-button size="mini" @click="operationHandler('<')"> < </el-button>
|
<el-button size="mini" @click="operationHandler('>=')"> >= </el-button>
|
<el-button size="mini" @click="operationHandler('<=')"> <= </el-button>
|
<el-button size="mini" @click="operationHandler('=')"> = </el-button>
|
<el-button size="mini" @click="operationHandler('!=')"> != </el-button>
|
<el-button size="mini" @click="operationHandler('()')"> () </el-button>
|
</div>
|
</el-form-item>
|
<el-form-item :label="form.enumSwitch ? '当前枚举值:' : '当前值域:'" prop="rangeValue">
|
<textarea v-model="form.rangeValue" :readonly="form.enumSwitch"
|
style="width: 330px; height: 80px; border: 1px solid #DCDFE6; overflow: auto; text-align: left;resize: none;">
|
</textarea>
|
</el-form-item>
|
</div>
|
<!-- VTDouble -->
|
<div v-if="form.attributeDataType === 'VTDouble'" class="right">
|
<h3>值域</h3>
|
<el-form-item :label="form.enumSwitch ? '枚举选择:' : '添加值域:'" prop="enumAddValue">
|
<el-input v-model="form.enumAddValue">
|
</el-input>
|
</el-form-item>
|
<el-form-item label="运算符:">
|
<div>
|
<el-button size="mini" @click="operationHandler('>')"> > </el-button>
|
<el-button size="mini" @click="operationHandler('<')"> < </el-button>
|
<el-button size="mini" @click="operationHandler('>=')"> >= </el-button>
|
<el-button size="mini" @click="operationHandler('<=')"> <= </el-button>
|
<el-button size="mini" @click="operationHandler('=')"> = </el-button>
|
<el-button size="mini" @click="operationHandler('!=')"> != </el-button>
|
<el-button size="mini" @click="operationHandler('()')"> () </el-button>
|
</div>
|
</el-form-item>
|
<el-form-item :label="form.enumSwitch ? '当前枚举值:' : '当前值域:'" prop="rangeValue">
|
<textarea v-model="form.rangeValue"
|
style="width: 330px; height: 80px; border: 1px solid #DCDFE6; overflow: auto; text-align: left;resize: none;">
|
</textarea>
|
</el-form-item>
|
</div>
|
</div>
|
</div>
|
</el-row>
|
</el-form>
|
|
<!-- 业务类型对话框 -->
|
<el-dialog
|
v-dialogDrag
|
:visible.sync="businessVisible"
|
append-to-body="true"
|
class="avue-dialog"
|
title="业务类型选择"
|
width="70%"
|
>
|
<avue-crud
|
ref="businessCrud"
|
:data="businessData"
|
:option="businessOption"
|
:table-loading="businessLoading"
|
@search-change="businessHandleSearch"
|
@search-reset="businessHandleReset"
|
@row-click="businessRowClick"
|
>
|
</avue-crud>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="businessEmpty">清 空</el-button>
|
<el-button @click="businessVisible = false">取 消</el-button>
|
<el-button type="primary" @click="businessSaveHandler">确 定</el-button>
|
</span>
|
</el-dialog>
|
|
<!-- 链接类型对话框 -->
|
<el-dialog
|
v-dialogDrag
|
:visible.sync="linkTypeVisible"
|
append-to-body="true"
|
class="avue-dialog"
|
title="链接类型选择"
|
width="70%"
|
>
|
<avue-crud
|
ref="linkTypeCrud"
|
:data="linkTypeData"
|
:option="linkTypeOption"
|
:table-loading="linkTypeLoading"
|
@search-change="linkHandleSearch"
|
@search-reset="linkHandleReset"
|
@row-click="linkRowClick"
|
>
|
</avue-crud>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="linkEmpty">清 空</el-button>
|
<el-button @click="linkTypeVisible = false">取 消</el-button>
|
<el-button type="primary" @click="linkSaveHandler">确 定</el-button>
|
</span>
|
</el-dialog>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="addEscHandler">取 消</el-button>
|
<el-button type="primary" @click="addSaveHandler">确 定</el-button>
|
</span>
|
</el-dialog>
|
<!--导入 -->
|
<upload-file ref="upload" :fileType="upFileType" :fileUrl="fileUrl" :tipList="tipList" title="导入"
|
@updata="getTableList"></upload-file>
|
<!-- 查看使用范围 -->
|
<el-dialog
|
v-dialogDrag
|
v-loading="checkViewLoading"
|
:visible.sync="checkViewVisible"
|
append-to-body="true"
|
class="avue-dialog"
|
title="查看使用范围"
|
width="60%"
|
>
|
<avue-crud
|
ref="checkViewCrud"
|
:data="checkViewData"
|
:option="checkViewOption"
|
@search-change="checkHandleSearch"
|
@search-reset="checkHandleReset"
|
>
|
|
</avue-crud>
|
</el-dialog>
|
</el-container>
|
</template>
|
|
<script>
|
import {
|
gridAttribute,
|
getUsedAttributeList,
|
getEnumMapByType,
|
deleteAttributes,
|
exportAttributes,
|
downloadAttributeTemplate,
|
getBizTypes,
|
getAllLtName,
|
addAttribute,
|
updateAttribute
|
} from "@/api/modeling/attributePool/api";
|
import basicOption from '@/util/basic-option';
|
import {column} from "./option"
|
import func from "@/util/func";
|
|
export default {
|
name: "index",
|
data() {
|
return {
|
rules: {
|
id: [
|
{required: true, message: '请输入名称', trigger: 'blur'},
|
{pattern: /^[a-zA-Z]+$/, message: '只能输入英文字符', trigger: 'blur'}
|
]
|
},
|
dialogTitle: "",
|
businessRow: {},
|
linkRow: {},
|
linkDataSearch: [],
|
businessSearchParams: {},
|
linkTypeSearchParams: {},
|
businessLoading: false,
|
linkTypeLoading: false,
|
businessVisible: false,
|
linkTypeVisible: false,
|
businessData: [],
|
linkTypeData: [],
|
businessOption: {
|
...basicOption,
|
addBtn: false,
|
menu: false,
|
searchMenuSpan: 8,
|
selection: false,
|
refreshBtn: false,
|
searchLabelWidth: 100,
|
highlightCurrentRow: true,
|
column: [
|
{
|
label: '业务类型名',
|
prop: 'name',
|
sortable: true,
|
search: true
|
},
|
{
|
label: '标签',
|
prop: 'label',
|
sortable: true,
|
},
|
{
|
label: '父类',
|
prop: 'fName',
|
sortable: true,
|
},
|
{
|
label: '版本规则',
|
prop: 'revRuleName',
|
sortable: true,
|
},
|
{
|
label: '生命周期',
|
prop: 'lifeCycle',
|
sortable: true,
|
},
|
]
|
},
|
linkTypeOption: {
|
...basicOption,
|
addBtn: false,
|
menu: false,
|
searchMenuSpan: 8,
|
selection: false,
|
refreshBtn: false,
|
searchLabelWidth: 100,
|
highlightCurrentRow: true,
|
column: [
|
{
|
label: '链接类型名',
|
prop: 'name',
|
sortable: true,
|
search: true
|
},
|
]
|
},
|
tableData: [],
|
option: {
|
...basicOption,
|
searchMenuSpan: 8,
|
calcHeight: -60,
|
addBtn: false,
|
editBtn: false,
|
delBtn: false,
|
column
|
},
|
tableLoading: false,
|
page: {
|
currentPage: 1,
|
pageSize: 10,
|
total: 0,
|
pageSizes: [10, 30, 50, 100],
|
},
|
searchParams: {},
|
selectList: [],
|
checkViewData: [],
|
checkViewDataSearch: [],
|
checkViewVisible: false,
|
checkViewLoading: false,
|
checkViewOption: {
|
...basicOption,
|
addBtn: false,
|
menu: false,
|
searchMenuSpan: 8,
|
refreshBtn: false,
|
selection: false,
|
column: [
|
{
|
label: '名称',
|
prop: 'attributeName',
|
sortable: true,
|
},
|
{
|
label: '来源',
|
prop: 'source',
|
sortable: true,
|
search: true
|
},
|
{
|
label: '说明',
|
prop: 'desc',
|
}
|
]
|
},
|
addVisible: false,
|
addLoading: false,
|
form: {
|
id: "",
|
name: "",
|
attributeDataType: "VTString",
|
description: "",
|
nullableFlag: true,
|
attrLength: 50,
|
enumFlag: false,
|
enumId: "",
|
enumSwitch: false,
|
enumAddValue: "",
|
range: "",
|
attributeSelectType: "business",
|
version: 1,
|
defaultValue: "",
|
referValue: "",
|
btmTypeId: "",
|
linkTypeName: "",
|
rangeValue: ""
|
|
},
|
typeSelectList: ['VTString', 'VTInteger', 'VTLong', 'VTDouble', 'VTBoolean', 'VTDate', 'VTTime', 'VTDateTime', 'VTNote', 'VTFilePath', 'VTClob'],
|
attributeDataTypePickList: [],
|
enumAddListChange: [],
|
tipList: [
|
"属性名和属性类型为必填字段,并且属性名不可和系统中已有属性名重复",
|
"当属性类型为VTString时属性长度列必填,为其他类型时不必填写",
|
"取值范围列填写时请用英文 ; 分隔,不填写时默认使用当前选中的枚举的所有枚举项的值作为取值范围"
|
],
|
upFileType: ['xls', 'xlsx'],
|
fileUrl: 'api/attributeController/importAttributes',
|
}
|
},
|
computed: {
|
lastItem() {
|
return this.selectList.length > 0 ? this.selectList[this.selectList.length - 1] : {};
|
},
|
isSpecialDataType() {
|
// 定义一个包含所有需要比较的类型的数组
|
const specialTypes = ['VTDate', 'VTTime', 'VTDateTime', 'VTNote', 'VTFilePath', 'VTClob'];
|
// 判断 lastItem.attributeDataType 是否在这个数组中
|
return specialTypes.includes(this.lastItem.attributeDataType);
|
},
|
rangeList() {
|
if (this.lastItem.range) {
|
return this.lastItem.range.split(';');
|
}
|
},
|
accuracy() {
|
return this.lastItem.attributeDataType === 'VTDouble';
|
},
|
length() {
|
return this.lastItem.attributeDataType === 'VTString' || this.lastItem.attributeDataType === 'VTDoubule';
|
},
|
// 等于其中以下值 不展示枚举
|
hideType() {
|
return this.form.attributeDataType === 'VTNote' ||
|
this.form.attributeDataType === 'VTDate' ||
|
this.form.attributeDataType === 'VTTime' ||
|
this.form.attributeDataType === 'VTClob' ||
|
this.form.attributeDataType === 'VTDateTime' ||
|
this.form.attributeDataType === 'VTFilePath';
|
},
|
rangeOptionValue() {
|
let values = this.form.rangeValue.split('\n');
|
|
// 处理每个值,去除等号前的部分,只保留等号后的部分
|
return values.map(value => {
|
let parts = value.split('=');
|
return parts.length > 1 ? parts[1].trim() : value.trim();
|
});
|
}
|
},
|
methods: {
|
//表格查询请求
|
getTableList() {
|
this.tableLoading = true;
|
gridAttribute(this.page.currentPage, this.page.pageSize, this.searchParams).then(res => {
|
const data = res.data.data;
|
this.tableData = data;
|
this.page.total = res.data.total;
|
this.tableLoading = false;
|
}).catch(err => {
|
this.$message.error(err)
|
});
|
},
|
|
// 表格头部刷新
|
handleRefresh() {
|
this.getTableList();
|
},
|
|
// 搜索
|
handleSearch(params, done) {
|
this.searchParams = {
|
"conditionMap[id]": "*" + params.id + "*"
|
};
|
this.getTableList()
|
done();
|
},
|
|
// 重置搜索条件
|
handleReset() {
|
this.searchParams = {};
|
this.getTableList();
|
},
|
|
// 选择框
|
selectChange(row) {
|
this.selectList = row;
|
},
|
|
// 点击行
|
rowClickHandler(row) {
|
this.$refs.userCrud.toggleRowSelection(row);
|
},
|
|
// 条数
|
sizeChange(val) {
|
this.page.pageSize = val;
|
},
|
|
// 页码
|
currentChange(val) {
|
this.page.currentPage = val;
|
},
|
|
// 创建打开对话框
|
rowSaveHandlerClick() {
|
this.addVisible = true;
|
this.dialogTitle = "add";
|
this.getEnumMapByTypeHandler('VTString');
|
},
|
|
// 行删除
|
rowDeleteHandler(row) {
|
let params = {
|
oid: row.oid,
|
name: row.id,
|
ts: row.ts
|
};
|
let data = [params];
|
this.$confirm('您确定要删除当前的数据吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
deleteAttributes(data).then(res => {
|
if (res.data.code === 200) {
|
this.$message.success(res.data.obj);
|
this.getTableList();
|
}
|
})
|
}).catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
// 多选删除
|
allDelHandler() {
|
if (this.selectList.length <= 0) {
|
this.$message.error('请至少选择一条数据进行删除!')
|
return;
|
}
|
let data = this.selectList.map(item => {
|
return {
|
oid: item.oid,
|
name: item.id,
|
ts: item.ts
|
}
|
})
|
this.$confirm('您确定要删除所选择的数据吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
deleteAttributes(data).then(res => {
|
if (res.data.code === 200) {
|
this.$message.success(res.data.obj);
|
this.getTableList();
|
}
|
})
|
}).catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
// 查看使用范围
|
chekView() {
|
if (this.selectList.length <= 0) {
|
this.$message.warning('请至少选择一条数据');
|
return;
|
}
|
if (this.selectList.length > 1) {
|
this.$message.warning('只能选择一条数据进行查看');
|
return;
|
}
|
|
getUsedAttributeList({attributeName: this.selectList[0].id}).then(res => {
|
if (res.data.code === 200) {
|
this.checkViewVisible = true;
|
this.checkViewData = res.data.data;
|
this.checkViewDataSearch = res.data.data;
|
}
|
})
|
},
|
|
// 查看使用范围查询
|
checkHandleSearch(params, done) {
|
const {source} = params;
|
|
if (!params.source) {
|
this.checkViewData = this.checkViewDataSearch;
|
return done();
|
}
|
;
|
|
this.checkViewData = this.checkViewData.filter(item => {
|
return item.source && item.source.includes(source);
|
});
|
|
done();
|
|
},
|
|
// 查看使用范围重置
|
checkHandleReset() {
|
this.checkViewData = this.checkViewDataSearch;
|
},
|
|
// 行编辑按钮
|
editBtnClick(row) {
|
this.dialogTitle = "edit";
|
this.form = {...row};
|
|
if (row.enumId) this.form.enumSwitch = true;
|
this.form.rangeValue = row.range.replace(/;/g, '\n');
|
|
if (row.btmTypeId) {
|
this.form.attributeSelectType = 'business'
|
this.form.referValue = row.btmTypeId;
|
}
|
if (row.linkTypeName) {
|
this.form.attributeSelectType = 'link'
|
this.form.referValue = row.linkTypeName;
|
}
|
|
this.getEnumMapByTypeHandler(this.form.attributeDataType)
|
this.addVisible = true;
|
|
},
|
|
// 属性类型下拉框change
|
attributeDataTypeChange(val) {
|
this.form.rangeValue = null;
|
this.getEnumMapByTypeHandler(val);
|
this.form.enumSwitch = false;
|
if (val === 'VTBoolean') {
|
this.form.defaultValue = 'false';
|
} else {
|
this.form.defaultValue = '';
|
}
|
},
|
|
// 属性类型下拉框数据处理
|
getEnumMapByTypeHandler(val) {
|
const enumType = {
|
VTString: 'String',
|
VTInteger: 'Integer',
|
VTLong: 'Integer',
|
};
|
if (enumType[val]) {
|
const string = enumType[val];
|
getEnumMapByType({enumType: string}).then(res => {
|
const data = res.data.data;
|
this.attributeDataTypePickList = data.flatMap(obj =>
|
Object.entries(obj).map(([key, values]) => ({
|
key: key,
|
values: values
|
}))
|
);
|
})
|
}
|
},
|
|
// 使用枚举时 枚举选择下拉框change事件
|
enumSelectChange(val) {
|
const list = this.attributeDataTypePickList.find(item => item.key === val).values;
|
this.form.rangeValue = list.join('\n');
|
this.form.defaultValue = this.rangeOptionValue[0];
|
},
|
|
// 使用枚举switch滑块change事件
|
switchEnumChange(status) {
|
if (status) {
|
this.form.enumId = this.attributeDataTypePickList[0].key;
|
const list = this.attributeDataTypePickList[0].values;
|
this.form.rangeValue = list.join('\n');
|
this.form.defaultValue = this.rangeOptionValue[0];
|
} else {
|
this.form.defaultValue = "";
|
this.form.rangeValue = "";
|
this.enumId = "";
|
}
|
},
|
|
// 不使用枚举 手动添加枚举值
|
enumAddHandler() {
|
// 检查和转换 this.form.range 为数组,同时排除空值
|
let currentRangeArray = this.form.rangeValue ? this.form.rangeValue.split('\n').filter(item => item.trim() !== '') : [];
|
|
let newValue = this.form.enumAddValue.trim();
|
if (currentRangeArray.includes(newValue)) {
|
this.$message.error('该值域规则已经存在!')
|
return;
|
}
|
|
currentRangeArray.push(newValue);
|
this.enumAddListChange = currentRangeArray;
|
this.form.rangeValue = currentRangeArray.join('\n');
|
this.form.enumAddValue = "";
|
},
|
|
// 不使用枚举 手动添加枚举值(多个运算符)
|
operationHandler(val) {
|
// 检查和转换 this.form.rangeValue 为数组,同时排除空值
|
let currentRangeArray = this.form.rangeValue
|
? this.form.rangeValue.split('\n').filter(item => item.trim() !== '')
|
: [];
|
|
// 处理 '()' 运算符的情况
|
if (val === '()') {
|
// 切割 enumAddValue 的逗号
|
let values = this.form.enumAddValue.split(',').map(item => item.trim());
|
|
// 检查是否有有效的值
|
if (values.length < 2 || values.some(item => item === '')) {
|
this.$message.error('请输入有效的值,并用逗号分隔!');
|
return;
|
}
|
|
// 检查左边值是否小于右边值
|
let leftValue = parseFloat(values[0]);
|
let rightValue = parseFloat(values[1]);
|
|
if (isNaN(leftValue) || isNaN(rightValue)) {
|
this.$message.error('请输入有效的数字值!');
|
return;
|
}
|
|
if (leftValue >= rightValue) {
|
this.$message.error('左边的值不能大于或等于右边的值!');
|
return;
|
}
|
|
// 构建 newValue 的形式 (值1,值2)
|
let newValue = `(${values.join(',')})`;
|
|
// 检查新的值是否已存在
|
if (currentRangeArray.includes(newValue)) {
|
this.$message.error('该值域规则已经存在!');
|
return;
|
}
|
|
// 添加新值到数组中
|
currentRangeArray.push(newValue);
|
this.enumAddListChange = currentRangeArray;
|
this.form.rangeValue = currentRangeArray.join('\n');
|
this.form.enumAddValue = "";
|
return;
|
}
|
|
// 处理其他运算符
|
const operatorMap = {
|
'>': '>',
|
'<': '<',
|
'>=': '>=',
|
'<=': '<=',
|
'=': '=',
|
'!=': '!='
|
};
|
|
// 创建新的值
|
let newValue = operatorMap[val] + this.form.enumAddValue.trim();
|
|
// 检查新的值是否已存在
|
if (currentRangeArray.includes(newValue)) {
|
this.$message.error('该值域规则已经存在!');
|
return;
|
}
|
|
// 添加新值到数组中
|
currentRangeArray.push(newValue);
|
this.enumAddListChange = currentRangeArray;
|
this.form.rangeValue = currentRangeArray.join('\n');
|
this.form.enumAddValue = "";
|
},
|
|
// 值域类型切换
|
attributeSelectTypeChange() {
|
this.$forceUpdate(); // 强制更新form组件
|
this.form.referValue = null; // 切换值域类型 清空当前参照
|
},
|
|
// 选择参照
|
referFormFocusHandler() {
|
this.form.enumSwitch = false;
|
this.form.rangeValue = "";
|
this.form.enumId = "";
|
const handlers = {
|
business: () => {
|
this.businessVisible = true;
|
this.businessLoading = true;
|
this.businessGetTable();
|
},
|
link: () => {
|
this.linkTypeVisible = true;
|
this.linkTypeLoading = true;
|
this.linkGetTable();
|
}
|
};
|
|
const {attributeSelectType} = this.form;
|
const handler = handlers[attributeSelectType];
|
|
if (handler) {
|
handler();
|
}
|
;
|
},
|
|
// 业务类型表格数据请求
|
businessGetTable() {
|
getBizTypes(this.businessSearchParams).then(res => {
|
const data = res.data.data;
|
this.businessData = data;
|
this.businessLoading = false;
|
})
|
},
|
|
// 业务类型参照搜索
|
businessHandleSearch(val, done) {
|
this.businessSearchParams = {
|
btmName: val.name
|
}
|
this.businessGetTable();
|
done()
|
},
|
|
// 业务类型参照清空搜索
|
businessHandleReset() {
|
this.businessSearchParams = {};
|
this.businessGetTable();
|
},
|
|
// 链接类型表格数据请求
|
linkGetTable() {
|
getAllLtName(this.linkTypeSearchParams).then(res => {
|
const data = res.data.data.map(item => ({name: item}));
|
;
|
this.linkTypeData = data;
|
this.linkDataSearch = data;
|
this.linkTypeLoading = false;
|
})
|
},
|
|
// 链接类型参照搜索
|
linkHandleSearch(params, done) {
|
const {name} = params;
|
|
if (!params.name) {
|
this.linkTypeData = this.linkDataSearch;
|
return done();
|
}
|
;
|
|
this.linkTypeData = this.linkDataSearch.filter(item => {
|
console.log(item)
|
return item.name && item.name.includes(name);
|
});
|
|
done();
|
},
|
|
// 链接类型参照清空搜索
|
linkHandleReset() {
|
this.linkTypeData = this.linkDataSearch;
|
},
|
|
// 业务类型表格行点击
|
businessRowClick(row) {
|
this.businessRow = row;
|
},
|
|
// 业务类型确定保存
|
businessSaveHandler() {
|
if (func.isEmptyObject(this.businessRow)) {
|
this.$message.error('请选择一条数据!')
|
return;
|
}
|
|
this.form.referValue = this.businessRow.name;
|
this.businessVisible = false;
|
},
|
|
// 业务类型清空
|
businessEmpty() {
|
this.form.referValue = null;
|
this.businessVisible = false;
|
},
|
|
// 链接类型确定保存
|
linkRowClick(row) {
|
this.linkRow = row;
|
},
|
|
// 业务类型确定保存
|
linkSaveHandler() {
|
if (func.isEmptyObject(this.linkRow)) {
|
this.$message.error('请选择一条数据!')
|
return;
|
}
|
|
this.form.referValue = this.linkRow.name;
|
this.linkTypeVisible = false;
|
},
|
|
// 链接类型清空
|
linkEmpty() {
|
this.form.referValue = null;
|
this.linkTypeVisible = false;
|
},
|
|
// 新增对话框 取消事件
|
addEscHandler() {
|
this.$refs.form.resetFields(); // 对整个表单进行重置,将所有字段值重置为初始值并移除校验结果
|
this.addVisible = false;
|
const form = {
|
id: "",
|
name: "",
|
attributeDataType: "VTString",
|
description: "",
|
nullableFlag: true,
|
attrLength: 50,
|
enumFlag: false,
|
enumId: "",
|
enumSwitch: false,
|
enumAddValue: "",
|
range: "",
|
attributeSelectType: "business",
|
version: 1,
|
defaultValue: "",
|
referValue: "",
|
btmTypeId: "",
|
linkTypeName: "",
|
rangeValue: ""
|
};
|
this.form = form;
|
},
|
|
// 新增保存
|
addSaveHandler() {
|
const form = {
|
id: "",
|
name: "",
|
attributeDataType: "VTString",
|
description: "",
|
nullableFlag: true,
|
attrLength: 50,
|
enumFlag: false,
|
enumId: "",
|
enumSwitch: false,
|
enumAddValue: "",
|
range: "",
|
attributeSelectType: "business",
|
version: 1,
|
defaultValue: "",
|
referValue: "",
|
btmTypeId: "",
|
linkTypeName: "",
|
rangeValue: ""
|
};
|
if (this.dialogTitle === 'add') {
|
this.form.range = this.form.rangeValue.replace(/\n/g, ';');
|
if (this.form.attributeSelectType === 'business') {
|
this.form.btmTypeId = this.form.referValue;
|
} else {
|
this.form.linkTypeName = this.form.referValue;
|
}
|
addAttribute(this.form).then(res => {
|
if (res.data.code === 200) {
|
this.$message.success(res.data.obj);
|
this.getTableList();
|
this.form = form;
|
this.addVisible = false;
|
}
|
})
|
}
|
if (this.dialogTitle === 'edit') {
|
this.form.range = this.form.rangeValue.replace(/\n/g, ';');
|
if (this.form.attributeSelectType === 'business') {
|
this.form.btmTypeId = this.form.referValue;
|
} else {
|
this.form.linkTypeName = this.form.referValue;
|
}
|
updateAttribute(this.form).then(res => {
|
if (res.data.code === 200) {
|
this.$message.success(res.data.obj);
|
this.getTableList();
|
this.form = form;
|
this.addVisible = false;
|
}
|
})
|
}
|
},
|
|
// 导入
|
upLoadHandler() {
|
this.$refs.upload.visible = true;
|
},
|
|
// 导出
|
downLoadHandler() {
|
if (this.selectList.length <= 0) {
|
this.$message.warning('请至少选择一条数据进行导出');
|
return;
|
}
|
|
let attrNames = this.selectList.map(item => item.id).join(',');
|
exportAttributes({attrNames: attrNames}).then(res => {
|
func.downloadFileByBlobHandler(res);
|
this.$message.success('导出成功');
|
}).catch(err => {
|
this.$message.error(err);
|
})
|
},
|
|
// 下载导入模板
|
downloadTemplateHandler() {
|
downloadAttributeTemplate().then(res => {
|
func.downloadFileByBlobHandler(res);
|
this.$message.success('下载成功');
|
}).catch(err => {
|
this.$message.error(err);
|
})
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.margin-top {
|
margin-top: 25px;
|
}
|
|
.left {
|
width: 45%;
|
height: 100%;
|
margin-right: 60px;
|
}
|
|
.right {
|
height: 100%;
|
width: auto;
|
margin-left: 60px;
|
}
|
|
.addDialogBottom {
|
width: 100%;
|
display: flex;
|
flex-direction: row;
|
}
|
|
.addDialogBottom > .el-divider--vertical {
|
width: 2px;
|
height: 78%;
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
transform: translate(-50%, -20%);
|
}
|
</style>
|