index.vue 8.5 KB

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