<template>
    <div class="app-container">
        <el-card>
            <el-descriptions :column="4" direction="vertical" :label-style="{ 'text-align': 'center' }" :content-style="{ 'text-align': 'center', color: '#ff4949', 'font-size': '20px', 'font-weight': 'bold' }">
                <el-descriptions-item label="本月订单金额(元)">{{ todayOrderAmount }}</el-descriptions-item>
                <el-descriptions-item label="本月收衣数(件)">{{ todayOrderClothCount }}</el-descriptions-item>
                <el-descriptions-item label="本月商品销售(件)">{{ todayOrderGoodsCount }}</el-descriptions-item>
                <el-descriptions-item label="本月充值金额(元)">{{ todayChargeAmount }}</el-descriptions-item>
                <el-descriptions-item label="支付宝/微信(元)">{{ todayOnlinePayAmount }}</el-descriptions-item>
                <el-descriptions-item label="会员卡消费(元)">{{ todayCardAmount }}</el-descriptions-item>
                <el-descriptions-item label="现金消费(元)">{{ todayCashAmount }}</el-descriptions-item>
                <el-descriptions-item label="券消费(元)">{{ todayCouponAmount }}</el-descriptions-item>
            </el-descriptions>
        </el-card>
        <el-form :model="queryParams" ref="queryForm" @submit.native.prevent :inline="true" v-show="showSearch" label-width="68px" style="margin-top: 10px">
            <el-form-item label="创建时间">
                <el-date-picker v-model="monthTime" value-format="yyyy-MM" type="month" placeholder="选择月"> </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <!--    <el-row :gutter="10" class="mb8">-->
        <!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
        <!--    </el-row>-->

        <el-tabs v-model="tabs" @tab-click="onChangeTabs" type="border-card">
            <el-tab-pane label="洗衣订单"></el-tab-pane>
            <el-tab-pane label="商品订单"></el-tab-pane>

            <el-table v-loading="loading" fit highlight-current-row border stripe :data="tabs == '0' ? clothOrderList : goodsOrderList" style="margin-top: 10px">
                <el-table-column label="订单编号" align="center" prop="orderNo" width="200" fixed="left" />
                <el-table-column :label="tabs == '0' ? '衣服件数' : '商品数量'" align="center">
                    <template slot-scope="scope">
                        {{ tabs == '0' ? scope.row.orderClothCount : scope.row.orderGoodsCount }}
                    </template>
                </el-table-column>
                <el-table-column label="总金额（元）" align="center" prop="orderAmount">
                    <template slot-scope="scope">
                        {{ tabs == '0' ? scope.row.orderAmount : scope.row.totalPrice }}
                    </template>
                </el-table-column>
                <el-table-column label="支付状态" align="center" v-if="tabs == '0'">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.hasPay" />
                    </template>
                </el-table-column>
                <el-table-column label="支付状态" align="center" v-if="tabs == '1'">
                    <template slot-scope="scope">
                        {{ scope.row.orderStatus == '0' || scope.row.orderStatus == '0' ? '否' : '是' }}
                    </template>
                </el-table-column>
                <el-table-column label="支付方式" align="center" prop="payType">
                    <template slot-scope="scope">
                        <dict-tag :options="dict.type.recharge_pay_type" :value="scope.row.payType" />
                    </template>
                </el-table-column>
                <el-table-column label="客户姓名" align="center" prop="userName" />
                <el-table-column label="客户手机号" align="center" prop="phoneNumber" />
                <el-table-column label="订单时间" align="center" prop="createTime" />
            </el-table>
        </el-tabs>
        <pagination v-show="clothTotal > 0" :total="clothTotal" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import { listFinancialStatisticsByClothOrderMonth } from '@/api/order/cloth'

export default {
    name: 'manageMonth',
    dicts: ['sys_yes_no', 'recharge_pay_type', 'order_type'],
    data() {
        return {
            tabs: '0',
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            clothTotal: 0,
            goodsTotal: 0,
            // 洗衣订单衣服明细表格数据
            clothOrderList: [],
            goodsOrderList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                beginCreateTime: '',
                endCreateTime: ''
            },
            createTimeRange: [],
            todayCardAmount: 0,
            todayCashAmount: 0,
            todayChargeAmount: 0,
            todayCouponAmount: 0,
            todayOnlinePayAmount: 0,
            todayOrderAmount: 0,
            todayOrderClothCount: 0,
            todayOrderGoodsCount: 0,
            pickerOptions: {
                onPick: this.getPickDate,
                disabledDate: this.disabledDate
            },
            pickDate: '', // 存放getPickDate获取的数据
            monthTime: ''
        }
    },
    created() {
        this.getList()
    },
    methods: {
        onChangeTabs() {
            this.handleQuery()
        },
        getList() {
            this.loading = true
            this.queryParams.monthTime = this.monthTime
            listFinancialStatisticsByClothOrderMonth(this.queryParams).then((response) => {
                this.clothOrderList = response.data.orderClothFinancialVOList
                this.goodsOrderList = response.data.goodsOrderFinancialVOList
                this.clothTotal = response.data.clothTotal
                this.goodsTotal = response.data.goodsTotal
                this.todayCardAmount = response.data.todayCardAmount
                this.todayCashAmount = response.data.todayCashAmount
                this.todayChargeAmount = response.data.todayChargeAmount
                this.todayCouponAmount = response.data.todayCouponAmount
                this.todayOnlinePayAmount = response.data.todayOnlinePayAmount
                this.todayOrderAmount = response.data.todayOrderAmount
                this.todayOrderClothCount = response.data.todayOrderClothCount
                this.todayOrderGoodsCount = response.data.todayOrderGoodsCount
                this.loading = false
            })
        },
        // 取消按钮
        cancel() {
            this.open = false
            this.reset()
        },
        // 表单重置
        reset() {
            this.resetForm('form')
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.monthTime = null
            this.queryParams.monthTime = null
            this.resetForm('queryForm')
            this.handleQuery()
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        checkClose(done) {
            this.$confirm('是否关闭表单，关闭后数据将丢失？')
                .then(function () {
                    done()
                })
                .then(() => {})
                .catch(() => {})
        }
    }
}
</script>
