dialogSystem.vue 26 KB

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