index.vue 11 KB

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