dialogAssets.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. <!--
  2. 上传文件的弹窗
  3. -->
  4. <template>
  5. <div v-if="dialog.addDevice">
  6. <router-view></router-view>
  7. <router-link to="/system/list/addsystem"></router-link>
  8. <el-dialog
  9. :title="title"
  10. :center="isCenter"
  11. :visible.sync="dialog.addDevice"
  12. :width="width"
  13. :fullscreen="isFull"
  14. >
  15. <div id="addDevice">
  16. <div v-show="!isCenter">
  17. <my-cascader ref="cascader" @change="changeCader"></my-cascader>
  18. </div>
  19. <div v-if="isCenter">
  20. <div>
  21. <div class="hanson-bar">
  22. <span>当前选择的设备族:{{deviceType.facility}}</span>
  23. <div style="float:right;overflow:hidden;">
  24. <span>增加</span>
  25. <el-input v-model="addNum" style="width:50px;" placeholder="增加个数" size="small"></el-input>
  26. <span>个{{deviceType.facility}}</span>
  27. <el-button size="small" @click="addMain">增加</el-button>
  28. </div>
  29. <div
  30. style="width:200px;color:gray;float:right;font-size:10px;"
  31. >是否隐藏自动填充信息点:
  32. <el-tooltip :content="'' + (isWatch ? '隐藏' : '不隐藏')" placement="top">
  33. <el-switch
  34. @change="changeWatch"
  35. v-model="isWatch"
  36. active-color="#13ce66"
  37. inactive-color="gray"
  38. ></el-switch>
  39. </el-tooltip>
  40. </div>
  41. </div>
  42. <div v-show="main && main.length" id="myHandson" ref="myHandson"></div>
  43. </div>
  44. </div>
  45. </div>
  46. <div v-show="!isCenter" slot="footer" class="dialog-footer">
  47. <!-- <el-button>取 消</el-button> -->
  48. <el-button type="primary" @click="step(1)">下 一 步</el-button>
  49. </div>
  50. <span v-show="isCenter" slot="footer" class="dialog-footer">
  51. <el-button type="primary" @click="createAssets">创建资产</el-button>
  52. </span>
  53. </el-dialog>
  54. <qrcode :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
  55. <firm
  56. :mess="{deviceId : deviceType.code}"
  57. ref="firm"
  58. @changeFirm="firmChange"
  59. :dialog="myDialog"
  60. ></firm>
  61. <supply-dialog @change="supplyChange" :id="id" ref="supply" :dialog="myDialog"></supply-dialog>
  62. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
  63. <guarantee-dialog ref="guarantee" :id="id" @change="guaranteeChange" :dialog="myDialog"></guarantee-dialog>
  64. <upload-files-dialog
  65. ref="upload"
  66. @changeFile="fileChange"
  67. :keysArr="filesArr"
  68. :dialog="myDialog"
  69. ></upload-files-dialog>
  70. <upload-img-dialog @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog"></upload-img-dialog>
  71. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="myDialog"></maintainer-dialog>
  72. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="myDialog"></insurer-dialog>
  73. <pic-dialog :dialog="myDialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
  74. </div>
  75. </template>
  76. <script>
  77. import myCascader from "@/components/ledger/lib/assets";
  78. import hansonTable from "@/components/ledger/lib/addDevice";
  79. import tools from "@/utils/scan/tools";
  80. import qrcode from "@/components/business_space/lib/qrcode";
  81. import firm from "@/components/business_space/dialogs/list/firm";
  82. import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog";
  83. import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog";
  84. import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog";
  85. import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog";
  86. import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog";
  87. import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog";
  88. import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog";
  89. import picDialog from "@/components/business_space/dialogs/list/picDialog"
  90. import Handsontable from "handsontable-pro"
  91. import 'handsontable-pro/dist/handsontable.full.css'
  92. import zhCN from 'handsontable-pro/languages/zh-CN';
  93. //下拉插件
  94. // import "@/assets/js/chosen.jquery.min";
  95. // import "@/assets/js/handsontable-chosen-editor";
  96. import text from "@/utils/handsontable/mainText"
  97. import showTools from "@/utils/handsontable/notShow"
  98. import {mapGetters, mapActions} from "vuex";
  99. import uuid from "@/utils/scan/uuid";
  100. import { getTableHeader, createProperty, getSpaceFloor, createAssetsList } from "@/api/scan/request";
  101. let table = function (num) {
  102. let main = []
  103. for (let i = 0; i < num; i++) {
  104. main.push({})
  105. }
  106. return main
  107. }
  108. export default {
  109. components: {
  110. myCascader,
  111. hansonTable,
  112. qrcode, //二维码页面
  113. firm, //
  114. supplyDialog,
  115. supplierDialog,
  116. guaranteeDialog,
  117. uploadFilesDialog,
  118. maintainerDialog,
  119. insurerDialog,
  120. uploadImgDialog,
  121. picDialog
  122. },
  123. props: {
  124. dialog: {
  125. type: Object,
  126. default: function () {
  127. return {
  128. addDevice: false
  129. };
  130. }
  131. },
  132. assetType: {
  133. type: Array,
  134. default: function () {
  135. return []
  136. }
  137. }
  138. },
  139. computed: {
  140. ...mapGetters("layout", [
  141. "projectId",
  142. "secret",
  143. "userId"
  144. ])
  145. },
  146. data() {
  147. return {
  148. width: "30%",
  149. isFull: false,//dialog是否为全屏
  150. title: "确定新增资产的类型",
  151. isCenter: false,
  152. deviceType: {},
  153. main: table(1),
  154. mess: {},
  155. headers: null,
  156. page: {
  157. size: 50,
  158. sizes: [10, 30, 50, 100, 150, 200],
  159. total: 400,
  160. currentPage: 1
  161. },
  162. id: 0,
  163. myDialog: {
  164. qrcode: false, //二维码弹窗
  165. firm: false, //厂商弹窗
  166. supply: false, //选择供应合同
  167. supplier: false, //供应商选择
  168. guarantee: false, //选择保单
  169. maintainer: false, //选择维修商
  170. insurer: false, //选择保险公司
  171. uploadFiles: false,//上传文件
  172. uploadImgs: false,//上传单个图片
  173. pic: false, //多个图片
  174. },
  175. addNum: 1,//增加个数
  176. row: null,//被修改的row
  177. filesArr: [],//保存临时的文件key
  178. messKey: null,
  179. imgsArr: [],//临时保存的图片key数组
  180. picsArr: [],//临时设备图片keys数组
  181. param: {
  182. ProjId: '',
  183. secret: ''
  184. },
  185. floorData: [],
  186. isWatch: true,
  187. ajaxResult: true
  188. };
  189. },
  190. created() {
  191. this.param.ProjId = this.projectId
  192. this.param.secret = this.secret
  193. // this.getFloorData()
  194. },
  195. mounted() { },
  196. methods: {
  197. //设置默认选中数据
  198. setValue() {
  199. this.$nextTick(_ => {
  200. this.$refs.cascader.setValue(this.assetType)
  201. })
  202. },
  203. //获取楼层数据
  204. // getFloorData() { // 物理世界 已无接口
  205. // getSpaceFloor(this.param).then(res => {
  206. // if (res.data.Result == 'success') {
  207. // let data = this.changeArr(res.data.Content), floorData = []
  208. // data.map(item => {
  209. // if (!!item.children) {
  210. // item.children.unshift({
  211. // value: '',
  212. // label: "未明确楼层的设备"
  213. // })
  214. // }
  215. // return item
  216. // })
  217. // data.map(item => {
  218. // if (!!item.children && item.children.length) {
  219. // item.children.map(child => {
  220. // floorData.push({
  221. // Code: item.value + "-" + child.value,
  222. // Name: item.label + "-" + child.label
  223. // })
  224. // })
  225. // }
  226. // })
  227. // this.floorData = floorData
  228. // // this.options = data
  229. // } else {
  230. // this.$message.error(res.data.ResultMsg)
  231. // }
  232. // }).catch(() => {
  233. // this.$message.error("请求出错")
  234. // })
  235. // },
  236. //将数组转换成optiosn格式
  237. changeArr(arr) {
  238. return arr.map(item => {
  239. if (item.floors && item.floors.length) {
  240. return {
  241. value: item.id,
  242. label: item.infos.BuildLocalName,
  243. children: item.floors.map(i => {
  244. return {
  245. value: i.id,
  246. label: i.infos.FloorLocalName || "未知",
  247. }
  248. })
  249. }
  250. } else {
  251. return {
  252. value: item.id,
  253. label: item.infos.BuildLocalName,
  254. children: null,
  255. isChilren: 1,
  256. }
  257. }
  258. })
  259. },
  260. //增加个数
  261. addMain() {
  262. for (let i = 0; i < this.addNum; i++) {
  263. this.main.push({})
  264. }
  265. if (!!this.hot) {
  266. this.hot.destroy()
  267. }
  268. this.initHot()
  269. },
  270. //下一步
  271. step(val) {
  272. if (!!val) {
  273. this.isFull = true
  274. this.isCenter = true
  275. this.title = "添加资产"
  276. this.getData()
  277. } else {
  278. this.isFull = false
  279. this.isCenter = false
  280. }
  281. },
  282. //修改设备类型
  283. changeCader(val) {
  284. this.deviceType = val
  285. },
  286. //获取header的mess
  287. getHeader(mess) {
  288. this.mess = mess;
  289. },
  290. //获取主体内容
  291. getMain(floorMess) {
  292. },
  293. //获取表头
  294. getData() {
  295. this.main = table(1)
  296. getTableHeader({
  297. code: this.deviceType.code,
  298. ProjId: this.projectId
  299. }).then(res => {
  300. this.headers = res.data.Content;
  301. if (!!this.hot) {
  302. this.hot.destroy();
  303. this.hot = null;
  304. }
  305. let data = tools.getItem(this.deviceType.code)
  306. if (!!data) {
  307. this.main = data
  308. }
  309. this.initHot();
  310. });
  311. },
  312. changeWatch() {
  313. this.getData()
  314. },
  315. //撤回
  316. undo() {
  317. this.hot.undo();
  318. },
  319. //刷新
  320. reset() {
  321. this.getData();
  322. },
  323. //添加设备
  324. addDevice() {
  325. },
  326. //创建资产
  327. createAssets() {
  328. let data = []
  329. let copyData = tools.copyArr(this.main)
  330. let falg = false
  331. copyData.map(item => {
  332. if (!!item.infos) {
  333. if (item.infos.EquipLocalName) {
  334. item.family = this.deviceType.code
  335. data.push(item)
  336. } else {
  337. falg = true
  338. }
  339. }
  340. })
  341. if (falg) {
  342. this.$message.error("存在资产的本地名称为空,请检查")
  343. return
  344. }
  345. let params = []
  346. data.map(item => {
  347. if (!!item.infos) {
  348. let one = {}
  349. if (!!item.flowBuild) {
  350. one.BuildId = item.flowBuild.split("-")[0]
  351. one.FloorId = item.flowBuild.split("-")[1] || null
  352. }
  353. one.Family = this.deviceType.code
  354. one.FamilyName = this.deviceType.facility
  355. one.Infos = item.infos
  356. one.FmId = "Pe" + uuid(32, 16)
  357. one.ProjId = this.projectId
  358. one.FmName = item.infos.EquipLocalName || ""
  359. one.X = 0
  360. one.Y = 0
  361. params.push(one)
  362. }
  363. })
  364. params.map(item => {
  365. for (let k in item.Infos) {
  366. if (item.Infos[k] == "") {
  367. item.Infos[k] = null
  368. }
  369. }
  370. })
  371. if (params.length) {
  372. this.createJson(params)
  373. } else {
  374. this.$message.error("信息点不能为空")
  375. }
  376. },
  377. //新建资产请求
  378. async createJson(data) {
  379. data.map(item => {
  380. if (!!item.Infos.dpSupplierId) {
  381. item.Infos.dpSupplierId = item.Infos.dpSupplierId.split("-")[0]
  382. }
  383. if (!!item.Infos.dpManufacturerId) {
  384. item.Infos.dpManufacturerId = item.Infos.dpManufacturerId.split("-")[0]
  385. }
  386. if (!!item.Infos.DPInsurerID) {
  387. item.Infos.DPInsurerID = item.Infos.DPInsurerID.split("-")[0]
  388. }
  389. if (!!item.Infos.dpMaintainerId) {
  390. item.Infos.dpMaintainerId = item.Infos.dpMaintainerId.split("-")[0]
  391. }
  392. if (!!item.Infos.dpSpecificationId) {
  393. item.Infos.dpSpecificationId = item.Infos.dpSpecificationId.split("-")[0]
  394. }
  395. for (let k in item.Infos) {
  396. if (item.Infos[k] == "") {
  397. item.Infos[k] = null
  398. }
  399. }
  400. return item
  401. })
  402. this.ajaxResult = true
  403. let param = {
  404. FmList: data,
  405. ProjId: this.projectId,
  406. UserId: this.userId
  407. }
  408. await this.createAssetId(param)
  409. },
  410. async createAssetId(param) {
  411. await createAssetsList(param, res => {
  412. console.log(res)
  413. if (res.Result != "success") {
  414. this.$message.error("请求错误")
  415. } else {
  416. tools.removeItem(this.deviceType.code)
  417. this.$emit("close", this.deviceType)
  418. this.dialog.addDevice = false
  419. }
  420. })
  421. },
  422. /**
  423. * 表头文案处理函数
  424. * @param list header数组数据
  425. *
  426. * @return 处理好的文案
  427. */
  428. delHeader(list) {
  429. let arr = tools.copyArr(list)
  430. // 如果不是只读状态,添加四大厂商选择
  431. arr = showTools.arrToArr(arr)
  432. let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2", "M"]
  433. readArr.push("Own")
  434. let data = showTools.changeHeader(arr, readArr, false, this.isWatch, false, true)
  435. data.unshift("所属建筑楼层");
  436. console.log(data, "data")
  437. return data;
  438. },
  439. /**
  440. * 表头数据处理函数
  441. * @param list header数组数据
  442. *
  443. * @return 处理好的数据格式
  444. */
  445. getType(list) {
  446. let arr = tools.copyArr(list)
  447. // 如果不是只读状态,添加四大厂商选择
  448. if (!this.onlyRead) {
  449. arr = showTools.arrToArr(arr)
  450. }
  451. let data = showTools.showTypes(arr, false, this.isWatch, false, true)
  452. data.unshift(
  453. {
  454. data: "flowBuild",
  455. renderer: tools.customDropdownRenderer,
  456. editor: "chosen",
  457. chosenOptions: {
  458. // multiple: true,//多选
  459. data: this.floorData
  460. }
  461. }
  462. );
  463. console.log("type", data)
  464. return data;
  465. },
  466. //初始化插件
  467. initHot() {
  468. var container = document.getElementById("myHandson");
  469. let winHeight = document.documentElement.clientHeight;
  470. this.hot = new Handsontable(container, {
  471. data: this.main,
  472. colHeaders: this.delHeader(this.headers), //表头文案
  473. columns: this.getType(this.headers), //数据显示格式
  474. filters: true,
  475. rowHeaders: true,
  476. height: winHeight - 100 - 50 - 60,
  477. columnSorting: true, //添加排序
  478. sortIndicator: true, //添加排序
  479. renderAllRows: true,
  480. autoColumnSize: true,
  481. language: "zh-CN",
  482. maxRows: this.main.length,
  483. manualColumnResize: true,
  484. manualColumnMove: true,
  485. dropdownMenu: [
  486. "filter_by_condition",
  487. "filter_by_value",
  488. "filter_action_bar"
  489. ],
  490. contextMenu: this.onlyRead ? false :{
  491. items: {
  492. remove_row: {
  493. name: "删除该资产"
  494. }
  495. }
  496. },
  497. afterChange: this.tdChange, //修改后
  498. afterFilter: this.trimmedRows, //排序前
  499. afterRemoveRow: this.romoveFm, //右键删除
  500. afterOnCellMouseDown: this.eventClick //鼠标点击
  501. });
  502. let pro = document.getElementById("hot-display-license-info");
  503. if (!!pro) {
  504. pro.parentNode.removeChild(pro);
  505. }
  506. this.isLoading = false;
  507. },
  508. tdChange() {
  509. tools.setItem(this.deviceType.code, this.main)
  510. },
  511. //表格中的点击
  512. eventClick(el, rowArr) {
  513. //点击的是表头
  514. if (rowArr.row < 0) {
  515. return;
  516. }
  517. let filter = this.filtersArr;
  518. //被筛选过后的数组
  519. let trimmedArr = this.trimmedRows();
  520. //是否启用了排序
  521. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  522. if (trimmedArr.length && isSort) {
  523. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  524. .__arrayMap;
  525. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  526. this.getInfors(infos, sortArr[rowArr.row]);
  527. } else if (isSort) {
  528. //排序后的数组
  529. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  530. let infos = this.main[sortArr[rowArr.row]];
  531. this.getInfors(infos, sortArr[rowArr.row]);
  532. } else if (trimmedArr.length) {
  533. let infos = this.main[trimmedArr[rowArr.row]];
  534. this.getInfors(infos, trimmedArr[rowArr.row]);
  535. } else {
  536. let infos = this.main[rowArr.row];
  537. this.getInfors(infos, rowArr);
  538. }
  539. },
  540. getInfors(infos, row) {
  541. //其他的开始判断
  542. let val = this.hot.colToProp(row.col);
  543. if (val == "infos.EquipQRCode") {
  544. this.myDialog.qrcode = true;
  545. this.$refs.qrcode.getCanvas(1111);
  546. }
  547. if (val == "linkSystem") {
  548. this.systemList = this.main[row.row].linkSystem || []
  549. this.dialog.systemType = true
  550. }
  551. if (val == "infos.dpManufacturerId") {
  552. this.myDialog.firm = true;
  553. }
  554. if (val == "infos.SupplierContractID") {
  555. let falg = null
  556. if (!!this.main[row.row].infos) {
  557. if (!!this.main[row.row].infos) {
  558. falg = this.main[row.row].infos.dpSupplierId.split("-")[0]
  559. }
  560. }
  561. if (!!falg) {
  562. this.id = falg
  563. this.myDialog.supply = true;
  564. } else {
  565. this.$message("请先选择供应商")
  566. }
  567. }
  568. if (val == "infos.InsuranceNum") {
  569. //选择保单
  570. let falg = null
  571. if (!!this.main[row.row].infos) {
  572. if (!!this.main[row.row].infos) {
  573. falg = this.main[row.row].infos.DPInsurerID.split("-")[0]
  574. }
  575. }
  576. if (!!falg) {
  577. this.id = falg
  578. this.myDialog.guarantee = true;
  579. } else {
  580. this.$message("请先选择保险商")
  581. }
  582. }
  583. if (val == "infos.InsuranceFile" || val == "infos.Archive") {
  584. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  585. this.myDialog.uploadFiles = true
  586. }
  587. if (
  588. val == "infos.InstallPic" ||
  589. val == "infos.InstallDrawing" ||
  590. val == "infos.Nameplate" ||
  591. val == "infos.Drawing"
  592. ) {
  593. if (val == "infos.Nameplate") {
  594. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]].key] : []) : []
  595. } else {
  596. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  597. }
  598. console.log(this.imgsArr,'this.imgsArr')
  599. this.myDialog.uploadImgs = true
  600. }
  601. if (val == "infos.Pic") {
  602. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  603. this.myDialog.pic = true
  604. }
  605. if (
  606. val == "infos.Supplier"
  607. ) {
  608. this.myDialog.supplier = true;
  609. }
  610. if (
  611. val == "infos.dpSupplierId"
  612. ) {
  613. this.myDialog.supplier = true;
  614. }
  615. if (val == "infos.dpMaintainerId"
  616. ) {
  617. this.myDialog.maintainer = true;
  618. }
  619. if (
  620. val == "infos.DPInsurerID"
  621. ) {
  622. this.myDialog.insurer = true;
  623. }
  624. if (val == "infos.maintainer") {
  625. this.myDialog.maintainer = true;
  626. }
  627. if (
  628. val == "infos.Insurer" ||
  629. val == "infos.InsurerContactor") {
  630. this.myDialog.insurer = true;
  631. }
  632. this.row = row.row
  633. this.messKey = val
  634. console.log(val, row);
  635. },
  636. //获取被筛选掉的行号
  637. trimmedRows() {
  638. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  639. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  640. let dataLength = this.main.length;
  641. let dataArr = new Array();
  642. for (let i = 0; i < dataLength; i++) {
  643. dataArr.push(i);
  644. }
  645. if (plugin.length <= 0) {
  646. dataArr = undefined;
  647. } else {
  648. dataArr = this.array_diff(dataArr, plugin);
  649. }
  650. return dataArr || [];
  651. // var DataArray = new Array();
  652. // for (var i = 0; i < plugin.length; i++) {
  653. // // 通过行号获取数据
  654. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  655. // }
  656. },
  657. //判断是否为空行
  658. isEmptyRow(instance, row) {
  659. var rowData = instance.countRows();
  660. for (var i = 0, ilen = rowData.length; i < ilen; i++) {
  661. if (rowData[i] !== null) {
  662. return false;
  663. }
  664. }
  665. return true;
  666. },
  667. //选择型号修改
  668. firmChange(data) {
  669. for (let key in data) {
  670. // this.utilToKey(key, "brand", data, "Brand")
  671. // this.utilToKey(key, "name", data, "Specification")
  672. // this.utilToKey(key, "venderName", data, "manufacturer")
  673. if (key == "venderId") {
  674. data[key] = data[key] + "-" + data.name + "/" + data.brand
  675. this.utilToKey(key, "venderId", data, "dpManufacturerId")
  676. }
  677. this.utilToKey(key, "specificationId", data, "dpSpecificationId")
  678. }
  679. tools.setItem(this.deviceType.code, this.main)
  680. },
  681. //如果选择供应商之后
  682. supplierChange(data) {
  683. for (let key in data) {
  684. // this.utilToKey(key, "name", data, "Supplier")
  685. // this.utilToKey(key, "email", data, "SupplierEmail")
  686. // this.utilToKey(key, "website", data, "SupplierWeb")
  687. // this.utilToKey(key, "phone", data, "SupplierPhone")
  688. // this.utilToKey(key, "fox", data, "SupplierFax")
  689. // this.utilToKey(key, "man", data, "SupplierContactor")
  690. if (key == "venderId") {
  691. data[key] = data[key] + "-" + data.name
  692. console.log(data)
  693. this.utilToKey(key, "venderId", data, "dpSupplierId")
  694. }
  695. // this.utilToKey(key, "specificationId", data, "dpSpecificationId")
  696. }
  697. tools.setItem(this.deviceType.code, this.main)
  698. },
  699. //供应商合同
  700. supplyChange(data) {
  701. let changeData = { id: data }
  702. this.utilToKey("id", "id", changeData, "SupplierContractID")
  703. tools.setItem(this.deviceType.code, this.main)
  704. },
  705. //保险合同
  706. guaranteeChange(data) {
  707. for (let key in data) {
  708. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  709. if (key == "contractFile") {
  710. if (!!data[key]) {
  711. data[key] = [data[key]]
  712. }
  713. }
  714. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  715. }
  716. tools.setItem(this.deviceType.code, this.main)
  717. },
  718. //保险商变更
  719. changeInsurer(data) {
  720. for (let key in data) {
  721. // this.utilToKey(key, "name", data, "Insurer")
  722. // this.utilToKey(key, "email", data, "InsurerEmail")
  723. // this.utilToKey(key, "website", data, "InsurerWeb")
  724. // this.utilToKey(key, "phone", data, "InsurerFax")
  725. // this.utilToKey(key, "man", data, "InsurerContactor")
  726. if (key == "venderId") {
  727. data[key] = data[key] + "-" + data.name
  728. this.utilToKey(key, "venderId", data, "DPInsurerID")
  729. }
  730. }
  731. tools.setItem(this.deviceType.code, this.main)
  732. },
  733. //维修商变更
  734. changeMaintainer(data) {
  735. for (let key in data) {
  736. // this.utilToKey(key, "name", data, "maintainer")
  737. // this.utilToKey(key, "email", data, "MaintainerEmail")
  738. // this.utilToKey(key, "website", data, "MaintainerWeb")
  739. // this.utilToKey(key, "phone", data, "MaintainerPhone")
  740. // this.utilToKey(key, "fox", data, "MaintainerFax")
  741. // this.utilToKey(key, "man", data, "MaintainerContactor")
  742. if (key == "venderId") {
  743. data[key] = data[key] + "-" + data.name
  744. this.utilToKey(key, "venderId", data, "dpMaintainerId")
  745. }
  746. }
  747. tools.setItem(this.deviceType.code, this.main)
  748. },
  749. utilToKey(key, name, data, messName) {
  750. if (key == name) {
  751. this.setDataToMain(data[key], messName, this.row)
  752. }
  753. },
  754. //上传文件弹窗触发事件
  755. fileChange(keys) {
  756. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  757. tools.setItem(this.deviceType.code, this.main)
  758. },
  759. //上传图片弹窗触发事件
  760. imgChange(keys) {
  761. console.log(keys,'keys')
  762. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  763. tools.setItem(this.deviceType.code, this.main)
  764. console.log(this.main,'this.main')
  765. },
  766. //设备图片弹窗改变事件
  767. changePics(keys) {
  768. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  769. tools.setItem(this.deviceType.code, this.main)
  770. },
  771. //判断是否有值,有值赋值
  772. // setDataToMain(data, key, row) {
  773. // console.log(data, key, row)
  774. // if (!!data && data != '--') {
  775. // console.log("data存在")
  776. // if (!!this.main[row].infos) {
  777. // //铭牌照片特殊处理
  778. // console.log("处理保存",key)
  779. // this.main[row][key[0]][key[1]] = data
  780. // console.log(this.main)
  781. // } else {
  782. // console.log("存储已保存")
  783. // this.main[row][key[0]] = {}
  784. // this.main[row][key[0]][key[1]] = data
  785. // }
  786. // } else {
  787. // this.main[row].infos[key] = ''
  788. // }
  789. // },
  790. //判断是否有值,有值赋值
  791. setDataToMain(data, key, row) {
  792. if (!!data && data != '--') {
  793. if (!!this.main[row].infos) {
  794. //铭牌照片特殊处理
  795. this.main[row].infos[key] = data
  796. } else {
  797. this.main[row].infos = {}
  798. this.main[row].infos[key] = data
  799. }
  800. } else {
  801. this.main[row].infos[key] = ''
  802. }
  803. }
  804. },
  805. watch: {
  806. dialog: {
  807. deep: true,
  808. handler: function () {
  809. if (this.dialog.addDevice) {
  810. this.setValue()
  811. }
  812. }
  813. }
  814. }
  815. };
  816. </script>
  817. <style lang="less" scoped>
  818. #addDevice {
  819. overflow: hidden;
  820. }
  821. </style>