index.vue 11 KB

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