<template>
  <div>
    <el-dialog :title="title" :visible.sync="showDialog" width="1000px" :close-on-click-modal="false" @close="handleClose"
      append-to-body>

      <basicMessage :projectId="row.projectId" :taskId="row.id"></basicMessage>

      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-dropdown v-if="isLook == 2" split-button type="primary" @click="submit">
          <span>{{ btn.label }}</span>
          <el-dropdown-menu slot="dropdown" class="text-align_center">
            <el-dropdown-item v-for="item in btnObj" :key="item.label" @click.native="onChangeFamily(item)">{{ item.label
            }}</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import basicMessage from '../details/components/basicMessage.vue'
export default {
  components: {
    basicMessage
  },
  data() {
    return {
      // 控制弹窗显示
      showDialog: false,
      row: {},
      isLook: '',
      title: '',
      btnObj: [
        {
          label: '同意创建',
          value: 0
        },
        {
          label: '取消创建',
          value: 1
        },
        {
          label: '缺少材料',
          value: 2
        }
      ],
      btn: {
        label: '同意创建',
        value: 0
      },
    }
  },
  mounted() {

  },
  methods: {
    open(row, str) {
      this.row = row
      this.isLook = str
      this.title = str == 2 ? '处理审核任务' : '查看审核任务'
      this.showDialog = true
    },
    // 切换按钮
    onChangeFamily(val) {
      this.btn = val
    },
    submit() {
      let params = {
        // id: this.row.projectId,
        taskId: this.row.id,
        type: this.btn.value
      }
      this.$api.updateTaskStatus(params).then(res => {
        if (res.code == 200) {
          this.$message.success('任务已处理')
          this.$emit('isSuccess', '成功')
          this.handleClose()
          this.splitClaim()
        }
      })
    },
    handleClose() {
      this.showDialog = false
    },
     //拆分权利要求并拆分
     splitClaim(){
      if(this.btn.value != 0 || this.row.reportType != 7){
        return false
      }
      var params = {
        projectId : this.row.projectId
      }
      this.$api.splitClaim(params).then(response=>{
        if(response.code == 200){

        }
      })
    },
  },
}
</script>

<style lang="scss" scoped></style>