assets.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  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. // colWidths: 200,
  522. autoColumnSize: true,
  523. language: "zh-CN",
  524. manualColumnResize: true,
  525. manualColumnMove: true,
  526. dropdownMenu: [
  527. "filter_by_condition",
  528. "filter_by_value",
  529. "filter_action_bar"
  530. ],
  531. contextMenu: {
  532. items: {
  533. remove_row: {
  534. name: "删除选中资产"
  535. }
  536. }
  537. },
  538. // 事件
  539. afterChange: this.handleUpdataTable, //修改后
  540. afterFilter: this.trimmedRows, //排序前
  541. afterRemoveRow: this.handleDeleteTableRow, //右键删除
  542. afterOnCellMouseDown: this.eventClick //鼠标点击
  543. });
  544. let pro = document.getElementById("hot-display-license-info");
  545. if (!!pro) {
  546. pro.parentNode.removeChild(pro);
  547. }
  548. this.isLoading = false;
  549. },
  550. //表格中的点击
  551. eventClick(el, rowArr) {
  552. //点击的是表头
  553. if (rowArr.row < 0) {
  554. return;
  555. }
  556. //被筛选过后的数组
  557. let trimmedArr = this.trimmedRows();
  558. //是否启用了排序
  559. let isSort = this.hot.getPlugin("columnSorting").isSorted();
  560. if (trimmedArr.length && isSort) {
  561. let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
  562. .__arrayMap;
  563. let infos = this.tableData[trimmedArr[sortArr[rowArr.row]]];
  564. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
  565. } else if (isSort) {
  566. //排序后的数组
  567. let sortArr = this.hot.getPlugin("columnSorting").rowsMapper.__arrayMap;
  568. let infos = this.tableData[sortArr[rowArr.row]];
  569. this.getInfors(infos, { row: sortArr[rowArr.row], col: rowArr.col }, el);
  570. } else if (trimmedArr.length) {
  571. let infos = this.tableData[trimmedArr[rowArr.row]];
  572. this.getInfors(infos, { row: trimmedArr[rowArr.row], col: rowArr.col }, el);
  573. } else {
  574. let infos = this.tableData[rowArr.row];
  575. this.getInfors(infos, rowArr, el);
  576. }
  577. },
  578. // 更新
  579. handleUpdataTable(changeData, source) {
  580. if (!this.onlyRead) {
  581. if (changeData) {
  582. let trimmedArr = this.trimmedRows();
  583. let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
  584. let data = [];
  585. for (let i = 0; i < param.length; i++) {
  586. data.push(param[i]);
  587. }
  588. //如果data中包含/且data长度为1,将其转换成.
  589. if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
  590. changeData[0][1] = changeData[0][1].split("/").join(".")
  591. }
  592. //存在data进行修改请求
  593. if (data && data.length) {
  594. this.updateProperty(data, changeData);
  595. }
  596. }
  597. }
  598. },
  599. //删除资产
  600. handleDeleteTableRow() {
  601. let params = tools.differenceArr(this.tableData, this.copyMain)
  602. let _this = this
  603. if (params.length < 1) {
  604. return
  605. }
  606. let param = []
  607. params.map(item => {
  608. param.push({ EquipID: item.EquipID })
  609. })
  610. this.$confirm("此操作将删除资产,是否继续?", "提示", {
  611. confirmButtonText: '确定',
  612. cancelButtonText: '取消',
  613. type: 'warning'
  614. }).then(() => {
  615. this.removeDevice(param)
  616. }).catch(() => {
  617. this.reset()
  618. this.$message("取消删除")
  619. })
  620. },
  621. // 删除资产
  622. async removeDevice(param) {
  623. await deleteProperty(param, res => {
  624. this.$message.success("删除成功")
  625. this.$emit('getJson', '')
  626. this.getTableData()
  627. })
  628. },
  629. // 更新
  630. updateProperty(data, change) {
  631. let param = {
  632. Content: [],
  633. Projection: []
  634. }, keyList = []
  635. //生成要修改字段列表
  636. change.map(item => {
  637. let key = item[1].split(".")[0]
  638. if (key == "flowBuild" && keyList.indexOf(key) == -1) {
  639. keyList.push("BuildingId", "FloorId")
  640. param.Projection.push("BuildingId", "FloorId")
  641. }
  642. if (item[1] && keyList.indexOf(key) == -1) {
  643. keyList.push(key)
  644. }
  645. if (item[1] && item[3] == "" && param.Projection.indexOf(key) == -1) {
  646. param.Projection.push(key)
  647. }
  648. })
  649. //生成对应修改数据
  650. data.map((item, index) => {
  651. keyList.map(value => {
  652. if (value == "BuildingId") {
  653. let itemData = tools.dataForKey(item, "flowBuild")
  654. if (itemData == "") {
  655. tools.setDataForKey(item, "BuildingId", null)
  656. tools.setDataForKey(item, "FloorId", null)
  657. } else {
  658. let BuildingId = itemData.split("-")[0]
  659. let FloorId = itemData.split("-")[1]
  660. if (BuildingId && FloorId) {
  661. tools.setDataForKey(item, "BuildingId", BuildingId)
  662. tools.setDataForKey(item, "FloorId", FloorId)
  663. } else if (BuildingId && !FloorId) {
  664. tools.setDataForKey(item, "BuildingId", BuildingId)
  665. tools.setDataForKey(item, "FloorId", null)
  666. }
  667. }
  668. } else {
  669. let itemData = tools.dataForKey(item, value)
  670. tools.setDataForKey(item, value, itemData == "" ? null : itemData)
  671. }
  672. });
  673. param.Content.push(item)
  674. })
  675. updateProperty(param, res => { })
  676. },
  677. //修改资产类型
  678. // changeCader() {
  679. // if (this.mess.deviceId) {
  680. // let param = {
  681. // data: {
  682. // Filters: `EquipCode='${this.mess.deviceId}'`,
  683. // PageNumber: 1,
  684. // PageSize: 50
  685. // }
  686. // }
  687. // getEquipBelongs(param, res => {
  688. // if (res.Content.length) {
  689. // this.deviceType.assetType = res.Content[0].Family
  690. // this.deviceType.assetName = res.Content[0].FamilyName
  691. // }
  692. // })
  693. // }
  694. // },
  695. //获取到了正确的信息
  696. getInfors(infos, row, el) {
  697. let val = this.hot.colToProp(row.col);
  698. let inputMode = this.inputMap[val];
  699. this.row = row.row;
  700. this.messKey = val;
  701. switch (val) {
  702. //操作
  703. case 'caozuo':
  704. // window.open(`http://adm.sagacloud.cn:8058/spread?id=${infos.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
  705. this.$message("开发中...")
  706. return false
  707. //资产二维码图片
  708. case 'EquipQRCode':
  709. this.qrcodeUrl = this.tableData[row.row].EquipQRCode;
  710. if (!!this.qrcodeUrl) {
  711. this.myDialog.qrcode = true;
  712. } else {
  713. this.$message("此资产没有资产二维码");
  714. }
  715. return false
  716. //关联系统
  717. case 'LinkSystem':
  718. if (!this.onlyRead) {
  719. this.curDevice = infos.EquipID;
  720. this.systemList = this.tableData[row.row].LinkSystem || [];
  721. this.myDialog.systemType = true;
  722. }
  723. return false
  724. //关联资产
  725. case 'LinkEquipLocalName':
  726. if (this.linkNameFalg) {
  727. this.myDialog.changeRea = true;
  728. }
  729. return false
  730. //品牌型号弹窗
  731. case 'DPManufacturerID':
  732. if (!this.onlyRead) {
  733. this.myDialog.firm = true;
  734. }
  735. return false
  736. //供应商信息弹窗
  737. case 'DPSupplierID':
  738. if (!this.onlyRead) {
  739. this.myDialog.supplier = true;
  740. }
  741. return false
  742. //维修商信息弹窗
  743. case 'DPMaintainerID':
  744. if (!this.onlyRead) {
  745. this.myDialog.maintainer = true;
  746. }
  747. return false
  748. //保险公司信息
  749. case 'DPInsurerID':
  750. if (!this.onlyRead) {
  751. this.myDialog.insurer = true;
  752. }
  753. return false
  754. //供应合同编号
  755. case 'LedgerParam.SupplyPurchase.SupplierContractID':
  756. if (!this.onlyRead) {
  757. let ContractIDflag = null;
  758. let DPSdata = this.tableData[row.row].DPSupplierID;
  759. if (DPSdata) {
  760. ContractIDflag = DPSdata.split("-")[0];
  761. }
  762. if (!!ContractIDflag) {
  763. this.id = ContractIDflag;
  764. this.myDialog.supply = true;
  765. } else {
  766. this.$message("请先选择供应商");
  767. }
  768. }
  769. return false
  770. //保险单号
  771. case 'LedgerParam.InsuranceDoc.InsuranceNum':
  772. if (!this.onlyRead) {
  773. let DPInsurerIDflag = null;
  774. let DPIdata = this.tableData[row.row].DPInsurerID;
  775. if (DPIdata) {
  776. DPInsurerIDflag = DPIdata.split("-")[0];
  777. }
  778. if (!!DPInsurerIDflag) {
  779. this.id = DPInsurerIDflag;
  780. this.myDialog.guarantee = true;
  781. } else {
  782. this.$message("请先选择保险商");
  783. }
  784. }
  785. return false
  786. //保险文件--资产文档--安装质检报告
  787. case 'LedgerParam.InsuranceDoc.InsuranceFile':
  788. case 'LedgerParam.PhotoDoc.Archive':
  789. case 'LedgerParam.Siteinstall.CheckReport':
  790. let IPSdata = tools.dataForKey(this.tableData[row.row], val);
  791. this.filesArr = IPSdata ? IPSdata : [];
  792. this.myDialog.uploadFiles = true;
  793. return false
  794. //安装照片--安装图纸--资产铭牌照片--资产图纸
  795. case 'LedgerParam.Siteinstall.InstallPic':
  796. case 'LedgerParam.Siteinstall.InstallDrawing':
  797. case 'LedgerParam.PhotoDoc.Nameplate':
  798. case 'LedgerParam.PhotoDoc.Drawing':
  799. let SSPPdata = tools.dataForKey(this.tableData[row.row], val);
  800. this.imgsArr = SSPPdata ? SSPPdata : [];
  801. this.myDialog.uploadImgs = true;
  802. return false
  803. //资产照片
  804. case 'LedgerParam.PhotoDoc.Pic':
  805. let Pdata = tools.dataForKey(this.tableData[row.row], val);
  806. this.picsArr = Pdata ? Pdata : [];
  807. this.myDialog.pic = true;
  808. return false
  809. //包含的部件字段
  810. case 'Count':
  811. if (this.onlyRead) {
  812. this.$router.push({ path: '/ledger/parts', query: { deviceId: infos.EquipID } });
  813. } else {
  814. this.$router.push({ path: '/ledger/partsmanage', query: { deviceId: infos.EquipID, typeId: this.mess.deviceId } });
  815. }
  816. return false
  817. default:
  818. break;
  819. }
  820. if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
  821. this.updateInfoPoint = val
  822. this.updateInput = tools.dataForKey(this.tableData[row.row], val)
  823. this.myDialog.update = true
  824. }
  825. },
  826. //关闭临时维护弹窗回调
  827. handleCloseUpdate() {
  828. this.updateInputShow = false
  829. this.updateInfoPoint = ''
  830. this.updateInput = ''
  831. },
  832. //更新临时维护信息点
  833. handleClickUpdate(){
  834. tools.setDataForKey(this.tableData[this.row], this.updateInfoPoint, this.updateInput)
  835. this.handleUpdataTable([[this.row, this.updateInfoPoint, null, this.updateInput]], "edit")
  836. this.updateInputShow = false
  837. this.myDialog.update = false
  838. this.updateInput = ''
  839. },
  840. //获取被筛选掉的行号
  841. trimmedRows() {
  842. var plugin = this.hot.getPlugin("trimRows").trimmedRows;
  843. let dataLength = this.tableData.length;
  844. let dataArr = new Array();
  845. for (let i = 0; i < dataLength; i++) {
  846. dataArr.push(i);
  847. }
  848. if (plugin.length <= 0) {
  849. dataArr = undefined;
  850. } else {
  851. dataArr = this.array_diff(dataArr, plugin);
  852. }
  853. return dataArr || [];
  854. },
  855. //去除数组中相同的元素
  856. array_diff(a, b) {
  857. for (var i = 0; i < b.length; i++) {
  858. for (var j = 0; j < a.length; j++) {
  859. if (a[j] == b[i]) {
  860. a.splice(j, 1);
  861. j = j - 1;
  862. }
  863. }
  864. }
  865. return a;
  866. },
  867. //如果选择供应商之后
  868. supplierChange(data) {
  869. tools.setDataForKey(this.tableData[this.row], "DPSupplierID", data.venderId)
  870. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.Supplier", data.name)
  871. this.handleUpdataTable(
  872. [
  873. [this.row, "DPSupplierID", null, data.venderId],
  874. [this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]
  875. ],
  876. "edit"
  877. )
  878. // this.handleUpdataTable([[this.row, "LedgerParam.SupplyPurchase.Supplier", null, data.name]], "edit")
  879. },
  880. //供应合同编号
  881. supplyChange(data) {
  882. tools.setDataForKey(this.tableData[this.row], "LedgerParam.SupplyPurchase.SupplierContractID", { id: data })
  883. },
  884. //保险单号-保险文件
  885. guaranteeChange(data) {
  886. for (let key in data) {
  887. this.utilToKey(key, "insuranceNo", data, "InsuranceNum")
  888. if (key == "contractFile") {
  889. if (!!data[key]) {
  890. data[key] = [data[key]]
  891. }
  892. }
  893. this.utilToKey(key, "contractFile", data, "InsuranceFile")
  894. }
  895. },
  896. //选择型号修改
  897. firmChange(data) {
  898. tools.setDataForKey(this.tableData[this.row], "DPManufacturerID", data.venderId)
  899. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Brand", data.brand)
  900. tools.setDataForKey(this.tableData[this.row], "LedgerParam.EquipManufactor.Specification", data.name)
  901. this.handleUpdataTable(
  902. [
  903. [this.row, "DPManufacturerID", null, data.venderId],
  904. [this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand],
  905. [this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]
  906. ],
  907. "edit"
  908. )
  909. // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Brand", null, data.brand]], "edit")
  910. // this.handleUpdataTable([[this.row, "LedgerParam.EquipManufactor.Specification", null, data.name]], "edit")
  911. },
  912. //保险商变更
  913. changeInsurer(data) {
  914. tools.setDataForKey(this.tableData[this.row], "DPInsurerID", data.venderId)
  915. tools.setDataForKey(this.tableData[this.row], "LedgerParam.InsuranceDoc.Insurer", data.name)
  916. this.handleUpdataTable(
  917. [
  918. [this.row, "DPInsurerID", null, data.venderId],
  919. [this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]
  920. ],
  921. "edit"
  922. )
  923. // this.handleUpdataTable([[this.row, "LedgerParam.InsuranceDoc.Insurer", null, data.name]], "edit")
  924. },
  925. //维修商变更
  926. changeMaintainer(data) {
  927. tools.setDataForKey(this.tableData[this.row], "DPMaintainerID", data.venderId)
  928. tools.setDataForKey(this.tableData[this.row], "LedgerParam.OperationMainte.Maintainer", data.name)
  929. this.handleUpdataTable(
  930. [
  931. [this.row, "DPMaintainerID", null, data.venderId],
  932. [this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]
  933. ],
  934. "edit"
  935. )
  936. // this.handleUpdataTable([[this.row, "LedgerParam.OperationMainte.Maintainer", null, data.name]], "edit")
  937. },
  938. //修改关联的资产
  939. changeProperty(val) {
  940. this.setDataToMain(val.PropertyId, 'PropertyId', this.row);
  941. this.setDataToMain(val.LinkEquipLocalName, 'LinkEquipLocalName', this.row);
  942. },
  943. //上传文件弹窗触发事件
  944. fileChange(keys) {
  945. this.setDataToMain(keys, this.messKey, this.row);
  946. },
  947. //上传图片弹窗触发事件
  948. imgChange(keys) {
  949. this.setDataToMain(keys, this.messKey, this.row);
  950. },
  951. //关联系统更改
  952. changeSystemType(data) {
  953. tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
  954. },
  955. //资产图片弹窗改变事件
  956. changePics(keys) {
  957. this.setDataToMain(keys, this.messKey, this.row);
  958. },
  959. utilToKey(key, name, data, messName) {
  960. if (key == name) {
  961. this.setDataToMain(data[key], messName, this.row)
  962. }
  963. },
  964. //判断是否有值,有值赋值
  965. setDataToMain(data, key, row) {
  966. if (!!data && data != '--') {
  967. if (!!this.tableData[row]) {
  968. tools.setDataForKey(this.tableData[row], key, data);
  969. this.handleUpdataTable([[row, key, null, data]], "edit");
  970. } else {
  971. this.tableData[row] = {};
  972. tools.setDataForKey(this.tableData[row], key, data);
  973. }
  974. } else {
  975. tools.setDataForKey(this.tableData[row], key, "");
  976. }
  977. },
  978. //未知
  979. setGraphyId(graphyId, assetGroupList) {
  980. this.graphyId = graphyId
  981. this.assetGroupList = assetGroupList
  982. },
  983. },
  984. watch: {
  985. projectId() {
  986. this.main = []
  987. this.mess.deviceId = null
  988. this.page.total = 0
  989. },
  990. showTypes: {
  991. handler(newName, oldName) {
  992. if (newName && newName[0] && newName[0].value) {
  993. this.showType = newName[0].value
  994. } else {
  995. this.showType = ""
  996. }
  997. },
  998. immediate: true,
  999. deep: true
  1000. }
  1001. }
  1002. };
  1003. </script>
  1004. <style lang="less">
  1005. .hanson-bar {
  1006. height: 40px;
  1007. padding: 5px 0;
  1008. font-size: 14px;
  1009. overflow: hidden;
  1010. margin-top: 0;
  1011. line-height: 40px;
  1012. .iconfont {
  1013. font-size: 12px;
  1014. }
  1015. }
  1016. .add-assets {
  1017. .el-dialog__body {
  1018. height: 130px;
  1019. .die-text {
  1020. margin-left: 10px;
  1021. font-weight: bold;
  1022. clear: both;
  1023. padding-top: 25px;
  1024. padding-bottom: 10px;
  1025. .die-num {
  1026. width: 100px;
  1027. text-align: center;
  1028. display: inline-block;
  1029. border-bottom: 1px solid #333;
  1030. }
  1031. }
  1032. }
  1033. }
  1034. .cancelButtonClass {
  1035. width: 180px;
  1036. }
  1037. </style>