1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489 |
- <template>
- <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;" v-loading="loading">
- <div class="hanson-bar">
- <div style="float:right;overflow:hidden;">
- <span>当前筛选条件下共{{ page.total || "--" }}设备</span>
- </div>
- <el-select v-model="onlyRead" @change="getHeaderData(mess)"
- style="width:100px;margin-right:20px;vertical-align:bottom;">
- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- <el-select v-model="showType" @change="initTable" style="width:100px;margin-right:10px;vertical-align:bottom;">
- <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
- </el-select>
- <!-- <el-button size="small" style='width: 80px;' @click="download" icon="iconfont icon-xiazai">下载</el-button> -->
- <el-button size="small" style="width: 80px;" @click="addDevice">添加设备
- </el-button>
- <el-button size="small" @click="Batch" v-show="!onlyRead" :disabled="!(tableData && tableData.length)">批量维护信息点
- </el-button>
- <el-button size='small' @click='handleBatchEquipPoint' v-show='true'>批量维护设备位置</el-button>
- <el-button size="small" style="width: 80px;" @click="reset">刷新
- </el-button>
- <el-button size="small" style="width: 80px;" v-show="!onlyRead" @click="undo">撤销
- </el-button>
- </div>
- <!-- 二维码弹窗 -->
- <qrcode :dialog="myDialog" :qrcodeUrl="qrcodeUrl" :addBody="true" ref="qrcode"></qrcode>
- <!-- bim坐标弹框 -->
- <bimDialog :dialog="myDialog" :bimcodeobj="bimcodeobj" @closeBIM="closeBIM" :addBody="true"
- ref="bimdialog" :read="onlyRead ? true : false"></bimDialog>
- <!-- 上传文件-->
- <upload-files-dialog :read="onlyRead ? true : false" ref="upload" @changeFile="fileChange" :keysArr="filesArr"
- :firmDataType="firmDataType"
- :information="information" :infoType="infoType" :dialog="myDialog"/>
- <!-- 上传图片-->
- <upload-img-dialog :read="onlyRead ? true : false" @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"
- :firmDataType="firmDataType"
- :information="information" :infoType="infoType"/>
- <pic-dialog :read="onlyRead ? true : false" :dialog="myDialog" :keysArr="picsArr" @change="changePics"
- :firmDataType="firmDataType"
- :information="information" :infoType="infoType"/>
- <div class="middle_sty" style="height: 91%; text-align:center"
- v-show="!mess.deviceId && (!tableData || !tableData.length)">
- <p>
- <i class="icon-wushuju iconfont"></i>
- 请选择设备族
- </p>
- </div>
- <div class="center middle_sty" style="height: 91%;" v-show="mess.deviceId && (!tableData || !tableData.length)">
- <p>
- <i class="icon-wushuju iconfont"></i>
- 暂无数据
- </p>
- </div>
- <div v-show="mess.deviceId && tableData && tableData.length" id="handsontable" ref="handsontable"></div>
- <div v-show="mess.deviceId && tableData && tableData.length" class="right">
- <my-pagination @change="getTableData" :page="page" :key="pageKey"></my-pagination>
- </div>
- <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
- <!-- 关联的系统 -->
- <system-type :device="mess" :curDevice="curDevice" :dialog="myDialog" :type="onlyRead ? 'read' : 'edit'"
- @change="changeSystemType"
- :list="systemList"></system-type>
- <!-- 关联资产 -->
- <change-rea @changeProperty="changeProperty" :dialog="myDialog" :category="deviceType"></change-rea>
- <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
- <!-- 不支持的输入方式 -->
- <el-dialog title="临时维护信息点" :visible.sync="myDialog.update" @close="handleCloseUpdate" width="670px">
- <el-row>
- 该信息点未定义对应组件,现在维护数据不确定后续是否可用。如确实需要维护,请点击
- <el-link @click="updateInputShow = true" type="primary" :underline="false">继续维护
- </el-link>
- 。
- </el-row>
- <el-row style="margin-top:20px;" v-show="updateInputShow">
- <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 8 }" placeholder="请输入内容"
- v-model="updateInput"></el-input>
- </el-row>
- <span slot="footer" class="dialog-footer">
- <el-button @click="myDialog.update = false">取 消</el-button>
- <el-button type="primary" @click="handleClickUpdate">确 认</el-button>
- </span>
- </el-dialog>
- <!-- 新增设备 -->
- <el-dialog title="确定新增设备的类型" :visible.sync="myDialog.addDevice" width="670px">
- <el-row>
- <my-cascader ref="cascader" @change="changeAddType" :all="true"></my-cascader>
- </el-row>
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" @click="toAddDevice">下 一 步</el-button>
- </span>
- </el-dialog>
- <!-- 维护信息弹窗-->
- <batchDialog ref="batchDialogs" @code="fourVendors" :firmName="firmName" :allObject="allObject" :page="batchPage"
- :information="information"
- :newEnclosure="newEnclosure" @getAllData="getAllData" @multiples="multiples"
- @upDataDevice="upDataDevice"/>
- </div>
- </template>
- <script>
- import {BeatchQueryParam, deleteEquip, getEquipBelongs, queryUpdate, updateEquip} from "@/api/scan/request";
- import {getEquipTableCon, queryEquip} from "@/api/object/equip";
- import {getDataDictionary} from "@/api/dict";
- import tools from "@/utils/scan/tools";
- import handsonUtils from "@/utils/hasontableUtils";
- import showTools from "@/utils/handsontable/notShow";
- import text from "@/utils/handsontable/mainText";
- import myCascader from "@/components/ledger/lib/cascader";
- import buildFloor from "@/utils/handsontable/buildFloorData";
- import qrcode from "@/components/ledger/lib/qrcode";
- import bimDialog from "@/components/ledger/lib/bimDialog";
- import uploadFilesDialog from "@/components/dialogs/list/filesDialog";
- import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog";
- import picDialog from "@/components/dialogs/list/picDialog";
- import batchDialog from "../../dialogs/list/batchDialog";
- import systemType from "@/components/dialogs/list/systemType";
- import myPagination from "@/components/ledger/lib/myPagination";
- import detailsDialog from "@/components/ledger/lib/detailsDia";
- import changeRea from "@/components/dialogs/changeRea";
- import {mapGetters} from "vuex";
- //图片查看
- import lookPic from "@/components/ledger/lib/lookImages";
- import Handsontable from "handsontable-pro";
- import "handsontable-pro/dist/handsontable.full.css";
- import lStorage from "@/utils/localStorage";
- import dataTypeMap from "@/utils/handsontable/dataTypeMap"
- //下拉插件
- // import "@/assets/js/chosen.jquery.min";
- // import "@/assets/js/handsontable-chosen-editor";
- export default {
- props: ["myParam"],
- components: {
- qrcode, //二维码页面
- uploadFilesDialog,
- uploadImgDialog,
- picDialog,
- myPagination,
- systemType,
- detailsDialog,
- changeRea,
- lookPic,
- myCascader,
- batchDialog,
- bimDialog
- },
- created() {
- buildFloor.getData(this.buildFloorData);
- },
- computed: {
- ...mapGetters("layout", ["projectId", "secret", "userId", "group_code"]),
- showTypes() {
- return this.onlyRead
- ? [
- {value: "Visible", label: "只看采集信息"},
- {value: "all", label: "全部"}
- ]
- : [
- {value: "all", label: "全部"},
- {value: "Visible", label: "只看采集信息"}
- ];
- },
- // batchDate() {
- // // return !(!this.onlyRead && this.copyMain)
- // return !(!this.onlyRead && this.page.total > 1)
- // },
- batchDialogShow() {
- return this.$refs.batchDialogs.batchDialog;
- }
- },
- data() {
- return {
- options: [
- {
- value: true,
- label: "只读模式"
- },
- {
- value: false,
- label: "编辑模式"
- }
- ],
- buildFloorData: [], //楼层数据
- tableData: [],
- mess: {},
- tableHeader: null,
- page: {
- size: 50,
- sizes: [10, 30, 50, 100, 150, 200],
- total: 0,
- currentPage: 1
- },
- pageKey: new Date().getTime(),
- batchPage: {
- size: 100,
- sizes: [100, 200, 500, 1000],
- total: 0,
- currentPage: 1
- },
- myDialog: {
- qrcode: false, //二维码弹窗
- bimcode: false, //bim弹窗
- uploadFiles: false, //上传文件
- uploadImgs: false, //上传单个图片
- pic: false, //多个图片
- addDevice: false, //添加设备
- systemType: false, //关联系统
- details: false, //详情页
- changeRea: false, //关联资产
- lookPic: false, //图片查看
- update: false //临时维护信息点
- },
- row: null, //被修改的row
- filesArr: [], //保存临时的文件key
- messKey: null,
- imgsArr: [], //临时保存的图片key数组
- picsArr: [], //临时设备图片keys数组
- systemList: [], //关联的系统
- copyMain: null,
- iframeSrc: "",
- id: 0,
- onlyRead: true,
- showType: "Visible",
- linkNameFalg: true,
- qrcodeUrl: "", //二维码图片地址
- bimcodeobj: "", //BIM对象
- loading: false,
- deviceType: {}, //族3位编码及名称
- floorData: [],
- curDevice: "", //当前点击的设备id
- addData: {}, //
- showParts: false,
- inputMap: {
- flowBuild: {
- editable: true,
- code: "flowBuild",
- name: "建筑楼层",
- path: "flowBuild",
- category: 'STATIC',
- dataType: "ENUM"
- }
- }, //信息点和输入方式映射表
- updateInputShow: false, //是否显示临时维护输入框
- updateInfoPoint: "", //临时维护信息点
- updateInput: "", //临时维护信息点值
- firmName: "", //维护信息显示厂家名称
- firmDataType: "row",
- allObject: [],
- information: {
- archive: {
- Archive: [], //设备文档
- name: "设备文档",
- code: "infos.PhotoDoc.Archive",
- num: 14
- },
- checkReport: {
- CheckReport: [], //安装质检报告
- name: "安装质检报告",
- code: "infos.Siteinstall.CheckReport",
- num: 18
- },
- drawing: {
- Drawing: [], //设备图纸
- name: "设备图纸",
- code: "infos.PhotoDoc.Drawing",
- num: 13
- },
- installDrawing: {
- InstallDrawing: [], //安装图纸
- name: "安装图纸",
- code: "infos.Siteinstall.InstallDrawing",
- num: 16
- },
- installPic: {
- InstallPic: [], //安装照片
- name: "安装照片",
- code: "infos.Siteinstall.InstallPic",
- num: 17
- },
- insuranceFile: {
- InsuranceFile: [], //保险文件
- name: "保险文件",
- code: "infos.InsuranceDoc.InsuranceFile",
- num: 11
- },
- nameplate: {
- Nameplate: [], //设备铭牌照片
- name: "设备铭牌照片",
- code: "infos.PhotoDoc.Nameplate",
- num: 12
- },
- pic: {
- Pic: [], //设备照片
- name: "设备照片",
- code: "infos.PhotoDoc.Pic",
- num: 15
- }
- },
- infoType: "",
- newEnclosure: []
- };
- },
- methods: {
- //获取表头
- getHeaderData(code) {
- let tempParams = this.$route.params;
- if (!tempParams.used && tempParams.pageSize) {
- this.page.currentPage = Number(tempParams.pageNo);
- this.page.size = Number(tempParams.pageSize);
- this.onlyRead = tempParams.readOnly;
- tempParams.used = true;
- } else {
- this.page.currentPage = 1;
- }
- this.pageKey = new Date().getTime();
- this.mess = code;
- this.changeCader();
- if (this.mess.deviceId) {
- let params = {
- type: this.mess.deviceId,
- orders: "sort asc, name desc",
- };
- getDataDictionary(params, res => {
- this.tableHeader = res.content;
- this.codeToDataSource = {}
- this.tableHeader.forEach(item => {
- if (item.path) {
- this.inputMap[item.path] = item;
- }
- if (item.dataSource) {
- try {
- this.codeToDataSource[item.code] = {}
- item.dataSource.forEach(dic => {
- this.codeToDataSource[item.code][dic.code] = dic.name;
- })
- } catch (e) {
- console.log(e);
- }
- }
- });
- this.getTableData();
- this.getAllData();
- // 信息维护
- this.newEnclosure = res.content.filter(i => i.dataType == dataTypeMap.ATTACHMENT && i.editable == true);
- });
- }
- },
- //关闭弹窗
- closeBIM(val) {
- this.myDialog.bimcode = false;
- if (val == "update") {
- this.getTableData();
- this.getAllData();
- }
- },
- //获取主体数据
- getTableData() {
- this.loading = true;
- //type存在发送请求
- if (this.mess.deviceId) {
- let param = {
- pageSize: this.page.size,
- orders: "createTime desc,id desc,localId desc,localName desc",
- pageNumber: this.page.currentPage,
- filters: `classCode='${this.mess.deviceId}'`
- };
- if (this.mess.buildId == "noKnow") {
- param.filters += `;buildingId isNull`;
- } else if (this.mess.buildId && this.mess.buildId != "all") {
- param.filters += `;buildingId='${this.mess.buildId}'`;
- }
- if (this.mess.floorId == "noKnow") {
- param.filters += `;floorId isNull`;
- } else if (this.mess.floorId && this.mess.floorId != "all") {
- param.filters += `;floorId='${this.mess.floorId}'`;
- }
- getEquipTableCon(param, res => {
- this.loading = false;
- this.showParts = res.message == "1" ? true : false; // 判断是否显示包含的部件列
- this.tableData = res.content.map(item => {
- if (
- item.hasOwnProperty("buildingId") &&
- item.hasOwnProperty("floorId")
- ) {
- item.flowBuild = item.buildingId + "-" + item.floorId;
- } else if (
- item.hasOwnProperty("buildingId") &&
- !item.hasOwnProperty("floorId")
- ) {
- item.flowBuild = item.buildingId;
- }
- return item;
- });
- this.copyMain = tools.deepCopy(this.tableData);
- this.page.total = res.total;
- if (this.tableData && this.tableData.length) {
- if (this.onlyRead) {
- this.getBatch(this.tableData);
- }
- this.initTable();
- }
- });
- }
- },
- //获取所有主体数据---用于维护信息
- getAllData() {
- if (!!this.mess.deviceId) {
- // 查询step2
- let params = {
- cascade: [
- {
- name: "property"
- },
- {
- Name: "building",
- Projection: ["localName", "name", "id"]
- },
- {
- Name: "floor",
- Projection: ["localName", "name", "id"]
- }
- ],
- filters: `classCode='${this.mess.deviceId}'`,
- pageSize: this.batchPage.size,
- orders: "createTime desc, id desc",
- pageNumber: this.batchPage.currentPage,
- projection: [
- "buildingId",
- "floorId",
- "classCode",
- "localName",
- "localID",
- "id",
- "bimId"
- ]
- };
- if (this.mess.buildId == "noKnow") {
- params.filters += `;buildingId isNull`;
- } else if (this.mess.buildId && this.mess.buildId != "all") {
- params.filters += `;buildingId='${this.mess.buildId}'`;
- }
- if (this.mess.floorId == "noKnow") {
- params.filters += `;floorId isNull`;
- } else if (this.mess.floorId && this.mess.floorId != "all") {
- params.filters += `;floorId='${this.mess.floorId}'`;
- }
- queryEquip(params, res => {
- this.allObject = res.content;
- this.batchPage.total = res.total;
- });
- }
- },
- //获取动态参数
- getBatch(data) {
- let param = {
- groupCode: this.group_code,
- appId: "datacenter",
- projectId: this.projectId,
- data: []
- };
- //一级遍历list
- this.tableHeader.map(head => {
- //如果一级标签为动态参数或者设定参数放入数据等待请求
- if (head.category != 'STATIC') {
- data.map(item => {
- let cur = tools.dataForKey(item, head.path);
- if (cur) {
- param.data.push({
- objectId: item.id,
- infoCode: head.code
- });
- }
- });
- }
- });
- if (param.data.length) {
- BeatchQueryParam(param, res => {
- if (!this.onlyRead) {
- return false;
- }
- this.tableData = data.map(item => {
- res.data.map(child => {
- if (item.id == child.objectId) {
- if (!!child.data || child.data == 0) {
- this.tableHeader.map(head => {
- if (head.code == child.infoCode) {
- let contentVal = child.data
- if (this.codeToDataSource[child.infoCode]) {
- contentVal = this.codeToDataSource[child.infoCode][child.data]
- }
- tools.setDataForKey(item, head.path, contentVal);
- }
- });
- } else {
- this.tableHeader.map(head => {
- if (head.code == child.infoCode) {
- tools.setDataForKey(
- item,
- head.path,
- child.error
- ? child.value
- ? "表号功能号格式错误"
- : "表号功能号不存在"
- : "暂未采集到实时数据"
- );
- }
- });
- }
- }
- });
- return item;
- });
- this.hot.loadData(this.tableData);
- });
- }
- },
- //修改资产
- changeAssetsFalg() {
- if (this.linkNameFalg) {
- this.linkNameFalg = false;
- } else {
- this.$confirm(
- "<p>真的要在这里修改设备关联的资产么?</p><p>真的能通过列表信息找到想关联的资产么?</p><p>在这里修改关联的资产一定是因为之前关联错了要修改么?</p>",
- "提示",
- {
- dangerouslyUseHTMLString: true,
- confirmButtonText: "没错!我要改关联的资产",
- cancelButtonText: "我就点开看看",
- confirmButtonClass: "cancelButtonClass",
- cancelButtonClass: "cancelButtonClass"
- }
- )
- .then(_ => {
- this.linkNameFalg = true;
- })
- .catch(_ => {
- this.$message("取消");
- });
- }
- },
- //撤回
- undo() {
- this.hot.undo();
- },
- //刷新-switch改变
- reset() {
- this.getTableData();
- },
- //添加设备
- addDevice() {
- this.myDialog.addDevice = true;
- if (this.mess.deviceId) {
- this.$nextTick(() => {
- this.$refs.cascader.setValue(this.mess.deviceId);
- });
- }
- },
- //下一步
- toAddDevice() {
- if (this.addData.deviceId) {
- this.$router.push({
- path: "/ledger/deviceadd",
- query: this.addData
- });
- }
- },
- //选择设备类型-添加设备
- changeAddType(val) {
- this.addData.deviceId = val.code;
- this.addData.name = val.facility;
- this.addData.showType = this.showType;
- },
- //下载
- download() {
- if (!this.onlyRead) {
- if (!!this.hot) {
- let fileName =
- this.mess.name +
- "-页数:" +
- this.page.currentPage +
- "-个数:" +
- this.tableData.length +
- "-总个数:" +
- this.page.total;
- this.hot.getPlugin("exportFile").downloadFile("csv", {
- filename: fileName,
- columnHeaders: true,
- exportHiddenRows: true,
- exportHiddenColumns: true,
- rowHeaders: true
- });
- } else {
- this.$message("请确定存在表格");
- }
- } else {
- this.$message("下载需在编辑状态下");
- }
- },
- //格式化表头
- formatHeaderData(list) {
- let arr = tools.copyArr(list);
- let data = showTools.headerTextFilter(
- arr,
- "equipment",
- this.onlyRead,
- this.showType,
- true
- );
- if (this.showParts) {
- data.unshift("操作", "当前关联的资产", "所属系统实例", "包含的部件");
- } else {
- data.unshift("操作", "当前关联的资产", "所属系统实例");
- }
- if (this.showType == "all" && this.showParts) {
- data.splice(6, 0, "所属建筑楼层");
- } else if (this.showType == "all" && !this.showParts) {
- data.splice(5, 0, "所属建筑楼层");
- }
- return data;
- },
- //格式化表内容
- formatHeaderType(list) {
- let arr = tools.copyArr(list);
- let data = showTools.headerTypeFilter(
- arr,
- "equipment",
- this.onlyRead,
- this.showType,
- true
- );
- if (this.showParts) {
- data.unshift(
- {
- data: "caozuo",
- renderer: tools.lookDetails,
- readOnly: true
- },
- {
- data: "linkEquipLocalName",
- readOnly: true,
- renderer: tools.LinkEquipLocalName
- },
- {
- data: "linkSystem",
- renderer: text.systemList,
- readOnly: true
- },
- {
- data: "count",
- readOnly: true,
- renderer: tools.lookDetails
- }
- );
- } else {
- data.unshift(
- {
- data: "caozuo",
- renderer: tools.lookDetails,
- readOnly: true
- },
- {
- data: "linkEquipLocalName",
- readOnly: true,
- renderer: tools.LinkEquipLocalName
- },
- {
- data: "linkSystem",
- renderer: text.systemList,
- readOnly: true
- }
- );
- }
- if (this.showType == "all" && this.showParts) {
- data.splice(6, 0, {
- data: "flowBuild",
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- data: this.buildFloorData
- },
- readOnly: this.onlyRead
- });
- } else if (this.showType == "all" && !this.showParts) {
- data.splice(5, 0, {
- data: "flowBuild",
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- data: this.buildFloorData
- },
- readOnly: this.onlyRead
- });
- }
- return data;
- },
- //初始化插件
- initTable() {
- var container = document.getElementById("handsontable");
- let winHeight = document.documentElement.clientHeight;
- if (this.hot) {
- this.hot.destroy();
- this.hot = null;
- }
- this.hot = new Handsontable(container, {
- data: this.tableData,
- fixedColumnsLeft: this.showParts ? 6 : 5,
- colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
- columns: this.formatHeaderType(this.tableHeader), //数据显示格式
- filters: true,
- maxRows: this.tableData.length,
- height: winHeight - 335,
- columnSorting: true, //添加排序
- sortIndicator: true, //添加排序
- renderAllRows: true,
- // colWidths: 200,
- autoColumnSize: true,
- language: "zh-CN",
- manualColumnResize: true,
- manualColumnMove: true,
- dropdownMenu: [
- "filter_by_condition",
- "filter_by_value",
- "filter_action_bar"
- ],
- contextMenu: this.onlyRead
- ? false
- : {
- items: {
- remove_row: {
- name: "删除选中设备"
- }
- }
- },
- // 事件
- afterChange: this.handleUpdataTable, //修改后
- afterFilter: this.trimmedRows, //排序前
- afterRemoveRow: this.handleDeleteTableRow, //右键删除
- afterOnCellMouseDown: this.eventClick //鼠标点击
- });
- let pro = document.getElementById("hot-display-license-info");
- if (!!pro) {
- pro.parentNode.removeChild(pro);
- }
- this.isLoading = false;
- },
- //表格中的点击
- eventClick(el, rowArr) {
- //点击的是表头
- if (rowArr.row < 0) {
- return;
- }
- //被筛选过后的数组
- let trimmedArr = this.trimmedRows();
- //是否启用了排序
- let isSort = this.hot.getPlugin("columnSorting").isSorted();
- if (trimmedArr.length && isSort) {
- let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
- .__arrayMap;
- let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
- this.getInfors(
- infos,
- {row: sortArr[rowArr.row], col: rowArr.col},
- el
- );
- } else if (isSort) {
- //排序后的数组
- let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
- let infos = this.tableData[sortArr[rowArr.row]];
- this.getInfors(
- infos,
- {row: sortArr[rowArr.row], col: rowArr.col},
- el
- );
- } else if (trimmedArr.length) {
- let infos = this.tableData[trimmedArr[rowArr.row]];
- this.getInfors(
- infos,
- {row: trimmedArr[rowArr.row], col: rowArr.col},
- el
- );
- } else {
- let infos = this.tableData[rowArr.row];
- this.getInfors(infos, rowArr, el);
- }
- },
- // 更新
- handleUpdataTable(changeData, source) {
- if (!this.onlyRead && source != "ObserveChanges.change") {
- if (changeData) {
- let trimmedArr = this.trimmedRows();
- let param = handsonUtils.getParam(
- changeData,
- source,
- this.hot,
- trimmedArr
- );
- let data = [];
- for (let i = 0; i < param.length; i++) {
- data.push(param[i]);
- }
- //如果data中包含/且data长度为1,将其转换成.
- if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
- changeData[0][1] = changeData[0][1].split("/").join(".");
- }
- //存在data进行修改请求
- if (data && data.length) {
- this.updateBusiness(data, changeData);
- }
- }
- }
- },
- //删除设备
- handleDeleteTableRow() {
- let params = tools.differenceArr(this.tableData, this.copyMain);
- let _this = this;
- if (params.length < 1) {
- return;
- }
- let param = [];
- params.map(item => {
- this.deleteCode = item.classCode;
- param.push({id: item.id});
- });
- this.$confirm("此操作将删除设备,是否继续?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- this.removeDevice(param);
- })
- .catch(() => {
- this.reset();
- this.$message("取消删除");
- });
- },
- // 删除设备
- async removeDevice(param) {
- await deleteEquip(param, res => {
- this.$message.success("删除成功");
- this.$emit("close", {code: this.deleteCode});
- // this.getTableData()
- });
- },
- // 更新
- updateBusiness(data, change) {
- let param = {
- content: [],
- projection: []
- },
- keyList = [];
- //生成要修改字段列表
- change.map(item => {
- let key = item[1].split(".")[0];
- if (key == "flowBuild" && keyList.indexOf(key) == -1) {
- keyList.push("buildingId", "floorId");
- param.projection.push("buildingId", "floorId");
- }
- if (item[1] && keyList.indexOf(key) == -1 && item[1] != "propertyId") {
- keyList.push(key);
- }
- if (
- item[1] &&
- item[3] == "" &&
- param.projection.indexOf(key) == -1 &&
- item[1] != "propertyId"
- ) {
- param.projection.push(key);
- keyList.push(item[1])
- }
- });
- //生成对应修改数据
- data.map((item, index) => {
- keyList.map(value => {
- if (value == "buildingId") {
- let itemData = tools.dataForKey(item, "flowBuild");
- if (itemData == "") {
- tools.setDataForKey(item, "buildingId", null);
- tools.setDataForKey(item, "floorId", null);
- } else {
- let BuildingId = itemData.split("-")[0];
- let FloorId = itemData.split("-")[1];
- if (BuildingId && FloorId) {
- tools.setDataForKey(item, "buildingId", BuildingId);
- tools.setDataForKey(item, "floorId", FloorId);
- } else if (BuildingId && !FloorId) {
- tools.setDataForKey(item, "buildingId", BuildingId);
- tools.setDataForKey(item, "floorId", null);
- }
- }
- } else {
- let itemData = tools.dataForKey(item, value);
- tools.setDataForKey(item, value, itemData == "" ? null : itemData);
- }
- });
- param.content.push(item);
- });
- updateEquip(param, res => {
- });
- },
- //修改设备类型
- changeCader() {
- if (this.mess.deviceId) {
- let param = {
- data: {
- filters: `equipCode='${this.mess.deviceId}'`,
- pageNumber: 1,
- pageSize: 50
- }
- };
- getEquipBelongs(param, res => {
- if (res.content.length) {
- this.deviceType.assetType = res.content[0].family;
- this.deviceType.assetName = res.content[0].familyName;
- }
- });
- }
- },
- // 接受维护信息传来的code,显示弹窗
- fourVendors(code) {
- this.firmDataType = "dialog";
- switch (code) {
- //品牌型号弹窗
- case "dpManufacturerId":
- // this.dataFirmType = 'dia'
- this.myDialog.firm = true;
- break;
- //供应商信息弹窗
- case "dpSupplierId":
- this.myDialog.supplier = true;
- break;
- //维修商信息弹窗
- case "dpMaintainerId":
- this.myDialog.maintainer = true;
- break;
- //保险公司信息
- case "dpInsurerId":
- this.myDialog.insurer = true;
- break;
- }
- },
- forValue(arr, val) {
- let enclosure = [];
- arr &&
- arr.length &&
- arr.map(i => {
- if (i.path == val) {
- enclosure = i.value;
- }
- });
- return enclosure;
- },
- multiples(val) {
- this.firmDataType = "dialog";
- switch (val) {
- case "infos.insuranceFile": //保险文件
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.archive": //设备文档
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.checkReport": //安装质检报告
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.maintainManual": //维修保养手册
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.approachingAcceptance": //进场验收单
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.acceptanceReport": //验收报告
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.operationManual": //操作说明书
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.originalCertificate": //原厂证明
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.testReport": //检测报告
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.productCertification": //产品合格证
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.installInstruction": //安装说明书
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.drawing": //设备图纸
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.installDrawing": //安装图纸
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.supplierContract": //供应合同
- this.filesArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadFiles = true;
- break;
- case "infos.installPic"://安装照片
- this.imgsArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadImgs = true;
- break;
- case "infos.nameplate"://设备铭牌照片
- this.imgsArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.uploadImgs = true;
- break;
- case "infos.pic"://设备照片
- this.picsArr = this.forValue(this.newEnclosure, val)
- ? this.forValue(this.newEnclosure, val)
- : [];
- this.infoType = val;
- this.myDialog.pic = true;
- break;
- }
- },
- getInfors(infos, row, el) {
- let val = this.hot.colToProp(row.col);
- let inputData = this.inputMap[val];
- this.row = row.row;
- this.messKey = val;
- this.firmDataType = "row";
- lStorage.set("screen_data", {
- path: this.$route.path,
- data: {equip: infos}
- });
- switch (val) {
- //操作
- case "caozuo":
- // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
- // this.$message("开发中...")
- this.$router.push({
- path: "deviceDetails",
- query: {
- type: this.mess.deviceId,
- equipId: infos.id,
- equipName: infos.localName
- ? infos.localName
- : infos.name
- ? infos.name
- : "",
- equipCode: infos.localId ? infos.localId : "",
- data: this.tableData.map(item => {
- return {
- value: item.id,
- label: item.localName
- ? item.localName
- : item.name
- ? item.name
- : ""
- };
- })
- }
- });
- return false;
- //设备二维码图片(infos.defaultQRCode)
- // case "infos.defaultQRCode":
- case "defaultQRCode":
- this.qrcodeUrl = this.tableData[row.row][val];
- if (this.qrcodeUrl) {
- this.myDialog.qrcode = true;
- } else {
- this.$message("此设备没有设备二维码");
- }
- return false;
- //BIM模型中坐标(bimLocation)
- case "bimLocation":
- this.bimcodeobj = this.tableData[row.row];
- if (Object.keys(this.bimcodeobj).length > 0) {
- this.myDialog.bimcode = true;
- } else {
- this.$message("此设备没有BIM模型中坐标");
- }
- return false;
- //关联系统()
- case "linkSystem":
- this.curDevice = infos.EquipID;
- this.systemList = this.tableData[row.row].linkSystem || [];
- this.myDialog.systemType = true;
- return false;
- //关联资产()
- case "linkEquipLocalName":
- if (!this.onlyRead) {
- this.myDialog.changeRea = true;
- }
- return false;
- /**
- * 关联资产后才可维护的信息点
- */
- case 'flowBuild': //所属建筑楼层
- case 'infos.productDate': //生产日期
- case 'infos.serialNum': //出厂编号
- case 'infos.assetID': //资产编号
- case 'infos.purchasePrice': //采购价格
- case 'infos.insuranceNum': //保险单号
- case 'infos.insuranceFile': //保险文件
- if (!this.onlyRead) {
- const linkId = this.tableData[row.row].linkId;
- if (!linkId) { //未关联资产
- this.$confirm('您暂未关联设备对应的资产,该信息点不可编辑', '提示', {
- confirmButtonText: '我知道了',
- showCancelButton: false,
- type: 'warning',
- center: true
- }).then(() => {
- return false;
- });
- }
- }
- return false;
- //保险文件--设备文档--安装质检报告
- case "infos.insuranceFile": //保险文件(F2)
- case "infos.archive": //设备文档(F2)
- case "infos.checkReport": //安装质检报告(F2)
- case "infos.maintainManual": //维修保养手册(F2)
- case "infos.approachingAcceptance": //进场验收单(F2)
- case "infos.acceptanceReport": //验收报告(F2)
- case "infos.operationManual": //操作说明书(F2)
- case "infos.originalCertificate": //原厂证明(F2)
- case "infos.testReport": //检测报告(F2)
- case "infos.productCertification": //产品合格证(F2)
- case "infos.installInstruction": //安装说明书(F2)
- case "infos.supplierContract": //供应合同(F2)
- case "infos.drawing": //设备图纸(F2)
- case "infos.installDrawing": //安装图纸(F2)
- let IPSdata = tools.dataForKey(this.tableData[row.row], val);
- this.filesArr = IPSdata ? IPSdata : [];
- if (!this.onlyRead || this.filesArr.length) {
- this.myDialog.uploadFiles = true;
- }
- return false;
- //安装照片--设备铭牌照片(F2)
- case "infos.installPic":
- case "infos.nameplate":
- let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
- this.imgsArr = SSPPdata ? SSPPdata : [];
- if (!this.onlyRead || this.imgsArr.length) {
- this.myDialog.uploadImgs = true;
- }
- return false;
- //设备照片(F2)
- case "infos.pic":
- let Pdata = tools.dataForKey(this.tableData[row.row], val);
- this.picsArr = Pdata ? Pdata : [];
- if (!this.onlyRead || this.picsArr.length) {
- this.myDialog.pic = true;
- }
- return false;
- //包含的部件字段
- case "count":
- let countUrl = this.onlyRead ? "/ledger/parts" : "/ledger/partsmanage";
- this.$router.push({
- path: countUrl,
- query: {
- deviceId: infos.id,
- typeId: this.mess.deviceId,
- pageNo: this.page.currentPage,
- pageSize: this.page.size
- }
- });
- return false;
- default:
- break;
- }
- if (!this.onlyRead && !inputData.editable) {
- this.$message("该信息点的值为自动生成,不可人工维护!");
- return false;
- }
- if (
- !this.onlyRead &&
- showTools.inputModeArr.indexOf(inputData.dataType) == "-1"
- ) {
- this.updateInfoPoint = val;
- this.updateInput = tools.dataForKey(this.tableData[row.row], val);
- this.myDialog.update = true;
- return false;
- }
- },
- //关闭临时维护弹窗回调
- handleCloseUpdate() {
- this.updateInputShow = false;
- this.updateInfoPoint = "";
- this.updateInput = "";
- },
- //更新临时维护信息点
- handleClickUpdate() {
- tools.setDataForKey(
- this.tableData[this.row],
- this.updateInfoPoint,
- this.updateInput
- );
- this.handleUpdataTable(
- [[this.row, this.updateInfoPoint, null, this.updateInput]],
- "edit"
- );
- this.updateInputShow = false;
- this.myDialog.update = false;
- this.updateInput = "";
- },
- //获取被筛选掉的行号
- trimmedRows() {
- var plugin = this.hot.getPlugin("trimRows").trimmedRows;
- let dataLength = this.tableData.length;
- let dataArr = new Array();
- for (let i = 0; i < dataLength; i++) {
- dataArr.push(i);
- }
- if (plugin.length <= 0) {
- dataArr = undefined;
- } else {
- dataArr = this.array_diff(dataArr, plugin);
- }
- return dataArr || [];
- },
- //去除数组中相同的元素
- array_diff(a, b) {
- for (var i = 0; i < b.length; i++) {
- for (var j = 0; j < a.length; j++) {
- if (a[j] == b[i]) {
- a.splice(j, 1);
- j = j - 1;
- }
- }
- }
- return a;
- },
- //修改关联的资产
- changeProperty(val) {
- this.setDataToMain(val.propertyId, "propertyId", this.row);
- this.setDataToMain(
- val.linkEquipLocalName,
- "linkEquipLocalName",
- this.row
- );
- },
- //上传文件弹窗触发事件
- fileChange(keys, type, file) {
- if (type === "dialog") {
- // this.information = keys
- this.newEnclosure.forEach(i => {
- if (i.path == keys) {
- this.$set(i, "value", file);
- }
- return i;
- });
- } else {
- this.setDataToMain(keys, this.messKey, this.row);
- }
- },
- //上传图片弹窗触发事件
- imgChange(keys, type, file) {
- if (type === "dialog") {
- // this.information = keys
- this.newEnclosure.forEach(i => {
- if (i.path == keys) {
- this.$set(i, "value", file);
- }
- return i;
- });
- } else {
- this.setDataToMain(keys, this.messKey, this.row);
- }
- },
- //关联系统更改
- changeSystemType(data) {
- tools.setDataForKey(this.tableData[this.row], "linkSystem", data);
- },
- //设备图片弹窗改变事件
- changePics(keys, type, file) {
- if (type === "dialog") {
- // this.information = keys
- this.newEnclosure.forEach(i => {
- if (i.path == keys) {
- this.$set(i, "value", file);
- }
- return i;
- });
- } else {
- this.setDataToMain(keys, this.messKey, this.row);
- }
- },
- utilToKey(key, name, data, messName) {
- if (key == name) {
- this.setDataToMain(data[key], messName, this.row);
- }
- },
- //判断是否有值,有值赋值
- setDataToMain(data, key, row) {
- if (!!data && data != "--") {
- if (!!this.tableData[row]) {
- tools.setDataForKey(this.tableData[row], key, data);
- this.handleUpdataTable([[row, key, null, data]], "edit");
- } else {
- this.tableData[row] = {};
- tools.setDataForKey(this.tableData[row], key, data);
- }
- } else {
- tools.setDataForKey(this.tableData[row], key, "");
- }
- },
- // 批量信息维护
- Batch() {
- this.firmDataType = "dialog";
- this.$refs.batchDialogs.batchDialog = true;
- },
- // 批量维护设备位置
- handleBatchEquipPoint() {
- let query = {};
- // 跳转批量维护设备位置页面
- this.$router.push({
- name: "BatchPointAssets",
- params: query
- })
- },
- upDataDevice(type, data1, data2) {
- let param = {content: data1};
- let param1 = {content: data2};
- if (type === 1) {
- //增量
- //LedgerParam
- let filterParam = this.filterCheck(param, "sole");
- let filterParam1 = this.filterCheck(param1, "multiple");
- if (filterParam) {
- updateEquip(param, res => {
- });
- }
- if (filterParam1) {
- param1.content.map(i => {
- i.equipId = i.id
- delete i.id
- return i
- })
- setTimeout(() => {
- queryUpdate(param1, res => {
- });
- });
- }
- }
- if (type === 2) {
- //覆盖
- let filterParams = this.filterCheck(param, "sole");
- if (filterParams) {
- updateEquip(param, res => {
- });
- }
- }
- setTimeout(() => {
- this.getTableData();
- this.getAllData();
- }, 1000);
- },
- filterCheck(arr, type) {
- if (type === "sole") {
- for (let i of arr.content) {
- for (let j in i.infos) {
- if (Array.isArray(i.infos[j]) && i.infos[j].length < 1) {
- delete i.infos[j]
- }
- }
- return Object.keys(i.infos).length;
- }
- } else if (type === "multiple") {
- let nArr = [];
- arr.content.forEach(i => {
- let {id, ...value} = i;
- nArr.push({infos: value});
- });
- // nArr.map(i => {
- // if (Array.isArray(i) && i.length < 1) {
- // console.log(i)
- // }
- // })
- for (let j of nArr) {
- return Object.keys(j.infos).length;
- }
- }
- }
- },
- watch: {
- projectId() {
- this.buildFloorData = [];
- buildFloor.getData(this.buildFloorData);
- this.tableData = [];
- this.mess.deviceId = null;
- this.page.total = 0;
- },
- showTypes: {
- handler(newName, oldName) {
- if (newName && newName[0] && newName[0].value) {
- this.showType = newName[0].value;
- } else {
- this.showType = "";
- }
- },
- immediate: true,
- deep: true
- }
- }
- };
- </script>
- <style lang="less">
- .hanson-bar {
- height: 40px;
- padding: 5px 0;
- font-size: 14px;
- overflow: hidden;
- margin-top: 0;
- line-height: 40px;
- .iconfont {
- font-size: 12px;
- }
- }
- .cancelButtonClass {
- width: 180px;
- }
- </style>
|