assets.vue 40 KB

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