tenantRules.vue 11 KB

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