<template>
    <div class="op-header-no">
        <div class="left-panel">
            <template v-if="trade==2">
                <sc-file-import :apiObj="$API.common.importFile" title="导入快递单号" :data="{otherData:'demo'}" templateUrl="http://www.scuiadmin/file.xlsx" accept=".xls, .xlsx" :maxSize="30" tip="请上传小于或等于 30M 的 .xls, .xlsx 格式文件" @success="success">
                    <template #default="{open}">
                        <el-button type="primary" icon="sc-icon-upload" @click="open">导入快递单号</el-button>
                    </template>
                    <template #uploader>
                        <el-icon class="el-icon--upload"><sc-icon-file-excel /></el-icon>
                        <div class="el-upload__text">
                            将文件拖到此处或 <em>点击选择文件上传</em>
                        </div>
                    </template>
                </sc-file-import>
            </template>
            <sc-file-export :apiObj="$API.common.exportFile" :data="searchKey" fileName="订单列表" async>
                <template #default="{open}">
                    <el-button type="danger" icon="sc-icon-download" @click="open">导出</el-button>
                </template>
            </sc-file-export>
        </div>
    </div>
</template>

<script>
import scFileExport from '@/components/scFileExport'
import scFileImport from '@/components/scFileImport'
export default {
    components: {
        scFileExport,scFileImport
    },
    props: {
        dataSelect: { type: Array, default: () => [] },
        dataSelectFull: { type: Array, default: () => [] },
        trade: { type: String, default: "0" },
    },
    data(){
        return {

        }
    },
    methods: {
        table_add(){
            this.$router.push('/merchant/goods/add')
        },
        table_sync(){
            this.$confirm(`发起同步后，请耐心等待1-2分钟后再刷新当前数据列表`, '提示', {
                type: 'warning'
            }).then(async () => {
                var resp = await this.$API.category.sync.get();
                if (resp.code == 0) {
                    return this.$message.error(resp.msg);
                }
                this.$message.success(resp.msg);
                this.$emit("success");
            }).catch(() => {

            })
        },
        table_batch_status(status){
            if (this.dataSelect.length == 0) {
                return this.$message.error("请选择修改数据")
            }
            this.$confirm(`审核中的商品不支持该操作，请确认是否有勾选审核中的商品`, '提示', {
                type: 'warning'
            }).then(async () => {
                var loading = this.$loading()
                let submitData = {"id":this.dataSelect,"value":status,"field":"status","type":"batch"};
                loading.close()
                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");
            }).catch(() => {

            })
        },
        handleSuccess(){
            this.$emit("success");
        }
    }
}
</script>