index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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: 'type'
  51. },
  52. {
  53. label: '获奖等级',
  54. model: 'level'
  55. },
  56. {
  57. label: '成果编号',
  58. model: 'resulnumber'
  59. },
  60. {
  61. label: '获奖人',
  62. model: 'user_id'
  63. },
  64. {
  65. label: '研究方向',
  66. model: 'direction'
  67. },
  68. {
  69. label: '获奖时间',
  70. model: 'time'
  71. },
  72. ],
  73. list: [],
  74. total: 0,
  75. skip: 0,
  76. limit: 5,
  77. page: 1,
  78. // 字典表
  79. userList: [],
  80. directionList: [],
  81. typeList: [],
  82. levelList: [],
  83. showList: [],
  84. // 查看
  85. info: {},
  86. infoFields: [],
  87. // 禁止滚动穿透
  88. show: false
  89. }
  90. },
  91. onLoad: async function(e) {
  92. const that = this;
  93. that.$set(that, `id`, e && e.id || '');
  94. uni.showLoading({
  95. title: '正在加载请稍后',
  96. mask: true
  97. })
  98. await that.searchOther();
  99. that.searchToken();
  100. await that.search();
  101. },
  102. onPullDownRefresh: async function() {
  103. const that = this;
  104. await that.search();
  105. uni.stopPullDownRefresh();
  106. },
  107. methods: {
  108. // 禁止滚动穿透
  109. change(e) {
  110. const that = this;
  111. that.show = e.show
  112. },
  113. searchToken() {
  114. const that = this;
  115. try {
  116. const res = uni.getStorageSync('token');
  117. if (res) {
  118. const user = that.$jwt(res);
  119. that.$set(that, `user`, user);
  120. } else {
  121. uni.navigateTo({
  122. url: `/pages/login/index`
  123. })
  124. }
  125. } catch (e) {
  126. uni.showToast({
  127. title: err.errmsg,
  128. icon: 'error',
  129. duration: 2000
  130. });
  131. }
  132. },
  133. async search() {
  134. const that = this;
  135. if (that.id) {
  136. let info = {
  137. skip: that.skip,
  138. limit: that.limit,
  139. lab_id: that.id
  140. }
  141. const res = await that.$api(`/award`, 'GET', {
  142. ...info,
  143. ...that.searchInfo
  144. }, 'freeLabel')
  145. if (res.errcode == '0') {
  146. for (let val of res.data) {
  147. val.user_id = that.getDict(val.user_id, 'user_id')
  148. val.type = that.getDict(val.type, 'type')
  149. val.level = that.getDict(val.level, 'level')
  150. val.direction = that.getDict(val.direction, 'direction')
  151. }
  152. that.$set(that, `list`, res.data)
  153. that.$set(that, `total`, res.total)
  154. } else {
  155. uni.showToast({
  156. title: res.errmsg,
  157. });
  158. }
  159. }
  160. uni.hideLoading();
  161. },
  162. // 输入框
  163. toInput(e) {
  164. const that = this;
  165. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  166. else that.$set(that, `searchInfo`, {})
  167. that.search();
  168. },
  169. // 查询字典表
  170. getDict(e, model) {
  171. const that = this;
  172. if (!e) return '暂无'
  173. if (model == 'user_id') {
  174. let list = [];
  175. for (const val of e) {
  176. let data = that.userList.find((i) => i._id == val);
  177. if (data) list.push(data.name);
  178. }
  179. return list.join(',');
  180. } else if (model == 'direction') {
  181. let data = that.directionList.find((i) => i._id == e);
  182. if (data) return data.name;
  183. else return '暂无';
  184. } else if (model == 'type') {
  185. let data = that.typeList.find((i) => i.dict_value == e);
  186. if (data) return data.dict_label;
  187. else return e;
  188. } else if (model == 'level') {
  189. let data = that.levelList.find((i) => i.dict_value == e);
  190. if (data) return data.dict_label;
  191. else return e;
  192. }
  193. },
  194. // 查看详情
  195. async toView(item) {
  196. const that = this;
  197. let infoFields = [{
  198. label: '年度',
  199. model: 'year'
  200. },
  201. {
  202. label: '论文类别',
  203. model: 'type'
  204. },
  205. {
  206. label: '获奖等级',
  207. model: 'level'
  208. },
  209. {
  210. label: '成果名称',
  211. model: 'name'
  212. },
  213. {
  214. label: '成果编号',
  215. model: 'resulnumber'
  216. },
  217. {
  218. label: '获奖人',
  219. model: 'user_id'
  220. },
  221. {
  222. label: '获奖时间',
  223. model: 'time'
  224. },
  225. {
  226. label: '研究方向',
  227. model: 'direction'
  228. },
  229. {
  230. label: '是否公开',
  231. model: 'is_show',
  232. is_show: true
  233. },
  234. {
  235. label: '附件',
  236. model: 'file',
  237. is_image: true
  238. },
  239. ];
  240. let res = await that.$api(`/award/${item._id}`, 'GET', {}, 'freeLabel')
  241. if (res.errcode == '0') {
  242. let info = res.data;
  243. //  整理数据
  244. if (info && info.type) info.type = that.getDict(info.type, 'type');
  245. if (info && info.level) info.level = that.getDict(info.level, 'level');
  246. if (info && info.user_id) info.user_id = that.getDict(info.user_id, 'user_id');
  247. if (info && info.direction) info.direction = that.getDict(info.direction, 'direction');
  248. that.$set(that, `info`, info)
  249. that.$set(that, `infoFields`, infoFields)
  250. that.$refs.popup.open()
  251. }
  252. },
  253. // 关闭弹框
  254. toClose() {
  255. const that = this;
  256. that.$refs.popup.close();
  257. },
  258. // 分页
  259. toPage(data) {
  260. const that = this;
  261. uni.showLoading({
  262. title: '加载中',
  263. mask: true
  264. })
  265. that.$set(that, `page`, data.page);
  266. that.$set(that, `skip`, data.skip)
  267. that.search();
  268. },
  269. async searchOther() {
  270. const that = this;
  271. let res;
  272. if (that.id) {
  273. //研究方向
  274. res = await that.$api('/direction', 'GET', {
  275. lab_id: that.id
  276. }, 'freeLabel')
  277. if (res.errcode == '0') that.$set(that, `directionList`, res.data);
  278. }
  279. // 固定/流动人员 作者
  280. let personList = [];
  281. res = await that.$api('/fixedpersonnel', 'GET', {
  282. status: '0'
  283. }, 'freeLabel')
  284. if (res.errcode == '0') personList = res.data;
  285. res = await that.$api('/flowpersonnel', 'GET', {
  286. status: '0'
  287. }, 'freeLabel')
  288. if (res.errcode == '0') personList.push(...res.data);
  289. that.$set(that, `userList`, personList);
  290. //类别
  291. res = await that.$api('/dictData', 'GET', {
  292. dict_type: 'cheng_resulttype',
  293. status: '0'
  294. }, 'jcyjdtglpt')
  295. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  296. //获奖等级
  297. res = await that.$api('/dictData', 'GET', {
  298. dict_type: 'jiang_level',
  299. status: '0'
  300. }, 'jcyjdtglpt')
  301. if (res.errcode == '0') that.$set(that, `levelList`, res.data);
  302. //是否启用
  303. res = await that.$api('/dictData', 'GET', {
  304. dict_type: 'info_show',
  305. status: '0'
  306. }, 'jcyjdtglpt')
  307. if (res.errcode == '0') that.$set(that, `showList`, res.data);
  308. },
  309. }
  310. }
  311. </script>
  312. <style lang="scss" scoped>
  313. .main {
  314. display: flex;
  315. flex-direction: column;
  316. width: 100vw;
  317. height: 100vh;
  318. .one {
  319. padding: 2vw;
  320. input {
  321. padding: 2vw;
  322. background-color: var(--f1Color);
  323. font-size: var(--font14Size);
  324. border-radius: 5px;
  325. }
  326. }
  327. .two {
  328. background-color: var(--f9Color);
  329. }
  330. .uni-popup {
  331. z-index: 9999 !important;
  332. }
  333. .popup {
  334. display: flex;
  335. flex-direction: column;
  336. width: 90vw;
  337. height: 40vh;
  338. background-color: var(--f9Color);
  339. .close {
  340. display: flex;
  341. justify-content: space-between;
  342. padding: 2vw;
  343. text:first-child {
  344. font-size: var(--font16Size);
  345. font-weight: bold;
  346. }
  347. }
  348. .info_1 {
  349. position: relative;
  350. display: flex;
  351. flex-direction: column;
  352. padding: 2vw;
  353. }
  354. }
  355. }
  356. </style>