<template>
    <div class="view-product" v-cloak>
        <div class="animated fadeInRight">
            <div class="ibox-content">
                <layui-form>
	                <layui-fieldset label="XX信息">
	                	<template slot="main">
		                								<layui-item>
		                        <layui-inline-input
		                            label="关联表id"
		                            placeholder="请输入关联表id"
		                            v-model="helpCenter.associationId"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="菜单名称"
		                            placeholder="请输入菜单名称"
		                            v-model="helpCenter.menuName"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="语言"
		                            placeholder="请输入语言"
		                            v-model="helpCenter.language"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="菜单类型"
		                            placeholder="请输入模块类型"
		                            v-model="helpCenter.modelType"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="菜单查询url"
		                            placeholder="请输入模块查询url"
		                            v-model="helpCenter.modelGetUrl"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="创建人"
		                            placeholder="请输入创建人"
		                            v-model="helpCenter.createBy"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="创建时间"
		                            placeholder="请输入创建时间"
		                            v-model="helpCenter.createDate"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="修改人"
		                            placeholder="请输入修改人"
		                            v-model="helpCenter.updateBy"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="修改时间"
		                            placeholder="请输入修改时间"
		                            v-model="helpCenter.updateDate"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="备用选项1"
		                            placeholder="请输入备用选项1"
		                            v-model="helpCenter.replaceable1"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="备用选项2"
		                            placeholder="请输入备用选项2"
		                            v-model="helpCenter.replaceable2"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="备用选项3"
		                            placeholder="请输入备用选项3"
		                            v-model="helpCenter.replaceable3"></layui-inline-input>
		                    </layui-item>
						</template>
					</layui-fieldset>
					<layui-inline class="btn-group-center">
                        <button class="layui-btn layui-btn-lg layui-btn-blue" lay-submit lay-filter="saveHelpCenter"><i class="fa fa-save"></i> 保存</button>
                        <button @click="close" class="layui-btn layui-btn-lg layui-btn-red"><i class="fa fa-times"></i> 关闭</button>
                    </layui-inline>
                </layui-form>
            </div>
        </div>
	</div>
</template>

<script>
import { getDicts } from '@/api/dict'
import { saveOrUpdate, get } from '@/api/help/helpCenter'
import Base from "@/views/base/Base"

export default {
	name: 'HelpCenterForm',
	extends: Base,
    data () {
        return {
            helpCenter: {
                id: this.$route.params.id,
				associationId: '',
				menuName: '',
				language: '',
				modelType: '',
				modelGetUrl: '',
				createBy: '',
				createDate: '',
				updateBy: '',
				updateDate: '',
				replaceable1: '',
				replaceable2: '',
				replaceable3: '',
            },
        }
    },
    computed: {

	},
	watch: {

    },
    mounted () {
        this.initData();
		this.$nextTick(() => {
			this.layuiInit();
		});
    },
    methods: {
    	save: function(){
    		this.submitHandler((token) => {
	            saveOrUpdate(JSON.stringify(this.helpCenter), token).then(result => {
	                alert(result.msg);
	                this.backListView(this.helpCenter.id == null);
	            }).catch((error) => {
	                // 此处你的业务代码
	                this.resetToken();
	            });
    		});
    	},
        initData: function(){
            if(this.helpCenter.id){
                get(this.helpCenter.id).then(result => {
                    var data = result.data;
                    if(data) {
                        this.helpCenter =  data.helpCenter || this.helpCenter;
                    }
                });
            }

        	getDicts('').then(result => {
                var data = result.data;
                if(data){
                }
            });
        },
        layuiInit: function(){
            var _this = this;
        	layui.use(['element', 'form'], function(){
        		var element = element
        		,form = layui.form;

				//自定义验证规则
				form.verify({
					title: function(value){
					    if(value.length < 10){
					    	return '标题至少得10个字符哟';
					    }
					}
					,content: function(value){
					    layedit.sync(editIndex);
					}
				});

				form.on('submit(saveHelpCenter)', function(data){
					_this.save();
					return false;
				});
        	});
        }
    }
}
</script>

<style scoped>

</style>
