index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <view class="one_1"></view>
  7. <uni-segmented-control :current="current" :values="list" @clickItem="onClickItem" styleType="text"
  8. activeColor="#dd524d"></uni-segmented-control>
  9. <view class="one_2">
  10. <view v-show="current === 0">
  11. <match ref="childRef0" :id="id" :typeList="typeList" :numberList="numberList"
  12. :durationList='durationList' :openList="openList"></match>
  13. </view>
  14. <view v-show="current === 1">
  15. <activity ref="childRef1" :id="id" :typeList="matchList" :durationList='durationList'
  16. :openList="openList" :type="current"></activity>
  17. </view>
  18. <view v-show="current === 2">
  19. <activity ref="childRef2" :id="id" :activityList="activityList" :durationList='durationList'
  20. :openList="openList" :type="current"></activity>
  21. </view>
  22. </view>
  23. </view>
  24. </scroll-view>
  25. </view>
  26. <view class="two">
  27. <view class="left">
  28. <view class="left_1">
  29. <uni-icons @tap="toAdd" custom-prefix="iconfont" type="icon-caogao04" size="20"
  30. color="#696969"></uni-icons>
  31. <text>保存草稿</text>
  32. </view>
  33. <view class="left_1">
  34. <uni-icons @tap="toCopy" custom-prefix="iconfont" type="icon-icon_cz" size="20"
  35. color="#696969"></uni-icons>
  36. <text>复用</text>
  37. </view>
  38. </view>
  39. <view class="right">
  40. <button type="warn" size="mini" @tap="onSubmit">完成</button>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script setup lang="ts">
  46. import { getCurrentInstance, ref } from 'vue';
  47. //该依赖已内置不需要单独安装
  48. import { onLoad } from "@dcloudio/uni-app";
  49. import activity from './components/activity.vue';
  50. import match from './components/match.vue';
  51. // 请求接口
  52. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  53. // 基本信息
  54. const config = ref({});
  55. // 详情信息id
  56. const id = ref('');
  57. const list = ref(['友谊赛', '训练', '活动']);
  58. const current = ref(0);
  59. // 字典表
  60. const typeList = ref([]);
  61. const numberList = ref([]);
  62. const matchList = ref([]);
  63. const activityList = ref([]);
  64. const durationList = ref([]);
  65. const openList = ref([]);
  66. const childRef0 = ref<any>();
  67. const childRef1 = ref<any>();
  68. const childRef2 = ref<any>()
  69. onLoad(async (options) => {
  70. // 球队id
  71. id.value = options && options.id
  72. await searchConfig();
  73. await searchOther();
  74. await search();
  75. })
  76. // config信息
  77. const searchConfig = async () => {
  78. config.value = uni.getStorageSync('config');
  79. };
  80. // 查询其他信息
  81. const searchOther = async () => {
  82. let res;
  83. // 比赛类型
  84. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_user_type', status: '0' });
  85. if (res.code === 200 && res.total > 0) typeList.value = res.rows
  86. // 比赛人数
  87. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_match_number', status: '0' });
  88. if (res.code === 200 && res.total > 0) numberList.value = res.rows
  89. // 训练类型
  90. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_train_type', status: '0' });
  91. if (res.code === 200 && res.total > 0) matchList.value = res.rows
  92. // 活动类型
  93. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_activity_type', status: '0' });
  94. if (res.code === 200 && res.total > 0) activityList.value = res.rows
  95. // 时长
  96. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_match_duration', status: '0' });
  97. if (res.code === 200 && res.total > 0) durationList.value = res.rows
  98. // 是否公开
  99. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_yes_no', status: '0' });
  100. if (res.code === 200 && res.total > 0) openList.value = res.rows
  101. };
  102. // 查询
  103. const search = async () => {
  104. if (id.value) { }
  105. };
  106. // 点击分页器
  107. const onClickItem = (e) => {
  108. if (current.value !== e.currentIndex) current.value = e.currentIndex
  109. };
  110. // 保存草稿
  111. const toAdd = async () => {
  112. console.log('保存草稿');
  113. };
  114. // 复用
  115. const toCopy = async () => {
  116. console.log('复用');
  117. };
  118. // 保存
  119. const onSubmit = async () => {
  120. if (current.value == 0) childRef0.value.formSubmit();
  121. else if (current.value == 1) childRef1.value.formSubmit();
  122. else childRef2.value.formSubmit();
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .content {
  127. display: flex;
  128. flex-direction: column;
  129. width: 100vw;
  130. height: 100vh;
  131. .one {
  132. position: relative;
  133. flex-grow: 1;
  134. .one_1 {
  135. height: 20vw;
  136. background-color: var(--f12Color);
  137. }
  138. }
  139. .two {
  140. display: flex;
  141. justify-content: space-between;
  142. align-items: center;
  143. padding: 2vw;
  144. border-top: 1px solid var(--footColor);
  145. .left {
  146. display: flex;
  147. .left_1 {
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. padding: 0 2vw;
  152. font-size: var(--font14Size);
  153. color: var(--f69Color);
  154. text {
  155. margin: 2px 0 0 0;
  156. }
  157. }
  158. }
  159. .right {
  160. button {
  161. width: 60vw;
  162. font-size: var(--font16Size);
  163. }
  164. }
  165. }
  166. }
  167. .scroll-view {
  168. position: absolute;
  169. top: 0;
  170. left: 0;
  171. right: 0;
  172. bottom: 0;
  173. .list-scroll-view {
  174. display: flex;
  175. flex-direction: column;
  176. }
  177. }
  178. </style>