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