lalala 6 лет назад
Родитель
Сommit
fff45f7ac8

+ 145 - 0
admin-code/src/components/module/sel-member.vue

@@ -0,0 +1,145 @@
+<template>
+	<el-dialog
+		title="选择会员"
+		:visible.sync="selDialog"
+		:close-on-click-modal="false"
+		:append-to-body="true"
+		width="800px"
+	>
+		<div class="recharge-modal-content">
+			<el-radio-group v-model="radio" class="radio-wrap">
+				<cl-crud class="liu-crud-wrap" @load="onLoad">
+					<template #table-column-radio="{scope}">
+						<div><el-radio :label="scope.row.index">选择</el-radio></div>
+					</template>
+
+					<template #table-column-userName="{scope}">
+						<div class="flex-center">
+							<cl-avatar
+								shape="square"
+								:size="40"
+								:src="scope.row.avatar | default_avatar"
+							></cl-avatar>
+							<div class="app-margin-left-10">{{ scope.row.userName }}</div>
+						</div>
+					</template>
+
+					<template #table-column-member="{scope}">
+						<div v-if="scope.row.member == -1">非会员</div>
+						<div v-else>{{ scope.row.userAsset.growth }}</div>
+					</template>
+				</cl-crud>
+			</el-radio-group>
+		</div>
+		<div slot="footer" class="dialog-footer">
+			<el-button size="small" @click="resetForm">取 消</el-button>
+			<el-button type="primary" size="small" @click="confirmFn">确定</el-button>
+		</div>
+	</el-dialog>
+</template>
+
+<script>
+export default {
+	name: 'sel-search',
+	props: {
+		show: {
+			type: Boolean,
+			default: false
+		},
+		multi: {
+			type: Boolean,
+			default: false
+		}
+	},
+	data() {
+		return {
+			selDialog: false,
+			ruleForm: {},
+			radio: '',
+			list: [],
+			selData: {}
+		};
+	},
+	watch: {
+		show(val) {
+			this.selDialog = val;
+		}
+	},
+	created() {},
+	methods: {
+		confirmFn() {
+			this.$emit('confirm', this.list[this.radio]);
+		},
+		resetForm() {
+			this.$refs['ruleForm'].resetFields();
+			this.$emit('cancel');
+		}, // cl-crud 组件ad
+		onLoad({ ctx, app }) {
+			this.app = app;
+			ctx.service(this.$service.member)
+				.set('table', {
+					columns: [
+						{
+							prop: 'radio',
+							label: '选择',
+							align: 'center',
+							'min-width': 60
+						},
+						{
+							prop: 'userName',
+							label: '会员名字',
+							align: 'center'
+						},
+						{
+							prop: 'mobile',
+							label: '手机号',
+							align: 'center'
+						},
+						{
+							prop: 'member',
+							label: '会员级别',
+							align: 'center'
+						},
+						{
+							prop: 'visitTimeFormat',
+							label: '最近访问',
+							align: 'center'
+						}
+					],
+					// 操作列
+					op: {
+						visible: false // 是否显示
+						// 同 element-ui Table-column Attributes
+					}
+				})
+				.set('pagination', {
+					size: 6
+				})
+				.set('layout', [
+					['slot-tabs'],
+					['search-key', 'flex1', 'refresh-btn'],
+					['data-table'],
+					['flex1', 'pagination']
+				])
+				.on('refresh', async (params, { next, render }) => {
+					// 继续执行刷新
+					let { list } = await next(params);
+					list.map((e, index) => {
+						e.index = index;
+					});
+					this.list = list;
+					render(list);
+				})
+				.done();
+			app.refresh({ type: this.tabIndex });
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+// 列表
+.radio-wrap {
+	display: block;
+}
+</style>

+ 1 - 1
admin-code/src/components/module/sel-search.vue

@@ -18,7 +18,7 @@
 							<cl-avatar
 								shape="square"
 								:size="40"
-								:src="scope.row.imgUrl"
+								:src="scope.row.imgUrl | default_avatar"
 								:style="{ margin: 'auto' }"
 							></cl-avatar>
 						</div>

+ 1 - 0
admin-code/src/cool/request/service.js

@@ -81,6 +81,7 @@ export class BaseService {
 	}
 
 	update(params) {
+		console.log('this', this);
 		return this.request({
 			url: '/update',
 			method: 'POST',

+ 13 - 2
admin-code/src/mock/userInfo.js

@@ -373,8 +373,19 @@ let menu = {
 			type: 0,
 			icon: 'iconkehuguanli',
 			orderNum: 2,
-			router: '/goods/list',
-			viewPath: 'views/goods/goods-list.vue',
+			router: '/staff/list',
+			viewPath: 'views/staff/list.vue',
+			keepAlive: 1
+		},
+		{
+			id: '901',
+			parentId: '9',
+			name: '员工管理',
+			type: 1,
+			icon: 'iconkehuguanli',
+			orderNum: 2,
+			router: '/staff/list',
+			viewPath: 'views/staff/list.vue',
 			keepAlive: 1
 		},
 		// 设置

+ 1 - 1
admin-code/src/service/common/index.js

@@ -102,7 +102,7 @@ export class CommonService extends BaseService {
 	}
 
 	/**
-	 * 用户信息
+	 * 节日信息
 	 *
 	 * @returns
 	 * @memberof CommonService

+ 7 - 1
admin-code/src/service/index.js

@@ -11,6 +11,9 @@ import imgStore from './img-store/index';
 import invite from './invite/index';
 import coupon from './coupon/index';
 import ad from './ad/index';
+import staff from './staff/index';
+import role from './role/index';
+import single from './single/index';
 
 Vue.prototype.$service = {
 	common,
@@ -24,7 +27,10 @@ Vue.prototype.$service = {
 	imgStore,
 	invite,
 	coupon,
-	ad
+	ad,
+	staff,
+	role,
+	single
 };
 
 export default Vue.prototype.$service;

+ 6 - 0
admin-code/src/service/role/index.js

@@ -0,0 +1,6 @@
+import { BaseService, Service } from '@/cool/index';
+
+@Service('admin-role')
+export class RoleService extends BaseService {}
+
+export default new RoleService();

+ 12 - 0
admin-code/src/service/single/index.js

@@ -0,0 +1,12 @@
+import { BaseService, Service } from '@/cool/index';
+
+export class SingleService extends BaseService {
+	log(data) {
+		return this.request({
+			url: '/admin-log/list',
+			params: data
+		});
+	}
+}
+
+export default new SingleService();

+ 6 - 0
admin-code/src/service/staff/index.js

@@ -0,0 +1,6 @@
+import { BaseService, Service } from '@/cool/index';
+
+@Service('admin')
+export class StaffService extends BaseService {}
+
+export default new StaffService();

+ 21 - 6
admin-code/src/views/ad/list.vue

@@ -59,7 +59,7 @@
 		</cl-crud>
 		<!-- 新增弹窗 -->
 		<el-dialog
-			:title="`添加广告图`"
+			:title="`${addOrModify == 1 ? '添加' : '修改'}广告图`"
 			:visible.sync="addDialog"
 			:close-on-click-modal="false"
 			width="600px"
@@ -189,11 +189,12 @@ export default {
 			// 修改弹窗
 			modifyData: {},
 			// 新增弹窗
+			addOrModify: 1,
 			addDialog: false,
 			adForm: {
 				adName: '',
 				adImg: '',
-				status: 1,
+				status: '1',
 				inTurn: 0,
 				type: '1',
 				style: '0',
@@ -226,17 +227,19 @@ export default {
 		// operate
 		modifyBtnFn(item) {
 			this.modifyData = item;
+			this.addOrModify = 2;
 			this.addDialog = true;
 			let data = JSON.parse(JSON.stringify(item));
 			data.startTime = this.$util.$formatDate(data.startTime);
 			data.endTime = this.$util.$formatDate(data.endTime);
 			if (this.$util.isEmpty(data)) return;
-			Object.keys(data).forEach((i, index) => {
+			Object.keys(this.adForm).forEach((i, index) => {
 				this.adForm[i] = data[i];
 			});
 		},
 		addBtnFn() {
 			this.addDialog = true;
+			this.addOrModify = 1;
 		},
 		handleClick(tab, e) {
 			this.app.refresh({ type: this.tabIndex });
@@ -253,12 +256,24 @@ export default {
 		addFn() {
 			let form = JSON.parse(JSON.stringify(this.adForm));
 			form.type = this.tabIndex;
-			if (form.style == '0') {
+			if (form.style == '1') {
 				form.url = '';
-			} else {
 				form.goodsId = this.goodsData.id;
 			}
-			this.$service.ad.add(form).then(res => {
+			let host = null;
+			if (this.addOrModify == 1) {
+				host = () => {
+					return this.$service.ad.add(form);
+				};
+			} else {
+				host = () => {
+					return this.$service.ad.update({
+						id: this.modifyData.id,
+						...form
+					});
+				};
+			}
+			host().then(res => {
 				this.$message.success('操作成功!');
 				this.resetForm();
 				this.app.refresh({ type: this.tabIndex });

+ 378 - 0
admin-code/src/views/staff/list.vue

@@ -0,0 +1,378 @@
+<template>
+	<div class="app-list-content">
+		<cl-crud class="liu-crud-wrap" @load="onLoad">
+			<template #table-column-nickName="{scope}">
+				<div class="flex-center">
+					<cl-avatar
+						shape="square"
+						:size="60"
+						:src="scope.row.avatarUrl | default_avatar"
+					></cl-avatar>
+					<div class="app-margin-left-10">{{ scope.row.nickName }}</div>
+				</div>
+			</template>
+
+			<template #table-column-incomeNotice="{scope}">
+				<el-switch
+					v-model="scope.row.incomeNotice"
+					active-value="1"
+					inactive-value="0"
+					@change="changeNotice(scope.row)"
+				></el-switch>
+			</template>
+
+			<template #table-column-status="{scope}">
+				<el-switch
+					v-model="scope.row.status"
+					active-value="1"
+					inactive-value="0"
+					@change="changeStatus(scope.row)"
+				></el-switch>
+			</template>
+
+			<!-- 编辑 -->
+			<template #slot-modify="{scope}">
+				<el-button type="text" @click="modifyBtnFn(scope.row)">编辑</el-button>
+			</template>
+			<!-- 删除 -->
+			<template #slot-del="{scope}">
+				<el-button type="text" @click="delBtnFn(scope.row)">删除</el-button>
+			</template>
+
+			<!-- 添加 -->
+			<template #slot-add-ad-btn="{scope}">
+				<el-button type="primary" size="mini" @click="addBtnFn">添加</el-button>
+			</template>
+		</cl-crud>
+		<!-- 新增弹窗 -->
+		<el-dialog
+			:title="`${addOrModify == 1 ? '添加' : '修改'}员工`"
+			:visible.sync="addDialog"
+			:close-on-click-modal="false"
+			width="600px"
+		>
+			<div class="ad-modal-content">
+				<el-form
+					:model="adForm"
+					:rules="ruleForm"
+					ref="adForm"
+					label-width="100px"
+					class="demo-form"
+				>
+					<el-form-item label="员工姓名" prop="adminName">
+						<el-input
+							v-model="adForm.adminName"
+							placeholder="请输入姓名"
+							size="small"
+						></el-input>
+					</el-form-item>
+					<el-form-item label="角色" prop="roleId">
+						<el-select v-model="adForm.roleId" size="small" placeholder="请选择角色">
+							<el-option
+								v-for="(item, index) in roleList"
+								:key="index"
+								:value="item.id"
+								>{{ item.roleName }}</el-option
+							>
+						</el-select>
+					</el-form-item>
+					<el-form-item label="关联微信" prop="userId">
+						<div>
+							<div class="member-wrap flex-center" v-if="!$util.isEmpty(memberData)">
+								<div class="member-img">
+									<cl-avatar
+										shape="square"
+										:size="40"
+										:src="memberData.avatarUrl | default_avatar"
+									></cl-avatar>
+								</div>
+								<div class="member-det">
+									<div class="app-size-28">{{ memberData.realName }}</div>
+									<div>{{ memberData.mobile }}</div>
+								</div>
+							</div>
+							<div>
+								<el-button type="primary" size="small" @click="selGoods"
+									>选择会员</el-button
+								>
+							</div>
+						</div>
+					</el-form-item>
+					<el-form-item label="收款通知" prop="remind">
+						<el-switch
+							v-model="adForm.remind"
+							active-value="1"
+							inactive-value="0"
+						></el-switch>
+					</el-form-item>
+					<el-form-item label="登陆密码" prop="password">
+						<el-input
+							v-model="adForm.password"
+							placeholder="请输入登录密码"
+							size="small"
+						></el-input>
+					</el-form-item>
+					<el-form-item label="备注">
+						<el-input v-model="adForm.remark" type="textarea" size="small"></el-input>
+					</el-form-item>
+					<el-form-item label="马上启用" prop="status">
+						<el-switch
+							v-model="adForm.status"
+							active-value="1"
+							inactive-value="0"
+						></el-switch>
+					</el-form-item>
+				</el-form>
+			</div>
+			<div slot="footer" class="dialog-footer">
+				<el-button size="small" @click="resetForm">取 消</el-button>
+				<el-button type="primary" size="small" @click="submitForm('adForm')"
+					>确认</el-button
+				>
+			</div>
+		</el-dialog>
+		<!-- 选择商品 -->
+		<sel-member
+			:show.sync="selMemberModal"
+			@confirm="selMemberConfirmFn"
+			@cancel="selMemberModal = false"
+		></sel-member>
+	</div>
+</template>
+
+<script>
+import selMember from '@/components/module/sel-member';
+
+export default {
+	name: 'list-ad',
+	components: {
+		selMember
+	},
+	data() {
+		return {
+			app: null,
+			// 修改弹窗
+			modifyData: {},
+			// 新增或者修改弹窗
+			addOrModify: 1,
+			addDialog: false,
+			adForm: {
+				adminName: '',
+				roleId: '',
+				remind: '1',
+				password: '',
+				userId: '',
+				remark: '',
+				status: '1'
+			},
+			ruleForm: {
+				adminName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+				roleId: [{ required: true, message: '请选择角色', trigger: 'change' }],
+				userId: [{ required: true, message: '请选择会员', trigger: 'blur' }],
+				password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
+			},
+			// 角色列表
+			roleList: [],
+			// 商品列表
+			selMemberModal: false,
+			memberData: {}
+		};
+	},
+	methods: {
+		// api
+		getRole() {
+			if (!this.$util.isEmpty(this.roleList)) return this.roleList;
+			this.$service.role.list().then(res => {
+				this.roleList = res.list;
+			});
+		},
+		delBtnFn(item) {
+			this.$confirm('是否删除该员工?', '提示', {
+				confirmButtonText: '确定',
+				cancelButtonText: '取消',
+				type: 'warning'
+			})
+				.then(() => {
+					this.$service.staff.delete({ id: item.id }).then(res => {
+						this.$message.success('删除成功!');
+						this.app.refresh({ type: this.tabIndex });
+					});
+				})
+				.catch();
+		},
+		// operate
+		modifyBtnFn(item) {
+			this.getRole();
+			this.addOrModify = 2;
+			this.modifyData = item;
+			this.addDialog = true;
+			let data = JSON.parse(JSON.stringify(item));
+			data.startTime = this.$util.$formatDate(data.startTime);
+			data.endTime = this.$util.$formatDate(data.endTime);
+			if (this.$util.isEmpty(data)) return;
+			Object.keys(this.adForm).forEach(i => {
+				if (i == 'password') return false;
+				this.adForm[i] = data[i];
+			});
+		},
+		addBtnFn() {
+			this.getRole();
+			this.addOrModify = 1;
+			this.addDialog = true;
+		},
+		// 切换收款通知
+		changeNotice(item) {},
+		changeStatus(item) {
+			this.$service.staff.updateStatus({ id: item.id, status: item.status }).then(res => {
+				this.$message.success('操作成功!');
+			});
+		},
+		resetForm() {
+			this.$refs['adForm'].resetFields();
+			this.memberData = {};
+			this.addDialog = false;
+		},
+
+		addFn() {
+			let host = null;
+			if (this.addOrModify == 1) {
+				host = () => {
+					return this.$service.staff.add(this.adForm);
+				};
+			} else {
+				host = () => {
+					return this.$service.staff.update({
+						id: this.modifyData.id,
+						...this.adForm
+					});
+				};
+			}
+			host(this.adForm).then(res => {
+				this.$message.success('操作成功!');
+				this.resetForm();
+				this.app.refresh({ type: this.tabIndex });
+			});
+		},
+		// 选择会员
+		selGoods() {
+			this.selMemberModal = true;
+		},
+		selMemberConfirmFn(item) {
+			this.memberData = item;
+			this.adForm.userId = item.id;
+			this.selMemberModal = false;
+		},
+		submitForm(formName) {
+			this.$refs[formName].validate(valid => {
+				if (valid) {
+					this.addFn();
+				} else {
+					console.log('error submit!!');
+					return false;
+				}
+			});
+		},
+		// cl-crud 组件ad
+		onLoad({ ctx, app }) {
+			this.app = app;
+			ctx.service(this.$service.staff)
+				.set('table', {
+					columns: [
+						{
+							prop: 'userId',
+							label: 'id',
+							align: 'center',
+							'min-width': 100
+						},
+						{
+							prop: 'nickName',
+							label: '微信名',
+							align: 'center',
+							'min-width': 120
+						},
+						{
+							prop: 'adminName',
+							label: '姓名',
+							align: 'center'
+						},
+						{
+							prop: 'mobile',
+							label: '手机号',
+							align: 'center'
+						},
+						{
+							prop: 'incomeNotice',
+							label: '收款通知',
+							align: 'center'
+						},
+						{
+							prop: 'roleName',
+							label: '角色',
+							align: 'center'
+						},
+						{
+							prop: 'addDate',
+							label: '添加时间',
+							align: 'center'
+						},
+						{
+							prop: 'lastLoginTime',
+							label: '最后登录',
+							align: 'center'
+						},
+						{
+							prop: 'status',
+							label: '是否启用',
+							align: 'center'
+						}
+					],
+					// 操作列
+					op: {
+						visible: true, // 是否显示
+						// 同 element-ui Table-column Attributes
+						props: {
+							width: 100,
+							align: 'center',
+							fixed: 'right',
+							label: '操作'
+						},
+						// 布局,请移步 `layout`
+						layout: ['slot-modify', 'slot-del']
+					}
+				})
+				.set('layout', [
+					['slot-tabs'],
+					['flex1', 'refresh-btn', 'slot-add-ad-btn'],
+					['data-table'],
+					['flex1', 'pagination']
+				])
+				// .on('refresh', async (params, { next, render }) => {
+				// 	// 继续执行刷新
+				// 	let { list } = await next(params);
+				// 	list.map((e, index) => {
+				// 		e.index = index;
+				// 		e.imgUrl = e.smallImgList[0];
+				// 	});
+				// 	this.list = list;
+				// 	render(list);
+				// })
+				.done();
+			app.refresh({ type: this.tabIndex });
+		}
+	}
+};
+</script>
+
+<style lang="scss" scoped>
+// module
+.ad-modal-content {
+	.member-wrap {
+		line-height: 1.4;
+		margin-bottom: 10px;
+		.member-det {
+			font-size: 12px;
+			margin-left: 10px;
+		}
+	}
+}
+</style>