device.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488
  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"></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. }).then(() => {
  1162. return false;
  1163. });
  1164. }
  1165. }
  1166. return false;
  1167. //保险文件--设备文档--安装质检报告
  1168. case "infos.insuranceFile": //保险文件(F2)
  1169. case "infos.archive": //设备文档(F2)
  1170. case "infos.checkReport": //安装质检报告(F2)
  1171. case "infos.maintainManual": //维修保养手册(F2)
  1172. case "infos.approachingAcceptance": //进场验收单(F2)
  1173. case "infos.acceptanceReport": //验收报告(F2)
  1174. case "infos.operationManual": //操作说明书(F2)
  1175. case "infos.originalCertificate": //原厂证明(F2)
  1176. case "infos.testReport": //检测报告(F2)
  1177. case "infos.productCertification": //产品合格证(F2)
  1178. case "infos.installInstruction": //安装说明书(F2)
  1179. case "infos.supplierContract": //供应合同(F2)
  1180. case "infos.drawing": //设备图纸(F2)
  1181. case "infos.installDrawing": //安装图纸(F2)
  1182. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  1183. this.filesArr = IPSdata ? IPSdata : [];
  1184. if (!this.onlyRead || this.filesArr.length) {
  1185. this.myDialog.uploadFiles = true;
  1186. }
  1187. return false;
  1188. //安装照片--设备铭牌照片(F2)
  1189. case "infos.installPic":
  1190. case "infos.nameplate":
  1191. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  1192. this.imgsArr = SSPPdata ? SSPPdata : [];
  1193. if (!this.onlyRead || this.imgsArr.length) {
  1194. this.myDialog.uploadImgs = true;
  1195. }
  1196. return false;
  1197. //设备照片(F2)
  1198. case "infos.pic":
  1199. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  1200. this.picsArr = Pdata ? Pdata : [];
  1201. if (!this.onlyRead || this.picsArr.length) {
  1202. this.myDialog.pic = true;
  1203. }
  1204. return false;
  1205. //包含的部件字段
  1206. case "count":
  1207. let countUrl = this.onlyRead ? "/ledger/parts" : "/ledger/partsmanage";
  1208. this.$router.push({
  1209. path: countUrl,
  1210. query: {
  1211. deviceId: infos.id,
  1212. typeId: this.mess.deviceId,
  1213. pageNo: this.page.currentPage,
  1214. pageSize: this.page.size
  1215. }
  1216. });
  1217. return false;
  1218. default:
  1219. break;
  1220. }
  1221. if (!this.onlyRead && !inputData.editable) {
  1222. this.$message("该信息点的值为自动生成,不可人工维护!");
  1223. return false;
  1224. }
  1225. if (
  1226. !this.onlyRead &&
  1227. showTools.inputModeArr.indexOf(inputData.dataType) == "-1"
  1228. ) {
  1229. this.updateInfoPoint = val;
  1230. this.updateInput = tools.dataForKey(this.tableData[row.row], val);
  1231. this.myDialog.update = true;
  1232. return false;
  1233. }
  1234. },
  1235. //关闭临时维护弹窗回调
  1236. handleCloseUpdate() {
  1237. this.updateInputShow = false;
  1238. this.updateInfoPoint = "";
  1239. this.updateInput = "";
  1240. },
  1241. //更新临时维护信息点
  1242. handleClickUpdate() {
  1243. tools.setDataForKey(
  1244. this.tableData[this.row],
  1245. this.updateInfoPoint,
  1246. this.updateInput
  1247. );
  1248. this.handleUpdataTable(
  1249. [[this.row, this.updateInfoPoint, null, this.updateInput]],
  1250. "edit"
  1251. );
  1252. this.updateInputShow = false;
  1253. this.myDialog.update = false;
  1254. this.updateInput = "";
  1255. },
  1256. //获取被筛选掉的行号
  1257. trimmedRows() {
  1258. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  1259. let dataLength = this.tableData.length;
  1260. let dataArr = new Array();
  1261. for (let i = 0; i < dataLength; i++) {
  1262. dataArr.push(i);
  1263. }
  1264. if (plugin.length <= 0) {
  1265. dataArr = undefined;
  1266. } else {
  1267. dataArr = this.array_diff(dataArr, plugin);
  1268. }
  1269. return dataArr || [];
  1270. },
  1271. //去除数组中相同的元素
  1272. array_diff(a, b) {
  1273. for (var i = 0; i < b.length; i++) {
  1274. for (var j = 0; j < a.length; j++) {
  1275. if (a[j] == b[i]) {
  1276. a.splice(j, 1);
  1277. j = j - 1;
  1278. }
  1279. }
  1280. }
  1281. return a;
  1282. },
  1283. //修改关联的资产
  1284. changeProperty(val) {
  1285. this.setDataToMain(val.propertyId, "propertyId", this.row);
  1286. this.setDataToMain(
  1287. val.linkEquipLocalName,
  1288. "linkEquipLocalName",
  1289. this.row
  1290. );
  1291. },
  1292. //上传文件弹窗触发事件
  1293. fileChange(keys, type, file) {
  1294. if (type === "dialog") {
  1295. // this.information = keys
  1296. this.newEnclosure.forEach(i => {
  1297. if (i.path == keys) {
  1298. this.$set(i, "value", file);
  1299. }
  1300. return i;
  1301. });
  1302. } else {
  1303. this.setDataToMain(keys, this.messKey, this.row);
  1304. }
  1305. },
  1306. //上传图片弹窗触发事件
  1307. imgChange(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. //关联系统更改
  1321. changeSystemType(data) {
  1322. tools.setDataForKey(this.tableData[this.row], "linkSystem", data);
  1323. },
  1324. //设备图片弹窗改变事件
  1325. changePics(keys, type, file) {
  1326. if (type === "dialog") {
  1327. // this.information = keys
  1328. this.newEnclosure.forEach(i => {
  1329. if (i.path == keys) {
  1330. this.$set(i, "value", file);
  1331. }
  1332. return i;
  1333. });
  1334. } else {
  1335. this.setDataToMain(keys, this.messKey, this.row);
  1336. }
  1337. },
  1338. utilToKey(key, name, data, messName) {
  1339. if (key == name) {
  1340. this.setDataToMain(data[key], messName, this.row);
  1341. }
  1342. },
  1343. //判断是否有值,有值赋值
  1344. setDataToMain(data, key, row) {
  1345. if (!!data && data != "--") {
  1346. if (!!this.tableData[row]) {
  1347. tools.setDataForKey(this.tableData[row], key, data);
  1348. this.handleUpdataTable([[row, key, null, data]], "edit");
  1349. } else {
  1350. this.tableData[row] = {};
  1351. tools.setDataForKey(this.tableData[row], key, data);
  1352. }
  1353. } else {
  1354. tools.setDataForKey(this.tableData[row], key, "");
  1355. }
  1356. },
  1357. // 批量信息维护
  1358. Batch() {
  1359. this.firmDataType = "dialog";
  1360. this.$refs.batchDialogs.batchDialog = true;
  1361. },
  1362. // 批量维护设备位置
  1363. handleBatchEquipPoint() {
  1364. let query = {};
  1365. // 跳转批量维护设备位置页面
  1366. this.$router.push({
  1367. name: "BatchPointAssets",
  1368. params: query
  1369. })
  1370. },
  1371. upDataDevice(type, data1, data2) {
  1372. let param = {content: data1};
  1373. let param1 = {content: data2};
  1374. if (type === 1) {
  1375. //增量
  1376. //LedgerParam
  1377. let filterParam = this.filterCheck(param, "sole");
  1378. let filterParam1 = this.filterCheck(param1, "multiple");
  1379. if (filterParam) {
  1380. updateEquip(param, res => {
  1381. });
  1382. }
  1383. if (filterParam1) {
  1384. param1.content.map(i => {
  1385. i.equipId = i.id
  1386. delete i.id
  1387. return i
  1388. })
  1389. setTimeout(() => {
  1390. queryUpdate(param1, res => {
  1391. });
  1392. });
  1393. }
  1394. }
  1395. if (type === 2) {
  1396. //覆盖
  1397. let filterParams = this.filterCheck(param, "sole");
  1398. if (filterParams) {
  1399. updateEquip(param, res => {
  1400. });
  1401. }
  1402. }
  1403. setTimeout(() => {
  1404. this.getTableData();
  1405. this.getAllData();
  1406. }, 1000);
  1407. },
  1408. filterCheck(arr, type) {
  1409. if (type === "sole") {
  1410. for (let i of arr.content) {
  1411. for (let j in i.infos) {
  1412. if (Array.isArray(i.infos[j]) && i.infos[j].length < 1) {
  1413. delete i.infos[j]
  1414. }
  1415. }
  1416. return Object.keys(i.infos).length;
  1417. }
  1418. } else if (type === "multiple") {
  1419. let nArr = [];
  1420. arr.content.forEach(i => {
  1421. let {id, ...value} = i;
  1422. nArr.push({infos: value});
  1423. });
  1424. // nArr.map(i => {
  1425. // if (Array.isArray(i) && i.length < 1) {
  1426. // console.log(i)
  1427. // }
  1428. // })
  1429. for (let j of nArr) {
  1430. return Object.keys(j.infos).length;
  1431. }
  1432. }
  1433. }
  1434. },
  1435. watch: {
  1436. projectId() {
  1437. this.buildFloorData = [];
  1438. buildFloor.getData(this.buildFloorData);
  1439. this.tableData = [];
  1440. this.mess.deviceId = null;
  1441. this.page.total = 0;
  1442. },
  1443. showTypes: {
  1444. handler(newName, oldName) {
  1445. if (newName && newName[0] && newName[0].value) {
  1446. this.showType = newName[0].value;
  1447. } else {
  1448. this.showType = "";
  1449. }
  1450. },
  1451. immediate: true,
  1452. deep: true
  1453. }
  1454. }
  1455. };
  1456. </script>
  1457. <style lang="less">
  1458. .hanson-bar {
  1459. height: 40px;
  1460. padding: 5px 0;
  1461. font-size: 14px;
  1462. overflow: hidden;
  1463. margin-top: 0;
  1464. line-height: 40px;
  1465. .iconfont {
  1466. font-size: 12px;
  1467. }
  1468. }
  1469. .cancelButtonClass {
  1470. width: 180px;
  1471. }
  1472. </style>