device.vue 35 KB

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