<template>
  <div class="">
    <div class="g-process-info">

      <el-form ref="ref_form1"
               :inline="false"
               :rules="dataRule"
               class="form">

        <el-form-item label="处理方式"
                      label-width="150px"
                      prop="operationType">
          <el-radio-group v-model="operationType"
                          @change="handleChangeOperationType">
            <el-radio v-if="!eventId"
                      label="">暂不处理</el-radio>
            <el-radio label="0">回复</el-radio>
            <el-radio label="1">立项</el-radio>
            <el-radio label="2">转服务</el-radio>

          </el-radio-group>
        </el-form-item>

      </el-form>

      <div v-if="operationType==='0'">
        <process-form-replay ref="ref_process_form_replay"
                             :eventDetailData="eventDetailData"
                             :eventId="eventId"></process-form-replay>
      </div>

      <div v-if="operationType==='1'">
        <process-form-project ref="ref_process_form_project"
                              :eventDetailData="eventDetailData"
                              :eventId="eventId"></process-form-project>
      </div>

      <div v-if="operationType==='2'">
        <process-form-demand ref="ref_process_form_demond"
                             :eventId="eventId"
                             :demandUserId="demandUserId"
                             :demandUserName="demandUserName"
                             :demandUserMobile="demandUserMobile"
                             :eventDetailData="eventDetailData"></process-form-demand>

      </div>

    </div>

  </div>
</template>

<script>
import { Loading } from "element-ui"; // 引入Loading服务
import { requestPost } from "@/js/dai/request";
import processFormReplay from "./process-form-replay";
import processFormProject from "./process-form-project";
import processFormDemand from "./process-form-demand";


let loading; // 加载动画

export default {
  data () {
    return {

      casOptions: [],
      iscascaderShow: 0,
      selCategoryArray: [],
      selCateObj: {},
      optionProps: {
        multiple: false,
        value: 'id',
        label: 'name',
        children: 'subCategory',
      },

      operationType: '',


      replayInfo: {},
      demand: {},
      project: {},
      okflag: false,

      eventDetailCopy: {}

    };
  },
  components: {
    processFormReplay,
    processFormProject,
    processFormDemand
  },
  computed: {
    dataRule () {
      return {

        operationType: [
          { required: true, message: "处理方式不能为空", trigger: "blur" },
        ],

      };
    },


  },
  props: {
    demandUserId: {
      type: String,
      default: "",
    },
    demandUserName: {
      type: String,
      default: "",
    },
    demandUserMobile: {
      type: String,
      default: "",
    },
    eventId: {
      type: String,
      default: "",
    },
    eventDetailData: {
      type: Object,
      default () {
        return {}
      }
    },
  },

  watch: {

  },

  async mounted () {
    const { user } = this.$store.state
    this.agencyId = user.agencyId

    if (this.eventId) {
      this.eventDetailCopy = JSON.parse(JSON.stringify(this.eventDetailData));

    }

  },

  methods: {
    handleChangeOperationType (val) {

    },
    async getProcessInfo () {
      this.okflag = false
      if (this.operationType === '0') {
        this.$refs.ref_process_form_replay.getReplayInfo()
        if (this.$refs.ref_process_form_replay.okflag) {
          this.replayInfo = this.$refs.ref_process_form_replay.formData

          this.okflag = true

        } else {
          return false
        }

      } else if (this.operationType === '1') {
        this.$refs.ref_process_form_project.getProjectInfo()
        if (this.$refs.ref_process_form_project.okflag) {

          this.project = this.$refs.ref_process_form_project.formData

          //赋值分类信息
          this.okflag = true

        } else {
          return false
        }
      } else if (this.operationType === '2') {
        this.$refs.ref_process_form_demond.getDemandInfo()
        if (this.$refs.ref_process_form_demond.okflag) {
          this.demand = this.$refs.ref_process_form_demond.formData

          this.okflag = true

        } else {
          return false
        }
      }

    },


    handleCancle () {
      this.resetData();

    },
    resetData () {

    },
    // 开启加载动画
    startLoading () {
      loading = Loading.service({
        lock: true, // 是否锁定
        text: "正在加载……", // 加载中需要显示的文字
        background: "rgba(0,0,0,.7)", // 背景颜色
      });
    },
    // 结束加载动画
    endLoading () {
      // clearTimeout(timer);
      if (loading) {
        loading.close();
      }
    },
  },
};
</script>
<style
  lang="scss"
  src="@/assets/scss/modules/shequzhili/event-info.scss"
  scoped
></style>





<style>
.el-dialog__body {
  padding: 0 10px 20px !important;
}
</style>
