|
@@ -39,6 +39,14 @@
|
|
|
:key="item.systemCode" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="设备工艺" prop="psCode" v-if="queryParams.deviceCategory === 'W'">
|
|
|
+ <el-select v-model="queryParams.psCode">
|
|
|
+ <el-option v-for="item in devOptions" :label="item.psName" :value="item.psCode" :key="item.psCode" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
@@ -78,7 +86,9 @@
|
|
|
<el-table-column label="子系统" align="center" prop="subsystemName" />
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button size="mini" type="text" icon="el-icon-info" @click="handleDetail(scope.row)" v-hasPermi="['basecfg:emsfacs:edit']">
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-info" @click="handleDevProcess(scope.row)" v-hasPermi="['basecfg:device:edit']" v-if="shouldShowDevProcessButton(scope.row)" >
|
|
|
+ 器件</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-info" @click="handleDetail(scope.row)" v-hasPermi="['basecfg:device:edit']">
|
|
|
详情</el-button>
|
|
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
|
|
v-hasPermi="['basecfg:device:edit']">
|
|
@@ -103,22 +113,89 @@
|
|
|
:key="item.facsCode" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="安装位置" prop="refArea">
|
|
|
- <treeselect v-model="form.refArea" :options="totalAreaOptions" :show-count="true" placeholder="请选择所属建筑"
|
|
|
- @select="handleAreaType" />
|
|
|
- </el-form-item>
|
|
|
+<!-- <el-form-item label="安装位置" prop="refArea">-->
|
|
|
+<!-- <treeselect v-model="form.refArea" :options="totalAreaOptions" :show-count="true" placeholder="请选择所属建筑"-->
|
|
|
+<!-- @select="handleAreaType" />-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
<el-form-item label="设备代码" prop="deviceCode">
|
|
|
<el-input v-model="form.deviceCode" placeholder="请输入设备代码" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="设备名称" prop="deviceName">
|
|
|
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+
|
|
|
+ <el-form-item label="设备工艺" prop="psCode" v-if="queryParams.deviceCategory === 'W'">
|
|
|
+ <el-select v-model="form.psCode">
|
|
|
+ <el-option v-for="item in devOptions" :label="item.psName" :value="item.psCode"
|
|
|
+ :key="item.psCode" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
<el-form-item label="设备类型" prop="deviceType">
|
|
|
<el-select v-model="form.deviceCategory">
|
|
|
<el-option v-for="item in subCategoryOptions" :label="item.name" :value="item.code"
|
|
|
:key="item.code" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="设备模型" prop="deviceModel">
|
|
|
+ <el-select v-model="form.deviceModel" style="width:100%" @change="handleModelChange">
|
|
|
+ <el-option
|
|
|
+ v-for="item in modelList"
|
|
|
+ :label="item.modelName"
|
|
|
+ :value="item.modelCode"
|
|
|
+ :key="item.modelCode"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <!-- 这里可以展示属性名称和属性值 -->
|
|
|
+ <div v-if="attrList.length > 0" class="attr-list-container">
|
|
|
+ <h3 >模型属性:</h3>
|
|
|
+ <ul>
|
|
|
+ <li v-for="attr in attrList" :key="attr.attrKey" class="attr-item">
|
|
|
+ <span class="attr-name">{{ attr.attrName }} ({{ attr.attrUnit }}):</span>
|
|
|
+ <!-- 使用 el-input 组件允许用户编辑属性值 -->
|
|
|
+ <el-input
|
|
|
+ v-model="attrValuesMap[attr.attrKey]"
|
|
|
+ placeholder="点击编辑"
|
|
|
+ size="small"
|
|
|
+ @blur="updateAttrValue(attr.attrKey, attrValuesMap[attr.attrKey])"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ <h3 class="attr-list-container" v-if="attrList.length > 0">自定义属性
|
|
|
+ <el-form-item label="" prop="attrList" >
|
|
|
+ <el-table class="attr-table" v-loading="loading" :data="form.customAttrs" max-height="280px" key="'customAttrs'" >
|
|
|
+ <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="attrName">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input size="mini" v-model="scope.row.attrName" 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 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>
|
|
|
+ </h3>
|
|
|
<el-form-item label="子系统" prop="subsystemCode">
|
|
|
<el-select v-model="form.subsystemCode">
|
|
|
<el-option v-for="item in subsystemOptions" :label="item.systemName" :value="item.systemCode"
|
|
@@ -132,6 +209,87 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
+
|
|
|
+ <!--设备器件-->
|
|
|
+ <el-drawer :title=ComponentRow.deviceName size="80%" :visible.sync="showDevProcessDrawer" direction="rtl" >
|
|
|
+ <div class="drawer-content" style="padding-left:50px" >
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleComponentAdd" v-hasPermi="['ems:component:add']">新增
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-table v-loading="loading" :data="ComponentList">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="设备代码" align="center" prop="deviceCode" />
|
|
|
+ <el-table-column label="部件编码" align="center" prop="compoCode" />
|
|
|
+ <el-table-column label="部件标签" align="center" prop="compoTag" />
|
|
|
+ <el-table-column label="工艺标识代码" align="center" prop="psCode" />
|
|
|
+ <el-table-column label="外系统部件编码" align="center" prop="extCompoCode" />
|
|
|
+ <el-table-column label="部件模型" align="center" prop="compoModel" />
|
|
|
+ <el-table-column label="部件品牌" align="center" prop="compoBrand" />
|
|
|
+ <el-table-column label="部件型号" align="center" prop="compoSpec" />
|
|
|
+ <el-table-column label="祖籍列表" align="center" prop="ancestors" />
|
|
|
+ <el-table-column label="上级部件" align="center" prop="parentEqpt" />
|
|
|
+
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleComponentUpdate(scope.row)" v-hasPermi="['ems:component:edit']">
|
|
|
+ 修改</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn" @click="handleComponentDelete(scope.row)" v-hasPermi="['ems:component:remove']">
|
|
|
+ 删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination v-show="total>0" :total="total" :page.sync="queryComponentParams.pageNum" :limit.sync="queryComponentParams.pageSize"
|
|
|
+ @pagination="getComponentList" />
|
|
|
+
|
|
|
+ <!-- 添加或修改设备器件对话框 -->
|
|
|
+ <el-dialog :title="title" :visible.sync="componentOpen" width="500px" append-to-body>
|
|
|
+ <el-form ref="componentForm" :model="componentForm" :rules="componentRules" label-width="150px">
|
|
|
+ <el-form-item label="设备code" prop="deviceCode">
|
|
|
+ <el-input v-model="componentForm.deviceCode" placeholder="请输入设备code" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部件编码" prop="compoCode">
|
|
|
+ <el-input v-model="componentForm.compoCode" placeholder="请输入部件编码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部件标签" prop="compoTag">
|
|
|
+ <el-input v-model="componentForm.compoTag" placeholder="请输入部件标签" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="工艺标签代码" prop="psCode">
|
|
|
+ <el-input v-model="componentForm.psCode" placeholder="请输入工艺标签代码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="外系统部件编码" prop="extCompoCode">
|
|
|
+ <el-input v-model="componentForm.extCompoCode" placeholder="请输入外系统部件编码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部件模型" prop="compoModel">
|
|
|
+ <el-input v-model="componentForm.compoModel" placeholder="请输入部件模型" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部件品牌" prop="compoBrand">
|
|
|
+ <el-input v-model="componentForm.compoBrand" placeholder="请输入部件品牌" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部件型号" prop="compoSpec">
|
|
|
+ <el-input v-model="componentForm.compoSpec" placeholder="请输入部件型号" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="祖籍列表" prop="ancestors">
|
|
|
+ <el-input v-model="componentForm.ancestors" placeholder="请输入祖籍列表" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="上级列表" prop="parentCompo">
|
|
|
+ <el-input v-model="componentForm.parentCompo" placeholder="请输入上级列表" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitComponentForm">确 定</el-button>
|
|
|
+ <el-button @click="ComponentCancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
<!-- 详情弹框 -->
|
|
|
<el-dialog :visible.sync="showDrawer" title="设备详情">
|
|
|
<div v-if="curRow">
|
|
@@ -148,7 +306,6 @@
|
|
|
<p>归属区域:{{ curRow.areaPath}}</p>
|
|
|
<p>归属设施:{{curRow.refFacsName}}</p>
|
|
|
</div>
|
|
|
-
|
|
|
</el-card>
|
|
|
|
|
|
<!-- 属性信息 -->
|
|
@@ -158,14 +315,12 @@
|
|
|
</div>
|
|
|
<div v-for="(item, index) in attrData" :key="index">
|
|
|
<p>属性名称:{{ item.attrName }}</p>
|
|
|
- <p>属性标识:{{ item.attrKey }}</p>
|
|
|
<p>属性值:{{ item.attrValue }}</p>
|
|
|
<p>属性单位:{{ item.attrUnit }}</p>
|
|
|
<!-- 在每个条目之后添加横线,除了最后一个条目 -->
|
|
|
<div v-if="index < attrData.length - 1" class="divider"></div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
-
|
|
|
<!-- 能力信息 -->
|
|
|
<el-card class="box-card" v-if="abilityData.length > 0">
|
|
|
<div slot="header" class="clearfix">
|
|
@@ -180,7 +335,6 @@
|
|
|
<div v-if="index < abilityData.length - 1" class="divider"></div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
-
|
|
|
<!-- 事件信息 -->
|
|
|
<el-card class="box-card" v-if="eventData.length > 0">
|
|
|
<div slot="header" class="clearfix">
|
|
@@ -205,19 +359,32 @@
|
|
|
<script>
|
|
|
import { listDevRecursionByArea, getDevice, delDevice, addDevice, updateDevice} from '@/api/device/device'
|
|
|
import { areaTreeSelect } from "@/api/basecfg/area"
|
|
|
-import { getFacsCategorygetByCode, listAllFacs } from '@/api/basecfg/emsfacs'
|
|
|
+import {addFacs, getFacsCategorygetByCode, listAllFacs, updateFacs} from '@/api/basecfg/emsfacs'
|
|
|
import { listSubsystemAll } from '@/api/adapter/subsystem'
|
|
|
-import { getModelByCode } from "@/api/basecfg/objModel";
|
|
|
+import {getModel, getModelByCode, listAllModel} from "@/api/basecfg/objModel";
|
|
|
import Treeselect from "@riophae/vue-treeselect";
|
|
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
|
-
|
|
|
+import {delAttr, getAttr, getObjAttr} from "@/api/basecfg/objAttribute";
|
|
|
+import {addAttrValueBatch} from "@/api/basecfg/objAttributeValue";
|
|
|
+import {getDevProcess} from "@/api/commonApi";
|
|
|
+import {addComponent, getComponent, listByDevice, listComponent, updateComponent} from "@/api/basecfg/component";
|
|
|
|
|
|
export default {
|
|
|
name: 'Device',
|
|
|
components: {Treeselect},
|
|
|
data () {
|
|
|
return {
|
|
|
+ ComponentRow:[],
|
|
|
+ componentForm:{},
|
|
|
+ subcategoryCode:'',
|
|
|
+ attrList: [], // 属性模板数组
|
|
|
+ attrValues: [],
|
|
|
+ ComponentList:[],
|
|
|
+ attrValuesMap: {},
|
|
|
+ modelList: [],
|
|
|
showDrawer: false,
|
|
|
+ showDevProcessDrawer:false,
|
|
|
+ componentOpen:false,
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
|
// 选中数组
|
|
@@ -246,6 +413,8 @@ export default {
|
|
|
// 设备分类
|
|
|
subCategoryOptions: undefined,
|
|
|
subsystemOptions: undefined,
|
|
|
+ devOptions: undefined,
|
|
|
+
|
|
|
defaultProps: {
|
|
|
children: "children",
|
|
|
label: "label"
|
|
@@ -259,14 +428,22 @@ export default {
|
|
|
deviceCategory: 'E',
|
|
|
areaType: null,
|
|
|
refArea: null,
|
|
|
- refFacs: null
|
|
|
+ refFacs: null,
|
|
|
+ customAttrs: null,
|
|
|
+ },
|
|
|
+ queryComponentParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
},
|
|
|
curRow: {},
|
|
|
attrData: [],
|
|
|
abilityData: [],
|
|
|
eventData: [],
|
|
|
+
|
|
|
// 表单参数
|
|
|
- form: {},
|
|
|
+ form: {
|
|
|
+ customAttrs: [] // 自定义属性数组
|
|
|
+ },
|
|
|
// 表单校验
|
|
|
rules: {
|
|
|
refFacs: [
|
|
@@ -282,6 +459,17 @@ export default {
|
|
|
{required: true, message: '设备名称不能为空', trigger: 'blur'}
|
|
|
]
|
|
|
},
|
|
|
+ componentRules: {
|
|
|
+ deviceCode: [
|
|
|
+ {required: true, message: "设备code不能为空", trigger: "blur"}
|
|
|
+ ],
|
|
|
+ // attrKey: [
|
|
|
+ // {required: true, message: "属性标识不能为空", trigger: "blur"}
|
|
|
+ // ],
|
|
|
+ // attrName: [
|
|
|
+ // {required: true, message: "属性名称不能为空", trigger: "blur"}
|
|
|
+ // ],
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -296,17 +484,77 @@ export default {
|
|
|
this.getFacsOptions();
|
|
|
this.getSubsystem();
|
|
|
this.getSubCategorygetByCode();
|
|
|
+ this.getFacsModel();
|
|
|
+ this.getAllDevProcess(this.subcategoryCode);
|
|
|
},
|
|
|
methods: {
|
|
|
/** 查询能源设备列表 */
|
|
|
getList () {
|
|
|
this.loading = true
|
|
|
listDevRecursionByArea(this.queryParams).then(response => {
|
|
|
+ console.log("参数",JSON.stringify(this.queryParams))
|
|
|
this.deviceList = response.rows
|
|
|
+ console.log("deviceList",this.deviceList)
|
|
|
this.total = response.total
|
|
|
this.loading = false
|
|
|
})
|
|
|
},
|
|
|
+ /**新增、修改、删除*/
|
|
|
+ handleComponentAdd(){
|
|
|
+ this.componentReset();
|
|
|
+ this.componentOpen = true;
|
|
|
+ this.title = "添加设备器件属性";
|
|
|
+
|
|
|
+ },
|
|
|
+ handleComponentUpdate(row) {
|
|
|
+ this.componentReset();
|
|
|
+ const id = row.id || this.ids
|
|
|
+ updateComponent(id).then(response => {
|
|
|
+ this.componentForm = response.data;
|
|
|
+ this.componentOpen = true;
|
|
|
+ this.title = "修改设备器件属性";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleComponentDelete(row) {
|
|
|
+ const ids = row.id || this.ids;
|
|
|
+ this.$modal.confirm('是否确认删除能源对象属性编号为"' + ids + '"的数据项?').then(function() {
|
|
|
+ return delAttr(ids);
|
|
|
+ }).then(() => {
|
|
|
+ console.log("删除row",row.deviceCode);
|
|
|
+ this.getComponentList(row.deviceCode);
|
|
|
+ this.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ submitComponentForm() {
|
|
|
+ this.$refs["componentForm"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.componentForm.id != null) {
|
|
|
+ updateComponent(this.componentForm).then(response => {
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
+ this.componentOpen =false;
|
|
|
+ this.getComponentList(this.componentForm.deviceCode);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addComponent(this.componentForm).then(response => {
|
|
|
+ this.$modal.msgSuccess("新增成功");
|
|
|
+ this.componentOpen = false;
|
|
|
+ this.getComponentList(this.componentForm.deviceCode);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ComponentCancel() {
|
|
|
+ this.componentOpen = false;
|
|
|
+ this.componentReset();
|
|
|
+ },
|
|
|
+ /**查询部件列表*/
|
|
|
+ getComponentList(){
|
|
|
+ listComponent(this.queryParams).then(response=>{
|
|
|
+ this.ComponentList=response.data
|
|
|
+ console.log("查询部件列表",this.ComponentList)
|
|
|
+ })
|
|
|
+ },
|
|
|
/** 查询区域树结构 */
|
|
|
getAreaTree (tier) {
|
|
|
areaTreeSelect(tier).then(response => {
|
|
@@ -337,17 +585,39 @@ export default {
|
|
|
deviceName: null,
|
|
|
deviceType: null,
|
|
|
deviceStatus: null,
|
|
|
+ deviceModel:null,
|
|
|
refArea: null,
|
|
|
refFacs: null,
|
|
|
subsystemCode: null,
|
|
|
+ psCode:null,
|
|
|
+ // psName:null,
|
|
|
createTime: null,
|
|
|
- updateTime: null
|
|
|
+ updateTime: null,
|
|
|
+
|
|
|
}
|
|
|
this.resetForm('form')
|
|
|
},
|
|
|
+ componentReset() {
|
|
|
+ this.componentForm = {
|
|
|
+ id: null,
|
|
|
+ deviceCode: null,
|
|
|
+ compoCode: null,
|
|
|
+ compoTag:null,
|
|
|
+ psCode: null,
|
|
|
+ extCompoCode: null,
|
|
|
+ compoModel: null,
|
|
|
+ compoBrand: null,
|
|
|
+ compoSpec: null,
|
|
|
+ ancestors: null,
|
|
|
+ parentCompo: null
|
|
|
+
|
|
|
+ };
|
|
|
+ this.resetForm("componentForm");
|
|
|
+ },
|
|
|
/** 搜索按钮操作 */
|
|
|
handleQuery () {
|
|
|
this.queryParams.pageNum = 1
|
|
|
+ console.log("搜索按钮this.queryParams", JSON.stringify(this.queryParams))
|
|
|
this.getList()
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
@@ -369,6 +639,26 @@ export default {
|
|
|
this.open = true
|
|
|
this.title = '添加能源设备'
|
|
|
},
|
|
|
+ /**设备器件按钮*/
|
|
|
+ handleDevProcess(row){
|
|
|
+ this.showDevProcessDrawer = true
|
|
|
+ this.ComponentRow = row
|
|
|
+ console.log("row",row)
|
|
|
+ listByDevice(this.ComponentRow.deviceCode).then(response => {
|
|
|
+ const data=response.data;
|
|
|
+ console.log("data",data);
|
|
|
+ this.ComponentList=data
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ shouldShowDevProcessButton(row) {
|
|
|
+ const categoryIsW = this.queryParams.deviceCategory === 'W';
|
|
|
+ const validPsCodes = ['AA', 'AH', 'AJ', 'AM', 'AP', 'AL', 'APE', 'ALE', 'AF', 'ACC'];
|
|
|
+ const psCodeIsValid = validPsCodes.includes(row.psCode);
|
|
|
+ // 只有当设备分类为输能设备且设备工艺代码有效时,才返回true
|
|
|
+ return categoryIsW && psCodeIsValid ;
|
|
|
+ },
|
|
|
/**设备详情按钮*/
|
|
|
handleDetail(row) {
|
|
|
this.showDrawer = true
|
|
@@ -378,11 +668,26 @@ export default {
|
|
|
getModelByCode(this.curRow.facsModel).then(response => {
|
|
|
const code=response.data
|
|
|
console.log("code",code)
|
|
|
- this.attrData=response.data.attrList
|
|
|
this.eventData=response.data.eventList
|
|
|
this.abilityData=response.data.abilityList
|
|
|
|
|
|
})
|
|
|
+ getObjAttr(2, this.curRow.deviceCode).then(response => {
|
|
|
+ console.log("response值", response.data);
|
|
|
+ const attrs = response.data.attrs;
|
|
|
+ const attrValues = response.data.attrValues;
|
|
|
+
|
|
|
+ // 合并 attrs 和 attrValues 数组
|
|
|
+ const mergedData = attrValues.map(attrValue => {
|
|
|
+ const attr = attrs.find(a => a.attrKey === attrValue.attrKey);
|
|
|
+ return {
|
|
|
+ ...attrValue,
|
|
|
+ attrName: attr ? attr.attrName : attrValue.attrName,
|
|
|
+ attrUnit: attr ? attr.attrUnit : ''
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this.attrData = mergedData;
|
|
|
+ });
|
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate (row) {
|
|
@@ -399,7 +704,74 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
- submitForm () {
|
|
|
+ // submitForm () {
|
|
|
+ // this.$refs['form'].validate(valid => {
|
|
|
+ // if (valid) {
|
|
|
+ // if (this.form.id != null) {
|
|
|
+ // updateDevice(this.form).then(response => {
|
|
|
+ // this.$modal.msgSuccess('修改成功')
|
|
|
+ // this.open = false
|
|
|
+ // this.getList()
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // addDevice(this.form).then(response => {
|
|
|
+ // this.$modal.msgSuccess('新增成功')
|
|
|
+ // this.open = false
|
|
|
+ // this.getList()
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ submitForm() {
|
|
|
+ // 重置 attrList 和 form.customAttrs
|
|
|
+ if (!this.attrList) {
|
|
|
+ this.attrList = [];
|
|
|
+ }
|
|
|
+ if (!this.form.customAttrs) {
|
|
|
+ this.form.customAttrs = [];
|
|
|
+ }
|
|
|
+ // 准备要发送的数据
|
|
|
+ let dataToSubmit = [];
|
|
|
+ // 添加模型属性数据
|
|
|
+ this.attrList.forEach(attr => {
|
|
|
+ const attrName=attr.attrName;
|
|
|
+ const attrKey = attr.attrKey;
|
|
|
+ const attrValue = this.attrValuesMap[attrKey];
|
|
|
+ const existingIndex = dataToSubmit.findIndex(item => item.attrKey === attrKey);
|
|
|
+ if (existingIndex === -1) {
|
|
|
+ // 如果attrKey不存在于dataToSubmit中,则添加
|
|
|
+ dataToSubmit.push({
|
|
|
+ modelCode: this.form.deviceModel, // 这里填写模型代码
|
|
|
+ objCode: this.form.deviceCode, // 这里填写设备代码
|
|
|
+ objType: 2, // 这里填写对象类型
|
|
|
+ attrKey: attrKey,
|
|
|
+ attrValue: attrValue,
|
|
|
+ attrName: attrName
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 添加自定义属性数据
|
|
|
+ this.form.customAttrs.forEach(customAttr => {
|
|
|
+ const attrName= customAttr.attrName;
|
|
|
+ const attrKey = customAttr.attrKey;
|
|
|
+ const attrValue = customAttr.attrValue;
|
|
|
+ const existingIndex = dataToSubmit.findIndex(item => item.attrKey === attrKey);
|
|
|
+ if (existingIndex === -1) {
|
|
|
+ // 如果attrKey不存在于dataToSubmit中,则添加
|
|
|
+ dataToSubmit.push({
|
|
|
+ modelCode: '', // 这里填写模型代码
|
|
|
+ objCode: this.form.deviceCode, // 这里填写设备代码
|
|
|
+ objType: 2, // 这里填写对象类型
|
|
|
+ attrKey: attrKey,
|
|
|
+ attrValue: attrValue,
|
|
|
+ attrName:attrName
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
this.$refs['form'].validate(valid => {
|
|
|
if (valid) {
|
|
|
if (this.form.id != null) {
|
|
@@ -407,13 +779,51 @@ export default {
|
|
|
this.$modal.msgSuccess('修改成功')
|
|
|
this.open = false
|
|
|
this.getList()
|
|
|
- })
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('修改失败:', error);
|
|
|
+ this.$message.error('修改失败');
|
|
|
+ });
|
|
|
+
|
|
|
+ if (dataToSubmit.length > 0) {
|
|
|
+ addAttrValueBatch(dataToSubmit)
|
|
|
+ .then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('属性添加成功');
|
|
|
+ } else {
|
|
|
+ this.$message.error('属性添加失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('属性添加失败:', error);
|
|
|
+ this.$message.error('属性添加失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // this.$message.info('没有属性需要添加');
|
|
|
+ }
|
|
|
} else {
|
|
|
addDevice(this.form).then(response => {
|
|
|
this.$modal.msgSuccess('新增成功')
|
|
|
this.open = false
|
|
|
this.getList()
|
|
|
- })
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('新增失败:', error);
|
|
|
+ this.$message.error('新增失败');
|
|
|
+ });
|
|
|
+
|
|
|
+ if (dataToSubmit.length > 0) {
|
|
|
+ addAttrValueBatch(dataToSubmit)
|
|
|
+ .then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('属性添加成功');
|
|
|
+ } else {
|
|
|
+ this.$message.error('属性添加失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('属性添加失败:', error);
|
|
|
+ this.$message.error('属性添加失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // this.$message.info('没有属性需要添加');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -457,8 +867,15 @@ export default {
|
|
|
this.subsystemOptions = response.data;
|
|
|
})
|
|
|
},
|
|
|
+ getAllDevProcess(subcategoryCode){
|
|
|
+ getDevProcess(subcategoryCode).then(response => {
|
|
|
+ this.devOptions = response.data
|
|
|
+ console.log("设备工艺",this.devOptions)
|
|
|
+ })
|
|
|
+ },
|
|
|
deviceCategoryChange () {
|
|
|
this.queryParams.deviceSubCategory = ''
|
|
|
+ //this.queryParams.psCode = null; // 重置设备工艺选择
|
|
|
if (this.queryParams.deviceCategory === 'E' || this.queryParams.deviceCategory === 'W'
|
|
|
|| this.queryParams.deviceCategory === 'T'|| this.queryParams.deviceCategory === 'C') {
|
|
|
this.getAreaTree("Building")
|
|
@@ -468,7 +885,89 @@ export default {
|
|
|
this.getSubCategorygetByCode()
|
|
|
this.getFacsOptions()
|
|
|
this.handleQuery()
|
|
|
- }
|
|
|
+ },
|
|
|
+ /**自定义属性表格*/
|
|
|
+ addCustomAttr() {
|
|
|
+ // 添加一个新的自定义属性
|
|
|
+ if (!Array.isArray(this.form.customAttrs)) {
|
|
|
+ this.form.customAttrs = [];
|
|
|
+ }
|
|
|
+ this.form.customAttrs.push({
|
|
|
+ attrKey: '',
|
|
|
+ attrName: '',
|
|
|
+ attrValue: ''
|
|
|
+ });
|
|
|
+ // 强制更新视图
|
|
|
+ this.$forceUpdate();
|
|
|
+
|
|
|
+ },
|
|
|
+ deleteCustomAttr(index) {
|
|
|
+ // 删除指定索引的自定义属性
|
|
|
+ if (this.form.customAttrs.length > 0) {
|
|
|
+ this.form.customAttrs.splice(index, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ /**设备模型*/
|
|
|
+ updateAttrValue(attrKey, newValue) {
|
|
|
+ this.attrValuesMap[attrKey] = newValue;
|
|
|
+ },
|
|
|
+
|
|
|
+ getFacsModel() {
|
|
|
+ listAllModel(2).then(response => {
|
|
|
+ this.modelList = response.data;
|
|
|
+ console.log("this.modelList",this.modelList)
|
|
|
+ this.modelList.forEach(model => {
|
|
|
+ console.log(model.modelCode);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleModelChange(modelCode) {
|
|
|
+ if (modelCode) {
|
|
|
+ this.getModelByCode(modelCode);
|
|
|
+ console.log("设备代码",this.form.deviceCode)
|
|
|
+ this.getObjAttr(2, this.form.deviceCode);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getModelByCode(modelCode) {
|
|
|
+ getModelByCode(modelCode).then(response => {
|
|
|
+ // this.attrList = response.data.attrList;
|
|
|
+ const filteredAttrList = response.data.attrList.filter(attr => attr.attrType === 0);
|
|
|
+ this.attrList = filteredAttrList;
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getObjAttr(objType, deviceCode) {
|
|
|
+ getObjAttr(objType, deviceCode).then(response => {
|
|
|
+ // const attrs = response.data.attrs;
|
|
|
+ const attrs = response.data.attrs.filter(attr => attr.attrType === 0);
|
|
|
+ console.log("attrs", attrs);
|
|
|
+ const attrValues = response.data.attrValues || []; // 确保是一个数组
|
|
|
+ console.log("attrValues", attrValues);
|
|
|
+
|
|
|
+ // 创建一个映射对象,用于存储 attrKey 与对应的 attrValue
|
|
|
+ const attrValuesMap = {};
|
|
|
+
|
|
|
+ // 遍历 attrs 数组
|
|
|
+ attrs.forEach(attr => {
|
|
|
+ // 查找 attrValues 数组中是否有匹配的 attrKey
|
|
|
+ const attrValueObj = attrValues.find(value => value.attrKey === attr.attrKey);
|
|
|
+ // 如果找到匹配的 attrValue,更新 attrValuesMap
|
|
|
+ if (attrValueObj) {
|
|
|
+ attrValuesMap[attr.attrKey] = attrValueObj.attrValue;
|
|
|
+ } else {
|
|
|
+ // 如果没有找到匹配的 attrValue,则设置为 '暂无数据'
|
|
|
+ attrValuesMap[attr.attrKey] = '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 更新 attrValuesMap 到组件的数据中
|
|
|
+ this.attrValuesMap = attrValuesMap;
|
|
|
+ // 打印更新后的 attrValuesMap,用于调试
|
|
|
+ console.log("Updated attrValuesMap", this.attrValuesMap);
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -484,5 +983,38 @@ export default {
|
|
|
margin-top: 20px; /* 标题顶部间距 */
|
|
|
margin-bottom: 10px; /* 标题底部间距 */
|
|
|
}
|
|
|
+.drawer-content {
|
|
|
+ padding: 0 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.divider {
|
|
|
+ border-bottom: 2px solid #ebeef5; /* 这是Element UI的默认边框颜色,你可以根据需要调整 */
|
|
|
+ margin: 10px 0; /* 这是横线与内容的间距,你可以根据需要调整 */
|
|
|
+}
|
|
|
+
|
|
|
+.section-title {
|
|
|
+ font-size: 18px; /* 标题字体大小 */
|
|
|
+ font-weight: bold; /* 字体加粗 */
|
|
|
+}
|
|
|
+
|
|
|
+.attr-list-container {
|
|
|
+ border: 1px solid #ccc; /* 给ul添加外框 */
|
|
|
+ padding: 10px; /* 内边距 */
|
|
|
+ margin: 10px 0; /* 外边距 */
|
|
|
+ font-weight: bold; /* 加粗标题 */
|
|
|
+}
|
|
|
+
|
|
|
+.attr-list-container h3 {
|
|
|
+ font-weight: bold; /* 加粗标题 */
|
|
|
+}
|
|
|
+
|
|
|
+.attr-item {
|
|
|
+ list-style-type: none; /* 移除列表项前的默认符号 */
|
|
|
+ margin-bottom: 5px; /* 列表项之间的间距 */
|
|
|
+}
|
|
|
+
|
|
|
+.attr-name {
|
|
|
+ font-weight: bold; /* 加粗属性名称 */
|
|
|
+}
|
|
|
|
|
|
</style>
|