123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <template>
- <!-- 禁止滚动穿透 -->
- <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta>
- <view class="main">
- <view class="one">
- <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索姓名">
- </view>
- <view class="two">
- <list name="list" :list="list" :fields="fields" :page="page" :total="total" :pageSize="limit"
- @toPage="toPage" @toView="toView">
- </list>
- </view>
- <uni-popup ref="popup" background-color="#fff" type="center" :is-mask-click="false" @change="change">
- <view class="popup">
- <view class="close">
- <text>信息管理</text>
- <uni-icons @tap="toClose" type="close" size="20"></uni-icons>
- </view>
- <view class="info_1">
- <info name="info" :data="info" :infoFields="infoFields" :showList="showList"></info>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import list from '@/components/list/index.vue';
- import info from '@/components/view/index.vue';
- export default {
- components: {
- list,
- info
- },
- data() {
- return {
- id: '',
- user: {},
- searchInfo: {},
- fields: [{
- label: '姓名',
- model: 'name',
- is_name: true
- },
- {
- label: '本实验室职务',
- model: 'type'
- },
- {
- label: '年龄',
- model: 'age'
- },
- {
- label: '单位',
- model: 'unit'
- },
- {
- label: '职务职称',
- model: 'zwzc'
- },
- {
- label: '专业',
- model: 'title'
- },
- {
- label: '称号',
- model: 'major'
- },
- ],
- list: [],
- total: 0,
- skip: 0,
- limit: 5,
- page: 1,
- // 字典表
- typeList: [],
- showList: [],
- // 查看
- info: {},
- infoFields: [],
- // 禁止滚动穿透
- show: false
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- uni.showLoading({
- title: '正在加载请稍后',
- mask: true
- })
- await that.searchOther();
- that.searchToken();
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- // 禁止滚动穿透
- change(e) {
- const that = this;
- that.show = e.show
- },
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) {
- const user = that.$jwt(res);
- that.$set(that, `user`, user);
- } else {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- async search() {
- const that = this;
- if (that.id) {
- let info = {
- skip: that.skip,
- limit: that.limit,
- lab_id: that.id
- }
- const res = await that.$api(`/committee`, 'GET', {
- ...info,
- ...that.searchInfo
- }, 'freeLabel')
- if (res.errcode == '0') {
- for (let val of res.data) {
- val.type = that.getDict(val.type, 'type')
- }
- that.$set(that, `list`, res.data)
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- }
- uni.hideLoading();
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
- else that.$set(that, `searchInfo`, {})
- that.search();
- },
- // 查询字典表
- getDict(e, model) {
- const that = this;
- if (!e) return '暂无'
- if (model == 'type') {
- let list = [];
- for (const val of e) {
- let data = that.typeList.find((i) => i.dict_value == val);
- if (data) list.push(data.dict_label);
- }
- return list.join(',');
- } else if (model == 'term_of') return e.join('-')
- },
- // 查看详情
- async toView(item) {
- const that = this;
- let infoFields = [{
- label: '姓名',
- model: 'name'
- },
- {
- label: '年龄',
- model: 'age'
- },
- {
- label: '单位',
- model: 'unit'
- },
- {
- label: '职务职称',
- model: 'zwzc'
- },
- {
- label: '称号',
- model: 'title'
- },
- {
- label: '专业',
- model: 'major'
- },
- {
- label: '任期时间',
- model: 'term_of'
- },
- {
- label: '本实验室职务',
- model: 'type'
- },
- {
- label: '是否公开',
- model: 'is_show',
- is_show: true
- },
- {
- label: '附件',
- model: 'file',
- is_image: true
- },
- ];
- let res = await that.$api(`/committee/${item._id}`, 'GET', {}, 'freeLabel')
- if (res.errcode == '0') {
- let info = res.data;
- // 整理数据
- if (info && info.type) info.type = that.getDict(info.type, 'type');
- if (info && info.term_of) info.term_of = that.getDict(info.term_of, 'term_of');
- that.$set(that, `info`, info)
- that.$set(that, `infoFields`, infoFields)
- that.$refs.popup.open()
- }
- },
- // 关闭弹框
- toClose() {
- const that = this;
- that.$refs.popup.close();
- },
- // 分页
- toPage(data) {
- const that = this;
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- that.$set(that, `page`, data.page);
- that.$set(that, `skip`, data.skip)
- that.search();
- },
- async searchOther() {
- const that = this;
- let res;
- // 职务
- res = await that.$api('/dictData', 'GET', {
- dict_type: 'xueshu_type',
- status: '0'
- }, 'jcyjdtglpt')
- if (res.errcode == '0') that.$set(that, `typeList`, res.data);
- //是否启用
- res = await that.$api('/dictData', 'GET', {
- dict_type: 'info_show',
- status: '0'
- }, 'jcyjdtglpt')
- if (res.errcode == '0') that.$set(that, `showList`, res.data);
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .two {
- background-color: var(--f9Color);
- }
- .uni-popup {
- z-index: 9999 !important;
- }
- .popup {
- display: flex;
- flex-direction: column;
- width: 90vw;
- height: 40vh;
- background-color: var(--f9Color);
- .close {
- display: flex;
- justify-content: space-between;
- padding: 2vw;
- text:first-child {
- font-size: var(--font16Size);
- font-weight: bold;
- }
- }
- .info_1 {
- position: relative;
- display: flex;
- flex-direction: column;
- padding: 2vw;
- }
- }
- }
- </style>
|