index.vue 12 KB

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