index.vue 9.0 KB

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