index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <!-- 禁止滚动穿透 -->
  3. <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta>
  4. <view class="main">
  5. <view class="one">
  6. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索活动名称">
  7. </view>
  8. <view class="two">
  9. <list name="list" :list="list" :fields="fields" :page="page" :total="total" :pageSize="limit"
  10. @toPage="toPage" @toView="toView">
  11. </list>
  12. </view>
  13. <uni-popup ref="popup" background-color="#fff" type="center" :is-mask-click="false" @change="change">
  14. <view class="popup">
  15. <view class="close">
  16. <text>信息管理</text>
  17. <uni-icons @tap="toClose" type="close" size="20"></uni-icons>
  18. </view>
  19. <view class="info_1">
  20. <info name="info" :data="info" :infoFields="infoFields" :showList="showList"></info>
  21. </view>
  22. </view>
  23. </uni-popup>
  24. </view>
  25. </template>
  26. <script>
  27. import list from '@/components/list/index.vue';
  28. import info from '@/components/view/index.vue';
  29. export default {
  30. components: {
  31. list,
  32. info
  33. },
  34. data() {
  35. return {
  36. id: '',
  37. user: {},
  38. searchInfo: {},
  39. fields: [{
  40. label: '活动名称',
  41. model: 'name',
  42. is_name: true
  43. },
  44. {
  45. label: '年度',
  46. model: 'year'
  47. },
  48. {
  49. label: '组织者',
  50. model: 'usernames'
  51. },
  52. {
  53. label: '充当角色',
  54. model: 'role'
  55. },
  56. {
  57. label: '人数',
  58. model: 'numbers'
  59. },
  60. {
  61. label: '宣传指导',
  62. model: 'propaganda'
  63. },
  64. ],
  65. list: [],
  66. total: 0,
  67. skip: 0,
  68. limit: 5,
  69. page: 1,
  70. showList: [],
  71. // 查看
  72. info: {},
  73. infoFields: [],
  74. // 禁止滚动穿透
  75. show: false
  76. }
  77. },
  78. onLoad: async function(e) {
  79. const that = this;
  80. that.$set(that, `id`, e && e.id || '');
  81. uni.showLoading({
  82. title: '正在加载请稍后',
  83. mask: true
  84. })
  85. await that.searchOther();
  86. that.searchToken();
  87. await that.search();
  88. },
  89. onPullDownRefresh: async function() {
  90. const that = this;
  91. await that.search();
  92. uni.stopPullDownRefresh();
  93. },
  94. methods: {
  95. // 禁止滚动穿透
  96. change(e) {
  97. const that = this;
  98. that.show = e.show
  99. },
  100. searchToken() {
  101. const that = this;
  102. try {
  103. const res = uni.getStorageSync('token');
  104. if (res) {
  105. const user = that.$jwt(res);
  106. that.$set(that, `user`, user);
  107. } else {
  108. uni.navigateTo({
  109. url: `/pages/login/index`
  110. })
  111. }
  112. } catch (e) {
  113. uni.showToast({
  114. title: err.errmsg,
  115. icon: 'error',
  116. duration: 2000
  117. });
  118. }
  119. },
  120. async search() {
  121. const that = this;
  122. if (that.id) {
  123. let info = {
  124. skip: that.skip,
  125. limit: that.limit,
  126. lab_id: that.id
  127. }
  128. const res = await that.$api(`/sjactivity`, 'GET', {
  129. ...info,
  130. ...that.searchInfo
  131. }, 'freeLabel')
  132. if (res.errcode == '0') {
  133. that.$set(that, `list`, res.data)
  134. that.$set(that, `total`, res.total)
  135. } else {
  136. uni.showToast({
  137. title: res.errmsg,
  138. });
  139. }
  140. }
  141. uni.hideLoading();
  142. },
  143. // 输入框
  144. toInput(e) {
  145. const that = this;
  146. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  147. else that.$set(that, `searchInfo`, {})
  148. that.search();
  149. },
  150. // 查看详情
  151. async toView(item) {
  152. const that = this;
  153. let infoFields = [{
  154. label: '年度',
  155. model: 'year'
  156. },
  157. {
  158. label: '活动名称',
  159. model: 'name'
  160. },
  161. {
  162. label: '组织者',
  163. model: 'usernames'
  164. },
  165. {
  166. label: '充当角色',
  167. model: 'role'
  168. },
  169. {
  170. label: '人数',
  171. model: 'numbers'
  172. },
  173. {
  174. label: '宣传指导',
  175. model: 'propaganda'
  176. },
  177. {
  178. label: '活动简介',
  179. model: 'content'
  180. },
  181. {
  182. label: '是否公开',
  183. model: 'is_show',
  184. is_show: true
  185. },
  186. {
  187. label: '附件',
  188. model: 'file',
  189. is_image: true
  190. },
  191. ];
  192. let res = await that.$api(`/sjactivity/${item._id}`, 'GET', {}, 'freeLabel')
  193. if (res.errcode == '0') {
  194. let info = res.data;
  195. that.$set(that, `info`, info)
  196. that.$set(that, `infoFields`, infoFields)
  197. that.$refs.popup.open()
  198. }
  199. },
  200. // 关闭弹框
  201. toClose() {
  202. const that = this;
  203. that.$refs.popup.close();
  204. },
  205. // 分页
  206. toPage(data) {
  207. const that = this;
  208. uni.showLoading({
  209. title: '加载中',
  210. mask: true
  211. })
  212. that.$set(that, `page`, data.page);
  213. that.$set(that, `skip`, data.skip)
  214. that.search();
  215. },
  216. async searchOther() {
  217. const that = this;
  218. let res;
  219. //是否启用
  220. res = await that.$api('/dictData', 'GET', {
  221. dict_type: 'info_show',
  222. status: '0'
  223. }, 'jcyjdtglpt')
  224. if (res.errcode == '0') that.$set(that, `showList`, res.data);
  225. },
  226. }
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. .main {
  231. display: flex;
  232. flex-direction: column;
  233. width: 100vw;
  234. height: 100vh;
  235. .one {
  236. padding: 2vw;
  237. input {
  238. padding: 2vw;
  239. background-color: var(--f1Color);
  240. font-size: var(--font14Size);
  241. border-radius: 5px;
  242. }
  243. }
  244. .two {
  245. background-color: var(--f9Color);
  246. }
  247. .uni-popup {
  248. z-index: 9999 !important;
  249. }
  250. .popup {
  251. display: flex;
  252. flex-direction: column;
  253. width: 90vw;
  254. height: 40vh;
  255. background-color: var(--f9Color);
  256. .close {
  257. display: flex;
  258. justify-content: space-between;
  259. padding: 2vw;
  260. text:first-child {
  261. font-size: var(--font16Size);
  262. font-weight: bold;
  263. }
  264. }
  265. .info_1 {
  266. position: relative;
  267. display: flex;
  268. flex-direction: column;
  269. padding: 2vw;
  270. }
  271. }
  272. }
  273. </style>