index.vue 4.3 KB

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