index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view>
  3. <!-- 卡片 -->
  4. <template v-if="activeData.show && activeData.jnpfKey === 'card'">
  5. <view class="u-m-b-20">
  6. <HCard :cardData="activeData">
  7. <template #content>
  8. <view class="card-inner u-p-l-8 u-p-r-8 u-p-t-8">
  9. <Item v-for="(child, index) in activeData.children" :item="child" :key="index" />
  10. </view>
  11. </template>
  12. </HCard>
  13. </view>
  14. </template>
  15. <!-- 排行榜 -->
  16. <template v-if="activeData.show && activeData.jnpfKey === 'rankList'">
  17. <view class="u-m-b-20">
  18. <HCard :cardData="activeData">
  19. <template #content>
  20. <HRankList :config="activeData"></HRankList>
  21. </template>
  22. </HCard>
  23. </view>
  24. </template>
  25. <!-- 文本 -->
  26. <template v-if="activeData.show && activeData.jnpfKey === 'text'">
  27. <view class="u-m-b-20">
  28. <HCard :cardData="activeData">
  29. <template #content>
  30. <HText :config="activeData"></HText>
  31. </template>
  32. </HCard>
  33. </view>
  34. </template>
  35. <!-- 图片 -->
  36. <template v-if="activeData.show && activeData.jnpfKey === 'image'">
  37. <view class="u-m-b-20">
  38. <HCard :cardData="activeData">
  39. <template #content>
  40. <HImage :config="activeData"></HImage>
  41. </template>
  42. </HCard>
  43. </view>
  44. </template>
  45. <!-- 轮播图 -->
  46. <template v-if="activeData.show && activeData.jnpfKey === 'carousel'">
  47. <view class="u-m-b-20">
  48. <HCard :cardData="activeData">
  49. <template #content>
  50. <HCarousel :config="activeData"></HCarousel>
  51. </template>
  52. </HCard>
  53. </view>
  54. </template>
  55. <!-- 视频 -->
  56. <template v-if="activeData.show && activeData.jnpfKey === 'video'">
  57. <view class="u-m-b-20">
  58. <HCard :cardData="activeData">
  59. <template #content>
  60. <HVideo :config="activeData"></HVideo>
  61. </template>
  62. </HCard>
  63. </view>
  64. </template>
  65. <!-- 图表 -->
  66. <template v-if="activeData.show && chartList.includes(activeData.jnpfKey)">
  67. <view class="u-m-b-20">
  68. <HCard :cardData="activeData">
  69. <template #content>
  70. <HCharts :config="activeData" :key="key"></HCharts>
  71. </template>
  72. </HCard>
  73. </view>
  74. </template>
  75. <!-- 自定义echarts -->
  76. <template v-if="activeData.show && activeData.jnpfKey === 'customEcharts'">
  77. <view class="u-m-b-20">
  78. <HCard :cardData="activeData">
  79. <template #content>
  80. <HCustomeCharts :config="activeData" :key="key"></HCustomeCharts>
  81. </template>
  82. </HCard>
  83. </view>
  84. </template>
  85. <!-- 我的待办 -->
  86. <template v-if="activeData.show && activeData.jnpfKey === 'todo'">
  87. <view class="u-m-b-20">
  88. <HCard :cardData="activeData">
  89. <template #content>
  90. <HTodo :config="activeData" :key="key"></HTodo>
  91. </template>
  92. </HCard>
  93. </view>
  94. </template>
  95. <!-- 常用功能 -->
  96. <template v-if="activeData.show && activeData.jnpfKey === 'dataBoard'">
  97. <view class="u-m-b-20">
  98. <HCard :cardData="activeData">
  99. <template #content>
  100. <HDataBoard :config="activeData" :key="key"></HDataBoard>
  101. </template>
  102. </HCard>
  103. </view>
  104. </template>
  105. <!-- 数据面板 -->
  106. <template v-if="activeData.show && activeData.jnpfKey === 'commonFunc'">
  107. <view class="u-m-b-20">
  108. <HCard :cardData="activeData">
  109. <template #content>
  110. <HCommonFunc :config="activeData" :key="key"></HCommonFunc>
  111. </template>
  112. </HCard>
  113. </view>
  114. </template>
  115. <!-- 时间轴 -->
  116. <template v-if="activeData.show && activeData.jnpfKey === 'timeAxis'">
  117. <view class="u-m-b-20">
  118. <HCard :cardData="activeData">
  119. <template #content>
  120. <HTimeAxis :config="activeData"></HTimeAxis>
  121. </template>
  122. </HCard>
  123. </view>
  124. </template>
  125. <!-- 表格 -->
  126. <template v-if="activeData.show && activeData.jnpfKey === 'tableList'">
  127. <view class="u-m-b-20">
  128. <HCard :cardData="activeData">
  129. <template #content>
  130. <HTable :config="activeData"></HTable>
  131. </template>
  132. </HCard>
  133. </view>
  134. </template>
  135. <!-- 待办事项 -->
  136. <template v-if="activeData.show && activeData.jnpfKey === 'todoList'">
  137. <view class="u-m-b-20">
  138. <HCard :cardData="activeData">
  139. <template #content>
  140. <HTodoList :config="activeData"></HTodoList>
  141. </template>
  142. </HCard>
  143. </view>
  144. </template>
  145. <!-- 未读邮件 -->
  146. <template v-if="activeData.show && activeData.jnpfKey === 'email'">
  147. <view class="u-m-b-20">
  148. <HCard :cardData="activeData">
  149. <template #content>
  150. <HEmail :config="activeData"></HEmail>
  151. </template>
  152. </HCard>
  153. </view>
  154. </template>
  155. <!-- 公告通知 -->
  156. <template v-if="activeData.show && activeData.jnpfKey === 'notice'">
  157. <view class="u-m-b-20">
  158. <HCard :cardData="activeData">
  159. <template #content>
  160. <HNotice :config="activeData"></HNotice>
  161. </template>
  162. </HCard>
  163. </view>
  164. </template>
  165. <!-- 标签 -->
  166. <template v-if="activeData.show && activeData.jnpfKey === 'tab'">
  167. <view class="u-m-b-20" style="background-color: #ffffff;">
  168. <u-tabs :list="activeData.children" name="title" :is-scroll="activeData.children.length>3"
  169. v-model="tabCurrent" @change="onTabChange" :show-bar="!!activeData.type" :class="tabsClass"
  170. :inactive-color="activeData.type==='border-card'?' #9ea1a6':'#303133'"
  171. :active-item-style='activeItemStyle' :bg-color="activeData.type==='border-card'?'#f5f7fa':'#fff'">
  172. </u-tabs>
  173. <view v-for="(item,i) in activeData.children" :key='i' class="tab-inner u-p-8">
  174. <view v-show="i == tabCurrent">
  175. <Item v-for="(child, index) in item.children" :item="child" :key="key" />
  176. </view>
  177. </view>
  178. </view>
  179. </template>
  180. </view>
  181. </template>
  182. <script>
  183. import HCard from './HCard'
  184. import HDataBoard from './HDataBoard'
  185. import HTable from './HTable'
  186. import HNotice from './HNotice'
  187. import HEmail from './HEmail'
  188. import HTodoList from './HTodoList'
  189. import HCharts from './HCharts'
  190. import HCustomeCharts from './HCustomeCharts'
  191. import HRankList from './HRankList'
  192. import HImage from './HImage'
  193. import HCarousel from './HCarousel'
  194. import HText from './HText'
  195. import HVideo from './HVideo'
  196. import HTodo from './HTodo'
  197. import HCommonFunc from './HCommonFunc'
  198. import HTimeAxis from './HTimeAxis'
  199. const chartList = ['barChart', 'lineChart', 'pieChart', 'radarChart', 'mapChart'];
  200. export default {
  201. name: 'Item',
  202. props: {
  203. item: {
  204. type: Object,
  205. default: () => ({})
  206. }
  207. },
  208. components: {
  209. HCard,
  210. HDataBoard,
  211. HTable,
  212. HNotice,
  213. HEmail,
  214. HTodoList,
  215. HCharts,
  216. HRankList,
  217. HImage,
  218. HCarousel,
  219. HCustomeCharts,
  220. HText,
  221. HVideo,
  222. HTodo,
  223. HCommonFunc,
  224. HTimeAxis
  225. },
  226. data() {
  227. return {
  228. cardData: {},
  229. current: 0,
  230. tabCurrent: 0,
  231. key: +new Date(),
  232. tabsClass: '',
  233. activeItemStyle: {
  234. 'background-color': '#fff',
  235. },
  236. chartList
  237. }
  238. },
  239. computed: {
  240. activeData() {
  241. const activeData = this.item;
  242. if (activeData.titleI18nCode) activeData.title = this.$t(activeData.titleI18nCode, activeData.title);
  243. if (activeData.card.cardRightBtnI18nCode) activeData.card.cardRightBtn =
  244. this.$t(activeData.card.cardRightBtnI18nCode, activeData.card.cardRightBtn);
  245. if (activeData.jnpfKey === 'tab') {
  246. for (let i = 0; i < activeData.children.length; i++) {
  247. if (activeData.children[i].titleI18nCode) activeData.children[i].title =
  248. this.$t(activeData.children[i].titleI18nCode, activeData.children[i].title);
  249. }
  250. }
  251. if (['todo', 'commonFunc', 'dataBoard'].includes(activeData.jnpfKey)) {
  252. for (let i = 0; i < activeData.option.defaultValue.length; i++) {
  253. const e = activeData.option.defaultValue[i];
  254. if (e.fullNameI18nCode) e.fullName = this.$t(e.fullNameI18nCode, e.fullName);
  255. }
  256. }
  257. if (activeData.jnpfKey === 'carousel') {
  258. for (let i = 0; i < activeData.option.defaultValue.length; i++) {
  259. const e = activeData.option.defaultValue[i];
  260. if (e.textDefaultValueI18nCode) {
  261. e.textDefaultValue = this.$t(e.textDefaultValueI18nCode, e.textDefaultValue);
  262. }
  263. }
  264. }
  265. if (activeData.jnpfKey === 'text' && activeData.dataType === 'static' && activeData.option
  266. .defaultValueI18nCode) {
  267. activeData.option.defaultValue =
  268. this.$t(activeData.option.defaultValueI18nCode, activeData.option.defaultValue);
  269. }
  270. if (activeData.jnpfKey === 'image' && activeData.option.textDefaultValueI18nCode) {
  271. activeData.option.textDefaultValue =
  272. this.$t(activeData.option.textDefaultValueI18nCode, activeData.option.textDefaultValue);
  273. }
  274. if (['tableList', 'notice'].includes(activeData.jnpfKey)) {
  275. for (let i = 0; i < activeData.option.columnData.length; i++) {
  276. const e = activeData.option.columnData[i];
  277. if (e.fullNameI18nCode) e.fullName = this.$t(e.fullNameI18nCode, e.fullName);
  278. }
  279. }
  280. if (activeData.jnpfKey === 'rankList') {
  281. for (let i = 0; i < activeData.option.columnOptions.length; i++) {
  282. const e = activeData.option.columnOptions[i];
  283. if (e.labelI18nCode) e.label = this.$t(e.labelI18nCode, e.label);
  284. }
  285. }
  286. if (chartList.includes(activeData.jnpfKey)) {
  287. if (activeData.option.titleTextI18nCode) activeData.option.titleText =
  288. this.$t(activeData.option.titleTextI18nCode, activeData.option.titleText);
  289. if (activeData.option.titleSubtextI18nCode) activeData.option.titleSubtext =
  290. this.$t(activeData.option.titleSubtextI18nCode, activeData.option.titleSubtext);
  291. if (activeData.option.xAxisNameI18nCode) activeData.option.xAxisName =
  292. this.$t(activeData.option.xAxisNameI18nCode, activeData.option.xAxisName);
  293. if (activeData.option.yAxisNameI18nCode) activeData.option.yAxisName =
  294. this.$t(activeData.option.yAxisNameI18nCode, activeData.option.yAxisName);
  295. }
  296. return activeData
  297. }
  298. },
  299. created() {
  300. if (this.item.jnpfKey === 'tab') {
  301. const list = this.item.children
  302. for (let i = 0; i < list.length; i++) {
  303. if (this.item.active == list[i].name) {
  304. this.tabCurrent = i
  305. break
  306. }
  307. }
  308. if (this.item.type === "border-card" || this.item.type === "card") {
  309. this.tabsClass = 'htabs'
  310. }
  311. }
  312. },
  313. methods: {
  314. change(index) {
  315. this.current = index;
  316. },
  317. onTabChange(index) {
  318. if (this.tabCurrent === index) return
  319. this.tabCurrent = index;
  320. this.key = +new Date()
  321. },
  322. }
  323. }
  324. </script>
  325. <style lang="scss">
  326. </style>