businessDialog.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. <!--
  2. 上传文件的弹窗
  3. -->
  4. <template>
  5. <div v-show="dialog.addDevice">
  6. <el-dialog
  7. :title="title"
  8. :center="isCenter"
  9. :visible.sync="dialog.addDevice"
  10. :width="width"
  11. :fullscreen="isFull"
  12. >
  13. <div id="addDevice">
  14. <div v-show="!isCenter">
  15. <my-cascader @change="changeCader"></my-cascader>
  16. </div>
  17. <div v-if="isCenter">
  18. <div>
  19. <div class="hanson-bar" style="overflow:hidden;">
  20. <el-button
  21. style="float:right;"
  22. size="small"
  23. @click="undo"
  24. icon="iconfont icon-undo"
  25. >撤销</el-button>
  26. <el-button
  27. style="float:right;"
  28. size="small"
  29. @click="reset"
  30. icon="iconfont icon-shuaxin"
  31. >刷新</el-button>
  32. <el-button style="float:right;" size="small" @click="addMain">增加</el-button>
  33. <el-input
  34. v-model="addNum"
  35. placeholder="增加个数"
  36. style="width:50px;float:right;"
  37. size="small"
  38. ></el-input>
  39. </div>
  40. <div v-show="main && main.length" id="myHandson" ref="myHandson"></div>
  41. </div>
  42. </div>
  43. </div>
  44. <span slot="footer" class="dialog-footer">
  45. <el-button type="primary" @click="addSpace">添加业务空间</el-button>
  46. </span>
  47. </el-dialog>
  48. <qrcode :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
  49. <firm ref="firm" :dialog="myDialog"></firm>
  50. <supply-dialog ref="supply" :dialog="myDialog"></supply-dialog>
  51. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
  52. <guarantee-dialog ref="guarantee" :dialog="myDialog"></guarantee-dialog>
  53. <upload-files-dialog
  54. ref="upload"
  55. @changeFile="fileChange"
  56. :keysArr="filesArr"
  57. :dialog="myDialog"
  58. ></upload-files-dialog>
  59. <upload-img-dialog @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"></upload-img-dialog>
  60. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="myDialog"></maintainer-dialog>
  61. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="myDialog"></insurer-dialog>
  62. <pic-dialog :dialog="myDialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
  63. </div>
  64. </template>
  65. <script>
  66. import myCascader from "@/components/business_space/lib/cascaders/assets";
  67. // import hansonTable from "@/components/business_space/dialogHanson/addDevice";
  68. import { getSpaceHeader } from "@/api/scan/request";
  69. import { mapGetters, mapActions } from "vuex";
  70. import tools from "@/utils/tools";
  71. import qrcode from "@/components/business_space/lib/qrcode";
  72. import firm from "@/components/business_space/dialogs/list/firm";
  73. import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog";
  74. import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog";
  75. import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog";
  76. import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog";
  77. import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog";
  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. let table = function (num) {
  82. let main = []
  83. for (let i = 0; i < num; i++) {
  84. main.push({})
  85. }
  86. return main
  87. }
  88. export default {
  89. components: {
  90. myCascader,
  91. // hansonTable,
  92. qrcode, //二维码页面
  93. firm, //
  94. supplyDialog,
  95. supplierDialog,
  96. guaranteeDialog,
  97. uploadFilesDialog,
  98. maintainerDialog,
  99. insurerDialog,
  100. uploadImgDialog,
  101. picDialog
  102. },
  103. props: {
  104. dialog: {
  105. type: Object,
  106. default: function () {
  107. return {
  108. addDevice: false
  109. };
  110. }
  111. },
  112. headerData: {
  113. type: Array,
  114. default: function () {
  115. return []
  116. }
  117. }
  118. },
  119. computed: {
  120. ...mapGetters("layout", ["projectId", "secret", "userId"]),
  121. },
  122. data() {
  123. return {
  124. width: "30%",
  125. isFull: true,//dialog是否为全屏
  126. title: "添加业务空间",
  127. isCenter: true,
  128. deviceType: {},
  129. main: table(10),
  130. mess: {},
  131. headers: null,
  132. page: {
  133. size: 50,
  134. sizes: [10, 30, 50, 100, 150, 200],
  135. total: 400,
  136. currentPage: 1
  137. },
  138. id: null,
  139. myDialog: {
  140. qrcode: false, //二维码弹窗
  141. firm: false, //厂商弹窗
  142. supply: false, //选择供应合同
  143. supplier: false, //供应商选择
  144. guarantee: false, //选择保单
  145. maintainer: false, //选择维修商
  146. insurer: false, //选择保险公司
  147. uploadFiles: false,//上传文件
  148. uploadImgs: false,//上传单个图片
  149. pic: false, //多个图片
  150. },
  151. addNum: 1,//增加个数
  152. row: null,//被修改的row
  153. filesArr: [],//保存临时的文件key
  154. messKey: null,
  155. imgsArr: [],//临时保存的图片key数组
  156. picsArr: [],//临时设备图片keys数组
  157. };
  158. },
  159. created() {
  160. },
  161. mounted() {
  162. },
  163. methods: {
  164. //增加个数
  165. addMain() {
  166. for (let i = 0; i < this.addNum; i++) {
  167. this.main.push({})
  168. }
  169. this.hot.loadData(this.main)
  170. },
  171. //添加业务空间确定
  172. addSpace() {
  173. console.log(this.main)
  174. let pushData = []
  175. this.main.map(item => {
  176. if (!!item.infos) {
  177. for (let key in item.infos) {
  178. if (!!item.infos[key]) {
  179. pushData.push(item)
  180. }
  181. }
  182. }
  183. })
  184. console.log(pushData)
  185. },
  186. //下一步
  187. // step(val) {
  188. // if (!!val) {
  189. // this.isFull = true
  190. // this.isCenter = true
  191. // this.title = "添加资产"
  192. // this.getData()
  193. // } else {
  194. // this.isFull = false
  195. // this.isCenter = false
  196. // }
  197. // },
  198. //修改设备类型
  199. changeCader(val) {
  200. this.deviceType = val
  201. },
  202. //获取header的mess
  203. getHeader(mess) {
  204. this.mess = mess;
  205. },
  206. //获取主体内容
  207. // getMain(floorMess) {
  208. // console.log(floorMess);
  209. // },
  210. //获取表头
  211. getData() {
  212. this.main = table(10)
  213. getSpaceHeader({
  214. code: "space",
  215. ProjId: this.projectId
  216. }).then(res => {
  217. this.headers = res.data.Content;
  218. if (!!this.hot) {
  219. this.hot.destroy();
  220. this.hot = null;
  221. }
  222. let data = tools.getItem(this.deviceType.code)
  223. if (!!data) {
  224. this.main = data
  225. }
  226. this.initHot();
  227. });
  228. },
  229. //撤回
  230. undo() {
  231. this.hot.undo();
  232. },
  233. //刷新
  234. reset() {
  235. this.getData();
  236. },
  237. //添加设备
  238. addDevice() {
  239. console.log("addDevice")
  240. },
  241. /**
  242. * 表头文案处理函数
  243. * @param arr header数组数据
  244. *
  245. * @return 处理好的文案
  246. */
  247. delHeader(arr) {
  248. let data = arr.map(item => {
  249. if (
  250. item.InputMode == "A1" ||
  251. item.InputMode == "A2" ||
  252. item.InputMode == "B1" ||
  253. item.InputMode == "C5" ||
  254. item.InputMode == "D1" ||
  255. item.InputMode == "D2" ||
  256. item.InputMode == "X" ||
  257. item.InputMode == "L" ||
  258. item.InputMode == "L1" ||
  259. item.InputMode == "L2" ||
  260. item.InputMode == "F1" ||
  261. item.InputMode == "F2"
  262. ) {
  263. if (item.unit == "") {
  264. return item.InfoPointName;
  265. } else {
  266. return item.InfoPointName + "(" + item.unit + ")";
  267. }
  268. } else {
  269. return undefined;
  270. }
  271. });
  272. data = data.filter(item => item);
  273. // data.unshift("同时创建资产", "所属建筑楼层", "所属系统实例");
  274. return data;
  275. },
  276. /**
  277. * 表头数据处理函数
  278. * @param arr header数组数据
  279. *
  280. * @return 处理好的数据格式
  281. */
  282. getType(arr) {
  283. let data = arr.map(item => {
  284. //二维码
  285. if (item.infoPointCode == "EquipQRCode") {
  286. return {
  287. data: "infos." + item.infoPointCode,
  288. renderer: tools.lookDetails,
  289. readOnly: true
  290. }
  291. }
  292. //厂商选择
  293. if (item.infoPointCode == "Brand" || item.infoPointCode == "Specification") {
  294. return {
  295. data: "infos." + item.infoPointCode,
  296. renderer: tools.lookDetails,
  297. readOnly: true
  298. }
  299. }
  300. if (item.infoPointCode == "SupplierContractID") {
  301. return {
  302. data: "infos." + item.infoPointCode,
  303. renderer: tools.lookDetails,
  304. readOnly: true
  305. }
  306. }
  307. if (item.infoPointCode == "InsuranceNum") {
  308. //选择保单
  309. return {
  310. data: "infos." + item.infoPointCode,
  311. renderer: tools.lookDetails,
  312. readOnly: true
  313. }
  314. }
  315. if (item.infoPointCode == "InsuranceFile" || item.infoPointCode == "Archive") {
  316. return {
  317. data: "infos." + item.infoPointCode,
  318. renderer: tools.lookDetails,
  319. readOnly: true
  320. }
  321. }
  322. if (
  323. item.infoPointCode == "InstallLocation" ||
  324. item.infoPointCode == "InstallPic" ||
  325. item.infoPointCode == "InstallDrawing" ||
  326. item.infoPointCode == "Nameplate" ||
  327. item.infoPointCode == "Pic" ||
  328. item.infoPointCode == "Drawing"
  329. ) {
  330. return {
  331. data: "infos." + item.infoPointCode,
  332. renderer: tools.lookDetails,
  333. readOnly: true
  334. }
  335. }
  336. if (
  337. item.infoPointCode == "Maintainer" ||
  338. item.infoPointCode == "Supplier" ||
  339. item.infoPointCode == "Insurer" ||
  340. item.infoPointCode == "InsurerContactor"
  341. ) {
  342. return {
  343. data: "infos." + item.infoPointCode,
  344. renderer: tools.lookDetails,
  345. readOnly: true
  346. }
  347. }
  348. if (item.InputMode == "D1") {
  349. return {
  350. data: "infos." + item.infoPointCode,
  351. renderer: tools.customDropdownRenderer,
  352. editor: "chosen",
  353. chosenOptions: {
  354. // multiple: true,//多选
  355. data: item.DataSource || ""
  356. }
  357. };
  358. } else if (item.InputMode == "A1" || item.InputMode == "A2") {
  359. return {
  360. data: "infos." + item.infoPointCode,
  361. type: "numeric",
  362. numericFormat: {
  363. pattern: "0,0.00"
  364. // culture: 'de-DE' // use this for EUR (German),
  365. // more cultures available on http://numbrojs.com/languages.html
  366. }
  367. };
  368. } else if (item.InputMode == "C5") {
  369. return {
  370. data: "infos." + item.infoPointCode,
  371. type: "date",
  372. dateFormat: "YYYY-MM-DD",
  373. correctFormat: true
  374. };
  375. } else if (
  376. item.InputMode == "B1" ||
  377. item.InputMode == "L" ||
  378. item.InputMode == "L1" ||
  379. item.InputMode == "L2"
  380. ) {
  381. return {
  382. data: "infos." + item.infoPointCode
  383. };
  384. } else if (
  385. item.InputMode == "X" ||
  386. item.InputMode == "F2"
  387. // item.InputMode == "L1" ||
  388. // item.InputMode == "L2"
  389. ) {
  390. return {
  391. data: "infos." + item.infoPointCode,
  392. readOnly: true
  393. };
  394. } else if (item.InputMode == "D2") {
  395. return {
  396. data: "infos." + item.infoPointCode,
  397. renderer: tools.customDropdownRenderer,
  398. editor: "chosen",
  399. chosenOptions: {
  400. multiple: true, //多选
  401. data: item.DataSource.Content || ""
  402. }
  403. };
  404. } else {
  405. return undefined;
  406. }
  407. });
  408. // data.unshift(
  409. // {
  410. // type: "checkbox",
  411. // checkedTemplate: 1,
  412. // uncheckedTemplate: 0,
  413. // data: "Checked",
  414. // label: {
  415. // position: "after",
  416. // }
  417. // },
  418. // {
  419. // data: "flowBuild",
  420. // renderer: tools.customDropdownRenderer,
  421. // editor: "chosen",
  422. // chosenOptions: {
  423. // // multiple: true,//多选
  424. // // data: item.DataSource.Content || ""
  425. // }
  426. // },
  427. // {
  428. // data: "system",
  429. // renderer: tools.customDropdownRenderer,
  430. // editor: "chosen",
  431. // chosenOptions: {
  432. // // multiple: true,//多选
  433. // // data: item.DataSource.Content || ""
  434. // }
  435. // }
  436. // );
  437. data = data.filter(item => item);
  438. return data;
  439. },
  440. //初始化插件
  441. initHot() {
  442. var container = document.getElementById("myHandson");
  443. let winHeight = document.documentElement.clientHeight;
  444. this.hot = new Handsontable(container, {
  445. data: this.main,
  446. colHeaders: this.delHeader(this.headers), //表头文案
  447. columns: this.getType(this.headers), //数据显示格式
  448. filters: true,
  449. height: winHeight - 100 - 50 - 60,
  450. columnSorting: true, //添加排序
  451. sortIndicator: true, //添加排序
  452. renderAllRows: true,
  453. autoColumnSize: true,
  454. language: "zh-CN",
  455. manualColumnResize: true,
  456. manualColumnMove: true,
  457. dropdownMenu: [
  458. "filter_by_condition",
  459. "filter_by_value",
  460. "filter_action_bar"
  461. ],
  462. contextMenu: this.onlyRead ? false :{
  463. items: {
  464. remove_row: {
  465. name: "删除该业务空间"
  466. }
  467. }
  468. },
  469. filters: true,
  470. afterFilter: this.trimmedRows,
  471. // 事件
  472. afterChange: this.tdChange, //修改后
  473. afterFilter: this.trimmedRows, //排序前
  474. beforeRemoveRow: this.romoveFm, //右键删除
  475. afterOnCellMouseDown: this.eventClick //鼠标点击
  476. });
  477. let pro = document.getElementById("hot-display-license-info");
  478. if (!!pro) {
  479. pro.parentNode.removeChild(pro);
  480. }
  481. this.isLoading = false;
  482. },
  483. tdChange() {
  484. tools.setItem(this.deviceType.code, this.main)
  485. },
  486. //表格中的点击
  487. eventClick(el, rowArr) {
  488. console.log(rowArr)
  489. //点击的是表头
  490. if (rowArr.row < 0) {
  491. return;
  492. }
  493. let filter = this.filtersArr;
  494. //被筛选过后的数组
  495. let trimmedArr = this.trimmedRows();
  496. //是否启用了排序
  497. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  498. if (trimmedArr.length && isSort) {
  499. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  500. .__arrayMap;
  501. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  502. this.getInfors(infos, sortArr[rowArr.row]);
  503. } else if (isSort) {
  504. //排序后的数组
  505. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  506. let infos = this.main[sortArr[rowArr.row]];
  507. this.getInfors(infos, sortArr[rowArr.row]);
  508. } else if (trimmedArr.length) {
  509. let infos = this.main[trimmedArr[rowArr.row]];
  510. this.getInfors(infos, trimmedArr[rowArr.row]);
  511. } else {
  512. let infos = this.main[rowArr.row];
  513. this.getInfors(infos, rowArr);
  514. }
  515. },
  516. getInfors(infos, row) {
  517. //其他的开始判断
  518. let val = this.hot.colToProp(row.col);
  519. if (val == "infos.EquipQRCode") {
  520. this.myDialog.qrcode = true;
  521. this.$refs.qrcode.getCanvas(1111);
  522. }
  523. if (val == "infos.Brand" || val == "infos.Specification") {
  524. this.myDialog.firm = true;
  525. }
  526. if (val == "infos.SupplierContractID") {
  527. let falg = null
  528. if (!!this.main[row.row].infos) {
  529. if (!!this.main[row.row].infos) {
  530. falg = this.main[row.row].infos.DPSupplierID
  531. }
  532. }
  533. if (!!falg) {
  534. this.id = falg
  535. this.myDialog.supply = true;
  536. } else {
  537. this.$message("请先选择供应商")
  538. }
  539. }
  540. if (val == "infos.InsuranceNum") {
  541. //选择保单
  542. this.myDialog.guarantee = true;
  543. }
  544. if (val == "infos.InsuranceFile" || val == "infos.Archive") {
  545. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  546. this.myDialog.uploadFiles = true
  547. }
  548. if (
  549. val == "infos.InstallLocation" ||
  550. val == "infos.InstallPic" ||
  551. val == "infos.InstallDrawing" ||
  552. val == "infos.Nameplate" ||
  553. val == "infos.Drawing"
  554. ) {
  555. if (val == "infos.Nameplate") {
  556. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]].key] : []) : []
  557. } else {
  558. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  559. }
  560. this.myDialog.uploadImgs = true
  561. }
  562. if (val == "infos.Pic") {
  563. // console.log(this.main[row.row].infos[val.split(".")[1]], "this.main[row.row].infos[val.split")
  564. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  565. console.log(this.picsArr)
  566. this.myDialog.pic = true
  567. }
  568. if (
  569. val == "infos.Supplier"
  570. ) {
  571. this.myDialog.supplier = true;
  572. }
  573. if (val == "infos.Maintainer") {
  574. this.myDialog.maintainer = true;
  575. }
  576. if (
  577. val == "infos.Insurer" ||
  578. val == "infos.InsurerContactor") {
  579. this.myDialog.insurer = true;
  580. }
  581. this.row = row.row
  582. this.messKey = val
  583. console.log(val, row);
  584. },
  585. //获取被筛选掉的行号
  586. trimmedRows() {
  587. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  588. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  589. let dataLength = this.main.length;
  590. let dataArr = new Array();
  591. for (let i = 0; i < dataLength; i++) {
  592. dataArr.push(i);
  593. }
  594. if (plugin.length <= 0) {
  595. dataArr = undefined;
  596. } else {
  597. dataArr = this.array_diff(dataArr, plugin);
  598. }
  599. return dataArr || [];
  600. // var DataArray = new Array();
  601. // for (var i = 0; i < plugin.length; i++) {
  602. // // 通过行号获取数据
  603. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  604. // }
  605. },
  606. //判断是否为空行
  607. isEmptyRow(instance, row) {
  608. var rowData = instance.countRows();
  609. for (var i = 0, ilen = rowData.length; i < ilen; i++) {
  610. if (rowData[i] !== null) {
  611. return false;
  612. }
  613. }
  614. return true;
  615. },
  616. //如果选择供应商之后
  617. supplierChange(data) {
  618. console.log(data, "供应商")
  619. for (let key in data) {
  620. this.utilToKey(key, "name", data, "Supplier")
  621. this.utilToKey(key, "email", data, "SupplierEmail")
  622. this.utilToKey(key, "website", data, "SupplierWeb")
  623. this.utilToKey(key, "phone", data, "SupplierPhone")
  624. this.utilToKey(key, "fox", data, "SupplierFax")
  625. this.utilToKey(key, "man", data, "SupplierContactor")
  626. this.utilToKey(key, "venderId", data, "DPSupplierID")
  627. }
  628. tools.setItem(this.deviceType.code, this.main)
  629. },
  630. //保险商变更
  631. changeInsurer(data) {
  632. console.log(data, "保险商")
  633. for (let key in data) {
  634. this.utilToKey(key, "name", data, "Insurer")
  635. this.utilToKey(key, "email", data, "InsurerEmail")
  636. this.utilToKey(key, "website", data, "InsurerWeb")
  637. this.utilToKey(key, "phone", data, "InsurerFax")
  638. this.utilToKey(key, "man", data, "InsurerContactor")
  639. this.utilToKey(key, "venderId", data, "DPInsurerID")
  640. }
  641. tools.setItem(this.deviceType.code, this.main)
  642. },
  643. //维修商变更
  644. changeMaintainer(data) {
  645. for (let key in data) {
  646. this.utilToKey(key, "name", data, "Maintainer")
  647. this.utilToKey(key, "email", data, "MaintainerEmail")
  648. this.utilToKey(key, "website", data, "MaintainerWeb")
  649. this.utilToKey(key, "phone", data, "MaintainerPhone")
  650. this.utilToKey(key, "fox", data, "MaintainerFax")
  651. this.utilToKey(key, "man", data, "MaintainerContactor")
  652. this.utilToKey(key, "venderId", data, "DPMaintainerID")
  653. }
  654. tools.setItem(this.deviceType.code, this.main)
  655. },
  656. utilToKey(key, name, data, messName) {
  657. if (key == name) {
  658. this.setDataToMain(data[key], messName, this.row)
  659. }
  660. },
  661. //上传文件弹窗触发事件
  662. fileChange(keys) {
  663. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  664. tools.setItem(this.deviceType.code, this.main)
  665. },
  666. //上传图片弹窗触发事件
  667. imgChange(keys) {
  668. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  669. tools.setItem(this.deviceType.code, this.main)
  670. },
  671. //设备图片弹窗改变事件
  672. changePics(keys) {
  673. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  674. tools.setItem(this.deviceType.code, this.main)
  675. console.log("assets", keys)
  676. },
  677. //判断是否有值,有值赋值
  678. setDataToMain(data, key, row) {
  679. if (!!data && data != '--') {
  680. if (!!this.main[row].infos) {
  681. //铭牌照片特殊处理
  682. if (key == 'Nameplate') {
  683. this.main[row].infos[key] = {
  684. "systemId": "dataPlatform",
  685. "name": "铭牌照片",
  686. "type": "image",
  687. "key": data
  688. }
  689. } else {
  690. this.main[row].infos[key] = data
  691. }
  692. } else {
  693. this.main[row].infos = {}
  694. if (key == 'Nameplate') {
  695. this.main[row].infos[key] = {
  696. "systemId": "dataPlatform",
  697. "name": "铭牌照片",
  698. "type": "image",
  699. "key": data
  700. }
  701. } else {
  702. this.main[row].infos[key] = data
  703. }
  704. }
  705. } else {
  706. this.main[row].infos[key] = ''
  707. }
  708. }
  709. },
  710. watch: {
  711. dialog: {
  712. deep: true,
  713. handler(newName, oldName) {
  714. // this.getData()
  715. console.log(this.dialog)
  716. if (this.dialog.addDevice) {
  717. this.getData()
  718. }
  719. },
  720. }
  721. }
  722. };
  723. </script>
  724. <style lang="less" scoped>
  725. #addDevice {
  726. overflow: hidden;
  727. }
  728. </style>