From 6748bd905cbba6ef9459f2cc7d6b833a110b08d0 Mon Sep 17 00:00:00 2001 From: 明梦爽 <2972214568@qq.com> Date: 星期六, 22 一月 2022 23:03:12 +0800 Subject: [PATCH] 完善了一些 --- src/components/Administrator/Main.vue | 91 +++++++++++++++++++++++---------------------- 1 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/components/Administrator/Main.vue b/src/components/Administrator/Main.vue index 16ed775..5707748 100644 --- a/src/components/Administrator/Main.vue +++ b/src/components/Administrator/Main.vue @@ -15,7 +15,7 @@ <el-row :gutter="40"> <el-col :span="4"> <!-- 娣诲姞鏂伴椈鎸夐挳 --> - <el-button el-button class="add" type="success" icon="el-icon-plus" @click="goEdit()">鐐瑰嚮鍦ㄨ鍒楄〃涓嬫坊鍔犱竴鏉℃柊闂�</el-button> + <el-button el-button class="add" type="success" icon="el-icon-plus" @click="goEdit(newsCategoryId)">鐐瑰嚮鍦ㄨ鍒楄〃涓嬫坊鍔犱竴鏉℃柊闂�</el-button> </el-col> <el-col :span="10"> <!-- 鏂伴椈鎼滅储 --> @@ -50,22 +50,25 @@ </el-table-column> </el-table> - <div class="fenye"> + <!-- 鍒嗛〉 --> + <div> <!-- 鑾峰彇鏂伴椈鍒楄〃鍒嗛〉 --> - <div class="get"> + <div> <el-pagination + v-show="getShow" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" - :page-sizes="[3,6,12, 18,]" + :page-sizes="[6,12, 18,]" :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination> </div> <!-- 妯$硦鏂伴椈鍒楄〃鍒嗛〉 --> - <div class="fuzzy"> + <div> <el-pagination + v-show="fuzzyShow" @size-change="handleSizeChangefuzzy" @current-change="handleCurrentChangefuzzy" :current-page="fuzzyForm.fuzzycurrent" @@ -92,7 +95,8 @@ <el-input v-model="editForm.title"></el-input> </el-form-item> <el-form-item label="鍙戝竷鏃ユ湡:"> - <el-input v-model="editForm.releaseTime"></el-input> + <!-- <el-input v-model="editForm.releaseTime"></el-input> --> + <el-date-picker v-model="editForm.releaseTime" type="date" placeholder="璇烽�夋嫨鍙戝竷鏃ユ湡"></el-date-picker> </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> @@ -106,16 +110,17 @@ <script> import { getNewsList,getnew,update,deleteNew,fuzzy } from '../../api/api' -import axios from 'axios' export default { data() { return { + fuzzyShow:false, //妯$硦鏌ヨ鍒嗛〉鐨勬樉绀�(甯冨皵鍊�) + getShow:true, //鑾峰彇鍒嗛〉鐨勬樉绀�(甯冨皵鍊�) visible: false, editDialogVisible:false, //鎺у埗淇敼瀵硅瘽妗嗙殑甯冨皵鍊� editForm:{}, //鏌ヨ鍒扮殑鏂伴椈瀵硅薄锛岀洰鍓嶄粎渚涗慨鏀逛娇鐢� newsCategoryId:1, //鍏堝瓨涓�涓皬鏍囬id tableData:[], //鏂伴椈鍒楄〃瀵硅薄 - pageSize:3, //姣忛〉鏉℃暟 + pageSize:6, //姣忛〉鏉℃暟 currentPage:1, //褰撳墠椤� total:0, //鏂伴椈鎬绘潯鏁� fuzzyForm:{ fuzzytitle:'',fuzzytotal:0,fuzzycurrent:1,fuzzysize:6 }, //妯$硦鏌ヨ鍒楄〃瀵硅薄 @@ -216,8 +221,8 @@ }, //绾ц仈閫夋嫨鍣ㄧ殑鏂规硶 handleChange(value) { - console.log(value); - console.log(value[1]); + // console.log(value); + // console.log(value[1]); this.newsCategoryId = value[1]; //灏嗗緱鍒扮殑灏忔爣棰榠d瀛樻斁璧锋潵 this.query(this.newsCategoryId); }, @@ -228,7 +233,7 @@ size:this.pageSize }; getNewsList(data).then(res=>{ - console.log(res); + // console.log(res); if (res.code !== 200) { return this.$message.error('鑾峰彇鏂伴椈鍒楄〃澶辫触') }else{ @@ -242,7 +247,7 @@ //灞曠ず淇敼瀵硅瘽妗� showEditDialog(id){ getnew(id).then(res => { - console.log(res); + // console.log(res); if (res.code == 200) { this.editForm = res.data } @@ -251,40 +256,35 @@ }, //纭畾淇敼琛ㄥ崟鎻愪氦锛岄獙璇佸彂璧疯姹� editNew(){ - // console.log(typeof(this.editForm.releaseTime)); - // console.log(this.editForm.releaseTime); - let arr = this.editForm.releaseTime.split('') - if(arr[4] !== '/' || arr[7] !== '/'){ - return this.$message.error('璇锋寜鐓р�淴XXX/XX/XX鈥濈殑鏍煎紡濉啓鏃ユ湡') - }else{ - const data = { - id: this.editForm.id, - releaseTime: this.editForm.releaseTime, - title:this.editForm.title - } - update(data).then(res=>{ - console.log('dsadasas'+res); - if (res.code == 200) { - this.editDialogVisible =false; - this.$message.success('淇敼鏂伴椈鎴愬姛锛�') - this.query(this.newsCategoryId); - } - }) + const data = { + id: this.editForm.id, + releaseTime: this.editForm.releaseTime, + title:this.editForm.title } + update(data).then(res=>{ + // console.log('dsadasas',res); + if (res.code == 200) { + this.editDialogVisible =false; + this.$message.success('淇敼鏂伴椈鎴愬姛锛�') + this.query(this.newsCategoryId); + } + }) }, //妯$硦鏌ヨ fuzzyList(title){ - console.log(title); + // console.log(title); if(title == ''){ return this.$message.error('璇峰厛杈撳叆鏌ヨ鏂伴椈鏍囬锛�') } + this.fuzzyShow = true //妯$硦鍒嗛〉鏄剧ず + this.getShow = false //鑾峰彇鍒嗛〉闅愯棌 const data = { current: this.fuzzyForm.fuzzycurrent, size: this.fuzzyForm.fuzzysize, title:title } fuzzy(data).then(res => { - console.log(res); + // console.log(res); if (res.code !== 200) { return this.$message.error('鏌ヨ鏂伴椈鍒楄〃澶辫触') }else{ @@ -299,10 +299,12 @@ qingKong(){ this.tableData = [] this.fuzzyForm.fuzzytotal = 0 + this.fuzzyShow = false + this.getShow = true }, //鏍规嵁id鍒犻櫎鏂伴椈 async deleteNews(id){ - console.log(id); + // console.log(id); const res = await this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ潯鏂伴椈, 鏄惁缁х画?', '鎻愮ず', { confirmButtonText: '纭畾', cancelButtonText: '鍙栨秷', @@ -355,15 +357,17 @@ this.fuzzyList(this.fuzzyForm.fuzzytitle) //妯$硦鏌ヨ }, //鍘诲線娣诲姞缂栬緫椤甸潰 - goEdit(){ - if (this.newsCategoryId==27||this.newsCategoryId==28||this.newsCategoryId==29|| - this.newsCategoryId==30||this.newsCategoryId==31) { - this.$message.error('璇ユ柊闂绘爣棰樹笅涓嶈兘娣诲姞鏂伴椈') - }else if(this.newsCategoryId == 35||this.newsCategoryId==36||this.newsCategoryId==37|| + goEdit(id){ + if (this.newsCategoryId==27&&this.total==1||this.newsCategoryId==28&&this.total==1||this.newsCategoryId==29&&this.total==1|| + this.newsCategoryId==30&&this.total==1||this.newsCategoryId==31&&this.total==1) { + this.$message.error('璇ユ柊闂绘爣棰樹笅鍙兘瀛樺湪涓�绡囨柊闂�') + }else if(this.newsCategoryId==27||this.newsCategoryId==28||this.newsCategoryId==29||this.newsCategoryId==30|| + this.newsCategoryId==31||this.newsCategoryId == 35||this.newsCategoryId==36||this.newsCategoryId==37|| this.newsCategoryId==38||this.newsCategoryId==39||this.newsCategoryId==40|| this.newsCategoryId==41||this.newsCategoryId==42||this.newsCategoryId==43|| this.newsCategoryId==44){ - this.$router.push('/administrator/edit') + this.$router.push({path:'/administrator/edit',query:{id:id}}) + console.log(this.newsCategoryId); }else{ this.$message.error('璇峰厛閫夋嫨鏂伴椈鏍囬') } @@ -376,11 +380,10 @@ .add{ margin-bottom: 10px !important; } +.block{ + margin-bottom: 10px; +} .el-pagination{ margin-top: 10px; -} -.fenye{ - display: flex; - justify-content: space-between; } </style> \ No newline at end of file -- Gitblit v1.8.0