dialogDevice.vue 30 KB

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