<template>
    <scTable ref="table" :apiObj="list.apiObj" :params="searchKey" @selectionChange="selectionChange" row-key="id">
        <el-table-column label="保证金流水号" width="220" prop="order_sn" fixed="left"></el-table-column>
        <el-table-column label="所属商家" prop="id" width="280">
            <template #default="scope">
                <div class="goods-img">
                    <div class="name" v-if="scope.row.poi">
                        <span>{{ scope.row.poi.poi_name }}</span>
                        <span class="dec">{{ scope.row.poi.poi_address }}</span>
                    </div>
                    <div v-else>-</div>
                </div>
            </template>
        </el-table-column>
        <el-table-column label="交易金额" prop="id">
            <template #default="scope">
                <div class="price">{{ $TOOL.money(scope.row.money) }}</div>
            </template>
        </el-table-column>
        <el-table-column label="状态" prop="id">
            <template #default="scope">
                <div class="status-success" v-if="scope.row.status==1"><sc-status-indicator type="success"></sc-status-indicator> 已生效</div>
                <div class="status-danger" v-if="scope.row.status==0"><sc-status-indicator type="danger"></sc-status-indicator> 待生效</div>
                <div class="status-info" v-if="scope.row.status==2"><sc-status-indicator type="info"></sc-status-indicator> 核查中</div>
            </template>
        </el-table-column>
        <el-table-column label="时间" prop="create_at"></el-table-column>
        <el-table-column label="交易类型" prop="type">
            <template #default="scope">
                <div class="status-success" v-if="scope.row.type==1"><sc-status-indicator type="success"></sc-status-indicator> 充值</div>
                <div class="status-danger" v-if="scope.row.type==2"><sc-status-indicator type="danger"></sc-status-indicator> 商责赔付扣款</div>
                <div class="status-success" v-if="scope.row.type==3"><sc-status-indicator type="danger"></sc-status-indicator> 商责赔付退款</div>
                <div class="status-danger" v-if="scope.row.type==4"><sc-status-indicator type="danger"></sc-status-indicator> 商责扣罚扣款</div>
                <div class="status-success" v-if="scope.row.type==5"><sc-status-indicator type="danger"></sc-status-indicator> 商责扣罚退款</div>
                <div class="status-danger" v-if="scope.row.type==6"><sc-status-indicator type="danger"></sc-status-indicator> 保证金退回</div>
            </template>
        </el-table-column>
        <!-- <el-table-column label="操作" width="180" align="right" fixed="right">
            <template #default="scope">
                <el-button-group>
                    <el-button size="small" text @click="table_update(scope.row)">查看详情</el-button>
                </el-button-group>
            </template>
        </el-table-column> -->
    </scTable>
</template>

<script>
export default {
    data(){
        return {
            list: {
                apiObj: this.$API.deposit.list
            },
            dataSelect:[],
            dataSelectFull:[],
            searchKey:{}
        }
    },
    
    methods: {
        async getTotal(){
            var resp = await this.$API.merDeposit.data.get();
            if (resp.code == 1) {
                this.$emit("total",resp.data);
            }
        },
        table_auth(data){
            this.$nextTick(() => {
                this.$refs.comboMain.open("edit").setData(data)
            })
        },
        table_update(data){
            this.$confirm(`更新后可能数据没有变化，确定更新该达人的基础数据吗？`, '提示', {
                type: 'warning'
            }).then(async ()=>{
                var resp = await this.$API.merStar.update.post({"id":data.id});
                if (resp.code == 0) {
                    return this.$message.error(resp.msg);
                }
                this.$message.success(resp.msg);
                this.$refs.table.refresh()
            }).catch(()=>{})
        },
        table_life(data){
            this.$confirm(`来客下架成功后，在小程序中将不展示该商品，同时也将无法二次上架`, '提示', {
                type: 'warning'
            }).then(async ()=>{
                var resp = await this.$API.merGoods.off.post({"id":data.id});
                if (resp.code == 0) {
                    return this.$message.error(resp.msg);
                }
                this.$message.success(resp.msg);
                this.$emit("success");
            }).catch(()=>{})
        },
        table_view(data){
            this.$router.push({path:"/merchant/goods/edit",query:{"product_id":data.product_id,"id":data.id,"spm":(new Date()).getTime()}})
        },
        table_del(data){
            this.$confirm(`删除店铺后，所有有关该店铺的门店、订单等信息都将删除，不可恢复，确定要执行删除吗`, '提示', {
                type: 'warning'
            }).then(async ()=>{
                var resp = await this.$API.shop.del.post({"id":data.id});
                if (resp.code == 0) {
                    return this.$message.error(resp.msg);
                }
                this.$message.success(resp.msg);
                this.$emit("success");
            }).catch(()=>{})
        },
        refresh(){
            this.$refs.table.refresh()
        },
        upData(data){
            this.$refs.table.upData(data)
        },
        handleSuccess(){
            this.$refs.table.refresh()
        },
        sortChange(event){
            if (event.order) {
                var data = {
                    "field":event.prop,
                    "order":event.order
                }
                this.$refs.table.upData(data)
            } else {
                this.$refs.table.reload(this.searchKey)
            }
            return ;
        },
        selectionChange(event){
            this.dataSelect = [];
            var arr = [];
            var arrCompany = [];
            event.forEach(function(val,index){
                arr[index] = val.id;
                arrCompany[index] = val;
            });
            this.dataSelectFull = arrCompany;
            this.dataSelect = arr;
            this.$emit("success",this.dataSelect);
            this.$emit("successFull",this.dataSelectFull);
        },
        table_passwd(row){
            this.$nextTick(() => {
                this.$refs.userPasswd.open("edit").setData(row)
            })
        }
    }
}
</script>

<style>
.goods-img{display: flex;gap: 5px;}
.goods-img .name span{display: block;}
.goods-img .name span.dec{color: #999;font-size: 12px;}
.goods-price,.price{display: flex;align-items: center;gap: 5px;font-size: 14px;}
.goods-price .del{text-decoration: line-through;}
.goods-price span{background-color: #fff !important;
    border: 1px solid #d3d9e0 !important;
    border-radius: 4px;
    box-sizing: border-box;
    color: #6c737a !important;
    display: inline-flex;
    flex: none;
    font-size: 12px;
    line-height: 18px !important;
    padding: 1px 6px !important;text-decoration: none;}
</style>