top.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div>
  3. <div class="white-bg border radius-5 picker flex flex-center">
  4. <span class="padding">项目阶段:</span>
  5. <el-select
  6. class="padding-right"
  7. style="width: 200px"
  8. clearable
  9. v-model="stage"
  10. @change="changeStage"
  11. >
  12. <el-option
  13. v-for="item in stages"
  14. :key="item"
  15. :label="item.name"
  16. :value="item.id"
  17. />
  18. </el-select>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. projectId: {
  26. required: true,
  27. type: String,
  28. default: ''
  29. }
  30. },
  31. watch: {
  32. projectId: {
  33. handler(val) {
  34. if (val.length > 0) {
  35. this.getStage()
  36. }
  37. },
  38. immediate: true
  39. }
  40. },
  41. data() {
  42. return {
  43. stages: [],
  44. stage: ''
  45. }
  46. },
  47. methods: {
  48. /**
  49. * 获取项目阶段
  50. */
  51. getStage() {
  52. this.$api.project
  53. .includeStage({ projectId: this.projectId })
  54. .then(res => {
  55. if (res.code === 200) {
  56. this.stages = res.data
  57. const tmp = this.stages.find(ele => ele.isLastSelect === 1)
  58. if (tmp) {
  59. this.stage = tmp.id
  60. } else {
  61. this.stage = this.stages[0].id
  62. }
  63. this.$emit('change', this.stage)
  64. }
  65. })
  66. },
  67. changeStage(res) {
  68. const tmp = this.stages.find(ele => ele.id === res)
  69. this.$emit('filter', tmp.sort)
  70. this.$emit('change', res)
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. :deep(.el-input__wrapper) {
  77. box-shadow: none;
  78. }
  79. </style>