<template>
    <el-dialog id="tableBody" title="导入打款信息" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">

        <div style="margin-left:30%">
               <el-form label-position="left" label-width="120px"   :model="formLabelAlign">
                    <el-form-item label="请填写批次号：">
                         <el-col :span="12">
                            <el-input v-model="formLabelAlign.batchNo" ></el-input>
                         </el-col>
                    </el-form-item>
                    <el-form-item label="备注信息：" >
                        <el-col :span="12">
                            <el-input v-model="formLabelAlign.describle"></el-input>
                        </el-col>
                    </el-form-item>
                    <el-form-item label="选择文件："  > 
                        <div  style="width:240px;">
                            <el-upload
                                class="upload-demo"
                                ref="upload"
                                action=""
                                :on-preview="handlePreview"
                                :on-remove="handleRemove"
                                :file-list="fileList"
                                :auto-upload="false">
                                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                <div slot="tip" class="el-upload__tip">只能上传excel文件!</div>
                            </el-upload>
                        </div>
                    </el-form-item>
                </el-form>
        </div>

        <div slot="footer" style="margin-right:30%;">
            <el-button type="info" plain @click="handleClose">取 消</el-button>
            <el-button type="primary" @click="submitMarket">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    export default {
        name: "byhRegainMarket",
        props: {
            dialogVisible: {
                type: Boolean
            },
            certNo: {
                type: String
            },
        },
        data () {
            return {
                client: {},
                records: [],
                fileList: [],
                formLabelAlign: {
                    batchNo: '',
                    describle: '',
                },
            }
        },
        methods: {

            /** 关闭处理 */
            handleClose () {
                this.visible = false
                setTimeout(() => {
                    this.$emit('update:dialogVisible', false)
                }, 100)
            },

            submitMarket() {
                this.$$post('/raise/addRaiseDate/', this.buildParam()).then(res => {
                    if (res.data.code != 200) {
                        this.$message.error(res.data.message);
                        return
                    }
                    this.$message({message: '操作成功', type: 'success'});
                    this.handleClose();
                    window.location.reload();
                }).catch(error => {
                    this.$Message.error(error || '系统异常');
                });
            },
            // 文件上传
            handleRemove(file, fileList) {
                //console.log(file, fileList);
            },
            handlePreview(file) {
                //console.log(file);
            },
            handleExceed(files, fileList) {
                this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${ file.name }？`);
            },
              //参数
            buildParam() {
                var return_hash = new FormData();

                if (this.formLabelAlign.batchNo != '') {
                     return_hash.append('batchNo',this.formLabelAlign.batchNo)
                }

                if (this.formLabelAlign.describle != '') {
                     return_hash.append('describle',this.formLabelAlign.describle)
                }
                return_hash.append('createUser', localStorage.getItem("userName"))
               
                if (this.$refs.upload != '') {
                    return_hash.append('file',this.$refs.upload.uploadFiles[0].raw)
                }
                return return_hash;
            },

        }
    }
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">

#tableBody{
    text-align:center;
}
</style>