device.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  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. } else {
  401. this.loading = false;
  402. this.$message.info("请选择设备类别!");
  403. }
  404. },
  405. //获取所有主体数据---用于维护信息
  406. getAllData() {
  407. if (!!this.mess.deviceId) {
  408. // 查询step2
  409. let params = {
  410. cascade: [
  411. {
  412. name: "property"
  413. },
  414. {
  415. Name: "building",
  416. Projection: ["localName", "name", "id"]
  417. },
  418. {
  419. Name: "floor",
  420. Projection: ["localName", "name", "id"]
  421. }
  422. ],
  423. filters: `classCode='${this.mess.deviceId}'`,
  424. pageSize: this.batchPage.size,
  425. orders: "createTime desc, id desc",
  426. pageNumber: this.batchPage.currentPage,
  427. projection: [
  428. "buildingId",
  429. "floorId",
  430. "classCode",
  431. "localName",
  432. "localID",
  433. "id",
  434. "bimId"
  435. ]
  436. };
  437. if (this.mess.buildId == "noKnow") {
  438. params.filters += `;buildingId isNull`;
  439. } else if (this.mess.buildId && this.mess.buildId != "all") {
  440. params.filters += `;buildingId='${this.mess.buildId}'`;
  441. }
  442. if (this.mess.floorId == "noKnow") {
  443. params.filters += `;floorId isNull`;
  444. } else if (this.mess.floorId && this.mess.floorId != "all") {
  445. params.filters += `;floorId='${this.mess.floorId}'`;
  446. }
  447. queryEquip(params, res => {
  448. this.allObject = res.content;
  449. this.batchPage.total = res.total;
  450. });
  451. }
  452. },
  453. //获取动态参数
  454. getBatch(data) {
  455. let param = {
  456. groupCode: this.group_code,
  457. appId: "datacenter",
  458. projectId: this.projectId,
  459. data: []
  460. };
  461. //一级遍历list
  462. this.tableHeader.map(head => {
  463. //如果一级标签为动态参数或者设定参数放入数据等待请求
  464. if (head.category != 'STATIC') {
  465. data.map(item => {
  466. let cur = tools.dataForKey(item, head.path);
  467. if (cur) {
  468. param.data.push({
  469. objectId: item.id,
  470. infoCode: head.code
  471. });
  472. }
  473. });
  474. }
  475. });
  476. if (param.data.length) {
  477. BeatchQueryParam(param, res => {
  478. if (!this.onlyRead) {
  479. return false;
  480. }
  481. this.tableData = data.map(item => {
  482. res.data.map(child => {
  483. if (item.id == child.objectId) {
  484. if (!!child.data || child.data == 0) {
  485. this.tableHeader.map(head => {
  486. if (head.code == child.infoCode) {
  487. let contentVal = child.data
  488. if (this.codeToDataSource[child.infoCode]) {
  489. contentVal = this.codeToDataSource[child.infoCode][child.data]
  490. }
  491. tools.setDataForKey(item, head.path, contentVal);
  492. }
  493. });
  494. } else {
  495. this.tableHeader.map(head => {
  496. if (head.code == child.infoCode) {
  497. tools.setDataForKey(
  498. item,
  499. head.path,
  500. child.error
  501. ? child.value
  502. ? "表号功能号格式错误"
  503. : "表号功能号不存在"
  504. : "暂未采集到实时数据"
  505. );
  506. }
  507. });
  508. }
  509. }
  510. });
  511. return item;
  512. });
  513. this.hot.loadData(this.tableData);
  514. });
  515. }
  516. },
  517. //修改资产
  518. changeAssetsFalg() {
  519. if (this.linkNameFalg) {
  520. this.linkNameFalg = false;
  521. } else {
  522. this.$confirm(
  523. "<p>真的要在这里修改设备关联的资产么?</p><p>真的能通过列表信息找到想关联的资产么?</p><p>在这里修改关联的资产一定是因为之前关联错了要修改么?</p>",
  524. "提示",
  525. {
  526. dangerouslyUseHTMLString: true,
  527. confirmButtonText: "没错!我要改关联的资产",
  528. cancelButtonText: "我就点开看看",
  529. confirmButtonClass: "cancelButtonClass",
  530. cancelButtonClass: "cancelButtonClass"
  531. }
  532. )
  533. .then(_ => {
  534. this.linkNameFalg = true;
  535. })
  536. .catch(_ => {
  537. this.$message("取消");
  538. });
  539. }
  540. },
  541. //撤回
  542. undo() {
  543. this.hot.undo();
  544. },
  545. //刷新-switch改变
  546. reset() {
  547. this.getTableData();
  548. },
  549. //添加设备
  550. addDevice() {
  551. this.myDialog.addDevice = true;
  552. if (this.mess.deviceId) {
  553. this.$nextTick(() => {
  554. this.$refs.cascader.setValue(this.mess.deviceId);
  555. });
  556. }
  557. },
  558. //下一步
  559. toAddDevice() {
  560. if (this.addData.deviceId) {
  561. this.$router.push({
  562. path: "/ledger/deviceadd",
  563. query: this.addData
  564. });
  565. }
  566. },
  567. //选择设备类型-添加设备
  568. changeAddType(val) {
  569. this.addData.deviceId = val.code;
  570. this.addData.name = val.facility;
  571. this.addData.showType = this.showType;
  572. },
  573. //下载
  574. download() {
  575. if (!this.onlyRead) {
  576. if (!!this.hot) {
  577. let fileName =
  578. this.mess.name +
  579. "-页数:" +
  580. this.page.currentPage +
  581. "-个数:" +
  582. this.tableData.length +
  583. "-总个数:" +
  584. this.page.total;
  585. this.hot.getPlugin("exportFile").downloadFile("csv", {
  586. filename: fileName,
  587. columnHeaders: true,
  588. exportHiddenRows: true,
  589. exportHiddenColumns: true,
  590. rowHeaders: true
  591. });
  592. } else {
  593. this.$message("请确定存在表格");
  594. }
  595. } else {
  596. this.$message("下载需在编辑状态下");
  597. }
  598. },
  599. //格式化表头
  600. formatHeaderData(list) {
  601. let arr = tools.copyArr(list);
  602. let data = showTools.headerTextFilter(
  603. arr,
  604. "equipment",
  605. this.onlyRead,
  606. this.showType,
  607. true
  608. );
  609. if (this.showParts) {
  610. data.unshift("操作", "当前关联的资产", "所属系统实例", "包含的部件");
  611. } else {
  612. data.unshift("操作", "当前关联的资产", "所属系统实例");
  613. }
  614. if (this.showType == "all" && this.showParts) {
  615. data.splice(6, 0, "所属建筑楼层");
  616. } else if (this.showType == "all" && !this.showParts) {
  617. data.splice(5, 0, "所属建筑楼层");
  618. }
  619. return data;
  620. },
  621. //格式化表内容
  622. formatHeaderType(list) {
  623. let arr = tools.copyArr(list);
  624. let data = showTools.headerTypeFilter(
  625. arr,
  626. "equipment",
  627. this.onlyRead,
  628. this.showType,
  629. true
  630. );
  631. if (this.showParts) {
  632. data.unshift(
  633. {
  634. data: "caozuo",
  635. renderer: tools.lookDetails,
  636. readOnly: true
  637. },
  638. {
  639. data: "linkEquipLocalName",
  640. readOnly: true,
  641. renderer: tools.LinkEquipLocalName
  642. },
  643. {
  644. data: "linkSystem",
  645. renderer: text.systemList,
  646. readOnly: true
  647. },
  648. {
  649. data: "count",
  650. readOnly: true,
  651. renderer: tools.lookDetails
  652. }
  653. );
  654. } else {
  655. data.unshift(
  656. {
  657. data: "caozuo",
  658. renderer: tools.lookDetails,
  659. readOnly: true
  660. },
  661. {
  662. data: "linkEquipLocalName",
  663. readOnly: true,
  664. renderer: tools.LinkEquipLocalName
  665. },
  666. {
  667. data: "linkSystem",
  668. renderer: text.systemList,
  669. readOnly: true
  670. }
  671. );
  672. }
  673. if (this.showType == "all" && this.showParts) {
  674. data.splice(6, 0, {
  675. data: "flowBuild",
  676. renderer: tools.customDropdownRenderer,
  677. editor: "chosen",
  678. chosenOptions: {
  679. data: this.buildFloorData
  680. },
  681. readOnly: this.onlyRead
  682. });
  683. } else if (this.showType == "all" && !this.showParts) {
  684. data.splice(5, 0, {
  685. data: "flowBuild",
  686. renderer: tools.customDropdownRenderer,
  687. editor: "chosen",
  688. chosenOptions: {
  689. data: this.buildFloorData
  690. },
  691. readOnly: this.onlyRead
  692. });
  693. }
  694. return data;
  695. },
  696. //初始化插件
  697. initTable() {
  698. var container = document.getElementById("handsontable");
  699. let winHeight = document.documentElement.clientHeight;
  700. if (this.hot) {
  701. this.hot.destroy();
  702. this.hot = null;
  703. }
  704. this.hot = new Handsontable(container, {
  705. data: this.tableData,
  706. fixedColumnsLeft: this.showParts ? 6 : 5,
  707. colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
  708. columns: this.formatHeaderType(this.tableHeader), //数据显示格式
  709. filters: true,
  710. maxRows: this.tableData.length,
  711. height: winHeight - 335,
  712. columnSorting: true, //添加排序
  713. sortIndicator: true, //添加排序
  714. renderAllRows: true,
  715. // colWidths: 200,
  716. autoColumnSize: true,
  717. language: "zh-CN",
  718. manualColumnResize: true,
  719. manualColumnMove: true,
  720. dropdownMenu: [
  721. "filter_by_condition",
  722. "filter_by_value",
  723. "filter_action_bar"
  724. ],
  725. contextMenu: this.onlyRead
  726. ? false
  727. : {
  728. items: {
  729. remove_row: {
  730. name: "删除选中设备"
  731. }
  732. }
  733. },
  734. // 事件
  735. afterChange: this.handleUpdataTable, //修改后
  736. afterFilter: this.trimmedRows, //排序前
  737. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  738. afterOnCellMouseDown: this.eventClick //鼠标点击
  739. });
  740. let pro = document.getElementById("hot-display-license-info");
  741. if (!!pro) {
  742. pro.parentNode.removeChild(pro);
  743. }
  744. this.isLoading = false;
  745. },
  746. //表格中的点击
  747. eventClick(el, rowArr) {
  748. //点击的是表头
  749. if (rowArr.row < 0) {
  750. return;
  751. }
  752. //被筛选过后的数组
  753. let trimmedArr = this.trimmedRows();
  754. //是否启用了排序
  755. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  756. if (trimmedArr.length && isSort) {
  757. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  758. .__arrayMap;
  759. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  760. this.getInfors(
  761. infos,
  762. {row: sortArr[rowArr.row], col: rowArr.col},
  763. el
  764. );
  765. } else if (isSort) {
  766. //排序后的数组
  767. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  768. let infos = this.tableData[sortArr[rowArr.row]];
  769. this.getInfors(
  770. infos,
  771. {row: sortArr[rowArr.row], col: rowArr.col},
  772. el
  773. );
  774. } else if (trimmedArr.length) {
  775. let infos = this.tableData[trimmedArr[rowArr.row]];
  776. this.getInfors(
  777. infos,
  778. {row: trimmedArr[rowArr.row], col: rowArr.col},
  779. el
  780. );
  781. } else {
  782. let infos = this.tableData[rowArr.row];
  783. this.getInfors(infos, rowArr, el);
  784. }
  785. },
  786. // 更新
  787. handleUpdataTable(changeData, source) {
  788. if (!this.onlyRead && source != "ObserveChanges.change") {
  789. if (changeData) {
  790. let trimmedArr = this.trimmedRows();
  791. let param = handsonUtils.getParam(
  792. changeData,
  793. source,
  794. this.hot,
  795. trimmedArr
  796. );
  797. let data = [];
  798. for (let i = 0; i < param.length; i++) {
  799. data.push(param[i]);
  800. }
  801. //如果data中包含/且data长度为1,将其转换成.
  802. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  803. changeData[0][1] = changeData[0][1].split("/").join(".");
  804. }
  805. //存在data进行修改请求
  806. if (data && data.length) {
  807. this.updateBusiness(data, changeData);
  808. }
  809. }
  810. }
  811. },
  812. //删除设备
  813. handleDeleteTableRow() {
  814. let params = tools.differenceArr(this.tableData, this.copyMain);
  815. let _this = this;
  816. if (params.length < 1) {
  817. return;
  818. }
  819. let param = [];
  820. params.map(item => {
  821. this.deleteCode = item.classCode;
  822. param.push({id: item.id});
  823. });
  824. this.$confirm("此操作将删除设备,是否继续?", "提示", {
  825. confirmButtonText: "确定",
  826. cancelButtonText: "取消",
  827. type: "warning"
  828. })
  829. .then(() => {
  830. this.removeDevice(param);
  831. })
  832. .catch(() => {
  833. this.reset();
  834. this.$message("取消删除");
  835. });
  836. },
  837. // 删除设备
  838. async removeDevice(param) {
  839. await deleteEquip(param, res => {
  840. this.$message.success("删除成功");
  841. this.$emit("close", {code: this.deleteCode});
  842. // this.getTableData()
  843. });
  844. },
  845. // 更新
  846. updateBusiness(data, change) {
  847. let param = {
  848. content: [],
  849. projection: []
  850. },
  851. keyList = [];
  852. //生成要修改字段列表
  853. change.map(item => {
  854. let key = item[1].split(".")[0];
  855. if (key == "flowBuild" && keyList.indexOf(key) == -1) {
  856. keyList.push("buildingId", "floorId");
  857. param.projection.push("buildingId", "floorId");
  858. }
  859. if (item[1] && keyList.indexOf(key) == -1 && item[1] != "propertyId") {
  860. keyList.push(key);
  861. }
  862. if (
  863. item[1] &&
  864. item[3] == "" &&
  865. param.projection.indexOf(key) == -1 &&
  866. item[1] != "propertyId"
  867. ) {
  868. param.projection.push(key);
  869. keyList.push(item[1])
  870. }
  871. });
  872. //生成对应修改数据
  873. data.map((item, index) => {
  874. keyList.map(value => {
  875. if (value == "buildingId") {
  876. let itemData = tools.dataForKey(item, "flowBuild");
  877. if (itemData == "") {
  878. tools.setDataForKey(item, "buildingId", null);
  879. tools.setDataForKey(item, "floorId", null);
  880. } else {
  881. let BuildingId = itemData.split("-")[0];
  882. let FloorId = itemData.split("-")[1];
  883. if (BuildingId && FloorId) {
  884. tools.setDataForKey(item, "buildingId", BuildingId);
  885. tools.setDataForKey(item, "floorId", FloorId);
  886. } else if (BuildingId && !FloorId) {
  887. tools.setDataForKey(item, "buildingId", BuildingId);
  888. tools.setDataForKey(item, "floorId", null);
  889. }
  890. }
  891. } else {
  892. let itemData = tools.dataForKey(item, value);
  893. tools.setDataForKey(item, value, itemData == "" ? null : itemData);
  894. }
  895. });
  896. param.content.push(item);
  897. });
  898. updateEquip(param, res => {
  899. });
  900. },
  901. //修改设备类型
  902. changeCader() {
  903. if (this.mess.deviceId) {
  904. let param = {
  905. data: {
  906. filters: `equipCode='${this.mess.deviceId}'`,
  907. pageNumber: 1,
  908. pageSize: 50
  909. }
  910. };
  911. getEquipBelongs(param, res => {
  912. if (res.content.length) {
  913. this.deviceType.assetType = res.content[0].family;
  914. this.deviceType.assetName = res.content[0].familyName;
  915. }
  916. });
  917. }
  918. },
  919. // 接受维护信息传来的code,显示弹窗
  920. fourVendors(code) {
  921. this.firmDataType = "dialog";
  922. switch (code) {
  923. //品牌型号弹窗
  924. case "dpManufacturerId":
  925. // this.dataFirmType = 'dia'
  926. this.myDialog.firm = true;
  927. break;
  928. //供应商信息弹窗
  929. case "dpSupplierId":
  930. this.myDialog.supplier = true;
  931. break;
  932. //维修商信息弹窗
  933. case "dpMaintainerId":
  934. this.myDialog.maintainer = true;
  935. break;
  936. //保险公司信息
  937. case "dpInsurerId":
  938. this.myDialog.insurer = true;
  939. break;
  940. }
  941. },
  942. forValue(arr, val) {
  943. let enclosure = [];
  944. arr &&
  945. arr.length &&
  946. arr.map(i => {
  947. if (i.path == val) {
  948. enclosure = i.value;
  949. } else {
  950. enclosure = []
  951. }
  952. });
  953. return enclosure;
  954. },
  955. multiples(val) {
  956. this.firmDataType = "dialog";
  957. switch (val) {
  958. case "infos.insuranceFile": //保险文件
  959. this.filesArr = this.forValue(this.newEnclosure, val)
  960. this.infoType = val;
  961. this.myDialog.uploadFiles = true;
  962. break;
  963. case "infos.archive": //设备文档
  964. this.filesArr = this.forValue(this.newEnclosure, val)
  965. this.infoType = val;
  966. this.myDialog.uploadFiles = true;
  967. break;
  968. case "infos.checkReport": //安装质检报告
  969. this.filesArr = this.forValue(this.newEnclosure, val)
  970. this.infoType = val;
  971. this.myDialog.uploadFiles = true;
  972. break;
  973. case "infos.maintainManual": //维修保养手册
  974. this.filesArr = this.forValue(this.newEnclosure, val)
  975. this.infoType = val;
  976. this.myDialog.uploadFiles = true;
  977. break;
  978. case "infos.approachingAcceptance": //进场验收单
  979. this.filesArr = this.forValue(this.newEnclosure, val)
  980. this.infoType = val;
  981. this.myDialog.uploadFiles = true;
  982. break;
  983. case "infos.acceptanceReport": //验收报告
  984. this.filesArr = this.forValue(this.newEnclosure, val)
  985. this.infoType = val;
  986. this.myDialog.uploadFiles = true;
  987. break;
  988. case "infos.operationManual": //操作说明书
  989. this.filesArr = this.forValue(this.newEnclosure, val)
  990. this.infoType = val;
  991. this.myDialog.uploadFiles = true;
  992. break;
  993. case "infos.originalCertificate": //原厂证明
  994. this.filesArr = this.forValue(this.newEnclosure, val)
  995. this.infoType = val;
  996. this.myDialog.uploadFiles = true;
  997. break;
  998. case "infos.testReport": //检测报告
  999. this.filesArr = this.forValue(this.newEnclosure, val)
  1000. this.infoType = val;
  1001. this.myDialog.uploadFiles = true;
  1002. break;
  1003. case "infos.productCertification": //产品合格证
  1004. this.filesArr = this.forValue(this.newEnclosure, val)
  1005. this.infoType = val;
  1006. this.myDialog.uploadFiles = true;
  1007. break;
  1008. case "infos.installInstruction": //安装说明书
  1009. this.filesArr = this.forValue(this.newEnclosure, val)
  1010. this.infoType = val;
  1011. this.myDialog.uploadFiles = true;
  1012. break;
  1013. case "infos.drawing": //设备图纸
  1014. this.filesArr = this.forValue(this.newEnclosure, val)
  1015. this.infoType = val;
  1016. this.myDialog.uploadFiles = true;
  1017. break;
  1018. case "infos.installDrawing": //安装图纸
  1019. this.filesArr = this.forValue(this.newEnclosure, val)
  1020. this.infoType = val;
  1021. this.myDialog.uploadFiles = true;
  1022. break;
  1023. case "infos.supplierContract": //供应合同
  1024. this.filesArr = this.forValue(this.newEnclosure, val)
  1025. this.infoType = val;
  1026. this.myDialog.uploadFiles = true;
  1027. break;
  1028. case "infos.installPic"://安装照片
  1029. this.imgsArr = this.forValue(this.newEnclosure, val)
  1030. this.infoType = val;
  1031. this.myDialog.uploadImgs = true;
  1032. break;
  1033. case "infos.nameplate"://设备铭牌照片
  1034. this.imgsArr = this.forValue(this.newEnclosure, val)
  1035. this.infoType = val;
  1036. this.myDialog.uploadImgs = true;
  1037. break;
  1038. case "infos.pic"://设备照片
  1039. this.picsArr = this.forValue(this.newEnclosure, val)
  1040. this.infoType = val;
  1041. this.myDialog.pic = true;
  1042. break;
  1043. case "infos.designIDGraph": //设计工况空调机组处理过程焓湿图(F2)
  1044. this.filesArr = this.forValue(this.newEnclosure, val)
  1045. this.infoType = val;
  1046. this.myDialog.uploadFiles = true;
  1047. break;
  1048. case "infos.fanCharacterCurve": //风机性能曲线(F1)
  1049. this.filesArr = this.forValue(this.newEnclosure, val)
  1050. this.infoType = val;
  1051. this.myDialog.uploadFiles = true;
  1052. break;
  1053. }
  1054. },
  1055. getInfors(infos, row, el) {
  1056. let val = this.hot.colToProp(row.col);
  1057. let inputData = this.inputMap[val];
  1058. this.row = row.row;
  1059. this.messKey = val;
  1060. this.firmDataType = "row";
  1061. lStorage.set("screen_data", {
  1062. path: this.$route.path,
  1063. data: {equip: infos}
  1064. });
  1065. switch (val) {
  1066. //操作
  1067. case "caozuo":
  1068. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  1069. // this.$message("开发中...")
  1070. this.$router.push({
  1071. path: "deviceDetails",
  1072. query: {
  1073. type: this.mess.deviceId,
  1074. equipId: infos.id,
  1075. equipName: infos.localName
  1076. ? infos.localName
  1077. : infos.name
  1078. ? infos.name
  1079. : "",
  1080. equipCode: infos.localId ? infos.localId : "",
  1081. data: this.tableData.map(item => {
  1082. return {
  1083. value: item.id,
  1084. label: item.localName
  1085. ? item.localName
  1086. : item.name
  1087. ? item.name
  1088. : ""
  1089. };
  1090. })
  1091. }
  1092. });
  1093. return false;
  1094. //设备二维码图片(infos.defaultQRCode)
  1095. // case "infos.defaultQRCode":
  1096. case "defaultQRCode":
  1097. this.qrcodeUrl = this.tableData[row.row][val];
  1098. if (this.qrcodeUrl) {
  1099. this.myDialog.qrcode = true;
  1100. } else {
  1101. this.$message("此设备没有设备二维码");
  1102. }
  1103. return false;
  1104. //BIM模型中坐标(bimLocation)
  1105. case "bimLocation":
  1106. this.bimcodeobj = this.tableData[row.row];
  1107. if (Object.keys(this.bimcodeobj).length > 0) {
  1108. this.myDialog.bimcode = true;
  1109. } else {
  1110. this.$message("此设备没有BIM模型中坐标");
  1111. }
  1112. return false;
  1113. //关联系统()
  1114. case "linkSystem":
  1115. this.curDevice = infos.EquipID;
  1116. this.systemList = this.tableData[row.row].linkSystem || [];
  1117. this.myDialog.systemType = true;
  1118. return false;
  1119. //关联资产()
  1120. case "linkEquipLocalName":
  1121. if (!this.onlyRead) {
  1122. this.myDialog.changeRea = true;
  1123. }
  1124. return false;
  1125. /**
  1126. * 关联资产后才可维护的信息点
  1127. */
  1128. // case 'flowBuild': //所属建筑楼层
  1129. // case 'infos.productDate': //生产日期
  1130. // case 'infos.serialNum': //出厂编号
  1131. // case 'infos.assetID': //资产编号
  1132. // case 'infos.purchasePrice': //采购价格
  1133. // case 'infos.insuranceNum': //保险单号
  1134. // case 'infos.insuranceFile': //保险文件
  1135. // if (!this.onlyRead) {
  1136. // const linkId = this.tableData[row.row].linkId;
  1137. // if (!linkId) { //未关联资产
  1138. // this.$confirm('您暂未关联设备对应的资产,该信息点不可编辑', '提示', {
  1139. // confirmButtonText: '我知道了',
  1140. // showCancelButton: false,
  1141. // type: 'warning',
  1142. // center: true
  1143. // }).then(() => {
  1144. // return false;
  1145. // });
  1146. // }
  1147. // }
  1148. // return false;
  1149. //保险文件--设备文档--安装质检报告
  1150. case "infos.insuranceFile": //保险文件(F2)
  1151. case "infos.archive": //设备文档(F2)
  1152. case "infos.checkReport": //安装质检报告(F2)
  1153. case "infos.maintainManual": //维修保养手册(F2)
  1154. case "infos.approachingAcceptance": //进场验收单(F2)
  1155. case "infos.acceptanceReport": //验收报告(F2)
  1156. case "infos.operationManual": //操作说明书(F2)
  1157. case "infos.originalCertificate": //原厂证明(F2)
  1158. case "infos.testReport": //检测报告(F2)
  1159. case "infos.productCertification": //产品合格证(F2)
  1160. case "infos.installInstruction": //安装说明书(F2)
  1161. case "infos.supplierContract": //供应合同(F2)
  1162. case "infos.drawing": //设备图纸(F2)
  1163. case "infos.installDrawing": //安装图纸(F2)
  1164. case "infos.designIDGraph": //设计工况空调机组处理过程焓湿图(F2)
  1165. case "infos.fanCharacterCurve": //风机性能曲线(F1)
  1166. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  1167. this.filesArr = IPSdata ? IPSdata : [];
  1168. if (!this.onlyRead || this.filesArr.length) {
  1169. this.myDialog.uploadFiles = true;
  1170. }
  1171. return false;
  1172. //安装照片--设备铭牌照片(F2)
  1173. case "infos.installPic":
  1174. case "infos.nameplate":
  1175. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  1176. this.imgsArr = SSPPdata ? SSPPdata : [];
  1177. if (!this.onlyRead || this.imgsArr.length) {
  1178. this.myDialog.uploadImgs = true;
  1179. }
  1180. return false;
  1181. //设备照片(F2)
  1182. case "infos.pic":
  1183. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  1184. this.picsArr = Pdata ? Pdata : [];
  1185. if (!this.onlyRead || this.picsArr.length) {
  1186. this.myDialog.pic = true;
  1187. }
  1188. return false;
  1189. //包含的部件字段
  1190. case "count":
  1191. let countUrl = this.onlyRead ? "/ledger/parts" : "/ledger/partsmanage";
  1192. this.$router.push({
  1193. path: countUrl,
  1194. query: {
  1195. deviceId: infos.id,
  1196. typeId: this.mess.deviceId,
  1197. pageNo: this.page.currentPage,
  1198. pageSize: this.page.size
  1199. }
  1200. });
  1201. return false;
  1202. default:
  1203. break;
  1204. }
  1205. if (!this.onlyRead && !inputData.editable) {
  1206. this.$message("该信息点的值为自动生成,不可人工维护!");
  1207. return false;
  1208. }
  1209. if (
  1210. !this.onlyRead &&
  1211. showTools.inputModeArr.indexOf(inputData.dataType) == "-1"
  1212. ) {
  1213. this.updateInfoPoint = val;
  1214. this.updateInput = tools.dataForKey(this.tableData[row.row], val);
  1215. this.myDialog.update = true;
  1216. return false;
  1217. }
  1218. },
  1219. //关闭临时维护弹窗回调
  1220. handleCloseUpdate() {
  1221. this.updateInputShow = false;
  1222. this.updateInfoPoint = "";
  1223. this.updateInput = "";
  1224. },
  1225. //更新临时维护信息点
  1226. handleClickUpdate() {
  1227. tools.setDataForKey(
  1228. this.tableData[this.row],
  1229. this.updateInfoPoint,
  1230. this.updateInput
  1231. );
  1232. this.handleUpdataTable(
  1233. [[this.row, this.updateInfoPoint, null, this.updateInput]],
  1234. "edit"
  1235. );
  1236. this.updateInputShow = false;
  1237. this.myDialog.update = false;
  1238. this.updateInput = "";
  1239. },
  1240. //获取被筛选掉的行号
  1241. trimmedRows() {
  1242. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  1243. let dataLength = this.tableData.length;
  1244. let dataArr = new Array();
  1245. for (let i = 0; i < dataLength; i++) {
  1246. dataArr.push(i);
  1247. }
  1248. if (plugin.length <= 0) {
  1249. dataArr = undefined;
  1250. } else {
  1251. dataArr = this.array_diff(dataArr, plugin);
  1252. }
  1253. return dataArr || [];
  1254. },
  1255. //去除数组中相同的元素
  1256. array_diff(a, b) {
  1257. for (var i = 0; i < b.length; i++) {
  1258. for (var j = 0; j < a.length; j++) {
  1259. if (a[j] == b[i]) {
  1260. a.splice(j, 1);
  1261. j = j - 1;
  1262. }
  1263. }
  1264. }
  1265. return a;
  1266. },
  1267. //修改关联的资产
  1268. changeProperty(val) {
  1269. this.setDataToMain(val.propertyId, "propertyId", this.row);
  1270. this.setDataToMain(
  1271. val.linkEquipLocalName,
  1272. "linkEquipLocalName",
  1273. this.row
  1274. );
  1275. },
  1276. //上传文件弹窗触发事件
  1277. fileChange(keys, type, file) {
  1278. if (type === "dialog") {
  1279. this.newEnclosure.forEach(i => {
  1280. if (i.path == keys) {
  1281. this.$set(i, "value", file);
  1282. }
  1283. return i;
  1284. });
  1285. } else {
  1286. this.setDataToMain(keys, this.messKey, this.row);
  1287. }
  1288. },
  1289. //上传图片弹窗触发事件
  1290. imgChange(keys, type, file) {
  1291. if (type === "dialog") {
  1292. this.newEnclosure.forEach(i => {
  1293. if (i.path == keys) {
  1294. this.$set(i, "value", file);
  1295. }
  1296. return i;
  1297. });
  1298. } else {
  1299. this.setDataToMain(keys, this.messKey, this.row);
  1300. }
  1301. },
  1302. //关联系统更改
  1303. changeSystemType(data) {
  1304. tools.setDataForKey(this.tableData[this.row], "linkSystem", data);
  1305. },
  1306. //设备图片弹窗改变事件
  1307. changePics(keys, type, file) {
  1308. if (type === "dialog") {
  1309. // this.information = keys
  1310. this.newEnclosure.forEach(i => {
  1311. if (i.path == keys) {
  1312. this.$set(i, "value", file);
  1313. }
  1314. return i;
  1315. });
  1316. } else {
  1317. this.setDataToMain(keys, this.messKey, this.row);
  1318. }
  1319. },
  1320. utilToKey(key, name, data, messName) {
  1321. if (key == name) {
  1322. this.setDataToMain(data[key], messName, this.row);
  1323. }
  1324. },
  1325. //判断是否有值,有值赋值
  1326. setDataToMain(data, key, row) {
  1327. if (!!data && data != "--") {
  1328. if (!!this.tableData[row]) {
  1329. tools.setDataForKey(this.tableData[row], key, data);
  1330. this.handleUpdataTable([[row, key, null, data]], "edit");
  1331. } else {
  1332. this.tableData[row] = {};
  1333. tools.setDataForKey(this.tableData[row], key, data);
  1334. }
  1335. } else {
  1336. tools.setDataForKey(this.tableData[row], key, "");
  1337. }
  1338. },
  1339. // 批量信息维护
  1340. Batch() {
  1341. this.firmDataType = "dialog";
  1342. this.$refs.batchDialogs.batchDialog = true;
  1343. },
  1344. // 批量维护设备位置
  1345. handleBatchEquipPoint() {
  1346. let query = {};
  1347. // 跳转批量维护设备位置页面
  1348. this.$router.push({
  1349. name: "BatchPointAssets",
  1350. params: query
  1351. })
  1352. },
  1353. upDataDevice(type, data1, data2) {
  1354. let param = {content: data1};
  1355. let param1 = {content: data2};
  1356. if (type === 1) {
  1357. //增量
  1358. //LedgerParam
  1359. let filterParam = this.filterCheck(param, "sole");
  1360. let filterParam1 = this.filterCheck(param1, "multiple");
  1361. if (filterParam) {
  1362. updateEquip(param, res => {
  1363. });
  1364. }
  1365. if (filterParam1) {
  1366. param1.content.map(i => {
  1367. i.equipId = i.id
  1368. delete i.id
  1369. return i
  1370. })
  1371. setTimeout(() => {
  1372. queryUpdate(param1, res => {
  1373. });
  1374. });
  1375. }
  1376. }
  1377. if (type === 2) {
  1378. //覆盖
  1379. let filterParams = this.filterCheck(param, "sole");
  1380. if (filterParams) {
  1381. updateEquip(param, res => {
  1382. });
  1383. }
  1384. }
  1385. setTimeout(() => {
  1386. this.getTableData();
  1387. this.getAllData();
  1388. }, 1000);
  1389. },
  1390. filterCheck(arr, type) {
  1391. if (type === "sole") {
  1392. for (let i of arr.content) {
  1393. for (let j in i.infos) {
  1394. if (Array.isArray(i.infos[j]) && i.infos[j].length < 1) {
  1395. delete i.infos[j]
  1396. }
  1397. }
  1398. return Object.keys(i.infos).length;
  1399. }
  1400. } else if (type === "multiple") {
  1401. let nArr = [];
  1402. arr.content.forEach(i => {
  1403. let {id, ...value} = i;
  1404. nArr.push({infos: value});
  1405. });
  1406. // nArr.map(i => {
  1407. // if (Array.isArray(i) && i.length < 1) {
  1408. // console.log(i)
  1409. // }
  1410. // })
  1411. for (let j of nArr) {
  1412. return Object.keys(j.infos).length;
  1413. }
  1414. }
  1415. }
  1416. },
  1417. watch: {
  1418. projectId() {
  1419. this.buildFloorData = [];
  1420. buildFloor.getData(this.buildFloorData);
  1421. this.tableData = [];
  1422. this.mess.deviceId = null;
  1423. this.page.total = 0;
  1424. },
  1425. showTypes: {
  1426. handler(newName, oldName) {
  1427. if (newName && newName[0] && newName[0].value) {
  1428. this.showType = newName[0].value;
  1429. } else {
  1430. this.showType = "";
  1431. }
  1432. },
  1433. immediate: true,
  1434. deep: true
  1435. }
  1436. }
  1437. };
  1438. </script>
  1439. <style lang="less">
  1440. .hanson-bar {
  1441. height: 40px;
  1442. padding: 5px 0;
  1443. font-size: 14px;
  1444. overflow: hidden;
  1445. margin-top: 0;
  1446. line-height: 40px;
  1447. .iconfont {
  1448. font-size: 12px;
  1449. }
  1450. }
  1451. .cancelButtonClass {
  1452. width: 180px;
  1453. }
  1454. </style>