src/views/sales/salesOpportunity/DetailAdvanceDialog.vue
@@ -13,23 +13,25 @@
          <div class="one">
            <el-radio :label="1">
              <span>推进到下一阶段</span>
              <el-select v-model="value" size="mini" disabled>
                <el-option v-for="(item, index) in options" :key="index" :label="item" :value="item"> </el-option>
              <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">
                <el-option v-for="(item, index) in options" :key="index" :label="item" :value="item"> </el-option>
              <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('form')">推进</el-button>
        <el-button type="primary" size="small" @click="saveClick()">推进</el-button>
        <el-button size="small" @click="commonConfig.visible = false">取消</el-button>
      </div>
    </el-dialog>
@@ -37,6 +39,7 @@
</template>
<script>
import { pushSaleChance } from "@/api/sales/salesOpportunity"
export default {
  name: "DetailAdvanceDialog",
  props: {
@@ -45,7 +48,10 @@
      default: () => {
        return {
          visible: false,
          active: "需求分析"
          active: "需求分析",
          allOptions: [],
          options: [],
          id: 0
        }
      }
    }
@@ -54,12 +60,13 @@
  computed: {},
  data() {
    return {
      allOptions: ["初期沟通", "需求分析", "方案报价", "商务谈判", "成功结案", "失败结案"],
      allOptions: this.advanceConfig.allOptions,
      dialogWidth: "25%",
      radio: 1,
      commonConfig: this.advanceConfig,
      value1: "",
      value: "",
      options: ["初期沟通", "需求分析", "方案报价", "商务谈判", "成功结案", "失败结案"]
      options: this.advanceConfig.options
    }
  },
  watch: {},
@@ -68,17 +75,45 @@
  },
  methods: {
    setData() {
      console.log(this.commonConfig.active)
      this.allOptions.map((item, index) => {
        if (item === this.commonConfig.active) {
          console.log(index)
          this.value = this.allOptions[index + 1]
        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
          })
        }
      })
    }
  }
}