<template>
    <div class="flex-container">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <!-- 搜索区域 -->
            <a-form layout="inline">
                <a-row :gutter="24">
                    <a-col :md="6" :sm="12">
                        <a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="积分类型">
                        <a-select placeholder="请选择" v-model="queryParam.activityType">
                                <a-select-option key="">请选择</a-select-option>
                                <a-select-option key="个人活动">个人活动</a-select-option>
                                <a-select-option key="团队活动">团队活动</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <a-form-item :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}" label="积分小类">
                            <a-select placeholder="请选择" v-model="queryParam.subclass">
                                <a-select-option key="">请选择</a-select-option>
                                <a-select-option key="部长考核">部长考核</a-select-option>
                                <a-select-option key="前置营销">前置营销</a-select-option>
                                <a-select-option key="线上活动">线上活动</a-select-option>
                                <a-select-option key="线下活动">线下活动</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>

                    <a-col :md="4" :sm="12">
                        <a-form-item  label="姓名：">
                            <a-input  placeholder="" v-model="queryParam.name"></a-input>
                        </a-form-item>
                    </a-col>

                    <a-col :md="4" :sm="12">
                        <a-form-item  label="账号：">
                            <a-input  placeholder="" v-model="queryParam.account"></a-input>
                        </a-form-item>
                    </a-col>

                    <span class="table-page-search-submitButtons" style="float: left; overflow: hidden;">
                        <a-col :md="6" :sm="24">
                            <a-button @click="search()" type="primary">查询</a-button>
                            <a-button  v-show="!callback" @click="handleSubmit" style="margin-left: 10px">导出</a-button>
                            <a-button v-show="callback" style="margin-left: 10px">导出中<a-spin  style="margin-left: 5px" size="small"/></a-button>
                        </a-col>
                    </span>
                </a-row>
            </a-form>
           </div>

        <!--列表-->
        <s-table  :locale="emptyText" :columns="columns" :data="rowdata" bordered ref="table" size="small" class="flex-filling">

            <template slot="operation" slot-scope="text,record">
                <a  @click="modifyfunction(record)">审核</a>

            </template>
        </s-table>

        <!--编辑----弹框-->
<!--        <a-modal :title="titleName" :visible="modifyvisible"  @ok="createfunctionOk" @cancel="createfunctionCancel" html-type="submit" width="840px">
            <a-form :form="Formtable">

                <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="审核状态">
                    <a-radio-group  v-decorator="['status', {rules: [{ required: true, message: '审核状态不能为空！'}]} ]">
                        <a-radio value="2">通过</a-radio>
                        <a-radio value="3">不通过</a-radio>
                    </a-radio-group>
                </a-form-item>

                <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="所得积分">
                    <a-input placeholder="所得积分" v-decorator="[ 'integral', {rules: [{ required: true,type:'number', message: '所得积分不能为空！' ,whitespace:true,transform:(value)=> {return Number(value)} }]} ]"></a-input>
                </a-form-item>

                <a-form-item :labelCol="{span: 6}" :wrapperCol="{span: 8, offset: 1}" label="审核备注">
                    <a-input placeholder="审核备注" v-decorator="[ 'remark', {rules: [{ required: false }]} ]"></a-input>
                </a-form-item>

            </a-form>
        </a-modal>-->
    </div>
</template>

<script>
    import STable from '@/components/table';
    import {getIntegralList,exportIntegral,download} from "@/api/school-center/activityIntegralAPI"
    import {cloneObject,exportFile} from '@/utils/util';
    import moment from "moment";
    export default {
        name: "activityIntegral",
        components: {
            STable,
        },
        data: function () {
            return {
                emptyText: {emptyText: '暂无数据'},
                previewVisible: false,
                callback:false,
                previewImage: '',
                fileList: [
                ],

                fileid:{},
                // form
                Formtable: this.$form.createForm(this, {name: 'Formtable'}),
                titleName:"",
                modifyForm: {
                    id: '',
                    status: '',
                    integral: '',
                    remark: ''
                },
                subNameList: [],
                packageName:[],
                chosePages:[],
                products:[],
                //输入框列表
                queryParam: {
                    title: '',
                    activityType: '',
                    subclass: '',
                    name: '',
                    account: '',
                    startTime :'',
                    endTime  :'',
                    orderseq  :'',
                    orderUniversityName  :'',
                    status  :'',
                    ordername  :''
                },
                modifyvisible: false,
                columns: [
                    {dataIndex: 'name', width: 200, title: '姓名', align: "center"},
                    {dataIndex: 'account', width: 200, title: '账号', align: "center"},
                    {dataIndex: 'recordIntegral', width: 200, title: '所得积分', align: "center"},
                    {dataIndex: 'activityType', width: 200, title: '积分类型', align: "center"},
                    {dataIndex: 'subclass', width: 200, title: '积分小类', align: "center"},
                    {dataIndex: 'substName', width: 200, title: '县分', align: "center"},
                    {dataIndex: 'schoolName', width: 200, title: '学校', align: "center"},
                    {dataIndex: 'createTime', width: 200, title: '创建时间', align: "center"},
                    {
                        dataIndex: 'operation',
                        width: 200,
                        title: '操作',
                        align: "center",
                        scopedSlots: {customRender: 'operation'},
                        fixed: "right"
                    }]
                ,
                rowdata: parameter => {
                    let params = {
                        pageNo: parameter.pageNo,
                        pageSize: parameter.pageSize
                    }
                    //表示
                    let obj = cloneObject(this.queryParam)
                    return getIntegralList(Object.assign(params, obj)).then(res => {
                        let data = {}
                        if (res.state !== 'success') {
                            this.emptyText.emptyText = '查询失败！'
                            this.$message.error("查询失败！", 5);
                            data = {
                                data: [],
                                pageSize: parameter.pageSize,
                                pageNo: 1,
                                totalCount: 0
                            }
                        } else {
                            if (res.data.records.length==0){
                                return data
                            }
                            data = {
                                data: res.data.records,
                                pageSize: parameter.pageSize,
                                pageNo: parameter.pageNo,
                                totalCount: res.data.total
                            }
                        }
                        return data
                    })
                }
            }
        },
        methods:{
            chosePagesfunction(data){
                this.chosePages=data
            },
            search() {
                this.$refs.table.refresh({search: true})
            },
            handleSubmit() {
                let downqueryParam=this.queryParam
                let nowdate = moment().format('YYYY-MM-DD');
                this.callback=true;
                exportFile(exportIntegral(downqueryParam), "积分记录清单.xls",this.downloadstatu);
                //exportFile(download(downqueryParam), "宽带订单清单" + nowdate + ".xls",this.downloadstatu);
            },
            downloadstatu(){
                this.callback=false;
            }
        }
    }
</script>

<style scoped>

</style>
