lalala %!s(int64=6) %!d(string=hai) anos
pai
achega
2197896a14

+ 4 - 2
admin-code/src/App.vue

@@ -14,8 +14,10 @@ export default {
 			this.$store.dispatch('userInfo');
 		}
 		let source = this.$project == 'sass' ? 'sass' : 'admin';
-		localStorage.setItem('source', source);
-		localStorage.setItem('account', 12358);
+		if (source == 'admin') {
+			localStorage.setItem('source', source);
+			localStorage.setItem('account', 12358);
+		}
 	},
 
 	computed: {

+ 1 - 1
admin-code/src/assets/css/base.scss

@@ -33,7 +33,7 @@ $backColor: #f5f5f5;
 }
 
 .app-list-content {
-    height: 100%
+    height: 100%;
 }
 
 .app-content {

+ 1 - 1
admin-code/src/config/s-config.js → admin-code/src/config/b-config.js

@@ -1,5 +1,5 @@
 import Vue from 'vue';
 // 项目配置--由bat脚本变更
-export const ProjectName = 'sass';
+export const ProjectName = 'business';
 
 Vue.prototype.$projectName = ProjectName;

+ 1 - 1
admin-code/src/config/s-env.js → admin-code/src/config/b-env.js

@@ -22,7 +22,7 @@ const baseUrl = (() => {
 			return `/${proxy}`;
 		case 'production':
 			// return `/api/admin`;
-			return `http://api.s.huaml.com`;
+			return `http://api.b.huaml.com`;
 		default:
 			return '';
 	}

+ 1 - 1
admin-code/src/config/config.js

@@ -1,5 +1,5 @@
 import Vue from 'vue';
 // 项目配置--由bat脚本变更
-export const ProjectName = 'business';
+export const ProjectName = 'sass';
 
 Vue.prototype.$projectName = ProjectName;

+ 1 - 1
admin-code/src/config/env.js

@@ -22,7 +22,7 @@ const baseUrl = (() => {
 			return `/${proxy}`;
 		case 'production':
 			// return `/api/admin`;
-			return `http://api.b.huaml.com`;
+			return `http://api.s.huaml.com`;
 		default:
 			return '';
 	}

+ 2 - 2
admin-code/src/constant/constant.js

@@ -80,6 +80,6 @@ const _CONST_MAP = {
 			value: 4
 		}
 	]
-}
+};
 
-export const _filter_const_map = _CONST_MAP
+export const _filter_const_map = _CONST_MAP;

+ 27 - 27
admin-code/src/constant/constantFilter.js

@@ -1,11 +1,11 @@
-import { _filter_const_map } from './constant.js'
+import { _filter_const_map } from './constant.js';
 
 export const constFilter = (value, key) => {
-	_validateDefined(key)
+	_validateDefined(key);
 	for (let k in _filter_const_map[key]) {
-		if (_filter_const_map[key][k].value == value) return _filter_const_map[key][k].label
+		if (_filter_const_map[key][k].value == value) return _filter_const_map[key][k].label;
 	}
-}
+};
 /**
  * 验证配置项是否存在
  * @param key 配置项键名
@@ -13,26 +13,26 @@ export const constFilter = (value, key) => {
  */
 const _validateDefined = key => {
 	if (!_filter_const_map.hasOwnProperty(key)) {
-		throw new Error(`constant dosen't find ${key}`)
+		throw new Error(`constant dosen't find ${key}`);
 	}
-	return _filter_const_map[key]
-}
+	return _filter_const_map[key];
+};
 
 /**
  * 获取配置项
  * @param key 配置项键名
  */
 export const getDefined = key => {
-	return _validateDefined(key)
-}
+	return _validateDefined(key);
+};
 
 /**
  * 获取配置项深拷贝(在实例修改不影响原常量值)
  * @param key 配置项键名
  */
 export const getDefinedCopy = key => {
-	return JSON.parse(JSON.stringify(_validateDefined(key)))
-}
+	return JSON.parse(JSON.stringify(_validateDefined(key)));
+};
 
 /**
  * 获取配置项中的某个值 (只对数组或对象有效)
@@ -42,40 +42,40 @@ export const getDefinedCopy = key => {
  * @returns {{}} 某个值
  */
 export const getDefinedValue = (key, value, by = 'value') => {
-	let obj = _validateDefined(key)
-	let val = {}
+	let obj = _validateDefined(key);
+	let val = {};
 
 	if (typeof obj != 'object') {
-		return val
+		return val;
 	}
 
 	for (var _key of Object.keys(obj)) {
 		if (obj[_key][by] == value) {
-			return obj[_key]
+			return obj[_key];
 		}
 	}
 
-	return val
-}
+	return val;
+};
 
 /**
  * 输入key 值,将CONSTMAP中的key对应的Object按照value大小从小到达排序
  * @param {*} key
  */
 export const constMapToArray = key => {
-	_validateDefined(key)
-	let value = _filter_const_map[key]
+	_validateDefined(key);
+	let value = _filter_const_map[key];
 	if (!_.isPlainObject(value)) {
-		if (_.isArray(value)) return value
-		else throw new Error(`${value} must be Object or Array`)
+		if (_.isArray(value)) return value;
+		else throw new Error(`${value} must be Object or Array`);
 	} else {
-		let arr = []
+		let arr = [];
 		for (let k in value) {
-			arr.push(value[k])
+			arr.push(value[k]);
 		}
 		arr.sort((pre, next) => {
-			return pre.value - next.vaue
-		})
-		return arr
+			return pre.value - next.vaue;
+		});
+		return arr;
 	}
-}
+};

+ 2 - 1
admin-code/src/main.js

@@ -46,7 +46,8 @@ Vue.use(crud, {
 				// const { permission } = that.$store.state.menu;
 				// const { add, delete: del, update } = that.service.permission;
 
-				that.permission = {
+				// that.permission = {
+				return {
 					// add: permission.includes(add),
 					// delete: permission.includes(del),
 					// update: permission.includes(update)

+ 12 - 1
admin-code/src/mock/userInfo.js

@@ -342,11 +342,22 @@ let menu = {
 			router: '/sass/manage/auth',
 			viewPath: 'sass/manage/auth',
 			keepAlive: 1
+		},
+		{
+			id: '8',
+			parentId: null,
+			name: '权限',
+			type: 1,
+			icon: null,
+			orderNum: 1,
+			router: null,
+			viewPath: null,
+			keepAlive: 0
 		}
 	]
 };
 
-// Mock.mock(RegExp('/comm/person' + '.*'), 'get', req => {
+// Mock.mock(RegExp('/auth/login' + '.*'), 'get', req => {
 // 	// console.table(req);
 // 	return {
 // 		code: 1,

+ 1 - 1
admin-code/src/pages/layout/index.vue

@@ -90,7 +90,7 @@ export default {
 			}
 
 			.content-view {
-				height: 100%;
+				height: calc(100% - 10px);
 				width: 100%;
 				box-sizing: border-box;
 				overflow-x: hidden;

+ 0 - 1
admin-code/src/pages/login/index.js

@@ -57,7 +57,6 @@ export default {
 				if (this.$projectName == 'business') {
 					// 用户信息
 					await this.$store.dispatch('userInfo');
-
 					// 商户信息
 					await this.$store.dispatch('shopInfo');
 				} else {

+ 269 - 0
admin-code/src/sass/manage/auth.vue

@@ -0,0 +1,269 @@
+<template>
+	<div class="app-list-content">
+		<cl-crud @load="onLoad">
+			<template #table-column-icon="{scope}">
+				<icon-svg :name="scope.row.icon" size="20px"></icon-svg>
+			</template>
+
+			<!-- <template #table-column-perms="{scope}">
+				<el-tag
+					size="medium"
+					v-for="(item, index) in scope.row.permList"
+					:key="index"
+					style="margin: 2px"
+					>{{ item }}</el-tag
+				>
+			</template> -->
+			<!-- 
+			<template #table-column-router="{scope}">
+				<el-link type="primary" :href="scope.row.router" v-if="scope.row.type == 1">{{
+					scope.row.router
+				}}</el-link>
+				<span v-else>{{ scope.row.router }}</span>
+			</template>
+
+			<template #table-column-keepAlive="{scope}">
+				<template v-if="scope.row.type == 1">
+					<i class="el-icon-check" v-if="scope.row.keepAlive"></i>
+					<i class="el-icon-close" v-else></i>
+				</template>
+			</template> -->
+
+			<template #slot-column-op="{scope}">
+				<el-button
+					type="text"
+					size="mini"
+					@click="upsertAppend(scope.row)"
+					v-if="scope.row.type != 2"
+					>新增</el-button
+				>
+			</template>
+		</cl-crud>
+
+		<cl-context-menu ref="context-menu"></cl-context-menu>
+	</div>
+</template>
+
+<script>
+import { deepTree } from '@/cool/utils/index';
+
+export default {
+	data() {
+		return {
+			crud: null,
+			parentArr: []
+		};
+	},
+
+	methods: {
+		onLoad({ ctx, app }) {
+			this.crud = app;
+
+			ctx.service(this.$service.sassAuth)
+				.set('dict', {
+					api: {
+						page: 'authList',
+						add: 'authAdd',
+						update: 'authUpdate',
+						delete: 'authDel'
+					}
+				})
+				.set('table', {
+					columns: [
+						{
+							prop: 'authName',
+							label: '名称',
+							width: 200
+						},
+						{
+							prop: 'parentId',
+							label: '父级ID',
+							align: 'center',
+							'min-width': 160
+						},
+						{
+							prop: 'frontUrl',
+							label: '前端路由',
+							align: 'center',
+							'min-width': 160
+						},
+						{
+							prop: 'backUrl',
+							label: '后端路由',
+							align: 'center',
+							'min-width': 160
+						}
+						// {
+						// 	prop: 'addTime',
+						// 	label: '时间',
+						// 	align: 'center',
+						// 	sortable: true,
+						// 	width: 180
+						// }
+					],
+					props: {
+						'row-key': 'id'
+					},
+					on: {
+						'row-click': (row, column) => {
+							if (column.property && row.children) {
+								app.refs('table').toggleRowExpansion(row);
+							}
+						},
+
+						'row-contextmenu': (row, column, event) => {
+							let list = [
+								{
+									label: '编辑',
+									callback: (e, close) => {
+										app.edit(row);
+										close();
+									}
+								},
+								{
+									label: '删除',
+									callback: (e, close) => {
+										app.delete(row);
+										close();
+									}
+								}
+							];
+
+							// if (row.type != 2) {
+							// 	list.unshift({
+							// 		label: '新增',
+							// 		callback: (e, close) => {
+							// 			this.upsertAppend(row);
+							// 			close();
+							// 		}
+							// 	});
+							// }
+
+							this.$refs['context-menu'].open(event, {
+								list
+							});
+
+							event.preventDefault();
+						}
+					},
+					op: {
+						props: {
+							width: '200'
+						},
+
+						layout: ['slot-column-op', 'edit', 'delete']
+					}
+				})
+				.set('upsert', {
+					props: {
+						width: '600px'
+					},
+					items: [
+						{
+							prop: 'parentId',
+							label: '父权限',
+							span: 24,
+							component: {
+								name: 'el-select',
+								attrs: {
+									placeholder: '请选择'
+								},
+								options: this.parentArr
+							}
+							// rules: {
+							// 	required: true,
+							// 	message: '级别不能为空'
+							// }
+						},
+						{
+							prop: 'name',
+							label: '权限名',
+							span: 24,
+							component: {
+								name: 'el-input',
+								attrs: {
+									placeholder: '请输入名称'
+								}
+							},
+							rules: {
+								required: true,
+								message: '名称不能为空'
+							}
+						},
+						{
+							prop: 'frontUrl',
+							label: '前端路由',
+							span: 24,
+							component: {
+								name: 'el-input',
+								attrs: {
+									placeholder: '请输入'
+								}
+							},
+							rules: {
+								required: true,
+								message: '前端路由不能为空'
+							}
+						},
+						{
+							prop: 'backUrl',
+							label: '后端路由',
+							span: 24,
+							component: {
+								name: 'el-input',
+								attrs: {
+									placeholder: '请输入'
+								}
+							}
+						},
+						{
+							prop: 'endId',
+							label: 'endId',
+							span: 24,
+							value: '1',
+							component: {
+								name: 'el-input',
+								attrs: {
+									placeholder: '请输入'
+								}
+							}
+						}
+					]
+				})
+				.set('layout', [['refresh-btn', 'add-btn'], ['data-table']])
+				.on('refresh', async (params, { next, render }) => {
+					let { list } = await next(params);
+					list = JSON.parse(JSON.stringify(list));
+					list = list.map(e => {
+						e.label = e.authName;
+						e.value = e.id;
+						return e;
+					});
+					this.crud.setData('upsert.items[prop:parentId].component.options', list);
+					console.log(this.parentArr);
+				})
+				.done();
+
+			app.refresh();
+		},
+
+		upsertAppend({ type, id }) {
+			this.crud.append({
+				parentId: id,
+				type: type + 1
+			});
+		},
+
+		setPermission({ id }) {
+			this.crud.append({
+				parentId: id,
+				type: 2
+			});
+		},
+
+		toUrl(url) {
+			this.$router.push(url);
+		}
+	}
+};
+</script>

+ 141 - 0
admin-code/src/sass/manage/auth1.vue

@@ -0,0 +1,141 @@
+<template>
+	<div class="app-list-content">
+		<div class="auth-tree">
+			<el-button class="add-btn" type="primary" size="small">添加权限</el-button>
+			<el-tree
+				:data="data"
+				:props="defaultProps"
+				node-key="id"
+				default-expand-all
+				:expand-on-click-node="false"
+				:render-content="renderContent"
+			></el-tree>
+		</div>
+		<!-- addOrModify -->
+		<el-dialog
+			:title="`${'添加'}权限`"
+			:visible.sync="treeDialog"
+			:close-on-click-modal="false"
+			width="400px"
+		>
+			<div class="recharge-modal-content">
+				<el-form
+					:model="form"
+					:rules="rules"
+					ref="rechargeForm"
+					label-width="80px"
+					class="demo-form"
+				>
+					<el-form-item label="充值金额">
+						<el-input
+							v-model="form.rechargeAmount"
+							placeholder="充值金额"
+							size="small"
+						></el-input>
+					</el-form-item>
+					<el-form-item label="确认密码">
+						<el-input
+							v-model="form.confirmPassword"
+							type="password"
+							placeholder="确认密码"
+							size="small"
+						></el-input>
+					</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="confirmFn">充值</el-button>
+			</div>
+		</el-dialog>
+	</div>
+</template>
+
+<script>
+let id = 1000;
+export default {
+	name: 'auth-tree',
+	data() {
+		return {
+			data: [],
+			defaultProps: {
+				children: 'children',
+				label: 'authName'
+			},
+			form: {
+				endId: '1',
+				parentId: '',
+				authName: '',
+				frontUrl: '',
+				backUrl: ''
+			}
+		};
+	},
+	mounted() {
+		this.init();
+	},
+	methods: {
+		// api
+		init() {
+			this._list();
+		},
+		_list() {
+			this.$service.sassAuth.authList({ endId: 1 }).then(res => {
+				this.data = res;
+			});
+		},
+		// operate
+		append(data) {
+			const newChild = { id: id++, label: 'testtest', children: [] };
+			if (!data.children) {
+				this.$set(data, 'children', []);
+			}
+			data.children.push(newChild);
+		},
+
+		remove(node, data) {
+			const parent = node.parent;
+			const children = parent.data.children || parent.data;
+			const index = children.findIndex(d => d.id === data.id);
+			children.splice(index, 1);
+		},
+
+		renderContent(h, { node, data, store }) {
+			return (
+				<span class="custom-tree-node">
+					<span class="tree-label">{node.label}</span>
+					<span class="tree-btn-wrap">
+						<el-button size="small" type="text" on-click={() => this.append(data)}>
+							修改
+						</el-button>
+						<el-button
+							size="small"
+							type="text"
+							on-click={() => this.remove(node, data)}>
+							删除
+						</el-button>
+					</span>
+				</span>
+			);
+		}
+	}
+};
+</script>
+
+<style lang="scss" scoped>
+.auth-tree {
+	height: calc(100% - 10px);
+	padding-top: 10px;
+	background-color: #fff;
+	.add-btn {
+		margin-left: 20px;
+		margin-bottom: 20px;
+	}
+	/deep/.custom-tree-node {
+		margin-bottom: 4px;
+		.tree-btn-wrap {
+			margin-left: 100px;
+		}
+	}
+}
+</style>

+ 16 - 3
admin-code/src/service/sass/auth/index.js

@@ -6,6 +6,10 @@ export class FestService extends BaseService {
 		return this.request({
 			url: '/auth/tree',
 			params: data
+		}).then(res => {
+			return {
+				list: res
+			};
 		});
 	}
 
@@ -13,7 +17,7 @@ export class FestService extends BaseService {
 	authAdd(data) {
 		return this.request({
 			url: '/auth/add',
-			methods: 'POST',
+			method: 'POST',
 			data: data
 		});
 	}
@@ -22,7 +26,16 @@ export class FestService extends BaseService {
 	authEdit(data) {
 		return this.request({
 			url: '/auth/update',
-			methods: 'POST',
+			method: 'POST',
+			data: data
+		});
+	}
+
+	// 删除权限树 s
+	authDel(data) {
+		return this.request({
+			url: '/auth/delete',
+			method: 'POST',
 			data: data
 		});
 	}
@@ -52,7 +65,7 @@ export class FestService extends BaseService {
 	packageEdit(data) {
 		return this.request({
 			url: '/set-auth/update',
-			methods: 'POST',
+			method: 'POST',
 			data: data
 		});
 	}

+ 1 - 1
admin-code/src/service/sass/shop/index.js

@@ -21,7 +21,7 @@ export class ShopService extends BaseService {
 	applyCheck(data) {
 		return this.request({
 			url: '/apply/check',
-			methods: 'POST',
+			method: 'POST',
 			data: data
 		});
 	}