123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503 |
- <template>
- <div class="adminShop-wrap">
- <div class="addShopBtn" @click="toShowAdd"><i class="el-icon-plus"></i><span>添加商家</span></div>
- <div class="shopList-wrap">
- <h5>商家信息</h5>
- <el-table
- :data="shopInfo"
- border
- style="width: 100%">
- <el-table-column
- prop="id"
- label="编号"
- min-width="1">
- </el-table-column>
- <el-table-column
- prop="userName"
- label="店铺名称"
- min-width="3">
- </el-table-column>
- <el-table-column
- prop="loginId"
- label="登陆账号"
- min-width="3">
- </el-table-column>
- <el-table-column
- prop="password"
- label="登陆密码"
- min-width="3">
- </el-table-column>
- <el-table-column
- prop="label"
- label="店铺标签"
- :filters="shopTagList"
- :filter-method="filterTag"
- filter-placement="bottom-end"
- min-width="3">
- <template slot-scope="scope">
- <el-tag
- :type="'success'"
- close-transition>{{scope.row.label}}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" min-width="6">
- <template slot-scope="scope">
- <el-button
- size="mini"
- @click="toShowEdit(scope.row)">编辑</el-button>
- <el-button
- size="mini"
- @click="toDelete(scope.row.id)">删除</el-button>
- <el-button
- size="mini"
- @click="toShowCheck(scope.row)">查看</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="pageblock">
- <el-pagination
- layout="prev, pager, next"
- :page-size="pageSize"
- :current-page.sync="currentPage"
- :total="total"
- @current-change="pagechange">
- </el-pagination>
- </div>
- </div>
- <el-dialog :title="dialogTitle" :visible.sync="dialogTableVisible" :show-close="false">
- <div class="dialogheader">
- <el-form label-position="right" label-width="80px">
- <el-form-item label="编号" v-show="dialogTitle=='查看商家'">
- <el-input v-model="showItem.id" :disabled="dialogTitle=='查看商家'"></el-input>
- </el-form-item>
- <el-form-item label="店铺名称">
- <el-input v-model="showItem.userName" :disabled="dialogTitle=='查看商家'"></el-input>
- </el-form-item>
- <el-form-item label="登陆账号">
- <el-input v-model="showItem.name" :disabled="dialogTitle=='查看商家'"></el-input>
- </el-form-item>
- <el-form-item label="登陆密码">
- <el-input v-model="showItem.password" :disabled="dialogTitle=='查看商家'"></el-input>
- </el-form-item>
- <el-form-item label="店铺标签">
- <el-select v-model="showItem.label" placeholder="请选择" :disabled="dialogTitle=='查看商家'">
- <el-option
- v-for="item in shopTagList"
- :key="item.id"
- :label="item.text"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="toAdd" v-show="dialogTitle=='添加商家'">提交</el-button>
- <el-button type="primary" @click="toEdit" v-show="dialogTitle=='编辑商家'">提交</el-button>
- <el-button @click="toCancel">取消</el-button>
- </el-form-item>
- </el-form>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- export default{
- data(){
- return{
- shopInfo:[],
- shopTagList:[],
- dialogTableVisible:false,
- dialogTitle:"",
- showItem:{
- id:"",
- userName:"",
- name:"",
- password:"",
- label:""
- },
- total:0,
- currentPage:1,
- pageSize:10,
- }
- },
- mounted(){
- this.getShopList();
- this.getShopTagList();
- },
- methods:{
- getShopList(){
- this.axios.post(this.Api.getAccountList,{
- type:1
- }).then((res)=>{
- //this.shopInfo=res.data;
- this.shopInfo=[];
- for(let i=(this.currentPage-1)*10;i<this.currentPage*10;i++){
- if(res.data.length-1>=i){
- this.shopInfo.push(res.data[i])
- }
- }
- this.total=parseInt(res.data.length);
- }).catch((err)=>{
- console.log("getShopList:"+err);
- });
- },
- getShopTagList(){
- this.axios.post(this.Api.getTagtList,{}).then((res)=>{
- this.shopTagList=res.data;
- }).catch((err)=>{
- console.log("getShopTagList:"+err);
- });
- },
- filterTag(value, row) {
- return row.label === value;
- },
- toShowAdd(){
- this.dialogTableVisible=true;
- this.dialogTitle="添加商家";
- },
- toShowEdit(obj){
- this.dialogTableVisible=true;
- this.dialogTitle="编辑商家";
- this.showItem.id=obj.id;
- this.showItem.userName=obj.userName;
- this.showItem.name=obj.loginId;
- this.showItem.password=obj.password;
- this.showItem.label=obj.label;
- },
- toShowCheck(obj){
- this.dialogTableVisible=true;
- this.dialogTitle="查看商家";
- this.showItem.id=obj.id;
- this.showItem.userName=obj.userName;
- this.showItem.name=obj.loginId;
- this.showItem.password=obj.password;
- this.showItem.label=obj.label;
- },
- toCancel(){
- this.dialogTableVisible=false;
- this.dialogTitle="";
- this.showItem={
- id:"",
- userName:"",
- name:"",
- password:"",
- label:""
- }
- },
- toAdd(){
- if(this.showItem.name==""||this.showItem.password==""||this.showItem.userName==""||this.showItem.label==""){
- this.$message.error('请填写完整信息');
- console.log(this.showItem)
- return;
- }
- let param={
- type:1,
- handle:"1",
- mess:{
- name:this.showItem.name,
- password:this.showItem.password,
- userName:this.showItem.userName,
- label:this.showItem.label,
- }
- }
- this.axios.post(this.Api.adminHandle,param).then((res)=>{
- console.log(res);
- if(res.data.code==200){
- this.$message({
- message: '添加成功',
- type: 'success'
- });
- this.toCancel();
- this.getShopList();
- }
- }).catch((err)=>{
- console.log("toAdd:"+err);
- });
- },
- toEdit(){
- if(this.showItem.name==""||this.showItem.password==""||this.showItem.userName==""||this.showItem.label==""){
- this.$message.error('请填写完整信息');
- console.log(this.showItem)
- return;
- }
- let param={
- type:1,
- handle:"2",
- mess:{
- id:this.showItem.id,
- name:this.showItem.name,
- password:this.showItem.password,
- userName:this.showItem.userName,
- label:this.showItem.label,
- }
- }
- this.axios.post(this.Api.adminHandle,param).then((res)=>{
- console.log(res);
- if(res.data.code==200){
- this.$message({
- message: '编辑成功',
- type: 'success'
- });
- this.toCancel();
- this.getShopList();
- }
- }).catch((err)=>{
- console.log("toEdit:"+err);
- });
- },
- toDelete(id){
- this.$confirm("确定将该商家删除吗?", '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- let param={
- type:1,
- handle:"3",
- mess:{
- id:id,
- }
- }
- this.axios.post(this.Api.adminHandle,param).then((res)=>{
- console.log(res);
- if(res.data.code==200){
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- this.getShopList();
- }else{
- this.$notify({
- title:'提示',
- message:'删除失败',
- type:'error',
- })
- }
- });
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消操作'
- });
- })
- },
- pagechange(val){
- this.currentPage=val;
- this.getShopList();
- },
- }
- }
- </script>
- <style scoped>
- .adminShop-wrap{
- width: 100%;
- padding: 0 20px;
- }
- .addShopBtn{
- width: 100%;
- height: 70px;
- background-color: #3eb983;
- border: 0;
- color: #fff;
- margin: 20px 0;
- font-size: 16px;
- line-height: 70px;
- cursor: pointer;
- }
- .addShopBtn span{
- height: 100%;
- display: inline-block;
- vertical-align: middle;
- }
- .addShopBtn i{
- font-size: 30px;
- margin-right: 10px;
- display: inline-block;
- vertical-align: middle;
- }
- .shopList-wrap{
- background-color: #fff;
- padding: 20px;
- margin-top: 20px;
- }
- .shopList-wrap h5{
- font-size: 16px;
- text-align: left;
- margin-bottom: 10px;
- }
- .shopList-content{
- width: 100%;
- }
- .el-table thead{
- background-color: #bcf2db;
- height: 32px;
- line-height: 32px;
- font-size: 12px;
- text-align: center;
- }
- .has-gutter th{
- color: #17905c;
- padding: 0 4px;
- }
- .pageblock{
- margin-top: 20px;
- text-align: right;
- }
- </style>
- <style>
- .el-table thead{
- background-color: #bcf2db;
- height: 32px;
- line-height: 32px;
- font-size: 12px;
- text-align: center;
- }
- .el-table thead tr{
- background-color: #bcf2db;
- }
- .el-table th{
- color: #17905c;
- padding: 0;
- background-color: #bcf2db;
- text-align: center;
- }
- .el-dialog{
- width: 500px;
- /*height: 280px;*/
- border-radius: 6px;
- text-align: left;
- }
- .el-dialog__header{
- padding: 20px 30px 0 40px;
- }
- .el-dialog__body{
- padding: 20px 30px;
- }
- .dialogheader{
- width: 100%;
- /*height: 60px;*/
-
- }
- .dialogheader p{
- width: 360px;
- height: 30px;
- line-height: 30px;
- margin-top: 10px;
- border:1px solid #3eb983;
- border-radius: 6px;
- text-align: left;
- padding-left: 10px;
- margin-left: 60px;
- }
- .dialogheader p input{
- height: 24px;
- line-height: 24px;
- border:0;
- margin-left: 20px;
- }
- .dialogheader .button{
- background: #3eb983;
- color: #fff;
- text-align: center;
- margin-top: 40px;
- cursor: pointer;
- }
- .dialogheader .el-button{
- width: 173px;
- padding: 10px 0;
- }
- .dialogheader .el-form-item{
- margin-bottom: 15px;
- }
- .dialogheader .el-button+.el-button{
- margin-left: 0;
- }
- .dialogheader .el-button--primary{
- background-color: #3eb983;
- border-color: #3eb983;
- }
- .dialogheader .el-button--primary:hover{
- background-color: #3eb983;
- border-color: #3eb983;
- }
- .dialogheader .el-button--default{
- background-color: #bfcbd9;
- color: #fff;
- }
- .dialogheader .el-button--default:hover{
- background-color: #bfcbd9;
- border-color: #bfcbd9;
- color: #fff;
- }
- .el-message-box button{
- display: inline-block;
- float: right;
- }
- .el-message-box .el-message-box__btns{
- height: 61px;
- }
- .el-message-box .el-message-box__btns button:nth-child(1){
- margin-left: 10px;
- }
- .el-message-box .el-message-box__btns .el-button--default{
- background-color: #bfcbd9;
- color: #fff;
- }
- .el-message-box .el-message-box__btns .el-button--default:hover{
- background-color: #bfcbd9;
- border-color: #bfcbd9;
- color: #fff;
- }
- .el-message-box .el-message-box__btns .el-button--primary{
- background-color: #3eb983;
- border-color: #3eb983;
- }
- .el-message-box .el-message-box__btns .el-button--primary:hover{
- background-color: #3eb983;
- border-color: #3eb983;
- }
- .el-pagination{
- font-weight: normal;
- padding-right: 0;
- }
- .el-pagination button{
- padding: 0 6px;
- min-width: 28px;
- }
- .el-pagination .btn-next, .el-pagination .btn-prev{
- border: 1px solid #d1dbe5;
- }
- .el-pagination .btn-prev{
- padding-right: 6px;
- border-right: 0;
- border-radius: 2px 0 0 2px;
- }
- .el-pagination .btn-next{
- border-left: 0;
- padding-left: 6px;
- border-radius: 0 2px 2px 0;
- }
- .el-pager li{
- border: 1px solid #d1dbe5;
- border-right: 0;
- min-width: 28px;
- }
- .el-pager li.active{
- color: #fff;
- }
- .pageblock .el-pager li.active{
- border-color: #3eb983;
- background-color: #3eb983;
- }
- .el-pager li.active+li{
- border-left: 0;
- }
- .el-pager li:last-child{
- border-right: 1px solid #d1dbe5;
- }
- </style>
|