businessDialog.vue 22 KB

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