index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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: 'time'
  47. },
  48. ],
  49. list: [],
  50. total: 0,
  51. skip: 0,
  52. limit: 5,
  53. page: 1,
  54. showList: [],
  55. // 查看
  56. info: {},
  57. infoFields: [],
  58. // 禁止滚动穿透
  59. show: false
  60. }
  61. },
  62. onLoad: async function(e) {
  63. const that = this;
  64. that.$set(that, `id`, e && e.id || '');
  65. uni.showLoading({
  66. title: '正在加载请稍后',
  67. mask: true
  68. })
  69. await that.searchOther();
  70. that.searchToken();
  71. await that.search();
  72. },
  73. onPullDownRefresh: async function() {
  74. const that = this;
  75. await that.search();
  76. uni.stopPullDownRefresh();
  77. },
  78. methods: {
  79. // 禁止滚动穿透
  80. change(e) {
  81. const that = this;
  82. that.show = e.show
  83. },
  84. searchToken() {
  85. const that = this;
  86. try {
  87. const res = uni.getStorageSync('token');
  88. if (res) {
  89. const user = that.$jwt(res);
  90. that.$set(that, `user`, user);
  91. } else {
  92. uni.navigateTo({
  93. url: `/pages/login/index`
  94. })
  95. }
  96. } catch (e) {
  97. uni.showToast({
  98. title: err.errmsg,
  99. icon: 'error',
  100. duration: 2000
  101. });
  102. }
  103. },
  104. async search() {
  105. const that = this;
  106. if (that.id) {
  107. let info = {
  108. skip: that.skip,
  109. limit: that.limit,
  110. lab_id: that.id
  111. }
  112. const res = await that.$api(`/outcome`, 'GET', {
  113. ...info,
  114. ...that.searchInfo
  115. }, 'freeLabel')
  116. if (res.errcode == '0') {
  117. that.$set(that, `list`, res.data)
  118. that.$set(that, `total`, res.total)
  119. } else {
  120. uni.showToast({
  121. title: res.errmsg,
  122. });
  123. }
  124. }
  125. uni.hideLoading();
  126. },
  127. // 输入框
  128. toInput(e) {
  129. const that = this;
  130. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  131. else that.$set(that, `searchInfo`, {})
  132. that.search();
  133. },
  134. // 查看详情
  135. async toView(item) {
  136. const that = this;
  137. let infoFields = [{
  138. label: '成果名称',
  139. model: 'name'
  140. },
  141. {
  142. label: '重要成果',
  143. model: 'content',
  144. is_editor: true
  145. },
  146. {
  147. label: '是否公开',
  148. model: 'is_show',
  149. is_show: true
  150. },
  151. {
  152. label: '附件',
  153. model: 'file',
  154. is_image: true
  155. },
  156. ];
  157. let res = await that.$api(`/outcome/${item._id}`, 'GET', {}, 'freeLabel')
  158. if (res.errcode == '0') {
  159. let info = res.data;
  160. that.$set(that, `info`, info)
  161. that.$set(that, `infoFields`, infoFields)
  162. that.$refs.popup.open()
  163. }
  164. },
  165. // 关闭弹框
  166. toClose() {
  167. const that = this;
  168. that.$refs.popup.close();
  169. },
  170. // 分页
  171. toPage(data) {
  172. const that = this;
  173. uni.showLoading({
  174. title: '加载中',
  175. mask: true
  176. })
  177. that.$set(that, `page`, data.page);
  178. that.$set(that, `skip`, data.skip)
  179. that.search();
  180. },
  181. async searchOther() {
  182. const that = this;
  183. let res;
  184. //是否启用
  185. res = await that.$api('/dictData', 'GET', {
  186. dict_type: 'info_show',
  187. status: '0'
  188. }, 'jcyjdtglpt')
  189. if (res.errcode == '0') that.$set(that, `showList`, res.data);
  190. },
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .main {
  196. display: flex;
  197. flex-direction: column;
  198. width: 100vw;
  199. height: 100vh;
  200. .one {
  201. padding: 2vw;
  202. input {
  203. padding: 2vw;
  204. background-color: var(--f1Color);
  205. font-size: var(--font14Size);
  206. border-radius: 5px;
  207. }
  208. }
  209. .two {
  210. background-color: var(--f9Color);
  211. }
  212. .uni-popup {
  213. z-index: 9999 !important;
  214. }
  215. .popup {
  216. display: flex;
  217. flex-direction: column;
  218. width: 90vw;
  219. height: 40vh;
  220. background-color: var(--f9Color);
  221. .close {
  222. display: flex;
  223. justify-content: space-between;
  224. padding: 2vw;
  225. text:first-child {
  226. font-size: var(--font16Size);
  227. font-weight: bold;
  228. }
  229. }
  230. .info_1 {
  231. position: relative;
  232. display: flex;
  233. flex-direction: column;
  234. padding: 2vw;
  235. }
  236. }
  237. }
  238. </style>