zhanghua
2022-10-31 feebf68645a0c91e07c7eadeb04ae970001f1fc1
src/views/operate/fivepack/shop/components/main/index.vue
@@ -7,30 +7,31 @@
                :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.id }}</template>
                    <template slot-scope="scope">{{ scope.row.storeName }}</template>
                </el-table-column>
                <el-table-column prop="nickName" label="店铺负责人" min-width="10">
                <el-table-column prop="owner" label="店铺负责人" min-width="10">
                </el-table-column>
                <el-table-column prop="username" label="店铺联系电话" min-width="10">
                <el-table-column prop="contact" label="店铺联系电话" min-width="10">
                </el-table-column>
                <el-table-column prop="mobile" label="店铺详细地址" min-width="10">
                </el-table-column>
                <el-table-column prop="note" label="店铺编号" min-width="10">
                <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">编辑</el-link>
                            <el-link class="leftPx" icon="el-icon-delete-solid" :underline="false">删除</el-link>
                            <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="updateFlag ? '修改用户部门信息' :'查看用户信息'">
                <updateUser :updateFlag="updateFlag" :userInfo=userInfo />
                title="编辑商铺信息" :before-close="handleClose">
                <updateUser :userInfo=userInfo @changeDialog="changeDialog" />
            </el-dialog>
            <!-- 分页 -->
            <div class="pagination">
@@ -54,9 +55,8 @@
            tableData: [],
            search: "",
            dialogUpdate: false,
            updateFlag: false,
            userInfo: '',
            totalNum: 200,
            totalNum: 0,
            pageSize: 10,
            currentPage: 1,
            renderFlag: false,
@@ -66,6 +66,64 @@
        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;
@@ -81,58 +139,32 @@
            this.currentPage = page;
            this.getUserList();
        },
        // 修改角色
        handleChangeRole(obj) {
            this.dialogUpdate = true
            this.user = obj;
            // console.log(obj)
        },
        // 修改用户状态
        handleChangeStatus(obj) {
            let { id, status } = obj;
            status == true ? status = 1 : status = 0;
            this.$axios.post(`sccg/admin/updateStatus/` + id + '?status=' + status).then(res => {
                console.log(res);
            })
        },
        // 获取用户列表
        getUserList() {
            const that = this;
            const { currentPage, pageSize, search } = this;
            // 获取所有用户信息、用户查询(暂时支持电话号码)
            this.$axios.get(`sccg/admin/list?mobile=${search}&current=${currentPage}&pageSize=${pageSize}`).then(res => {
                if (res.code === 200) {
                    res.data.records.forEach(item => {
                        item.createTime = helper(item.createTime);
                        item.status == 1 ? item.status = true : item.status = false;
                    })
                    that.totalNum = res.data.pages * pageSize;
                    that.tableData = res.data.records;
                    this.renderFlag = true;
                }
            })
        },
        // 查看用户信息(不可修改)
        handleFind(rowData) {
            this.dialogUpdate = true;
            this.updateFlag = false;
            this.userInfo = rowData;
        },
        // 修改用户部门信息
        handleUpdate(rowData) {
            this.dialogUpdate = true;
            this.updateFlag = true;
            this.userInfo = rowData
            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 '';
            },
            if ((rowIndex + 1) % 2 == 0) {
                return 'warning-row';
            } else {
                return 'success-row';
            }
            return '';
        },
    },
    props: ['refresh', 'keyword', 'resetFresh'],
    watch: {
@@ -162,17 +194,21 @@
    .mainTitle {
        line-height: 60px;
    }
    .el-link{
    .el-link {
        color: #4b9bb7;
    }
    .leftPx{
    .leftPx {
        margin-left: 10px;
    }
    .pagination {
        margin-top: 50px;
        display: flex;
        line-height: 50px;
        justify-content: center;
        .el-pagination {
            &::v-deep li,
@@ -199,10 +235,12 @@
            .line {
                padding: 0 5px;
            }
            .el-button{
            .el-button {
                // background-color: #fff;
                border: none;
            }
            span:hover {
                cursor: pointer;
            }