system.vue 33 KB

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