index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="tabs-v">
  3. <template v-if="option.defaultValue && option.defaultValue.length">
  4. <scroll-view scroll-y="true" :style="option.defaultValue<5?'' :'height: 620rpx'">
  5. <div v-for="(item, i) in option.defaultValue" :key="i">
  6. <div class="app-title">
  7. <div class='name' v-for="(it, ii) in option.appColumnList" :key="ii" style="" @tap="jump(item)">
  8. <text v-if="option.showName" :style="{'font-weight': option.nameFontWeight?'bolder':'normal',
  9. 'font-size':option.nameFontSize+'px',color:option.nameFontColor}">
  10. {{it.fullName}}:</text>
  11. <text :style="{'font-weight': option.dataFontWeight?'bolder':'normal','font-size':option.dataFontSize+'px',
  12. color:option.dataFontColor}">{{item[it.filedName]}}</text>
  13. </div>
  14. <u-line v-if="i<option.defaultValue.length-1"></u-line>
  15. </div>
  16. </div>
  17. </scroll-view>
  18. </template>
  19. <view v-else class="notData-box u-flex-col">
  20. <view class="u-flex-col notData-inner">
  21. <image :src="icon" mode="" class="iconImg"></image>
  22. <text class="notData-inner-text">{{$t('common.noData')}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. getDataInterfaceRes
  30. } from '@/api/common'
  31. import resources from '@/libs/resources.js'
  32. export default {
  33. props: {
  34. config: {
  35. type: Object,
  36. required: true
  37. }
  38. },
  39. data() {
  40. return {
  41. icon: resources.message.nodata,
  42. option: {},
  43. propsApi: ""
  44. }
  45. },
  46. created() {
  47. this.init()
  48. },
  49. methods: {
  50. jump(item) {
  51. this.jnpf.solveAddressParam(item, this.config)
  52. this.jnpf.jumpLink(item.urlAddress)
  53. },
  54. init() {
  55. this.initData()
  56. if (this.config.refresh.autoRefresh) {
  57. setInterval(this.initData, this.config.refresh.autoRefreshTime * 60000)
  58. }
  59. },
  60. initData() {
  61. if (this.config.dataType === "dynamic") {
  62. if (!this.config.propsApi) return
  63. const query = {
  64. paramList: this.config.templateJson
  65. };
  66. getDataInterfaceRes(this.config.propsApi, query).then(res => {
  67. this.config.option.defaultValue = res.data || []
  68. this.handleAttrs()
  69. })
  70. } else {
  71. this.handleAttrs()
  72. }
  73. },
  74. handleAttrs() {
  75. this.option = this.config.option
  76. this.option.appColumnList.map((o) => {
  77. if (o.fullNameI18nCode) o.fullName = this.$t(o.fullNameI18nCode)
  78. })
  79. this.option.defaultValue = this.option.defaultValue.slice(0, this.option.appCount || 50)
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .tabs-v {
  86. padding: 16rpx 10rpx 10rpx;
  87. height: 100%;
  88. overflow: hidden;
  89. }
  90. .name {
  91. font-size: 28rpx;
  92. display: inline-block;
  93. width: calc(100% - 100rpx);
  94. white-space: nowrap;
  95. text-overflow: ellipsis;
  96. overflow: hidden;
  97. word-break: break-all;
  98. vertical-align: top;
  99. margin-bottom: 10rpx;
  100. }
  101. .app-title {
  102. padding: 8rpx 0px 10rpx 20px;
  103. }
  104. .notData-box {
  105. width: 100%;
  106. height: 100%;
  107. justify-content: center;
  108. align-items: center;
  109. .notData-inner {
  110. width: 280rpx;
  111. height: 308rpx;
  112. align-items: center;
  113. .iconImg {
  114. width: 100%;
  115. height: 100%;
  116. }
  117. .notData-inner-text {
  118. padding: 30rpx 0;
  119. color: #909399;
  120. }
  121. }
  122. }
  123. </style>