From 27d35a9f1355e4a56aa1e8c1aad9c7f58002ed50 Mon Sep 17 00:00:00 2001 From: 明梦爽 <2972214568@qq.com> Date: 星期三, 10 八月 2022 17:52:13 +0800 Subject: [PATCH] 修改login --- src/components/Administrator/AdEdit.vue | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 151 insertions(+), 24 deletions(-) diff --git a/src/components/Administrator/AdEdit.vue b/src/components/Administrator/AdEdit.vue index 665807a..1a20dce 100644 --- a/src/components/Administrator/AdEdit.vue +++ b/src/components/Administrator/AdEdit.vue @@ -1,56 +1,181 @@ <template> <div> <el-card class="box-card"> + <el-button type="primary" @click="add()" icon="el-icon-circle-plus" class="add">娉ㄥ唽鏂扮殑绠$悊鍛樿处鍙�</el-button> <!-- 鏂伴椈琛ㄦ牸鍖哄煙 --> - <el-table - :data="tableData" - border - style="width: 100%" - :header-cell-style="{textAlign: 'center'}" - :cell-style="{ textAlign: 'center' }" - > + <el-table :data="tableData" border style="width: 100%" :header-cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }"> <el-table-column type="index" label="搴忓彿" width="50"> <!-- <template slot-scope="scope"> <span>{{ (currentPage-1)*pageSize+scope.$index+1 }}</span> </template> --> </el-table-column> - <el-table-column prop="username" label="鏅�氱鐞嗗憳璐﹀彿" width="" > - </el-table-column> - <el-table-column prop="id" label="id" width=""> - </el-table-column> + <el-table-column prop="username" label="鏅�氱鐞嗗憳璐﹀彿" width=""> </el-table-column> + <el-table-column prop="id" label="id" width=""> </el-table-column> <el-table-column label="鎿嶄綔" width=""> <template slot-scope="scope"> <!-- {{ scope.row.id }} --> <div> - <el-button type="success" @click="look(scope.row.id)">娣诲姞</el-button> - <el-button type="warning" @click="showEditDialog(scope.row.id)">淇敼</el-button> - <el-button type="info" @click="deleteNews(scope.row.id)">鍒犻櫎</el-button> + <el-button type="primary" @click="showEditDialog(scope.row.id)" icon="el-icon-edit"></el-button> + <el-button type="danger" @click="deleteAds(scope.row.id)" icon="el-icon-delete"></el-button> </div> </template> - </el-table-column> </el-table> </el-card> + <!-- 淇敼璐︽埛鐨勫璇濇 --> + <el-dialog title="淇敼鏅�氱鐞嗗憳瀵嗙爜" :visible.sync="editDialogVisible" width="50%" @close="editClose"> + <!-- rules琛ㄥ崟楠岃瘉瑙勫垯锛宺ef褰撳墠琛ㄥ崟鐨勯獙璇佸璞� --> + <el-form ref="editFormRef" :model="editForm" label-width="80px" status-icon> + <el-form-item label="鐢ㄦ埛鍚�:"> + <el-input v-model="editForm.username" prefix-icon="iconfont icon-user" placeholder="璇疯緭鍏ヨ处鍙�" clearable=""></el-input> + </el-form-item> + <el-form-item label="鏃у瘑鐮�:"> + <el-input v-model="editForm.oldPassword" prefix-icon="iconfont icon-3702mima" type="password" show-password placeholder="璇疯緭鍏ユ棫瀵嗙爜"></el-input> + </el-form-item> + <el-form-item label="鏂板瘑鐮�:"> + <el-input v-model="editForm.password" prefix-icon="iconfont icon-3702mima" type="password" show-password placeholder="璇疯緭鍏ユ柊瀵嗙爜"></el-input> + </el-form-item> + </el-form> + <span slot="footer" class="dialog-footer"> + <el-button @click="cancel">鍙� 娑�</el-button> + <el-button type="primary" @click="subEdit()">纭� 瀹�</el-button> + </span> + </el-dialog> + <!-- 娣诲姞绠$悊鍛樺璇濇 --> + <el-dialog title="娣诲姞鏅�氱鐞嗗憳" :visible.sync="addDialogVisible" width="50%" @close="addClose"> + <!-- rules琛ㄥ崟楠岃瘉瑙勫垯锛宺ef褰撳墠琛ㄥ崟鐨勯獙璇佸璞� --> + <el-form ref="addFormRef" :model="addForm" label-width="80px" status-icon> + <el-form-item label="鐢ㄦ埛鍚�:"> + <el-input v-model="addForm.username" prefix-icon="iconfont icon-user" placeholder="璇疯緭鍏ヨ处鍙�" clearable=""></el-input> + </el-form-item> + <el-form-item label="瀵嗙爜:"> + <el-input v-model="addForm.password" prefix-icon="iconfont icon-3702mima" type="password" show-password placeholder="璇疯緭鍏ュ瘑鐮�"></el-input> + </el-form-item> + </el-form> + <span slot="footer" class="dialog-footer"> + <el-button @click="canceladd">鍙� 娑�</el-button> + <el-button type="primary" @click="addEdit()">娉� 鍐�</el-button> + </span> + </el-dialog> </div> </template> <script> -import { getmain,editAccount } from '../../api/api' +import { getmain, editAccount, deleteAd, addAd } from '../../api/api' export default { data() { return { - tableData:[], //鏅�氱鐞嗗憳鍒楄〃 + tableData: [], //鏅�氱鐞嗗憳鍒楄〃 + editDialogVisible: false, + addDialogVisible: false, + editForm: { username: '', oldPassword: '', password: '' }, //淇敼琛ㄥ崟瀵硅薄 + addForm: { username: '', password: '' } //娣诲姞绠$悊瀵硅薄 } }, - created(){ + created() { this.ready() }, - methods:{ - ready(){ + methods: { + //鑾峰彇閾虹鍒楄〃 + ready() { getmain().then(res => { - console.log(res); - if(res.code == 200){ + // console.log(res); + if (res.code == 200) { this.tableData = res.data + } + }) + }, + //灞曠ず缂栬緫瀵硅瘽妗� + showEditDialog() { + this.editDialogVisible = true + }, + editClose() { + this.editForm.username = '' + this.editForm.oldPassword = '' + this.editForm.password = '' + }, + cancel() { + this.editForm.username = '' + this.editForm.oldPassword = '' + this.editForm.password = '' + this.editDialogVisible = false + }, + //缂栬緫纭畾浜嬩欢 + subEdit() { + const data = { + username: this.editForm.username, + oldPassword: this.editForm.oldPassword, + password: this.editForm.password + } + editAccount(data).then(res => { + // console.log(res); + if (res.code == 200) { + this.$message.success('璐︽埛淇敼鎴愬姛') + this.editDialogVisible = false + this.ready() + } else { + this.$message.error('璐︽埛淇敼澶辫触') + } + }) + }, + //鍒犻櫎鏅�氱鐞嗗憳 + async deleteAds(id) { + // console.log(id); + const res = await this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ョ鐞嗚处鍙�, 鏄惁缁х画?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).catch(err => { + return err + }) + //濡傛灉鐢ㄦ埛鐐瑰嚮纭畾鍒欒繑鍥瀋onfirm + //濡傛灉鐢ㄦ埛鐐瑰嚮鍙栨秷鍒欒繑鍥瀋ancel + console.log(res) + if (res !== 'confirm') { + return this.$message.info('宸插彇娑堝垹闄') + } else { + // console.log(id); + const data = { + id: id + } + //鍙傛暟data 瑕佷互瀵硅薄鐨勫舰寮忎紶鍏� + deleteAd(data).then(res => { + // console.log('>>>'+res); + if (res.code == 200) { + this.$message.success('鍒犻櫎鎴愬姛锛�') + this.ready() + } else { + return this.$message.error('鍒犻櫎澶辫触锛�') + } + }) + } + }, + add() { + this.addDialogVisible = true + }, + //娉ㄥ唽鍙栨秷娓呯┖ + canceladd() { + this.addForm.username = '' + this.addForm.password = '' + this.addDialogVisible = false + }, + addClose() { + this.addForm.username = '' + this.addForm.password = '' + }, + //娉ㄥ唽鎻愪氦 + addEdit() { + const data = { + username: this.addForm.username, + password: this.addForm.password + } + addAd(data).then(res => { + if (res.code == 200) { + this.$message.success('娉ㄥ唽鎴愬姛') + this.addDialogVisible = false + this.ready() + } else { + this.$message.error('娉ㄥ唽澶辫触') } }) } @@ -59,5 +184,7 @@ </script> <style lang="less" scoped> - -</style> \ No newline at end of file +.add { + margin-bottom: 10px; +} +</style> -- Gitblit v1.8.0