dialogDevice.vue 30 KB

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