Browse Source

组织学校列表页面

lzw 6 months ago
parent
commit
d2f73755c2
3 changed files with 896 additions and 23 deletions
  1. 381 7
      src/components/organList.vue
  2. 513 14
      src/components/schoolList.vue
  3. 2 2
      src/views/HomeView.vue

+ 381 - 7
src/components/organList.vue

@@ -2,16 +2,34 @@
     <div class="list_container">
         <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"
+                    style="margin-right: 10px; width: 200px"></el-input>
+                <el-select v-model="checkArea" placeholder="选择区域" clearable filterable @change="changeArea"
+                    style="margin-right: 10px">
+                    <el-option v-for="item in regionCList" :key="item.id" :label="item.name" :value="item.name">
+                    </el-option>
+                </el-select>
+                <el-button type="primary" size="small" @click="add_organ_dialog = true;">新增组织</el-button>
+            </div>
         </div>
         <div class="tableBox">
             <el-table :data="organizations" stripe border style="width: 100%" :header-cell-style="headerCellStyle">
                 <el-table-column show-overflow-tooltip prop="name" label="组织名称" min-width="45"></el-table-column>
-                <el-table-column show-overflow-tooltip prop="code" label="编码" min-width="45"></el-table-column>
+                <el-table-column show-overflow-tooltip prop="code" label="编码" min-width="45">
+                    <template slot-scope="scope">
+                        {{ scope.row.code || '-' }} <!-- 如果 org 为空,显示 '-' -->
+                    </template>
+                </el-table-column>
+                <el-table-column show-overflow-tooltip prop="area" label="区域" min-width="45"></el-table-column>
                 <el-table-column show-overflow-tooltip prop="ctime" label="创建时间" min-width="45"></el-table-column>
                 <el-table-column label="操作" width="150px">
                     <template slot-scope="scope">
                         <div class="operate">
-                            <button style="color: #308fff;" @click="update(scope.row)">编辑</button>
+                            <button @click="update(scope.row)">编辑</button>
+                            <button @click="toPage(scope.row)">批量创建</button>
+                            <button @click="delete_organ(scope.row.id)" style="color:red;">删除</button>
+                            
                         </div>
                     </template>
                 </el-table-column>
@@ -21,29 +39,171 @@
         <el-pagination :current-page="currentPage" :page-size="pageSize" :total="total"
             @current-change="handlePageChange" layout="total,prev, pager, next, jumper">
         </el-pagination>
+        <!-- 新增组织弹窗 -->
+        <el-dialog title="新增组织" class="table" :visible.sync="add_organ_dialog" :before-close="close_add_organ"
+            width="700px">
+            <div class="el_dialog_org_content">
+                <form class="el-form">
+                    <!-- 组织名称 -->
+                    <div class="el-form-item" style="margin-top: 15px">
+                        <label class="el-form-item__label" style="width: 100px">组织名称</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="orgName" type="text" autocomplete="off" placeholder="组织名称"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 地区 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">组织编码</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="randomCode" type="text" autocomplete="off" placeholder="请输入随机码"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 区域 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">区域</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+
+                                    <el-select v-model="regionC" placeholder="请选择区域" class="custom-select" filterable>
+                                        <el-option v-for="(org, index) in regionCList" :key="index" :label="org.name"
+                                            :value="org.name">
+                                            {{ org.name }}
+                                        </el-option>
+                                    </el-select>
+
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <!-- 按钮区域 -->
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="close_add_organ">取 消</el-button>
+                <el-button type="primary" @click="ajax_add_org">确认</el-button>
+            </div>
+        </el-dialog>
+        <!-- 修改组织弹窗 -->
+        <el-dialog title="修改组织" class="table" :visible.sync="add_organ_dialog2" :before-close="close_add_organ2"
+            width="700px">
+            <div class="el_dialog_org_content">
+                <form class="el-form">
+                    <!-- 组织名称 -->
+                    <div class="el-form-item" style="margin-top: 15px">
+                        <label class="el-form-item__label" style="width: 100px">组织名称</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="orgName" type="text" autocomplete="off" placeholder="组织名称"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 地区 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">组织编码</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="randomCode" type="text" autocomplete="off" placeholder="请输入随机码"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 区域 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">区域</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+
+                                    <el-select v-model="regionC" placeholder="请选择区域" class="custom-select" filterable>
+                                        <el-option v-for="(org, index) in regionCList" :key="index" :label="org.name"
+                                            :value="org.name">
+                                            {{ org.name }}
+                                        </el-option>
+                                    </el-select>
+
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <!-- 按钮区域 -->
+            <div slot="footer" class="dialog-footer">
+                <el-button @click="close_add_organ2">取 消</el-button>
+                <el-button type="primary" @click="updateOrgan">确认</el-button>
+            </div>
+        </el-dialog>
     </div>
 </template>
 <script>
 import { API_CONFIG } from '@/common/apiConfig';
+import { mapGetters } from 'vuex';
 export default {
     name: 'onList',
     data() {
         return {
             organizations: [],
-            currentPage:1,
+            organList: [],
+            checkOrg: "",
+            checkArea: "",
+            currentPage: 1,
             pageSize: 10,
-            total: 0
+            total: 0,
+            add_organ_dialog: false,
+            add_organ_dialog2: false,
+            orgName: "",
+            randomCode: "",
+            regionC: 'cn',
+            uLogin: "1", // 登录状态 (1 或 2)
+            radio: "1",
+            regionCList: [
+                { id: 1, name: 'hk' },
+                { id: 2, name: 'cn' }
+            ], //区域列表
+            form: {
+                organ: ""
+            },
+            organ: {}
         }
     },
+    computed: {
+        ...mapGetters(['userid']),
+    },
     methods: {
         // 表头的背景色
         headerCellStyle() {
             return { backgroundColor: "#f1f1f1" };
         },
+        changeOrg() {
+            this.currentPage = 1;
+            this.getOrgan();
+        },
+        changeArea() {
+            this.currentPage = 1;
+            this.getOrgan();
+        },
         getOrgan() {
             let params = [
                 {
                     functionName: "getOrgan",
+                    org: this.checkOrg,
+                    area: this.checkArea,
                     page: this.currentPage,
                     num: this.pageSize,
                 }
@@ -56,8 +216,9 @@ export default {
                         // 使用 map() 提取所有组织名称
                         this.organizations = res.data[0]
                         this.total = res.data[0][0].num
-                        console.log(this.organizations);
-                        
+
+                        // console.log(this.organizations);
+
                     }
 
                 })
@@ -66,14 +227,184 @@ export default {
                     console.error("请求失败,错误信息:", err);
                 });
         },
+        ajax_org() {
+            const params = [API_CONFIG.ajax_org]; // 使用配置中的接口参数
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    // console.log("返回的数据为:", res.data);  // 检查返回的数据
+                    if (res.data && Array.isArray(res.data[0])) {
+                        // 使用 map() 提取所有组织名称
+                        this.organList = res.data[0].map((item) => ({
+                            name: item.name,
+                            id: item.id,
+                        }));
+                    }
+                    // console.log("返回的结果为:",this.organizations);
+                })
+                .catch((err) => {
+                    this.$message.error("查询失败");
+                    console.error("请求失败,错误信息:", err);
+                });
+        },
         // 页码扩展按钮
         handlePageChange(page) {
             this.currentPage = page;
             this.getOrgan();
         },
+        //新增学校关闭
+        close_add_organ() {
+            this.regionC = 'cn'
+            this.add_organ_dialog = false;
+        },
+        //修改学校关闭
+        close_add_organ2() {
+            this.regionC = 'cn'
+            this.add_organ_dialog2 = false;
+        },
+        //新增组织
+        ajax_add_org() {
+            // 获取弹窗中的输入内容
+            let orgName = this.orgName; // 组织名称
+            let randomCode = this.randomCode || ""; // 随机码(可为空)
+            let uLogin = this.radio; // 获取复选框选中的值(1 或 2)
+
+            // 验证组织名称不能为空
+            if (!orgName) {
+                this.$message.error("组织名称不能为空");
+                return;
+            }
+
+            // 构造请求参数
+            let params = [
+                {
+                    functionName: API_CONFIG.ajax_add_org.functionName, // 调用存储过程的名称
+                    u_name: orgName, // 组织名称
+                    u_create: this.userid, // u_create 固定为0
+                    u_code: randomCode, // 随机码(可以为空)
+                    u_regionC: this.regionC,
+                    u_login: uLogin, // 登录状态
+                },
+            ];
+
+            // 发起请求
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    console.log(res.data);
+                    // 检查返回的结果
+                    if (res.data && res.data[0] && res.data[0][0]) {
+                        if (res.data[0][0].name === 1) {
+                            this.$message({
+                                type: "error",
+                                message: "该组织已存在,请重新选择!",
+                            });
+                            return;
+                        } else {
+                            this.$message({
+                                type: "success",
+                                message: "添加成功!",
+                            });
+                        }
+                    } else {
+                        this.$message.error("插入失败,未返回有效结果");
+                    }
+                    // 刷新组织列表
+                    this.getOrgan();
+                    //关闭弹窗
+                    this.add_organ_dialog = false;
+                    // 清空输入框、下拉菜单选择和单选框
+                    this.orgName = ""; // 清空学校名称
+                    this.regionC = 'cn'
+                    this.randomCode = ""; // 清空地区选择
+                    this.uLogin = "1"; // 清空学校类型选择
+                })
+                .catch((err) => {
+                    this.$message.error("插入失败");
+                    console.error("请求失败,错误信息:", err);
+                });
+        },
+
+        update(row) {
+            this.add_organ_dialog2 = true;
+            this.nid = row.id;
+            this.orgName = row.name;
+            this.randomCode = row.code;
+            this.regionC = row.area;
+            console.log(row);
+        },
+        updateOrgan() {
+            let params = [
+                {
+                    functionName: "updateOrgan",
+                    id: this.nid,
+                    name: this.orgName,
+                    code: this.randomCode,
+                    area: this.regionC
+
+                }
+            ];
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    console.log("👉", res.data);
+                    this.add_organ_dialog2 = false;
+                    this.$message({
+                        message: '修改成功',
+                        type: 'success'
+                    });
+                    this.getOrgan();
+
+                })
+                .catch((err) => {
+                    this.$message.error("修改失败");
+                    console.log(err);
+                });
+        },
+        delete_organ(id) {
+            this.nid = id;
+
+            let params = [
+                {
+                    functionName: "deleteOrgan",
+                    id: this.nid
+                }
+            ];
+            this.$confirm("确定删除此组织记录吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    this.$ajax
+                        .post(API_CONFIG.baseUrl, params)
+                        .then((res) => {
+                            console.log("👉", res.data);
+                            this.$message({
+                                message: '删除成功',
+                                type: 'success'
+                            });
+                            this.getOrgan();
+
+                        })
+                })
+                .catch((err) => {
+                    this.$message.error("删除失败");
+                    console.log(err);
+                });
+        },
+        toPage(row) {
+            const oid = "";
+            const org = row.id;
+            const url=`https://pbl.cocorobo.cn/pbl-teacher-table/dist/?#/teacher?userid=${this.userid}&oid=${oid}&org=${org}`;
+            window.open(url,'_blank');
+        }
+
+
     },
     mounted() {
-        this.getOrgan()
+        this.getOrgan();
+        this.ajax_org();
     }
 }
 </script>
@@ -90,9 +421,52 @@ export default {
     margin: 10px 0;
 }
 
+.operate {
+    display: flex;
+    gap: 10px;
+}
+
+/* 新增组织的内容容器 */
+.el_dialog_org_content {
+    color: #606266;
+    font-size: 14px;
+    height: 120px;
+}
+
+.el-form-item {
+    margin-bottom: 22px;
+    display: flex;
+    align-items: center;
+    /* border: 1px solid black; */
+}
+
+.el-form-item__label {
+    font-size: 14px;
+    color: #606266;
+    line-height: 40px;
+    margin-left: 20px;
+    width: 70px;
+}
+
+.el-form-item__content {
+    line-height: 40px;
+    position: relative;
+    font-size: 14px;
+}
+
+.table>>>.el-dialog__header {
+    padding: 15px 20px;
+    background: #454545;
+}
+
+.table>>>.el-dialog__title {
+    color: #fff;
+}
+
 .operate button {
     background: none;
     border: none;
     cursor: pointer;
+    color: #308fff;
 }
 </style>

+ 513 - 14
src/components/schoolList.vue

@@ -2,17 +2,42 @@
     <div class="list_container">
         <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"
+                    style="margin-right: 10px; width: 200px"></el-input>
+                <el-input v-model="checkOrg" placeholder="请输入组织" size="normal" clearable @input="changeOrg"
+                    style="margin-right: 10px; width: 200px"></el-input>
+
+                <el-button type="primary" size="small" @click="add_school_dialog = true;">新增学校</el-button>
+            </div>
         </div>
         <div class="tableBox">
-            <el-table :data="schoolList" stripe border style="width: 100%" :header-cell-style="headerCellStyle">
+            <el-table :data="schoolData" stripe border style="width: 100%" :header-cell-style="headerCellStyle">
                 <el-table-column show-overflow-tooltip prop="name" label="学校名称" min-width="45"></el-table-column>
-                <el-table-column show-overflow-tooltip prop="dest" label="组织" min-width="45"></el-table-column>
-                <el-table-column show-overflow-tooltip prop="code" label="编码" min-width="45"></el-table-column>
+                <el-table-column show-overflow-tooltip prop="org_name" label="组织" min-width="45">
+                    <template slot-scope="scope">
+                        {{ scope.row.org_name || '-' }} <!-- 如果 org 为空,显示 '-' -->
+                    </template>
+                </el-table-column>
+                <el-table-column show-overflow-tooltip prop="org_code" label="组织编码" min-width="45">
+                    <template slot-scope="scope">
+                        {{ scope.row.org_code || '-' }} <!-- 如果 org 为空,显示 '-' -->
+                    </template>
+                </el-table-column>
+                <el-table-column show-overflow-tooltip prop="code" label="编码" min-width="45">
+                    <template slot-scope="scope">
+                        {{ scope.row.code || '-' }} <!-- 如果 org 为空,显示 '-' -->
+                    </template>
+                </el-table-column>
+                <el-table-column show-overflow-tooltip prop="area" label="区域" min-width="45"></el-table-column>
                 <el-table-column show-overflow-tooltip prop="ctime" label="创建时间" min-width="45"></el-table-column>
                 <el-table-column label="操作" width="150px">
                     <template slot-scope="scope">
                         <div class="operate">
-                            <button style="color: #308fff;" @click="update(scope.row)">编辑</button>
+                            <button @click="update(scope.row)">编辑</button>
+                            <button @click="toPage(scope.row)">批量创建</button>
+                            <button @click="delete_school(scope.row.id)" style="color:red;">删除</button>
+
                         </div>
                     </template>
                 </el-table-column>
@@ -22,18 +47,220 @@
         <el-pagination :current-page="currentPage" :page-size="pageSize" :total="total"
             @current-change="handlePageChange" layout="total,prev, pager, next, jumper">
         </el-pagination>
+        <!-- 新增学校弹窗 -->
+        <el-dialog title="新增学校" class="table" :visible.sync="add_school_dialog" :before-close="close_add_school"
+            width="700px">
+            <div class="el_dialog_school_content">
+                <form class="el-form">
+                    <!-- 学校名称 -->
+                    <div class="el-form-item" style="margin-top: 15px">
+                        <label class="el-form-item__label" style="width: 100px">学校名称</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="sch_name" type="text" autocomplete="off" placeholder="学校名称"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 地区 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">地区</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="region" type="text" autocomplete="off" placeholder="请输入地区"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 学校编码 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">学校编码</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="schoolCode" type="text" autocomplete="off" placeholder="请输入编码"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">上级组织</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <el-form :model="school" ref="form">
+                                        <el-select v-model="school.parentOrgId" placeholder="请选择组织"
+                                            class="custom-select" filterable>
+                                            <el-option v-for="(org, index) in organizations" :key="index"
+                                                :label="org.name" :value="org.id">
+                                                {{ org.name }}
+                                            </el-option>
+                                        </el-select>
+                                    </el-form>
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+
+                    <!-- 区域 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">区域</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+
+                                    <el-select v-model="regionC" placeholder="请选择区域" class="custom-select" filterable>
+                                        <el-option v-for="(org, index) in regionCList" :key="index" :label="org.name"
+                                            :value="org.name">
+                                            {{ org.name }}
+                                        </el-option>
+                                    </el-select>
+
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <!-- 按钮区域 -->
+            <div slot="footer" class="el-dialog__footer">
+                <el-button @click="close_add_school">取 消</el-button>
+                <el-button type="primary" @click="ajax_add_school">确认</el-button>
+            </div>
+        </el-dialog>
+        <!-- 修改学校弹窗 -->
+        <el-dialog title="修改学校" class="table" :visible.sync="add_school_dialog2" :before-close="close_add_school2"
+            width="700px">
+            <div class="el_dialog_school_content">
+                <form class="el-form">
+                    <!-- 学校名称 -->
+                    <div class="el-form-item" style="margin-top: 15px">
+                        <label class="el-form-item__label" style="width: 100px">学校名称</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="sch_name" type="text" autocomplete="off" placeholder="学校名称"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 地区 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">地区</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="region" type="text" autocomplete="off" placeholder="请输入地区"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <!-- 学校编码 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">学校编码</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <input v-model="schoolCode" type="text" autocomplete="off" placeholder="请输入编码"
+                                        class="el-input__inner" />
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">上级组织</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+                                    <el-form :model="school" ref="form">
+                                        <el-select v-model="school.parentOrgId" placeholder="请选择组织"
+                                            class="custom-select" filterable>
+                                            <el-option v-for="(org, index) in organizations" :key="index"
+                                                :label="org.name" :value="org.id">
+                                                {{ org.name }}
+                                            </el-option>
+                                        </el-select>
+                                    </el-form>
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+
+                    <!-- 区域 -->
+                    <div class="el-form-item">
+                        <label class="el-form-item__label" style="width: 100px">区域</label>
+                        <div class="el-form-item__content" style="margin-left: 5px">
+                            <span>
+                                <div class="add_input el-input el-input--suffix">
+
+                                    <el-select v-model="regionC" placeholder="请选择区域" class="custom-select" filterable>
+                                        <el-option v-for="(org, index) in regionCList" :key="index" :label="org.name"
+                                            :value="org.name">
+                                            {{ org.name }}
+                                        </el-option>
+                                    </el-select>
+
+                                </div>
+                            </span>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <!-- 按钮区域 -->
+            <div slot="footer" class="el-dialog__footer">
+                <el-button @click="close_add_school2">取 消</el-button>
+                <el-button type="primary" @click="updateSchool()">确认</el-button>
+            </div>
+        </el-dialog>
     </div>
 </template>
 <script>
 import { API_CONFIG } from '@/common/apiConfig';
+import { mapGetters } from 'vuex';
+
 export default {
     name: 'schoolList',
     data() {
         return {
+            schoolData: [],
             schoolList: [],
-            currentPage:1,
+            cn_school: [],
+            checkOid: "",
+            checkOrg: "",
+            currentPage: 1,
             pageSize: 10,
-            total: 0
+            total: 0,
+            add_school_dialog: false,
+            add_school_dialog2: false,
+            sch_name: "", //学校名称
+            form: {
+                name: "",
+                account: "",
+                organization: "",
+                school: "",
+            },
+            school: {
+                OrgId: null, // 初始化 OrgId 为 null 或适当的默认值
+                parentOrgId: ''
+            },
+            region: "", //地区
+            schoolCode: "", //学校编码
+            regionC: 'cn', //区域
+            regionCList: [
+                { id: 1, name: 'hk' },
+                { id: 2, name: 'cn' }
+            ], //区域列表
+            organizations: [],
+            schoolType: "1", //学校单选框类型
+            loginPermission: "1", //是否允许登录
+            nid: "", //修改学校的id
         }
     },
     methods: {
@@ -41,10 +268,20 @@ export default {
         headerCellStyle() {
             return { backgroundColor: "#f1f1f1" };
         },
-        getOrgan() {
+        changeOrg() {
+            this.currentPage = 1;
+            this.getSchool();
+        },
+        changeOid() {
+            this.currentPage = 1; // 重置当前页
+            this.getSchool(); // 调用获取数据的方法
+        },
+        getSchool() {
             let params = [
                 {
                     functionName: "getSchoolList",
+                    sName: this.checkOid,
+                    oName: this.checkOrg,
                     page: this.currentPage,
                     num: this.pageSize,
                 }
@@ -55,10 +292,15 @@ export default {
                     // console.log("返回的数据为:", res.data);  // 检查返回的数据
                     if (res.data && Array.isArray(res.data[0])) {
                         // 使用 map() 提取所有组织名称
-                        this.schoolList = res.data[0]   
-                        this.total = res.data[0][0].num
-                        // console.log(res.data[0].num);
-                        
+                        this.schoolData = res.data[0]
+
+                        if (this.schoolData.length > 0 && res.data[0][0] && res.data[0][0].num !== undefined) {
+                            this.total = res.data[0][0].num; // 使用 num 的值
+                        } else {
+                            this.total = 0; // 设置总数为0
+                        }
+                    } else {
+                        this.total = 0; // 如果没有数据,设置总数为0
                     }
 
                 })
@@ -67,15 +309,228 @@ export default {
                     console.error("请求失败,错误信息:", err);
                 });
         },
+        ajax_school() {
+            // 构建请求参数
+            let params = [
+                {
+                    functionName: "getAllSchool", // 调用存储过程的名称
+                },
+            ];
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    // console.log("返回的数据为:", res.data);  // 检查返回的数据
+                    if (res.data && Array.isArray(res.data[0])) {
+                        this.cn_school = res.data[0].map((item) => ({
+                            name: item.name,
+                            id: item.id,
+                            org: item.org,
+                            area: item.area
+                        }));
+                        // 将 name 和 org 都存入 cn_school 数组中
+                        this.schoolList = res.data[0].map((item) => ({
+                            name: item.name,
+                            id: item.id,
+                            org: item.org,
+                            area: item.area
+                        }));
+                        // console.log(this.schoolList);
+                    }
+                })
+                .catch((err) => {
+                    this.$message.error("查询失败");
+                    console.error("请求失败,错误信息:", err);
+                });
+        },
         // 页码扩展按钮
         handlePageChange(page) {
             this.currentPage = page;
-            this.getOrgan();
+            this.getSchool();
+        },
+        close_add_school() {
+            this.add_school_dialog = false;
+        },
+        close_add_school2() {
+            this.add_school_dialog2 = false;
+            this.sch_name = ""; // 清空学校名称
+            this.school.parentOrgId = ""; // 清空组织选择
+            this.region = ""; // 清空地区选择
+            this.regionC = 'cn'
+            this.schoolType = "1"; // 清空学校类型选择
+            this.schoolCode = ""; // 清空学校编码
+            this.loginPermission = "1"; // 清空登录权限的选择
+        },
+        //组织查询
+        ajax_org() {
+            const params = [API_CONFIG.ajax_org]; // 使用配置中的接口参数
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    // console.log("返回的数据为:", res.data);  // 检查返回的数据
+                    if (res.data && Array.isArray(res.data[0])) {
+                        // 使用 map() 提取所有组织名称
+                        this.organizations = res.data[0].map((item) => ({
+                            name: item.name,
+                            id: item.id,
+                        }));
+                    }
+                    // console.log("返回的结果为:", this.organizations);
+                })
+                .catch((err) => {
+                    this.$message.error("查询失败");
+                    console.error("请求失败,错误信息:", err);
+                });
+        },
+        ajax_add_school() {
+            // 校验学校名称是否为空
+            if (!this.sch_name || this.sch_name.trim() === "") {
+                this.$message.error("学校名称不能为空!");
+                return;
+            }
+
+            // 构建请求参数
+            let params = [
+                {
+                    functionName: API_CONFIG.ajax_add_school.functionName, // 调用存储过程的名称
+                    u_name: this.sch_name, // 学校名称,绑定到 orgName
+                    u_org: this.school.parentOrgId || "", // 选择的组织的 ID,绑定到 school.parentOrgId,如果没有选择则为空
+                    u_dest: this.region || "", // 地区,绑定到 region,如果为空则传空字符串
+                    u_type: this.schoolType || "", // 学校类型,绑定到 schoolType,如果没有选择则为空
+                    u_code: this.schoolCode || "", // 学校编码,绑定到 schoolCode,如果为空则传空字符串
+                    u_regionC: this.regionC || "",
+                    u_isLogin: this.loginPermission === "1" ? 1 : 2, // 是否允许登录,默认传 2(不允许登录)如果没有选择
+                    uid: this.userid,
+                },
+            ];
+
+            // 发起请求
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    // console.log("👉", res.data);
+                    if (res.data && res.data[0] && res.data[0][0]) {
+                        if (res.data[0][0].name === 1) {
+                            this.$message({
+                                type: "error",
+                                message: "该学校已存在,请重新选择!",
+                            });
+                            return;
+                        } else {
+                            this.$message({
+                                type: "success",
+                                message: "添加成功!",
+                            });
+                        }
+                    } else {
+                        this.$message.error("插入失败,未返回有效结果");
+                    }
+                    // 刷新学校列表
+                    this.getSchool();
+                    // 关闭弹窗
+                    this.add_school_dialog = false;
+                    // 清空输入框、下拉菜单选择和单选框
+                    this.sch_name = ""; // 清空学校名称
+                    this.school.parentOrgId = ""; // 清空组织选择
+                    this.region = ""; // 清空地区选择
+                    this.regionC = 'cn'
+                    this.schoolType = "1"; // 清空学校类型选择
+                    this.schoolCode = ""; // 清空学校编码
+                    this.loginPermission = "1"; // 清空登录权限的选择
+                })
+                .catch((err) => {
+                    this.$message.error("插入失败");
+                    console.error("请求失败,错误信息:", err);
+                });
+        },
+        update(row) {
+            this.nid = row.id;
+            this.add_school_dialog2 = true;
+            this.sch_name = row.name;
+            this.school.parentOrgId = row.org;
+            this.region = row.dest;
+            this.schoolCode = row.code;
+            this.regionC = row.area;
+
+        },
+        updateSchool() {
+            let params = [
+                {
+                    functionName: "updateSchool",
+                    id: this.nid,
+                    name: this.sch_name,
+                    dest: this.region,
+                    code: this.schoolCode,
+                    organ: this.school.parentOrgId,
+                    area: this.regionC
+
+                }
+            ];
+            this.$ajax
+                .post(API_CONFIG.baseUrl, params)
+                .then((res) => {
+                    console.log("👉", res.data);
+                    this.add_school_dialog2 = false;
+                    this.$message({
+                        message: '修改成功',
+                        type: 'success'
+                    });
+                    this.getSchool();
+
+                })
+                .catch((err) => {
+                    this.$message.error("修改失败");
+                    console.log(err);
+                });
         },
+        delete_school(id) {
+            this.nid = id;
+
+            let params = [
+                {
+                    functionName: "deleteSchool",
+                    id: this.nid
+                }
+            ];
+            this.$confirm("确定删除此学校记录吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    this.$ajax
+                        .post(API_CONFIG.baseUrl, params)
+                        .then((res) => {
+                            console.log("👉", res.data);
+                            this.$message({
+                                message: '删除成功',
+                                type: 'success'
+                            });
+                            this.getSchool();
+
+                        })
+                })
+                .catch((err) => {
+                    this.$message.error("删除失败");
+                    console.log(err);
+                });
+        },
+        toPage(row) {
+            const oid = row.id;
+            const org = row.org;
+            const url=`https://pbl.cocorobo.cn/pbl-teacher-table/dist/?#/teacher?userid=${this.userid}&oid=${oid}&org=${org}`;
+            window.open(url,'_blank');
+        }
+
     },
     mounted() {
-        this.getOrgan()
-    }
+        this.getSchool();
+        this.ajax_org();
+        this.ajax_school();
+    },
+    computed: {
+        ...mapGetters(["userid"]),
+
+    },
 }
 </script>
 <style scoped>
@@ -87,13 +542,57 @@ export default {
     overflow: auto;
 }
 
+/* 新增学校的内容容器 */
+.el_dialog_school_content {
+    color: #606266;
+    font-size: 14px;
+    /* height: 300px; */
+}
+
+.el-form-item {
+    margin-bottom: 22px;
+    display: flex;
+    align-items: center;
+    /* border: 1px solid black; */
+}
+
+.el-form-item__label {
+    font-size: 14px;
+    color: #606266;
+    line-height: 40px;
+    margin-left: 20px;
+    width: 70px;
+}
+
+.el-form-item__content {
+    line-height: 40px;
+    position: relative;
+    font-size: 14px;
+}
+
+.table>>>.el-dialog__header {
+    padding: 15px 20px;
+    background: #454545;
+}
+
+.table>>>.el-dialog__title {
+    color: #fff;
+}
+
+
 .tableBox {
     margin: 10px 0;
 }
 
+.operate {
+    display: flex;
+    gap: 10px;
+}
+
 .operate button {
     background: none;
     border: none;
     cursor: pointer;
+    color: #308fff;
 }
 </style>

+ 2 - 2
src/views/HomeView.vue

@@ -22,9 +22,9 @@
           <router-link class="menu_left" to="/school-list">
             <i class="el-icon-school"></i>学校列表
           </router-link>
-          <!-- <router-link class="menu_left" to="/version-add">
+          <router-link class="menu_left" to="/version-add">
             <i class="el-icon-office-building"></i>版本更新
-          </router-link> -->
+          </router-link>
         </ul>
       </div>
       <div class="table-container">