123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <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: 'person_id'
- },
- {
- label: '核心成员',
- model: 'persons'
- },
- {
- label: '是否启用',
- model: 'is_show',
- is_status: true
- },
- ],
- list: [],
- total: 0,
- skip: 0,
- limit: 5,
- page: 1,
- // 字典表
- userList: [],
- 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(`/direction`, 'GET', {
- ...info,
- ...that.searchInfo
- }, 'freeLabel')
- if (res.errcode == '0') {
- for (let val of res.data) {
- val.person_id = that.getDict(val.person_id, 'person_id')
- val.persons = that.getDict(val.persons, 'persons')
- val.is_show = that.getDict(val.is_show, 'is_show')
- }
- 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 == 'person_id') {
- let data = that.userList.find((i) => i._id == e);
- if (data) return data.name;
- else return '暂无';
- } else if (model == 'persons') {
- let list = [];
- if (e.length > 0) {
- for (const val of e) {
- let data = that.userList.find((i) => i._id == val);
- if (data) list.push(data.name);
- }
- return list.join(',');
- }
- } else if (model == 'is_show') {
- let data = that.showList.find((i) => i.dict_value == e);
- if (data) return data.dict_label;
- else return '暂无';
- }
- },
- // 查看详情
- async toView(item) {
- const that = this;
- let infoFields = [{
- label: '方向名称',
- model: 'name'
- },
- {
- label: '带头人',
- model: 'person_id'
- },
- {
- label: '核心成员',
- model: 'persons'
- },
- {
- label: '是否公开',
- model: 'is_show',
- is_show: true
- },
- {
- label: '附件',
- model: 'file',
- is_file: true
- },
- ];
- let res = await that.$api(`/direction/${item._id}`, 'GET', {}, 'freeLabel')
- if (res.errcode == '0') {
- let info = res.data;
- // 整理数据
- if (info && info.persons) info.persons = that.getDict(info.persons, 'persons');
- if (info && info.person_id) info.person_id = that.getDict(info.person_id, 'person_id');
- 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: 'info_show',
- status: '0'
- }, 'jcyjdtglpt')
- if (res.errcode == '0') that.$set(that, `showList`, res.data);
- // 固定/流动人员 作者
- let personList = [];
- res = await that.$api('/fixedpersonnel', 'GET', {
- status: '0'
- }, 'freeLabel')
- if (res.errcode == '0') personList = res.data;
- res = await that.$api('/flowpersonnel', 'GET', {
- status: '0'
- }, 'freeLabel')
- if (res.errcode == '0') personList.push(...res.data);
- that.$set(that, `userList`, personList);
- },
- }
- }
- </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>
|