index.vue 4.4 KB

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