<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="helpCenterAssociation.selfId"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="标题层级" 
		                            placeholder="请输入标题层级"
		                            v-model="helpCenterAssociation.levelStatus"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="创建人" 
		                            placeholder="请输入创建人"
		                            v-model="helpCenterAssociation.createBy"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="创建时间" 
		                            placeholder="请输入创建时间"
		                            v-model="helpCenterAssociation.createDate"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="修改人" 
		                            placeholder="请输入修改人"
		                            v-model="helpCenterAssociation.updateBy"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="修改时间" 
		                            placeholder="请输入修改时间"
		                            v-model="helpCenterAssociation.updateDate"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="关系表备用选项1" 
		                            placeholder="请输入关系表备用选项1"
		                            v-model="helpCenterAssociation.assReplaceable1"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="关系表备用选项2" 
		                            placeholder="请输入关系表备用选项2"
		                            v-model="helpCenterAssociation.assReplaceable2"></layui-inline-input>
		                    </layui-item>
							<layui-item>
		                        <layui-inline-input
		                            label="关系表备用选项3" 
		                            placeholder="请输入关系表备用选项3"
		                            v-model="helpCenterAssociation.assReplaceable3"></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="saveHelpCenterAssociation"><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/helpCenterAssociation'
import Base from "@/views/base/Base"

export default {
	name: 'HelpCenterAssociationForm',
	extends: Base,
    data () {
        return {
            helpCenterAssociation: {
                id: this.$route.params.id,
				selfId: '',
				levelStatus: '',
				createBy: '',
				createDate: '',
				updateBy: '',
				updateDate: '',
				assReplaceable1: '',
				assReplaceable2: '',
				assReplaceable3: '',
            },
        }
    },
    computed: {
       	
	},
	watch: {
        
    },
    mounted () {
        this.initData();
		this.$nextTick(() => {
			this.layuiInit();
		});
    },
    methods: {
    	save: function(){  
    		this.submitHandler((token) => {    		
	            saveOrUpdate(JSON.stringify(this.helpCenterAssociation), token).then(result => {
	                alert(result.msg);
	                this.backListView(this.helpCenterAssociation.id == null);
	            }).catch((error) => {
	                // 此处你的业务代码
	                this.resetToken();
	            });
    		});
    	},
        initData: function(){
            if(this.helpCenterAssociation.id){
                get(this.helpCenterAssociation.id).then(result => {
                    var data = result.data;
                    if(data) {
                        this.helpCenterAssociation =  data.helpCenterAssociation || this.helpCenterAssociation;
                    }
                });
            }
            
        	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(saveHelpCenterAssociation)', function(data){
					_this.save();
					return false;
				});
        	});
        }
    }
}
</script>

<style scoped>

</style>