school.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. <template>
  2. <div
  3. class="pb_content"
  4. style="
  5. overflow: auto;
  6. margin: 0px;
  7. box-sizing: border-box;
  8. width: 100%;
  9. height: 100%;
  10. "
  11. >
  12. <div>
  13. <div
  14. class="pb_content_body"
  15. style="
  16. background: #fff;
  17. padding: 0px 25px;
  18. box-sizing: border-box;
  19. margin: 10px auto 0;
  20. "
  21. >
  22. <div class="pb_head">
  23. <span>学校管理</span>
  24. <!-- <span>备注:教师可以根据课程、班级条件筛选学生并查看该学生信息</span> -->
  25. </div>
  26. </div>
  27. <div class="allBox">
  28. <div class="halfBox" style="width: 58%">
  29. <div class="student_head">
  30. <div>参与校</div>
  31. <div>
  32. <el-button size="small" type="primary" @click="openAddSchool(1)">
  33. 添加学校</el-button
  34. >
  35. </div>
  36. </div>
  37. <div style="margin: 0 auto 10px">
  38. <div class="student_table">
  39. <el-table
  40. ref="table"
  41. :data="tableData"
  42. stripe
  43. border
  44. :header-cell-style="{
  45. background: '#f1f1f1',
  46. 'text-align': 'center',
  47. }"
  48. :cell-style="{ 'text-align': 'center' }"
  49. style="width: 100%"
  50. :height="tableHeight"
  51. v-loading="isLoading"
  52. >
  53. <el-table-column prop="name" label="学校名称" min-width="30">
  54. </el-table-column>
  55. <el-table-column label="联结学校" min-width="10" align="center">
  56. <template slot-scope="scope">
  57. <div>
  58. {{ scope.row.cname ? scope.row.cname : "暂无" }}
  59. </div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="date" label="操作" min-width="30">
  63. <template slot-scope="scope">
  64. <div class="pb_buttonBox">
  65. <el-button
  66. size="mini"
  67. type="primary"
  68. @click="openNoCSchool(scope.row.id, scope.row.cname)"
  69. >联结</el-button
  70. >
  71. <el-button
  72. size="mini"
  73. type="primary"
  74. @click="
  75. updateS(
  76. scope.row.id,
  77. scope.row.name,
  78. scope.row.dest,
  79. 1
  80. )
  81. "
  82. >修改</el-button
  83. >
  84. <el-button
  85. size="mini"
  86. type="primary"
  87. @click="deleteSchool(scope.row.id, 1)"
  88. >删除
  89. </el-button>
  90. </div>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </div>
  96. <div class="student_page">
  97. <el-pagination
  98. background
  99. layout="prev, pager, next"
  100. :page-size="10"
  101. :total="total"
  102. v-if="page"
  103. @current-change="handleCurrentChange"
  104. ></el-pagination>
  105. </div>
  106. </div>
  107. <div class="halfBox" style="width: 40%">
  108. <div class="student_head">
  109. <div>协同校</div>
  110. <div>
  111. <el-button size="small" type="primary" @click="openAddSchool(2)">
  112. 添加学校</el-button
  113. >
  114. </div>
  115. </div>
  116. <div style="margin: 0 auto 10px">
  117. <div class="student_table">
  118. <el-table
  119. ref="table"
  120. :data="tableData1"
  121. stripe
  122. border
  123. :header-cell-style="{
  124. background: '#f1f1f1',
  125. 'text-align': 'center',
  126. }"
  127. :cell-style="{ 'text-align': 'center' }"
  128. style="width: 100%"
  129. :height="tableHeight"
  130. v-loading="isLoading"
  131. >
  132. <el-table-column prop="name" label="学校名称" min-width="30">
  133. <template slot-scope="scope">
  134. <div :class="scope.row.oid ? 'isLj' : ''">
  135. {{
  136. scope.row.oid
  137. ? scope.row.name + "(已联结)"
  138. : scope.row.name
  139. }}
  140. </div>
  141. </template>
  142. </el-table-column>
  143. <el-table-column prop="date" label="操作" min-width="30">
  144. <template slot-scope="scope">
  145. <div class="pb_buttonBox">
  146. <el-button
  147. size="mini"
  148. type="primary"
  149. @click="
  150. updateS(
  151. scope.row.id,
  152. scope.row.name,
  153. scope.row.dest,
  154. 2
  155. )
  156. "
  157. >修改</el-button
  158. >
  159. <el-button
  160. size="mini"
  161. type="primary"
  162. @click="deleteSchool(scope.row.id, 2)"
  163. >删除
  164. </el-button>
  165. </div>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. </div>
  170. </div>
  171. <div class="student_page">
  172. <el-pagination
  173. background
  174. layout="prev, pager, next"
  175. :page-size="10"
  176. :total="total1"
  177. v-if="page1"
  178. @current-change="handleCurrentChange1"
  179. ></el-pagination>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. <el-dialog
  185. title="添加学校"
  186. :visible.sync="dialogVisible"
  187. width="500px"
  188. :before-close="handleClose"
  189. class="dialog_diy"
  190. center
  191. >
  192. <div class="addBox">
  193. <span class="tian1">学校名称</span>
  194. <el-input
  195. v-model="schoolName"
  196. style="width: 250px; margin: 15px 0px"
  197. placeholder="请输入学校名称"
  198. ></el-input>
  199. </div>
  200. <div class="addBox">
  201. <span class="tian1">所属地区</span>
  202. <el-cascader
  203. size="large"
  204. style="width: 250px"
  205. clearable
  206. :options="region"
  207. v-model="selectedOptions"
  208. @change="handleChange"
  209. placeholder="请选择市区"
  210. >
  211. </el-cascader>
  212. </div>
  213. <span slot="footer" class="dialog-footer">
  214. <el-button @click="dialogVisible = false">取 消</el-button>
  215. <el-button type="primary" @click="addSchool">确 定</el-button>
  216. </span>
  217. </el-dialog>
  218. <el-dialog
  219. title="修改学校"
  220. :visible.sync="dialogVisible1"
  221. width="500px"
  222. :before-close="handleClose"
  223. class="dialog_diy"
  224. center
  225. >
  226. <div class="addBox">
  227. <span class="tian1">学校名称</span>
  228. <el-input
  229. v-model="schoolName"
  230. style="width: 250px; margin: 15px 0px"
  231. placeholder="请输入学校名称"
  232. ></el-input>
  233. </div>
  234. <div class="addBox">
  235. <span class="tian1">所属地区</span>
  236. <el-cascader
  237. size="large"
  238. style="width: 250px"
  239. clearable
  240. :options="region"
  241. v-model="selectedOptions"
  242. @change="handleChange"
  243. placeholder="请选择市区"
  244. >
  245. </el-cascader>
  246. </div>
  247. <span slot="footer" class="dialog-footer">
  248. <el-button @click="dialogVisible1 = false">取 消</el-button>
  249. <el-button type="primary" @click="updateSchool">确 定</el-button>
  250. </span>
  251. </el-dialog>
  252. <el-dialog
  253. title="添加联结"
  254. :visible.sync="dialogVisible2"
  255. width="500px"
  256. :before-close="handleClose1"
  257. class="dialog_diy"
  258. center
  259. >
  260. <div class="addBox">
  261. <span class="tian1">协同校</span>
  262. <el-select v-model="isCSchool" placeholder="请选择联结学校">
  263. <el-option label="取消联结" value="''"> </el-option>
  264. <el-option
  265. v-for="item in cShool"
  266. :key="item.id"
  267. :label="item.name"
  268. :value="item.id"
  269. >
  270. </el-option>
  271. </el-select>
  272. </div>
  273. <span slot="footer" class="dialog-footer">
  274. <el-button @click="dialogVisible2 = false">取 消</el-button>
  275. <el-button type="primary" @click="addNoSchool">确 定</el-button>
  276. </span>
  277. </el-dialog>
  278. </div>
  279. </template>
  280. <script>
  281. import { regionData, CodeToText } from "element-china-area-data";
  282. const Data = regionData;
  283. export default {
  284. data() {
  285. return {
  286. region: Data,
  287. selectedOptions: [], //"440000","440100"
  288. place: [],
  289. tableHeight: "500px",
  290. isLoading: false,
  291. formLabelWidth: "100px",
  292. tableData: [],
  293. tableData1: [],
  294. schoolName: "",
  295. page: 1,
  296. total: 0,
  297. page1: 1,
  298. total1: 0,
  299. userid: this.$route.query.userid,
  300. oid: this.$route.query.oid,
  301. org: this.$route.query.org,
  302. dialogVisible: false,
  303. dialogVisible1: false,
  304. dialogVisible2: false,
  305. sType: 0,
  306. isCSchool: "",
  307. cShool: [],
  308. };
  309. },
  310. mounted() {
  311. this.$nextTick(function () {
  312. // this.tableHeight =
  313. // window.innerHeight - this.$refs.table.$el.offsetTop;
  314. // if (this.tableHeight <= 530) {
  315. // this.tableHeight = 530;
  316. // }
  317. // // 监听窗口大小变化
  318. // let self = this;
  319. // window.onresize = function () {
  320. // self.tableHeight =
  321. // window.innerHeight - self.$refs.table.$el.offsetTop;
  322. // if (self.tableHeight <= 530) {
  323. // self.tableHeight = 530;
  324. // }
  325. // };
  326. });
  327. },
  328. methods: {
  329. handleChange() {
  330. if (!this.selectedOptions) {
  331. return;
  332. }
  333. var loc = "";
  334. this.place = [];
  335. for (let i = 0; i < this.selectedOptions.length; i++) {
  336. loc += CodeToText[this.selectedOptions[i]];
  337. this.place.push(this.selectedOptions[i]);
  338. }
  339. console.log(this.region);
  340. },
  341. time() {
  342. if (!this.now) {
  343. this.now = new Date().getTime();
  344. return true;
  345. } else {
  346. let time = new Date().getTime();
  347. if (time - this.now > 3000) {
  348. this.now = time;
  349. return true;
  350. } else {
  351. return false;
  352. }
  353. }
  354. },
  355. tableRowClassName({ row, rowIndex }) {
  356. if ((rowIndex + 1) % 2 === 0) {
  357. return "even_row";
  358. } else {
  359. return "";
  360. }
  361. },
  362. handleClose(done) {
  363. this.schoolName = "";
  364. this.place = [];
  365. done();
  366. },
  367. handleClose1(done) {
  368. done();
  369. },
  370. handleCurrentChange(val) {
  371. this.page = val;
  372. this.selectSchool();
  373. },
  374. handleCurrentChange1(val) {
  375. this.page1 = val;
  376. this.selectSchool1();
  377. },
  378. selectSchool() {
  379. this.isLoading = true;
  380. let params = {
  381. t: 1,
  382. org: this.org,
  383. page: this.page,
  384. };
  385. this.ajax
  386. .get(this.$store.state.api + "selectOrgType", params)
  387. .then((res) => {
  388. this.isLoading = false;
  389. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  390. this.tableData = res.data[0];
  391. })
  392. .catch((err) => {
  393. this.isLoading = false;
  394. console.error(err);
  395. });
  396. },
  397. selectSchool1() {
  398. this.isLoading = true;
  399. let params = {
  400. t: 2,
  401. org: this.org,
  402. page: this.page1,
  403. };
  404. this.ajax
  405. .get(this.$store.state.api + "selectOrgType", params)
  406. .then((res) => {
  407. this.isLoading = false;
  408. this.total1 = res.data[0].length > 0 ? res.data[0][0].num : 0;
  409. this.tableData1 = res.data[0];
  410. })
  411. .catch((err) => {
  412. this.isLoading = false;
  413. console.error(err);
  414. });
  415. },
  416. addSchool() {
  417. let params = [
  418. {
  419. n: this.schoolName,
  420. org: this.org,
  421. d: this.place.join("/"),
  422. t: this.sType,
  423. uid: this.userid,
  424. },
  425. ];
  426. this.ajax
  427. .post(this.$store.state.api + "insertSchoolByOrg", params)
  428. .then((res) => {
  429. this.$message({
  430. message: "添加成功",
  431. type: "success",
  432. });
  433. this.dialogVisible = false;
  434. this.schoolName = "";
  435. this.place = [];
  436. this.selectSchool();
  437. this.selectSchool1();
  438. this.sType = 0;
  439. })
  440. .catch((err) => {
  441. this.$message.error("添加失败");
  442. console.error(err);
  443. });
  444. },
  445. updateS(id, name, d, t) {
  446. this.dialogVisible1 = true;
  447. this.schoolName = name;
  448. this.place = [];
  449. if (d != null) {
  450. this.selectedOptions = d.split("/");
  451. } else {
  452. this.selectedOptions = [];
  453. }
  454. this.updateId = id;
  455. this.sType = t;
  456. },
  457. updateSchool() {
  458. let params = {
  459. n: this.schoolName,
  460. d: this.place.join("/"),
  461. id: this.updateId,
  462. };
  463. this.ajax
  464. .get(this.$store.state.api + "updateSchoolByOrg", params)
  465. .then((res) => {
  466. this.$message({
  467. message: "修改成功",
  468. type: "success",
  469. });
  470. this.dialogVisible1 = false;
  471. this.updateId = "";
  472. this.schoolName = "";
  473. this.place = [];
  474. this.selectSchool();
  475. this.selectSchool1();
  476. this.sType = 0;
  477. })
  478. .catch((err) => {
  479. this.$message.error("修改失败");
  480. console.error(err);
  481. });
  482. },
  483. deleteSchool(id, t) {
  484. this.sType = t;
  485. let params = [
  486. {
  487. id: id,
  488. },
  489. ];
  490. let _this = this;
  491. _this
  492. .$confirm("确定删除此学校吗?", "提示", {
  493. confirmButtonText: "确定",
  494. cancelButtonText: "取消",
  495. type: "warning",
  496. })
  497. .then(() => {
  498. _this.ajax
  499. .post(this.$store.state.api + "deleteSchoolAdmin", params)
  500. .then((res) => {
  501. _this.$message({
  502. message: "删除成功",
  503. type: "success",
  504. });
  505. _this.updateId = "";
  506. _this.schoolName = "";
  507. _this.selectSchool();
  508. _this.selectSchool1();
  509. _this.sType = 0;
  510. })
  511. .catch((err) => {
  512. _this.$message.error("删除成功");
  513. console.error(err);
  514. });
  515. })
  516. .catch(() => {
  517. return;
  518. });
  519. },
  520. selectNoSChool() {
  521. this.ajax
  522. .get(this.$store.state.api + "selectNoCSchool")
  523. .then((res) => {
  524. this.cShool = res.data[0];
  525. })
  526. .catch((err) => {
  527. this.$message.error("查询失败");
  528. console.error(err);
  529. });
  530. },
  531. openAddSchool(t) {
  532. this.dialogVisible = true;
  533. this.place = [];
  534. this.selectedOptions = [];
  535. this.sType = t;
  536. },
  537. openNoCSchool(id, oname) {
  538. this.dialogVisible2 = true;
  539. this.updateId = id;
  540. if (oname != null || oname != "") {
  541. this.isCSchool = oname;
  542. }
  543. this.selectNoSChool();
  544. },
  545. addNoSchool() {
  546. let params = {
  547. id: this.updateId,
  548. coid: this.isCSchool,
  549. };
  550. this.ajax
  551. .get(this.$store.state.api + "addNoSchool", params)
  552. .then((res) => {
  553. this.$message({
  554. message: "联结成功",
  555. type: "success",
  556. });
  557. this.dialogVisible2 = false;
  558. this.updateId = "";
  559. this.isCSchool = "";
  560. this.selectSchool();
  561. this.selectSchool1();
  562. })
  563. .catch((err) => {
  564. this.$message.error("联结失败");
  565. console.error(err);
  566. });
  567. },
  568. },
  569. created() {
  570. this.page = 1;
  571. this.selectSchool();
  572. this.selectSchool1();
  573. },
  574. };
  575. </script>
  576. <style scoped>
  577. .pb_head > span:nth-child(2) {
  578. font-size: 16px;
  579. margin-left: 80px;
  580. color: #ab582f;
  581. }
  582. .addBox {
  583. display: flex;
  584. align-items: center;
  585. justify-content: center;
  586. }
  587. .tian1 {
  588. /* font-size: 16px; */
  589. margin-right: 10px;
  590. }
  591. .pb_head {
  592. margin: 0 !important;
  593. width: 100% !important;
  594. }
  595. .student_page {
  596. margin: 10px 0 0 0;
  597. }
  598. .disUoloadSty >>> .el-upload--picture-card {
  599. display: none;
  600. /* 上传按钮隐藏 */
  601. }
  602. .dialogBox {
  603. display: flex;
  604. align-items: center;
  605. justify-content: center;
  606. }
  607. .dialogBox span {
  608. margin: 0 20px;
  609. }
  610. .student_head {
  611. width: 100%;
  612. /* margin-left: 25px; */
  613. padding: 5px 0;
  614. display: flex;
  615. justify-content: space-between;
  616. flex-direction: row;
  617. flex-wrap: nowrap;
  618. align-items: center;
  619. background: #fff;
  620. }
  621. .student_head > div:nth-child(1) {
  622. padding: 0 0 0 30px;
  623. font-size: 18px;
  624. }
  625. .student_head > div:nth-child(2) {
  626. margin-right: 10px;
  627. }
  628. .student_search,
  629. .student_search1 {
  630. display: flex;
  631. width: 100%;
  632. position: relative;
  633. flex-direction: row;
  634. flex-wrap: nowrap;
  635. align-items: center;
  636. justify-content: flex-end;
  637. }
  638. .student_search1 {
  639. justify-content: space-between;
  640. }
  641. .student_table >>> .el-table--border td {
  642. border-right: 0px !important;
  643. }
  644. .student_table >>> .el-table,
  645. .student_table >>> .el-table__body-wrapper {
  646. height: auto !important;
  647. }
  648. .el-table >>> .even_row {
  649. background-color: #f1f1f1 !important;
  650. }
  651. .dialog_diy >>> .el-dialog__header {
  652. padding: 9px 20px 10px;
  653. background: #32455b !important;
  654. }
  655. .dialog_diy >>> .el-dialog__title {
  656. color: #fff;
  657. font-size: 15px;
  658. }
  659. .dialog_diy >>> .el-dialog__headerbtn {
  660. top: 14px;
  661. }
  662. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
  663. color: #fff;
  664. }
  665. .dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
  666. color: #fff;
  667. }
  668. .dialog_diy >>> .el-dialog__body,
  669. .dialog_diy >>> .el-dialog__footer {
  670. background: #fafafa;
  671. }
  672. .r_diy >>> .el-dialog__footer {
  673. padding: 0;
  674. }
  675. .a_addBox {
  676. height: 570px;
  677. overflow: auto;
  678. }
  679. .workdates {
  680. height: 100%;
  681. position: absolute;
  682. top: 0;
  683. background: #fff;
  684. overflow: auto;
  685. z-index: 1;
  686. width: 95%;
  687. left: 50%;
  688. transform: translateX(-50%);
  689. padding: 20px;
  690. box-sizing: border-box;
  691. }
  692. .cancelbox {
  693. position: absolute;
  694. z-index: 2;
  695. left: 50%;
  696. width: 95%;
  697. transform: translateX(-50%);
  698. display: flex;
  699. justify-content: flex-end;
  700. padding: 0 90px 0px 0px;
  701. box-sizing: border-box;
  702. }
  703. .cardList {
  704. font-size: 14px;
  705. height: 360px;
  706. overflow: auto;
  707. }
  708. .cardList div {
  709. margin-bottom: 18px;
  710. }
  711. .cardList div:last-child {
  712. margin-bottom: 0;
  713. }
  714. .cardHead {
  715. display: flex;
  716. }
  717. .allBox {
  718. display: flex;
  719. flex-direction: row;
  720. flex-wrap: nowrap;
  721. align-items: flex-start;
  722. width: 94%;
  723. margin: 0 auto;
  724. justify-content: space-between;
  725. }
  726. .halfBox {
  727. /* width: 50%; */
  728. margin-top: 10px;
  729. }
  730. .isLj {
  731. color: #4679ab;
  732. font-weight: bold;
  733. }
  734. </style>