device.vue 30 KB

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