system.vue 24 KB

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