<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-03-20 14:36:37
 * @LastEditors: 无尘
 * @LastEditTime: 2020-05-06 11:37:01
 -->
<template>
  <div class="app-detail-wrap">
    <div class="task-set-content boder-box">
      <div class="task-set-cell">
        <div class="set-line-item">
          <span class="set-line-item_title font-14 color-606266 text-right">不良评价拨打：</span><el-select v-model="setObj.taskCallType" placeholder="请选择" class="w-240" @change="changeSelect"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select><span v-if="setObj.taskCallType == 2" class="font-14 color-909399 p-l-10">双向透传，使用GIC双向呼叫及透传功能。计费由GIC计费中心计费，可记录通话记录及监测是否拨通。</span>
          <span v-if="setObj.taskCallType == 1" class="font-14 color-909399 p-l-10">普通呼叫，使用导购自己手机呼叫。计费方式同正常手机运营商呼叫计费。无法记录通话记录及监测是否拨通</span>
        </div>
        <div class="set-line-item">
          <span class="set-line-item_title font-14 color-606266 text-right">任务分配：</span>
          <el-radio style="margin-right: 5px;" v-model="setObj.distributeCustomerJudge" :label="1">{{ '' }}</el-radio
          ><el-tooltip class="item" effect="dark" content="勾选此项，不良评价回访任务将分配给产生该笔消费订单的所在门店店长" placement="top-start">
            <span :class="['font-14 color-606266', setObj.distributeCustomerJudge == 1 ? 'color-303133' : 'color-606266']" style="cursor: pointer;padding-bottom: 2px; border-bottom: 1px dashed #2F54EB;">分配给消费门店店长</span>
          </el-tooltip>
          <el-radio style="margin-right: 5px;" class="p-l-40" v-model="setObj.distributeCustomerJudge" :label="2">{{ '' }}</el-radio
          ><el-tooltip class="item" effect="dark" content="勾选此项，不良评价回访任务将分配给产生该笔消费订单的会员的专属导购" placement="top-start">
            <span :class="['font-14 ', setObj.distributeCustomerJudge == 2 ? 'color-303133' : 'color-606266']" style="cursor: pointer;padding-bottom: 2px; border-bottom: 1px dashed #2F54EB;">分配给专属导购</span>
          </el-tooltip>
        </div>
        <div class="set-line-item">
          <span class="set-line-item_title font-14 color-606266 text-right">逾期设置：</span>
          <span class=" font-14 color-303133">不良评价回访下发后</span>
          <el-input-number controls-position="right" class="w-100" v-model="setObj.overDayJudge" placeholder="请输入内容" :step="1" :step-strictly="true" :min="0" :max="99999999"></el-input-number><span class="font-14 color-606266 p-l-10">天</span>
          <span class="font-14 color-909399 p-l-15">注：0天即为当天下发，当天完成，1天即为当天下发，次日24：00之前完成</span>
        </div>
        <div v-if="setObj.taskCallType == 2" class="set-line-item">
          <span class="set-line-item_title font-14 color-606266  text-right">放弃任务条件：</span><span class="font-14 color-606266">不良评价下发后 </span><el-input-number controls-position="right" class="w-100" v-model="setObj.giveUpJudge" placeholder="请输入内容" :step="1" :step-strictly="true" :min="0" :max="99999999"></el-input-number><span class="font-14 color-606266 p-l-10">次</span>
          <span class="font-14 color-606266">呼叫后无响应，导购可放弃该条任务</span>
        </div>
        <!-- <div class="set-line-item">
          <span class="set-line-item_title font-14 color-606266 text-right">不良评价释放：</span><el-checkbox v-model="setObj.relaxTaskJudge"></el-checkbox
          ><el-tooltip class="item" effect="dark" content="开启后，导购换绑导购code后，原导购code任务将被释放给门店店长" placement="top-start">
            <span :class="['font-14 color-606266 m-l-10']" style="cursor: pointer;padding-bottom: 2px; border-bottom: 1px dashed #2F54EB;">释放未绑定/解绑导购任务</span>
          </el-tooltip>
        </div> -->
        <div class="set-line-item">
          <span class="set-line-item_title font-14 color-606266 text-right"></span>
          <el-button type="primary" @click="saveSet">保存</el-button>
        </div>
      </div>

      <div class="task-set-save m-t-30"></div>
    </div>
  </div>
</template>
<script>
import { _debounce } from '@/common/js/public';
import errMsg from '@/common/js/error';
import showMsg from '@/common/js/showmsg';
import { postRequest } from '@/api/api';
export default {
  name: 'reviewed',
  props: {
    brandId: {
      type: String,
      default() {
        return '';
      }
    }
  },
  data() {
    return {
      activeTab: '1',
      activeBrand: this.brandId, // 商户(品牌) id
      options: [
        {
          label: '普通电话',
          value: 1
        },
        {
          label: '双向透传',
          value: 2
        }
      ],
      activeId: '1',
      setObj: {
        taskCallType: 1,
        taskType: 0,
        overDayJudge: '',
        distributeTypeJudge: '',
        distributeCustomerJudge: 1,
        giveUpJudge: ''
      }
    };
  },
  computed: {},
  methods: {
    /**
     * 保存
     */
    saveSet: _debounce(function() {
      let that = this;
      that.postSave();
    }, 500),
    postSave() {
      let that = this;
      let para = {
        enterpriseId: that.activeBrand,
        taskCallType: that.setObj.taskCallType,
        taskType: 0,
        overDayJudge: that.setObj.overDayJudge,
        giveUpJudge: that.setObj.giveUpJudge,
        distributeTypeJudge: that.setObj.distributeTypeJudge,
        distributeCustomerJudge: that.setObj.distributeCustomerJudge,
        relaxTaskJudge: that.setObj.relaxTaskJudge ? 1 : 0
      };
      postRequest('/haoban-app-tel-task-three-web/setting/save-task-setting', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            showMsg.showmsg('保存成功', 'success');
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    },
    /**
     * 获取设置数据
     */
    getData() {
      let that = this;
      let para = {
        enterpriseId: that.activeBrand,
        taskType: 0
      };
      postRequest('/haoban-app-tel-task-three-web/setting/find-task-setting', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            resData.result.relaxTaskJudge = resData.result.relaxTaskJudge == 1 ? true : false;
            that.setObj = resData.result;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  watch: {
    brandId: function(newData, oldData) {
      const that = this;
      if (!!newData) {
        that.activeBrand = newData;
        that.getData();
      }
    }
  },
  mounted() {
    let that = this;
    document.documentElement.style.backgroundColor = '#f0f2f5';
    that.$emit('showTab', '23');
    if (!!that.brandId) {
      that.getData();
    }
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  },
  components: {}
};
</script>
<style type="text/scss" lang="scss" scoped>
.w-100 {
  width: 100px;
}
.w-240 {
  width: 240px;
}
.p-l-3 {
  padding-left: 3px;
}
.p-l-40 {
  padding-left: 40px;
}
.task-set-content {
  padding: 30px;
  .task-set-cell {
    /* padding: 30px 0; */
    .el-date-editor.el-input {
      width: 118px;
    }
  }
  .set-line-item {
    margin-bottom: 20px;
    .set-line-item_title {
      display: inline-block;
      width: 110px;
    }
  }
}
</style>
