index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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 } 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. /**
  139. * 点击工具栏按钮回调方法
  140. * @param {Object} Obj {tool:{icon:'icon组件名称',name:'按钮名称',type:'icon组件type'},item:当前行数据}
  141. */
  142. buttonClickHandle(obj) {
  143. let index = Number(obj.item.index.split('-')[1])
  144. let _this = this
  145. switch (obj.tool.name) {
  146. case '删除':
  147. this.deleteClick(obj.item)
  148. break
  149. case '上移':
  150. up()
  151. break
  152. case '下移':
  153. down()
  154. break
  155. }
  156. function up() {
  157. if (index == 0) {
  158. _this.$message.error('处于顶端,不可再上移')
  159. } else {
  160. let upDate = _this.tableData[index - 1]
  161. _this.tableData.splice(index - 1, 1)
  162. _this.tableData.splice(index, 0, upDate)
  163. }
  164. }
  165. function down() {
  166. if (index == _this.tableData.length - 1) {
  167. _this.$message.error('处于底端,不可再下移')
  168. } else {
  169. let downDate = _this.tableData[index + 1]
  170. _this.tableData.splice(index + 1, 1)
  171. _this.tableData.splice(index, 0, downDate)
  172. }
  173. }
  174. },
  175. handleNodeClick(data, e) {
  176. this.GraphCategoryId = [e.node.eventKey]
  177. this.getData()
  178. },
  179. deleteClick(row) {
  180. console.log(row)
  181. let postParams = [
  182. {
  183. GraphCategoryId: this.GraphCategoryId[0],
  184. GraphElementId: row.Id
  185. }
  186. ]
  187. deleteRelation({ postParams }).then(res => {
  188. if (res.Result == 'success') {
  189. this.$message({
  190. type: 'success',
  191. message: '删除成功!'
  192. })
  193. this.getData()
  194. }
  195. })
  196. },
  197. mesg() {
  198. this.getData()
  199. },
  200. add() {
  201. this.$refs.addLegend.open('', '', this.GraphCategoryId)
  202. },
  203. init() {
  204. let getParams = {}
  205. getLegendTree({ getParams }).then(res => {
  206. this.treeData = res.Content
  207. this.getData()
  208. })
  209. },
  210. getData() {
  211. let postParams = this.GraphCategoryId
  212. let data = {}
  213. queryRelation({ data, postParams }).then(res => {
  214. this.tableData = res.data.Content
  215. })
  216. }
  217. },
  218. mounted() {
  219. this.init()
  220. }
  221. }
  222. </script>
  223. <style lang="less" scoped>
  224. .legend-rules {
  225. background: rgba(247, 249, 250, 1);
  226. height: 100%;
  227. display: flex;
  228. flex-direction: column;
  229. color: #1f2329;
  230. .nav {
  231. height: 48px;
  232. line-height: 48px;
  233. width: 100%;
  234. background: #fff;
  235. margin-left: 17px;
  236. .img-menu {
  237. margin-right: 9px;
  238. }
  239. .img-logo {
  240. margin: 0 9px;
  241. }
  242. .circular {
  243. display: inline-block;
  244. width: 4px;
  245. height: 4px;
  246. background: rgba(195, 198, 203, 1);
  247. border-radius: 50%;
  248. margin: 0 8px 3px 8px;
  249. }
  250. }
  251. /deep/ .p-drop .p-drop-title .p-drop-triangle {
  252. margin-top: -5px;
  253. }
  254. .legend-rules-top {
  255. text-align: center;
  256. height: 48px;
  257. line-height: 48px;
  258. font-size: 16px;
  259. .rules-button {
  260. float: right;
  261. margin-right: 16px;
  262. margin-top: 8px;
  263. }
  264. }
  265. .legend-rules-bottom {
  266. flex: 1;
  267. display: flex;
  268. .legend-rules-left {
  269. width: 288px;
  270. padding: 26px;
  271. }
  272. .legend-rules-right {
  273. padding: 16px;
  274. flex: 1;
  275. background: #fff;
  276. color: #1f2429;
  277. .img {
  278. width: 28px;
  279. height: 28px;
  280. }
  281. }
  282. }
  283. }
  284. </style>
  285. <style lang="less" >
  286. .legend-rules {
  287. .el-tree {
  288. background: rgba(247, 249, 250, 1);
  289. }
  290. .is-current {
  291. background: #e1f2ff !important;
  292. border-radius: 4px;
  293. font-size: 14px;
  294. color: rgba(0, 145, 255, 1);
  295. }
  296. th {
  297. font-size: 12px;
  298. font-family: MicrosoftYaHei;
  299. color: #646a73;
  300. height: 40px;
  301. background: rgba(248, 249, 250, 1);
  302. }
  303. td {
  304. color: #1f2429;
  305. }
  306. }
  307. </style>