device.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489
  1. <template>
  2. <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;" v-loading="loading">
  3. <div class="hanson-bar">
  4. <div style="float:right;overflow:hidden;">
  5. <span>当前筛选条件下共{{ page.total || "--" }}设备</span>
  6. </div>
  7. <el-select v-model="onlyRead" @change="getHeaderData(mess)"
  8. style="width:100px;margin-right:20px;vertical-align:bottom;">
  9. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  10. </el-select>
  11. <el-select v-model="showType" @change="initTable" style="width:100px;margin-right:10px;vertical-align:bottom;">
  12. <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
  13. </el-select>
  14. <!-- <el-button size="small" style='width: 80px;' @click="download" icon="iconfont icon-xiazai">下载</el-button> -->
  15. <el-button size="small" style="width: 80px;" @click="addDevice">添加设备
  16. </el-button>
  17. <el-button size="small" @click="Batch" v-show="!onlyRead" :disabled="!(tableData && tableData.length)">批量维护信息点
  18. </el-button>
  19. <el-button size='small' @click='handleBatchEquipPoint' v-show='true'>批量维护设备位置</el-button>
  20. <el-button size="small" style="width: 80px;" @click="reset">刷新
  21. </el-button>
  22. <el-button size="small" style="width: 80px;" v-show="!onlyRead" @click="undo">撤销
  23. </el-button>
  24. </div>
  25. <!-- 二维码弹窗 -->
  26. <qrcode :dialog="myDialog" :qrcodeUrl="qrcodeUrl" :addBody="true" ref="qrcode"></qrcode>
  27. <!-- bim坐标弹框 -->
  28. <bimDialog :dialog="myDialog" :bimcodeobj="bimcodeobj" @closeBIM="closeBIM" :addBody="true"
  29. ref="bimdialog" :read="onlyRead ? true : false"></bimDialog>
  30. <!-- 上传文件-->
  31. <upload-files-dialog :read="onlyRead ? true : false" ref="upload" @changeFile="fileChange" :keysArr="filesArr"
  32. :firmDataType="firmDataType"
  33. :information="information" :infoType="infoType" :dialog="myDialog"/>
  34. <!-- 上传图片-->
  35. <upload-img-dialog :read="onlyRead ? true : false" @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"
  36. :firmDataType="firmDataType"
  37. :information="information" :infoType="infoType"/>
  38. <pic-dialog :read="onlyRead ? true : false" :dialog="myDialog" :keysArr="picsArr" @change="changePics"
  39. :firmDataType="firmDataType"
  40. :information="information" :infoType="infoType"/>
  41. <div class="middle_sty" style="height: 91%; text-align:center"
  42. v-show="!mess.deviceId && (!tableData || !tableData.length)">
  43. <p>
  44. <i class="icon-wushuju iconfont"></i>
  45. 请选择设备族
  46. </p>
  47. </div>
  48. <div class="center middle_sty" style="height: 91%;" v-show="mess.deviceId && (!tableData || !tableData.length)">
  49. <p>
  50. <i class="icon-wushuju iconfont"></i>
  51. 暂无数据
  52. </p>
  53. </div>
  54. <div v-show="mess.deviceId && tableData && tableData.length" id="handsontable" ref="handsontable"></div>
  55. <div v-show="mess.deviceId && tableData && tableData.length" class="right">
  56. <my-pagination @change="getTableData" :page="page" :key="pageKey"></my-pagination>
  57. </div>
  58. <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
  59. <!-- 关联的系统 -->
  60. <system-type :device="mess" :curDevice="curDevice" :dialog="myDialog" :type="onlyRead ? 'read' : 'edit'"
  61. @change="changeSystemType"
  62. :list="systemList"></system-type>
  63. <!-- 关联资产 -->
  64. <change-rea @changeProperty="changeProperty" :dialog="myDialog" :category="deviceType"></change-rea>
  65. <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
  66. <!-- 不支持的输入方式 -->
  67. <el-dialog title="临时维护信息点" :visible.sync="myDialog.update" @close="handleCloseUpdate" width="670px">
  68. <el-row>
  69. 该信息点未定义对应组件,现在维护数据不确定后续是否可用。如确实需要维护,请点击
  70. <el-link @click="updateInputShow = true" type="primary" :underline="false">继续维护
  71. </el-link>
  72. </el-row>
  73. <el-row style="margin-top:20px;" v-show="updateInputShow">
  74. <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 8 }" placeholder="请输入内容"
  75. v-model="updateInput"></el-input>
  76. </el-row>
  77. <span slot="footer" class="dialog-footer">
  78. <el-button @click="myDialog.update = false">取 消</el-button>
  79. <el-button type="primary" @click="handleClickUpdate">确 认</el-button>
  80. </span>
  81. </el-dialog>
  82. <!-- 新增设备 -->
  83. <el-dialog title="确定新增设备的类型" :visible.sync="myDialog.addDevice" width="670px">
  84. <el-row>
  85. <my-cascader ref="cascader" @change="changeAddType" :all="true"></my-cascader>
  86. </el-row>
  87. <span slot="footer" class="dialog-footer">
  88. <el-button type="primary" @click="toAddDevice">下 一 步</el-button>
  89. </span>
  90. </el-dialog>
  91. <!-- 维护信息弹窗-->
  92. <batchDialog ref="batchDialogs" @code="fourVendors" :firmName="firmName" :allObject="allObject" :page="batchPage"
  93. :information="information"
  94. :newEnclosure="newEnclosure" @getAllData="getAllData" @multiples="multiples"
  95. @upDataDevice="upDataDevice"/>
  96. </div>
  97. </template>
  98. <script>
  99. import {BeatchQueryParam, deleteEquip, getEquipBelongs, queryUpdate, updateEquip} from "@/api/scan/request";
  100. import {getEquipTableCon, queryEquip} from "@/api/object/equip";
  101. import {getDataDictionary} from "@/api/dict";
  102. import tools from "@/utils/scan/tools";
  103. import handsonUtils from "@/utils/hasontableUtils";
  104. import showTools from "@/utils/handsontable/notShow";
  105. import text from "@/utils/handsontable/mainText";
  106. import myCascader from "@/components/ledger/lib/cascader";
  107. import buildFloor from "@/utils/handsontable/buildFloorData";
  108. import qrcode from "@/components/ledger/lib/qrcode";
  109. import bimDialog from "@/components/ledger/lib/bimDialog";
  110. import uploadFilesDialog from "@/components/dialogs/list/filesDialog";
  111. import uploadImgDialog from "@/components/dialogs/list/uploadImgDialog";
  112. import picDialog from "@/components/dialogs/list/picDialog";
  113. import batchDialog from "../../dialogs/list/batchDialog";
  114. import systemType from "@/components/dialogs/list/systemType";
  115. import myPagination from "@/components/ledger/lib/myPagination";
  116. import detailsDialog from "@/components/ledger/lib/detailsDia";
  117. import changeRea from "@/components/dialogs/changeRea";
  118. import {mapGetters} from "vuex";
  119. //图片查看
  120. import lookPic from "@/components/ledger/lib/lookImages";
  121. import Handsontable from "handsontable-pro";
  122. import "handsontable-pro/dist/handsontable.full.css";
  123. import lStorage from "@/utils/localStorage";
  124. import dataTypeMap from "@/utils/handsontable/dataTypeMap"
  125. //下拉插件
  126. // import "@/assets/js/chosen.jquery.min";
  127. // import "@/assets/js/handsontable-chosen-editor";
  128. export default {
  129. props: ["myParam"],
  130. components: {
  131. qrcode, //二维码页面
  132. uploadFilesDialog,
  133. uploadImgDialog,
  134. picDialog,
  135. myPagination,
  136. systemType,
  137. detailsDialog,
  138. changeRea,
  139. lookPic,
  140. myCascader,
  141. batchDialog,
  142. bimDialog
  143. },
  144. created() {
  145. buildFloor.getData(this.buildFloorData);
  146. },
  147. computed: {
  148. ...mapGetters("layout", ["projectId", "secret", "userId", "group_code"]),
  149. showTypes() {
  150. return this.onlyRead
  151. ? [
  152. {value: "Visible", label: "只看采集信息"},
  153. {value: "all", label: "全部"}
  154. ]
  155. : [
  156. {value: "all", label: "全部"},
  157. {value: "Visible", label: "只看采集信息"}
  158. ];
  159. },
  160. // batchDate() {
  161. // // return !(!this.onlyRead && this.copyMain)
  162. // return !(!this.onlyRead && this.page.total > 1)
  163. // },
  164. batchDialogShow() {
  165. return this.$refs.batchDialogs.batchDialog;
  166. }
  167. },
  168. data() {
  169. return {
  170. options: [
  171. {
  172. value: true,
  173. label: "只读模式"
  174. },
  175. {
  176. value: false,
  177. label: "编辑模式"
  178. }
  179. ],
  180. buildFloorData: [], //楼层数据
  181. tableData: [],
  182. mess: {},
  183. tableHeader: null,
  184. page: {
  185. size: 50,
  186. sizes: [10, 30, 50, 100, 150, 200],
  187. total: 0,
  188. currentPage: 1
  189. },
  190. pageKey: new Date().getTime(),
  191. batchPage: {
  192. size: 100,
  193. sizes: [100, 200, 500, 1000],
  194. total: 0,
  195. currentPage: 1
  196. },
  197. myDialog: {
  198. qrcode: false, //二维码弹窗
  199. bimcode: false, //bim弹窗
  200. uploadFiles: false, //上传文件
  201. uploadImgs: false, //上传单个图片
  202. pic: false, //多个图片
  203. addDevice: false, //添加设备
  204. systemType: false, //关联系统
  205. details: false, //详情页
  206. changeRea: false, //关联资产
  207. lookPic: false, //图片查看
  208. update: false //临时维护信息点
  209. },
  210. row: null, //被修改的row
  211. filesArr: [], //保存临时的文件key
  212. messKey: null,
  213. imgsArr: [], //临时保存的图片key数组
  214. picsArr: [], //临时设备图片keys数组
  215. systemList: [], //关联的系统
  216. copyMain: null,
  217. iframeSrc: "",
  218. id: 0,
  219. onlyRead: true,
  220. showType: "Visible",
  221. linkNameFalg: true,
  222. qrcodeUrl: "", //二维码图片地址
  223. bimcodeobj: "", //BIM对象
  224. loading: false,
  225. deviceType: {}, //族3位编码及名称
  226. floorData: [],
  227. curDevice: "", //当前点击的设备id
  228. addData: {}, //
  229. showParts: false,
  230. inputMap: {
  231. flowBuild: {
  232. editable: true,
  233. code: "flowBuild",
  234. name: "建筑楼层",
  235. path: "flowBuild",
  236. category: 'STATIC',
  237. dataType: "ENUM"
  238. }
  239. }, //信息点和输入方式映射表
  240. updateInputShow: false, //是否显示临时维护输入框
  241. updateInfoPoint: "", //临时维护信息点
  242. updateInput: "", //临时维护信息点值
  243. firmName: "", //维护信息显示厂家名称
  244. firmDataType: "row",
  245. allObject: [],
  246. information: {
  247. archive: {
  248. Archive: [], //设备文档
  249. name: "设备文档",
  250. code: "infos.PhotoDoc.Archive",
  251. num: 14
  252. },
  253. checkReport: {
  254. CheckReport: [], //安装质检报告
  255. name: "安装质检报告",
  256. code: "infos.Siteinstall.CheckReport",
  257. num: 18
  258. },
  259. drawing: {
  260. Drawing: [], //设备图纸
  261. name: "设备图纸",
  262. code: "infos.PhotoDoc.Drawing",
  263. num: 13
  264. },
  265. installDrawing: {
  266. InstallDrawing: [], //安装图纸
  267. name: "安装图纸",
  268. code: "infos.Siteinstall.InstallDrawing",
  269. num: 16
  270. },
  271. installPic: {
  272. InstallPic: [], //安装照片
  273. name: "安装照片",
  274. code: "infos.Siteinstall.InstallPic",
  275. num: 17
  276. },
  277. insuranceFile: {
  278. InsuranceFile: [], //保险文件
  279. name: "保险文件",
  280. code: "infos.InsuranceDoc.InsuranceFile",
  281. num: 11
  282. },
  283. nameplate: {
  284. Nameplate: [], //设备铭牌照片
  285. name: "设备铭牌照片",
  286. code: "infos.PhotoDoc.Nameplate",
  287. num: 12
  288. },
  289. pic: {
  290. Pic: [], //设备照片
  291. name: "设备照片",
  292. code: "infos.PhotoDoc.Pic",
  293. num: 15
  294. }
  295. },
  296. infoType: "",
  297. newEnclosure: []
  298. };
  299. },
  300. methods: {
  301. //获取表头
  302. getHeaderData(code) {
  303. let tempParams = this.$route.params;
  304. if (!tempParams.used && tempParams.pageSize) {
  305. this.page.currentPage = Number(tempParams.pageNo);
  306. this.page.size = Number(tempParams.pageSize);
  307. this.onlyRead = tempParams.readOnly;
  308. tempParams.used = true;
  309. } else {
  310. this.page.currentPage = 1;
  311. }
  312. this.pageKey = new Date().getTime();
  313. this.mess = code;
  314. this.changeCader();
  315. if (this.mess.deviceId) {
  316. let params = {
  317. type: this.mess.deviceId,
  318. orders: "sort asc, name desc",
  319. };
  320. getDataDictionary(params, res => {
  321. this.tableHeader = res.content;
  322. this.codeToDataSource = {}
  323. this.tableHeader.forEach(item => {
  324. if (item.path) {
  325. this.inputMap[item.path] = item;
  326. }
  327. if (item.dataSource) {
  328. try {
  329. this.codeToDataSource[item.code] = {}
  330. item.dataSource.forEach(dic => {
  331. this.codeToDataSource[item.code][dic.code] = dic.name;
  332. })
  333. } catch (e) {
  334. console.log(e);
  335. }
  336. }
  337. });
  338. this.getTableData();
  339. this.getAllData();
  340. // 信息维护
  341. this.newEnclosure = res.content.filter(i => i.dataType == dataTypeMap.ATTACHMENT && i.editable == true);
  342. });
  343. }
  344. },
  345. //关闭弹窗
  346. closeBIM(val) {
  347. this.myDialog.bimcode = false;
  348. if (val == "update") {
  349. this.getTableData();
  350. this.getAllData();
  351. }
  352. },
  353. //获取主体数据
  354. getTableData() {
  355. this.loading = true;
  356. //type存在发送请求
  357. if (this.mess.deviceId) {
  358. let param = {
  359. pageSize: this.page.size,
  360. orders: "createTime desc,id desc,localId desc,localName desc",
  361. pageNumber: this.page.currentPage,
  362. filters: `classCode='${this.mess.deviceId}'`
  363. };
  364. if (this.mess.buildId == "noKnow") {
  365. param.filters += `;buildingId isNull`;
  366. } else if (this.mess.buildId && this.mess.buildId != "all") {
  367. param.filters += `;buildingId='${this.mess.buildId}'`;
  368. }
  369. if (this.mess.floorId == "noKnow") {
  370. param.filters += `;floorId isNull`;
  371. } else if (this.mess.floorId && this.mess.floorId != "all") {
  372. param.filters += `;floorId='${this.mess.floorId}'`;
  373. }
  374. getEquipTableCon(param, res => {
  375. this.loading = false;
  376. this.showParts = res.message == "1" ? true : false; // 判断是否显示包含的部件列
  377. this.tableData = res.content.map(item => {
  378. if (
  379. item.hasOwnProperty("buildingId") &&
  380. item.hasOwnProperty("floorId")
  381. ) {
  382. item.flowBuild = item.buildingId + "-" + item.floorId;
  383. } else if (
  384. item.hasOwnProperty("buildingId") &&
  385. !item.hasOwnProperty("floorId")
  386. ) {
  387. item.flowBuild = item.buildingId;
  388. }
  389. return item;
  390. });
  391. this.copyMain = tools.deepCopy(this.tableData);
  392. this.page.total = res.total;
  393. if (this.tableData && this.tableData.length) {
  394. if (this.onlyRead) {
  395. this.getBatch(this.tableData);
  396. }
  397. this.initTable();
  398. }
  399. });
  400. }
  401. },
  402. //获取所有主体数据---用于维护信息
  403. getAllData() {
  404. if (!!this.mess.deviceId) {
  405. // 查询step2
  406. let params = {
  407. cascade: [
  408. {
  409. name: "property"
  410. },
  411. {
  412. Name: "building",
  413. Projection: ["localName", "name", "id"]
  414. },
  415. {
  416. Name: "floor",
  417. Projection: ["localName", "name", "id"]
  418. }
  419. ],
  420. filters: `classCode='${this.mess.deviceId}'`,
  421. pageSize: this.batchPage.size,
  422. orders: "createTime desc, id desc",
  423. pageNumber: this.batchPage.currentPage,
  424. projection: [
  425. "buildingId",
  426. "floorId",
  427. "classCode",
  428. "localName",
  429. "localID",
  430. "id",
  431. "bimId"
  432. ]
  433. };
  434. if (this.mess.buildId == "noKnow") {
  435. params.filters += `;buildingId isNull`;
  436. } else if (this.mess.buildId && this.mess.buildId != "all") {
  437. params.filters += `;buildingId='${this.mess.buildId}'`;
  438. }
  439. if (this.mess.floorId == "noKnow") {
  440. params.filters += `;floorId isNull`;
  441. } else if (this.mess.floorId && this.mess.floorId != "all") {
  442. params.filters += `;floorId='${this.mess.floorId}'`;
  443. }
  444. queryEquip(params, res => {
  445. this.allObject = res.content;
  446. this.batchPage.total = res.total;
  447. });
  448. }
  449. },
  450. //获取动态参数
  451. getBatch(data) {
  452. let param = {
  453. groupCode: this.group_code,
  454. appId: "datacenter",
  455. projectId: this.projectId,
  456. data: []
  457. };
  458. //一级遍历list
  459. this.tableHeader.map(head => {
  460. //如果一级标签为动态参数或者设定参数放入数据等待请求
  461. if (head.category != 'STATIC') {
  462. data.map(item => {
  463. let cur = tools.dataForKey(item, head.path);
  464. if (cur) {
  465. param.data.push({
  466. objectId: item.id,
  467. infoCode: head.code
  468. });
  469. }
  470. });
  471. }
  472. });
  473. if (param.data.length) {
  474. BeatchQueryParam(param, res => {
  475. if (!this.onlyRead) {
  476. return false;
  477. }
  478. this.tableData = data.map(item => {
  479. res.data.map(child => {
  480. if (item.id == child.objectId) {
  481. if (!!child.data || child.data == 0) {
  482. this.tableHeader.map(head => {
  483. if (head.code == child.infoCode) {
  484. let contentVal = child.data
  485. if (this.codeToDataSource[child.infoCode]) {
  486. contentVal = this.codeToDataSource[child.infoCode][child.data]
  487. }
  488. tools.setDataForKey(item, head.path, contentVal);
  489. }
  490. });
  491. } else {
  492. this.tableHeader.map(head => {
  493. if (head.code == child.infoCode) {
  494. tools.setDataForKey(
  495. item,
  496. head.path,
  497. child.error
  498. ? child.value
  499. ? "表号功能号格式错误"
  500. : "表号功能号不存在"
  501. : "暂未采集到实时数据"
  502. );
  503. }
  504. });
  505. }
  506. }
  507. });
  508. return item;
  509. });
  510. this.hot.loadData(this.tableData);
  511. });
  512. }
  513. },
  514. //修改资产
  515. changeAssetsFalg() {
  516. if (this.linkNameFalg) {
  517. this.linkNameFalg = false;
  518. } else {
  519. this.$confirm(
  520. "<p>真的要在这里修改设备关联的资产么?</p><p>真的能通过列表信息找到想关联的资产么?</p><p>在这里修改关联的资产一定是因为之前关联错了要修改么?</p>",
  521. "提示",
  522. {
  523. dangerouslyUseHTMLString: true,
  524. confirmButtonText: "没错!我要改关联的资产",
  525. cancelButtonText: "我就点开看看",
  526. confirmButtonClass: "cancelButtonClass",
  527. cancelButtonClass: "cancelButtonClass"
  528. }
  529. )
  530. .then(_ => {
  531. this.linkNameFalg = true;
  532. })
  533. .catch(_ => {
  534. this.$message("取消");
  535. });
  536. }
  537. },
  538. //撤回
  539. undo() {
  540. this.hot.undo();
  541. },
  542. //刷新-switch改变
  543. reset() {
  544. this.getTableData();
  545. },
  546. //添加设备
  547. addDevice() {
  548. this.myDialog.addDevice = true;
  549. if (this.mess.deviceId) {
  550. this.$nextTick(() => {
  551. this.$refs.cascader.setValue(this.mess.deviceId);
  552. });
  553. }
  554. },
  555. //下一步
  556. toAddDevice() {
  557. if (this.addData.deviceId) {
  558. this.$router.push({
  559. path: "/ledger/deviceadd",
  560. query: this.addData
  561. });
  562. }
  563. },
  564. //选择设备类型-添加设备
  565. changeAddType(val) {
  566. this.addData.deviceId = val.code;
  567. this.addData.name = val.facility;
  568. this.addData.showType = this.showType;
  569. },
  570. //下载
  571. download() {
  572. if (!this.onlyRead) {
  573. if (!!this.hot) {
  574. let fileName =
  575. this.mess.name +
  576. "-页数:" +
  577. this.page.currentPage +
  578. "-个数:" +
  579. this.tableData.length +
  580. "-总个数:" +
  581. this.page.total;
  582. this.hot.getPlugin("exportFile").downloadFile("csv", {
  583. filename: fileName,
  584. columnHeaders: true,
  585. exportHiddenRows: true,
  586. exportHiddenColumns: true,
  587. rowHeaders: true
  588. });
  589. } else {
  590. this.$message("请确定存在表格");
  591. }
  592. } else {
  593. this.$message("下载需在编辑状态下");
  594. }
  595. },
  596. //格式化表头
  597. formatHeaderData(list) {
  598. let arr = tools.copyArr(list);
  599. let data = showTools.headerTextFilter(
  600. arr,
  601. "equipment",
  602. this.onlyRead,
  603. this.showType,
  604. true
  605. );
  606. if (this.showParts) {
  607. data.unshift("操作", "当前关联的资产", "所属系统实例", "包含的部件");
  608. } else {
  609. data.unshift("操作", "当前关联的资产", "所属系统实例");
  610. }
  611. if (this.showType == "all" && this.showParts) {
  612. data.splice(6, 0, "所属建筑楼层");
  613. } else if (this.showType == "all" && !this.showParts) {
  614. data.splice(5, 0, "所属建筑楼层");
  615. }
  616. return data;
  617. },
  618. //格式化表内容
  619. formatHeaderType(list) {
  620. let arr = tools.copyArr(list);
  621. let data = showTools.headerTypeFilter(
  622. arr,
  623. "equipment",
  624. this.onlyRead,
  625. this.showType,
  626. true
  627. );
  628. if (this.showParts) {
  629. data.unshift(
  630. {
  631. data: "caozuo",
  632. renderer: tools.lookDetails,
  633. readOnly: true
  634. },
  635. {
  636. data: "linkEquipLocalName",
  637. readOnly: true,
  638. renderer: tools.LinkEquipLocalName
  639. },
  640. {
  641. data: "linkSystem",
  642. renderer: text.systemList,
  643. readOnly: true
  644. },
  645. {
  646. data: "count",
  647. readOnly: true,
  648. renderer: tools.lookDetails
  649. }
  650. );
  651. } else {
  652. data.unshift(
  653. {
  654. data: "caozuo",
  655. renderer: tools.lookDetails,
  656. readOnly: true
  657. },
  658. {
  659. data: "linkEquipLocalName",
  660. readOnly: true,
  661. renderer: tools.LinkEquipLocalName
  662. },
  663. {
  664. data: "linkSystem",
  665. renderer: text.systemList,
  666. readOnly: true
  667. }
  668. );
  669. }
  670. if (this.showType == "all" && this.showParts) {
  671. data.splice(6, 0, {
  672. data: "flowBuild",
  673. renderer: tools.customDropdownRenderer,
  674. editor: "chosen",
  675. chosenOptions: {
  676. data: this.buildFloorData
  677. },
  678. readOnly: this.onlyRead
  679. });
  680. } else if (this.showType == "all" && !this.showParts) {
  681. data.splice(5, 0, {
  682. data: "flowBuild",
  683. renderer: tools.customDropdownRenderer,
  684. editor: "chosen",
  685. chosenOptions: {
  686. data: this.buildFloorData
  687. },
  688. readOnly: this.onlyRead
  689. });
  690. }
  691. return data;
  692. },
  693. //初始化插件
  694. initTable() {
  695. var container = document.getElementById("handsontable");
  696. let winHeight = document.documentElement.clientHeight;
  697. if (this.hot) {
  698. this.hot.destroy();
  699. this.hot = null;
  700. }
  701. this.hot = new Handsontable(container, {
  702. data: this.tableData,
  703. fixedColumnsLeft: this.showParts ? 6 : 5,
  704. colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
  705. columns: this.formatHeaderType(this.tableHeader), //数据显示格式
  706. filters: true,
  707. maxRows: this.tableData.length,
  708. height: winHeight - 335,
  709. columnSorting: true, //添加排序
  710. sortIndicator: true, //添加排序
  711. renderAllRows: true,
  712. // colWidths: 200,
  713. autoColumnSize: true,
  714. language: "zh-CN",
  715. manualColumnResize: true,
  716. manualColumnMove: true,
  717. dropdownMenu: [
  718. "filter_by_condition",
  719. "filter_by_value",
  720. "filter_action_bar"
  721. ],
  722. contextMenu: this.onlyRead
  723. ? false
  724. : {
  725. items: {
  726. remove_row: {
  727. name: "删除选中设备"
  728. }
  729. }
  730. },
  731. // 事件
  732. afterChange: this.handleUpdataTable, //修改后
  733. afterFilter: this.trimmedRows, //排序前
  734. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  735. afterOnCellMouseDown: this.eventClick //鼠标点击
  736. });
  737. let pro = document.getElementById("hot-display-license-info");
  738. if (!!pro) {
  739. pro.parentNode.removeChild(pro);
  740. }
  741. this.isLoading = false;
  742. },
  743. //表格中的点击
  744. eventClick(el, rowArr) {
  745. //点击的是表头
  746. if (rowArr.row < 0) {
  747. return;
  748. }
  749. //被筛选过后的数组
  750. let trimmedArr = this.trimmedRows();
  751. //是否启用了排序
  752. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  753. if (trimmedArr.length && isSort) {
  754. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  755. .__arrayMap;
  756. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  757. this.getInfors(
  758. infos,
  759. {row: sortArr[rowArr.row], col: rowArr.col},
  760. el
  761. );
  762. } else if (isSort) {
  763. //排序后的数组
  764. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  765. let infos = this.tableData[sortArr[rowArr.row]];
  766. this.getInfors(
  767. infos,
  768. {row: sortArr[rowArr.row], col: rowArr.col},
  769. el
  770. );
  771. } else if (trimmedArr.length) {
  772. let infos = this.tableData[trimmedArr[rowArr.row]];
  773. this.getInfors(
  774. infos,
  775. {row: trimmedArr[rowArr.row], col: rowArr.col},
  776. el
  777. );
  778. } else {
  779. let infos = this.tableData[rowArr.row];
  780. this.getInfors(infos, rowArr, el);
  781. }
  782. },
  783. // 更新
  784. handleUpdataTable(changeData, source) {
  785. if (!this.onlyRead && source != "ObserveChanges.change") {
  786. if (changeData) {
  787. let trimmedArr = this.trimmedRows();
  788. let param = handsonUtils.getParam(
  789. changeData,
  790. source,
  791. this.hot,
  792. trimmedArr
  793. );
  794. let data = [];
  795. for (let i = 0; i < param.length; i++) {
  796. data.push(param[i]);
  797. }
  798. //如果data中包含/且data长度为1,将其转换成.
  799. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  800. changeData[0][1] = changeData[0][1].split("/").join(".");
  801. }
  802. //存在data进行修改请求
  803. if (data && data.length) {
  804. this.updateBusiness(data, changeData);
  805. }
  806. }
  807. }
  808. },
  809. //删除设备
  810. handleDeleteTableRow() {
  811. let params = tools.differenceArr(this.tableData, this.copyMain);
  812. let _this = this;
  813. if (params.length < 1) {
  814. return;
  815. }
  816. let param = [];
  817. params.map(item => {
  818. this.deleteCode = item.classCode;
  819. param.push({id: item.id});
  820. });
  821. this.$confirm("此操作将删除设备,是否继续?", "提示", {
  822. confirmButtonText: "确定",
  823. cancelButtonText: "取消",
  824. type: "warning"
  825. })
  826. .then(() => {
  827. this.removeDevice(param);
  828. })
  829. .catch(() => {
  830. this.reset();
  831. this.$message("取消删除");
  832. });
  833. },
  834. // 删除设备
  835. async removeDevice(param) {
  836. await deleteEquip(param, res => {
  837. this.$message.success("删除成功");
  838. this.$emit("close", {code: this.deleteCode});
  839. // this.getTableData()
  840. });
  841. },
  842. // 更新
  843. updateBusiness(data, change) {
  844. let param = {
  845. content: [],
  846. projection: []
  847. },
  848. keyList = [];
  849. //生成要修改字段列表
  850. change.map(item => {
  851. let key = item[1].split(".")[0];
  852. if (key == "flowBuild" && keyList.indexOf(key) == -1) {
  853. keyList.push("buildingId", "floorId");
  854. param.projection.push("buildingId", "floorId");
  855. }
  856. if (item[1] && keyList.indexOf(key) == -1 && item[1] != "propertyId") {
  857. keyList.push(key);
  858. }
  859. if (
  860. item[1] &&
  861. item[3] == "" &&
  862. param.projection.indexOf(key) == -1 &&
  863. item[1] != "propertyId"
  864. ) {
  865. param.projection.push(key);
  866. keyList.push(item[1])
  867. }
  868. });
  869. //生成对应修改数据
  870. data.map((item, index) => {
  871. keyList.map(value => {
  872. if (value == "buildingId") {
  873. let itemData = tools.dataForKey(item, "flowBuild");
  874. if (itemData == "") {
  875. tools.setDataForKey(item, "buildingId", null);
  876. tools.setDataForKey(item, "floorId", null);
  877. } else {
  878. let BuildingId = itemData.split("-")[0];
  879. let FloorId = itemData.split("-")[1];
  880. if (BuildingId && FloorId) {
  881. tools.setDataForKey(item, "buildingId", BuildingId);
  882. tools.setDataForKey(item, "floorId", FloorId);
  883. } else if (BuildingId && !FloorId) {
  884. tools.setDataForKey(item, "buildingId", BuildingId);
  885. tools.setDataForKey(item, "floorId", null);
  886. }
  887. }
  888. } else {
  889. let itemData = tools.dataForKey(item, value);
  890. tools.setDataForKey(item, value, itemData == "" ? null : itemData);
  891. }
  892. });
  893. param.content.push(item);
  894. });
  895. updateEquip(param, res => {
  896. });
  897. },
  898. //修改设备类型
  899. changeCader() {
  900. if (this.mess.deviceId) {
  901. let param = {
  902. data: {
  903. filters: `equipCode='${this.mess.deviceId}'`,
  904. pageNumber: 1,
  905. pageSize: 50
  906. }
  907. };
  908. getEquipBelongs(param, res => {
  909. if (res.content.length) {
  910. this.deviceType.assetType = res.content[0].family;
  911. this.deviceType.assetName = res.content[0].familyName;
  912. }
  913. });
  914. }
  915. },
  916. // 接受维护信息传来的code,显示弹窗
  917. fourVendors(code) {
  918. this.firmDataType = "dialog";
  919. switch (code) {
  920. //品牌型号弹窗
  921. case "dpManufacturerId":
  922. // this.dataFirmType = 'dia'
  923. this.myDialog.firm = true;
  924. break;
  925. //供应商信息弹窗
  926. case "dpSupplierId":
  927. this.myDialog.supplier = true;
  928. break;
  929. //维修商信息弹窗
  930. case "dpMaintainerId":
  931. this.myDialog.maintainer = true;
  932. break;
  933. //保险公司信息
  934. case "dpInsurerId":
  935. this.myDialog.insurer = true;
  936. break;
  937. }
  938. },
  939. forValue(arr, val) {
  940. let enclosure = [];
  941. arr &&
  942. arr.length &&
  943. arr.map(i => {
  944. if (i.path == val) {
  945. enclosure = i.value;
  946. }
  947. });
  948. return enclosure;
  949. },
  950. multiples(val) {
  951. this.firmDataType = "dialog";
  952. switch (val) {
  953. case "infos.insuranceFile": //保险文件
  954. this.filesArr = this.forValue(this.newEnclosure, val)
  955. ? this.forValue(this.newEnclosure, val)
  956. : [];
  957. this.infoType = val;
  958. this.myDialog.uploadFiles = true;
  959. break;
  960. case "infos.archive": //设备文档
  961. this.filesArr = this.forValue(this.newEnclosure, val)
  962. ? this.forValue(this.newEnclosure, val)
  963. : [];
  964. this.infoType = val;
  965. this.myDialog.uploadFiles = true;
  966. break;
  967. case "infos.checkReport": //安装质检报告
  968. this.filesArr = this.forValue(this.newEnclosure, val)
  969. ? this.forValue(this.newEnclosure, val)
  970. : [];
  971. this.infoType = val;
  972. this.myDialog.uploadFiles = true;
  973. break;
  974. case "infos.maintainManual": //维修保养手册
  975. this.filesArr = this.forValue(this.newEnclosure, val)
  976. ? this.forValue(this.newEnclosure, val)
  977. : [];
  978. this.infoType = val;
  979. this.myDialog.uploadFiles = true;
  980. break;
  981. case "infos.approachingAcceptance": //进场验收单
  982. this.filesArr = this.forValue(this.newEnclosure, val)
  983. ? this.forValue(this.newEnclosure, val)
  984. : [];
  985. this.infoType = val;
  986. this.myDialog.uploadFiles = true;
  987. break;
  988. case "infos.acceptanceReport": //验收报告
  989. this.filesArr = this.forValue(this.newEnclosure, val)
  990. ? this.forValue(this.newEnclosure, val)
  991. : [];
  992. this.infoType = val;
  993. this.myDialog.uploadFiles = true;
  994. break;
  995. case "infos.operationManual": //操作说明书
  996. this.filesArr = this.forValue(this.newEnclosure, val)
  997. ? this.forValue(this.newEnclosure, val)
  998. : [];
  999. this.infoType = val;
  1000. this.myDialog.uploadFiles = true;
  1001. break;
  1002. case "infos.originalCertificate": //原厂证明
  1003. this.filesArr = this.forValue(this.newEnclosure, val)
  1004. ? this.forValue(this.newEnclosure, val)
  1005. : [];
  1006. this.infoType = val;
  1007. this.myDialog.uploadFiles = true;
  1008. break;
  1009. case "infos.testReport": //检测报告
  1010. this.filesArr = this.forValue(this.newEnclosure, val)
  1011. ? this.forValue(this.newEnclosure, val)
  1012. : [];
  1013. this.infoType = val;
  1014. this.myDialog.uploadFiles = true;
  1015. break;
  1016. case "infos.productCertification": //产品合格证
  1017. this.filesArr = this.forValue(this.newEnclosure, val)
  1018. ? this.forValue(this.newEnclosure, val)
  1019. : [];
  1020. this.infoType = val;
  1021. this.myDialog.uploadFiles = true;
  1022. break;
  1023. case "infos.installInstruction": //安装说明书
  1024. this.filesArr = this.forValue(this.newEnclosure, val)
  1025. ? this.forValue(this.newEnclosure, val)
  1026. : [];
  1027. this.infoType = val;
  1028. this.myDialog.uploadFiles = true;
  1029. break;
  1030. case "infos.drawing": //设备图纸
  1031. this.filesArr = this.forValue(this.newEnclosure, val)
  1032. ? this.forValue(this.newEnclosure, val)
  1033. : [];
  1034. this.infoType = val;
  1035. this.myDialog.uploadFiles = true;
  1036. break;
  1037. case "infos.installDrawing": //安装图纸
  1038. this.filesArr = this.forValue(this.newEnclosure, val)
  1039. ? this.forValue(this.newEnclosure, val)
  1040. : [];
  1041. this.infoType = val;
  1042. this.myDialog.uploadFiles = true;
  1043. break;
  1044. case "infos.supplierContract": //供应合同
  1045. this.filesArr = this.forValue(this.newEnclosure, val)
  1046. ? this.forValue(this.newEnclosure, val)
  1047. : [];
  1048. this.infoType = val;
  1049. this.myDialog.uploadFiles = true;
  1050. break;
  1051. case "infos.installPic"://安装照片
  1052. this.imgsArr = this.forValue(this.newEnclosure, val)
  1053. ? this.forValue(this.newEnclosure, val)
  1054. : [];
  1055. this.infoType = val;
  1056. this.myDialog.uploadImgs = true;
  1057. break;
  1058. case "infos.nameplate"://设备铭牌照片
  1059. this.imgsArr = this.forValue(this.newEnclosure, val)
  1060. ? this.forValue(this.newEnclosure, val)
  1061. : [];
  1062. this.infoType = val;
  1063. this.myDialog.uploadImgs = true;
  1064. break;
  1065. case "infos.pic"://设备照片
  1066. this.picsArr = this.forValue(this.newEnclosure, val)
  1067. ? this.forValue(this.newEnclosure, val)
  1068. : [];
  1069. this.infoType = val;
  1070. this.myDialog.pic = true;
  1071. break;
  1072. }
  1073. },
  1074. getInfors(infos, row, el) {
  1075. let val = this.hot.colToProp(row.col);
  1076. let inputData = this.inputMap[val];
  1077. this.row = row.row;
  1078. this.messKey = val;
  1079. this.firmDataType = "row";
  1080. lStorage.set("screen_data", {
  1081. path: this.$route.path,
  1082. data: {equip: infos}
  1083. });
  1084. switch (val) {
  1085. //操作
  1086. case "caozuo":
  1087. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  1088. // this.$message("开发中...")
  1089. this.$router.push({
  1090. path: "deviceDetails",
  1091. query: {
  1092. type: this.mess.deviceId,
  1093. equipId: infos.id,
  1094. equipName: infos.localName
  1095. ? infos.localName
  1096. : infos.name
  1097. ? infos.name
  1098. : "",
  1099. equipCode: infos.localId ? infos.localId : "",
  1100. data: this.tableData.map(item => {
  1101. return {
  1102. value: item.id,
  1103. label: item.localName
  1104. ? item.localName
  1105. : item.name
  1106. ? item.name
  1107. : ""
  1108. };
  1109. })
  1110. }
  1111. });
  1112. return false;
  1113. //设备二维码图片(infos.defaultQRCode)
  1114. // case "infos.defaultQRCode":
  1115. case "defaultQRCode":
  1116. this.qrcodeUrl = this.tableData[row.row][val];
  1117. if (this.qrcodeUrl) {
  1118. this.myDialog.qrcode = true;
  1119. } else {
  1120. this.$message("此设备没有设备二维码");
  1121. }
  1122. return false;
  1123. //BIM模型中坐标(bimLocation)
  1124. case "bimLocation":
  1125. this.bimcodeobj = this.tableData[row.row];
  1126. if (Object.keys(this.bimcodeobj).length > 0) {
  1127. this.myDialog.bimcode = true;
  1128. } else {
  1129. this.$message("此设备没有BIM模型中坐标");
  1130. }
  1131. return false;
  1132. //关联系统()
  1133. case "linkSystem":
  1134. this.curDevice = infos.EquipID;
  1135. this.systemList = this.tableData[row.row].linkSystem || [];
  1136. this.myDialog.systemType = true;
  1137. return false;
  1138. //关联资产()
  1139. case "linkEquipLocalName":
  1140. if (!this.onlyRead) {
  1141. this.myDialog.changeRea = true;
  1142. }
  1143. return false;
  1144. /**
  1145. * 关联资产后才可维护的信息点
  1146. */
  1147. case 'flowBuild': //所属建筑楼层
  1148. case 'infos.productDate': //生产日期
  1149. case 'infos.serialNum': //出厂编号
  1150. case 'infos.assetID': //资产编号
  1151. case 'infos.purchasePrice': //采购价格
  1152. case 'infos.insuranceNum': //保险单号
  1153. case 'infos.insuranceFile': //保险文件
  1154. if (!this.onlyRead) {
  1155. const linkId = this.tableData[row.row].linkId;
  1156. if (!linkId) { //未关联资产
  1157. this.$confirm('您暂未关联设备对应的资产,该信息点不可编辑', '提示', {
  1158. confirmButtonText: '我知道了',
  1159. showCancelButton: false,
  1160. type: 'warning',
  1161. center: true
  1162. }).then(() => {
  1163. return false;
  1164. });
  1165. }
  1166. }
  1167. return false;
  1168. //保险文件--设备文档--安装质检报告
  1169. case "infos.insuranceFile": //保险文件(F2)
  1170. case "infos.archive": //设备文档(F2)
  1171. case "infos.checkReport": //安装质检报告(F2)
  1172. case "infos.maintainManual": //维修保养手册(F2)
  1173. case "infos.approachingAcceptance": //进场验收单(F2)
  1174. case "infos.acceptanceReport": //验收报告(F2)
  1175. case "infos.operationManual": //操作说明书(F2)
  1176. case "infos.originalCertificate": //原厂证明(F2)
  1177. case "infos.testReport": //检测报告(F2)
  1178. case "infos.productCertification": //产品合格证(F2)
  1179. case "infos.installInstruction": //安装说明书(F2)
  1180. case "infos.supplierContract": //供应合同(F2)
  1181. case "infos.drawing": //设备图纸(F2)
  1182. case "infos.installDrawing": //安装图纸(F2)
  1183. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  1184. this.filesArr = IPSdata ? IPSdata : [];
  1185. if (!this.onlyRead || this.filesArr.length) {
  1186. this.myDialog.uploadFiles = true;
  1187. }
  1188. return false;
  1189. //安装照片--设备铭牌照片(F2)
  1190. case "infos.installPic":
  1191. case "infos.nameplate":
  1192. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  1193. this.imgsArr = SSPPdata ? SSPPdata : [];
  1194. if (!this.onlyRead || this.imgsArr.length) {
  1195. this.myDialog.uploadImgs = true;
  1196. }
  1197. return false;
  1198. //设备照片(F2)
  1199. case "infos.pic":
  1200. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  1201. this.picsArr = Pdata ? Pdata : [];
  1202. if (!this.onlyRead || this.picsArr.length) {
  1203. this.myDialog.pic = true;
  1204. }
  1205. return false;
  1206. //包含的部件字段
  1207. case "count":
  1208. let countUrl = this.onlyRead ? "/ledger/parts" : "/ledger/partsmanage";
  1209. this.$router.push({
  1210. path: countUrl,
  1211. query: {
  1212. deviceId: infos.id,
  1213. typeId: this.mess.deviceId,
  1214. pageNo: this.page.currentPage,
  1215. pageSize: this.page.size
  1216. }
  1217. });
  1218. return false;
  1219. default:
  1220. break;
  1221. }
  1222. if (!this.onlyRead && !inputData.editable) {
  1223. this.$message("该信息点的值为自动生成,不可人工维护!");
  1224. return false;
  1225. }
  1226. if (
  1227. !this.onlyRead &&
  1228. showTools.inputModeArr.indexOf(inputData.dataType) == "-1"
  1229. ) {
  1230. this.updateInfoPoint = val;
  1231. this.updateInput = tools.dataForKey(this.tableData[row.row], val);
  1232. this.myDialog.update = true;
  1233. return false;
  1234. }
  1235. },
  1236. //关闭临时维护弹窗回调
  1237. handleCloseUpdate() {
  1238. this.updateInputShow = false;
  1239. this.updateInfoPoint = "";
  1240. this.updateInput = "";
  1241. },
  1242. //更新临时维护信息点
  1243. handleClickUpdate() {
  1244. tools.setDataForKey(
  1245. this.tableData[this.row],
  1246. this.updateInfoPoint,
  1247. this.updateInput
  1248. );
  1249. this.handleUpdataTable(
  1250. [[this.row, this.updateInfoPoint, null, this.updateInput]],
  1251. "edit"
  1252. );
  1253. this.updateInputShow = false;
  1254. this.myDialog.update = false;
  1255. this.updateInput = "";
  1256. },
  1257. //获取被筛选掉的行号
  1258. trimmedRows() {
  1259. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  1260. let dataLength = this.tableData.length;
  1261. let dataArr = new Array();
  1262. for (let i = 0; i < dataLength; i++) {
  1263. dataArr.push(i);
  1264. }
  1265. if (plugin.length <= 0) {
  1266. dataArr = undefined;
  1267. } else {
  1268. dataArr = this.array_diff(dataArr, plugin);
  1269. }
  1270. return dataArr || [];
  1271. },
  1272. //去除数组中相同的元素
  1273. array_diff(a, b) {
  1274. for (var i = 0; i < b.length; i++) {
  1275. for (var j = 0; j < a.length; j++) {
  1276. if (a[j] == b[i]) {
  1277. a.splice(j, 1);
  1278. j = j - 1;
  1279. }
  1280. }
  1281. }
  1282. return a;
  1283. },
  1284. //修改关联的资产
  1285. changeProperty(val) {
  1286. this.setDataToMain(val.propertyId, "propertyId", this.row);
  1287. this.setDataToMain(
  1288. val.linkEquipLocalName,
  1289. "linkEquipLocalName",
  1290. this.row
  1291. );
  1292. },
  1293. //上传文件弹窗触发事件
  1294. fileChange(keys, type, file) {
  1295. if (type === "dialog") {
  1296. // this.information = keys
  1297. this.newEnclosure.forEach(i => {
  1298. if (i.path == keys) {
  1299. this.$set(i, "value", file);
  1300. }
  1301. return i;
  1302. });
  1303. } else {
  1304. this.setDataToMain(keys, this.messKey, this.row);
  1305. }
  1306. },
  1307. //上传图片弹窗触发事件
  1308. imgChange(keys, type, file) {
  1309. if (type === "dialog") {
  1310. // this.information = keys
  1311. this.newEnclosure.forEach(i => {
  1312. if (i.path == keys) {
  1313. this.$set(i, "value", file);
  1314. }
  1315. return i;
  1316. });
  1317. } else {
  1318. this.setDataToMain(keys, this.messKey, this.row);
  1319. }
  1320. },
  1321. //关联系统更改
  1322. changeSystemType(data) {
  1323. tools.setDataForKey(this.tableData[this.row], "linkSystem", data);
  1324. },
  1325. //设备图片弹窗改变事件
  1326. changePics(keys, type, file) {
  1327. if (type === "dialog") {
  1328. // this.information = keys
  1329. this.newEnclosure.forEach(i => {
  1330. if (i.path == keys) {
  1331. this.$set(i, "value", file);
  1332. }
  1333. return i;
  1334. });
  1335. } else {
  1336. this.setDataToMain(keys, this.messKey, this.row);
  1337. }
  1338. },
  1339. utilToKey(key, name, data, messName) {
  1340. if (key == name) {
  1341. this.setDataToMain(data[key], messName, this.row);
  1342. }
  1343. },
  1344. //判断是否有值,有值赋值
  1345. setDataToMain(data, key, row) {
  1346. if (!!data && data != "--") {
  1347. if (!!this.tableData[row]) {
  1348. tools.setDataForKey(this.tableData[row], key, data);
  1349. this.handleUpdataTable([[row, key, null, data]], "edit");
  1350. } else {
  1351. this.tableData[row] = {};
  1352. tools.setDataForKey(this.tableData[row], key, data);
  1353. }
  1354. } else {
  1355. tools.setDataForKey(this.tableData[row], key, "");
  1356. }
  1357. },
  1358. // 批量信息维护
  1359. Batch() {
  1360. this.firmDataType = "dialog";
  1361. this.$refs.batchDialogs.batchDialog = true;
  1362. },
  1363. // 批量维护设备位置
  1364. handleBatchEquipPoint() {
  1365. let query = {};
  1366. // 跳转批量维护设备位置页面
  1367. this.$router.push({
  1368. name: "BatchPointAssets",
  1369. params: query
  1370. })
  1371. },
  1372. upDataDevice(type, data1, data2) {
  1373. let param = {content: data1};
  1374. let param1 = {content: data2};
  1375. if (type === 1) {
  1376. //增量
  1377. //LedgerParam
  1378. let filterParam = this.filterCheck(param, "sole");
  1379. let filterParam1 = this.filterCheck(param1, "multiple");
  1380. if (filterParam) {
  1381. updateEquip(param, res => {
  1382. });
  1383. }
  1384. if (filterParam1) {
  1385. param1.content.map(i => {
  1386. i.equipId = i.id
  1387. delete i.id
  1388. return i
  1389. })
  1390. setTimeout(() => {
  1391. queryUpdate(param1, res => {
  1392. });
  1393. });
  1394. }
  1395. }
  1396. if (type === 2) {
  1397. //覆盖
  1398. let filterParams = this.filterCheck(param, "sole");
  1399. if (filterParams) {
  1400. updateEquip(param, res => {
  1401. });
  1402. }
  1403. }
  1404. setTimeout(() => {
  1405. this.getTableData();
  1406. this.getAllData();
  1407. }, 1000);
  1408. },
  1409. filterCheck(arr, type) {
  1410. if (type === "sole") {
  1411. for (let i of arr.content) {
  1412. for (let j in i.infos) {
  1413. if (Array.isArray(i.infos[j]) && i.infos[j].length < 1) {
  1414. delete i.infos[j]
  1415. }
  1416. }
  1417. return Object.keys(i.infos).length;
  1418. }
  1419. } else if (type === "multiple") {
  1420. let nArr = [];
  1421. arr.content.forEach(i => {
  1422. let {id, ...value} = i;
  1423. nArr.push({infos: value});
  1424. });
  1425. // nArr.map(i => {
  1426. // if (Array.isArray(i) && i.length < 1) {
  1427. // console.log(i)
  1428. // }
  1429. // })
  1430. for (let j of nArr) {
  1431. return Object.keys(j.infos).length;
  1432. }
  1433. }
  1434. }
  1435. },
  1436. watch: {
  1437. projectId() {
  1438. this.buildFloorData = [];
  1439. buildFloor.getData(this.buildFloorData);
  1440. this.tableData = [];
  1441. this.mess.deviceId = null;
  1442. this.page.total = 0;
  1443. },
  1444. showTypes: {
  1445. handler(newName, oldName) {
  1446. if (newName && newName[0] && newName[0].value) {
  1447. this.showType = newName[0].value;
  1448. } else {
  1449. this.showType = "";
  1450. }
  1451. },
  1452. immediate: true,
  1453. deep: true
  1454. }
  1455. }
  1456. };
  1457. </script>
  1458. <style lang="less">
  1459. .hanson-bar {
  1460. height: 40px;
  1461. padding: 5px 0;
  1462. font-size: 14px;
  1463. overflow: hidden;
  1464. margin-top: 0;
  1465. line-height: 40px;
  1466. .iconfont {
  1467. font-size: 12px;
  1468. }
  1469. }
  1470. .cancelButtonClass {
  1471. width: 180px;
  1472. }
  1473. </style>