index.vue 4.5 KB

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