index.vue 6.7 KB

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