index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 =='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 'data-room-ui/js/mixins/refreshComponent'
  18. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  19. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  20. import linkageMixins from 'data-room-ui/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. this.linkage(row)
  55. },
  56. dataFormatting (config, data) {
  57. const header = []
  58. const dataList = []
  59. const alignList = []
  60. const widthList = []
  61. if (config.customize.columnConfig.length === 0) {
  62. const key = []
  63. for (const i in data.columnData) {
  64. header.push(data.columnData[i].remark)
  65. key.push(i)
  66. }
  67. data.data.forEach((item) => {
  68. const arr = []
  69. header.forEach((x, index) => {
  70. arr.push(item[key[index]])
  71. })
  72. dataList.push(arr)
  73. })
  74. } else {
  75. const key = []
  76. config.customize.columnConfig.forEach(item => {
  77. header.push(item.name)
  78. key.push(item.code)
  79. alignList.push(item.align)
  80. widthList.push(item.width)
  81. })
  82. data.data.forEach((item) => {
  83. const arr = []
  84. header.forEach((x, index) => {
  85. arr.push(item[key[index]])
  86. })
  87. dataList.push(arr)
  88. })
  89. if (config.customize.index) {
  90. if (alignList.length === header.length) {
  91. alignList.unshift('center')
  92. }
  93. if (widthList.length === header.length) {
  94. widthList.unshift('100')
  95. }
  96. } else {
  97. if (alignList.length !== header.length) {
  98. alignList.shift()
  99. }
  100. if (widthList.length !== header.length) {
  101. widthList.shift()
  102. }
  103. }
  104. }
  105. config.option = {
  106. ...config.option,
  107. data: dataList,
  108. header: header,
  109. columnWidth: [...widthList],
  110. align: [...alignList]
  111. }
  112. return config
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .light-theme{
  119. background-color: #FFFFFF;
  120. color: #000000;
  121. }
  122. .auto-theme{
  123. background-color: rgba(0,0,0,0);
  124. }
  125. .dark-theme{
  126. background-color:rgb(31, 31, 31) ;
  127. }
  128. .bs-design-wrap{
  129. position: relative;
  130. width: 100%;
  131. height: 100%;
  132. background-color: transparent;
  133. border-radius: 4px;
  134. box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1);
  135. box-sizing: border-box;
  136. }
  137. .title-box{
  138. height: 40px;
  139. padding: 10px 10px 0 0;
  140. box-sizing: border-box;
  141. .title {
  142. font-size: 14px;
  143. color: #333;
  144. font-weight: bold;
  145. border-left: 3px solid var(--bs-el-color-primary);
  146. padding-left: 16px;
  147. }
  148. .target-value{
  149. overflow-y: auto;
  150. height: 60px;
  151. font-weight: bold;
  152. width: 100%;
  153. font-size: 20px;
  154. color: #333;
  155. padding: 16px 0 0 22px;
  156. box-sizing: border-box;
  157. }
  158. }
  159. .el-icon-warning{
  160. color: #FFD600;
  161. }
  162. .title-hover{
  163. &:hover{
  164. cursor: move;
  165. }
  166. }
  167. /*滚动条样式*/
  168. ::v-deep ::-webkit-scrollbar {
  169. width: 4px;
  170. border-radius: 4px;
  171. height: 4px;
  172. }
  173. ::v-deep ::-webkit-scrollbar-thumb {
  174. background: #dddddd !important;
  175. border-radius: 10px;
  176. }
  177. </style>