dialogDevice.vue 30 KB

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