SanHQin пре 3 месеци
родитељ
комит
48898870bc

+ 6 - 4
src/components/dialog/addMenuDialog.vue

@@ -36,7 +36,7 @@
 							</el-image>
 						</el-tooltip>
 					</el-form-item>
-					<el-form-item label="菜单激活图标">
+					<el-form-item label="菜单激活图标" v-if="['admin-sidebar'].includes(this.tagType)">
 						<el-tooltip
 							class="item"
 							effect="dark"
@@ -84,16 +84,18 @@ export default {
 				children:[]
 			},
 			type: null,
+			tagType:null,
 		};
 	},
 	methods: {
-		open(data, type = "add") {
+		open(data, type = "add",tagType) {
 			if (data) {
 				this.form = JSON.parse(JSON.stringify(data));
 			} else {
 				this.init();
 			}
 			this.type = type;
+			this.tagType = tagType;
 			this.show = true;
 		},
 		close() {
@@ -109,8 +111,8 @@ export default {
 			};
 		},
 		submit() {
-			if(!this.form.menuName || !this.form.menuIcon || !this.form.menuActiveIcon)return this.$message.error("请完善表单")
-			this.$emit("success", {item:this.form,type:this.type});
+			if(!this.form.menuName || !this.form.menuIcon || (!['admin-school'].includes(this.tagType) && !this.form.menuActiveIcon ))return this.$message.error("请完善表单")
+			this.$emit("success", {item:this.form,type:this.type,tagType:this.tagType});
 		},
 		async addUrlIcon(type = "menuIcon") {
 			let _url = await this.uploadFile("image/*");

+ 332 - 35
src/components/dialog/permissionSettingDialog.vue

@@ -5,7 +5,7 @@
 			class="permissionSettingDialog"
 			:visible.sync="show"
 			:close-on-click-modal="false"
-			width="1000px"
+			width="1400px"
 			top="8vh"
 		>
 			<div v-loading="loading" class="ps_area">
@@ -42,13 +42,20 @@
 							@click="changeTagType('admin-sidebar')"
 							>平台侧边栏</span
 						>
+						<span
+							:class="{ pa_a_h_active: tagType == 'admin-school' }"
+							@click="changeTagType('admin-school')"
+							v-if="type == 'org'"
+							>学校设置</span
+						>
+						<!-- v-if="data.parentid" -->
 					</div>
 					<div class="ea_add">
 						<el-button
 							size="mini"
-							v-if="['admin-sidebar'].includes(tagType)"
+							v-if="['admin-sidebar', 'admin-school'].includes(tagType)"
 							type="primary"
-							@click="addMenu()"
+							@click="addMenu(tagType)"
 							>添加菜单</el-button
 						>
 						<el-button
@@ -1020,6 +1027,158 @@
 							</el-table>
 						</div>
 					</div>
+
+					<div
+						class="editArea pa_a_eb_admin-sidebar"
+						v-show="tagType == 'admin-school'"
+					>
+						<div class="ea_table">
+							<el-table
+								:data="form.admin.school.list"
+								stripe
+								border
+								style="width: 100%"
+								row-key="typeId"
+								:header-cell-style="headerCellStyle"
+								:tree-props="{
+									children: 'children',
+									hasChildren: 'hasChildren',
+								}"
+							>
+								<el-table-column
+									label="菜单名称"
+									min-width="200"
+									show-overflow-tooltip
+								>
+									<template slot-scope="scope">{{
+										scope.row.menuName ? scope.row.menuName : "-"
+									}}</template>
+								</el-table-column>
+
+								<el-table-column
+									label="菜单默认图标"
+									min-width="200"
+									show-overflow-tooltip
+								>
+									<template slot-scope="scope">
+										<el-image
+											v-if="scope.row.menuIcon"
+											style="width: 50px; height: 50px"
+											:src="scope.row.menuIcon"
+											fit="cover"
+										>
+											<div slot="error" class="image-slot">
+												<i class="el-icon-picture-outline"></i>
+											</div>
+										</el-image>
+										<span v-else>-</span>
+									</template>
+								</el-table-column>
+								<el-table-column
+									label="学校名称"
+									min-width="200"
+									show-overflow-tooltip
+								>
+									<template slot-scope="scope">{{
+										scope.row.name ? scope.row.name : "-"
+									}}</template>
+								</el-table-column>
+
+								<el-table-column
+									label="编码"
+									min-width="100"
+									show-overflow-tooltip
+								>
+									<template slot-scope="scope">{{
+										scope.row.code ? scope.row.code : "-"
+									}}</template>
+								</el-table-column>
+
+								<el-table-column
+									label="组织名称"
+									min-width="300"
+									show-overflow-tooltip
+								>
+									<template slot-scope="scope">{{
+										scope.row.orgName ? scope.row.orgName : "-"
+									}}</template>
+								</el-table-column>
+								<el-table-column
+									label="操作"
+									width="320px"
+									fixed="right"
+									show-overflow-tooltip
+								>
+									<template slot-scope="scope">
+										<button
+											@click="addSchool(scope.row.id)"
+											v-if="scope.row.menuName"
+											style="
+												color: #308fff;
+												background: none;
+												border: none;
+												cursor: pointer;
+												margin-left: 25px;
+											"
+										>
+											添加学校
+										</button>
+
+										<button
+											@click="editMenu(scope.row)"
+											v-if="scope.row.s"
+											style="
+												color: #308fff;
+												background: none;
+												border: none;
+												cursor: pointer;
+												margin-left: 25px;
+											"
+										>
+											修改
+										</button>
+										<button
+											@click="moveUp(scope.row, scope.row.typeId)"
+											style="
+												color: #308fff;
+												background: none;
+												border: none;
+												cursor: pointer;
+												margin-left: 25px;
+											"
+										>
+											上移
+										</button>
+										<button
+											@click="moveDown(scope.row, scope.row.typeId)"
+											style="
+												color: #308fff;
+												background: none;
+												border: none;
+												cursor: pointer;
+												margin-left: 25px;
+											"
+										>
+											下移
+										</button>
+
+										<button
+											@click="del(scope.row, scope.row.typeId)"
+											style="
+												color: #ff2570;
+												background: none;
+												border: none;
+												cursor: pointer;
+												margin-left: 25px;
+											"
+										>
+											删除
+										</button>
+									</template>
+								</el-table-column>
+							</el-table>
+						</div>
+					</div>
 				</div>
 			</div>
 			<!-- 按钮区域 -->
@@ -1032,6 +1191,11 @@
 		<addMenuDialog ref="addMenuDialogRef" @success="addMenuSuccess" />
 		<selectAppDialog ref="selectAppDialogRef" @success="selectAppSuccess" />
 		<addBannerDialog ref="addBannerDialogRef" @success="addBannerSuccess" />
+		<selectSchoolDialog
+			ref="selectSchoolDialogRef"
+			@success="selectSchoolSuccess"
+			:id="data?data.id:''"
+		/>
 	</div>
 </template>
 
@@ -1043,7 +1207,7 @@ import addMenuDialog from "./addMenuDialog.vue";
 import { addOp } from "@/api/user";
 import { mapGetters } from "vuex";
 import selectAppDialog from "./selectAppDialog.vue";
-
+import selectSchoolDialog from "./selectSchoolDialog.vue";
 import addBannerDialog from "./addBannerDialog";
 export default {
 	components: {
@@ -1051,6 +1215,7 @@ export default {
 		addMenuDialog,
 		selectAppDialog,
 		addBannerDialog,
+		selectSchoolDialog,
 	},
 	computed: {
 		...mapGetters(["userid"]),
@@ -1083,6 +1248,9 @@ export default {
 					sidebar: {
 						list: [],
 					},
+					school: {
+						list: [],
+					},
 				},
 			},
 		};
@@ -1092,12 +1260,14 @@ export default {
 			this.init();
 			let _data = JSON.parse(JSON.stringify(data));
 			if (_data.json) {
-				this.form = JSON.parse(_data.json);
+				let _form = JSON.parse(_data.json);
+				if (!_form.admin.school) {
+					_form.admin.school = { list: [] };
+				}
+				this.form = _form;
 			}
-			// this.getToolData();
 			Promise.all([this.getToolData(), this.getAppData()])
 				.then(() => {
-					// console.log(JSON.parse(JSON.stringify([this.toolList,this.appList])))
 					this.setDataListToo(this.toolList, this.appList);
 				})
 				.catch((e) => {
@@ -1132,6 +1302,9 @@ export default {
 					sidebar: {
 						list: [],
 					},
+					school: {
+						list: [],
+					},
 				},
 			};
 			this.type = null;
@@ -1363,6 +1536,36 @@ export default {
 					const itemToMove = this.form.admin.banner.splice(_index, 1)[0];
 					this.form.admin.banner.splice(_index - 1, 0, itemToMove);
 				}
+			} else if (this.tagType == "admin-school") {
+				let typeIdList = typeId.split("-");
+				console.log(typeIdList);
+				if (typeIdList.length == 1) {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == typeIdList[0]
+					);
+					if (_index > 0) {
+						const itemToMove = this.form.admin.school.list.splice(_index, 1)[0];
+						this.form.admin.school.list.splice(_index - 1, 0, itemToMove);
+					}
+				} else if (typeIdList.length == 2) {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == typeIdList[0]
+					);
+					let _index2 = this.form.admin.school.list[_index].children.findIndex(
+						(i) => i.code == typeIdList[1]
+					);
+					console.log(_index2);
+					if (_index2 > 0) {
+						const itemToMove = this.form.admin.school.list[
+							_index
+						].children.splice(_index2, 1)[0];
+						this.form.admin.school.list[_index].children.splice(
+							_index2 - 1,
+							0,
+							itemToMove
+						);
+					}
+				}
 			}
 		},
 		moveDown(row, typeId) {
@@ -1421,6 +1624,37 @@ export default {
 					const itemToMove = this.form.admin.banner.splice(_index, 1)[0];
 					this.form.admin.banner.splice(_index + 1, 0, itemToMove);
 				}
+			} else if (this.tagType == "admin-school") {
+				let typeIdList = typeId.split("-");
+				if (typeIdList.length == 1) {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == typeIdList[0]
+					);
+					if (_index < this.form.admin.school.list.length - 1) {
+						const itemToMove = this.form.admin.school.list.splice(_index, 1)[0];
+						this.form.admin.school.list.splice(_index + 1, 0, itemToMove);
+					}
+				} else if (typeIdList.length == 2) {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == typeIdList[0]
+					);
+					let _index2 = this.form.admin.school.list[_index].children.findIndex(
+						(i) => i.code == typeIdList[1]
+					);
+					if (
+						_index2 <
+						this.form.admin.school.list[_index].children.length - 1
+					) {
+						const itemToMove = this.form.admin.school.list[
+							_index
+						].children.splice(_index2, 1)[0];
+						this.form.admin.school.list[_index].children.splice(
+							_index2 + 1,
+							0,
+							itemToMove
+						);
+					}
+				}
 			}
 		},
 		del(row, typeId) {
@@ -1453,13 +1687,28 @@ export default {
 					this.form.admin.sidebar.list[_index].children.splice(_index2, 1);
 				}
 				// this.form.admin.sidebar.list.splice(_index, 1);
-			}else if(this.tagType == "admin-banner"){
-				const index = this.form.admin.banner.findIndex(
-					(i) => i.id === row.id
-				);
+			} else if (this.tagType == "admin-banner") {
+				const index = this.form.admin.banner.findIndex((i) => i.id === row.id);
 				if (index > -1) {
 					this.form.admin.banner.splice(index, 1);
 				}
+			} else if (this.tagType == "admin-school") {
+				let typeIdList = typeId.split("-");
+				if (typeIdList.length == 1) {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == typeIdList[0]
+					);
+					this.form.admin.school.list.splice(_index, 1);
+				} else if (typeIdList.length == 2) {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == typeIdList[0]
+					);
+					let _index2 = this.form.admin.school.list[_index].children.findIndex(
+						(i) => i.code == typeIdList[1]
+					);
+					this.form.admin.school.list[_index].children.splice(_index2, 1);
+				}
+				// this.form.admin.sidebar.list.splice(_index, 1);
 			}
 		},
 		getToolData() {
@@ -1653,42 +1902,74 @@ export default {
 				this.form.desktop.list
 			);
 		},
-		async addMenuSuccess({ item, type }) {
+		async addMenuSuccess({ item, type, tagType }) {
 			console.log(item, type);
-			if (type == "add") {
-				this.form.admin.sidebar.list.push(item);
-				item.id = String(new Date().getTime());
-				item.typeId = item.id;
-				await addOp({
-					uid: this.userid,
-					cid: "",
-					type: "user_op",
-					content: `添加了一级菜单:${item.menuName}`,
-				});
-			} else if (type == "edit") {
-				let _index = this.form.admin.sidebar.list.findIndex(
-					(i) => i.typeId == item.typeId
-				);
-				if (_index != -1) {
-					let _sidebar = JSON.parse(JSON.stringify(this.form.admin.sidebar));
-					_sidebar.list[_index] = item;
-					this.form.admin.sidebar = JSON.parse(JSON.stringify(_sidebar));
-					this.$forceUpdate();
+			if (tagType == "admin-sidebar") {
+				if (type == "add") {
+					item.id = String(new Date().getTime());
+					item.typeId = item.id;
+					this.form.admin.sidebar.list.push(item);
 					await addOp({
 						uid: this.userid,
 						cid: "",
 						type: "user_op",
-						content: `修改了了一级菜单:${item.menuName}`,
+						content: `添加了侧边栏一级菜单:${item.menuName}`,
 					});
+				} else if (type == "edit") {
+					let _index = this.form.admin.sidebar.list.findIndex(
+						(i) => i.typeId == item.typeId
+					);
+					if (_index != -1) {
+						let _sidebar = JSON.parse(JSON.stringify(this.form.admin.sidebar));
+						_sidebar.list[_index] = item;
+						this.form.admin.sidebar = JSON.parse(JSON.stringify(_sidebar));
+						this.$forceUpdate();
+						await addOp({
+							uid: this.userid,
+							cid: "",
+							type: "user_op",
+							content: `修改了侧边栏一级菜单:${item.menuName}`,
+						});
+					}
+				}
+			} else if (tagType == "admin-school") {
+				if (type == "add") {
+					item.id = String(new Date().getTime());
+					item.typeId = item.id;
+					delete item.menuActiveIcon;
+					this.form.admin.school.list.push(item);
+					await addOp({
+						uid: this.userid,
+						cid: "",
+						type: "user_op",
+						content: `添加了学校一级菜单:${item.menuName}`,
+					});
+				} else if (type == "edit") {
+					let _index = this.form.admin.school.list.findIndex(
+						(i) => i.typeId == item.typeId
+					);
+					if (_index != -1) {
+						let _school = JSON.parse(JSON.stringify(this.form.admin.school));
+						_school.list[_index] = item;
+						this.form.admin.school = JSON.parse(JSON.stringify(_school));
+						this.$forceUpdate();
+						await addOp({
+							uid: this.userid,
+							cid: "",
+							type: "user_op",
+							content: `修改了了学校一级菜单:${item.menuName}`,
+						});
+					}
 				}
 			}
+
 			this.$refs.addMenuDialogRef.close();
 		},
-		addMenu() {
-			this.$refs.addMenuDialogRef.open();
+		addMenu(type) {
+			this.$refs.addMenuDialogRef.open("", "add", type);
 		},
 		editMenu(row) {
-			this.$refs.addMenuDialogRef.open(row, "edit");
+			this.$refs.addMenuDialogRef.open(row, "edit", this.tagType);
 		},
 		addApp() {
 			this.$refs.selectAppDialogRef.open({
@@ -1714,6 +1995,22 @@ export default {
 			this.$forceUpdate();
 			this.$refs.selectAppDialogRef.close();
 		},
+		addSchool(id) {
+			console.log("👉", id);
+			let _children = this.form.admin.school.list.find(
+				(i) => i.id == id
+			).children;
+			this.$refs.selectSchoolDialogRef.open(_children, id);
+		},
+		selectSchoolSuccess({ data, type }) {
+			let _data = JSON.parse(JSON.stringify(data));
+			_data.forEach((i) => {
+				delete i.json;
+				i.typeId = `${type}-${i.code}`
+			});
+			this.form.admin.school.list.find((i) => i.id == type).children = _data;
+			this.$refs.selectSchoolDialogRef.close();
+		},
 	},
 };
 </script>

+ 206 - 0
src/components/dialog/selectSchoolDialog.vue

@@ -0,0 +1,206 @@
+<template>
+	<div>
+		<el-dialog
+			title="选择学校"
+			class="selectSchoolDialog"
+			:visible.sync="show"
+			:close-on-click-modal="false"
+			width="1400px"
+			@before-close="beforeClose"
+			:destroy-on-close="true"
+			top="8vh"
+		>
+			<div v-loading="loading" class="std_body">
+				<div class="std_b_table">
+					<el-table
+						ref="form"
+						:data="dataList"
+						v-if="show"
+						stripe
+						border
+						style="width: 100%;height: 100%;"
+						:header-cell-style="headerCellStyle"
+						row-key="id"
+						@selection-change="handleSelectionChange"
+					>
+						<el-table-column
+							type="selection"
+							width="45"
+							:selectable="selectable"
+							:reserve-selection="true"
+						></el-table-column>
+						<el-table-column
+							label="学校名称"
+							min-width="400"
+							show-overflow-tooltip>
+							<template slot-scope="scope">{{
+										scope.row.name ? scope.row.name : "-"
+									}}</template>
+						</el-table-column>
+
+						<el-table-column
+							label="编码"
+							min-width="300"
+							show-overflow-tooltip>
+							<template slot-scope="scope">{{
+										scope.row.code ? scope.row.code : "-"
+									}}</template>
+						</el-table-column>
+
+						<el-table-column
+							label="组织名称"
+							min-width="500"
+							show-overflow-tooltip>
+							<template slot-scope="scope">{{
+										scope.row.orgName ? scope.row.orgName : "-"
+									}}</template>
+						</el-table-column>
+					</el-table>
+				</div>
+
+			</div>
+			<!-- 按钮区域 -->
+			<div slot="footer" class="el-dialog__footer">
+				<el-button @click="close()">取 消</el-button>
+				<el-button type="primary" @click="submit()">确认</el-button>
+			</div>
+		</el-dialog>
+	</div>
+</template>
+
+<script>
+import { API_CONFIG } from "@/common/apiConfig";
+export default {
+	props:{
+		id:{
+			type:String,
+			default:""
+		},
+	},
+	data() {
+		return {
+			show: false,
+			loading: false,
+			dataList: [],
+			type: null,
+			selectList: [],
+			disableSelectList:[],
+		};
+	},
+	methods: {
+		// 表头的背景色
+		headerCellStyle() {
+			return { backgroundColor: "#f1f1f1" };
+		},
+		selectable(){
+			return true;
+			// if(this.type && ['desktop','admin-index','admin-sidebar2'].includes(this.type)){
+			// 	return true;
+			// }else if(this.type && ['admin-sidebar'].includes(this.type)){
+			// 	let _result = true;
+			// 	if(this.disableSelectList.findIndex(i=>i.id==row.id)!=-1){
+			// 		_result = false
+			// 	}
+			// 	return _result;
+			// }
+
+		},
+		open(data, type) {
+			this.show = true;
+
+			this.init();
+			this.selectList = data;
+			this.type = type;
+			this.getData()
+
+			this.$nextTick(() => {
+				if (data.length > 0) {
+					this.setTableSelect(data);
+				}
+			});
+		},
+		close() {
+			this.$refs.form.clearSelection();
+			this.$forceUpdate();
+			this.show = false;
+		},
+		init() {
+			this.dataList = [];
+			this.type = null;
+			this.selectList = [];
+		},
+		getData() {
+			new Promise((resolve) => {
+				let params = [
+					{
+						functionName: "select_liYuanCampus",
+						porg:this.id?this.id:'',
+					},
+				];
+				this.loading = true;
+				this.$ajax
+					.post(API_CONFIG.baseUrl, params)
+					.then((res) => {
+						let _data = res.data;
+						let _list = _data[0];
+						_list.forEach(i=>{
+							i.json = JSON.parse(i.json);
+						})
+						console.log(_list)
+						this.dataList = _list;
+						this.loading = false;
+						resolve();
+					})
+					.catch((err) => {
+						console.log(err);
+						this.loading = false;
+						this.$message.error("获取学校数据失败");
+					});
+			});
+		},
+		handleSelectionChange(val) {
+			this.selectList = val;
+		},
+		submit() {
+			this.$emit("success", {data:this.selectList, type:this.type});
+		},
+		setTableSelect(data) {
+				data.forEach((i) => {
+					this.$refs.form.toggleRowSelection(i, true);
+				});
+		},
+		getRowKeys(row) {
+			return row.id;
+		},
+		beforeClose(done) {
+			this.init();
+			done();
+		},
+	},
+};
+</script>
+
+<style scoped>
+.selectSchoolDialog >>> .el-dialog__header {
+	padding: 15px 20px;
+	background: #454545;
+}
+
+.selectSchoolDialog >>> .el-dialog__title {
+	color: #fff;
+}
+.std_body {
+	width: 100%;
+	height: 662px;
+	overflow: auto;
+	display: flex;
+	flex-direction: column;
+	justify-content: space-between;
+}
+
+.std_b_table {
+	width: 100%;
+	height: 620px;
+	overflow: auto;
+}
+</style>