|
@@ -65,7 +65,6 @@
|
|
|
>删除
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
-
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
|
|
@@ -125,6 +124,12 @@
|
|
|
<el-form-item label="模型名称" prop="modelName">
|
|
|
<el-input v-model="form.modelName" placeholder="请输入模型名称"/>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="能力接口" prop="abilityHandle">
|
|
|
+ <el-input v-model="form.abilityHandle" placeholder="请输入能力接口"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="事件接口" prop="eventHandle">
|
|
|
+ <el-input v-model="form.eventHandle" placeholder="请输入事件接口"/>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
@@ -132,7 +137,6 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
-
|
|
|
<!-- ”特性“对话框 -->
|
|
|
<el-drawer :title=curRow.modelName size="80%" :visible.sync="showDrawer" direction="rtl">
|
|
|
<div class="drawer-content" style="padding-left:50px">
|
|
@@ -195,18 +199,8 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--属性值表格-->
|
|
|
- <el-form-item label="枚举类型值" prop="customAttrs" v-if="attrForm.attrValueType === 'String'">
|
|
|
+ <el-form-item label="枚举类型值" prop="customAttrs" v-if="attrForm.attrValueType === 'Enum'">
|
|
|
<el-table class="attr-table" v-loading="loading" :data="customAttrs" max-height="280px" key="'customAttrs'">
|
|
|
- <el-table-column label="模型代码" align="center" prop="modelCode">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-input size="mini" v-model="scope.row.modelCode" placeholder="请输入模型代码" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="属性标识" align="center" prop="attrKey">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-input size="mini" v-model="scope.row.attrKey" placeholder="请输入属性标识" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
<el-table-column label="枚举值" align="center" prop="attrValue">
|
|
|
<template slot-scope="scope">
|
|
|
<el-input size="mini" v-model="scope.row.attrValue" placeholder="请输入枚举值" />
|
|
@@ -323,7 +317,7 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
- <!-- 添加或修改能力对话框 -->
|
|
|
+ <!--添加或修改能力对话框 -->
|
|
|
<el-dialog :title="title" :visible.sync="abilityOpen" width="500px" append-to-body>
|
|
|
<el-form ref="abilityForm" :model="abilityForm" :rules="abilityRules" label-width="80px">
|
|
|
<el-form-item label="能力键" prop="abilityKey">
|
|
@@ -338,6 +332,12 @@
|
|
|
<el-form-item label="能力参数" prop="abilityParam">
|
|
|
<el-input v-model="abilityForm.abilityParam" type="textarea" placeholder="请输入内容"/>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="隐藏标记" prop="hiddenFlag">
|
|
|
+ <el-radio-group v-model="abilityForm.hiddenFlag">
|
|
|
+ <el-radio :label="0">隐藏</el-radio>
|
|
|
+ <el-radio :label="1">展示</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button type="primary" @click="submitAbilityForm">确 定</el-button>
|
|
@@ -357,13 +357,13 @@ import { listModel, getModel, delModel, addModel, updateModel, getModelByCode }
|
|
|
import { getEvent, delEvent, addEvent, updateEvent } from '@/api/basecfg/objEvent'
|
|
|
import { getAttr, delAttr, addAttr, updateAttr } from '@/api/basecfg/objAttribute'
|
|
|
import { getAbility, delAbility, addAbility, updateAbility } from '@/api/basecfg/objAbility'
|
|
|
-import {getAttrList,delAttrEnum,addAttrEnums} from '@/api/basecfg/emum'
|
|
|
+import {getAttrList,delAttrEnum} from '@/api/basecfg/emum'
|
|
|
|
|
|
export default {
|
|
|
name: 'Model',
|
|
|
data() {
|
|
|
return {
|
|
|
- // 用于存储表格数据
|
|
|
+ // 用于存储属性表格
|
|
|
customAttrs: [],
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
@@ -380,7 +380,7 @@ export default {
|
|
|
// 能源对象属性表格数据
|
|
|
modelList: [],
|
|
|
filteredModelList:[],
|
|
|
- activeObjType: '1', // 当前激活的 objType
|
|
|
+ activeObjType: '1',
|
|
|
// 弹出层标题
|
|
|
title: '',
|
|
|
// 是否显示弹出层
|
|
@@ -434,7 +434,9 @@ export default {
|
|
|
modelCode: null,
|
|
|
modelName: null,
|
|
|
// 这里将由标签页控制
|
|
|
- objType: null
|
|
|
+ objType: null,
|
|
|
+ abilityHandle: null,
|
|
|
+ eventHandle: null
|
|
|
},
|
|
|
eventForm: {},
|
|
|
attrForm: {},
|
|
@@ -487,16 +489,14 @@ export default {
|
|
|
{ required: true, message: '能力名称不能为空', trigger: 'blur' }
|
|
|
]
|
|
|
},
|
|
|
-
|
|
|
- // 能源对象事件表格数据
|
|
|
+ // 能源对象事件
|
|
|
eventList: [],
|
|
|
- // 能源对象属性表格数据
|
|
|
+ // 能源对象属性
|
|
|
attrList: [],
|
|
|
- // 能源对象能力表格数据
|
|
|
+ // 能源对象能力
|
|
|
abilityList: [],
|
|
|
showDrawer: false,
|
|
|
subDialogShow: false,
|
|
|
- // subTitle: '',
|
|
|
subKey: 'attr'
|
|
|
}
|
|
|
},
|
|
@@ -520,8 +520,6 @@ export default {
|
|
|
// 添加自定义属性的方法
|
|
|
addCustomAttr() {
|
|
|
this.customAttrs.push({
|
|
|
- modelCode:this.attrForm.modelCode,
|
|
|
- attrKey: null,
|
|
|
attrValue: null,
|
|
|
attrValueName: null,
|
|
|
});
|
|
@@ -591,7 +589,6 @@ export default {
|
|
|
this.loading = true
|
|
|
getModelByCode(modelcode).then(response => {
|
|
|
const data = response.data
|
|
|
- console.log('data', data)
|
|
|
this.attrList = data.attrList
|
|
|
this.eventList = data.eventList
|
|
|
this.abilityList = data.abilityList
|
|
@@ -604,28 +601,23 @@ export default {
|
|
|
this.loading = true
|
|
|
getModelByCode(modelcode).then(response => {
|
|
|
const data = response.data
|
|
|
- console.log('data', data)
|
|
|
this.attrList = data.attrList
|
|
|
this.eventList = data.eventList
|
|
|
this.abilityList = data.abilityList
|
|
|
-
|
|
|
})
|
|
|
this.loading = false
|
|
|
},
|
|
|
/** 查询能源对象能力列表 */
|
|
|
getAbilityList(modelcode) {
|
|
|
this.loading = true
|
|
|
- console.log('对象能力!!!!')
|
|
|
getModelByCode(modelcode).then(response => {
|
|
|
const data = response.data
|
|
|
- console.log('data', data)
|
|
|
this.attrList = data.attrList
|
|
|
this.eventList = data.eventList
|
|
|
this.abilityList = data.abilityList
|
|
|
|
|
|
})
|
|
|
this.loading = false
|
|
|
-
|
|
|
},
|
|
|
|
|
|
// 表单重置
|
|
@@ -662,7 +654,8 @@ export default {
|
|
|
abilityKey: null,
|
|
|
abilityName: null,
|
|
|
abilityDesc: null,
|
|
|
- abilityParam: null
|
|
|
+ abilityParam: null,
|
|
|
+ hiddenFlag:null,
|
|
|
}
|
|
|
this.resetForm('abilityForm')
|
|
|
},
|
|
@@ -673,7 +666,6 @@ export default {
|
|
|
const id = row.id || this.ids
|
|
|
getAttr(id).then(response => {
|
|
|
this.attrForm = response.data
|
|
|
- console.log("this.attrForm",this.attrForm)
|
|
|
this.attrOpen = true
|
|
|
this.title = '修改能源对象属性'
|
|
|
this.attrForm.modelCode= this.curRow.modelCode
|
|
@@ -710,7 +702,6 @@ export default {
|
|
|
this.$modal.confirm('是否确认删除能源对象属性编号为"' + ids + '"的数据项?').then(function() {
|
|
|
return delAttr(ids)
|
|
|
}).then(() => {
|
|
|
- console.log('删除row', row.modelCode)
|
|
|
this.getAttrList(row.modelCode)
|
|
|
this.$modal.msgSuccess('删除成功')
|
|
|
}).catch(() => {
|
|
@@ -721,7 +712,6 @@ export default {
|
|
|
this.$modal.confirm('是否确认删除能源对象事件编号为"' + ids + '"的数据项?').then(function() {
|
|
|
return delEvent(ids)
|
|
|
}).then(() => {
|
|
|
- console.log('删除row', row.modelCode)
|
|
|
this.getEventList(row.modelCode)
|
|
|
this.$modal.msgSuccess('删除成功')
|
|
|
}).catch(() => {
|
|
@@ -732,62 +722,42 @@ export default {
|
|
|
this.$modal.confirm('是否确认删除能源对象能力编号为"' + ids + '"的数据项?').then(function() {
|
|
|
return delAbility(ids)
|
|
|
}).then(() => {
|
|
|
- console.log('删除row', row.modelCode)
|
|
|
this.getAbilityList(row.modelCode)
|
|
|
this.$modal.msgSuccess('删除成功')
|
|
|
}).catch(() => {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- /** 获取数据库中已存在的枚举值*/
|
|
|
- async getExistingEnums() {
|
|
|
- try {
|
|
|
- this.loading = true;
|
|
|
- const response = await getAttrList(this.attrForm.modelCode, this.attrForm.attrKey);
|
|
|
- this.existingEnums = response.data || [];
|
|
|
- this.loading = false;
|
|
|
- } catch (error) {
|
|
|
- this.$modal.msgError("获取枚举值失败:" + error.message);
|
|
|
- this.loading = false;
|
|
|
- throw error;
|
|
|
- }
|
|
|
- },
|
|
|
/** 提交按钮 */
|
|
|
submitAttrForm() {
|
|
|
- this.$refs["attrForm"].validate(async (valid) => {
|
|
|
+ this.$refs['attrForm'].validate(valid => {
|
|
|
if (valid) {
|
|
|
- try {
|
|
|
- await this.getExistingEnums();
|
|
|
- const newCustomAttrs = this.customAttrs.filter(attr => {
|
|
|
- return !this.existingEnums.some(existingAttr =>
|
|
|
- existingAttr.attrKey === attr.attrKey &&
|
|
|
- existingAttr.attrValue === attr.attrValue
|
|
|
- );
|
|
|
+ const formData = {
|
|
|
+ ...this.attrForm,
|
|
|
+ valueEnums: this.customAttrs.map(item => ({
|
|
|
+ modelCode: this.attrForm.modelCode,
|
|
|
+ attrKey: this.attrForm.attrKey,
|
|
|
+ attrValue: item.attrValue,
|
|
|
+ attrValueName: item.attrValueName
|
|
|
+ }))
|
|
|
+ };
|
|
|
+
|
|
|
+ if (this.attrForm.id != null) {
|
|
|
+ updateAttr(formData).then(response => {
|
|
|
+ this.$modal.msgSuccess('修改成功');
|
|
|
+ this.attrOpen = false;
|
|
|
+ this.getAttrList(this.attrForm.modelCode); // 刷新属性列表
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addAttr(formData).then(response => {
|
|
|
+ this.$modal.msgSuccess('新增成功');
|
|
|
+ this.attrOpen = false;
|
|
|
+ this.getAttrList(this.attrForm.modelCode);
|
|
|
});
|
|
|
- if (newCustomAttrs.length > 0) {
|
|
|
- await addAttrEnums(newCustomAttrs); // 调用接口添加枚举值
|
|
|
- this.$modal.msgSuccess("枚举值添加成功");
|
|
|
- } else {
|
|
|
- this.$modal.msgSuccess("没有新的枚举值需要添加");
|
|
|
- }
|
|
|
-
|
|
|
- if (this.attrForm.id != null) {
|
|
|
- await updateAttr(this.attrForm);
|
|
|
- this.$modal.msgSuccess("修改成功");
|
|
|
- } else {
|
|
|
- await addAttr(this.attrForm);
|
|
|
- this.$modal.msgSuccess("新增成功");
|
|
|
- }
|
|
|
-
|
|
|
- this.attrOpen = false;
|
|
|
- this.getAttrList(this.attrForm.modelCode);
|
|
|
- } catch (error) {
|
|
|
- this.$modal.msgError("操作失败:" + error.message);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
submitEventForm() {
|
|
|
this.$refs['eventForm'].validate(valid => {
|
|
|
if (valid) {
|
|
@@ -795,14 +765,12 @@ export default {
|
|
|
updateEvent(this.eventForm).then(response => {
|
|
|
this.$modal.msgSuccess('修改成功')
|
|
|
this.eventOpen = false
|
|
|
- console.log('id', this.eventForm)
|
|
|
this.getEventList(this.eventForm.modelCode)
|
|
|
})
|
|
|
} else {
|
|
|
addEvent(this.eventForm).then(response => {
|
|
|
this.$modal.msgSuccess('新增成功')
|
|
|
this.eventOpen = false
|
|
|
- console.log('id', this.eventForm)
|
|
|
this.getEventList(this.eventForm.modelCode)
|
|
|
})
|
|
|
}
|
|
@@ -854,7 +822,8 @@ export default {
|
|
|
id: null,
|
|
|
modelCode: null,
|
|
|
modelName: null,
|
|
|
- objType: null
|
|
|
+ objType: null,
|
|
|
+
|
|
|
}
|
|
|
this.resetForm('form')
|
|
|
},
|