school.vue 20 KB

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