123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <view class="project-select">
- <view class="common-list">
- <view class="common-item" v-for="(item,index) in list" :key="item.id" @click="select(item)">
- <view class="title">{{item.name}}</view>
- <view class="date">{{item.organizationName || '-'}}</view>
- <view class="space">{{JSON.parse(item.address).join('-')}}</view>
- <view class="state">
- <view></view>
- <view class="tag">
- <view class="status-tag primary" v-for="(node,index) in item.projectListIdentity" :key="node.id">
- {{node.name}}
- </view>
- </view>
- </view>
- <view class="icon" v-if="project.id === item.id">
- <uni-icons type="checkmarkempty" color="#08979c" size="30"></uni-icons>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getProjectList,
- selectProject,
- refresh
- } from '@/request/api/project'
- import {
- selectOrangaized,
- getOrganizationDetailById
- } from '@/request/api/organization.js'
- export default {
- data() {
- return {
- list: [],
- project: {}
- }
- },
- onShow() {
- this.project = this.$store.getters.project;
- },
- onLoad() {
- this.init();
- },
- methods: {
- init() {
- uni.showLoading();
- refresh().then(res => {
- if (res.code == 200) {
- getProjectList().then(res => {
- uni.hideLoading();
- if (res.code == 200) {
- this.list = res.data;
- }
- })
- } else {
- uni.hideLoading();
- }
- })
- },
- select(item) {
- uni.showActionSheet({
- itemList: item.projectListIdentity.map(node => node.name),
- success: node => {
- let identity = item.projectListIdentity[node.tapIndex];
- uni.showLoading();
- if (identity.id == 6 || identity.id == 3) {
- getOrganizationDetailById(item.organizationId).then(res => {
- if (res.code === 200) {
- this.$store.dispatch('app/changeOrganization', res.data);
- selectOrangaized(res.data);
- this.selectProject(item, identity);
- }
- })
- } else {
- this.selectProject(item, identity);
- }
- }
- });
- },
- selectProject(item, identity) {
- selectProject(item.id).then(res => {
- if (res.code === 200) {
- this.$store.dispatch('app/changeProject', item);
- this.$store.dispatch('app/changeIdentity', identity);
- uni.setStorageSync('vuex_state', this.$store.state);
- uni.$emit('reloadData');
- this.$toast('切换成功');
- setTimeout(() => {
- uni.hideLoading();
- uni.navigateBack();
- }, 400)
- } else {
- uni.hideLoading();
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .project-select {
- padding: 30rpx 0;
- .tag {
- display: flex;
- .status-tag {
- margin-left: 5px;
- }
- }
- }
- </style>
|