Explorar el Código

添加com地区

11wqe1 hace 1 semana
padre
commit
e976da0258
Se han modificado 4 ficheros con 255 adiciones y 16 borrados
  1. 17 0
      src/api/user.js
  2. 2 2
      src/components/list.vue
  3. 3 3
      src/components/organList.vue
  4. 233 11
      src/components/schoolList.vue

+ 17 - 0
src/api/user.js

@@ -76,6 +76,23 @@ export function addSuffxSchool(data) {
   return axios.post(`${baseApi}addSuffxSchool`, [data])
 }
 
+// 添加学校
+export function insert_school3New(data) {
+  return axios.post(`${baseApi}insert_school3New`, [data])
+}
+
+// 修改年级
+export function updateGrade(data) {
+  return axios.get(`${baseApi}updateGrade`, data)
+}
+// 添加年级
+export function insertGrade(data) {
+  return axios.get(`${baseApi}insertGrade`, data)
+}
+// 查询年级
+export function selectGrade(data) {
+  return axios.get(`${baseApi}selectGrade`, data)
+}
 // 后缀管理 编辑学校
 export function exitSuffxSchool(data) {
   return axios.post(`${baseApi}exitSuffxSchool`, [data])

+ 2 - 2
src/components/list.vue

@@ -5,9 +5,9 @@
     <div class="title_examine">
       <div class="pub_title">账号列表</div>
       <div style="margin-left: auto">
-        <el-input v-model="s_name" placeholder="输入检索用户名" size="normal" clearable @input="changeOid"
+        <el-input v-model="s_name" placeholder="输入检索用户名" size="normal" clearable @change="changeOid"
           style="margin-right: 10px; width: 200px"></el-input>
-        <el-input v-model="s_username" placeholder="输入检索账号" size="normal" clearable @input="changeOid"
+        <el-input v-model="s_username" placeholder="输入检索账号" size="normal" clearable @change="changeOid"
           style="margin-right: 10px; width: 200px"></el-input>
         <el-select v-model="checkRole" placeholder="选择身份" clearable filterable @change="changeOid"
           style="margin-right: 10px; width: 120px">

+ 3 - 3
src/components/organList.vue

@@ -3,7 +3,7 @@
         <div class="title_examine">
             <div class="pub_title">组织列表</div>
             <div style="margin-left: auto;">
-                <el-input v-model="checkOrg" placeholder="请输入组织" size="normal" clearable @input="changeOrg"
+                <el-input v-model="checkOrg" placeholder="请输入组织" size="normal" clearable @change="changeOrg"
                     style="margin-right: 10px; width: 200px"></el-input>
                 <el-select v-model="checkArea" placeholder="选择区域" clearable filterable @change="changeArea"
                     style="margin-right: 10px">
@@ -641,8 +641,8 @@ export default {
                     if (res.data && Array.isArray(res.data[0])) {
                         // 使用 map() 提取所有组织名称
                         this.organizations = res.data[0]
-                        this.total = res.data[0][0].num
-
+                        this.total = res.data[0].length ? res.data[0][0].num : 0;
+                        
                         console.log(this.organizations);
 
                     }

+ 233 - 11
src/components/schoolList.vue

@@ -3,9 +3,9 @@
 		<div class="title_examine">
 			<div class="pub_title">学校列表</div>
 			<div style="margin-left: auto">
-				<el-input v-model="checkOid" placeholder="请输入学校" size="normal" clearable @input="changeOid"
+				<el-input v-model="checkOid" placeholder="请输入学校" size="normal" clearable @change="changeOid"
 					style="margin-right: 10px; width: 200px"></el-input>
-				<el-input v-model="checkOrg" placeholder="请输入组织" size="normal" clearable @input="changeOrg"
+				<el-input v-model="checkOrg" placeholder="请输入组织" size="normal" clearable @change="changeOrg"
 					style="margin-right: 10px; width: 200px"></el-input>
 				<el-select v-model="checkArea" placeholder="选择区域" clearable filterable @change="changeArea"
 					style="margin-right: 10px">
@@ -57,7 +57,7 @@
 						<span v-else>{{ scope.row.isLogin }}</span>
 					</template>
 				</el-table-column>
-				<el-table-column label="操作" width="380px">
+				<el-table-column label="操作" width="420px">
 					<template slot-scope="scope">
 						<div class="operate">
 							<button @click="update(scope.row)">编辑</button>
@@ -70,6 +70,7 @@
 							<button @click="permissionSetting(scope.row)"
 								v-show="!unShowJurUser.includes(userid)">权限设置</button>
 							<button @click="addcommunityL(scope.row)">添加社区</button>
+							<!-- <button @click="opengradia(scope.row.id)">年级管理</button> -->
 							<button @click="delete_school(scope.row)" style="color: red">
 								删除
 							</button>
@@ -181,6 +182,18 @@
 							</span>
 						</div>
 					</div>
+					<!-- 年级 -->
+					<!-- <div class="flexcol">
+						<div style="display: flex;gap: 15px;">
+							<span>年级</span>
+							<el-checkbox :indeterminate="graisInde" v-model="gracheckAll" @change="handleCheckAllChange">全选</el-checkbox>
+						</div>
+						<div>
+							<el-checkbox-group v-model="checkedGra" @change="hangraChange">
+								<el-checkbox v-for="city in gralist" :label="city" :key="city">{{city}}</el-checkbox>
+							</el-checkbox-group>
+						</div>
+					</div> -->
 				</form>
 			</div>
 			<!-- 按钮区域 -->
@@ -493,6 +506,7 @@
             </span>
         </el-dialog>
 
+		<!-- 添加社区成员  -->
         <el-dialog
             title="添加社区成员"
             :visible.sync="dialogaddCyperson"
@@ -568,6 +582,57 @@
                 <el-button type="primary" @click="addcyperson">确定</el-button>
             </span>
         </el-dialog>
+
+		<!-- 管理年级 -->
+		<el-dialog
+            title="管理年级"
+            :visible.sync="gradia"
+            :append-to-body="true"
+            width="600"
+            :close-on-click-modal="false"
+            :before-close="handleClose"
+            class="table"
+            >
+			<div>
+				<el-button size="mini" type="primary" @click="graopt(0)">添加年级</el-button>
+			</div>
+			<el-table
+				:data="gratab"
+				v-loading="graloading"
+			>
+				<el-table-column
+					prop="name"
+					label="年级"
+					>
+				</el-table-column>
+
+				<el-table-column label="操作" align="center" width="250">
+					<template slot-scope="scope">
+						<el-button size="mini" type="primary" @click="graopt(1,scope.row)">编辑</el-button>
+						<el-button size="mini" type="primary" @click="delGra(scope.row.id)">删除</el-button>
+					</template>
+				</el-table-column>
+			</el-table>
+		
+        </el-dialog>
+		<el-dialog
+            :title="`${isaddGra ? '修改' : '添加'}年级`"
+            :visible.sync="addgradia"
+            :append-to-body="true"
+            width="600"
+            :close-on-click-modal="false"
+            :before-close="handleClose"
+            class="table"
+            >
+			<div>{{`${isaddGra ? '修改' : '添加'}年级`}}</div>
+			<el-input v-model="graName" placeholder="请输入内容"></el-input>
+			<span slot="footer" class="dialog-footer">
+                <el-button @click="addgradia = false">取 消</el-button>
+                <el-button v-if="isaddGra == 0" type="primary" @click="insertGradeL(graName,graoid)">确定添加</el-button>
+                <el-button v-else type="primary" @click="updateGrade()">确定修改</el-button>
+
+            </span>
+        </el-dialog>
 		<permissionSettingDialog ref="permissionSettingDialogRef" @getData="getSchool" />
 	</div>
 </template>
@@ -576,6 +641,8 @@ import { addOp,addCommunity,
     getcylist,updateCommunity,
     getAddcyPersonlist,updateCommunityperson,
     getcypersonlist,delCommunity,updateCyOP } from "@/api/user";
+import { insert_school3New,insertGrade,selectGrade,updateGrade } from "@/api/user.js";
+
 import { API_CONFIG } from "@/common/apiConfig";
 import { mapGetters } from "vuex";
 import permissionSettingDialog from "./dialog/permissionSettingDialog";
@@ -586,6 +653,20 @@ export default {
 	},
 	data() {
 		return {
+			gracheckAll: false,
+			checkedGra: [],
+			gralist: ['一年级','二年级','三年级','四年级','五年级','六年级','七年级','八年级','九年级','高一','高二','高三'],
+			graisInde: false, //年级全选按钮
+			gradia:false,
+			addgradia:false,
+			graloading:false,
+			gratotal:0,
+			grapage:1,
+			gratab:[],
+			graName:'',
+			graoid:'',
+			graclaid:'',
+			isaddGra:0, //0是添加 1是修改
 			// 点击组织操作添加社区弹框
             dialogcommunity:false,
             // 打开添加信息组织弹框,存储的组织信息
@@ -655,6 +736,7 @@ export default {
 			regionCList: [
 				{ id: 1, name: "hk" },
 				{ id: 2, name: "cn" },
+				{ id: 3, name: "com" },
 			], //区域列表
 			organizations: [],
 			schoolDetail: "", //学校描述
@@ -665,6 +747,85 @@ export default {
 		};
 	},
 	methods: {
+		graopt(val,data){
+			this.isaddGra = val;
+			if (data && data.id) {
+				this.graclaid = data.id;
+				this.graName = data.name;
+			}else{
+				this.graName = '';
+			}
+			this.addgradia = true;
+		},   
+		//修改年级
+		updateGrade() {
+			let params = {
+				id: this.graclaid,
+				n: this.graName,
+				oid: this.graoid,
+			};
+			// this.ajax
+			// 	.get(this.$store.state.api + "updateGrade", params)
+			// 	.then((res) => {
+			updateGrade(params)
+			.then((res) => {
+				if (res.data[0] && res.data[0][0].classname == 1) {
+					this.$message({
+					message: "不能与其他年级名称相同!",
+					type: "error",
+					});
+				} else {
+					this.$message({
+					message: "年级修改成功!",
+					type: "success",
+					});
+					this.addgradia = false;
+					this.opengradia(this.graoid);
+					this.graName = '';
+					this.graclaid = '';
+				}
+			})
+			.catch((err) => {
+				this.$message({
+					message: this.lang.Modificationfailed,
+					type: "error",
+				});
+				console.error(err);
+			});
+		},
+		//获取年级列表
+		opengradia(oid) {
+			this.gradia = true;
+			this.graoid = oid;
+			this.graloading = true;
+			let params = {
+				cu: "",
+				oid: oid,
+				cn: '',
+				page: this.grapage,
+			};
+			console.log('params',params);
+			selectGrade(params)
+				.then(async (res) => {
+					this.gratotal = res.data[0].length > 0 ? res.data[0][0].num : 0;
+					this.gratab = res.data[0];
+					this.graloading = false;
+				})
+				.catch((error) => {
+                    this.graloading = false;
+					console.error("请求失败,错误信息:", error);
+				});
+		},
+		// 添加年级
+		handleCheckAllChange(val) {
+			this.checkedGra = val ? this.gralist : [];
+			this.graisInde = false;
+		},
+		hangraChange(value) {
+			let checkedCount = value.length;
+			this.gracheckAll = checkedCount === this.gralist.length;
+			this.graisInde = checkedCount > 0 && checkedCount < this.gralist.length;
+		},
 		addType(){
 			this.editCyInfo.typeL.push({
 				id: Date.now(),
@@ -673,6 +834,62 @@ export default {
 				children: []
 			})
 		},
+		async batchInstgra(oid){
+			let kk = []
+			for (let index = 0; index < this.checkedGra.length; index++) {
+				setTimeout(async () => {
+					kk.push(await this.insertGradeL(this.checkedGra[index],oid))
+				}, 500);
+			}
+			Promise.all(kk)
+				.then(() => {
+					this.checkedGra = [];
+					if (kk.indexOf(0) != -1) {
+						this.$message.error('年级未全部添加成功')
+					}else{
+						this.$message.success('年级添加成功')
+					}
+				})
+				.catch((e) => {
+					console.log("👉", e);
+				});
+		},
+		//新增年级
+		insertGradeL(val,oid) {
+			return new Promise((resolve, reject) => {
+				let params = {
+					name: val,
+					oid: oid,
+					uid: this.userid,
+				};
+				// console.log('params',params);
+				insertGrade(params)
+					.then((res) => {
+					if (res.data[0] && res.data[0][0].classname == 1) {
+						this.$message({
+							message: "不能与其他年级名称相同!",
+							type: "error",
+						});
+						reject(0)
+					} else {
+						if (this.graoid) {
+							this.$message({
+								message: "年级添加成功!",
+								type: "success",
+							});
+							this.addgradia = false;
+							this.opengradia(this.graoid);
+						}
+						resolve(1)
+					}
+					})
+					.catch((err) => {
+						reject(0)
+						console.error(err);
+					});
+			})
+		},
+		
 		Deltype(ind){
 			this.editCyInfo.typeL.splice(ind,1)
 		},
@@ -826,9 +1043,8 @@ export default {
 			if (this.schoolCode2 && this.schoolCode2.length && this.schoolCode2.length != 4) return this.$message.error("随机码须4位数");
 
 			// 构建请求参数
-			let params = [
+			let params = 
 				{
-					functionName: API_CONFIG.ajax_add_schoolN.functionName, // 调用存储过程的名称
 					u_name: this.sch_name, // 学校名称,绑定到 orgName
 					u_org: this.school.parentOrgId || "", // 选择的组织的 ID,绑定到 school.parentOrgId,如果没有选择则为空
 					u_dest: this.region || "", // 地区,绑定到 region,如果为空则传空字符串
@@ -839,16 +1055,14 @@ export default {
 					u_regionC: this.regionC || "",
 					u_isLogin: this.loginPermission === "1" ? 1 : 2, // 是否允许登录,默认传 2(不允许登录)如果没有选择
 					uid: this.userid,
-				},
-			];
+				};
 
 			// 发起请求
-			this.$ajax
-				.post(API_CONFIG.baseUrl, params)
+			insert_school3New(params)
 				.then(async (res) => {
 					// console.log("👉", res.data);
 					if (res.data && res.data[0] && res.data[0][0]) {
-						if (res.data[0][0].name === 1) {
+						if (res.data[0][0].insertId === 1) {
 							this.$message({
 								type: "error",
 								message: "该学校已存在,请重新选择!",
@@ -857,8 +1071,11 @@ export default {
 						} else {
 							this.$message({
 								type: "success",
-								message: "添加成功!",
+								message: "学校添加成功!",
 							});
+							// if (this.checkedGra.length) {
+							// 	this.batchInstgra(res.data[0][0].insertId)
+							// }
 							await addOp({
 								uid: this.userid,
 								cid: "",
@@ -1760,4 +1977,9 @@ export default {
     flex-direction: column;
     gap: 15px;
 }
+.flexcol{
+	display: flex;
+	flex-direction: column;
+	gap: 10px;
+}
 </style>