projectList.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.organizationName || '-'}}</view>
  7. <view class="space">{{JSON.parse(item.address).join('-')}}</view>
  8. <view class="state">
  9. <view></view>
  10. <view class="tag">
  11. <view class="status-tag primary" v-for="(node,index) in item.projectListIdentity" :key="node.id">
  12. {{node.name}}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="icon" v-if="project.id === item.id">
  17. <uni-icons type="checkmarkempty" color="#08979c" size="30"></uni-icons>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getProjectList,
  26. selectProject,
  27. refresh
  28. } from '@/request/api/project'
  29. import {
  30. selectOrangaized,
  31. getOrganizationDetailById
  32. } from '@/request/api/organization.js'
  33. export default {
  34. data() {
  35. return {
  36. list: [],
  37. project: {}
  38. }
  39. },
  40. onShow() {
  41. this.project = this.$store.getters.project;
  42. },
  43. onLoad() {
  44. this.init();
  45. },
  46. methods: {
  47. init() {
  48. uni.showLoading();
  49. refresh().then(res => {
  50. if (res.code == 200) {
  51. getProjectList().then(res => {
  52. uni.hideLoading();
  53. if (res.code == 200) {
  54. this.list = res.data;
  55. }
  56. })
  57. } else {
  58. uni.hideLoading();
  59. }
  60. })
  61. },
  62. select(item) {
  63. uni.showActionSheet({
  64. itemList: item.projectListIdentity.map(node => node.name),
  65. success: node => {
  66. let identity = item.projectListIdentity[node.tapIndex];
  67. uni.showLoading();
  68. if (identity.id == 6 || identity.id == 3) {
  69. getOrganizationDetailById(item.organizationId).then(res => {
  70. if (res.code === 200) {
  71. this.$store.dispatch('app/changeOrganization', res.data);
  72. selectOrangaized(res.data);
  73. this.selectProject(item, identity);
  74. }
  75. })
  76. } else {
  77. this.selectProject(item, identity);
  78. }
  79. }
  80. });
  81. },
  82. selectProject(item, identity) {
  83. selectProject(item.id).then(res => {
  84. if (res.code === 200) {
  85. this.$store.dispatch('app/changeProject', item);
  86. this.$store.dispatch('app/changeIdentity', identity);
  87. uni.setStorageSync('vuex_state', this.$store.state);
  88. uni.$emit('reloadData');
  89. this.$toast('切换成功');
  90. setTimeout(() => {
  91. uni.hideLoading();
  92. uni.navigateBack();
  93. }, 400)
  94. } else {
  95. uni.hideLoading();
  96. }
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss">
  103. .project-select {
  104. padding: 30rpx 0;
  105. .tag {
  106. display: flex;
  107. .status-tag {
  108. margin-left: 5px;
  109. }
  110. }
  111. }
  112. </style>