yangfeng
2023-08-15 6857572e3d303daaf3c28e639aad91c0bdf2fc42
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<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" :value="item"></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" :value="item"></el-option>
              </el-select>
              <div v-if="value === '失败关闭'" class="reason">
                <div class="label"><span style="color: red">*</span>原因</div>
                <el-input class="input" type="textarea" :rows="2" placeholder="请输入内容" v-model="reason"></el-input>
              </div>
            </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>
      <!-- 新建/编辑客户管理 -->
      <AddClientManageDialog
        v-if="editConfig.visible"
        :edit-client-manage-config="editConfig"
        @salesOpportunityClick="salesOpportunityClick"
      />
      <!-- 新建/编辑销售机会 -->
      <AddSalesOpportunityDialog v-if="editOpportunityConfig.visible" :edit-common-config="editOpportunityConfig" />
    </el-dialog>
  </div>
</template>
 
<script>
import { pushSalesSources } from "@/api/client/salesLead"
import AddClientManageDialog from "@/views/client/client/AddClientManageDialog"
import AddSalesOpportunityDialog from "@/views/sales/salesOpportunity/AddSalesOpportunityDialog"
export default {
  name: "AdvanceDialog",
  props: {
    advanceConfig: {
      type: Object,
      default: () => {
        return {
          visible: false,
          infomation: {}
        }
      }
    }
  },
  components: { AddClientManageDialog, AddSalesOpportunityDialog },
  computed: {},
  data() {
    return {
      dialogWidth: "25%",
      radio: 1,
      commonConfig: this.advanceConfig,
      value1: "",
      value: "",
      options: [],
      reason: "",
      editConfig: {
        visible: false,
        title: "新建",
        isSalesOpportunity: false,
        infomation: {}
      },
      editOpportunityConfig: {
        visible: false,
        title: "新建",
        infomation: {}
      }
    }
  },
  watch: {},
  created() {
    this.setData(this.advanceConfig.infomation.sales_status)
  },
  methods: {
    setData(status) {
      if (status === 0) {
        this.options = ["跟进中", "失败关闭", "升级到客户", "升级到客户和销售机会"]
        this.value = "跟进中"
        this.value1 = "跟进中"
      } else if (status === 1) {
        this.options = ["失败关闭", "升级到客户", "升级到客户和销售机会"]
        this.value = "失败关闭"
        this.value1 = "失败关闭"
      } else if (status === -1) {
        this.options = ["升级到客户", "升级到客户和销售机会"]
        this.value = "升级到客户"
        this.value1 = "升级到客户"
      }
    },
    handleClose() {
      this.commonConfig.visible = false
      if (this.value === "升级到客户和销售机会") {
        this.$parent.getData()
      }
    },
    designatedStageClick(val) {
      console.log(val)
      this.radio = 2
    },
    saveClick() {
      console.log(this.value)
      if (this.value === "跟进中") {
        // val === '新建' ||
        this.pushSalesSources(1)
      } else if (this.value === "失败关闭") {
        if (this.reason.length > 0) {
          this.pushSalesSources(-1)
        } else {
          this.$message.warning("原因不能为空")
        }
      } else if (this.value === "升级到客户") {
        this.$confirm('升级后将转入"客户管理"模块, 是否继续?', "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.editConfig.visible = true
            this.editConfig.title = "新建"
            this.editConfig.infomation = {
              ...this.commonConfig.infomation,
              sales_leads_id: this.commonConfig.infomation.id
            }
          })
          .catch(() => {})
      } else if (this.value === "升级到客户和销售机会") {
        this.$confirm('升级后将转入"客户管理"和"销售机会"模块, 是否继续?', "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.editConfig.visible = true
            this.editConfig.title = "新建"
            this.editConfig.isSalesOpportunity = true
            this.editConfig.infomation = {
              ...this.commonConfig.infomation,
              sales_leads_id: this.commonConfig.infomation.id
            }
          })
          .catch(() => {})
      }
    },
    // 推进接口
    async pushSalesSources(step) {
      await pushSalesSources({
        id: this.commonConfig.infomation.id,
        reason: this.reason,
        step: step
      }).then((res) => {
        console.log(res)
        this.$message.success("推进成功")
        this.handleClose()
        this.$parent.getData()
      })
    },
    // 销售机会
    salesOpportunityClick(item) {
      console.log(item)
      this.editOpportunityConfig.visible = true
      this.editOpportunityConfig.title = "新建"
      this.editOpportunityConfig.infomation = { client_name: item.name }
    }
  }
}
</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;
        .reason {
          display: flex;
          margin-top: 10px;
          align-items: center;
          .label {
            width: 122px;
            text-align: right;
          }
          .input {
            margin-left: 10px;
            width: 195px;
          }
        }
      }
    }
    .dialog-footer {
      background-color: #f5f5f5;
      height: 55px;
      line-height: 55px;
    }
  }
}
</style>