Explorar o código

增加合作商

wangguoyu %!s(int64=3) %!d(string=hai) anos
pai
achega
aed4f38b32

+ 32 - 0
src/api/hezuoshang.js

@@ -0,0 +1,32 @@
+import request from '@/utils/request';
+
+export function getBusinessList(data = {}) {
+    return request({
+                       url:    `/home/business/list`,
+                       method: 'post',
+                       data,
+                   });
+}
+export function buginessUnhandled(data = {}) {
+    return request({
+        url:    `/home/business/unhandled`,
+        method: 'post',
+        data,
+    });
+}
+export function buginessHandled(data = {}) {
+    return request({
+        url:    `/home/business/handle`,
+        method: 'post',
+        data,
+    });
+}
+export function buginessExport(data = {}) {
+    return request({
+        url:    `/home/business/export`,
+        method: 'post',
+        data,
+    });
+}
+
+

+ 12 - 0
src/router.js

@@ -227,6 +227,18 @@ const router = new Router({
                                               },
                                           },
                                           {
+                                              path: '/hezuoshangguanli',
+                                              name: 'hezuoshangguanli',
+                                              meta: {
+                                                  icon: "",
+                                                  title: "合作商管理"
+                                              },
+                                              isAdminMenu: true,
+                                              component: () => {
+                                                  return import(/* webpackChunkName: "news" */ './views/management/hezuoshangguanli/index.vue');
+                                              },
+                                          },
+                                          {
                                               path: '/think',
                                               name: 'think',
                                               meta: {

+ 93 - 0
src/views/management/hezuoshangguanli/components/Pagination.vue

@@ -0,0 +1,93 @@
+<template>
+    <el-pagination
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+            :current-page.sync="page"
+            :page-sizes="pageSizes"
+            :page-size="size"
+            layout="total, sizes, prev, pager, next, jumper"
+            :total="total">
+    </el-pagination>
+</template>
+
+<script>
+    export default {
+        name:     'Pagination',
+        props:    {
+            pageSizes: {
+                type:    Array,
+                default: () => [],
+            },
+            codePage: {
+                type: String,
+                default: 'page'
+            },
+            codeSize: {
+                type: String,
+                default: 'size'
+            },
+            codeTotal: {
+                type: String,
+                default: 'total'
+            }
+        },
+        inject:   {
+            paginationServiceData: {
+                type:    Object,
+                default: () => {
+                },
+            },
+            tableServiceData: {
+                type:    Object,
+                default: () => {
+                },
+            },
+        },
+        computed: {
+            page:  {
+                get() {
+                    return this.paginationServiceData[this.codePage];
+                },
+                set(val) {
+                    this.paginationServiceData[this.codePage] = val;
+                },
+            },
+            size:  {
+                get() {
+                    return this.paginationServiceData[this.codeSize];
+                },
+                set(val) {
+                    this.paginationServiceData[this.codeSize] = val;
+                },
+            },
+            total: {
+                get() {
+                    return this.paginationServiceData[this.codeTotal];
+                },
+                set(val) {
+                    this.this.paginationServiceData[this.codeTotal] = val;
+                },
+            },
+        },
+        watch:    {
+            total(newVal) {
+                if (newVal >= this.size && !this.tableServiceData.myData.length && this.page > 1) {
+                    this.page--;
+                    this.$emit('current-page', this.page);
+                }
+            },
+        },
+        methods:  {
+            handleSizeChange(val) {
+                this.$emit('size-change', val);
+            },
+            handleCurrentChange(val) {
+                this.$emit('current-page', val);
+            },
+        },
+    };
+</script>
+
+<style scoped>
+
+</style>

+ 101 - 0
src/views/management/hezuoshangguanli/components/SearchArea.vue

@@ -0,0 +1,101 @@
+<template>
+    <div class="admin-registration-search">
+        <div>
+            <el-date-picker
+                    v-model="startTime"
+                    type="date"
+                    value-format="yyyy-MM-dd"
+                    placeholder="选择开始日期">
+            </el-date-picker>
+            <span class="line">—</span>
+            <el-date-picker
+                    v-model="endTime"
+                    value-format="yyyy-MM-dd"
+                    type="date"
+                    placeholder="选择开始日期">
+            </el-date-picker>
+
+            <el-select class="select-state" v-model="state" placeholder="请选择状态">
+                <el-option
+                        v-for="item in status"
+                        :key="item.value"
+                        :label="item.label"
+                        :value="item.value">
+                </el-option>
+            </el-select>
+
+            <el-button class="btn-search" size="medium" @click="search">查询</el-button>
+        </div>
+        <div>
+            <el-button size="medium" type="primary" @click="exportResisterData">导出</el-button>
+        </div>
+    </div>
+</template>
+
+<script>
+    const status = [
+        {
+            value: -1,
+            label: '全部',
+        },
+        {
+            value: 0,
+            label: '未处理',
+        },
+        {
+            value: 1,
+            label: '已处理',
+        },
+    ];
+    export default {
+        name:    'SearchArea',
+        data() {
+            return {
+                startTime: null,
+                endTime:   null,
+                status:    status,
+                state:     -1,
+            };
+        },
+        methods: {
+            search() {
+                const opt = {
+                    startTime: this.startTime,
+                    endTime:   this.endTime,
+                    state: this.state,
+                };
+                this.$emit('search', opt);
+            },
+            exportResisterData() {
+                const opt = {
+                    startTime: this.startTime,
+                    endTime:   this.endTime,
+                    state: this.state,
+                };
+                this.$emit('exportList', opt)
+            },
+        },
+        mounted() {
+            this.search();
+        }
+    };
+</script>
+
+<style lang="scss" scoped>
+    .admin-registration-search {
+        display: flex;
+        justify-content: space-between;
+
+        .select-state {
+            margin-left: 20px;
+        }
+
+        .line {
+            margin: 0 20px;
+        }
+
+        .btn-search {
+            margin-left: 20px;
+        }
+    }
+</style>

+ 94 - 0
src/views/management/hezuoshangguanli/components/Table.vue

@@ -0,0 +1,94 @@
+<template>
+    <el-table
+            :data="tableData"
+            border
+            class="table"
+            height="auto"
+            @selection-change="handleSelectionChange"
+            style="width: 100%">
+        <el-table-column
+                type="selection"
+                fixed
+                width="55">
+        </el-table-column>
+        <el-table-column
+                prop="phone"
+                label="手机号"
+                width="360">
+        </el-table-column>
+        <el-table-column
+                prop="stateName"
+                label="状态"
+                width="360">
+        </el-table-column>
+        <el-table-column
+                prop="createTime"
+                label="注册时间"
+                width="360">
+        </el-table-column>
+
+        <el-table-column
+                label="操作"
+                fixed="right"
+        >
+            <template slot-scope="scope">
+                <el-button v-if="scope.row.state === 0" type="text" @click="handleAudit(scope.row)">处理</el-button>
+                <el-button v-else type="text" @click="handleUnAudit(scope.row)">撤回</el-button>
+            </template>
+        </el-table-column>
+    </el-table>
+</template>
+
+<script>
+    export default {
+        name:     'Table',
+        inject:   {
+            tableServiceData:      {
+                type:    Object,
+                default: () => {
+                },
+            },
+            paginationServiceData: {
+                type:    Object,
+                default: () => {
+                },
+            },
+        },
+        computed: {
+            tableData() {
+                return this.tableServiceData.myData;
+            },
+        },
+        methods:  {
+            handleSelectionChange(data) {
+                const arr = [];
+                data.forEach(item => {
+                    arr.push(item.deId);
+                });
+                this.$emit('select-change', arr);
+            },
+            handleAudit(data) {
+                this.$emit('audit', data);
+            },
+            handleUnAudit(data) {
+                this.$emit('unAudit', data);
+            },
+        },
+    };
+</script>
+
+<style lang="scss" scoped>
+    .table {
+        ::v-deep .is-leaf {
+            .cell {
+                text-align: center;
+            }
+        }
+
+        ::v-deep .el-table-column--selection {
+            .cell {
+                text-align: center;
+            }
+        }
+    }
+</style>

+ 182 - 0
src/views/management/hezuoshangguanli/index.vue

@@ -0,0 +1,182 @@
+<template>
+    <div class="admin-Registration-management">
+        <!--   搜索     -->
+        <SearchArea
+                @search="handleSearch"
+                @exportList="handleExportList"
+        ></SearchArea>
+        <!--   列表     -->
+        <MtaTable
+                class="mta-Table"
+                @audit="handleAudit"
+                @unAudit="handleUnAudit"
+        ></MtaTable>
+        <!--   分页     -->
+        <MtaPagination class="my-Pagination"
+                       :pageSizes="defaultPageSizes"
+                       @size-change="handleSizeChange"
+                       @current-page="handleCurrentPage"></MtaPagination>
+    </div>
+</template>
+
+<script>
+    import SearchArea       from './components/SearchArea';
+    import MtaTable         from './components/Table';
+    import MtaPagination    from './components/Pagination';
+    import * as commonTools from '@/utils/admin/tools';
+    import Vue              from 'vue';
+    import * as hezuoshang     from '@/api/hezuoshang';
+
+    const pagination = {
+        page:  1,
+        size:  10,
+        total: 0,
+    };
+    const tableData = {
+        myData: [],
+    };
+    const defaultPageSizes = [10, 20, 30, 40];
+    const paginationServiceData = Vue.observable(pagination);
+    const tableServiceData = Vue.observable(tableData);
+
+    export default {
+        name:       'index',
+        components: {
+            SearchArea,
+            MtaTable,
+            MtaPagination,
+        },
+        provide:    {
+            tableServiceData,
+            paginationServiceData,
+        },
+        data() {
+            return {
+                defaultPageSizes: defaultPageSizes,
+                searchOpt:        {},
+                userId:           null,
+            };
+        },
+        methods:    {
+            async handleExportList(data) {
+                const opt = {
+                    startTime: data.startTime,
+                    endTime:   data.endTime,
+                    state:     data.state,
+                };
+                const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
+                try {
+                    const res = await hezuoshang.buginessExport(opt);
+                    if (res.code === 0) {
+                        window.location.href = res.data;
+                        loading.close();
+                    }
+                } catch (e) {
+                    loading.close();
+                }
+
+            },
+            async handleAudit(data) {
+                const opt = {
+                    id:   data.id,
+                    userId: this.userId,
+                };
+                const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
+
+                try {
+                    const res = await hezuoshang.buginessHandled(opt);
+                    if (res.code === 0 && res.data) {
+                        // 更新table
+                        this.getWeikezhizuoListData();
+                    }
+                    loading.close();
+                } catch (e) {
+                    loading.close();
+                }
+            },
+            async handleUnAudit(data) {
+
+                const opt = {
+                    id:   data.id,
+                    userId: this.userId,
+                };
+                const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
+
+                try {
+                    const res = await hezuoshang.buginessUnhandled(opt);
+                    if (res.code === 0 && res.data) {
+                        // 更新table
+                        this.getWeikezhizuoListData();
+                    }
+                    loading.close();
+                } catch (e) {
+                    loading.close();
+                }
+            },
+            handleSearch(data) {
+                paginationServiceData.page = 1;
+                this.searchOpt = data;
+                this.getWeikezhizuoListData(data);
+
+            },
+            handleSizeChange(val) {
+                paginationServiceData.size = val;
+                this.getWeikezhizuoListData();
+            },
+            handleCurrentPage(val) {
+                paginationServiceData.page = val;
+                this.getWeikezhizuoListData();
+            },
+            async getWeikezhizuoListData() {
+                const opt = Object.assign({}, this.searchOpt, paginationServiceData, { userId: this.userId });
+                delete opt.total;
+
+                const loading = this.$loading({ background: 'rgba(0, 0, 0, 0.7)' });
+                try {
+                    const res = await hezuoshang.getBusinessList(opt);
+                    if (res.code === 0) {
+                        this.updateTable(res.data);
+                    }
+                    loading.close();
+                } catch (e) {
+                    console.log('请求异常接口:getWeikezhizuoListData');
+                    loading.close();
+                }
+            },
+            updateTable(data) {
+                console.log(data);
+                tableServiceData.myData = data.data;
+                paginationServiceData.total = data.total;
+            },
+            clearData() {
+                paginationServiceData.page = 1;
+                paginationServiceData.size = 10;
+                paginationServiceData.total = 0;
+                tableServiceData.myData = [];
+            },
+        },
+        created() {
+            const userAuth = commonTools.getUserAuth();
+            this.userId = userAuth && userAuth.userId;
+        },
+        beforeDestroy() {
+            this.clearData();
+        },
+    };
+</script>
+
+<style lang="scss" scoped>
+    .admin-Registration-management {
+        padding: 20px;
+
+        .mta-Table {
+            margin-top: 20px;
+            height: calc(100vh - 274px) !important;
+        }
+
+        .my-Pagination {
+            margin-top: 20px;
+        }
+
+    }
+</style>