<template>
    <div>
        <Modal 
            v-model="currentShowPreModal"  
            scrollable 
            width="60"
            @on-cancel="hideModal">
            <!-- :loading="loading" -->
            <p slot="header">
                <span>预览查询结果</span>
            </p>
            <Table border :columns="columns1" :data="premodel"></Table>
        </Modal>
</div>
</template>
<script>

export default {
    props: ['showPreModal', 'predata'],
    data() {
        return {
            // loading: false,
            currentShowPreModal: this.showPreModal,
            currentpremodel: this.premodel,
            columns1: [
                    {
                        title: 'area',
                        key: 'area'
                    },
                    {
                        title: 'num',
                        key: 'num'
                    },
                    {
                        title: 'name',
                        key: 'name'
                    }
                ],
                premodel: [
                    {
                        area: 'John Brown',
                        num: 18,
                        name: 'New York No. 1 Lake Park',
                        
                    },
                    {
                        area: 'Jim Green',
                        num: 24,
                        name: 'London No. 1 Lake Park',
                        
                    },
                    {
                        area: 'Joe Black',
                        num: 30,
                        name: 'Sydney No. 1 Lake Park',
                        
                    },
                   
                ]
        }
    },
    watch: {
        showPreModal (newV, oldV) {
            this.currentShowPreModal = newV
        },
        currentsqlmodel (newV, oldV) {
            this.currentsqlmodel = newV
        }
    },
    methods: {
        hideModal() {
            this.$emit("clickedhidemodal", false);
        },
        handleSubmit () {
            // this.loading = true
            this.$refs['sqlmodelForPre'].validate((valid) => {
                if (valid) {
                    if (this.modelTitle == '新增') {
                        saveItem(this.currentsqlmodel).then(res => {
                            // this.loading = false
                            if (res.data.code == 0) {
                                this.$Message.success('添加成功!');
                            } else {
                                this.$Message.error(res.data.message);
                            }
                            this.$emit("clickedhidemodal", false)
                        })
                    } else {
                        updateItem(this.currentsqlmodel).then(res => {
                            // this.loading = false
                            if (res.data.code == 0) {
                                this.$Message.success('修改成功!');
                            } else {
                                this.$Message.error(res.data.message);
                            }
                            this.$emit("clickedhidemodal", false)
                        })
                    }
                    
                } else {
                    this.$Message.error('请注意格式!');
                }
            })
        }
    },
    mounted () {
  }
}
</script>

<style>
/* @import '../../assets/icon/iconfont.css'; */
.inpw{
    width: 300px;
    margin-left:4%
}
</style>
