device.vue 30 KB

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