device.vue 32 KB

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