indexExport.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div>
  3. <el-row style="margin-top: 30px;">
  4. <span>请选择要导出的数据:</span>
  5. <el-select v-model="value" placeholder="请选择">
  6. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  7. </el-select>
  8. <el-button @click="handleClickDownload" type="primary" :loading="loading" style="margin-left: 15px;">导出Excel</el-button>
  9. </el-row>
  10. <div style="text-align:center;font-size:25px;margin-top:20%;">当前页面中的为临时功能,完整版正在设计中……</div>
  11. </div>
  12. </template>
  13. <script>
  14. import jsontoExcel from "@/utils/JOSNToExcel"
  15. import { State, Family } from "@/data/mapTable"
  16. import { queryEquip, queryProperty } from "@/api/scan/request"
  17. import { mapGetters, mapActions } from "vuex"
  18. export default {
  19. data() {
  20. return {
  21. loading: false,
  22. value: '',
  23. dataList: [],
  24. options: [{
  25. value: 'header1',
  26. label: '已建立关联的设备资产'
  27. }, {
  28. value: 'header2',
  29. label: '未关联资产的设备'
  30. }, {
  31. value: 'header3',
  32. label: '未关联设备的资产'
  33. }],
  34. header1: [{
  35. fieldName: "Building.BuildLocalName",
  36. headerName: "建筑"
  37. }, {
  38. fieldName: "Floor.FloorLocalName",
  39. headerName: "楼层"
  40. }, {
  41. fieldName: "EquipCategory.EquipName",
  42. headerName: "设备类"
  43. }, {
  44. fieldName: "EquipLocalName",
  45. headerName: "设备本地名称"
  46. }, {
  47. fieldName: "EquipLocalID",
  48. headerName: "设备本地编码"
  49. }, {
  50. fieldName: "EquipID",
  51. headerName: "设备id"
  52. }, {
  53. fieldName: "BIMID",
  54. headerName: "设备BIMID"
  55. }, {
  56. fieldName: "Property.EquipFamilyList.0.FamilyName",
  57. headerName: "资产设备族"
  58. }, {
  59. fieldName: "Property.EquipLocalName",
  60. headerName: "资产本地名称"
  61. }, {
  62. fieldName: "Property.EquipLocalID",
  63. headerName: "资产本地编码"
  64. }, {
  65. fieldName: "Property.EquipID",
  66. headerName: "资产id"
  67. }, {
  68. fieldName: "Property.CreateTime",
  69. headerName: "资产创建时间"
  70. }, {
  71. fieldName: "Property.CodeType",
  72. headerName: "资产现场验证状态"
  73. }, {
  74. fieldName: "LedgerParam.Siteinstall.InstallLocation",
  75. headerName: "安装位置"
  76. }],
  77. header2: [{
  78. fieldName: "Building.BuildLocalName",
  79. headerName: "建筑"
  80. }, {
  81. fieldName: "Floor.FloorLocalName",
  82. headerName: "楼层"
  83. }, {
  84. fieldName: "EquipCategory.EquipName",
  85. headerName: "设备类"
  86. }, {
  87. fieldName: "EquipLocalName",
  88. headerName: "设备本地名称"
  89. }, {
  90. fieldName: "EquipLocalID",
  91. headerName: "设备本地编码"
  92. }, {
  93. fieldName: "EquipID",
  94. headerName: "设备id"
  95. }, {
  96. fieldName: "BIMID",
  97. headerName: "设备BIMID"
  98. }, {
  99. fieldName: "Property.EquipFamilyList.0.FamilyName",
  100. headerName: "资产设备族"
  101. }, {
  102. fieldName: "Property.EquipLocalName",
  103. headerName: "资产本地名称"
  104. }, {
  105. fieldName: "Property.EquipLocalID",
  106. headerName: "资产本地编码"
  107. }, {
  108. fieldName: "Property.EquipID",
  109. headerName: "资产id"
  110. }, {
  111. fieldName: "Property.CreateTime",
  112. headerName: "资产创建时间"
  113. }, {
  114. fieldName: "Property.CodeType",
  115. headerName: "资产现场验证状态"
  116. }, {
  117. fieldName: "LedgerParam.Siteinstall.InstallLocation",
  118. headerName: "安装位置"
  119. }],
  120. header3: [{
  121. fieldName: "Building.BuildLocalName",
  122. headerName: "建筑"
  123. }, {
  124. fieldName: "Floor.FloorLocalName",
  125. headerName: "楼层"
  126. }, {
  127. fieldName: "Equipment.EquipCategory.EquipName",
  128. headerName: "设备类"
  129. }, {
  130. fieldName: "Equipment.EquipLocalName",
  131. headerName: "设备本地名称"
  132. }, {
  133. fieldName: "Equipment.EquipLocalID",
  134. headerName: "设备本地编码"
  135. }, {
  136. fieldName: "Equipment.EquipID",
  137. headerName: "设备id"
  138. }, {
  139. fieldName: "Equipment.BIMID",
  140. headerName: "设备BIMID"
  141. }, {
  142. fieldName: "EquipFamilyList.0.FamilyName",
  143. headerName: "资产设备族"
  144. }, {
  145. fieldName: "EquipLocalName",
  146. headerName: "资产本地名称"
  147. }, {
  148. fieldName: "EquipLocalID",
  149. headerName: "资产本地编码"
  150. }, {
  151. fieldName: "EquipID",
  152. headerName: "资产id"
  153. }, {
  154. fieldName: "CreateTime",
  155. headerName: "资产创建时间"
  156. }, {
  157. fieldName: "CodeType",
  158. headerName: "资产现场验证状态"
  159. }, {
  160. fieldName: "LedgerParam.Siteinstall.InstallLocation",
  161. headerName: "安装位置"
  162. }]
  163. }
  164. },
  165. methods: {
  166. handleClickDownload() {
  167. this.loading = true
  168. this.dataList = []
  169. if (this.value == 'header1') {
  170. this.getheader1Data()
  171. } else if (this.value == 'header2') {
  172. this.getheader2Data()
  173. } else if (this.value == 'header3') {
  174. this.getheader3Data()
  175. }
  176. },
  177. getheader1Data(pageNum) {
  178. pageNum = pageNum ? pageNum : 1
  179. let params = {
  180. Cascade: [
  181. {
  182. Name: "equipCategory",
  183. Projection: ["EquipCode", "EquipName"]
  184. },
  185. {
  186. Name: "property",
  187. Cascade: [
  188. {
  189. Name: "equipFamilyList",
  190. Projection: [ "Family", "FamilyName" ]
  191. }
  192. ],
  193. Projection: ["Family", "EquipLocalName", "EquipLocalID", "EquipID", "CodeType", "CreateTime"]
  194. },
  195. {
  196. Name: "building",
  197. Projection: ["BuildLocalName", "BuildName", "BuildID"]
  198. },
  199. {
  200. Name: "floor",
  201. Projection: ["FloorLocalName", "FloorName", "FloorID"]
  202. }
  203. ],
  204. Filters: " not propertyId isnull ",
  205. Orders: "CreateTime desc, EquipID asc",
  206. PageNumber: pageNum,
  207. PageSize: 1000,
  208. Projection: ["CreateTime", "BuildingId", "FloorId", "Category", "EquipLocalName", "EquipLocalID", "EquipID", "BIMID", "LedgerParam"]
  209. }
  210. queryEquip(params, res => {
  211. this.dataList = this.dataList.concat(res.Content.map((item) => {
  212. item.Property.CodeType = State[item.Property.CodeType]
  213. // item.Property.Family = Family[item.Property.Family]
  214. return item
  215. }))
  216. if (res.Total / (res.PageSize * res.PageNumber) > 1) {
  217. this.getheader1Data(res.PageNumber + 1)
  218. } else {
  219. let time = +new Date()
  220. this.loading = false
  221. jsontoExcel.downloadExl(this.header1, this.dataList, `已建立关联的资产设备-${time}`)
  222. }
  223. })
  224. },
  225. getheader2Data(pageNum) {
  226. pageNum = pageNum ? pageNum : 1
  227. let params = {
  228. Cascade: [
  229. {
  230. Name: "equipCategory",
  231. Projection: ["EquipCode", "EquipName"]
  232. },
  233. {
  234. Name: "building",
  235. Projection: ["BuildLocalName", "BuildName", "BuildID"]
  236. },
  237. {
  238. Name: "floor",
  239. Projection: ["FloorLocalName", "FloorName", "FloorID"]
  240. }
  241. ],
  242. Filters: " propertyId isnull ",
  243. Orders: "CreateTime desc, EquipID asc",
  244. PageNumber: pageNum,
  245. PageSize: 1000,
  246. Projection: ["CreateTime", "BuildingId", "FloorId", "Category", "EquipLocalName", "EquipLocalID", "EquipID", "BIMID", "LedgerParam"]
  247. }
  248. queryEquip(params, res => {
  249. this.dataList = this.dataList.concat(res.Content)
  250. if (res.Total / (res.PageSize * res.PageNumber) > 1) {
  251. this.getheader2Data(res.PageNumber + 1)
  252. } else {
  253. let time = +new Date()
  254. this.loading = false
  255. jsontoExcel.downloadExl(this.header2, this.dataList, `未关联资产的设备-${time}`)
  256. }
  257. })
  258. },
  259. getheader3Data(pageNum) {
  260. pageNum = pageNum ? pageNum : 1
  261. let params = {
  262. Cascade: [
  263. {
  264. Name: "equipFamilyList",
  265. Projection: [ "Family", "FamilyName" ]
  266. },
  267. {
  268. Name: "building",
  269. Projection: [ "BuildLocalName", "BuildName", "BuildID" ]
  270. },
  271. {
  272. Name: "floor",
  273. Projection: [ "FloorLocalName", "FloorName", "FloorID" ]
  274. }
  275. ],
  276. Filters: " EquipmentId isnull ",
  277. Orders: "CreateTime desc, EquipID asc",
  278. PageNumber: pageNum,
  279. PageSize: 1000,
  280. Projection: [ "BuildingId", "FloorId", "Family", "EquipLocalName", "EquipLocalID", "EquipID", "CreateTime", "CodeType", "LedgerParam"]
  281. }
  282. queryProperty(params, res => {
  283. this.dataList = this.dataList.concat(res.Content.map((item) => {
  284. item.CodeType = State[item.CodeType]
  285. return item
  286. }))
  287. if (res.Total / (res.PageSize * res.PageNumber) > 1) {
  288. this.getheader3Data(res.PageNumber + 1)
  289. } else {
  290. let time = +new Date()
  291. this.loading = false
  292. jsontoExcel.downloadExl(this.header3, this.dataList, `未关联设备的资产-${time}`)
  293. }
  294. })
  295. }
  296. }
  297. }
  298. </script>
  299. <style scoped>
  300. </style>