dialogSystem.vue 25 KB

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