system.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. <template>
  2. <div>
  3. <div class="hanson-bar">
  4. <span>当前筛选条件下共{{page.total || '--'}}系统</span>
  5. <div style="width:300px;float:right;overflow:hidden;">
  6. <el-button size="small" @click="addDevice" icon="iconfont icon-tianjia">添加系统</el-button>
  7. <el-button size="small" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
  8. <el-button size="small" @click="undo" icon="iconfont icon-undo">撤销</el-button>
  9. </div>
  10. <div style="width:200px;color:gray;float:right;padding-top:7px;font-size:10px;">
  11. <span v-if="!onlyRead">隐藏自动填充的信息点:</span>
  12. <el-tooltip v-if="!onlyRead" :content="'' + (isWatch ? '隐藏' : '不隐藏')" placement="top">
  13. <el-switch
  14. @change="changeWatch"
  15. v-model="isWatch"
  16. active-color="#13ce66"
  17. inactive-color="gray"
  18. ></el-switch>
  19. </el-tooltip>
  20. <span v-if="onlyRead">只看要采集的信息:</span>
  21. <el-tooltip v-if="onlyRead" :content="'' + (allMess ? '部分' : '全集')" placement="top">
  22. <el-switch
  23. @change="changeWatch"
  24. v-model="allMess"
  25. active-color="#13ce66"
  26. inactive-color="gray"
  27. ></el-switch>
  28. </el-tooltip>
  29. </div>
  30. <div
  31. style="width:90px;cursor: pointer;color:gray;float:right; font-size:10px;padding-top:7px;"
  32. >
  33. <p v-if="onlyRead" @click="changeRead">
  34. <i class="iconfont icon-yulan"></i>
  35. <span>只读模式</span>
  36. </p>
  37. <p v-else @click="changeRead">
  38. <i class="iconfont icon-yulan"></i>
  39. <span>编辑模式</span>
  40. </p>
  41. </div>
  42. </div>
  43. <qrcode :dialog="dialog" :addBody="true" ref="qrcode"></qrcode>
  44. <firm ref="firm" :dialog="dialog"></firm>
  45. <supply-dialog ref="supply" :dialog="dialog"></supply-dialog>
  46. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="dialog"></supplier-dialog>
  47. <guarantee-dialog ref="guarantee" :dialog="dialog"></guarantee-dialog>
  48. <upload-files-dialog ref="upload" @changeFile="fileChange" :keysArr="filesArr" :dialog="dialog"></upload-files-dialog>
  49. <upload-img-dialog @changeFile="imgChange" :keysArr="imgsArr" :dialog="dialog"></upload-img-dialog>
  50. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="dialog"></maintainer-dialog>
  51. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="dialog"></insurer-dialog>
  52. <pic-dialog :dialog="dialog" :keysArr="picsArr" @change="changePics"></pic-dialog>
  53. <div
  54. v-show="!main || !main.length"
  55. style="width:100%;text-align:center;font-size:30px;color:gray;"
  56. >请选择系统类型</div>
  57. <div v-show="main && main.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
  58. <my-pagination v-show="main && main.length" @change="getMain" :page="page"></my-pagination>
  59. <dialog-assets
  60. :assetType="[this.mess.deviceId]"
  61. @close="getClose"
  62. v-if="dialog.addDevice"
  63. ref="assets"
  64. :dialog="dialog"
  65. ></dialog-assets>
  66. <details-dialog :iframeSrc="iframeSrc" v-if="dialog.details" :dialog="dialog"></details-dialog>
  67. <system-relevance @close="reset" :id="systemId" :dialog="dialog"></system-relevance>
  68. </div>
  69. </template>
  70. <script>
  71. import { getTableHeader, getBillSystemList, updateBusiness, BeatchQueryParam, delBatchList } from "@/api/scan/request";
  72. import tools from "@/utils/scan/tools";
  73. import handsonUtils from "@/utils/scan/hasontableUtils"
  74. import showTools from "@/utils/handsontable/notShow"
  75. import qrcode from "@/components/business_space/lib/qrcode";
  76. import firm from "@/components/business_space/dialogs/list/firm";
  77. import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog";
  78. import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog";
  79. import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog";
  80. import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog";
  81. import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog";
  82. import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog";
  83. import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog";
  84. import picDialog from "@/components/business_space/dialogs/list/picDialog"
  85. import myPagination from "@/components/common/myPagination";
  86. import dialogAssets from "@/components/ledger/addDialog/dialogSystem";
  87. import detailsDialog from "@/components/business_space/lib/detailsDia"
  88. import systemRelevance from "@/components/ledger/tableTransfers"
  89. import Handsontable from "handsontable-pro"
  90. import 'handsontable-pro/dist/handsontable.full.css'
  91. import zhCN from 'handsontable-pro/languages/zh-CN';
  92. import {
  93. mapGetters,
  94. mapActions
  95. } from "vuex";
  96. //下拉插件
  97. // import "@/assets/js/chosen.jquery.min";
  98. // import "@/assets/js/handsontable-chosen-editor";
  99. export default {
  100. components: {
  101. qrcode, //二维码页面
  102. firm, //
  103. supplyDialog,
  104. supplierDialog,
  105. guaranteeDialog,
  106. uploadFilesDialog,
  107. maintainerDialog,
  108. insurerDialog,
  109. uploadImgDialog,
  110. picDialog,
  111. myPagination,
  112. dialogAssets,
  113. detailsDialog,
  114. systemRelevance
  115. },
  116. computed: {
  117. ...mapGetters("peojMess", [
  118. "projectId",
  119. "secret",
  120. "userId"
  121. ])
  122. },
  123. data() {
  124. return {
  125. main: [],
  126. mess: {},
  127. headers: null,
  128. page: {
  129. size: 50,
  130. sizes: [10, 30, 50, 100, 150, 200],
  131. total: 0,
  132. currentPage: 1
  133. },
  134. dialog: {
  135. qrcode: false, //二维码弹窗
  136. firm: false, //厂商弹窗
  137. supply: false, //选择供应合同
  138. supplier: false, //供应商选择
  139. guarantee: false, //选择保单
  140. maintainer: false, //选择维修商
  141. insurer: false, //选择保险公司
  142. uploadFiles: false,//上传文件
  143. uploadImgs: false,//上传单个图片
  144. pic: false, //多个图片
  145. addDevice: false,
  146. details: false,//详情页
  147. relevance: false,//关联设备
  148. },
  149. row: null,//被修改的row
  150. filesArr: [],//保存临时的文件key
  151. messKey: null,
  152. imgsArr: [],//临时保存的图片key数组
  153. picsArr: [],//临时设备图片keys数组
  154. noShowList: ["SysID", "SysName"],
  155. copyMain: null,
  156. iframeSrc: "",
  157. systemId: "",
  158. onlyRead: true,
  159. allMess: true,
  160. linkNameFalg: false,
  161. qrcodeUrl: "",//二维码图片地址
  162. isWatch: true,
  163. loading: false,
  164. };
  165. },
  166. created() {
  167. },
  168. mounted() { },
  169. methods: {
  170. //触发父组件change
  171. getClose(val) {
  172. this.$emit("close", val)
  173. },
  174. //获取表头
  175. getHeaderData(code) {
  176. this.mess = code
  177. getTableHeader({
  178. code: this.mess.deviceId,
  179. ProjId: this.projectId
  180. }).then(res => {
  181. this.headers = res.data.Content;
  182. this.getMain()
  183. });
  184. },
  185. changeRead() {
  186. this.onlyRead = !this.onlyRead
  187. this.getMain()
  188. },
  189. changeWatch() {
  190. this.reset()
  191. },
  192. //获取主体数据
  193. getMain() {
  194. let _this = this
  195. let param = {
  196. data: {
  197. customInfo: true,
  198. "limit": { // 分页查询, 选填.
  199. "skip": this.page.size * (this.page.currentPage - 1), // 跳过多少数据
  200. "count": this.page.size // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
  201. },
  202. criteria: {
  203. id: "",
  204. type: [this.mess.deviceId]
  205. }
  206. },
  207. secret: this.secret,
  208. ProjId: this.projectId
  209. }
  210. if (this.mess.buildId == "all") {
  211. param.data.criteria.id = this.mess.ProjId
  212. } else if (!this.mess.floorId && !this.mess.buildId) {
  213. param.data.criteria.id = this.mess.ProjId
  214. } else {
  215. param.data.criteria.id = this.mess.buildId
  216. }
  217. this.loading = true
  218. getBillSystemList(param, res => {
  219. if (_this.onlyRead) {
  220. this.getBatch(res.Content)
  221. }
  222. this.loading = false
  223. this.main = res.Content
  224. this.copyMain = tools.deepCopy(res.Content)
  225. this.page.total = res.Count
  226. if (!!this.hot) {
  227. this.hot.destroy();
  228. this.hot = null;
  229. }
  230. if (!!res.Content && res.Content.length) {
  231. this.initHot();
  232. }
  233. })
  234. },
  235. //撤回
  236. undo() {
  237. this.hot.undo();
  238. },
  239. //刷新
  240. reset() {
  241. this.getMain();
  242. },
  243. //添加设备
  244. addDevice() {
  245. this.dialog.addDevice = true
  246. this.$nextTick(() => {
  247. this.$refs.assets.step(0)
  248. })
  249. },
  250. /**
  251. * 表头文案处理函数
  252. * @param list header数组数据
  253. *
  254. * @return 处理好的文案
  255. */
  256. delHeader(list) {
  257. let arr = tools.copyArr(list)
  258. // 如果不是只读状态,添加四大厂商选择
  259. // if (!this.onlyRead) {
  260. // arr = showTools.assetToArr(arr)
  261. // }
  262. // console.log(arr)
  263. let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "X", "L", "L1", "L2", "F1", "F2"]
  264. let data = showTools.changeHeader(arr, readArr, this.onlyRead, this.isWatch, this.allMess)
  265. data.unshift("操作", "关联设备数量");
  266. return data;
  267. },
  268. /**
  269. * 表头数据处理函数
  270. * @param list header数组数据
  271. *
  272. * @return 处理好的数据格式
  273. */
  274. getType(list) {
  275. let arr = tools.copyArr(list)
  276. let data = showTools.showTypes(arr, this.onlyRead, this.isWatch, this.allMess)
  277. data.unshift(
  278. {
  279. data: "caozuo",
  280. renderer: tools.lookDetails,
  281. readOnly: true
  282. },
  283. {
  284. data: "count",
  285. renderer: tools.num,
  286. readOnly: true
  287. }
  288. );
  289. data = data.filter(item => item);
  290. if (this.onlyRead) {
  291. data.map(item => {
  292. item.readOnly = true
  293. })
  294. }
  295. return data;
  296. },
  297. changeItem(item) {
  298. //二维码
  299. if (item.infopoint_code == "EquipQRCode" && item.visible) {
  300. return {
  301. data: "infos." + item.infopoint_code,
  302. renderer: text.lookQRCode,
  303. readOnly: true
  304. }
  305. }
  306. //厂商选择
  307. // if ((item.infopoint_code == "Brand" || item.infopoint_code == "Specification") && item.visible) {
  308. // return {
  309. // data: "infos." + item.infopoint_code,
  310. // renderer: tools.lookDetails,
  311. // readOnly: true
  312. // }
  313. // }
  314. // if (item.infopoint_code == "SupplierContractID" && item.visible) {
  315. // return {
  316. // data: "infos." + item.infopoint_code,
  317. // renderer: tools.lookDetails,
  318. // readOnly: true
  319. // }
  320. // }
  321. if (item.infopoint_code == "InsuranceNum" && item.visible) {
  322. //选择保单
  323. return {
  324. data: "infos." + item.infopoint_code,
  325. renderer: tools.lookDetails,
  326. readOnly: true
  327. }
  328. }
  329. if ((item.infopoint_code == "InsuranceFile" || item.infopoint_code == "Archive") && item.visible) {
  330. return {
  331. data: "infos." + item.infopoint_code,
  332. renderer: tools.lookDetails,
  333. readOnly: true
  334. }
  335. }
  336. if (
  337. (
  338. item.infopoint_code == "InstallPic" ||
  339. item.infopoint_code == "InstallDrawing" ||
  340. item.infopoint_code == "Nameplate" ||
  341. item.infopoint_code == "Pic" ||
  342. item.infopoint_code == "Drawing"
  343. ) && item.visible
  344. ) {
  345. return {
  346. data: "infos." + item.infopoint_code,
  347. renderer: tools.lookDetails,
  348. readOnly: true
  349. }
  350. }
  351. if (
  352. (
  353. item.infopoint_code == "Maintainer" ||
  354. item.infopoint_code == "Supplier" ||
  355. item.infopoint_code == "Insurer" ||
  356. item.infopoint_code == "InsurerContactor"
  357. )
  358. && item.visible
  359. ) {
  360. return {
  361. data: "infos." + item.infopoint_code,
  362. }
  363. }
  364. if (item.collection_cmpt_code == "Enum" && item.visible) {
  365. return {
  366. data: "infos." + item.infopoint_code,
  367. renderer: this.customDropdownRenderer,
  368. editor: "chosen",
  369. chosenOptions: {
  370. // multiple: true,//多选
  371. data: item.dataSource || ""
  372. }
  373. };
  374. } else if (item.collection_cmpt_code == "Num" && item.visible) {
  375. return {
  376. data: "infos." + item.infopoint_code,
  377. type: "numeric",
  378. numericFormat: {
  379. pattern: "0,0.00"
  380. // culture: 'de-DE' // use this for EUR (German),
  381. // more cultures available on http://numbrojs.com/languages.html
  382. }
  383. };
  384. } else if (item.collection_cmpt_code == "Time" && item.visible) {
  385. return {
  386. data: "infos." + item.infopoint_code,
  387. type: "date",
  388. dateFormat: "YYYY-MM-DD",
  389. correctFormat: true
  390. };
  391. } else if (item.collection_cmpt_code == "text" && item.visible) {
  392. return {
  393. data: "infos." + item.infopoint_code
  394. };
  395. } else if (
  396. (item.info_point_code == "设备ID" ||
  397. item.info_point_code == "设备名称") && item.visible
  398. ) {
  399. return {
  400. data: "infos." + item.infopoint_code,
  401. readOnly: true
  402. };
  403. } else if (item.collection_cmpt_code == "checkBox" && item.visible) {
  404. return {
  405. data: "infos." + item.infopoint_code,
  406. renderer: this.customDropdownRenderer,
  407. editor: "chosen",
  408. chosenOptions: {
  409. multiple: true,//多选
  410. data: item.dataSource || ""
  411. }
  412. };
  413. } else if (item.collection_cmpt_code == "Own" && item.visible) {
  414. return {
  415. data: "infos." + item.infopoint_code,
  416. renderer: text.idType,
  417. }
  418. } else {
  419. return undefined
  420. }
  421. },
  422. //插件修改
  423. customDropdownRenderer(
  424. instance,
  425. td,
  426. row,
  427. col,
  428. prop,
  429. value,
  430. cellProperties
  431. ) {
  432. var selectedId;
  433. var optionsList = cellProperties.chosenOptions.data;
  434. if (
  435. typeof optionsList === "undefined" ||
  436. typeof optionsList.length === "undefined" ||
  437. !optionsList.length
  438. ) {
  439. Handsontable.renderers.TextRenderer(
  440. instance,
  441. td,
  442. row,
  443. col,
  444. prop,
  445. value,
  446. cellProperties
  447. );
  448. return td;
  449. }
  450. var values = (value + "").split(",");
  451. value = [];
  452. for (var index = 0; index < optionsList.length; index++) {
  453. if (values.indexOf(optionsList[index].code + "") > -1) {
  454. selectedId = optionsList[index].code;
  455. value.push(optionsList[index].name);
  456. }
  457. }
  458. value = value.join(", ");
  459. Handsontable.renderers.TextRenderer(
  460. instance,
  461. td,
  462. row,
  463. col,
  464. prop,
  465. value,
  466. cellProperties
  467. );
  468. return td;
  469. },
  470. messShow(item) {
  471. if (item.collection_cmpt_code == "Enum") {
  472. return {
  473. data: "infos." + item.infopoint_code,
  474. renderer: this.customDropdownRenderer,
  475. editor: "chosen",
  476. chosenOptions: {
  477. // multiple: true,//多选
  478. data: item.dataSource || ""
  479. }
  480. };
  481. } else if (item.collection_cmpt_code == "Num") {
  482. return {
  483. data: "infos." + item.infopoint_code,
  484. type: "numeric",
  485. numericFormat: {
  486. pattern: "0,0.00"
  487. // culture: 'de-DE' // use this for EUR (German),
  488. // more cultures available on http://numbrojs.com/languages.html
  489. }
  490. };
  491. } else if (item.collection_cmpt_code == "Time") {
  492. return {
  493. data: "infos." + item.infopoint_code,
  494. type: "date",
  495. dateFormat: "YYYY-MM-DD",
  496. correctFormat: true
  497. };
  498. } else if (item.collection_cmpt_code == "text") {
  499. return {
  500. data: "infos." + item.infopoint_code
  501. };
  502. } else if (
  503. (item.info_point_code == "设备ID" ||
  504. item.info_point_code == "设备名称")
  505. ) {
  506. return {
  507. data: "infos." + item.infopoint_code,
  508. readOnly: true
  509. };
  510. } else if (item.collection_cmpt_code == "checkBox") {
  511. return {
  512. data: "infos." + item.infopoint_code,
  513. renderer: this.customDropdownRenderer,
  514. editor: "chosen",
  515. chosenOptions: {
  516. multiple: true,//多选
  517. data: item.dataSource || ""
  518. }
  519. };
  520. } else {
  521. return {
  522. data: "infos." + item.infopoint_code,
  523. }
  524. }
  525. },
  526. //获取动态参数
  527. getBatch(data) {
  528. console.log(this.headers, data, "data22222")
  529. let param = {
  530. secret: this.secret,
  531. ProjId: this.projectId,
  532. data: {
  533. criterias: []
  534. }
  535. }
  536. if (!!data && data.length) {
  537. //一级遍历list
  538. data.map(item => {
  539. if (!!item.infos) {
  540. //二级遍历对象infos
  541. for (let key in item.infos) {
  542. //判断是否是设定参数和动态参数
  543. if (!!item.infos[key]) {
  544. this.headers.map(child => {
  545. //如果一级标签为动态参数或者设定参数放入数据等待请求
  546. if (key == child.infoPointCode && (child.InputMode == "L" || child.InputMode == "L1" || child.InputMode == "L2")) {
  547. param.data.criterias.push({
  548. id: item.id,
  549. code: key
  550. })
  551. }
  552. })
  553. }
  554. }
  555. }
  556. })
  557. if (param.data.criterias.length) {
  558. BeatchQueryParam(param, res => {
  559. if (!this.onlyRead) {
  560. return false
  561. }
  562. this.main = data.map(item => {
  563. res.Content.map(child => {
  564. if (item.id == child.id) {
  565. if (!!child.data || child.data == 0) {
  566. item.infos[child.code] = child.data
  567. } else {
  568. item.infos[child.code] = child.error ? "表号功能号格式错误" : "表号功能号不存在"
  569. }
  570. }
  571. })
  572. return item
  573. })
  574. console.log(this.main)
  575. this.hot.loadData(this.main)
  576. })
  577. }
  578. }
  579. },
  580. //初始化插件
  581. initHot() {
  582. var container = document.getElementById("handsontable");
  583. let winHeight = document.documentElement.clientHeight;
  584. this.hot = new Handsontable(container, {
  585. data: this.main,
  586. fixedColumnsLeft: 5,
  587. colHeaders: this.delHeader(this.headers), //表头文案
  588. columns: this.getType(this.headers), //数据显示格式
  589. filters: true,
  590. maxRows: this.main.length,
  591. height: winHeight - 100 - 50 - 270,
  592. columnSorting: true, //添加排序
  593. sortIndicator: true, //添加排序
  594. renderAllRows: true,
  595. // colWidths: 200,
  596. autoColumnSize: true,
  597. language: "zh-CN",
  598. manualColumnResize: true,
  599. manualColumnMove: true,
  600. dropdownMenu: [
  601. "filter_by_condition",
  602. "filter_by_value",
  603. "filter_action_bar"
  604. ],
  605. contextMenu: {
  606. items: {
  607. remove_row: {
  608. name: "删除该系统"
  609. }
  610. }
  611. },
  612. // 事件
  613. afterChange: this.tdChange, //修改后
  614. afterFilter: this.trimmedRows, //排序前
  615. afterRemoveRow: this.romoveFm, //右键删除
  616. afterOnCellMouseDown: this.eventClick //鼠标点击
  617. });
  618. let pro = document.getElementById("hot-display-license-info");
  619. if (!!pro) {
  620. pro.parentNode.removeChild(pro);
  621. }
  622. this.isLoading = false;
  623. },
  624. //表格中的点击
  625. eventClick(el, rowArr) {
  626. //点击的是表头
  627. if (rowArr.row < 0) {
  628. return;
  629. }
  630. //被筛选过后的数组
  631. let trimmedArr = this.trimmedRows();
  632. //是否启用了排序
  633. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  634. if (trimmedArr.length && isSort) {
  635. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  636. .__arrayMap;
  637. let infos = this.main[trimmedArr[sortArr[rowArr.row]]];
  638. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
  639. } else if (isSort) {
  640. //排序后的数组
  641. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  642. let infos = this.main[sortArr[rowArr.row]];
  643. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col });
  644. } else if (trimmedArr.length) {
  645. let infos = this.main[trimmedArr[rowArr.row]];
  646. this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col });
  647. } else {
  648. let infos = this.main[rowArr.row];
  649. this.getInfors(infos, rowArr);
  650. }
  651. },
  652. tdChange(changeData, source) {
  653. if (!this.onlyRead) {
  654. if (changeData) {
  655. let trimmedArr = this.trimmedRows();
  656. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  657. let data = [];
  658. for (let i = 0; i < param.length; i++) {
  659. data.push(param[i]);
  660. }
  661. //如果data中包含/且data长度为1,将其转换成.
  662. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  663. changeData[0][1] = changeData[0][1].split("/").join(".")
  664. }
  665. //存在data进行修改请求
  666. if (data && data.length) {
  667. this.updateBusiness(data, changeData);
  668. }
  669. }
  670. }
  671. },
  672. //删除资产
  673. async romoveFm() {
  674. this.$confirm('此操作将删除该系统, 是否继续?', '提示', {
  675. confirmButtonText: '确定',
  676. cancelButtonText: '取消',
  677. type: 'warning'
  678. }).then(() => {
  679. let params = tools.differenceArr(this.main, this.copyMain)
  680. console.log(params, "params")
  681. let param = {
  682. secret: this.secret,
  683. ProjId: this.projectId,
  684. data: {
  685. criterias: []
  686. }
  687. }
  688. for (let i = 0; i < params.length; i++) {
  689. param.data.criterias.push({ id: params[i].id })
  690. }
  691. this.removeSys(param)
  692. this.getMain()
  693. }).catch(() => {
  694. this.$message({
  695. type: 'info',
  696. message: '已取消删除'
  697. });
  698. });
  699. },
  700. async removeSys(param) {
  701. await delBatchList(param, res => {
  702. this.$message.success("删除成功")
  703. })
  704. },
  705. // 修改
  706. updateBusiness(data, change) {
  707. let param = {
  708. ProjId: this.mess.ProjId,
  709. secret: this.mess.secret,
  710. data: {
  711. criterias: []
  712. }
  713. };
  714. //生成对应修改数据
  715. data.map((item, index) => {
  716. let arr = change[index][1].split(".");
  717. let info = {};
  718. info[arr[1]] = [{ value: change[index][3] != "" ? change[index][3] : null }];
  719. param.data.criterias.push({
  720. id: item.id,
  721. infos: info
  722. });
  723. });
  724. console.log(param)
  725. param.data.criterias.map(item => {
  726. for (let k in item.infos) {
  727. if (item.infos[k] == "") {
  728. item.infos[k] = null
  729. }
  730. }
  731. })
  732. updateBusiness(param).then(res => {
  733. console.log(res);
  734. });
  735. },
  736. //获取到了正确的信息
  737. getInfors(infos, row) {
  738. //其他的开始判断
  739. let val = this.hot.colToProp(row.col);
  740. this.systemId = infos.id
  741. if (val == "count") {
  742. this.dialog.relevance = true
  743. }
  744. if (val == "caozuo") {
  745. this.iframeSrc =
  746. process.env.BASE_URL +
  747. ":8889/#/details?perjectId=" +
  748. this.projectId +
  749. "&secret=" +
  750. this.secret +
  751. "&FmId=" +
  752. infos.id +
  753. "&type=1&code=" +
  754. infos.category.substring(2, 4);
  755. this.dialog.details = true
  756. }
  757. if (val == "infos.EquipQRCode") {
  758. this.dialog.qrcode = true;
  759. this.$refs.qrcode.getCanvas(1111);
  760. }
  761. // if (val == "infos.Brand" || val == "infos.Specification") {
  762. // this.dialog.firm = true;
  763. // }
  764. // if (val == "infos.SupplierContractID") {
  765. // this.dialog.supply = true;
  766. // }
  767. // if (val == "infos.InsuranceNum") {
  768. // //选择保单
  769. // this.dialog.guarantee = true;
  770. // }
  771. if (val == "infos.InsuranceFile" || val == "infos.Archive") {
  772. this.filesArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  773. this.dialog.uploadFiles = true
  774. }
  775. if (
  776. val == "infos.InstallLocation" ||
  777. val == "infos.InstallPic" ||
  778. val == "infos.InstallDrawing" ||
  779. val == "infos.Nameplate" ||
  780. val == "infos.Drawing"
  781. ) {
  782. if (val == "infos.Nameplate") {
  783. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]].key] : []) : []
  784. } else {
  785. this.imgsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? [this.main[row.row].infos[val.split(".")[1]]] : []) : []
  786. }
  787. this.dialog.uploadImgs = true
  788. }
  789. if (val == "infos.Pic") {
  790. // console.log(this.main[row.row].infos[val.split(".")[1]], "this.main[row.row].infos[val.split")
  791. this.picsArr = this.main[row.row].infos ? (this.main[row.row].infos[val.split(".")[1]] ? this.main[row.row].infos[val.split(".")[1]] : []) : []
  792. this.dialog.pic = true
  793. }
  794. // if (
  795. // val == "infos.Supplier"
  796. // ) {
  797. // this.dialog.supplier = true;
  798. // }
  799. // if (val == "infos.Maintainer") {
  800. // this.dialog.maintainer = true;
  801. // }
  802. // if (
  803. // val == "infos.Insurer" ||
  804. // val == "infos.InsurerContactor") {
  805. // this.dialog.insurer = true;
  806. // }
  807. this.row = row.row
  808. this.messKey = val
  809. console.log(val, row);
  810. },
  811. //获取被筛选掉的行号
  812. trimmedRows() {
  813. // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
  814. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  815. let dataLength = this.main.length;
  816. let dataArr = new Array();
  817. for (let i = 0; i < dataLength; i++) {
  818. dataArr.push(i);
  819. }
  820. if (plugin.length <= 0) {
  821. dataArr = undefined;
  822. } else {
  823. dataArr = this.array_diff(dataArr, plugin);
  824. }
  825. return dataArr || [];
  826. // var DataArray = new Array();
  827. // for (var i = 0; i < plugin.length; i++) {
  828. // // 通过行号获取数据
  829. // DataArray.push(this.hot.getSourceDataAtRow(plugin[i]));
  830. // }
  831. },
  832. //如果选择供应商之后
  833. supplierChange(data) {
  834. for (let key in data) {
  835. if (key == 'name') {
  836. this.setDataToMain(data[key], "Supplier", this.row)
  837. }
  838. if (key == 'email') {
  839. this.setDataToMain(data[key], "SupplierEmail", this.row)
  840. }
  841. if (key == 'website') {
  842. this.setDataToMain(data[key], "SupplierWeb", this.row)
  843. }
  844. if (key == 'phone') {
  845. this.setDataToMain(data[key], "SupplierPhone", this.row)
  846. }
  847. if (key == 'fox') {
  848. this.setDataToMain(data[key], "SupplierFax", this.row)
  849. }
  850. if (key == 'man') {
  851. this.setDataToMain(data[key], "SupplierContactor", this.row)
  852. }
  853. }
  854. // tools.setItem(this.deviceType.code, this.main)
  855. },
  856. //保险商变更
  857. changeInsurer(data) {
  858. for (let key in data) {
  859. if (key == 'name') {
  860. this.setDataToMain(data[key], "Insurer", this.row)
  861. }
  862. if (key == 'email') {
  863. this.setDataToMain(data[key], "InsurerEmail", this.row)
  864. }
  865. if (key == 'website') {
  866. this.setDataToMain(data[key], "InsurerWeb", this.row)
  867. }
  868. if (key == 'phone') {
  869. this.setDataToMain(data[key], "InsurerPhone", this.row)
  870. }
  871. if (key == 'fox') {
  872. this.setDataToMain(data[key], "InsurerFax", this.row)
  873. }
  874. if (key == 'man') {
  875. this.setDataToMain(data[key], "InsurerContactor", this.row)
  876. }
  877. }
  878. // tools.setItem(this.deviceType.code, this.main)
  879. },
  880. //维修商变更
  881. changeMaintainer(data) {
  882. for (let key in data) {
  883. if (key == 'name') {
  884. this.setDataToMain(data[key], "Maintainer", this.row)
  885. }
  886. if (key == 'email') {
  887. this.setDataToMain(data[key], "MaintainerEmail", this.row)
  888. }
  889. if (key == 'website') {
  890. this.setDataToMain(data[key], "MaintainerWeb", this.row)
  891. }
  892. if (key == 'phone') {
  893. this.setDataToMain(data[key], "MaintainerPhone", this.row)
  894. }
  895. if (key == 'fox') {
  896. this.setDataToMain(data[key], "MaintainerFax", this.row)
  897. }
  898. if (key == 'man') {
  899. this.setDataToMain(data[key], "MaintainerContactor", this.row)
  900. }
  901. }
  902. // tools.setItem(this.deviceType.code, this.main)
  903. },
  904. //上传文件弹窗触发事件
  905. fileChange(keys) {
  906. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  907. // tools.setItem(this.deviceType.code, this.main)
  908. },
  909. //上传图片弹窗触发事件
  910. imgChange(keys) {
  911. this.setDataToMain(keys[0], this.messKey.split(".")[1], this.row)
  912. // tools.setItem(this.deviceType.code, this.main)
  913. },
  914. //设备图片弹窗改变事件
  915. changePics(keys) {
  916. this.setDataToMain(keys, this.messKey.split(".")[1], this.row)
  917. // tools.setItem(this.deviceType.code, this.main)
  918. },
  919. //判断是否有值,有值赋值
  920. setDataToMain(data, key, row) {
  921. if (!!data && data != '--') {
  922. if (!!this.main[row].infos) {
  923. //falg确定每个的是否有值
  924. let falg = false
  925. if (!this.main[row].infos[key]) {
  926. falg = true
  927. }
  928. //铭牌照片特殊处理
  929. if (key == 'Nameplate') {
  930. this.main[row].infos[key] = {
  931. "systemId": "dataPlatform",
  932. "name": "铭牌照片",
  933. "type": "image",
  934. "key": data
  935. }
  936. } else {
  937. this.main[row].infos[key] = data
  938. }
  939. if (falg) {
  940. this.updateBusiness([this.main[row]], [[0, "infos." + key, null, data]])
  941. }
  942. } else {
  943. this.main[row].infos = {}
  944. if (key == 'Nameplate') {
  945. this.main[row].infos[key] = {
  946. "systemId": "dataPlatform",
  947. "name": "铭牌照片",
  948. "type": "image",
  949. "key": data
  950. }
  951. } else {
  952. this.main[row].infos[key] = data
  953. }
  954. }
  955. } else {
  956. this.main[row].infos[key] = ''
  957. }
  958. }
  959. },
  960. watch: {
  961. dialog: {
  962. deep: true,
  963. handler: function () {
  964. // if (!this.dialog.relevance) {
  965. // this.reset()
  966. // }
  967. }
  968. }
  969. }
  970. };
  971. </script>
  972. <style lang="less">
  973. .hanson-bar {
  974. height: 40px;
  975. padding: 5px;
  976. font-size: 16px;
  977. overflow: hidden;
  978. .iconfont {
  979. font-size: 12px;
  980. }
  981. .el-button {
  982. margin-right: 10px;
  983. }
  984. }
  985. </style>