index.vue 8.4 KB

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