<template>
  <el-dialog
    center
    :title="$t('修改跟进状态')"
    :visible="show"
    @close="customerFollowUpdateStatusClose"
    width="30%">
    <div style="width: 100%;min-height: 60px;text-align: center">
      <el-form label-width="120px">
        <el-col :span="20">
          <el-form-item :label="$t('跟进状态')">
            <el-select v-model="status" :placeholder="$t('请选择')" size="small">
              <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS)" :key="dict.value"
                         :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)"/>
            </el-select>
          </el-form-item>
        </el-col>
      </el-form>
      <!--      <el-select clearable v-model="status" :placeholder="$t('请选择')" size="small" >-->
      <!--        <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />-->
      <!--      </el-select>-->
    </div>
    <span slot="footer" class="dialog-footer">
    <el-button @click="$emit('update:show',false)">{{ $t('取 消') }}</el-button>
    <el-button type="primary" @click="submit">{{ $t('确 定') }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {DICT_TYPE, getDictDatas, getDictDatas2} from "@/utils/dict";
import {getCustomerFollowupList, updateCustomerFollowupStatus} from "@/api/ecw/customerFollow";

export default {
  name: "customerFollowUpdateStatus",
  props: {
    show: {
      type: Boolean,
      default: false
    },
    followupIds: [Array, String],
    tableName: String
  },
  computed: {
    isChinese() {
      return this.$i18n.locale === "zh_CN"
    },
    getFollowupIds() {
      console.log(this.followupIds, 'this.followupIds')
      if (this.followupIds instanceof Array) return this.followupIds
      else return this.followupIds.split(',')
    }
  },
  data() {
    return {
      getDictDatas,
      getDictDatas2,
      DICT_TYPE,
      status: null
    }
  },
  methods: {
    submit() {
      if (this.status == null || this.status == undefined) {
        return this.$message.warning(this.$t('请选择修改的状态！'));
      }
      console.log(this.followupIds, 'this.followupIds')
      updateCustomerFollowupStatus({
        ids: this.getFollowupIds,
        status: this.status
      }).then(r => {
        if (r.code === 0) {
          this.$message.success(this.$t('修改成功！'))
          this.$emit("refresh")
          this.customerFollowUpdateStatusClose()
        }

      })
    },

    customerFollowUpdateStatusClose() {
      this.status = null;
      this.$emit('update:show', false)

    },
  }
}
</script>

<style scoped>

</style>
