index.vue 4.4 KB

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