|
@@ -125,12 +125,6 @@
|
|
<el-form-item label="模型名称" prop="modelName">
|
|
<el-form-item label="模型名称" prop="modelName">
|
|
<el-input v-model="form.modelName" placeholder="请输入模型名称"/>
|
|
<el-input v-model="form.modelName" placeholder="请输入模型名称"/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <!-- 对象类型选择,但值由标签页控制 -->
|
|
|
|
-<!-- <el-form-item label="对象类型" prop="objType">-->
|
|
|
|
-<!-- <el-select v-model="form.objType" placeholder="请选择对象类型" disabled>-->
|
|
|
|
-<!-- <el-option :label="objTypeMapping[activeObjType]" :value="activeObjType" />-->
|
|
|
|
-<!-- </el-select>-->
|
|
|
|
-<!-- </el-form-item>-->
|
|
|
|
</el-form>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
@@ -170,8 +164,9 @@
|
|
<pagination v-show="total>0" :total="total" :page.sync="queryAttrParams.pageNum"
|
|
<pagination v-show="total>0" :total="total" :page.sync="queryAttrParams.pageNum"
|
|
:limit.sync="queryAttrParams.pageSize"
|
|
:limit.sync="queryAttrParams.pageSize"
|
|
@pagination="getAttrList"/>
|
|
@pagination="getAttrList"/>
|
|
- <!-- 添加或修改服务区用电属性对话框 -->
|
|
|
|
- <el-dialog :title="title" :visible.sync="attrOpen" width="500px" append-to-body>
|
|
|
|
|
|
+
|
|
|
|
+ <!-- 添加或修改属性对话框 -->
|
|
|
|
+ <el-dialog :title="title" :visible.sync="attrOpen" width="650px" append-to-body>
|
|
<el-form ref="attrForm" :model="attrForm" :rules="attrRules" label-width="150px">
|
|
<el-form ref="attrForm" :model="attrForm" :rules="attrRules" label-width="150px">
|
|
<el-form-item label="属性名称" prop="attrName">
|
|
<el-form-item label="属性名称" prop="attrName">
|
|
<el-input v-model="attrForm.attrName" placeholder="请输入属性名称"/>
|
|
<el-input v-model="attrForm.attrName" placeholder="请输入属性名称"/>
|
|
@@ -198,6 +193,42 @@
|
|
</el-option>
|
|
</el-option>
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+
|
|
|
|
+ <!--属性值表格-->
|
|
|
|
+ <el-form-item label="枚举类型值" prop="customAttrs" v-if="attrForm.attrValueType === 'String'">
|
|
|
|
+ <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="请输入枚举值" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="描述" align="center" prop="attrValueName">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-input size="mini" v-model="scope.row.attrValueName" placeholder="请输入描述" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" label="操作">
|
|
|
|
+ <template slot="header">
|
|
|
|
+ <div class="operateBtns" @click="addCustomAttr">
|
|
|
|
+ <span>添加</span><i class="el-icon-circle-plus-outline"></i>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <i class="el-icon-delete" @click="deleteCustomAttr(scope.$index)"></i>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="submitAttrForm">确 定</el-button>
|
|
<el-button type="primary" @click="submitAttrForm">确 定</el-button>
|
|
@@ -295,9 +326,6 @@
|
|
<!-- 添加或修改能力对话框 -->
|
|
<!-- 添加或修改能力对话框 -->
|
|
<el-dialog :title="title" :visible.sync="abilityOpen" width="500px" append-to-body>
|
|
<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 ref="abilityForm" :model="abilityForm" :rules="abilityRules" label-width="80px">
|
|
-<!-- <el-form-item label="模型code" prop="modelCode">-->
|
|
|
|
-<!-- <el-input v-model="abilityForm.modelCode" placeholder="请输入模型code"/>-->
|
|
|
|
-<!-- </el-form-item>-->
|
|
|
|
<el-form-item label="能力键" prop="abilityKey">
|
|
<el-form-item label="能力键" prop="abilityKey">
|
|
<el-input v-model="abilityForm.abilityKey" placeholder="请输入能力键"/>
|
|
<el-input v-model="abilityForm.abilityKey" placeholder="请输入能力键"/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -329,11 +357,14 @@ import { listModel, getModel, delModel, addModel, updateModel, getModelByCode }
|
|
import { getEvent, delEvent, addEvent, updateEvent } from '@/api/basecfg/objEvent'
|
|
import { getEvent, delEvent, addEvent, updateEvent } from '@/api/basecfg/objEvent'
|
|
import { getAttr, delAttr, addAttr, updateAttr } from '@/api/basecfg/objAttribute'
|
|
import { getAttr, delAttr, addAttr, updateAttr } from '@/api/basecfg/objAttribute'
|
|
import { getAbility, delAbility, addAbility, updateAbility } from '@/api/basecfg/objAbility'
|
|
import { getAbility, delAbility, addAbility, updateAbility } from '@/api/basecfg/objAbility'
|
|
|
|
+import {getAttrList,delAttrEnum,addAttrEnums} from '@/api/basecfg/emum'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: 'Model',
|
|
name: 'Model',
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ // 用于存储表格数据
|
|
|
|
+ customAttrs: [],
|
|
// 遮罩层
|
|
// 遮罩层
|
|
loading: true,
|
|
loading: true,
|
|
// 选中数组
|
|
// 选中数组
|
|
@@ -402,7 +433,8 @@ export default {
|
|
id: null,
|
|
id: null,
|
|
modelCode: null,
|
|
modelCode: null,
|
|
modelName: null,
|
|
modelName: null,
|
|
- objType: null // 这里将由标签页控制
|
|
|
|
|
|
+ // 这里将由标签页控制
|
|
|
|
+ objType: null
|
|
},
|
|
},
|
|
eventForm: {},
|
|
eventForm: {},
|
|
attrForm: {},
|
|
attrForm: {},
|
|
@@ -462,7 +494,6 @@ export default {
|
|
attrList: [],
|
|
attrList: [],
|
|
// 能源对象能力表格数据
|
|
// 能源对象能力表格数据
|
|
abilityList: [],
|
|
abilityList: [],
|
|
-
|
|
|
|
showDrawer: false,
|
|
showDrawer: false,
|
|
subDialogShow: false,
|
|
subDialogShow: false,
|
|
// subTitle: '',
|
|
// subTitle: '',
|
|
@@ -473,17 +504,43 @@ export default {
|
|
this.getList()
|
|
this.getList()
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
-
|
|
|
|
handleTabClick(tab) {
|
|
handleTabClick(tab) {
|
|
this.activeObjType = tab.name;
|
|
this.activeObjType = tab.name;
|
|
- this.form.objType = null; // 重置表单时清除预设的 objType
|
|
|
|
|
|
+ this.form.objType = null;
|
|
this.getList();
|
|
this.getList();
|
|
},
|
|
},
|
|
|
|
+ getObjAttrList(modelCode, attrKey) {
|
|
|
|
+ this.loading = true;
|
|
|
|
+ getAttrList(modelCode, attrKey).then((response) => {
|
|
|
|
+ this.customAttrs = response.data || [];
|
|
|
|
+ this.loading = false;
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ // 添加自定义属性的方法
|
|
|
|
+ addCustomAttr() {
|
|
|
|
+ this.customAttrs.push({
|
|
|
|
+ modelCode:this.attrForm.modelCode,
|
|
|
|
+ attrKey: null,
|
|
|
|
+ attrValue: null,
|
|
|
|
+ attrValueName: null,
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ //删除自定义属性的方法
|
|
|
|
+ deleteCustomAttr(index) {
|
|
|
|
+ const customAttr = this.customAttrs[index];
|
|
|
|
+ const attrEnumId = customAttr.id;
|
|
|
|
+ this.$modal.confirm('是否确认删除枚举值编号为"' + attrEnumId + '"的数据项?').then(() => {
|
|
|
|
+ return delAttrEnum(attrEnumId);
|
|
|
|
+ }).then(() => {
|
|
|
|
+ this.customAttrs.splice(index, 1);
|
|
|
|
+ this.$modal.msgSuccess('删除成功');
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 设配详情
|
|
// 设配详情
|
|
handleDetail(row) {
|
|
handleDetail(row) {
|
|
this.showDrawer = true
|
|
this.showDrawer = true
|
|
this.curRow = row
|
|
this.curRow = row
|
|
- //console.log('模型代码', this.modelCode)
|
|
|
|
getModel(this.curRow.id).then(response => {
|
|
getModel(this.curRow.id).then(response => {
|
|
const data = response.data
|
|
const data = response.data
|
|
console.log('data', data)
|
|
console.log('data', data)
|
|
@@ -498,6 +555,8 @@ export default {
|
|
this.attrOpen = true
|
|
this.attrOpen = true
|
|
this.title = '添加能源对象属性'
|
|
this.title = '添加能源对象属性'
|
|
this.attrForm.modelCode= this.curRow.modelCode
|
|
this.attrForm.modelCode= this.curRow.modelCode
|
|
|
|
+ console.log("新增123",this.attrForm)
|
|
|
|
+ this.getObjAttrList(this.attrForm.modelCode, this.attrForm.attrKey);
|
|
},
|
|
},
|
|
handleEventAdd() {
|
|
handleEventAdd() {
|
|
this.eventReset()
|
|
this.eventReset()
|
|
@@ -529,7 +588,6 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
getEventList(modelcode) {
|
|
getEventList(modelcode) {
|
|
- console.log('对象事件!!!!')
|
|
|
|
this.loading = true
|
|
this.loading = true
|
|
getModelByCode(modelcode).then(response => {
|
|
getModelByCode(modelcode).then(response => {
|
|
const data = response.data
|
|
const data = response.data
|
|
@@ -619,6 +677,7 @@ export default {
|
|
this.attrOpen = true
|
|
this.attrOpen = true
|
|
this.title = '修改能源对象属性'
|
|
this.title = '修改能源对象属性'
|
|
this.attrForm.modelCode= this.curRow.modelCode
|
|
this.attrForm.modelCode= this.curRow.modelCode
|
|
|
|
+ this.getObjAttrList(this.attrForm.modelCode, this.attrForm.attrKey);
|
|
|
|
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -680,27 +739,55 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /** 获取数据库中已存在的枚举值*/
|
|
|
|
+ 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() {
|
|
submitAttrForm() {
|
|
- this.$refs['attrForm'].validate(valid => {
|
|
|
|
|
|
+ this.$refs["attrForm"].validate(async (valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- if (this.attrForm.id != null) {
|
|
|
|
- updateAttr(this.attrForm).then(response => {
|
|
|
|
- this.$modal.msgSuccess('修改成功')
|
|
|
|
- this.attrOpen = false
|
|
|
|
- console.log('id', this.attrForm.modelCode)
|
|
|
|
- this.getAttrList(this.attrForm.modelCode)
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- addAttr(this.attrForm).then(response => {
|
|
|
|
- this.$modal.msgSuccess('新增成功')
|
|
|
|
- this.attrOpen = false
|
|
|
|
- this.getAttrList(this.attrForm.modelCode)
|
|
|
|
- })
|
|
|
|
|
|
+ try {
|
|
|
|
+ await this.getExistingEnums();
|
|
|
|
+ const newCustomAttrs = this.customAttrs.filter(attr => {
|
|
|
|
+ return !this.existingEnums.some(existingAttr =>
|
|
|
|
+ existingAttr.attrKey === attr.attrKey &&
|
|
|
|
+ existingAttr.attrValue === attr.attrValue
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ 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() {
|
|
submitEventForm() {
|
|
this.$refs['eventForm'].validate(valid => {
|
|
this.$refs['eventForm'].validate(valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
@@ -800,7 +887,7 @@ export default {
|
|
const id = row.id || this.ids
|
|
const id = row.id || this.ids
|
|
getModel(id).then(response => {
|
|
getModel(id).then(response => {
|
|
this.form = response.data
|
|
this.form = response.data
|
|
- this.form.objType = this.activeObjType; // 设置默认对象类型
|
|
|
|
|
|
+ this.form.objType = this.activeObjType;
|
|
this.open = true
|
|
this.open = true
|
|
this.title = '修改能源对象属性'
|
|
this.title = '修改能源对象属性'
|
|
})
|
|
})
|