index.vue 7.2 KB

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