projectList.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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="select(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="staff-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. import {
  33. selectOrangaized,
  34. getOrganizationDetailById
  35. } from '@/request/api/organization.js'
  36. export default {
  37. data() {
  38. return {
  39. list: [],
  40. project: {}
  41. }
  42. },
  43. onShow() {
  44. this.project = this.$store.getters.project;
  45. },
  46. onLoad() {
  47. this.init();
  48. },
  49. methods: {
  50. init() {
  51. getProjectList().then(res => {
  52. if (res.code == 200) {
  53. this.list = res.data;
  54. }
  55. })
  56. },
  57. select(item) {
  58. uni.showActionSheet({
  59. itemList: item.projectListIdentity.map(node => node.name),
  60. success: node => {
  61. let identity = item.projectListIdentity[node.tapIndex];
  62. uni.showLoading();
  63. if (identity.id == 6 || identity.id == 3) {
  64. getOrganizationDetailById(item.organizationId).then(res => {
  65. if (res.code === 200) {
  66. this.$store.dispatch('app/changeOrganization', res.data);
  67. selectOrangaized(res.data);
  68. this.selectProject(item, identity);
  69. }
  70. })
  71. } else {
  72. this.selectProject(item, identity);
  73. }
  74. }
  75. });
  76. },
  77. selectProject(item, identity) {
  78. selectProject(item.id).then(res => {
  79. if (res.code === 200) {
  80. this.$store.dispatch('app/changeProject', item);
  81. this.$store.dispatch('app/changeIdentity', identity);
  82. uni.setStorageSync('vuex_state', this.$store.state);
  83. uni.$emit('reloadData');
  84. this.$toast('切换成功');
  85. setTimeout(() => {
  86. uni.hideLoading();
  87. uni.navigateBack();
  88. }, 400)
  89. } else {
  90. uni.hideLoading();
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .project-select {
  99. padding: 30rpx 0;
  100. }
  101. </style>