system.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <template>
  2. <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;">
  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)" style="width:100px;margin-right:20px;vertical-align:bottom;">
  8. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  9. </el-select>
  10. <el-select v-model="showType" @change="initTable" style="width:100px;margin-right:10px;vertical-align:bottom;">
  11. <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
  12. </el-select>
  13. <el-button size="small" style="width: 80px" @click="addDevice" icon="iconfont icon-tianjia">添加系统</el-button>
  14. <el-button size="small" style="width: 80px" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
  15. <el-button size="small" style="width: 80px" @click="undo" icon="iconfont icon-undo">撤销</el-button>
  16. </div>
  17. <qrcode :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
  18. <upload-files-dialog ref="upload" @changeFile="fileChange" :keysArr="filesArr" :dialog="myDialog"></upload-files-dialog>
  19. <upload-img-dialog @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"></upload-img-dialog>
  20. <pic-dialog :dialog="myDialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
  21. <div class="center middle_sty" style="height: 91%" v-show="!mess.deviceId && (!tableData || !tableData.length)">
  22. <p><i class="icon-wushuju iconfont"></i>请选择系统类型</p>
  23. </div>
  24. <div class="center middle_sty" style="height: 91%" v-show="mess.deviceId && (!tableData || !tableData.length)">
  25. <p><i class="icon-wushuju iconfont"></i>暂无数据</p>
  26. </div>
  27. <div v-show="mess.deviceId && tableData && tableData.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
  28. <div v-show="mess.deviceId && tableData && tableData.length" class="right">
  29. <my-pagination @change="getTableData" :page="page"></my-pagination>
  30. </div>
  31. <!-- <dialog-assets :assetType="[this.mess.deviceId]" @close="getClose" v-if="myDialog.addDevice" ref="assets" :dialog="myDialog"></dialog-assets> -->
  32. <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
  33. <system-relevance @close="reset" :id="systemId" :dialog="myDialog"></system-relevance>
  34. <!-- 不支持的输入方式 -->
  35. <el-dialog title="临时维护信息点" :visible.sync="myDialog.update" @close="handleCloseUpdate" width="670px">
  36. <el-row>
  37. 该信息点未定义对应组件,现在维护数据不确定后续是否可用。如确实需要维护,请点击<el-link @click="updateInputShow = true" type="primary" :underline="false">继续维护</el-link>。
  38. </el-row>
  39. <el-row style="margin-top:20px;" v-show="updateInputShow">
  40. <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 8}" placeholder="请输入内容" v-model="updateInput"></el-input>
  41. </el-row>
  42. <span slot="footer" class="dialog-footer">
  43. <el-button @click="myDialog.update = false">取 消</el-button>
  44. <el-button type="primary" @click="handleClickUpdate">确 认</el-button>
  45. </span>
  46. </el-dialog>
  47. <!-- 关联楼层 -->
  48. <editSysfloor ref="editFloor" @relateSuccess="relateSuccess"></editSysfloor>
  49. <!-- 新增系统 -->
  50. <el-dialog title="确定新增系统的类型" :visible.sync="myDialog.addDevice" width="30%">
  51. <el-row>
  52. <my-cascader ref="cascader" @change="changeAddType" :all="true"></my-cascader>
  53. </el-row>
  54. <span slot="footer" class="dialog-footer">
  55. <el-button type="primary" @click="toAddDevice">下 一 步</el-button>
  56. </span>
  57. </el-dialog>
  58. </div>
  59. </template>
  60. <script>
  61. import {
  62. BeatchQueryParam,
  63. getDataDictionary,
  64. querySysLinkBuild,
  65. updateGeneralSys,
  66. deleteGeneralSys
  67. } from "@/api/scan/request"
  68. import myCascader from "@/components/ledger/lib/system";
  69. import tools from "@/utils/scan/tools";
  70. import handsonUtils from "@/utils/scan/hasontableUtils"
  71. import showTools from "@/utils/handsontable/notShow"
  72. import qrcode from "@/components/business_space/lib/qrcode"
  73. import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog"
  74. import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
  75. import picDialog from "@/components/business_space/dialogs/list/picDialog"
  76. import myPagination from "@/components/common/myPagination"
  77. import dialogAssets from "@/components/ledger/addDialog/dialogSystem"
  78. import detailsDialog from "@/components/business_space/lib/detailsDia"
  79. import systemRelevance from "@/components/ledger/tableTransfers"
  80. import Handsontable from "handsontable-pro"
  81. import text from "@/utils/handsontable/mainText"
  82. import 'handsontable-pro/dist/handsontable.full.css'
  83. import editSysfloor from "@/components/ledger/lib/editSysFloor";
  84. import { mapGetters } from "vuex";
  85. export default {
  86. components: {
  87. qrcode, //二维码页面
  88. uploadFilesDialog,
  89. uploadImgDialog,
  90. picDialog,
  91. myPagination,
  92. dialogAssets,
  93. detailsDialog,
  94. systemRelevance,
  95. myCascader,
  96. editSysfloor
  97. },
  98. computed: {
  99. ...mapGetters("layout", ["projectId", "secret", "userId"]),
  100. showTypes() {
  101. return this.onlyRead ?
  102. [{ value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }] :
  103. [{ value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }]
  104. }
  105. },
  106. data() {
  107. return {
  108. options: [{
  109. value: true,
  110. label: '只读模式'
  111. }, {
  112. value: false,
  113. label: '编辑模式'
  114. }],
  115. tableData: [],
  116. mess: {},
  117. tableHeader: null,
  118. page: {
  119. size: 50,
  120. sizes: [10, 30, 50, 100, 150, 200],
  121. total: 0,
  122. currentPage: 1
  123. },
  124. myDialog: {
  125. qrcode: false, //二维码弹窗
  126. firm: false, //厂商弹窗
  127. supply: false, //选择供应合同
  128. supplier: false, //供应商选择
  129. guarantee: false, //选择保单
  130. maintainer: false, //选择维修商
  131. insurer: false, //选择保险公司
  132. uploadFiles: false,//上传文件
  133. uploadImgs: false,//上传单个图片
  134. pic: false, //多个图片
  135. addDevice: false,
  136. details: false,//详情页
  137. relevance: false,//关联设备
  138. update: false,//临时维护信息点
  139. },
  140. row: null,//被修改的row
  141. filesArr: [],//保存临时的文件key
  142. messKey: null,
  143. imgsArr: [],//临时保存的图片key数组
  144. picsArr: [],//临时设备图片keys数组
  145. noShowList: ["SysID", "SysName"],
  146. copyMain: null,
  147. iframeSrc: "",
  148. systemId: "",
  149. onlyRead: true,
  150. showType: 'Visible',
  151. linkNameFalg: false,
  152. qrcodeUrl: "",//二维码图片地址
  153. loading: false,
  154. addData: {}, //添加设备选择的设备类型
  155. inputMap: {
  156. flowBuild: 'D1'
  157. }, //信息点和输入方式映射表
  158. updateInputShow: false, //是否显示临时维护输入框
  159. updateInfoPoint: '',//临时维护信息点
  160. updateInput: '', //临时维护信息点值
  161. };
  162. },
  163. created() {
  164. },
  165. mounted() { },
  166. methods: {
  167. //触发父组件change
  168. getClose(val) {
  169. this.$emit("close", val)
  170. },
  171. //获取表头
  172. getHeaderData(code) {
  173. this.mess = code
  174. if (this.mess.deviceId) {
  175. let params = {
  176. data: {
  177. Orders: "sort asc, InfoPointName desc",
  178. PageNumber: 1,
  179. PageSize: 1000
  180. },
  181. type: this.mess.deviceId
  182. }
  183. getDataDictionary(params, res => {
  184. this.tableHeader = res.Content;
  185. this.tableHeader.forEach(item => {
  186. if (item.Path && item.InputMode) {
  187. this.inputMap[item.Path] = item.InputMode
  188. }
  189. })
  190. this.getTableData()
  191. });
  192. }
  193. },
  194. changeWatch() {
  195. this.reset()
  196. },
  197. //获取主体数据
  198. getTableData() {
  199. let _this = this
  200. this.loading = true
  201. if (!!this.mess.deviceId) {
  202. let param = {
  203. data: {
  204. PageSize: this.page.size,
  205. Orders: "createTime desc, SysLocalName desc, SysLocalID desc, SysID desc",
  206. PageNumber: this.page.currentPage,
  207. Filters: `category='${this.mess.deviceId}'`
  208. }
  209. }
  210. if (this.mess.buildId == "noKnow") {
  211. param.buildingId = 1;
  212. } else if (this.mess.buildId && this.mess.buildId != "all") {
  213. param.buildingId = this.mess.buildId;
  214. }
  215. if (this.mess.floorId == "noKnow") {
  216. param.floorId = 1;
  217. } else if (this.mess.floorId && this.mess.floorId != "all") {
  218. param.floorId = this.mess.floorId;
  219. }
  220. querySysLinkBuild(param, res => {
  221. this.loading = false;
  222. _this.tableData = res.Content;
  223. _this.copyMain = tools.deepCopy(res.Content);
  224. _this.page.total = res.Total;
  225. if (res.Content && res.Content.length) {
  226. if (this.onlyRead) {
  227. this.getBatch(res.Content)
  228. }
  229. _this.initTable();
  230. }
  231. })
  232. }
  233. },
  234. //撤回
  235. undo() {
  236. this.hot.undo();
  237. },
  238. //刷新
  239. reset() {
  240. if (this.mess.deviceId) {
  241. this.getTableData();
  242. } else {
  243. this.$message({
  244. message: '请选择系统类型',
  245. type: 'warning'
  246. });
  247. }
  248. },
  249. //添加设备
  250. addDevice() {
  251. this.myDialog.addDevice = true
  252. if (this.mess.deviceId) {
  253. this.$nextTick(() => {
  254. this.$refs.cascader.setValue(this.mess.deviceId)
  255. })
  256. }
  257. },
  258. //下一步
  259. toAddDevice() {
  260. if (this.addData.Category) {
  261. this.$router.push({
  262. path: "/ledger/systemadd",
  263. query: this.addData
  264. });
  265. }
  266. },
  267. //选择设备类型-添加设备
  268. changeAddType(val) {
  269. this.addData.Category = val.Category;
  270. this.addData.CategoryName = val.CategoryName;
  271. this.addData.showType = this.showType;
  272. },
  273. //格式化表头
  274. formatHeaderData(list) {
  275. let arr = tools.copyArr(list)
  276. let data = showTools.headerTextFilter(arr, 'system', this.onlyRead, this.showType)
  277. data.unshift("操作");
  278. if (this.showType == "all") {
  279. data.splice(3, 0, "所属建筑楼层")
  280. }
  281. return data;
  282. },
  283. //格式化表内容
  284. formatHeaderType(list) {
  285. let arr = tools.copyArr(list)
  286. let data = showTools.headerTypeFilter(arr, 'system', this.onlyRead, this.showType)
  287. data.unshift(
  288. {
  289. data: "caozuo",
  290. renderer: tools.lookDetails,
  291. readOnly: true
  292. },
  293. // {
  294. // data: "Count",
  295. // renderer: tools.num,
  296. // readOnly: true
  297. // }
  298. );
  299. if (this.onlyRead) {
  300. data.map(item => {
  301. item.readOnly = true
  302. })
  303. }
  304. if (this.showType == "all") {
  305. data.splice(3, 0, {
  306. data: "BuildingFloorInfoList",
  307. renderer: text.sysInBuildFloor,
  308. readOnly: this.onlyRead
  309. })
  310. }
  311. return data;
  312. },
  313. //获取动态参数
  314. getBatch(data) {
  315. let param = {
  316. secret: this.secret,
  317. ProjId: this.projectId,
  318. data: {
  319. criterias: []
  320. }
  321. }
  322. //一级遍历list
  323. this.tableHeader.map(head => {
  324. //如果一级标签为动态参数或者设定参数放入数据等待请求
  325. if (
  326. head.InputMode == "L" ||
  327. head.InputMode == "L1" ||
  328. head.InputMode == "L2" ||
  329. head.InputMode == "M"
  330. ) {
  331. data.map(item => {
  332. let cur = tools.dataForKey(item, head.Path);
  333. if (cur) {
  334. param.data.criterias.push({
  335. id: item.SysID,
  336. code: head.InfoPointCode
  337. });
  338. }
  339. });
  340. }
  341. })
  342. if (param.data.criterias.length) {
  343. BeatchQueryParam(param, res => {
  344. if (!this.onlyRead) {
  345. return false
  346. }
  347. this.tableData = data.map(item => {
  348. res.Content.map(child => {
  349. if (item.SysID == child.id) {
  350. if (!!child.data || child.data == 0) {
  351. this.tableHeader.map(head => {
  352. if (head.InfoPointCode == child.code) {
  353. tools.setDataForKey(item, head.Path, child.data);
  354. }
  355. });
  356. } else {
  357. this.tableHeader.map(head => {
  358. if (head.InfoPointCode == child.code) {
  359. tools.setDataForKey(
  360. item,
  361. head.Path,
  362. // child.error ? "表号功能号格式错误" : "表号功能号不存在"
  363. child.error ? child.value ? "表号功能号格式错误" : "表号功能号不存在" : "暂未采集到实时数据"
  364. );
  365. }
  366. });
  367. }
  368. }
  369. })
  370. return item
  371. })
  372. this.hot.loadData(this.tableData)
  373. })
  374. }
  375. },
  376. //初始化插件
  377. initTable() {
  378. var container = document.getElementById("handsontable");
  379. let winHeight = document.documentElement.clientHeight;
  380. if (this.hot) {
  381. this.hot.destroy();
  382. this.hot = null;
  383. }
  384. this.hot = new Handsontable(container, {
  385. data: this.tableData,
  386. fixedColumnsLeft: 3,
  387. colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
  388. columns: this.formatHeaderType(this.tableHeader), //数据显示格式
  389. filters: true,
  390. maxRows: this.tableData.length,
  391. height: winHeight - 335,
  392. columnSorting: true, //添加排序
  393. sortIndicator: true, //添加排序
  394. renderAllRows: true,
  395. // observeChanges: false, //启用observeChanges插件
  396. // colWidths: 200,
  397. autoColumnSize: true,
  398. language: "zh-CN",
  399. manualColumnResize: true,
  400. manualColumnMove: true,
  401. dropdownMenu: [
  402. "filter_by_condition",
  403. "filter_by_value",
  404. "filter_action_bar"
  405. ],
  406. contextMenu: this.onlyRead ? false :{
  407. items: {
  408. remove_row: {
  409. name: "删除该系统"
  410. }
  411. }
  412. },
  413. // 事件
  414. afterChange: this.handleUpdataTable, //修改后
  415. afterFilter: this.trimmedRows, //排序前
  416. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  417. afterOnCellMouseDown: this.eventClick //鼠标点击
  418. });
  419. let pro = document.getElementById("hot-display-license-info");
  420. if (!!pro) {
  421. pro.parentNode.removeChild(pro);
  422. }
  423. this.isLoading = false;
  424. },
  425. //表格中的点击
  426. eventClick(el, rowArr) {
  427. //点击的是表头
  428. if (rowArr.row < 0) {
  429. return;
  430. }
  431. //被筛选过后的数组
  432. let trimmedArr = this.trimmedRows();
  433. //是否启用了排序
  434. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  435. if (trimmedArr.length && isSort) {
  436. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  437. .__arrayMap;
  438. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  439. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
  440. } else if (isSort) {
  441. //排序后的数组
  442. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  443. let infos = this.tableData[sortArr[rowArr.row]];
  444. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
  445. } else if (trimmedArr.length) {
  446. let infos = this.tableData[trimmedArr[rowArr.row]];
  447. this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col });
  448. } else {
  449. let infos = this.tableData[rowArr.row];
  450. this.getInfors(infos, rowArr);
  451. }
  452. },
  453. handleUpdataTable(changeData, source) {
  454. if (!this.onlyRead && source != 'ObserveChanges.change') {
  455. if (changeData) {
  456. let trimmedArr = this.trimmedRows();
  457. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  458. let data = [];
  459. for (let i = 0; i < param.length; i++) {
  460. data.push(param[i]);
  461. }
  462. //如果data中包含/且data长度为1,将其转换成.
  463. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  464. changeData[0][1] = changeData[0][1].split("/").join(".")
  465. }
  466. //存在data进行修改请求
  467. if (data && data.length) {
  468. this.updateBusiness(data, changeData);
  469. }
  470. }
  471. }
  472. },
  473. //删除资产
  474. async handleDeleteTableRow() {
  475. this.$confirm('此操作将删除该系统, 是否继续?', '提示', {
  476. confirmButtonText: '确定',
  477. cancelButtonText: '取消',
  478. type: 'warning'
  479. }).then(() => {
  480. let params = tools.differenceArr(this.tableData, this.copyMain)
  481. let param = []
  482. params.map(item => {
  483. param.push({ SysID: item.SysID })
  484. })
  485. this.removeSys(param)
  486. }).catch(() => {
  487. this.getTableData()
  488. this.$message('取消删除');
  489. });
  490. },
  491. async removeSys(param) {
  492. await deleteGeneralSys(param, res => {
  493. this.$message.success("删除成功")
  494. this.$emit('close', '')
  495. this.getTableData()
  496. })
  497. },
  498. // 修改
  499. updateBusiness(data, change) {
  500. let param = {
  501. Content: [],
  502. Projection: []
  503. }, keyList = [];
  504. //生成要修改字段列表
  505. change.map(item => {
  506. let key = item[1].split(".")[0]
  507. if (item[1] && keyList.indexOf(key) == -1) {
  508. keyList.push(key);
  509. }
  510. if (item[1] && item[3] == "" && param.Projection.indexOf(key) == -1) {
  511. param.Projection.push(key);
  512. }
  513. });
  514. //生成对应修改数据
  515. data.map((item, index) => {
  516. keyList.map(value => {
  517. let itemData = tools.dataForKey(item, value);
  518. tools.setDataForKey(item, value, itemData == "" ? null : itemData);
  519. });
  520. param.Content.push(item);
  521. });
  522. updateGeneralSys(param, res => { });
  523. },
  524. //获取到了正确的信息
  525. getInfors(infos, row) {
  526. //其他的开始判断
  527. let val = this.hot.colToProp(row.col);
  528. let inputData = this.inputMap[val];
  529. this.systemId = infos.SysID
  530. this.row = row.row
  531. this.messKey = val
  532. switch (val) {
  533. //操作
  534. case 'caozuo':
  535. // window.open(`http://adm.sagacloud.cn:8058/system?id=${infos.id}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  536. // this.$message("开发中...")
  537. this.$router.push({
  538. path: "/ledger/systemDetail",
  539. query: { SysID: infos.SysID, Name: infos.SysLocalName || infos.SysName, SysType: infos.Category }
  540. })
  541. return false
  542. //设备二维码图片
  543. case 'EquipQRCode':
  544. this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
  545. if (!!this.qrcodeUrl) {
  546. this.myDialog.qrcode = true;
  547. } else {
  548. this.$message("此设备没有设备二维码");
  549. }
  550. return false
  551. //关联设备数量
  552. case 'Count':
  553. if (!this.onlyRead) {
  554. this.myDialog.relevance = true
  555. }
  556. return false
  557. case 'BuildingFloorInfoList':
  558. if (!this.onlyRead) {
  559. this.$refs.editFloor.showDialog(this.tableData[row.row]);
  560. }
  561. return false
  562. default:
  563. break;
  564. }
  565. if (!this.onlyRead && !inputData.Editable) {
  566. this.$message("该信息点的值为自动生成,不可人工维护!");
  567. return false;
  568. }
  569. if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
  570. this.updateInfoPoint = val;
  571. this.updateInput = tools.dataForKey(this.tableData[row.row], val);
  572. this.myDialog.update = true;
  573. return false;
  574. }
  575. },
  576. //关闭临时维护弹窗回调
  577. handleCloseUpdate() {
  578. this.updateInputShow = false
  579. this.updateInfoPoint = ''
  580. this.updateInput = ''
  581. },
  582. //更新临时维护信息点
  583. handleClickUpdate() {
  584. // this.$message("更新成功");
  585. tools.setDataForKey(this.tableData[this.row], this.updateInfoPoint, this.updateInput)
  586. this.handleUpdataTable([[this.row, this.updateInfoPoint, null, this.updateInput]], "edit")
  587. this.updateInputShow = false
  588. this.myDialog.update = false
  589. this.updateInput = ''
  590. },
  591. //关联建筑楼层成功
  592. relateSuccess(data) {
  593. this.getTableData()
  594. // tools.setDataForKey(this.tableData[this.row], "BuildingFloorInfoList", data)
  595. },
  596. //获取被筛选掉的行号
  597. trimmedRows() {
  598. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  599. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  600. let dataLength = this.tableData.length;
  601. let dataArr = new Array();
  602. for (let i = 0; i < dataLength; i++) {
  603. dataArr.push(i);
  604. }
  605. if (plugin.length <= 0) {
  606. dataArr = undefined;
  607. } else {
  608. dataArr = this.array_diff(dataArr, plugin);
  609. }
  610. return dataArr || [];
  611. // var DataArray = new Array();
  612. // for (var i = 0; i < plugin.length; i++) {
  613. // // 通过行号获取数据
  614. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  615. // }
  616. },
  617. //上传文件弹窗触发事件
  618. fileChange(keys) {
  619. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  620. // tools.setItem(this.deviceType.code, this.tableData)
  621. },
  622. //上传图片弹窗触发事件
  623. imgChange(keys) {
  624. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  625. // tools.setItem(this.deviceType.code, this.tableData)
  626. },
  627. //设备图片弹窗改变事件
  628. changePics(keys) {
  629. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  630. // tools.setItem(this.deviceType.code, this.tableData)
  631. },
  632. //判断是否有值,有值赋值
  633. setDataToMain(data, key, row) {
  634. if (!!data && data != '--') {
  635. if (!!this.tableData[row].infos) {
  636. //falg确定每个的是否有值
  637. let falg = false
  638. if (!this.tableData[row].infos[key]) {
  639. falg = true
  640. }
  641. //铭牌照片特殊处理
  642. if (key == 'Nameplate') {
  643. this.tableData[row].infos[key] = {
  644. "systemId": "dataPlatform",
  645. "name": "铭牌照片",
  646. "type": "image",
  647. "key": data
  648. }
  649. } else {
  650. this.tableData[row].infos[key] = data
  651. }
  652. if (falg) {
  653. this.updateBusiness([this.tableData[row]], [[0, "infos." + key, null, data]])
  654. }
  655. } else {
  656. this.tableData[row].infos = {}
  657. if (key == 'Nameplate') {
  658. this.tableData[row].infos[key] = {
  659. "systemId": "dataPlatform",
  660. "name": "铭牌照片",
  661. "type": "image",
  662. "key": data
  663. }
  664. } else {
  665. this.tableData[row].infos[key] = data
  666. }
  667. }
  668. } else {
  669. this.tableData[row].infos[key] = ''
  670. }
  671. }
  672. },
  673. watch: {
  674. projectId() {
  675. this.tableData = []
  676. this.mess.deviceId = null
  677. this.page.total = 0
  678. },
  679. showTypes: {
  680. handler(newName, oldName) {
  681. if (newName && newName[0] && newName[0].value) {
  682. this.showType = newName[0].value
  683. } else {
  684. this.showType = ""
  685. }
  686. },
  687. immediate: true,
  688. deep: true
  689. }
  690. }
  691. };
  692. </script>
  693. <style lang="less">
  694. .hanson-bar {
  695. height: 40px;
  696. padding: 5px 0;
  697. font-size: 14px;
  698. overflow: hidden;
  699. margin-top: 0;
  700. line-height: 40px;
  701. .iconfont {
  702. font-size: 12px;
  703. }
  704. }
  705. </style>