Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product

pull/2/head
tangqian 2023-05-17 18:21:41 +08:00
commit 711b61ca25
3 changed files with 212 additions and 79 deletions

View File

@ -53,11 +53,7 @@ export function exportUserExcel(query) {
})
}
// 用户状态修改
export function changeUserStatus(id, status) {
const data = {
id,
status
}
export function changeUserStatus(data) {
return request({
url: '/member/user/update-status',
method: 'put',

View File

@ -2,12 +2,23 @@
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="组织id" prop="orgId">
<el-input v-model="queryParams.orgId" placeholder="请输入组织id" clearable @keyup.enter.native="handleQuery"/>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="所属组织" prop="orgId">
<treeselect style="width: 240px;" v-model="queryParams.orgId" :options="deptOptions" :show-count="true"
:clearable="false"
placeholder="请选择所属组织" :normalizer="normalizer"/>
</el-form-item>
<el-form-item label="会员id" prop="userId">
<el-input v-model="queryParams.userId" placeholder="请输入会员id" clearable @keyup.enter.native="handleQuery"/>
<el-form-item label="启用状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
<el-form-item label="推广员名称" prop="nickname">
<el-input v-model="queryParams.nickname" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="手机号" prop="mobile">
<el-input v-model="queryParams.mobile" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
@ -19,38 +30,41 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['member:promoter:create']">新增</el-button>
v-hasPermi="['member:promoter:create']">新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport"
v-hasPermi="['system:user:import']">导入</el-button>
v-hasPermi="['system:user:import']">导入
</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"-->
<!-- v-hasPermi="['member:promoter:export']">导出</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"-->
<!-- v-hasPermi="['member:promoter:export']">导出</el-button>-->
<!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="推广员名称" align="center" prop="nickname" />
<el-table-column label="手机号" align="center" prop="mobile" />
<el-table-column label="所属组织" align="center" prop="orgName" />
<el-table-column label="启用状态" align="center" prop="status" >
<el-table-column label="编号" align="center" prop="id"/>
<el-table-column label="推广员名称" align="center" prop="nickname"/>
<el-table-column label="手机号" align="center" prop="mobile"/>
<el-table-column label="所属组织" align="center" prop="orgName"/>
<el-table-column label="启用状态" align="center" prop="status">
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row)" />
<el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1"
@change="handleStatusChange(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['member:promoter:update']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['member:promoter:delete']">修改密码</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleStatusChange(scope.row)"
v-hasPermi="['member:promoter:delete']">禁用</el-button>
v-hasPermi="['member:promoter:update']">修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleUpdatePassword(scope.row)"
v-hasPermi="['member:promoter:delete']">修改密码
</el-button>
</template>
</el-table-column>
</el-table>
@ -60,12 +74,24 @@
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="组织id" prop="orgId">
<el-input v-model="form.orgId" placeholder="请输入组织id" />
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="所属组织" prop="orgId">
<treeselect style="width: 240px;" v-model="form.orgId" :options="deptOptions" :show-count="true"
:clearable="false"
placeholder="请选择所属组织" :normalizer="normalizer"/>
</el-form-item>
<el-form-item label="会员id" prop="userId">
<el-input v-model="form.userId" placeholder="请输入会员id" />
<el-form-item label="启用状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="parseInt(dict.value)">{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="推广员姓名" prop="nickname">
<el-input v-model="form.nickname" placeholder="请输入"/>
</el-form-item>
<el-form-item label="推广员手机号" prop="mobile">
<el-input v-model="form.mobile" placeholder="请输入"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -81,11 +107,13 @@
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<!-- <div class="el-upload__tip" slot="tip">-->
<!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据-->
<!-- </div>-->
<!-- <div class="el-upload__tip" slot="tip">-->
<!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据-->
<!-- </div>-->
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
@click="importTemplate">下载模板
</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
@ -93,30 +121,62 @@
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
<!-- 修改密码 -->
<el-dialog title="修改密码" :visible.sync="updatePassword.show" width="500px" append-to-body>
<el-form ref="form" :model="updatePasswordForm" :rules="passwrodRules" label-width="80px">
<el-form-item label="密码" prop="title">
<el-input v-model="form.title" placeholder="请输入"/>
</el-form-item>
<el-form-item label="确认密码" prop="picUrl">
<el-input v-model="form.title" placeholder="请输入"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="updatePassword.show = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { createPromoter, updatePromoter, deletePromoter, getPromoter, getPromoterPage, importTemplate,exportPromoterExcel } from "@/api/member/promoter";
import {
createPromoter,
updatePromoter,
deletePromoter,
getPromoter,
getPromoterPage,
importTemplate,
exportPromoterExcel
} from '@/api/member/promoter';
import {
changeUserStatus
} from "@/api/member/user";
import {getBaseHeader} from "@/utils/request";
import {CommonStatusEnum} from "@/utils/constants";
import {DICT_TYPE} from "@/utils/dict";
} from '@/api/member/user';
import {listSimpleDepts} from '@/api/system/dept';
import {listSimplePosts} from '@/api/system/post';
import {getBaseHeader} from '@/utils/request';
import {CommonStatusEnum} from '@/utils/constants';
import {DICT_TYPE} from '@/utils/dict';
import Treeselect from '@riophae/vue-treeselect';
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
import ImageUpload from '@/components/ImageUpload/index.vue';
export default {
name: "Promoter",
name: 'Promoter',
computed: {
DICT_TYPE() {
return DICT_TYPE
}
},
components: {
ImageUpload,
Treeselect
},
data() {
return {
//
loading: true,
deptOptions: undefined,
//
exportLoading: false,
//
@ -126,7 +186,7 @@ export default {
// 广
list: [],
//
title: "",
title: '',
//
open: false,
//
@ -134,7 +194,7 @@ export default {
//
open: false,
//
title: "推广员导入",
title: '推广员导入',
//
isUploading: false,
//
@ -144,6 +204,11 @@ export default {
//
url: process.env.VUE_APP_BASE_API + '/admin-api/member/promoter/import'
},
updatePassword: {
show: false,
userId: ''
},
updatePasswordForm: {},
//
queryParams: {
pageNo: 1,
@ -155,15 +220,71 @@ export default {
form: {},
//
rules: {
orgId: [{ required: true, message: "组织id不能为空", trigger: "blur" }],
userId: [{ required: true, message: "会员id不能为空", trigger: "blur" }],
orgId: [{
required: true,
message: '请选择所属组织',
trigger: 'blur'
}],
status: [{
required: true,
message: '请选择状态',
trigger: 'blur'
}],
nickname: [{
required: true,
message: '请输入名称',
trigger: 'blur'
}],
mobile: [
{
required: true,
message: '请输入手机号',
trigger: 'blur'
},
{
pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
message: '请输入正确的手机号码',
trigger: 'blur'
}
]
}
};
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
//
normalizer(node) {
return {
id: node.id,
label: node.name,
children: node.children
}
},
/** 查询部门下拉树结构 + 岗位下拉 */
getTreeselect() {
listSimpleDepts().then(response => {
// deptOptions
this.deptOptions = [];
this.deptOptions.push(...this.handleTree(response.data, 'id'));
});
listSimplePosts().then(response => {
// postOptions
this.postOptions = [];
this.postOptions.push(...response.data);
});
},
//
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
this.queryParams.deptId = data.id;
},
/** 查询列表 */
getList() {
this.loading = true;
@ -179,6 +300,11 @@ export default {
this.open = false;
this.reset();
},
handleUpdatePassword(row) {
this.updatePasswordForm = {}
this.updatePassword.show = true
this.updatePassword.userId = row.userId
},
/** 表单重置 */
reset() {
this.form = {
@ -186,7 +312,7 @@ export default {
orgId: undefined,
userId: undefined,
};
this.resetForm("form");
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
@ -195,35 +321,32 @@ export default {
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.resetForm('queryForm');
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加推广员";
this.title = '添加推广员';
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
getPromoter(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改推广员";
});
this.form = row
this.open = true;
this.title = '修改推广员';
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs['form'].validate(valid => {
if (!valid) {
return;
}
//
if (this.form.id != null) {
updatePromoter(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$modal.msgSuccess('修改成功');
this.open = false;
this.getList();
});
@ -231,7 +354,7 @@ export default {
}
//
createPromoter(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.$modal.msgSuccess('新增成功');
this.open = false;
this.getList();
});
@ -240,21 +363,26 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal.confirm('是否确认删除推广员编号为"' + id + '"的数据项?').then(function() {
return deletePromoter(id);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
this.$modal.confirm('是否确认删除推广员编号为"' + id + '"的数据项?').then(function () {
return deletePromoter(id);
}).then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
}).catch(() => {
});
},
//
handleStatusChange(row) {
let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "禁用";
this.$modal.confirm('您确认要"' + text + '""' + row.nickname + '"推广员吗?').then(function() {
return changeUserStatus(row.user_id, row.status);
console.log('row', row)
let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '禁用';
this.$modal.confirm('您确认要"' + text + '""' + row.nickname + '"推广员吗?').then(function () {
return changeUserStatus({
id: row.userId,
status: row.status
});
}).then(() => {
this.$modal.msgSuccess(text + "成功");
}).catch(function() {
this.$modal.msgSuccess(text + '成功');
}).catch(function () {
row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
: CommonStatusEnum.ENABLE;
});
@ -266,16 +394,17 @@ export default {
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出所有推广员数据项?').then(() => {
this.exportLoading = true;
return exportPromoterExcel(params);
}).then(response => {
this.$download.excel(response, '推广员.xls');
this.exportLoading = false;
}).catch(() => {});
this.exportLoading = true;
return exportPromoterExcel(params);
}).then(response => {
this.$download.excel(response, '推广员.xls');
this.exportLoading = false;
}).catch(() => {
});
},
/** 导入按钮操作 */
handleImport() {
this.upload.title = "推广员导入";
this.upload.title = '推广员导入';
this.upload.open = true;
},
/** 下载模板操作 */
@ -307,7 +436,7 @@ export default {
for (const username in data.failureUsernames) {
text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username + '' + data.failureUsernames[username];
}
this.$alert(text, "导入结果", { dangerouslyUseHTMLString: true });
this.$alert(text, '导入结果', {dangerouslyUseHTMLString: true});
this.getList();
},
//

View File

@ -271,6 +271,10 @@ export default {
required: true,
message: '店铺负责人号码不能为空',
trigger: 'blur'
},{
pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
message: '请输入正确的手机号码',
trigger: 'blur'
}],
introduction: [{
required: true,
@ -279,12 +283,16 @@ export default {
}],
serviceTime: [{
required: true,
message: '服务不能为空',
message: '服务时间不能为空',
trigger: 'blur'
}],
serviceMobile: [{
required: true,
message: '服务不能为空',
message: '服务电话不能为空',
trigger: 'blur'
},{
pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
message: '请输入正确的手机或座机号码',
trigger: 'blur'
}]
}