index.vue 4.6 KB

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