projectList.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="project-select">
  3. <view class="common-list">
  4. <view class="common-item" v-for="(item,index) in list" :key="item.id" @click="selectProject(item)">
  5. <view class="title">{{item.name}}</view>
  6. <view class="date">{{item.createDate}}</view>
  7. <view class="space">{{JSON.parse(item.address).join('-')}}</view>
  8. <view class="state">
  9. <view class="create">
  10. <uni-icons class="inherit-icons" type="person-filled" color="#08979c" size="18"></uni-icons>
  11. <text class="name hui-ellipsis">{{item.organizationName || '-'}}</text>
  12. </view>
  13. <view class="tag">
  14. <view class="status-tag primary" v-for="(node,index) in item.projectListIdentity"
  15. :key="item.id">
  16. {{node.name}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="icon" v-if="project.id === item.id">
  21. <uni-icons type="checkmarkempty" color="#08979c" size="30"></uni-icons>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. getProjectList,
  30. selectProject
  31. } from '@/request/api/project'
  32. export default {
  33. data() {
  34. return {
  35. list: [],
  36. project: {}
  37. }
  38. },
  39. onShow() {
  40. this.project = this.$store.getters.project;
  41. },
  42. onLoad() {
  43. this.init();
  44. },
  45. methods: {
  46. init() {
  47. getProjectList().then(res => {
  48. if (res.code == 200) {
  49. this.list = res.data;
  50. }
  51. })
  52. },
  53. selectProject(item) {
  54. uni.showActionSheet({
  55. itemList: item.projectListIdentity.map(node => node.name),
  56. success: res => {
  57. uni.showLoading()
  58. selectProject(item.id).then(res => {
  59. if (res.code === 200) {
  60. let node = item.projectListIdentity[res.tapIndex];
  61. this.$store.dispatch('app/changeProject', item);
  62. this.$store.dispatch('app/changeIdentity', node);
  63. uni.setStorageSync('vuex_state', this.$store.state);
  64. this.$toast('切换成功');
  65. setTimeout(() => {
  66. uni.hideLoading();
  67. uni.navigateBack();
  68. }, 400)
  69. } else {
  70. uni.hideLoading();
  71. }
  72. })
  73. }
  74. });
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .project-select {
  81. padding: 30rpx 0;
  82. }
  83. </style>