assets.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. <template>
  2. <div style="height: calc(100% - 44.5px);padding: 0px 10px 10px;box-sizing: border-box;">
  3. <div class="hanson-bar">
  4. <div style="float:right;overflow:hidden;">
  5. <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
  6. <i v-show="!onlyRead" class="el-icon-fa el-icon-fa-eye"></i>
  7. </span>
  8. <span>当前筛选条件下共{{page.total || '--'}}设备</span>
  9. </div>
  10. <el-select v-model="onlyRead" @change="getHeaderData(mess)" style="width:100px;margin-right:20px;vertical-align:bottom;">
  11. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  12. </el-select>
  13. <el-select v-model="showType" @change="initTable" style="width:130px;margin-right:10px;vertical-align:bottom;">
  14. <el-option v-for="item in showTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
  15. </el-select>
  16. <el-button size="small" style="width: 80px;" @click="addDevice" icon="iconfont icon-tianjia">添加资产</el-button>
  17. <el-button size="small" style="width: 80px;" @click="reset" icon="iconfont icon-shuaxin">刷新</el-button>
  18. <el-button v-show="!onlyRead" size="small" style="width: 80px;" @click="undo" icon="iconfont icon-undo">撤销</el-button>
  19. </div>
  20. <qrcode :qrcodeUrl="qrcodeUrl" :dialog="myDialog" :addBody="true" ref="qrcode"></qrcode>
  21. <firm ref="firm" :mess="mess" @changeFirm="firmChange" :dialog="myDialog"></firm>
  22. <supply-dialog @change="supplyChange" ref="supply" :id="id" :dialog="myDialog"></supply-dialog>
  23. <supplier-dialog ref="supplier" @changeSupplier="supplierChange" :dialog="myDialog"></supplier-dialog>
  24. <guarantee-dialog @change="guaranteeChange" :id="id" ref="guarantee" :dialog="myDialog"></guarantee-dialog>
  25. <upload-files-dialog :read="onlyRead ? true : false" ref="upload" @changeFile="fileChange" :keysArr="filesArr" :dialog="myDialog" ></upload-files-dialog>
  26. <upload-img-dialog :read="onlyRead ? true : false" @changeFile="imgChange" :keysArr="imgsArr" :dialog="myDialog" ></upload-img-dialog>
  27. <maintainer-dialog @changeMaintainer="changeMaintainer" ref="maintainer" :dialog="myDialog"></maintainer-dialog>
  28. <insurer-dialog @changeInsurer="changeInsurer" ref="insurer" :dialog="myDialog"></insurer-dialog>
  29. <pic-dialog :read="onlyRead ? true : false" :dialog="myDialog" :keysArr="picsArr" @change="changePics" ></pic-dialog>
  30. <div class="center middle_sty" style="height: 91%" v-show="!mess.deviceId && (!tableData || !tableData.length)">
  31. <p>
  32. <i class="iconwushuju iconfont"></i>
  33. 请选择设备族
  34. </p>
  35. </div>
  36. <div class="center middle_sty" style="height: 91%" v-show="mess.deviceId && (!tableData || !tableData.length)">
  37. <p>
  38. <i class="iconwushuju iconfont"></i>
  39. 暂无数据
  40. </p>
  41. </div>
  42. <div v-show="mess.deviceId && tableData && tableData.length" v-loading="loading" id="handsontable" ref="handsontable"></div>
  43. <div v-show="tableData && tableData.length" class='right'>
  44. <my-pagination @change="getTableData" :page="page"></my-pagination>
  45. </div>
  46. <dialog-assets :assetType="[this.mess.deviceId]" @close="closeDialog" ref="assets" v-if="myDialog.addDevice" :dialog="myDialog" ></dialog-assets>
  47. <details-dialog :iframeSrc="iframeSrc" v-if="myDialog.details" :dialog="myDialog"></details-dialog>
  48. <look-pic :dialog="myDialog" :keysArr="picsArr"></look-pic>
  49. </div>
  50. </template>
  51. <script>
  52. import { getDataDictionary, queryProperty, updateProperty, deleteProperty, upDateTableMain, delProperty, getEquipmentFamily } from "@/api/scan/request";
  53. import tools from "@/utils/scan/tools"
  54. import handsonUtils from "@/utils/scan/hasontableUtils"
  55. import showTools from "@/utils/handsontable/notShow"
  56. import text from "@/utils/handsontable/mainText"
  57. import buildFloorData from '@/utils/handsontable/buildFloorData'
  58. import qrcode from "@/components/business_space/lib/qrcode"
  59. import firm from "@/components/business_space/dialogs/list/firm"
  60. import supplyDialog from "@/components/business_space/dialogs/list/supplyDialog"
  61. import supplierDialog from "@/components/business_space/dialogs/list/supplierDialog"
  62. import maintainerDialog from "@/components/business_space/dialogs/list/maintainerDialog"
  63. import insurerDialog from "@/components/business_space/dialogs/list/insurerDialog"
  64. import guaranteeDialog from "@/components/business_space/dialogs/list/guaranteeDialog"
  65. import uploadFilesDialog from "@/components/business_space/dialogs/list/filesDialog"
  66. import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
  67. import detailsDialog from "@/components/business_space/lib/detailsDia"
  68. import picDialog from "@/components/business_space/dialogs/list/picDialog"
  69. import myPagination from "@/components/common/myPagination"
  70. import dialogAssets from "@/components/ledger/addDialog/dialogAssets"
  71. import { mapGetters, mapActions } from "vuex"
  72. //图片查看
  73. import lookPic from "@/components/ledger/lib/lookImages"
  74. import Handsontable from "handsontable-pro"
  75. import 'handsontable-pro/dist/handsontable.full.css'
  76. import zhCN from 'handsontable-pro/languages/zh-CN'
  77. //下拉插件
  78. // import "@/assets/js/chosen.jquery.min";
  79. // import "@/assets/js/handsontable-chosen-editor";
  80. export default {
  81. components: {
  82. qrcode, //二维码页面
  83. firm, //
  84. supplyDialog,
  85. supplierDialog,
  86. guaranteeDialog,
  87. uploadFilesDialog,
  88. maintainerDialog,
  89. insurerDialog,
  90. uploadImgDialog,
  91. picDialog,
  92. myPagination,
  93. dialogAssets,
  94. detailsDialog,
  95. lookPic
  96. },
  97. created() { },
  98. computed: {
  99. ...mapGetters("layout", [ "projectId", "secret", "userId" ]),
  100. showTypes() {
  101. return this.onlyRead ?
  102. [{ value: "Visible", label: '只看采集信息' }, { value: "all", label: '全部' }] :
  103. [{ value: "Visible", label: '只看采集信息' }, { value: "partInfo", label: '隐藏信息点' }, { value: "all", label: '全部' }]
  104. }
  105. },
  106. data() {
  107. return {
  108. options: [{
  109. value: true,
  110. label: '只读模式'
  111. }, {
  112. value: false,
  113. label: '编辑模式'
  114. }],
  115. tableData: [],
  116. mess: {},
  117. tableHeader: null,
  118. page: {
  119. size: 50,
  120. sizes: [10, 30, 50, 100, 150, 200],
  121. total: 0,
  122. currentPage: 1
  123. },
  124. myDialog: {
  125. qrcode: false, //二维码弹窗
  126. firm: false, //厂商弹窗
  127. supply: false, //选择供应合同
  128. supplier: false, //供应商选择
  129. guarantee: false, //选择保单
  130. maintainer: false, //选择维修商
  131. insurer: false, //选择保险公司
  132. uploadFiles: false,//上传文件
  133. uploadImgs: false,//上传单个图片
  134. pic: false, //多个图片
  135. addDevice: false,//添加资产
  136. systemType: false,//关联系统
  137. details: false,//详情页
  138. changeRea: false,//关联资产
  139. lookPic: false,//图片查看
  140. },
  141. row: null, //被修改的row
  142. filesArr: [], //保存临时的文件key
  143. messKey: null,
  144. imgsArr: [], //临时保存的图片key数组
  145. picsArr: [], //临时资产图片keys数组
  146. copyMain: null,
  147. graphyId: null,
  148. assetGroupList: [],
  149. iframeSrc: "",
  150. id: 0,
  151. onlyRead: true,
  152. showType: 'all',
  153. linkNameFalg: false,
  154. qrcodeUrl: "", //二维码图片地址
  155. loading: false,
  156. deviceType: {}, //族3位编码及名称
  157. floorData: [],
  158. curDevice: '',//当前点击的资产id
  159. addData: {}, //添加资产选择的资产类型
  160. showFlowBuild: false //是否显示建筑楼层
  161. };
  162. },
  163. methods: {
  164. //获取表头
  165. getHeaderData(code) {
  166. this.page.currentPage = 1
  167. this.mess = code
  168. if (this.mess.deviceId) {
  169. let params = {
  170. data: {
  171. PageNumber: 1,
  172. PageSize: 500
  173. },
  174. type: this.mess.deviceId
  175. };
  176. getDataDictionary(params, res => {
  177. this.tableHeader = res.Content;
  178. this.getTableData()
  179. });
  180. }
  181. },
  182. //获取主体数据
  183. getTableData() {
  184. this.loading = true
  185. //type存在发送请求
  186. if (!!this.mess.deviceId) {
  187. let param = {
  188. PageSize: this.page.size,
  189. Orders: "createTime desc, EquipID desc",
  190. PageNumber: this.page.currentPage,
  191. Filters: `Family='${this.mess.deviceId}'`
  192. }
  193. if (this.mess.buildId == "noKnow") {
  194. param.Filters += `;buildingId isNull`
  195. } else if (this.mess.buildId && this.mess.buildId != "all") {
  196. param.Filters += `;buildingId='${this.mess.buildId}'`
  197. }
  198. if (this.mess.floorId == "noKnow") {
  199. param.Filters += `;floorId isNull`
  200. } else if (this.mess.floorId && this.mess.floorId != "all") {
  201. param.Filters += `;floorId='${this.mess.floorId}'`
  202. }
  203. queryProperty(param, res => {
  204. this.loading = false
  205. this.tableData = res.Content.map((item) => {
  206. if (item.hasOwnProperty("BuildingId") && item.hasOwnProperty("FloorId")) {
  207. item.flowBuild = item.BuildingId + "-" + item.FloorId
  208. } else if (item.hasOwnProperty("BuildingId") && !item.hasOwnProperty("FloorId")) {
  209. item.flowBuild = item.BuildingId
  210. }
  211. return item
  212. })
  213. this.copyMain = tools.deepCopy(this.tableData)
  214. this.page.total = res.Total
  215. if (this.hot) {
  216. this.hot.destroy()
  217. this.hot = null
  218. }
  219. if (this.tableData && this.tableData.length) {
  220. if (this.onlyRead) {
  221. this.getBatch(this.tableData)
  222. }
  223. this.initTable()
  224. }
  225. })
  226. }
  227. },
  228. //获取动态参数
  229. getBatch(data) {
  230. let param = {
  231. secret: this.secret,
  232. ProjId: this.projectId,
  233. data: {
  234. criterias: []
  235. }
  236. };
  237. this.tableHeader.map(head => {
  238. if (
  239. head.InputMode == "L" ||
  240. head.InputMode == "L1" ||
  241. head.InputMode == "L2" ||
  242. head.InputMode == "M"
  243. ) {
  244. data.map(item => {
  245. let cur = tools.dataForKey(item, head.Path);
  246. if (cur) {
  247. param.data.criterias.push({
  248. id: item.EquipID,
  249. code: head.InfoPointCode
  250. });
  251. }
  252. });
  253. }
  254. });
  255. if (param.data.criterias.length) {
  256. BeatchQueryParam(param, res => {
  257. this.tableData = data.map(item => {
  258. res.Content.map(child => {
  259. if (item.EquipID == child.id) {
  260. if (child.data || child.data == 0) {
  261. this.tableHeader.map(head => {
  262. if (head.InfoPointCode == child.code) {
  263. tools.setDataForKey(item, head.Path, child.data);
  264. }
  265. });
  266. } else {
  267. this.tableHeader.map(head => {
  268. if (head.InfoPointCode == child.code) {
  269. tools.setDataForKey(
  270. item,
  271. head.Path,
  272. child.error ? "表号功能号格式错误" : "表号功能号不存在"
  273. );
  274. }
  275. });
  276. }
  277. }
  278. });
  279. return item;
  280. });
  281. this.hot.loadData(this.tableData);
  282. });
  283. }
  284. },
  285. //显示楼层信息
  286. changeAssetsFalg() {
  287. if (this.showFlowBuild) {
  288. this.showFlowBuild = false
  289. this.getTableData()
  290. } else {
  291. this.$confirm('<p>维护资产所在建筑楼层后,对后续数据影响较大,如业务空间中的所在关系or其他?暂未梳理明白……</p><p>后续要修改设备所属建筑楼层,只能通过模型中的待建模清单操作</p>', '提示', {
  292. dangerouslyUseHTMLString: true,
  293. confirmButtonText: '就要维护资产所属建筑楼层',
  294. cancelButtonText: '暂时不搞了',
  295. confirmButtonClass: 'confirmButtonClass',
  296. cancelButtonClass: 'cancelButtonClass'
  297. }).then(_ => {
  298. this.showFlowBuild = true
  299. this.initTable()
  300. }).catch(_ => {
  301. this.$message("取消")
  302. })
  303. }
  304. },
  305. //撤回
  306. undo() {
  307. this.hot.undo();
  308. },
  309. //刷新-switch改变
  310. reset() {
  311. this.getTableData();
  312. },
  313. //添加资产
  314. addDevice() {
  315. this.myDialog.addDevice = true
  316. if (this.mess.deviceId) {
  317. this.$nextTick(() => {
  318. this.$refs.cascader.setValue([this.mess.deviceId])
  319. })
  320. }
  321. },
  322. //下一步
  323. toAddDevice() {
  324. if (this.addData.deviceId) {
  325. this.$router.push({
  326. path: "/ledger/addevice",
  327. query: this.addData
  328. });
  329. }
  330. },
  331. //选择设备类型-添加资产
  332. changeAddType(val) {
  333. this.addData.deviceId = val.code;
  334. this.addData.name = val.facility;
  335. },
  336. //下载
  337. download() {
  338. if (!this.onlyRead) {
  339. if (!!this.hot) {
  340. let fileName = this.mess.name + "-页数:" + this.page.currentPage + "-个数:" + this.tableData.length + "-总个数:" + this.page.total
  341. this.hot.getPlugin('exportFile').downloadFile("csv", { filename: fileName, columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
  342. } else {
  343. this.$message("请确定存在表格")
  344. }
  345. } else {
  346. this.$message("下载需在编辑状态下")
  347. }
  348. },
  349. //格式化表头
  350. formatHeaderData(list) {
  351. let arr = tools.copyArr(list)
  352. let data = showTools.headerTextFilter(arr, 'property', this.onlyRead, this.showType, true)
  353. data.unshift("操作", "当前关联的设备")
  354. if (this.showFlowBuild) {
  355. data.splice(2, 0, "所属建筑楼层")
  356. }
  357. return data
  358. },
  359. //格式化表内容
  360. formatHeaderType(list) {
  361. let arr = tools.copyArr(list)
  362. let data = showTools.headerTypeFilter(arr, 'property', this.onlyRead, this.showType, true)
  363. data.unshift(
  364. {
  365. data: "caozuo",
  366. renderer: tools.lookDetails
  367. }, {
  368. data: "assetsName",
  369. readOnly: true
  370. }
  371. )
  372. if (this.showFlowBuild) {
  373. data.splice(2, 0, {
  374. data: "flowBuild",
  375. renderer: tools.customDropdownRenderer,
  376. editor: "chosen",
  377. chosenOptions: {
  378. data: buildFloorData.data
  379. }
  380. })
  381. }
  382. return data
  383. },
  384. //初始化插件
  385. initTable() {
  386. var container = document.getElementById("handsontable");
  387. let winHeight = document.documentElement.clientHeight;
  388. this.hot = new Handsontable(container, {
  389. data: this.tableData,
  390. fixedColumnsLeft: this.showFlowBuild?5:4,
  391. colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
  392. columns: this.formatHeaderType(this.tableHeader), //数据显示格式
  393. filters: true,
  394. maxRows: this.tableData.length,
  395. height: winHeight - 335,
  396. columnSorting: true, //添加排序
  397. sortIndicator: true, //添加排序
  398. renderAllRows: true,
  399. // colWidths: 200,
  400. autoColumnSize: true,
  401. language: "zh-CN",
  402. manualColumnResize: true,
  403. manualColumnMove: true,
  404. dropdownMenu: [
  405. "filter_by_condition",
  406. "filter_by_value",
  407. "filter_action_bar"
  408. ],
  409. contextMenu: {
  410. items: {
  411. remove_row: {
  412. name: "删除选中资产"
  413. }
  414. }
  415. },
  416. // 事件
  417. afterChange: this.handleUpdataTable, //修改后
  418. afterFilter: this.trimmedRows, //排序前
  419. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  420. afterOnCellMouseDown: this.eventClick //鼠标点击
  421. });
  422. let pro = document.getElementById("hot-display-license-info");
  423. if (!!pro) {
  424. pro.parentNode.removeChild(pro);
  425. }
  426. this.isLoading = false;
  427. },
  428. //表格中的点击
  429. eventClick(el, rowArr) {
  430. //点击的是表头
  431. if (rowArr.row < 0) {
  432. return;
  433. }
  434. //被筛选过后的数组
  435. let trimmedArr = this.trimmedRows();
  436. //是否启用了排序
  437. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  438. if (trimmedArr.length && isSort) {
  439. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  440. .__arrayMap;
  441. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  442. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
  443. } else if (isSort) {
  444. //排序后的数组
  445. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  446. let infos = this.tableData[sortArr[rowArr.row]];
  447. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
  448. } else if (trimmedArr.length) {
  449. let infos = this.tableData[trimmedArr[rowArr.row]];
  450. this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col }, el);
  451. } else {
  452. let infos = this.tableData[rowArr.row];
  453. this.getInfors(infos, rowArr, el);
  454. }
  455. },
  456. // 更新
  457. handleUpdataTable(changeData, source) {
  458. if (!this.onlyRead) {
  459. if (changeData) {
  460. let trimmedArr = this.trimmedRows();
  461. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  462. let data = [];
  463. for (let i = 0; i < param.length; i++) {
  464. data.push(param[i]);
  465. }
  466. //如果data中包含/且data长度为1,将其转换成.
  467. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  468. changeData[0][1] = changeData[0][1].split("/").join(".")
  469. }
  470. //存在data进行修改请求
  471. if (data && data.length) {
  472. this.updateProperty(data, changeData);
  473. }
  474. }
  475. }
  476. },
  477. //删除资产
  478. handleDeleteTableRow() {
  479. let params = tools.differenceArr(this.tableData, this.copyMain)
  480. let _this = this
  481. if (params.length < 1) {
  482. return
  483. }
  484. let param = []
  485. params.map(item => {
  486. param.push({ EquipID: item.EquipID })
  487. })
  488. this.$confirm("此操作将删除资产,是否继续?", "提示", {
  489. confirmButtonText: '确定',
  490. cancelButtonText: '取消',
  491. type: 'warning'
  492. }).then(() => {
  493. this.removeDevice(param)
  494. }).catch(() => {
  495. this.reset()
  496. this.$message("取消删除")
  497. })
  498. },
  499. // 删除资产
  500. async removeDevice(param) {
  501. await deleteProperty(param, res => {
  502. this.$message.success("删除成功")
  503. this.$emit('close','')
  504. this.getTableData()
  505. })
  506. },
  507. // 更新
  508. updateProperty(data, change) {
  509. let param = {
  510. Content: [],
  511. Projection: []
  512. }
  513. //生成要修改字段列表
  514. change.map(item => {
  515. if (item[1] && param.Projection.indexOf(item[1]) == -1) {
  516. if (item[1].split(".")[0] == "flowBuild") {
  517. param.Projection.push("BuildingId","FloorId")
  518. } else {
  519. param.Projection.push(item[1].split(".")[0])
  520. }
  521. }
  522. })
  523. //生成对应修改数据
  524. data.map((item, index) => {
  525. param.Projection.map(value => {
  526. if (value == "BuildingId") {
  527. let itemData = tools.dataForKey(item, "flowBuild")
  528. if (itemData == "") {
  529. tools.setDataForKey(item, "BuildingId", null)
  530. tools.setDataForKey(item, "FloorId", null)
  531. } else {
  532. let BuildingId = itemData.split("-")[0]
  533. let FloorId = itemData.split("-")[1]
  534. if (BuildingId && FloorId) {
  535. tools.setDataForKey(item, "BuildingId", BuildingId)
  536. tools.setDataForKey(item, "FloorId", FloorId)
  537. } else if (BuildingId && !FloorId) {
  538. tools.setDataForKey(item, "BuildingId", BuildingId)
  539. tools.setDataForKey(item, "FloorId", null)
  540. }
  541. }
  542. } else {
  543. let itemData = tools.dataForKey(item, value)
  544. tools.setDataForKey(item, value, itemData == "" ? null : itemData)
  545. }
  546. });
  547. param.Content.push(item)
  548. })
  549. updateProperty(param, res => { })
  550. },
  551. //修改资产类型
  552. // changeCader() {
  553. // if (this.mess.deviceId) {
  554. // let param = {
  555. // data: {
  556. // Filters: `EquipCode='${this.mess.deviceId}'`,
  557. // PageNumber: 1,
  558. // PageSize: 50
  559. // }
  560. // }
  561. // getEquipBelongs(param, res => {
  562. // if (res.Content.length) {
  563. // this.deviceType.assetType = res.Content[0].Family
  564. // this.deviceType.assetName = res.Content[0].FamilyName
  565. // }
  566. // })
  567. // }
  568. // },
  569. //获取到了正确的信息
  570. getInfors(infos, row, el) {
  571. let val = this.hot.colToProp(row.col);
  572. this.row = row.row;
  573. this.messKey = val;
  574. switch (val) {
  575. //操作
  576. case 'caozuo':
  577. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  578. this.$message("开发中...")
  579. break;
  580. //资产二维码图片
  581. case 'EquipQRCode':
  582. this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
  583. if (!!this.qrcodeUrl) {
  584. this.myDialog.qrcode = true;
  585. } else {
  586. this.$message("此资产没有资产二维码");
  587. }
  588. break;
  589. //关联系统
  590. case 'LinkSystem':
  591. if (!this.onlyRead) {
  592. this.curDevice = infos.EquipID;
  593. this.systemList = this.tableData[row.row].LinkSystem || [];
  594. this.myDialog.systemType = true;
  595. }
  596. break;
  597. //关联资产
  598. case 'LinkEquipLocalName':
  599. if (this.linkNameFalg) {
  600. this.myDialog.changeRea = true;
  601. }
  602. break;
  603. //品牌型号弹窗
  604. case 'DPManufacturerID':
  605. if (!this.onlyRead) {
  606. this.myDialog.firm = true;
  607. }
  608. break;
  609. //供应商信息弹窗
  610. case 'DPSupplierID':
  611. if (!this.onlyRead) {
  612. this.myDialog.supplier = true;
  613. }
  614. break;
  615. //维修商信息弹窗
  616. case 'DPMaintainerID':
  617. if (!this.onlyRead) {
  618. this.myDialog.maintainer = true;
  619. }
  620. break;
  621. //保险公司信息
  622. case 'DPInsurerID':
  623. if (!this.onlyRead) {
  624. this.myDialog.insurer = true;
  625. }
  626. break;
  627. //供应合同编号
  628. case 'LedgerParam.SupplyPurchase.SupplierContractID':
  629. if (!this.onlyRead) {
  630. let ContractIDflag = null;
  631. let DPSdata = this.tableData[row.row].DPSupplierID;
  632. if (DPSdata) {
  633. ContractIDflag = DPSdata.split("-")[0];
  634. }
  635. if (!!ContractIDflag) {
  636. this.id = ContractIDflag;
  637. this.myDialog.supply = true;
  638. } else {
  639. this.$message("请先选择供应商");
  640. }
  641. }
  642. break;
  643. //保险单号
  644. case 'LedgerParam.InsuranceDoc.InsuranceNum':
  645. if (!this.onlyRead) {
  646. let DPInsurerIDflag = null;
  647. let DPIdata = this.tableData[row.row].DPInsurerID;
  648. if (DPIdata) {
  649. DPInsurerIDflag = DPIdata.split("-")[0];
  650. }
  651. if (!!DPInsurerIDflag) {
  652. this.id = DPInsurerIDflag;
  653. this.myDialog.guarantee = true;
  654. } else {
  655. this.$message("请先选择保险商");
  656. }
  657. }
  658. break;
  659. //保险文件--资产文档--安装质检报告
  660. case 'LedgerParam.InsuranceDoc.InsuranceFile':
  661. case 'LedgerParam.PhotoDoc.Archive':
  662. case 'LedgerParam.Siteinstall.CheckReport':
  663. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  664. this.filesArr = IPSdata ? IPSdata : [];
  665. this.myDialog.uploadFiles = true;
  666. break;
  667. //安装照片--安装图纸--资产铭牌照片--资产图纸
  668. case 'LedgerParam.Siteinstall.InstallPic':
  669. case 'LedgerParam.Siteinstall.InstallDrawing':
  670. case 'LedgerParam.PhotoDoc.Nameplate':
  671. case 'LedgerParam.PhotoDoc.Drawing':
  672. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  673. this.imgsArr = SSPPdata ? SSPPdata : [];
  674. this.myDialog.uploadImgs = true;
  675. break;
  676. //资产照片
  677. case 'LedgerParam.PhotoDoc.Pic':
  678. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  679. this.picsArr = Pdata ? Pdata : [];
  680. this.myDialog.pic = true;
  681. break;
  682. //包含的部件字段
  683. case 'Count':
  684. if (this.onlyRead) {
  685. this.$router.push({ path: '/ledger/parts', query: { deviceId: infos.EquipID } });
  686. } else {
  687. this.$router.push({ path: '/ledger/partsmanage', query: { deviceId: infos.EquipID, typeId: this.mess.deviceId } });
  688. }
  689. break;
  690. default:
  691. break;
  692. }
  693. },
  694. //获取被筛选掉的行号
  695. trimmedRows() {
  696. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  697. let dataLength = this.tableData.length;
  698. let dataArr = new Array();
  699. for (let i = 0; i < dataLength; i++) {
  700. dataArr.push(i);
  701. }
  702. if (plugin.length <= 0) {
  703. dataArr = undefined;
  704. } else {
  705. dataArr = this.array_diff(dataArr, plugin);
  706. }
  707. return dataArr || [];
  708. },
  709. //去除数组中相同的元素
  710. array_diff(a, b) {
  711. for (var i = 0; i < b.length; i++) {
  712. for (var j = 0; j < a.length; j++) {
  713. if (a[j] == b[i]) {
  714. a.splice(j, 1);
  715. j = j - 1;
  716. }
  717. }
  718. }
  719. return a;
  720. },
  721. //如果选择供应商之后
  722. supplierChange(data) {
  723. tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
  724. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
  725. this.handleUpdataTable([[this.row, "DPSupplierID", null, data.venderId]], "edit")
  726. this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
  727. },
  728. //供应合同编号
  729. supplyChange(data) {
  730. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", { id: data })
  731. },
  732. //保险单号-保险文件
  733. guaranteeChange(data) {
  734. for (let key in data) {
  735. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  736. if (key == "contractFile") {
  737. if (!!data[key]) {
  738. data[key] = [data[key]]
  739. }
  740. }
  741. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  742. }
  743. },
  744. //选择型号修改
  745. firmChange(data) {
  746. tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)
  747. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
  748. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
  749. this.handleUpdataTable([[this.row, "DPManufacturerID", null, data.venderId]], "edit")
  750. this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
  751. this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
  752. },
  753. //保险商变更
  754. changeInsurer(data) {
  755. tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
  756. tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
  757. this.handleUpdataTable([[this.row, "DPInsurerID", null, data.venderId]], "edit")
  758. this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
  759. },
  760. //维修商变更
  761. changeMaintainer(data) {
  762. tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
  763. tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
  764. this.handleUpdataTable([[this.row, "DPMaintainerID", null, data.venderId]], "edit")
  765. this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
  766. },
  767. //修改关联的资产
  768. changeProperty(val) {
  769. this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
  770. this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
  771. },
  772. //上传文件弹窗触发事件
  773. fileChange(keys) {
  774. this.setDataToMain(keys, this.messKey, this.row);
  775. },
  776. //上传图片弹窗触发事件
  777. imgChange(keys) {
  778. this.setDataToMain(keys, this.messKey, this.row);
  779. },
  780. //关联系统更改
  781. changeSystemType(data) {
  782. tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
  783. },
  784. //资产图片弹窗改变事件
  785. changePics(keys) {
  786. this.setDataToMain(keys, this.messKey, this.row);
  787. },
  788. utilToKey(key, name, data, messName) {
  789. if (key == name) {
  790. this.setDataToMain(data[key], messName, this.row)
  791. }
  792. },
  793. //判断是否有值,有值赋值
  794. setDataToMain(data, key, row) {
  795. if (!!data && data != '--') {
  796. if (!!this.tableData[row]) {
  797. tools.setDataForKey(this.tableData[row], key, data);
  798. this.handleUpdataTable([[row, key, null, data]], "edit");
  799. } else {
  800. this.tableData[row] = {};
  801. tools.setDataForKey(this.tableData[row], key, data);
  802. }
  803. } else {
  804. tools.setDataForKey(this.tableData[row], key, "");
  805. }
  806. },
  807. //未知
  808. setGraphyId(graphyId, assetGroupList) {
  809. this.graphyId = graphyId
  810. this.assetGroupList = assetGroupList
  811. },
  812. },
  813. watch: {
  814. projectId(){
  815. this.main = []
  816. this.mess.deviceId = null
  817. this.page.total = 0
  818. },
  819. showTypes: {
  820. handler(newName, oldName) {
  821. if (newName && newName[0] && newName[0].value) {
  822. this.showType = newName[0].value
  823. } else {
  824. this.showType = ""
  825. }
  826. },
  827. immediate: true,
  828. deep: true
  829. }
  830. }
  831. };
  832. </script>
  833. <style lang="less">
  834. .hanson-bar {
  835. height: 40px;
  836. padding: 5px 0;
  837. font-size: 14px;
  838. overflow: hidden;
  839. margin-top: 0;
  840. line-height: 40px;
  841. .iconfont {
  842. font-size: 12px;
  843. }
  844. }
  845. .cancelButtonClass {
  846. width: 180px;
  847. }
  848. </style>