index.vue 8.0 KB

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