index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <!-- 图例库首页 -->
  3. <div class='legend-rules'>
  4. <div class='nav'>
  5. <img class='img-menu' src='@/assets/imgs/menu.png' alt />
  6. <el-divider direction='vertical'></el-divider>
  7. <img class='img-logo' src='@/assets/imgs/logo_tu.png' alt />
  8. <span style='color:#1F2329'>万达管理说明书</span>
  9. <span class='circular'></span>
  10. <!-- <span style='color:#1F2329'>图例绘制规则</span>
  11. <i class='el-icon-caret-bottom'></i>-->
  12. <Dropdown v-model='selVal' :data='dataSelect'>
  13. <span style=' font-size: 14px;color: #1f2329 ;'>{{selText}}</span>
  14. </Dropdown>
  15. </div>
  16. <div class='legend-rules-top'>
  17. 图例绘制规则
  18. <el-button type='primary' class='rules-button' size='small' @click='add'>添加图例</el-button>
  19. </div>
  20. <div class='legend-rules-bottom'>
  21. <div class='legend-rules-left'>
  22. <!-- <p>楼层功能</p> -->
  23. <!-- <el-tree :data='treeData' :default-checked-keys='`GDXT`' :props='defaultProps' default-expand-all @node-click='handleNodeClick'></el-tree> -->
  24. <a-tree
  25. :tree-data='treeData'
  26. v-if='treeData.length'
  27. defaultExpandAll
  28. :replaceFields='defaultProps'
  29. :default-selected-keys='["GDXT"]'
  30. @select='handleNodeClick'
  31. ></a-tree>
  32. </div>
  33. <div class='legend-rules-right'>
  34. <!-- <el-table :data='tableData' style='width: 100%'>
  35. <el-table-column prop='Name' label='图例名称'>
  36. <template slot-scope='{row}'>{{row.Name || '--'}}</template>
  37. </el-table-column>
  38. <el-table-column prop='Url' label='图例样式'>
  39. <template slot-scope='{row}'>
  40. <img v-if='row.Url' class='img' :src='`/serve/topology-wanda/Picture/query/${row.Url}`' alt />
  41. <span v-else>{{'--'}}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column prop label='单位'>
  45. <template slot-scope='{row}'>{{row.Unit || '--'}}</template>
  46. </el-table-column>
  47. <el-table-column label='操作' width='100'>
  48. <template slot-scope='scope'>
  49. <el-button @click='deleteClick(scope.row)' type='text' size='small'>删除</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>-->
  53. <Table
  54. :head='headList2'
  55. :source='tableData'
  56. :toolButtons='toolBtns'
  57. :selectWidth='180'
  58. height='100%'
  59. @tool-button-click='buttonClickHandle'
  60. >
  61. <img slot-scope='{col, row}' v-if='col.key==="Url"' class='img' :src='`/serve/topology-wanda/Picture/query/${row.Url}`' alt />
  62. </Table>
  63. </div>
  64. </div>
  65. <add-legend ref='addLegend' @mesg='mesg'></add-legend>
  66. </div>
  67. </template>
  68. <script>
  69. import addLegend from '../legendLibrary/addLegend'
  70. import { getLegendTree, queryRelation, deleteRelation, graphElementUpdate } from '@/api/legendLibrary.js'
  71. export default {
  72. components: { addLegend },
  73. data() {
  74. return {
  75. treeData: [],
  76. GraphCategoryId: ['GDXT'],
  77. tableData: [],
  78. defaultProps: {
  79. children: 'Category',
  80. title: 'Name',
  81. key: 'Id'
  82. }, //test
  83. // 可筛选表格表头列表
  84. headList2: [
  85. {
  86. title: '图例名称', // 列的名称
  87. key: 'Name', // 列的标识
  88. show: true // 是否显示该列
  89. },
  90. {
  91. title: '图例样式',
  92. key: 'Url',
  93. show: true
  94. },
  95. {
  96. title: '单位',
  97. key: 'Unit',
  98. show: true
  99. }
  100. ],
  101. // 操作按钮组 (非必填)
  102. toolBtns: [
  103. {
  104. icon: 'copy',
  105. name: '上移'
  106. },
  107. {
  108. icon: 'print',
  109. name: '下移'
  110. },
  111. {
  112. icon: 'pending',
  113. name: '删除'
  114. }
  115. ],
  116. selText: '图例绘制规则',
  117. selVal: '1',
  118. dataSelect: [
  119. { id: '0', name: '图例库管理' },
  120. { id: '1', name: '图例绘制规则' }
  121. ]
  122. }
  123. },
  124. watch: {
  125. selVal(n, o) {
  126. if (n === o) return
  127. this.selText = this.dataSelect.find(d => d.id === n).name
  128. console.log(n, o)
  129. if (n == 0) {
  130. this.$router.push({ path: 'legendLibrary' })
  131. }
  132. if (n == 1) {
  133. this.$router.push({ path: 'legendRules' })
  134. }
  135. }
  136. },
  137. methods: {
  138. buttonClickHandle(obj) {
  139. let index = Number(obj.item.index.split('-')[1])
  140. let _this = this
  141. switch (obj.tool.name) {
  142. case '删除':
  143. this.deleteClick(obj.item)
  144. break
  145. case '上移':
  146. up()
  147. break
  148. case '下移':
  149. down()
  150. break
  151. }
  152. function up() {
  153. if (index == 0) {
  154. _this.$message.error('处于顶端,不可再上移')
  155. } else {
  156. let upDate = _this.tableData[index - 1]
  157. _this.tableData.splice(index - 1, 1)
  158. _this.tableData.splice(index, 0, upDate)
  159. let ids = _this.tableData.map(({ Id }) => Id)
  160. _this.upDateGraphy(ids)
  161. }
  162. }
  163. function down() {
  164. if (index == _this.tableData.length - 1) {
  165. _this.$message.error('处于底端,不可再下移')
  166. } else {
  167. let downDate = _this.tableData[index + 1]
  168. _this.tableData.splice(index + 1, 1)
  169. _this.tableData.splice(index, 0, downDate)
  170. let ids = _this.tableData.map(({ Id }) => Id)
  171. _this.upDateGraphy(ids)
  172. }
  173. }
  174. },
  175. // 更新图例关系信息
  176. upDateGraphy(ids) {
  177. let posParams = {
  178. GraphCategoryId: this.GraphCategoryId[0],
  179. GraphElementIds: ids,
  180. Move: true
  181. }
  182. graphElementUpdate({ posParams }).then(res => {
  183. this.getData()
  184. })
  185. },
  186. handleNodeClick(data, e) {
  187. this.GraphCategoryId = [e.node.eventKey]
  188. this.getData()
  189. },
  190. deleteClick(row) {
  191. let postParams = [
  192. {
  193. GraphCategoryId: this.GraphCategoryId[0],
  194. GraphElementId: row.Id
  195. }
  196. ]
  197. deleteRelation({ postParams }).then(res => {
  198. if (res.Result == 'success') {
  199. this.$message({
  200. type: 'success',
  201. message: '删除成功!'
  202. })
  203. this.getData()
  204. }
  205. })
  206. },
  207. mesg() {
  208. this.getData()
  209. },
  210. add() {
  211. this.$refs.addLegend.open('', '', this.GraphCategoryId)
  212. },
  213. init() {
  214. let getParams = {}
  215. getLegendTree({ getParams }).then(res => {
  216. this.treeData = res.Content
  217. this.getData()
  218. })
  219. },
  220. getData() {
  221. let postParams = this.GraphCategoryId
  222. let data = {}
  223. queryRelation({ data, postParams }).then(res => {
  224. this.tableData = res.data.Content
  225. })
  226. }
  227. },
  228. mounted() {
  229. this.init()
  230. }
  231. }
  232. </script>
  233. <style lang="less" scoped>
  234. .legend-rules {
  235. background: rgba(247, 249, 250, 1);
  236. height: 100%;
  237. display: flex;
  238. flex-direction: column;
  239. color: #1f2329;
  240. .nav {
  241. height: 48px;
  242. line-height: 48px;
  243. width: 100%;
  244. background: #fff;
  245. margin-left: 17px;
  246. .img-menu {
  247. margin-right: 9px;
  248. }
  249. .img-logo {
  250. margin: 0 9px;
  251. }
  252. .circular {
  253. display: inline-block;
  254. width: 4px;
  255. height: 4px;
  256. background: rgba(195, 198, 203, 1);
  257. border-radius: 50%;
  258. margin: 0 8px 3px 8px;
  259. }
  260. }
  261. /deep/ .p-drop .p-drop-title .p-drop-triangle {
  262. margin-top: -5px;
  263. }
  264. .legend-rules-top {
  265. text-align: center;
  266. height: 48px;
  267. line-height: 48px;
  268. font-size: 16px;
  269. .rules-button {
  270. float: right;
  271. margin-right: 16px;
  272. margin-top: 8px;
  273. }
  274. }
  275. .legend-rules-bottom {
  276. flex: 1;
  277. display: flex;
  278. .legend-rules-left {
  279. // width: 288px;
  280. // padding: 26px;
  281. }
  282. .legend-rules-right {
  283. padding: 16px;
  284. flex: 1;
  285. background: #fff;
  286. color: #1f2429;
  287. .img {
  288. width: 28px;
  289. height: 28px;
  290. }
  291. }
  292. }
  293. }
  294. </style>
  295. <style lang="less" >
  296. .legend-rules {
  297. .el-tree {
  298. background: rgba(247, 249, 250, 1);
  299. }
  300. .is-current {
  301. background: #e1f2ff !important;
  302. border-radius: 4px;
  303. font-size: 14px;
  304. color: rgba(0, 145, 255, 1);
  305. }
  306. th {
  307. font-size: 12px;
  308. font-family: MicrosoftYaHei;
  309. color: #646a73;
  310. height: 40px;
  311. background: rgba(248, 249, 250, 1);
  312. }
  313. td {
  314. color: #1f2429;
  315. }
  316. }
  317. </style>