objectInstance.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <!-- 对象实例 -->
  3. <div id="objectInstance" v-loading="loading">
  4. <div class="obj-item" v-for="form in forms" :key="form.id" :style="{height:drawCanvas? '600px' : '350px'}">
  5. <el-form :model="form" label-width="150px">
  6. <el-form-item label="对象类型:">
  7. {{ form.TypeName || '--' }}
  8. </el-form-item>
  9. <el-form-item label="对象实例本地名称:">
  10. {{ form.ObjectLocalName || '--' }}
  11. </el-form-item>
  12. <el-form-item label="对象实例本地编码:">
  13. {{ form.ObjectLocalCode || '--' }}
  14. </el-form-item>
  15. <el-form-item label="对象实例ID:">
  16. {{ form.ObjectID || '--' }}
  17. </el-form-item>
  18. <el-form-item label="信息点名称:">
  19. {{ form.InfomationPointName || '--' }}
  20. </el-form-item>
  21. <el-form-item label="对应值:">
  22. {{ reValue || '--' }}
  23. </el-form-item>
  24. <el-form-item label="对象实例位置图:">
  25. <span v-show="!drawCanvas">--</span>
  26. <div v-show="drawCanvas" style="border:1px solid rgba(0, 0, 0, 0.2);height:300px;">
  27. <canvas v-show="drawCanvas" height="300" :width="canvasWidth" class="instanceMap" :id="form.instanceId"
  28. :k="refreshCanvas"></canvas>
  29. </div>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapGetters } from 'vuex'
  37. import { LocationPointScene, DivideFloorScene, FloorView } from "@saga-web/cad-engine"
  38. import { SColor } from "@saga-web/draw/lib";
  39. import {
  40. getTabFunNumObjInstance,
  41. // floorQuery, //数据中心查询楼层
  42. projectQuery, //数据中心查询项目信息
  43. zoneQueryOutline, //数据中心所有空间实例
  44. queryLinkSys, //数据中心系统查询
  45. queryTenant, //数据中心查询租户
  46. partsQuery, //数据中心部件查询
  47. } from '@/api/scan/request'
  48. import { floorQuery } from '@/api/object/floor'
  49. import { queryEquip } from "@/api/object/equip";
  50. import { getDataDictionary } from "@/api/dict";
  51. import { buildingQuery } from '@/api/object/build'
  52. export default {
  53. data() {
  54. return {
  55. forms: [],//实例数据
  56. views: [],//canvas view
  57. scenes: [],//canvas scene
  58. loading: true,
  59. refreshCanvas: '',//重载canvas组件
  60. drawCanvas: false,//是否画canvas,
  61. canvasWidth: 450
  62. }
  63. },
  64. methods: {
  65. //加载对象实例
  66. loadObjectInstance() {
  67. this.loading = true;
  68. let pa = {
  69. Filters: `MeterFuncid='${this.tabFunNum}';Related='true'`//
  70. };
  71. let that = this;
  72. //获取所有实例信息
  73. getTabFunNumObjInstance(pa, res => {
  74. that.loading = false;
  75. that.forms = res.Content;
  76. res.Content.map((item, key) => {
  77. //存在实例ID
  78. if (item.ObjectID) {
  79. that.forms[key].instanceId = item.ObjectID;
  80. if (item.TypeCode == 'Eq') {
  81. //获取设备信息
  82. queryEquip({
  83. filters: `equipID='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  84. }, equipMsg => {
  85. if (equipMsg.content[0]) {
  86. if (equipMsg.content[0].locationJson && equipMsg.content[0].floorId) {
  87. let canvasOption = {
  88. /** 标记的id */
  89. Id: equipMsg.content[0].equipID,
  90. /** 标记的名称 */
  91. Name: equipMsg.content[0].equipName,
  92. /** X坐标 */
  93. X: equipMsg.content[0].locationJson.X,
  94. /** Y坐标 */
  95. Y: -equipMsg.content[0].locationJson.Y
  96. }
  97. that.forms[key].ObjectLocalName = equipMsg.content[0].equipLocalName
  98. that.forms[key].ObjectLocalCode = equipMsg.content[0].equipLocalID
  99. this.loadDataToInstanceByFloorID(equipMsg.content[0].floorId, key, item.TypeCode, canvasOption);
  100. }
  101. if (item.InfoList.length && equipMsg.content[0].classCode) {
  102. let params = {
  103. filters: `code in ${JSON.stringify(item.InfoList)}`,
  104. type: equipMsg.content[0].classCode
  105. }
  106. getDataDictionary(params, resp => {
  107. that.forms[key].InfomationPointName = resp.content.map(t => t.name).join(',');
  108. that.$forceUpdate()
  109. })
  110. }
  111. }
  112. })
  113. } else if (item.TypeCode == 'Sp') {
  114. //获取空间信息
  115. if (item.SpaceType) {
  116. zoneQueryOutline({
  117. Filters: `RoomID='${item.TypeCode + item.ProjectId + item.ObjectID}'`,
  118. ZoneType: item.SpaceType
  119. }, zoneMsg => {
  120. if (zoneMsg.Content[0]) {
  121. if (zoneMsg.Content[0].Outline) {
  122. let canvasOption = {
  123. RoomLocalName: zoneMsg.Content[0].RoomLocalName,
  124. OutLine: zoneMsg.Content[0].Outline,
  125. RoomID: zoneMsg.Content[0].RoomID,
  126. Color: '#F9C3C3'
  127. }
  128. that.forms[key].ObjectLocalName = zoneMsg.Content[0].RoomLocalName
  129. that.forms[key].ObjectLocalCode = zoneMsg.Content[0].RoomLocalID
  130. this.loadDataToInstanceByFloorID(zoneMsg.Content[0].FloorId, key, item.TypeCode, canvasOption);
  131. }
  132. if (item.InfoList.length && zoneMsg.Content[0].ObjectType) {
  133. let params = {
  134. filters: `code in ${JSON.stringify(item.InfoList)}`,
  135. type: zoneMsg.Content[0].ObjectType
  136. }
  137. getDataDictionary(params, resp => {
  138. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  139. that.$forceUpdate()
  140. })
  141. }
  142. }
  143. });
  144. }
  145. } else if (item.TypeCode == 'Ec') {
  146. partsQuery({
  147. Filters: `EquipID='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  148. }, equipMsg => {
  149. if (equipMsg.Content[0]) {
  150. if (equipMsg.Content[0].LocationJson && equipMsg.Content[0].FloorId) {
  151. let canvasOption = {
  152. /** 标记的id */
  153. Id: equipMsg.Content[0].EquipID,
  154. /** 标记的名称 */
  155. Name: equipMsg.Content[0].EquipName,
  156. /** X坐标 */
  157. X: equipMsg.Content[0].LocationJson.X,
  158. /** Y坐标 */
  159. Y: -equipMsg.Content[0].LocationJson.Y
  160. }
  161. that.forms[key].ObjectLocalName = equipMsg.Content[0].EquipLocalName
  162. that.forms[key].ObjectLocalCode = equipMsg.Content[0].EquipLocalID
  163. this.loadDataToInstanceByFloorID(equipMsg.Content[0].FloorId, key, item.TypeCode, canvasOption);
  164. }
  165. if (item.InfoList.length && equipMsg.Content[0].Category) {
  166. let params = {
  167. filters: `code in ${JSON.stringify(item.InfoList)}`,
  168. type: equipMsg.Content[0].Category
  169. }
  170. getDataDictionary(params, resp => {
  171. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  172. that.$forceUpdate()
  173. })
  174. }
  175. }
  176. })
  177. } else if (item.TypeCode == 'Sy') {
  178. queryLinkSys({
  179. filters: `id='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  180. }, res => {
  181. if (res.content.length) {
  182. that.forms[key].ObjectLocalName = res.content[0].localName
  183. that.forms[key].ObjectLocalCode = res.content[0].localId
  184. if (item.InfoList.length && res.content[0].classCode) {
  185. let params = {
  186. filters: `code in ${JSON.stringify(item.InfoList)}`,
  187. type: res.content[0].classCode
  188. }
  189. getDataDictionary(params, resp => {
  190. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  191. that.$forceUpdate()
  192. })
  193. }
  194. }
  195. })
  196. } else if (item.TypeCode == 'Bd') {
  197. buildingQuery({
  198. filters: `id='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  199. }, res => {
  200. if (res.content.length) {
  201. that.forms[key].ObjectLocalName = res.content[0].localName
  202. that.forms[key].ObjectLocalCode = res.content[0].localId
  203. if (item.InfoList.length && res.content[0].objectType) {
  204. let params = {
  205. filters: `code in ${JSON.stringify(item.InfoList)}`,
  206. type: res.content[0].objectType
  207. }
  208. getDataDictionary(params, resp => {
  209. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  210. that.$forceUpdate()
  211. })
  212. }
  213. }
  214. })
  215. } else if (item.TypeCode == 'Fl') {
  216. floorQuery({
  217. filters: `id='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  218. }, res => {
  219. if (res.content.length) {
  220. that.forms[key].ObjectLocalName = res.content[0].localName
  221. that.forms[key].ObjectLocalCode = res.content[0].localId
  222. if (item.InfoList.length && res.content[0].objectType) {
  223. let params = {
  224. filters: `code in ${JSON.stringify(item.InfoList)}`,
  225. type: res.content[0].objectType
  226. }
  227. getDataDictionary(params, resp => {
  228. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  229. that.$forceUpdate()
  230. })
  231. }
  232. }
  233. })
  234. } else if (item.TypeCode == 'VOTn') {
  235. queryTenant({
  236. Filters: `TenantID='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  237. }, res => {
  238. if (res.Content.length) {
  239. that.forms[key].ObjectLocalName = res.Content[0].TenantLocalName
  240. that.forms[key].ObjectLocalCode = res.Content[0].TenantLocalID
  241. if (item.InfoList.length && res.Content[0].ObjectType) {
  242. let params = {
  243. filters: `code in ${JSON.stringify(item.InfoList)}`,
  244. type: res.Content[0].ObjectType
  245. }
  246. getDataDictionary(params, resp => {
  247. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  248. that.$forceUpdate()
  249. })
  250. }
  251. }
  252. })
  253. } else if (item.TypeCode == 'Pj') {
  254. projectQuery({
  255. Filters: `ProjID='${item.TypeCode + item.ProjectId + item.ObjectID}'`
  256. }, res => {
  257. if (res.Content.length) {
  258. that.forms[key].ObjectLocalName = res.Content[0].ProjLocalName
  259. that.forms[key].ObjectLocalCode = res.Content[0].ProjLocalID
  260. if (item.InfoList.length && res.Content[0].ObjectType) {
  261. let params = {
  262. filters: `code in ${JSON.stringify(item.InfoList)}`,
  263. type: res.Content[0].ObjectType
  264. }
  265. getDataDictionary(params, resp => {
  266. that.forms[key].InfomationPointName = resp.content.map(t => t.name || '').join(',');
  267. that.$forceUpdate()
  268. })
  269. }
  270. }
  271. })
  272. }
  273. }
  274. });
  275. })
  276. },
  277. //通过floorid获取信息,后通过floormap获取数据后绘制canvas
  278. loadDataToInstanceByFloorID(floorId, key, typecode, options) {
  279. let param = {
  280. filters: `floorId='${floorId}'`
  281. }
  282. let that = this;
  283. //获取楼层信息
  284. floorQuery(param, floorMsg => {
  285. //刷新canvas
  286. that.refreshCanvas = new Date().getTime();
  287. if (!that.views[key]) {
  288. that.views[key] = new FloorView(`${that.forms[key].instanceId}`)
  289. }
  290. that.views[key].scene = null;
  291. that.scenes[key] = null;
  292. //类型
  293. if (typecode == 'Eq' || typecode == 'Ec') {
  294. that.scenes[key] = new LocationPointScene();
  295. } else if (typecode == 'Sp') {
  296. that.scenes[key] = new DivideFloorScene();
  297. }
  298. if (floorMsg.content[0] && floorMsg.content[0].structureInfo && floorMsg.content[0].structureInfo.floorMap) {
  299. //获取数据,并加载canvas
  300. that.scenes[key].loadUrl(`/image-service/common/file_get?systemId=revit&key=${floorMsg.content[0].structureInfo.floorMap}`).then(() => {
  301. that.drawCanvas = true;
  302. that.views[key].scene = that.scenes[key];
  303. that.scenes[key].isSpaceSelectable = false;
  304. if (typecode == 'Eq' || typecode == 'Ec') {
  305. that.scenes[key].addMarker(options);
  306. } else if (typecode == 'Sp') {
  307. that.scenes[key].addZone(options);
  308. }
  309. that.views[key].fitSceneToView();
  310. })
  311. } else {
  312. that.drawCanvas = false;
  313. }
  314. });
  315. }
  316. },
  317. mounted() {
  318. this.canvasWidth = document.getElementById("objectInstance").offsetWidth - 200
  319. this.loadObjectInstance();
  320. },
  321. props: {
  322. tabFunNum: String,//表号功能号,
  323. reValue: String//对应值
  324. },
  325. computed: {
  326. ...mapGetters('layout', ['projectId'])
  327. },
  328. watch: {
  329. //切换时更新数据
  330. tabFunNum() {
  331. this.loadObjectInstance();
  332. }
  333. }
  334. }
  335. </script>
  336. <style lang="less" scoped>
  337. #objectInstance {
  338. height: 100%;
  339. overflow: auto;
  340. }
  341. .instanceMap {
  342. min-height: 100px;
  343. }
  344. .obj-item {
  345. margin: 15px 10px;
  346. box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.2);
  347. background-color: white;
  348. padding: 10px 10px;
  349. height: 600px;
  350. }
  351. </style>