dialogDevice.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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="iconfont icon-xiaolian"></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: 10,
  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. }).then(_ => {
  228. this.floorFalg = true
  229. this.getData()
  230. }).catch(_ => {
  231. this.$message("取消")
  232. })
  233. }
  234. },
  235. //获取资产族
  236. getEquipmentFamilyList() {
  237. getEquipmentFamily(res => {
  238. this.EquipmentList = res.Content
  239. console.log(this.EquipmentList, "EquipmentList")
  240. })
  241. },
  242. //设置默认选中数据
  243. setValue() {
  244. this.$nextTick(_ => {
  245. this.$refs.cascader.setValue(this.assetType)
  246. })
  247. },
  248. //获取楼层数据
  249. getFloorData() {
  250. getSpaceFloor(this.param).then(res => {
  251. if (res.data.Result == 'success') {
  252. let data = this.changeArr(res.data.Content), floorData = []
  253. data.map(item => {
  254. if (!!item.children) {
  255. item.children.unshift({
  256. value: '',
  257. label: "未明确楼层"
  258. })
  259. }
  260. return item
  261. })
  262. data.map(item => {
  263. if (!!item.children && item.children.length) {
  264. item.children.map(child => {
  265. floorData.push({
  266. Code: item.value + "-" + child.value,
  267. Name: item.label + "-" + child.label
  268. })
  269. })
  270. }
  271. })
  272. this.floorData = floorData
  273. console.log(this.floorData)
  274. } else {
  275. this.$message.error(res.data.ResultMsg)
  276. }
  277. }).catch(() => {
  278. this.$message.error("请求出错")
  279. })
  280. },
  281. //将数组转换成optiosn格式
  282. changeArr(arr) {
  283. return arr.map(item => {
  284. if (item.floors && item.floors.length) {
  285. return {
  286. value: item.id,
  287. label: item.infos.BuildLocalName,
  288. children: item.floors.map(i => {
  289. return {
  290. value: i.id,
  291. label: i.infos.FloorLocalName || "未知",
  292. }
  293. })
  294. }
  295. } else {
  296. return {
  297. value: item.id,
  298. label: item.infos.BuildLocalName,
  299. children: null,
  300. isChilren: 1,
  301. }
  302. }
  303. })
  304. },
  305. //增加个数
  306. addMain() {
  307. for (let i = 0; i < this.addNum; i++) {
  308. this.main.push({
  309. Checked: 1
  310. })
  311. }
  312. if (!!this.hot) {
  313. this.hot.destroy()
  314. }
  315. this.initHot()
  316. },
  317. //下一步
  318. step(val) {
  319. if (!!val) {
  320. if (!!!this.deviceType.code) {
  321. this.$message("请选择设备类别")
  322. return
  323. }
  324. this.isFull = true
  325. this.isCenter = true
  326. this.title = "添加设备"
  327. this.getData()
  328. } else {
  329. this.isFull = false
  330. this.isCenter = false
  331. }
  332. },
  333. //修改设备类型
  334. changeCader(val) {
  335. this.deviceType = val
  336. this.EquipmentList.map(item => {
  337. if (!!item.content && item.content.length) {
  338. item.content.map(child => {
  339. if (child.code == this.deviceType.code) {
  340. this.deviceType.assetType = item.code
  341. this.deviceType.assetName = item.name
  342. }
  343. })
  344. }
  345. })
  346. },
  347. //获取header的mess
  348. getHeader(mess) {
  349. this.mess = mess;
  350. },
  351. //获取表头
  352. getData() {
  353. this.main = table(1)
  354. getTableHeader({
  355. code: this.deviceType.code,
  356. ProjId: this.projectId
  357. }).then(res => {
  358. this.headers = res.data.Content;
  359. if (!!this.hot) {
  360. this.hot.destroy();
  361. this.hot = null;
  362. }
  363. let data = tools.getItem(this.deviceType.code)
  364. if (!!data) {
  365. this.main = data
  366. }
  367. this.initHot();
  368. });
  369. },
  370. //添加设备
  371. addDevice() {
  372. let data = []
  373. let copyData = tools.copyArr(this.main)
  374. let falg = false
  375. copyData.map(item => {
  376. if (!!item.infos || !!item.relation) {
  377. if (item.infos.EquipLocalName) {
  378. item.equipment_category = this.deviceType.code
  379. data.push(item)
  380. } else {
  381. falg = true
  382. }
  383. }
  384. })
  385. if (falg) {
  386. this.$message.info("存在设备的本地名称为空,请检查")
  387. return
  388. }
  389. data = data.map(item => {
  390. if (!!item.infos) {
  391. for (let key in item.infos) {
  392. item.infos[key] = [{ "value": item.infos[key] != "" ? item.infos[key] : null }]
  393. }
  394. }
  395. if (!!item.flowBuild) {
  396. item.building_id = item.flowBuild.split("-")[0]
  397. item.floor_id = item.flowBuild.split("-")[1] || null
  398. //不存在floor字段去除floor
  399. if (!item.floor_id) {
  400. delete item.floor_id
  401. }
  402. delete item.flowBuild
  403. }
  404. return item
  405. })
  406. if (data.length) {
  407. this.createJson(data)
  408. } else {
  409. this.$message.info("信息点不能为空")
  410. }
  411. },
  412. //创建设备接口
  413. async createJson(data) {
  414. console.log(this.projectId)
  415. let param = {
  416. data: { criterias: data },
  417. ProjId: this.projectId,
  418. secret: this.secret
  419. }
  420. param.data.criterias.map(item => {
  421. if (!!item.infos.DPSupplierID && !!item.infos.DPSupplierID[0].value) {
  422. item.infos.DPSupplierID[0].value = item.infos.DPSupplierID[0].value.split("-")[0]
  423. }
  424. if (!!item.infos.DPManufacturerID && !!item.infos.DPManufacturerID[0].value) {
  425. item.infos.DPManufacturerID[0].value = item.infos.DPManufacturerID[0].value.split("-")[0]
  426. }
  427. if (!!item.infos.DPInsurerID && !!item.infos.DPInsurerID[0].value) {
  428. item.infos.DPInsurerID[0].value = item.infos.DPInsurerID[0].value.split("-")[0]
  429. }
  430. if (!!item.infos.DPMaintainerID && !!item.infos.DPMaintainerID[0].value) {
  431. item.infos.DPMaintainerID[0].value = item.infos.DPMaintainerID[0].value.split("-")[0]
  432. }
  433. if (!!item.infos.DPSpecificationID && !!item.infos.DPSpecificationID[0].value) {
  434. item.infos.DPSpecificationID[0].value = item.infos.DPSpecificationID[0].value.split("-")[0]
  435. }
  436. })
  437. BatchCreateSome(param, res => {
  438. console.log(res)
  439. this.createPost(param.data.criterias, res.Content)
  440. this.dialog.addDevice = false
  441. console.log(this.deviceType)
  442. this.$emit("close", this.deviceType)
  443. tools.removeItem(this.deviceType.code)
  444. })
  445. },
  446. //c创建请求
  447. async createPost(param, data) {
  448. console.log(param, data)
  449. let pushParam = {
  450. data: { criterias: [] },
  451. ProjId: this.projectId,
  452. secret: this.secret
  453. }
  454. let list = []
  455. data.map((item, index) => {
  456. //linkSystem存在且长度不为0
  457. if (!!param[index].linkSystem && param[index].linkSystem.length) {
  458. param[index].linkSystem.map(child => {
  459. let list = {
  460. "from_id": child.id, //必填,object id
  461. "to_id": item.id, //必填,object id
  462. "graph_id": this.graphyId, //必填,图实例id
  463. "rel_type": "1",
  464. }
  465. pushParam.data.criterias.push(list)
  466. })
  467. }
  468. if (!!param[index].Checked) {
  469. param[index].id = item.id
  470. list.push(param[index])
  471. }
  472. })
  473. await this.EqCreateAs(list)
  474. await this.relationCreate(pushParam)
  475. },
  476. //根据设备id创建资产
  477. async EqCreateAs(list) {
  478. let param = {
  479. FmList: [],
  480. ProjId: this.projectId,
  481. UserId: this.userId
  482. }
  483. list.map(item => {
  484. param.FmList.push({
  485. EquipmentId: item.id,
  486. FmId: "Pe" + uuid(32, 16),
  487. FmName: item.EquipLocalName || "",
  488. Family: this.deviceType.assetType,
  489. FamilyName: this.deviceType.assetName,
  490. ProjId: this.projectId,
  491. Inofs: {
  492. DPManufacturerID: item.infos.DPManufacturerID ? item.infos.DPManufacturerID[0].value : null,
  493. DPSpecificationID: item.infos.DPSpecificationID ? item.infos.DPSpecificationID[0].value : null,
  494. DPSupplierID: item.infos.DPSupplierID ? item.infos.DPSupplierID[0].value : null,
  495. DPMaintainerID: item.infos.DPMaintainerID ? item.infos.DPMaintainerID[0].value : null,
  496. DPInsurerID: item.infos.DPInsurerID ? item.infos.DPInsurerID[0].value : null,
  497. }
  498. })
  499. })
  500. await createAssetsList(param, res => {
  501. return true
  502. })
  503. },
  504. //创建关系
  505. async relationCreate(param) {
  506. await createRelation(param).then(res => {
  507. if (res.data.Result == "success") {
  508. return true
  509. } else {
  510. this.$message.error("请求失败:" + res.data.ResultMsg)
  511. }
  512. }).catch(_ => {
  513. this.$message.error("请求失败")
  514. })
  515. },
  516. changeWatch() {
  517. this.getData()
  518. },
  519. /**
  520. * 表头文案处理函数
  521. * @param list header数组数据
  522. *
  523. * @return 处理好的文案
  524. */
  525. delHeader(list) {
  526. let arr = tools.copyArr(list)
  527. // 如果不是只读状态,添加四大厂商选择
  528. if (!this.onlyRead) {
  529. arr = showTools.arrToArr(arr)
  530. }
  531. let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2"]
  532. readArr.push("Own")
  533. let data = showTools.changeHeader(arr, readArr, false, this.isWatch, true)
  534. data.unshift("同时创建资产", "所属系统实例");
  535. if (this.floorFalg) {
  536. data.splice(1, 0, "所属建筑楼层")
  537. }
  538. return data;
  539. },
  540. /**
  541. * 表头数据处理函数
  542. * @param list header数组数据
  543. *
  544. * @return 处理好的数据格式
  545. */
  546. getType(list) {
  547. let arr = tools.copyArr(list)
  548. if (!this.onlyRead) {
  549. arr = showTools.arrToArr(arr)
  550. }
  551. let data = showTools.showTypes(arr, this.onlyRead, this.isWatch, true)
  552. data.unshift(
  553. {
  554. type: "checkbox",
  555. checkedTemplate: 1,
  556. uncheckedTemplate: 0,
  557. data: "Checked",
  558. label: {
  559. position: "after",
  560. }
  561. },
  562. {
  563. data: "linkSystem",
  564. renderer: text.systemList,
  565. readOnly: true
  566. }
  567. );
  568. if (this.floorFalg) {
  569. data.splice(1, 0, {
  570. data: "flowBuild",
  571. renderer: tools.customDropdownRenderer,
  572. editor: "chosen",
  573. chosenOptions: {
  574. // multiple: true,//多选
  575. data: this.floorData
  576. }
  577. })
  578. }
  579. return data;
  580. },
  581. //初始化插件
  582. initHot() {
  583. var container = document.getElementById("myHandson");
  584. let winHeight = document.documentElement.clientHeight;
  585. console.log(this.delHeader(this.headers), this.getType(this.headers))
  586. this.hot = new Handsontable(container, {
  587. data: this.main,
  588. colHeaders: this.delHeader(this.headers), //表头文案
  589. columns: this.getType(this.headers), //数据显示格式
  590. filters: true,
  591. maxRows: this.main.length,
  592. rowHeaders: true,
  593. height: winHeight - 100 - 50 - 60,
  594. columnSorting: true, //添加排序
  595. sortIndicator: true, //添加排序
  596. renderAllRows: true,
  597. autoColumnSize: true,
  598. language: "zh-CN",
  599. manualColumnResize: true,
  600. manualColumnMove: true,
  601. dropdownMenu: [
  602. "filter_by_condition",
  603. "filter_by_value",
  604. "filter_action_bar"
  605. ],
  606. contextMenu: {
  607. items: {
  608. remove_row: {
  609. name: "删除该业务空间"
  610. }
  611. }
  612. },
  613. filters: true,
  614. afterFilter: this.trimmedRows,
  615. // 事件
  616. afterChange: this.tdChange, //修改后
  617. afterFilter: this.trimmedRows, //排序前
  618. beforeRemoveRow: this.romoveFm, //右键删除
  619. afterOnCellMouseDown: this.eventClick //鼠标点击
  620. // afterOnCellMouseUp: this.eventClick
  621. });
  622. let pro = document.getElementById("hot-display-license-info");
  623. if (!!pro) {
  624. pro.parentNode.removeChild(pro);
  625. }
  626. this.isLoading = false;
  627. },
  628. tdChange() {
  629. tools.setItem(this.deviceType.code, this.main)
  630. },
  631. //表格中的点击
  632. eventClick(el, rowArr) {
  633. console.log(el, rowArr)
  634. //点击的是表头
  635. if (rowArr.row < 0) {
  636. return;
  637. }
  638. let filter = this.filtersArr;
  639. //被筛选过后的数组
  640. let trimmedArr = this.trimmedRows();
  641. //是否启用了排序
  642. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  643. if (trimmedArr.length && isSort) {
  644. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  645. .__arrayMap;
  646. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  647. this.getInfors(infos, sortArr[rowArr.row]);
  648. } else if (isSort) {
  649. //排序后的数组
  650. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  651. let infos = this.main[sortArr[rowArr.row]];
  652. this.getInfors(infos, sortArr[rowArr.row]);
  653. } else if (trimmedArr.length) {
  654. let infos = this.main[trimmedArr[rowArr.row]];
  655. this.getInfors(infos, trimmedArr[rowArr.row]);
  656. } else {
  657. let infos = this.main[rowArr.row];
  658. this.getInfors(infos, rowArr);
  659. }
  660. },
  661. getInfors(infos, row) {
  662. //其他的开始判断
  663. let val = this.hot.colToProp(row.col);
  664. if (val == "linkSystem") {
  665. this.systemList = this.main[row.row].linkSystem || []
  666. this.dialog.systemType = true
  667. }
  668. // if (val == "infos.Brand" || val == "infos.Specification") {
  669. // this.myDialog.firm = true;
  670. // }
  671. if (val == "infos.DPManufacturerID") {
  672. this.myDialog.firm = true;
  673. }
  674. if (val == "infos.SupplierContractID") {
  675. let falg = null
  676. if (!!this.main[row.row].infos) {
  677. if (!!this.main[row.row].infos.DPSupplierID) {
  678. falg = this.main[row.row].infos.DPSupplierID.split("-")[0]
  679. }
  680. }
  681. if (!!falg) {
  682. this.id = falg
  683. this.myDialog.supply = true;
  684. } else {
  685. this.$message("请先选择供应商")
  686. }
  687. }
  688. if (val == "infos.InsuranceNum") {
  689. //选择保单
  690. let falg = null
  691. if (!!this.main[row.row].infos) {
  692. if (!!this.main[row.row].infos.DPInsurerID) {
  693. falg = this.main[row.row].infos.DPInsurerID.split("-")[0]
  694. }
  695. }
  696. if (!!falg) {
  697. this.id = falg
  698. this.myDialog.guarantee = true;
  699. } else {
  700. this.$message("请先选择保险商")
  701. }
  702. }
  703. if (val == "infos.InsuranceFile" || val == "infos.Archive") {
  704. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  705. this.myDialog.uploadFiles = true
  706. }
  707. if (
  708. val == "infos.InstallPic" ||
  709. val == "infos.InstallDrawing" ||
  710. val == "infos.Nameplate" ||
  711. val == "infos.Drawing"
  712. ) {
  713. if (val == "infos.Nameplate") {
  714. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  715. } else {
  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. }
  718. this.myDialog.uploadImgs = true
  719. }
  720. if (val == "infos.Pic") {
  721. // console.log(this.main[row.row].infos[val.split(".")[1]], "this.main[row.row].infos[val.split")
  722. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  723. this.myDialog.pic = true
  724. }
  725. if (
  726. val == "infos.DPSupplierID"
  727. ) {
  728. if (!!this.main[row.row].Checked) {
  729. this.myDialog.supplier = true;
  730. } else {
  731. this.$message("该信息点需勾选同步创建资产方可编辑")
  732. }
  733. }
  734. if (val == "infos.DPMaintainerID"
  735. ) {
  736. if (!!this.main[row.row].Checked) {
  737. this.myDialog.maintainer = true;
  738. } else {
  739. this.$message("该信息点需勾选同步创建资产方可编辑")
  740. }
  741. }
  742. if (
  743. val == "infos.DPInsurerID"
  744. ) {
  745. if (!!this.main[row.row].Checked) {
  746. this.myDialog.insurer = true;
  747. } else {
  748. this.$message("该信息点需勾选同步创建资产方可编辑")
  749. }
  750. }
  751. this.row = row.row
  752. this.messKey = val
  753. console.log(val, row);
  754. },
  755. //获取被筛选掉的行号
  756. trimmedRows() {
  757. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  758. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  759. let dataLength = this.main.length;
  760. let dataArr = new Array();
  761. for (let i = 0; i < dataLength; i++) {
  762. dataArr.push(i);
  763. }
  764. if (plugin.length <= 0) {
  765. dataArr = undefined;
  766. } else {
  767. dataArr = this.array_diff(dataArr, plugin);
  768. }
  769. return dataArr || [];
  770. // var DataArray = new Array();
  771. // for (var i = 0; i < plugin.length; i++) {
  772. // // 通过行号获取数据
  773. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  774. // }
  775. },
  776. //判断是否为空行
  777. isEmptyRow(instance, row) {
  778. var rowData = instance.countRows();
  779. for (var i = 0, ilen = rowData.length; i < ilen; i++) {
  780. if (rowData[i] !== null) {
  781. return false;
  782. }
  783. }
  784. return true;
  785. },
  786. //选择型号修改
  787. firmChange(data) {
  788. for (let key in data) {
  789. // this.utilToKey(key, "brand", data, "Brand")
  790. // this.utilToKey(key, "name", data, "Specification")
  791. // this.utilToKey(key, "venderName", data, "Manufacturer")
  792. if (key == "venderId") {
  793. data[key] = data[key] + "-" + data.name + "/" + data.brand
  794. this.utilToKey(key, "venderId", data, "DPManufacturerID")
  795. }
  796. this.utilToKey(key, "specificationId", data, "DPSpecificationID")
  797. }
  798. tools.setItem(this.deviceType.code, this.main)
  799. },
  800. //供应商合同
  801. supplyChange(data) {
  802. let changeData = { id: data }
  803. this.utilToKey("id", "id", changeData, "SupplierContractID")
  804. tools.setItem(this.deviceType.code, this.main)
  805. },
  806. //保险合同
  807. guaranteeChange(data) {
  808. console.log("保险合同发生改变", data)
  809. for (let key in data) {
  810. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  811. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  812. }
  813. tools.setItem(this.deviceType.code, this.main)
  814. },
  815. //如果选择供应商之后
  816. supplierChange(data) {
  817. console.log("供应商", data)
  818. for (let key in data) {
  819. // this.utilToKey(key, "name", data, "Supplier")
  820. // this.utilToKey(key, "email", data, "SupplierEmail")
  821. // this.utilToKey(key, "website", data, "SupplierWeb")
  822. // this.utilToKey(key, "phone", data, "SupplierPhone")
  823. // this.utilToKey(key, "fox", data, "SupplierFax")
  824. // this.utilToKey(key, "man", data, "SupplierContactor")
  825. if (key == "venderId") {
  826. data[key] = data[key] + "-" + data.name
  827. console.log(data)
  828. this.utilToKey(key, "venderId", data, "DPSupplierID")
  829. }
  830. }
  831. tools.setItem(this.deviceType.code, this.main)
  832. },
  833. //保险商变更
  834. changeInsurer(data) {
  835. for (let key in data) {
  836. // this.utilToKey(key, "name", data, "Insurer")
  837. // this.utilToKey(key, "email", data, "InsurerEmail")
  838. // this.utilToKey(key, "website", data, "InsurerWeb")
  839. // this.utilToKey(key, "phone", data, "InsurerFax")
  840. // this.utilToKey(key, "man", data, "InsurerContactor")
  841. if (key == "venderId") {
  842. data[key] = data[key] + "-" + data.name
  843. this.utilToKey(key, "venderId", data, "DPInsurerID")
  844. }
  845. }
  846. tools.setItem(this.deviceType.code, this.main)
  847. },
  848. //维修商变更
  849. changeMaintainer(data) {
  850. console.log(data, "data")
  851. for (let key in data) {
  852. // this.utilToKey(key, "name", data, "Maintainer")
  853. // this.utilToKey(key, "email", data, "MaintainerEmail")
  854. // this.utilToKey(key, "website", data, "MaintainerWeb")
  855. // this.utilToKey(key, "phone", data, "MaintainerPhone")
  856. // this.utilToKey(key, "fox", data, "MaintainerFax")
  857. // this.utilToKey(key, "man", data, "MaintainerContactor")
  858. if (key == "venderId") {
  859. data[key] = data[key] + "-" + data.name
  860. this.utilToKey(key, "venderId", data, "DPMaintainerID")
  861. }
  862. }
  863. tools.setItem(this.deviceType.code, this.main)
  864. },
  865. utilToKey(key, name, data, messName) {
  866. if (key == name) {
  867. this.setDataToMain(data[key], messName, this.row)
  868. }
  869. },
  870. //上传文件弹窗触发事件
  871. fileChange(keys) {
  872. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  873. tools.setItem(this.deviceType.code, this.main)
  874. },
  875. //上传图片弹窗触发事件
  876. imgChange(keys) {
  877. console.log(keys, "keys", this.messKey.split("."), this.row,'22222222222222')
  878. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  879. tools.setItem(this.deviceType.code, this.main)
  880. },
  881. //设备图片弹窗改变事件
  882. changePics(keys) {
  883. console.log(keys, "keys", this.messKey.split("."), this.row,'22222222222222')
  884. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  885. tools.setItem(this.deviceType.code, this.main)
  886. },
  887. //系统实例弹窗确定
  888. setSystem(data) {
  889. this.main[this.row].linkSystem = data
  890. tools.setItem(this.deviceType.code, this.main)
  891. },
  892. //判断是否有值,有值赋值
  893. setDataToMain(data, key, row) {
  894. if (!!data && data != '--') {
  895. if (!!this.main[row].infos) {
  896. //铭牌照片特殊处理
  897. this.main[row].infos[key] = data
  898. } else {
  899. this.main[row].infos = {}
  900. this.main[row].infos[key] = data
  901. }
  902. } else {
  903. this.main[row].infos[key] = ''
  904. }
  905. }
  906. },
  907. watch: {
  908. dialog: {
  909. deep: true,
  910. handler: function () {
  911. if (this.dialog.addDevice) {
  912. this.setValue()
  913. }
  914. }
  915. }
  916. }
  917. };
  918. </script>
  919. <style lang="less" scoped>
  920. #addDevice {
  921. overflow: hidden;
  922. }
  923. </style>