songshankun
2023-10-12 87dfb09836f2942ab9ae5f87d712c05226ad9c62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
  <div class="advance">
    <el-dialog
      :title="'推进'"
      append-to-body
      :visible.sync="commonConfig.visible"
      :width="dialogWidth"
      :before-close="handleClose"
      custom-class="advance-dialog"
    >
      <div class="content">
        <el-radio-group v-model="radio">
          <div class="one">
            <el-radio :label="1">
              <span>推进到下一阶段</span>
              <el-select v-model="value1" size="mini" disabled>
                <el-option v-for="(item, index) in options" :key="index" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </el-radio>
          </div>
          <div class="two">
            <el-radio :label="2">
              <span>推进到指定阶段</span>
              <el-select v-model="value" size="mini" @change="designatedStageClick">
                <el-option v-for="(item, index) in options" :key="index" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </el-radio>
          </div>
        </el-radio-group>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="saveClick()">推进</el-button>
        <el-button size="small" @click="commonConfig.visible = false">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { pushSaleChance } from "@/api/sales/salesOpportunity"
export default {
  name: "DetailAdvanceDialog",
  props: {
    advanceConfig: {
      type: Object,
      default: () => {
        return {
          visible: false,
          active: "需求分析",
          allOptions: [],
          options: [],
          id: 0
        }
      }
    }
  },
  components: {},
  computed: {},
  data() {
    return {
      allOptions: this.advanceConfig.allOptions,
      dialogWidth: "25%",
      radio: 1,
      commonConfig: this.advanceConfig,
      value1: "",
      value: "",
      options: this.advanceConfig.options
    }
  },
  watch: {},
  created() {
    this.setData()
  },
  methods: {
    setData() {
      this.allOptions.map((item, index) => {
        if (item.id === this.commonConfig.active) {
          if (index + 1 === this.allOptions.length) {
            this.value = this.allOptions[0].id
            this.value1 = this.allOptions[0].id
          } else {
            this.value = this.allOptions[index + 1].id
            this.value1 = this.allOptions[index + 1].id
          }
 
          this.options.splice(index, 1)
        }
      })
    },
    handleClose() {
      this.commonConfig.visible = false
    },
    designatedStageClick() {
      this.radio = 2
    },
    async saveClick() {
      let stepId = 0
      if (this.radio === 2) {
        stepId = this.value
      } else {
        stepId = this.value1
      }
      await pushSaleChance({
        id: this.commonConfig.id,
        step: stepId
      }).then((res) => {
        if (res.code === 200) {
          this.handleClose()
          this.$emit('pushed',{
            id: this.commonConfig.id,
            step: stepId
          })
        }
      })
    }
  }
}
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
::v-deep {
  .advance-dialog .el-dialog__body {
    padding: 10px 20px;
    .content {
      .el-select {
        margin-left: 10px;
      }
      .two {
        margin-top: 15px;
      }
    }
    .dialog-footer {
      background-color: #f5f5f5;
      height: 55px;
      line-height: 55px;
    }
  }
}
</style>