<template>
    <fieldset>
        <legend>
            <el-tag type="info">按需操作</el-tag>
        </legend>
        <div class="op-header">
            <div class="left-panel">
                <sc-file-export :apiObj="$API.merOrder.export" :data="searchKey" :fileName="name+'_'+(new Date().getTime())" async>
                    <template #default="{ open }">
                        <el-button type="primary" icon="sc-icon-download" @click="open">导出</el-button>
                    </template>
                </sc-file-export>
                <template v-if="status==1">
                    <el-button type="danger" icon="el-icon-document-checked" @click="batch_send" :disabled="dataSelect.length>0?false:true">批量确认</el-button>
                </template>
            </div>
        </div>
    </fieldset>
</template>

<script>
import scFileExport from '@/components/scFileExport'
export default {
    components: {
        scFileExport
    },
    props: {
        status: { type: String, default: "1" },
        name: { type: String, default: "已预约订单" },
        dataSelect: { type: Array, default: () => [] },
        searchKey: { type: Object, default: () => {} },
        dataSelectFull: { type: Array, default: () => [] }
    },
    data(){
        return {

        }
    },
    methods: {
        table_export(){
            
        },
        batch_send(){
            this.$confirm(`确认订单后，所勾选的订单状态将自动调整为【服务中】，用户取消服务需要在【解锁审核】中进行处理`, '提示', {
                type: 'warning'
            }).then(async () => {
                var loading = this.$loading();
                var resp = await this.$API.merOrder.batchState.post({"order":this.dataSelect});
                loading.close();
                if (resp.code !== 1) {
                    return this.$message.error(resp.msg);
                }
                this.$message.success(resp.msg);
                this.$emit("success");
            }).catch(() => {

            })
        },
        async table_batch_status(status){
            if (this.dataSelect.length == 0) {
                return this.$message.error("请选择修改数据")
            }
            let submitData = {"id":this.dataSelect,"value":status,"field":"status","type":"batch"};
            var resp = await this.$API.merGoods.batch.post(submitData);
            if (resp.code == 0) {
                return this.$message.error(resp.msg);
            }
            this.$message.success(resp.msg);
            this.$emit("success");
        },
        handleSuccess(){
            this.$emit("success");
        },
    }
}
</script>