<template>
    <div>
        <el-dialog :title="operateTitle" :visible="operateVisable" @close="cancel" center :distroy-on-close="true">
            <el-table v-loading="loading" :data="dataList" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection">
                </el-table-column>
                <el-table-column label="序号" type="index" align="center">
                    <template slot-scope="scope">
                        <span>{{
                            (queryParamsData.pageNum - 1) * queryParamsData.pageSize + scope.$index + 1
                        }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="案件编号" align="center" prop="caseNum" :show-overflow-tooltip="true" />
                <el-table-column label="申请人(机构)" align="center" prop="applicantName" :show-overflow-tooltip="true" />
                <el-table-column label="案件标的" align="center" prop="caseSubjectAmount" />
                <el-table-column label="仲裁方式" align="center" prop="arbitratMethodName" :show-overflow-tooltip="true" />
                <!-- 仲裁员 -->
                <el-table-column label="仲裁员" align="center" prop="arbitratorName" />
                <!-- 开庭日期 -->
                <el-table-column label="开庭日期" align="center" prop="hearDate" :show-overflow-tooltip="true" />
                <el-table-column label="案件状态" align="center" prop="caseStatusName">
                    <template slot-scope="scope">
                        <el-tag type="success">{{ scope.row.caseStatusName }}</el-tag>
                    </template>
                </el-table-column>
            </el-table>
            <div class="radiobox" v-if="operateStatus == 2">
                <el-radio-group v-model="radio">
                    <el-radio :label="1">同意</el-radio>
                    <el-radio :label="2">拒绝</el-radio>
                </el-radio-group>
            </div>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParamsData.pageNum"
                :limit.sync="queryParamsData.pageSize" @pagination="getcaseApply(queryParamsData)" />
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancel" class="endbutton"><span>取 消</span></el-button>
                <el-button @click="submitBatch" type="primary" class="endbutton" :disabled="dataList.length == 0"><span>确 认</span></el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import {
    caseApply,
    submitCaseApply,
    removeCaseApply,
    submitCaseApplicationCheck
} from "@/api/caseAccess/caseEntry";
import { writtenHear } from "@/api/caseManagement/caseManagement.js";
import {
    adjudicationCaseFile,
} from "@/api/awardManagement/awardManagement";
export default {
    props: ["operateVisable", "operateData", "operateTitle", 'operateStatus','queryParams'],
    data() {
        return {
            // 遮罩层
            loading: true,
            // 总条数
            total: 0,
            // 查询参数
            queryParamsData: {
                caseStatus: null,
                pageNum: 1,
                pageSize: 10,
            },
            // 表格数据
            dataList: [],
            batchData: [],
            radio:1
        };
    },
    watch: {
        operateVisable(val) {
            this.radio = 1;
            if (val) {
                this.getcaseApply(this.queryParamsData)
            }
        }
    },
    created() {

    },
    methods: {
        // 选择勾选框
        handleSelectionChange(val) {
            this.batchData = [];
            val.forEach(item => {
                this.batchData.push(item.id)
            })
        },
        cancel() {
            this.$emit("cancelOperate");
        },
        // 批量操作
        submitBatch() {
            if (this.operateStatus == 0) {
                this.submitCaseApplyFn({ ids: this.batchData })
            } else if (this.operateStatus == 1) {
                this.removeCaseApplyFn({ ids: this.batchData })
            } else if (this.operateStatus == 2) {
                this.submitCaseApplicationCheckFn({ ids: this.batchData,agreeOrNotCheck:this.radio })
            }else if (this.operateStatus == 3) {
                this.adjudicationCaseFileFn({ ids: this.batchData })
            }else if (this.operateStatus == 4) {
                // this.adjudicationCaseFileFn({ ids: this.batchData })
                this.writtenHearFn({ids: this.batchData})
            }else if (this.operateStatus == 5) {
                // this.adjudicationCaseFileFn({ ids: this.batchData })
                // this.writtenHearFn({ids: this.batchData})
            }
        },
        // 批量提交
        submitCaseApplyFn(data) {
            submitCaseApply(data).then(res => {
                this.$modal.msgSuccess("提交成功");
                this.cancel();
                this.$emit("getcaseApply", this.queryParams);
            })
        },
        // 批量删除
        removeCaseApplyFn(data) {
            removeCaseApply(data).then(res => {
                this.$modal.msgSuccess("删除成功");
                this.cancel();
                this.$emit("getcaseApply", this.queryParams);
            })
        },
        // 批量立案审查
        submitCaseApplicationCheckFn(data){
            submitCaseApplicationCheck(data).then(res=>{
                this.$modal.msgSuccess("立案审查成功");
                this.cancel();
                this.$emit("getcaseApply", this.queryParams);
            })
        },
        //批量归档
        adjudicationCaseFileFn(data){
            adjudicationCaseFile(data).then(res=>{
                this.$modal.msgSuccess("归档成功");
                this.cancel();
                this.$emit("getcaseApply", this.queryParams);
            })
        },
        // 批量生成裁决书
        writtenHearFn(data){
            writtenHear(data).then(res=>{
                this.$modal.msgSuccess("生成成功");
                this.cancel();
                this.$emit("getcaseApply", this.queryParams);
            })
        },
        /** 查询列表 */
        getcaseApply(val) {
            this.loading = true;
            if (this.operateStatus == 0) {
                this.queryParamsData.caseStatus = 0
            } else if (this.operateStatus == 1) {
                this.queryParamsData.caseStatus = 0
            } else if (this.operateStatus == 2) {
                this.queryParamsData.caseStatus = 1
            }else if (this.operateStatus == 3) {
                this.queryParamsData.caseStatus = 16
            }else if (this.operateStatus == 4) {
                this.queryParamsData.caseStatus = 9
            }else if (this.operateStatus == 5) {
                this.queryParamsData.caseStatus = 11
            }
            caseApply(val).then((response) => {
                this.dataList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
    },
};
</script>
  
<style lang="scss" scoped>
.steps {
    display: flex;
    flex-wrap: wrap;
}
.radiobox{
    margin-top: 30px;
}
</style>