<template>
    <scTable ref="table" :apiObj="list.apiObj" :params="searchKey" @selectionChange="selectionChange" row-key="id">
        <el-table-column type="selection" width="50" fixed="left"></el-table-column>
        <el-table-column label="会员ID" prop="openid" width="220" fixed="left"></el-table-column>
        <el-table-column label="会员卡号" prop="card_no">
            <template #default="scope">
                {{ scope.row.card_no?scope.row.card_no:'-' }}
            </template>
        </el-table-column>
        <el-table-column label="订单编号" prop="order_sn">
            <template #default="scope">
                {{ scope.row.order_sn?scope.row.order_sn:'-' }}
            </template>
        </el-table-column>
        <el-table-column label="类型" prop="type">
            <template #default="scope">
                <el-tag type="error" v-if="scope.row.type == 1">支出</el-tag>
                <el-tag type="success" v-if="scope.row.type == 2">收入</el-tag>
            </template>
        </el-table-column>
        <el-table-column label="金额" prop="money">
            <template #default="scope">
                ¥{{ scope.row.money }}
            </template>
        </el-table-column>
        <el-table-column label="余额" prop="money">
            <template #default="scope">
                {{ $TOOL.money(scope.row.balance) }}
            </template>
        </el-table-column>
        <el-table-column label="其他" prop="order_sn" width="220">
            <template #default="scope">
                {{ scope.row.remark?scope.row.remark:'-' }}
            </template>
        </el-table-column>
        <el-table-column label="时间" prop="create_at" width="180"></el-table-column>
    </scTable>
</template>

<script>
export default {
    props: {
        type: { type: String, default: "1" }
    },
    data(){
        return {
            colorData:['','彩色','黑白'],
            duplexData:['','单面','双面'],
            list: {
                apiObj: this.$API.mUser.log
            },
            status: ['待支付','待打印', '打印失败', '已打印','申请退款','退款失败','已退款'],
            ostatus: ['-','店内打印', '远程自取', '商家配送'],
            payStatus:['-','微信','会员卡'],
            visible:false,
            dataSelect:[],
            dataSelectFull:[],
            searchKey:{}
        }
    },
    methods:{
        table_edit(data){
            this.$nextTick(() => {
                this.$refs.formMain.open("edit",this.type).setData(data)
            })
        },
        table_del(data){
            this.$confirm("确定要删除该数据吗？","删除确认",{type: 'warning'}).then(async ()=>{
                var resp = await this.$API.mPrice.del.post({"id":data.id,"type":""});
                if (resp.code == 0) {
                    return this.$message.error(resp.msg)
                }
                this.$message.success(resp.msg)
                this.$refs.table.refresh()
            }).catch(()=>{});
        },
        refresh(){
            this.$refs.table.refresh()
        },
        upData(data){
            this.$refs.table.upData(data)
        },
        handleSuccess(){
            this.$refs.table.refresh()
        },
    }
}
</script>

<style>
.price{display: flex;align-items: center;}
.del{text-decoration: line-through;margin-left: 5px;color: #f00;}
</style>