index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="HTodo-v" :key="key">
  3. <view class="HTodo-box u-flex">
  4. <view class="HTodo-list u-flex" :style="{'flex-wrap':option.appStyleType==1?'nowrap':'wrap'}">
  5. <view class="u-flex-col HTodo-list-item" v-for="(item,index) in option.appDefaultValue" :key="index"
  6. @click="jump(item)" :style="option.style">
  7. <view class=" u-m-b-8">
  8. <view :class="item.icon" class="icon"
  9. :style="{'background-color':item.iconColor||item.iconBgColor || '#008cff'}"></view>
  10. </view>
  11. <view class="u-line-1 title"
  12. :style="{'font-size':option.labelFontSize,'color':option.labelFontColor,'font-weight':option.labelFontWeight?700:400}">
  13. {{item.fullName}}
  14. </view>
  15. <view class="u-line-1 title"
  16. :style="{'font-size':option.valueFontSize,'color':option.valueFontColor,'font-weight':option.valueFontWeight?700:400}">
  17. {{item.num+' '}}
  18. <text
  19. :style="{'font-size':option.unitFontSize,'color':option.unitFontColor,'font-weight':option.unitFontWeight?700:400}">{{item.unit}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. getDataInterfaceRes
  29. } from '@/api/common'
  30. export default {
  31. props: {
  32. config: {
  33. type: Object,
  34. default: () => {}
  35. }
  36. },
  37. data() {
  38. return {
  39. option: {},
  40. propsApi: '',
  41. key: +new Date(),
  42. }
  43. },
  44. created() {
  45. this.init()
  46. uni.$off('proRefresh')
  47. uni.$on('proRefresh', () => {
  48. this.initData()
  49. })
  50. },
  51. methods: {
  52. init() {
  53. this.initData()
  54. if (!this.config.allRefresh.autoRefresh && this.config.refresh.autoRefresh) {
  55. setInterval(this.initData, this.config.refresh.autoRefreshTime * 60000)
  56. }
  57. },
  58. initData() {
  59. this.option = JSON.parse(JSON.stringify(this.config.option))
  60. this.option.appDefaultValue.map((o) => {
  61. if (o.fullNameI18nCode) o.fullName = this.$t(o.fullNameI18nCode)
  62. })
  63. let style;
  64. style = {
  65. 'width': '238rpx'
  66. }
  67. if (this.option.appStyleType == 2) {
  68. style.width = 100 / this.option.appRowNumber + '%'
  69. if (this.option.appShowBorder) {
  70. style['border-right'] = '2rpx solid #f0f2f6'
  71. style['border-bottom'] = '2rpx solid #f0f2f6'
  72. }
  73. }
  74. this.option.style = style
  75. this.option.appDefaultValue = this.option.appDefaultValue.filter((o) => !o.noShow)
  76. if (this.config.dataType == 'dynamic') {
  77. for (let i = 0; i < this.option.appDefaultValue.length; i++) {
  78. this.option.appDefaultValue[i].num = '';
  79. }
  80. if (!this.config.propsApi) return;
  81. let list = this.option.appDefaultValue || []
  82. const query = {
  83. paramList: this.config.templateJson
  84. };
  85. getDataInterfaceRes(this.config.propsApi, query).then(res => {
  86. for (let i = 0; i < this.option.appDefaultValue.length; i++) {
  87. const list = this.option.appDefaultValue[i]
  88. list.num = list.field ? res.data[list.field] : '';
  89. }
  90. this.handleAttrs()
  91. })
  92. } else {
  93. this.handleAttrs()
  94. }
  95. },
  96. handleAttrs() {
  97. this.option.valueFontSize = this.option.valueFontSize * 2 + 'rpx'
  98. this.option.unitFontSize = this.option.unitFontSize * 2 + 'rpx'
  99. this.key = +new Date()
  100. },
  101. jump(item) {
  102. this.jnpf.solveAddressParam(item, this.config)
  103. if (this.config.platform === 'mp') return
  104. let url;
  105. if (item.linkType == 1 && item.type == 3) {
  106. let data = {
  107. id: item.moduleId,
  108. moduleId: item.moduleId,
  109. urlAddress: item.urlAddress,
  110. ...JSON.parse(item.propertyJson)
  111. }
  112. url = '/pages/apply/dynamicModel/index?config=' +
  113. this.jnpf.base64.encode(JSON.stringify(data))
  114. } else if (item.linkType == 1 && item.type == 2) {
  115. url = item.urlAddress
  116. } else if (item.linkType == 1 && item.type == 8) {
  117. let propertyJson = JSON.parse(item.propertyJson)
  118. uni.navigateTo({
  119. url: "/pages/portal/scanPortal/index?id=" + propertyJson.moduleId + "&protalType=1" +
  120. "&fullName=" + item.fullName,
  121. fail: (err) => {},
  122. });
  123. return
  124. } else {
  125. if (!item.urlAddress) return
  126. url = '/pages/apply/externalLink/index?url=' + encodeURIComponent(item.urlAddress) +
  127. '&fullName= ' + item.fullName
  128. }
  129. uni.navigateTo({
  130. url: url,
  131. fail: (err) => {
  132. // this.$u.toast("暂无此页面")
  133. }
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .HTodo-v {
  141. width: 100%;
  142. height: 100%;
  143. .HTodo-box {
  144. width: 100%;
  145. overflow-x: scroll;
  146. .HTodo-list {
  147. .HTodo-list-item {
  148. align-items: center;
  149. padding: 16rpx 20rpx;
  150. .title {
  151. width: 100%;
  152. text-align: center;
  153. }
  154. .icon {
  155. width: 90rpx;
  156. height: 90rpx;
  157. font-size: 60rpx;
  158. color: #fff;
  159. text-align: center;
  160. line-height: 90rpx;
  161. border-radius: 16rpx;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. </style>