assets.vue 38 KB

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