index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div
  3. style="width: 100%;height: 100%"
  4. class="bs-design-wrap"
  5. >
  6. <dv-scroll-board
  7. :key="updateKey"
  8. :class="{'light-theme':customTheme === 'light','auto-theme':customTheme =='auto','dark-theme':customTheme =='dark'}"
  9. :config="option"
  10. @click="rowClick"
  11. />
  12. </div>
  13. </template>
  14. <script>
  15. import DvScrollBoard from '@jiaminghi/data-view/lib/components/scrollBoard/src/main.vue'
  16. import '@jiaminghi/data-view/lib/components/scrollBoard/src/main.css'
  17. import { refreshComponentMixin } from 'packages/js/mixins/refreshComponent'
  18. import commonMixins from 'packages/js/mixins/commonMixins'
  19. import paramsMixins from 'packages/js/mixins/paramsMixins'
  20. import linkageMixins from 'packages/js/mixins/linkageMixins'
  21. export default {
  22. name: 'ScrollBoard',
  23. components: {
  24. DvScrollBoard
  25. },
  26. mixins: [refreshComponentMixin, paramsMixins, commonMixins, linkageMixins],
  27. props: {
  28. // 卡片的属性
  29. config: {
  30. type: Object,
  31. default: () => ({})
  32. }
  33. },
  34. data () {
  35. return {
  36. }
  37. },
  38. computed: {
  39. option: {
  40. get () {
  41. return { ...this.config.customize, data: this.config.option?.data, header: this.config.option?.header, columnWidth: this.config.option?.columnWidth, align: this.config.option?.align }
  42. },
  43. set () {}
  44. }
  45. },
  46. watch: {
  47. },
  48. mounted () {
  49. this.chartInit()
  50. },
  51. methods: {
  52. // 表格点击事件
  53. rowClick (row) {
  54. console.log('点击')
  55. this.linkage(row)
  56. },
  57. dataFormatting (config, data) {
  58. const header = []
  59. const dataList = []
  60. const alignList = []
  61. const widthList = []
  62. if (config.customize.columnConfig.length === 0) {
  63. const key = []
  64. for (const i in data.columnData) {
  65. header.push(data.columnData[i].remark)
  66. key.push(i)
  67. }
  68. data.data.forEach((item) => {
  69. const arr = []
  70. header.forEach((x, index) => {
  71. arr.push(item[key[index]])
  72. })
  73. dataList.push(arr)
  74. })
  75. } else {
  76. const key = []
  77. config.customize.columnConfig.forEach(item => {
  78. header.push(item.name)
  79. key.push(item.code)
  80. alignList.push(item.align)
  81. widthList.push(item.width)
  82. })
  83. data.data.forEach((item) => {
  84. const arr = []
  85. header.forEach((x, index) => {
  86. arr.push(item[key[index]])
  87. })
  88. dataList.push(arr)
  89. })
  90. if (config.customize.index) {
  91. if (alignList.length === header.length) {
  92. alignList.unshift('center')
  93. }
  94. if (widthList.length === header.length) {
  95. widthList.unshift('100')
  96. }
  97. } else {
  98. if (alignList.length !== header.length) {
  99. alignList.shift()
  100. }
  101. if (widthList.length !== header.length) {
  102. widthList.shift()
  103. }
  104. }
  105. }
  106. config.option = {
  107. ...config.option,
  108. data: dataList,
  109. header: header,
  110. columnWidth: [...widthList],
  111. align: [...alignList]
  112. }
  113. return config
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .light-theme{
  120. background-color: #FFFFFF;
  121. color: #000000;
  122. }
  123. .auto-theme{
  124. background-color: rgba(0,0,0,0);
  125. }
  126. .dark-theme{
  127. background-color:rgb(31, 31, 31) ;
  128. }
  129. .bs-design-wrap{
  130. position: relative;
  131. width: 100%;
  132. height: 100%;
  133. background-color: transparent;
  134. border-radius: 4px;
  135. box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1);
  136. box-sizing: border-box;
  137. }
  138. .title-box{
  139. height: 40px;
  140. padding: 10px 10px 0 0;
  141. box-sizing: border-box;
  142. .title {
  143. font-size: 14px;
  144. color: #333;
  145. font-weight: bold;
  146. border-left: 3px solid var(--bs-el-color-primary);
  147. padding-left: 16px;
  148. }
  149. .target-value{
  150. overflow-y: auto;
  151. height: 60px;
  152. font-weight: bold;
  153. width: 100%;
  154. font-size: 20px;
  155. color: #333;
  156. padding: 16px 0 0 22px;
  157. box-sizing: border-box;
  158. }
  159. }
  160. .el-icon-warning{
  161. color: #FFD600;
  162. }
  163. .title-hover{
  164. &:hover{
  165. cursor: move;
  166. }
  167. }
  168. /*滚动条样式*/
  169. /deep/::-webkit-scrollbar {
  170. width: 4px;
  171. border-radius: 4px;
  172. height: 4px;
  173. }
  174. /deep/::-webkit-scrollbar-thumb {
  175. background: #dddddd !important;
  176. border-radius: 10px;
  177. }
  178. </style>