dialogSystem.vue 25 KB

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