From 894dd034da2c3b466f0ee80db36342d4b0d01ebc Mon Sep 17 00:00:00 2001 From: 明梦爽 <2972214568@qq.com> Date: 星期三, 26 一月 2022 23:18:03 +0800 Subject: [PATCH] 管理权限整好 --- src/components/Administrator/Edit.vue | 113 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 99 insertions(+), 14 deletions(-) diff --git a/src/components/Administrator/Edit.vue b/src/components/Administrator/Edit.vue index 94447f1..16e10cc 100644 --- a/src/components/Administrator/Edit.vue +++ b/src/components/Administrator/Edit.vue @@ -1,33 +1,118 @@ <template> - <div> - <quill-editor ref="text" v-model="content" class="myQuillEditor" :options="editorOption" /> - <el-button type="primary" @click="submit">鎻愪氦</el-button> + <div class="box"> + <el-row><h3 style="margin-top: 0px">{{ $route.query.title }}</h3></el-row> + 鏂伴椈鏍囬锛�<el-input v-model="title" placeholder="璇疯緭鍏ユ柊闂绘爣棰�"></el-input><br/><br/> + 鍙戝竷鏃ユ湡锛�<el-date-picker format="yyyy 骞� MM 鏈� dd 鏃�" value-format="yyyy-MM-dd" v-model="releaseTime" placeholder="璇烽�夋嫨鏂伴椈鍙戝竷鏃ユ湡"></el-date-picker><br/><br/> + <!-- <el-upload + class="upload-demo" + ref="upload" + drag + action + :auto-upload="false" + :http-request="httpRequest" + multiple + :file-list="fileList"> + <i class="el-icon-upload"></i> + <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div> + <div class="el-upload__tip" slot="tip">鍙兘涓婁紶jpg/png鏂囦欢锛屼笖涓嶈秴杩�500kb</div> + </el-upload><br/> --> + 鏂伴椈鍐呭锛�<quill-editor ref="text" v-model="content" class="myQuillEditor" :options="editorOption" /> + <el-row style="margin-top:50px;"> + <el-button type="success" @click="submit">鍙戝竷</el-button> + </el-row> </div> </template> <script> +import { add } from '../../api/api' import { quillEditor } from 'vue-quill-editor' import 'quill/dist/quill.core.css' import 'quill/dist/quill.snow.css' import 'quill/dist/quill.bubble.css' - export default { components:{ quillEditor }, - data () { + data(){ return { - content: '', - editorOption: {} , + title:'', //鏍囬鍐呭 + releaseTime:'', //鍙戝竷鏃ユ湡 + content: '', //鏂伴椈鍐呭 + newsCategoryId:2, + editorOption: { + placeholder: "璇疯緭鍏ユ鏂�", + // editorOption閲屾槸鏀惧浘鐗囦笂浼犻厤缃弬鏁扮敤鐨勶紝渚嬪锛� + action: '/api/product/richtext_img_upload.do', // 蹇呭~鍙傛暟 鍥剧墖涓婁紶鍦板潃 + methods: 'POST', // 蹇呭~鍙傛暟 鍥剧墖涓婁紶鏂瑰紡 + token: '', // 鍙�夊弬鏁� 濡傛灉闇�瑕乼oken楠岃瘉锛屽亣璁句綘鐨則oken鏈夊瓨鏀惧湪sessionStorage + name: 'upload_file', // 蹇呭~鍙傛暟 鏂囦欢鐨勫弬鏁板悕 + size: 10000000, // 鍙�夊弬鏁� 鍥剧墖澶у皬锛屽崟浣嶄负Kb, 1M = 1024Kb + accept: 'multipart/form-data, image/png, image/gif, image/jpeg, image/bmp, image/x-icon,image/jpg' // 鍙�� 鍙笂浼犵殑鍥剧墖鏍煎紡 + } , //缂栬緫鍣ㄦ柊闂诲璞� + fileList:[], } }, - methods: { - submit () { - console.log(this.$refs.text.value) + created(){ + // console.log('>>>>>>>',this.$route.query.id); + this.newsCategoryId = this.$route.query.id + }, + methods:{ + // jsonData(formData){ var jsonData = {}; formData.forEach((value, key) => jsonData[key] = value); return jsonData }, + // httpRequest(params){ + // const pictureFile = params.file; + // const newsCategoryId = this.newsCategoryId; + // const content = this.content; + // const title = this.title; + // const releaseTime = this.releaseTime; + // var formData = new FormData(); + // formData.append("pictureFile",pictureFile) + // formData.append("newsCategoryId",newsCategoryId) + // formData.append("content",content) + // formData.append("title",title) + // formData.append("releaseTime",releaseTime) + // console.log(this.jsonData(formData)); + // add(this.jsonData(formData)).then(res => { + // console.log(res); + // if(res.code !== 200){ + // return this.$message.error('鍙戝竷鏂伴椈澶辫触锛岃閲嶈瘯锛�') + // }else{ + // this.$message.success('鏂伴椈鍙戝竷鎴愬姛锛�') + // console.log(this.content); + // this.$router.go(-1) + // } + // }) + // }, + submit(){ + // this.$refs.upload.submit(); + const data = { + newsCategoryId:this.newsCategoryId, + content:this.content, + title:this.title, + releaseTime:this.releaseTime + } + add(data).then(res => { + console.log(res); + if(res.code !== 200){ + return this.$message.error('鍙戝竷鏂伴椈澶辫触锛岃閲嶈瘯锛�') + }else{ + this.$message.success('鏂伴椈鍙戝竷鎴愬姛锛�') + console.log(this.content); + this.$router.go(-1) + } + }) } } } </script> -<style lang="less" scoped> -// .myQuillEditor{ -// height: 400px; -// } +<style lang="less" scoped> +.box{ + width: 1200px; + margin: 0 auto; +} +.myQuillEditor{ + height: 350px; +} +.btn{ + position: absolute; + bottom: 20px; + left: 168px; +} </style> \ No newline at end of file -- Gitblit v1.8.0