index.vue 11 KB

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