equipRules.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <div id="equipRules">
  3. <!-- 查询条件 -->
  4. <div class="query-area">
  5. <el-row>
  6. <el-col :span="22">
  7. <el-form ref="form" :model="form" :inline="true">
  8. <el-row>
  9. <div class="query-item special">
  10. <el-input :placeholder="`请输入${typeName}标识关键字`" v-model="form.EquipmentMark" @keyup.enter.native="queryTableData">
  11. <i slot="suffix" class="el-input__icon el-icon-search" @click="queryTableData"></i>
  12. </el-input>
  13. </div>
  14. <div class="query-item">
  15. <label style="padding-right:9px">数据源</label>
  16. <dataSource :Related="null" @change="changeDataSource" :typeName="typeName"></dataSource>
  17. </div>
  18. <div class="query-item">
  19. <dictionary-device @change="changeDictionary" :Related="null" :typeName="typeName"></dictionary-device>
  20. </div>
  21. <div class="query-item">
  22. <label style="padding-right:9px">位置标签</label>
  23. <locationFlag :Related="null" @change="changeLocationFlag" :typeName="typeName"></locationFlag>
  24. </div>
  25. </el-row>
  26. </el-form>
  27. </el-col>
  28. <el-col :span="2">
  29. <el-tooltip class="item" effect="dark" :content="`填充${typeName}标识与实例对应规则`" placement="left">
  30. <el-button size="small" type="primary" @click="toAddRelation" icon="el-icon-edit-outline" style="float:right;margin-left:10px;"
  31. :disabled="isPending">
  32. </el-button>
  33. </el-tooltip>
  34. <el-tooltip class="item" effect="dark" :content="`根据${typeName}标识自动填充实例`" placement="left">
  35. <el-button size="small" type="primary" @click="autoGroupRela" :icon="autoLoading?'iconfont icon-jiazai':'iconfont icon-zidong'"
  36. style="float:right;padding:7px 14px;width:44px;margin-left:0;" :disabled="autoLoading"></el-button>
  37. </el-tooltip>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. <el-row>
  42. <el-col :span="12" style="padding-left:10px;font-size:13px;border-left:2px solid #000;">点位表中出现的所有{{typeName}}</el-col>
  43. <el-col :span="12" style="padding-left:10px;font-size:13px;border-left:2px solid #000;">对应物理世界中的{{typeName}}实例</el-col>
  44. </el-row>
  45. <!-- 列表区域 -->
  46. <div class="table-area">
  47. <el-table :data="tableData" style="width: 100%" height="100%" v-loading="loading" :header-cell-style="headerStyle">
  48. <el-table-column prop="EquipmentMark" :label="`${typeName}标识`" show-overflow-tooltip min-width="100"></el-table-column>
  49. <el-table-column prop="LocationFlag" label="位置标签" min-width="200">
  50. <template slot-scope="scope">
  51. <el-tooltip :content="scope.row.LocationFlag.toString()" placement="top">
  52. <div class="tool-tip">{{scope.row.LocationFlag.toString()}}</div>
  53. </el-tooltip>
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="Datasource" label="数据源" show-overflow-tooltip min-width="100"></el-table-column>
  57. <el-table-column prop="SubTypeName" :label="`数字字典${typeName}类型`" show-overflow-tooltip min-width="100"></el-table-column>
  58. <el-table-column prop="ObjectLocalName" :label="`对应的${typeName}实例`" show-overflow-tooltip min-width="100" class-name="td-bl">
  59. </el-table-column>
  60. <el-table-column label="实例所在建筑楼层" min-width="100">
  61. <template slot-scope="scope">
  62. <el-tooltip
  63. :content="scope.row.BuildLocalName?scope.row.FloorLocalName?scope.row.BuildLocalName+'-'+scope.row.FloorLocalName:scope.row.BuildLocalName:''"
  64. placement="top">
  65. <div class="tool-tip">
  66. {{scope.row.BuildLocalName?scope.row.FloorLocalName?scope.row.BuildLocalName+'-'+scope.row.FloorLocalName:scope.row.BuildLocalName:''}}
  67. </div>
  68. </el-tooltip>
  69. </template>
  70. </el-table-column>
  71. <el-table-column prop="RoomLocalName" label="实例所在业务空间" show-overflow-tooltip min-width="200"></el-table-column>
  72. <el-table-column prop="action" label="操作" min-width="100">
  73. <template slot-scope="scope">
  74. <el-tooltip class="item" effect="dark" content="清除对应规则" placement="left">
  75. <el-button size="mini" @click="handleDelete(scope.$index, scope.row)" type="danger" plain
  76. :disabled="isPending||scope.row.Related=='False'" icon="el-icon-delete"></el-button>
  77. </el-tooltip>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </div>
  82. <!-- 分页 -->
  83. <el-pagination class="fr" v-show="tableData && tableData.length" @size-change="handleSizeChange" @current-change="handleCurrentChange"
  84. :current-page="page.pageNumber" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
  85. :total="page.total"></el-pagination>
  86. <!-- 清除对应关系弹窗 -->
  87. <del-relation-dialog ref="del" @refresh="refresh"></del-relation-dialog>
  88. </div>
  89. </template>
  90. <script>
  91. import tools from "@/utils/tools";
  92. import { mapGetters, mapActions } from "vuex";
  93. import applyRulesDialog from "@/components/point/dynamicdata/applyRulesDialog";
  94. import delRelationDialog from "@/components/point/dynamicdata/delRelationDialog";
  95. import dictionaryDevice from "@/components/point/dynamicdata/dictionaryDevice";
  96. import dataSource from "@/components/point/dynamicdata/dataSource";
  97. import locationFlag from "@/components/point/dynamicdata/locationFlag";
  98. import equipRules from "@/components/point/dynamicdata/equipRules";
  99. import {
  100. dynamicClashConfirm,
  101. dynamicExecute,
  102. dynamicQuery,
  103. dynamicQueryPoint,
  104. dynamicPointTypeList,
  105. queryEquip, //数据中心设备查询
  106. } from "@/api/scan/request";
  107. export default {
  108. computed: {
  109. ...mapGetters("layout", ["projectId"])
  110. },
  111. data() {
  112. return {
  113. headerStyle: {
  114. backgroundColor: '#e1e4e5',
  115. color: '#2b2b2b',
  116. lineHeight: '30px'
  117. },
  118. sourceList: [], //数据源
  119. DynEquipList: [], //数据字典设备类型
  120. LocFlagList: [], //位置标签
  121. tableData: [], //列表数据
  122. page: {
  123. pageSize: 50,
  124. pageSizes: [10, 20, 50, 100],
  125. pageNumber: 1,
  126. total: 0
  127. },
  128. form: {
  129. EquipmentMark: "", //设备标识关键字
  130. SubTypeName: [], //数据字典设备类型
  131. LocationFlag: [], //位置标签
  132. Datasource: [] //数据源
  133. }, //查询条件
  134. loading: false, //列表loading
  135. autoLoading: false, //自动对应实例
  136. };
  137. },
  138. components: {
  139. applyRulesDialog,
  140. delRelationDialog,
  141. dictionaryDevice,
  142. dataSource,
  143. locationFlag
  144. },
  145. props: {
  146. typeName: {},
  147. isPending: {
  148. default: false
  149. }
  150. },
  151. created() {
  152. this.init();
  153. },
  154. mounted() { },
  155. methods: {
  156. //获取查询条件-提示信息
  157. init() {
  158. this.getTableData()
  159. },
  160. //清除对应关系
  161. handleDelete(index, row) {
  162. this.$refs.del.showDialog(row);
  163. },
  164. //改变pagesize
  165. handleSizeChange(pageSize) {
  166. this.page.pageSize = pageSize;
  167. this.getTableData();
  168. },
  169. //改变pageno
  170. handleCurrentChange(pageNo) {
  171. this.page.pageNumber = pageNo;
  172. this.getTableData();
  173. },
  174. //跳转至填充对应规则
  175. toAddRelation() {
  176. this.$router.push({ path: "equipRela", query: { typeName: this.typeName } });
  177. },
  178. //获取表格数据
  179. getTableData() {
  180. let param = {
  181. PageNumber: this.page.pageNumber,
  182. PageSize: this.page.pageSize,
  183. TypeNameList: [this.typeName]
  184. };
  185. //处理查询条件
  186. if (this.form.EquipmentMark && this.form.EquipmentMark.length) {
  187. param.EquipmentMark = this.form.EquipmentMark;
  188. }
  189. if (this.form.SubTypeName.length) {
  190. param.SubTypeCodeList = this.form.SubTypeName;
  191. }
  192. if (this.form.LocationFlag.length) {
  193. param.LocationFlagList = this.form.LocationFlag;
  194. }
  195. if (this.form.Datasource.length) {
  196. param.DatasourceList = this.form.Datasource;
  197. }
  198. this.loading = true;
  199. // 查询对应关系(P1)
  200. dynamicQuery(param, res => {
  201. let dyData = res.Content;
  202. let tempArr = dyData.map(t => {
  203. if (t.Related == 'True') {
  204. t.EquipID = t.TypeCode + t.ProjectId + t.ObjectID;
  205. return t.EquipID;
  206. }
  207. return undefined;
  208. }).filter(item => item);
  209. if (tempArr.length) {
  210. queryEquip({
  211. PageSize: this.page.pageSize,
  212. Filters: `EquipID in ${JSON.stringify(tempArr)}`,
  213. Cascade: [{ Name: "zoneSpaceInBase" }, { Name: 'building' }, { Name: 'floor' }]
  214. }, response => {
  215. let Data = response.Content;
  216. dyData.forEach(item => {
  217. Data.forEach(t => {
  218. if (t.EquipID == item.EquipID) {
  219. item.ObjectLocalName = t.EquipLocalName;
  220. item.FloorLocalName = t.Floor ? t.Floor.FloorLocalName : '';
  221. item.BuildLocalName = t.Building ? t.Building.BuildLocalName : '';
  222. item.RoomLocalName = '';
  223. if (t.ZoneSpaceBaseIn) {
  224. t.ZoneSpaceBaseIn.forEach(it => {
  225. item.RoomLocalName += it.RoomLocalName + ',';
  226. })
  227. item.RoomLocalName = item.RoomLocalName.substring(0, item.RoomLocalName.length - 1);
  228. }
  229. }
  230. })
  231. })
  232. this.loading = false;
  233. this.tableData = dyData;
  234. })
  235. } else {
  236. this.loading = false;
  237. this.tableData = dyData;
  238. }
  239. this.page.total = res.PageSize < 50 ? res.PageSize : res.Total;
  240. });
  241. },
  242. //刷新列表
  243. refresh() {
  244. this.page.pageNumber = 1;
  245. this.$emit('refresh', this.typeName);
  246. this.getTableData();
  247. },
  248. //数据字典设备类型修改
  249. changeDictionary(val) {
  250. this.page.pageNumber = 1;
  251. this.form.SubTypeName = val;
  252. this.getTableData();
  253. },
  254. //数据源修改
  255. changeDataSource(val) {
  256. this.page.pageNumber = 1;
  257. this.form.Datasource = val;
  258. this.getTableData();
  259. },
  260. //修改位置标签
  261. changeLocationFlag(val) {
  262. this.page.pageNumber = 1;
  263. this.form.LocationFlag = val;
  264. this.getTableData();
  265. },
  266. //查询列表
  267. queryTableData() {
  268. this.page.pageNumber = 1;
  269. this.getTableData();
  270. },
  271. //自动对应实例
  272. autoGroupRela() {
  273. this.$emit('autoGroupRela', 'equip');
  274. }
  275. },
  276. watch: {
  277. projectId() {
  278. this.init();
  279. }
  280. }
  281. };
  282. </script>
  283. <style lang="scss" scoped>
  284. #equipRules {
  285. height: calc(100% - 54px);
  286. /deep/ .text-right {
  287. text-align: right;
  288. }
  289. .query-item {
  290. float: left;
  291. & + .query-item {
  292. margin-left: 10px;
  293. }
  294. }
  295. /deep/ .special .el-input__inner {
  296. width: 220px;
  297. }
  298. /deep/ .table-area {
  299. width: 100%;
  300. height: calc(100% - 71px);
  301. margin-bottom: 10px;
  302. td div {
  303. white-space: nowrap;
  304. text-overflow: ellipsis;
  305. overflow: hidden;
  306. }
  307. .td-bl {
  308. border-left: 1px solid #ebeef5;
  309. }
  310. .tool-tip {
  311. white-space: nowrap;
  312. overflow: hidden;
  313. text-overflow: ellipsis;
  314. }
  315. }
  316. }
  317. </style>