733ba90dbd3f59ce803ba3c4ff1cd7a626d8e097.svn-base 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <s-table
  3. size="middle"
  4. bordered
  5. row-key="id"
  6. :columns="columns"
  7. :data="loadData_"
  8. >
  9. <!-- <template slot="graphType" slot-scope="text, record">
  10. <div v-if="text">
  11. <template v-for="(t,i) in getGraphType(text)">
  12. <a-tag color="cyan" :key="i">{{t}}</a-tag>
  13. </template>
  14. </div>
  15. </template> -->
  16. <template slot="action" slot-scope="text, record">
  17. <a @click="handleAdd(record)" :disabled="layoutCodes.indexOf(record.code)>=0">添加</a>
  18. <!-- <a-divider type="vertical" />
  19. <a @click="handleDel(record)" >移除</a> -->
  20. </template>
  21. </s-table>
  22. </template>
  23. <script>
  24. import STable from '@/components/Xtable'
  25. import { getAction } from '@/api/manage'
  26. // 引入相关的依赖
  27. export default {
  28. name: 'ChartList',
  29. components: {
  30. STable
  31. },
  32. props: {
  33. layout: {
  34. type: Array,
  35. default: () => []
  36. }
  37. },
  38. watch: {
  39. 'layout.length': {
  40. handler(newValue, oldValue) {
  41. this.layoutCodes = []
  42. this.layout.forEach(item => {
  43. this.layoutCodes.push(item.data.code)
  44. })
  45. }
  46. }
  47. },
  48. data() {
  49. return {
  50. queryParam: {},
  51. graphTypeDictOptions: {
  52. bar: '柱状图',
  53. line: '曲线图',
  54. pie: '饼图',
  55. transverseBarMuiltid: '条形图',
  56. radar: '雷达图',
  57. funnel: '漏斗图',
  58. table: '数据表格'
  59. },
  60. columns: [
  61. {
  62. title: '#',
  63. dataIndex: '',
  64. key: 'rowIndex',
  65. width: 60,
  66. align: 'center',
  67. customRender: function(t, r, index) {
  68. return parseInt(index) + 1
  69. }
  70. },
  71. {
  72. title: '图表名称',
  73. align: 'center',
  74. dataIndex: 'name'
  75. },
  76. {
  77. title: '编码',
  78. align: 'center',
  79. dataIndex: 'code'
  80. },
  81. {
  82. title: '图表类型',
  83. align: 'center',
  84. dataIndex: 'graphType',
  85. scopedSlots: { customRender: 'graphType' }
  86. },
  87. {
  88. title: '操作',
  89. dataIndex: 'action',
  90. align: 'center',
  91. scopedSlots: { customRender: 'action' }
  92. }
  93. ],
  94. url: {
  95. list: '/diagram/diagramConfiguration/list'
  96. },
  97. layoutCodes: [],
  98. loadData_: parameter => {
  99. return getAction(this.url.list, Object.assign(parameter, this.queryParam)).then(res => {
  100. return res.result
  101. })
  102. }
  103. }
  104. },
  105. methods: {
  106. handleDel(data) {
  107. this.$emit('delete', data.i)
  108. },
  109. handleAdd(data) {
  110. this.$emit('add', {
  111. code: data.code,
  112. title: data.name,
  113. url: '/online/cggraphreport/chart/' + data.code,
  114. comp: 'OnlGraphreportAutoChart'
  115. })
  116. },
  117. getGraphType(graphTypes) {
  118. if (graphTypes) {
  119. var arry = []
  120. graphTypes.split(',').forEach(item => {
  121. this.graphTypeDictOptions[item] ? arry.push(this.graphTypeDictOptions[item]) : ''
  122. })
  123. return arry
  124. } else {
  125. return []
  126. }
  127. }
  128. },
  129. mounted() {
  130. this.layout.forEach(item => {
  131. this.layoutCodes.push(item.code)
  132. })
  133. }
  134. }
  135. </script>
  136. <style scoped>
  137. </style>