1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
| <template> <div style="margin-top:10px; width:40%"> <el-form :model="cmsPage" :rules="rules" ref="cmsPageForm" label-width="100px" class="demo-ruleForm"> <el-form-item label="站点ID" prop="siteId"> <!-- 站点ID下拉选择 --> <el-select v-model="cmsPage.siteId" placeholder="请选择站点"> <el-option v-for="item in cmsSiteList" :key="item.siteId" :label="item.siteName" :value="item.siteId"> </el-option> </el-select> </el-form-item> <el-form-item label="模板ID" prop="templateId"> <!-- 模板ID下拉选择 --> <el-select v-model="cmsPage.templateId" placeholder="请选择模板"> <el-option v-for="item in cmsTemplateList" :key="item.templateId" :label="item.templateName" :value="item.templateId"> </el-option> </el-select> </el-form-item> <el-form-item label="页面名称" prop="pageName"> <el-input v-model="cmsPage.pageName"></el-input> </el-form-item> <el-form-item label="别名" prop="pageAliase"> <el-input v-model="cmsPage.pageAliase"></el-input> </el-form-item> <el-form-item label="访问路径" prop="pageWebPath"> <el-input v-model="cmsPage.pageWebPath"></el-input> </el-form-item> <el-form-item label="物理路径" prop="pagePhysicalPath"> <el-input v-model="cmsPage.pagePhysicalPath"></el-input> </el-form-item> <el-form-item label="类型" prop="pageType"> <el-radio-group v-model="cmsPage.pageType"> <el-radio label="0">静态</el-radio> <el-radio label="1">动态</el-radio> </el-radio-group> </el-form-item> <el-form-item label="创建日期" prop="pageCreateTime"> <el-date-picker v-model="cmsPage.pageCreateTime" type="datetime" placeholder="选择日期时间"> </el-date-picker> </el-form-item> <el-form-item> <el-button @click="goBack">返回</el-button> <el-button type="primary" @click="onSubmit('cmsPageForm')">提交</el-button> </el-form-item> </el-form> </div> </template>
<script> import * as cmsApi from '../api/cms' export default { data() { return { cmsPage: { siteId:'', templateId:'', pageName: '', pageAliase: '', pageWebPath: '', pageParameter:'', pagePhysicalPath:'', pageType:'', pageCreateTime: new Date() }, cmsSiteList:[], cmsTemplateList:[], rules: { siteId: [ { required: true, message: '请选择站点', trigger: 'change'} ], templateId: [ { required: true, message: '请选择模板', trigger: 'change' } ], pageCreateTime: [ { type: 'date', required: true, message: '请选择创建时间', trigger: 'change' } ], pageName: [ { required: true, message: '请输入页面名称', trigger: 'blur' } ], pageWebPath: [ { required: true, message: '请输入页面名称', trigger: 'blur' } ], pagePhysicalPath: [ { required: true, message: '请输入页面名称', trigger: 'blur' } ], pageType: [ { required: true, message: '请选择页面类型', trigger: 'change' } ] } } }, methods: { // 查询所有站点cmsSite cmsSiteQueryAll:function() { cmsApi.site_list_all().then(res => { this.cmsSiteList = res.queryResult.list }) }, // 查询所有模板cmsTemplate cmsTemplateQueryAll:function() { cmsApi.template_list_all().then(res => { this.cmsTemplateList = res.queryResult.list }) }, onSubmit:function(formname) { // 校验表单 this.$refs[formname].validate((valid) => { if (valid) {// 校验通过 this.$confirm('确认提交?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'info' }).then(() => { cmsApi.add(this.cmsPage).then(res => { this.$message({ showClose: true, message: res.message, type: 'success' }) // 清空数据 this.cmsPage = {} // 回退页面 this.goBack() }).catch(res => { this.$message({ showClose: true, message: '系统异常', type: 'error' }) }) }) } else { this.$message({ showClose: true, message: '提交失败,请检查是否正确录入数据!', type: 'error' }); } }); }, goBack:function() { if (this.$route.query.page) { // 返回 this.$router.push({ path:'/cms/page/list', query: { page:this.$route.query.page, siteId:this.$route.query.siteId } }) } else { this.$router.push({ path:'/cms/page/list' }) } } }, created() { }, mounted() { this.cmsSiteQueryAll() this.cmsTemplateQueryAll() } } </script>
|