<template>
|
<main>
|
<div class="mainContent">
|
<!-- 数据展示 -->
|
<el-table ref="multipleTable"
|
:header-cell-style="{background:'#06122c','font-size':'12px',color:'#4b9bb7','font-weight':'650','line-height':'45px'}"
|
:data="tableData" style="width: 100%" :row-class-name="tableRowClassName">
|
<el-table-column type="selection" min-width="5">
|
</el-table-column>
|
<el-table-column prop="storeNumber" label="店铺编号" min-width="10">
|
</el-table-column>
|
<el-table-column label="店铺名称" min-width="10">
|
<template slot-scope="scope">{{ scope.row.storeName }}</template>
|
</el-table-column>
|
<el-table-column prop="owner" label="店铺负责人" min-width="10">
|
</el-table-column>
|
<el-table-column prop="contact" label="店铺联系电话" min-width="10">
|
</el-table-column>
|
<el-table-column prop="storeAddress" label="店铺详细地址" min-width="10">
|
</el-table-column>
|
<el-table-column prop="operation" label="操作" min-width="15">
|
<template slot-scope="scope">
|
<div class="operation">
|
<el-link icon="el-icon-edit" :underline="false" @click.native.prevent='handleEdit(scope.row)'>编辑</el-link>
|
<el-link class="leftPx" icon="el-icon-delete-solid" :underline="false"
|
@click.native.prevent="hadnleDelete(scope.row)">删除</el-link>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!-- 查看修改页面 -->
|
<el-dialog :visible.sync="dialogUpdate" width="45%" v-if="dialogUpdate"
|
title="编辑商铺信息" :before-close="handleClose">
|
<updateUser :userInfo=userInfo @changeDialog="changeDialog" />
|
</el-dialog>
|
<!-- 分页 -->
|
<div class="pagination">
|
<el-pagination background :current-page="currentPage" layout="prev, pager, next" :total="totalNum"
|
:page-size="pageSize" @current-change="changeCurrentPage" @prev-click="handlePrev"
|
@next-click="handleNext">
|
</el-pagination>
|
</div>
|
</div>
|
</main>
|
</template>
|
<script>
|
import helper from '@/utils/mydate'
|
import updateUser from '../updateUser';
|
export default {
|
components: {
|
updateUser
|
},
|
data() {
|
return {
|
tableData: [],
|
search: "",
|
dialogUpdate: false,
|
userInfo: '',
|
totalNum: 0,
|
pageSize: 10,
|
currentPage: 1,
|
renderFlag: false,
|
}
|
},
|
created() {
|
this.getUserList();
|
},
|
methods: {
|
// 关闭弹窗
|
handleClose(done){
|
this.$confirm('确认关闭')
|
.then(_=>{
|
done();
|
})
|
.catch(err=>{
|
console.log(err);
|
})
|
},
|
// 改变弹窗状态
|
changeDialog({flag}){
|
this.dialogUpdate = flag;
|
this.getUserList();
|
},
|
// 删除
|
hadnleDelete({id}) {
|
console.log(id);
|
this.$confirm('确定删除?')
|
.then(_=>{
|
this.$axios({
|
method:'get',
|
url:`sccg/store/storeinfo/delete/${id}`
|
})
|
.then(res=>{
|
if(res.code === 200){
|
this.$message({
|
type:'success',
|
message:'删除成功',
|
})
|
this.getUserList();
|
}
|
})
|
.catch(err=>{
|
console.log(err,2)
|
})
|
})
|
.catch(err=>{
|
console.log(err,1);
|
})
|
},
|
// 编辑
|
async handleEdit({id}){
|
this.userInfo = await this.getShopInfo(id);
|
this.dialogUpdate = true;
|
},
|
// 获取门店信息
|
async getShopInfo(id){
|
let obj = {};
|
await this.$axios({
|
method:'get',
|
url:`sccg/store/storeinfo/${id}`,
|
})
|
.then(res=>{
|
obj = res.data
|
})
|
return obj;
|
},
|
// 当前页改变触发事件
|
changeCurrentPage(page) {
|
this.currentPage = page;
|
this.getUserList();
|
},
|
// 上一页点击事件
|
handlePrev(page) {
|
this.currentPage = page;
|
this.getUserList();
|
},
|
// 下一页点击事件
|
handleNext(page) {
|
this.currentPage = page;
|
this.getUserList();
|
},
|
// 获取用户列表
|
getUserList() {
|
const that = this;
|
const { currentPage, pageSize, search } = this;
|
this.$axios.get(`sccg/store/storeinfo/list?keyword=${search}&pageNum=${currentPage}&pageSize=${pageSize}`)
|
.then(res => {
|
if (res.code === 200) {
|
res.data.list.forEach(item => {
|
item.createTime = helper(item.createTime);
|
item.status == 1 ? item.status = true : item.status = false;
|
})
|
that.totalNum = res.data.total;
|
that.tableData = res.data.list;
|
this.renderFlag = true;
|
}
|
})
|
},
|
// 设置表格斑马纹
|
tableRowClassName({ row, rowIndex }) {
|
if ((rowIndex + 1) % 2 == 0) {
|
return 'warning-row';
|
} else {
|
return 'success-row';
|
}
|
return '';
|
},
|
},
|
props: ['refresh', 'keyword', 'resetFresh'],
|
watch: {
|
refresh: {
|
handler(newValue, oldValue) {
|
if (newValue == true) {
|
this.search = '';
|
if (this.keyword != '') {
|
this.search = this.keyword;
|
}
|
this.getUserList();
|
this.$emit('resetFresh', { flag: false })
|
}
|
},
|
immediate: true
|
}
|
}
|
}
|
</script>
|
<style lang="scss" scoped>
|
main {
|
background-color: #09152f;
|
margin-top: 20px;
|
padding-bottom: 50px;
|
border: 1pox solid #fff;
|
|
.mainTitle {
|
line-height: 60px;
|
}
|
|
.el-link {
|
color: #4b9bb7;
|
}
|
|
.leftPx {
|
margin-left: 10px;
|
}
|
|
.pagination {
|
margin-top: 50px;
|
display: flex;
|
line-height: 50px;
|
justify-content: center;
|
|
.el-pagination {
|
|
&::v-deep li,
|
&::v-deep .btn-prev,
|
&::v-deep .btn-next {
|
background-color: #071f39;
|
color: #4b9bb7;
|
}
|
}
|
}
|
|
.el-table {
|
color: #4b9bb7;
|
font-size: 10px;
|
|
&::v-deep .el-table__empty-block {
|
background-color: #09152f;
|
color: #4b9bb7;
|
}
|
|
.operation {
|
display: flex;
|
|
.line {
|
padding: 0 5px;
|
}
|
|
.el-button {
|
// background-color: #fff;
|
border: none;
|
}
|
|
span:hover {
|
cursor: pointer;
|
}
|
}
|
}
|
|
.el-table::v-deep .warning-row {
|
background: #06122c;
|
}
|
|
.el-table::v-deep .success-row {
|
background: #071f39;
|
}
|
|
&::v-deep .switchStyle .el-switch__label {
|
position: absolute;
|
display: none;
|
color: #fff;
|
}
|
|
&::v-deep .el-switch__core {
|
background-color: rgba(166, 166, 166, 1);
|
}
|
|
&::v-deep .switchStyle .el-switch__label--left {
|
z-index: 9;
|
left: 20px;
|
}
|
|
&::v-deep .switchStyle .el-switch__label--right {
|
z-index: 9;
|
left: 4px;
|
}
|
|
&::v-deep .switchStyle .el-switch__label.is-active {
|
display: block;
|
}
|
|
&::v-deep .switchStyle.el-switch .el-switch__core,
|
&::v-deep .el-switch .el-switch__label {
|
width: 50px !important;
|
}
|
}
|
</style>
|