school.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <section class="content">
  3. <div class="box-body">
  4. <!-- 表单 -->
  5. <el-form :inline="true" :model="formSearch">
  6. <el-form-item label="学校名称">
  7. <el-input placeholder="请输入学校名称" v-model="formSearch.name" />
  8. </el-form-item>
  9. <el-form-item label="学校代码">
  10. <el-input placeholder="请输入学校代码" v-model="formSearch.code" />
  11. </el-form-item>
  12. <el-form-item label="学校域名">
  13. <el-input
  14. placeholder="请输入学校域名"
  15. v-model="formSearch.domainName"
  16. />
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button
  20. size="small"
  21. type="primary"
  22. icon="el-icon-search"
  23. @click="handleSearchBtn"
  24. >
  25. 查询
  26. </el-button>
  27. <el-button
  28. size="small"
  29. icon="el-icon-refresh"
  30. @click="resetSearchForm"
  31. >
  32. 重置
  33. </el-button>
  34. <el-button
  35. size="small"
  36. type="primary"
  37. icon="el-icon-plus"
  38. @click="insert"
  39. >
  40. 新增
  41. </el-button>
  42. </el-form-item>
  43. </el-form>
  44. <div class="block-seperator"></div>
  45. <span>操作:</span>
  46. <el-button
  47. size="small"
  48. type="success"
  49. :disabled="noBatchSelected"
  50. @click="enableOrg"
  51. icon="el-icon-check"
  52. >
  53. 启用
  54. </el-button>
  55. <el-button
  56. size="small"
  57. type="danger"
  58. :disabled="noBatchSelected"
  59. @click="disableOrg"
  60. icon="el-icon-close"
  61. >
  62. 禁用
  63. </el-button>
  64. <div style="width: 100%;margin-bottom: 10px;"></div>
  65. <!-- 添加或修改学校弹出框 -->
  66. <el-dialog
  67. title="学校信息"
  68. width="500px"
  69. :visible.sync="schoolDialog"
  70. @close="dialogBeforeClose"
  71. >
  72. <el-form
  73. :inline="true"
  74. inline-message
  75. :model="schoolForm"
  76. ref="schoolForm"
  77. :rules="rules"
  78. label-position="right"
  79. label-width="90px"
  80. class="editSchoolForm"
  81. >
  82. <el-row>
  83. <el-form-item label="学校代码" label-width="120px" prop="code">
  84. <el-input
  85. class="pull_length"
  86. v-model="schoolForm.code"
  87. auto-complete="off"
  88. placeholder="学校域名"
  89. :disabled="null != schoolForm.id"
  90. />
  91. </el-form-item>
  92. </el-row>
  93. <el-row>
  94. <el-form-item label="学校名称" label-width="120px" prop="name">
  95. <el-input
  96. class="pull_length"
  97. v-model="schoolForm.name"
  98. auto-complete="off"
  99. placeholder="学校名称"
  100. />
  101. </el-form-item>
  102. </el-row>
  103. <el-row>
  104. <el-form-item
  105. label="学校域名"
  106. label-width="120px"
  107. prop="domainName"
  108. >
  109. <el-input
  110. class="pull_length"
  111. v-model="schoolForm.domainName"
  112. auto-complete="off"
  113. placeholder="学校域名"
  114. />
  115. </el-form-item>
  116. </el-row>
  117. <el-row>
  118. <el-form-item label="负责人" label-width="120px" prop="contacts">
  119. <el-input
  120. class="pull_length"
  121. v-model="schoolForm.contacts"
  122. auto-complete="off"
  123. placeholder="负责人"
  124. />
  125. </el-form-item>
  126. </el-row>
  127. <el-row>
  128. <el-form-item label="联系方式" label-width="120px" prop="telephone">
  129. <el-input
  130. class="pull_length"
  131. v-model="schoolForm.telephone"
  132. auto-complete="off"
  133. placeholder="联系方式"
  134. />
  135. </el-form-item>
  136. </el-row>
  137. <el-row>
  138. <el-form-item label="考生端产品名" label-width="120px">
  139. <el-input
  140. class="pull_length"
  141. v-model="schoolForm.properties.OE_STUDENT_SYS_NAME"
  142. auto-complete="off"
  143. placeholder="考生端产品名"
  144. />
  145. </el-form-item>
  146. </el-row>
  147. <el-row>
  148. <el-form-item label="状态" label-width="120px" prop="enable">
  149. <el-radio-group class="pull_right_sm" v-model="schoolForm.enable">
  150. <el-radio label="true">启用</el-radio>
  151. <el-radio label="false">禁用</el-radio>
  152. </el-radio-group>
  153. </el-form-item>
  154. </el-row>
  155. <el-row class="d-flex justify-content-center">
  156. <el-button type="primary" @click="submitForm">保 存</el-button>
  157. <el-button @click="schoolDialog = false">取 消</el-button>
  158. </el-row>
  159. </el-form>
  160. </el-dialog>
  161. <!-- 学校产品分配弹出框 -->
  162. <el-dialog title="产品分配" :visible.sync="functionDialog">
  163. <div>
  164. <el-button type="primary" @click="saveOrgFunction"> 保 存 </el-button>
  165. <el-button @click="functionDialog = false">取 消</el-button>
  166. </div>
  167. </el-dialog>
  168. <!-- logo上传弹窗 -->
  169. <el-dialog title="logo上传" width="350px" :visible.sync="logoDialog">
  170. <el-form inline>
  171. <el-row>
  172. <el-form-item label="学校名称">
  173. <el-input class="pull_length" v-model="curSchool.name" disabled />
  174. </el-form-item>
  175. <el-form-item label="学校代码">
  176. <el-input class="pull_length" v-model="curSchool.code" disabled />
  177. </el-form-item>
  178. <el-form-item>
  179. <el-upload
  180. class="form_left"
  181. ref="upload"
  182. accept="image/*"
  183. :action="uploadAction"
  184. :headers="uploadHeaders"
  185. :data="uploadData"
  186. :before-upload="beforeUpload"
  187. :on-progress="uploadProgress"
  188. :on-success="uploadSuccess"
  189. :on-error="uploadError"
  190. :file-list="fileList"
  191. :auto-upload="false"
  192. :multiple="false"
  193. >
  194. <el-button size="small" slot="trigger" type="primary">
  195. 选择文件
  196. </el-button>
  197. &nbsp;
  198. <el-button size="small" type="success" @click="submitUpload">
  199. 确认上传
  200. </el-button>
  201. <el-button size="small" type="danger" @click="removeFile">
  202. 清空文件
  203. </el-button>
  204. <div slot="tip" class="el-upload__tip">只能上传图片</div>
  205. </el-upload>
  206. </el-form-item>
  207. </el-row>
  208. </el-form>
  209. </el-dialog>
  210. <!-- 页面列表 -->
  211. <el-table
  212. :data="tableData"
  213. border
  214. resizable
  215. stripe
  216. @selection-change="selectChange"
  217. >
  218. <el-table-column type="selection" width="35" />
  219. <el-table-column prop="id" label="ID" width="60" />
  220. <el-table-column label="学校名称">
  221. <template slot-scope="scope">
  222. <el-popover trigger="hover" placement="left">
  223. <div style="font-size: 18px;font-family: 新宋体">
  224. <tr>
  225. <td style="color: green">学校名称</td>
  226. <td style="color:purple;padding-left: 20px;">
  227. {{ scope.row.name }}
  228. </td>
  229. </tr>
  230. <tr>
  231. <td style="color: green">学校代码</td>
  232. <td style="color:purple;padding-left: 20px;">
  233. {{ scope.row.code }}
  234. </td>
  235. </tr>
  236. <tr>
  237. <td style="color: green">负责人</td>
  238. <td style="color:purple;padding-left: 20px;">
  239. {{ scope.row.contacts }}
  240. </td>
  241. </tr>
  242. <tr>
  243. <td style="color: green">联系方式</td>
  244. <td style="color:purple;padding-left: 20px;">
  245. {{ scope.row.telephone }}
  246. </td>
  247. </tr>
  248. </div>
  249. <div slot="reference" class="name-wrapper">
  250. <span>{{ scope.row.name }}</span>
  251. </div>
  252. </el-popover>
  253. </template>
  254. </el-table-column>
  255. <el-table-column prop="domainName" width="190" label="学校域名" />
  256. <el-table-column
  257. sortable
  258. prop="updateTime"
  259. width="170"
  260. label="更新时间"
  261. />
  262. <el-table-column width="50" label="状态">
  263. <span slot-scope="scope">
  264. <span v-if="scope.row.enable">
  265. <el-tooltip
  266. class="item"
  267. effect="dark"
  268. content="启用"
  269. placement="left"
  270. >
  271. <i class="el-icon-success" style="color:green;"></i>
  272. </el-tooltip>
  273. </span>
  274. <span v-else>
  275. <el-tooltip
  276. class="item"
  277. effect="dark"
  278. content="禁用"
  279. placement="left"
  280. >
  281. <i class="el-icon-error" style="color:red;"></i>
  282. </el-tooltip>
  283. </span>
  284. </span>
  285. </el-table-column>
  286. <el-table-column :context="_self" width="210" prop="" label="操作">
  287. <div slot-scope="scope">
  288. <el-button
  289. size="mini"
  290. type="primary"
  291. plain
  292. @click="edit(scope.row)"
  293. >
  294. <i class="el-icon-edit"></i> 编辑
  295. </el-button>
  296. <el-button
  297. size="mini"
  298. type="primary"
  299. plain
  300. @click="setLogo(scope.row)"
  301. icon="el-icon-upload"
  302. >
  303. logo上传
  304. </el-button>
  305. </div>
  306. </el-table-column>
  307. </el-table>
  308. <div class="page pull-right">
  309. <el-pagination
  310. @current-change="handleCurrentChange"
  311. :current-page="currentPage"
  312. :page-size="pageSize"
  313. :page-sizes="[10, 20, 50, 100]"
  314. @size-change="handleSizeChange"
  315. layout="total, sizes, prev, pager, next, jumper"
  316. :total="total"
  317. />
  318. </div>
  319. </div>
  320. </section>
  321. </template>
  322. <script>
  323. import { CORE_API } from "@/constants/constants.js";
  324. import { mapState } from "vuex";
  325. export default {
  326. name: "School",
  327. data() {
  328. return {
  329. formSearch: {
  330. code: "",
  331. name: "",
  332. domainName: ""
  333. },
  334. schoolForm: {
  335. id: null,
  336. name: "",
  337. code: "",
  338. domainName: "",
  339. contacts: "",
  340. telephone: "",
  341. enable: "true",
  342. remark: "",
  343. properties: {
  344. OE_STUDENT_SYS_NAME: null
  345. }
  346. },
  347. functionDialog: false,
  348. functionDialogInited: false,
  349. schoolDialog: false,
  350. logoDialog: false,
  351. curSchool: {
  352. name: null,
  353. code: null
  354. },
  355. uploadAction: "",
  356. uploadHeaders: {},
  357. uploadData: {},
  358. fileList: [],
  359. selectedOrgIds: [],
  360. loading: true,
  361. tableData: [],
  362. currentPage: 1,
  363. pageSize: 10,
  364. total: 10,
  365. imp: "",
  366. rules: {
  367. code: [{ required: true, message: "请输入学校代码", trigger: "blur" }],
  368. domainName: [
  369. { required: true, message: "请输入学校域名", trigger: "blur" }
  370. ],
  371. name: [{ required: true, message: "请输入学校名称", trigger: "blur" }],
  372. contacts: [
  373. { required: true, message: "请输入负责人", trigger: "blur" }
  374. ],
  375. telephone: [
  376. { required: true, message: "请输入联系方式", trigger: "blur" }
  377. ],
  378. enable: [{ required: true, message: "请选择状态", trigger: "change" }]
  379. }
  380. };
  381. },
  382. computed: {
  383. ...mapState({ user: state => state.user }),
  384. noBatchSelected() {
  385. return this.selectedOrgIds.length === 0;
  386. },
  387. orgIds() {
  388. var orgIds = "";
  389. for (let orgId of this.selectedOrgIds) {
  390. if (!orgIds) {
  391. orgIds += orgId;
  392. } else {
  393. orgIds += "," + orgId;
  394. }
  395. }
  396. return orgIds;
  397. }
  398. },
  399. methods: {
  400. resetSearchForm() {
  401. this.formSearch.code = "";
  402. this.formSearch.name = "";
  403. this.formSearch.domainName = "";
  404. },
  405. dialogBeforeClose() {
  406. this.$refs.schoolForm.clearValidate();
  407. },
  408. handleSizeChange(val) {
  409. this.pageSize = val;
  410. this.currentPage = 1;
  411. this.searchForm();
  412. },
  413. getTag(status) {
  414. if (status == true) {
  415. return "success";
  416. } else if (status == false) {
  417. return "danger";
  418. }
  419. return status;
  420. },
  421. handleCurrentChange(val) {
  422. this.currentPage = val;
  423. this.searchForm();
  424. },
  425. handleSearchBtn() {
  426. this.currentPage = 1;
  427. this.searchForm();
  428. },
  429. //查询
  430. searchForm() {
  431. this.loading = true;
  432. var param = new URLSearchParams(this.formSearch);
  433. var url =
  434. CORE_API +
  435. "/org/rootOrgPage/" +
  436. (this.currentPage - 1) +
  437. "/" +
  438. this.pageSize +
  439. "?" +
  440. param;
  441. this.$httpWithMsg.get(url).then(response => {
  442. this.tableData = response.data.list;
  443. this.total = response.data.total;
  444. this.loading = false;
  445. });
  446. },
  447. //启用
  448. enableOrg() {
  449. if (this.selectedOrgIds.length === 0) {
  450. this.$notify({
  451. type: "warning",
  452. message: "请选择要启用的机构"
  453. });
  454. } else {
  455. this.$confirm("是否启用这些机构?", "提示", {
  456. confirmButtonText: "确定",
  457. cancelButtonText: "取消",
  458. type: "warning"
  459. }).then(() => {
  460. var url = CORE_API + "/org/enable/" + this.orgIds;
  461. this.$httpWithMsg.put(url).then(() => {
  462. this.$notify({
  463. type: "success",
  464. message: "启用成功!"
  465. });
  466. this.searchForm();
  467. });
  468. });
  469. }
  470. },
  471. disableOrg() {
  472. if (this.selectedOrgIds.length === 0) {
  473. this.$notify({
  474. type: "warning",
  475. message: "请选择要禁用的机构"
  476. });
  477. } else {
  478. this.$confirm("是否禁用这些机构?", "提示", {
  479. confirmButtonText: "确定",
  480. cancelButtonText: "取消",
  481. type: "warning"
  482. }).then(() => {
  483. var url = CORE_API + "/org/disable/" + this.orgIds;
  484. this.$$httpWithMsg.put(url, {}).then(() => {
  485. this.$notify({
  486. type: "success",
  487. message: "禁用成功!"
  488. });
  489. this.searchForm();
  490. });
  491. });
  492. }
  493. },
  494. selectChange(row) {
  495. this.selectedOrgIds = [];
  496. row.forEach(element => {
  497. this.selectedOrgIds.push(element.id);
  498. });
  499. console.log(this.selectedOrgIds);
  500. },
  501. //重置
  502. resetForm() {
  503. this.$refs.schoolForm.resetFields();
  504. },
  505. //提交
  506. submitForm() {
  507. this.$refs.schoolForm.validate(valid => {
  508. if (valid) {
  509. if (null != this.schoolForm.id) {
  510. //修改
  511. url = CORE_API + "/org/updateRootOrg";
  512. this.$httpWithMsg.put(url, this.schoolForm).then(() => {
  513. this.$notify({
  514. type: "success",
  515. message: "修改成功!"
  516. });
  517. this.searchForm();
  518. this.schoolDialog = false;
  519. });
  520. } else {
  521. //新增
  522. var url = CORE_API + "/org/addRootOrg";
  523. this.$httpWithMsg.post(url, this.schoolForm).then(() => {
  524. this.$notify({
  525. type: "success",
  526. message: "新增成功!"
  527. });
  528. this.searchForm();
  529. this.schoolDialog = false;
  530. });
  531. }
  532. } else {
  533. console.log("error submit!");
  534. return false;
  535. }
  536. });
  537. },
  538. //新增
  539. insert() {
  540. this.schoolForm.id = null;
  541. this.schoolForm.name = "";
  542. this.schoolForm.code = "";
  543. this.schoolForm.domainName = "";
  544. this.schoolForm.telephone = "";
  545. this.schoolForm.contacts = "";
  546. this.schoolForm.properties.OE_STUDENT_SYS_NAME = "";
  547. this.schoolForm.enable = "true";
  548. this.schoolDialog = true;
  549. },
  550. //修改
  551. edit(row) {
  552. this.schoolForm.id = row.id;
  553. this.schoolForm.name = row.name;
  554. this.schoolForm.code = row.code;
  555. this.schoolForm.domainName = row.domainName;
  556. this.schoolForm.telephone = row.telephone;
  557. this.schoolForm.contacts = row.contacts;
  558. this.schoolForm.properties.OE_STUDENT_SYS_NAME = "";
  559. this.schoolForm.enable = row.enable ? "true" : "false";
  560. var url = CORE_API + "/org/allProperties/" + row.id;
  561. this.$httpWithMsg.get(url).then(response => {
  562. this.schoolForm.properties = Object.assign(
  563. this.schoolForm.properties,
  564. response.data
  565. );
  566. this.schoolDialog = true;
  567. });
  568. },
  569. //设置产品
  570. saveOrgFunction() {},
  571. //设置logo
  572. setLogo(row) {
  573. this.uploadAction = CORE_API + "/org/importLogo/" + row.id;
  574. this.removeFile();
  575. this.curSchool.name = row.name;
  576. this.curSchool.code = row.code;
  577. this.logoDialog = true;
  578. },
  579. initUpload() {
  580. this.fileList = [];
  581. },
  582. beforeUpload(file) {
  583. console.log(file);
  584. },
  585. uploadProgress() {
  586. console.log("uploadProgress");
  587. },
  588. uploadSuccess(response) {
  589. console.log("uploadSuccess");
  590. console.log(response);
  591. if (!response || response.length == 0) {
  592. this.$notify({
  593. message: "上传成功",
  594. type: "success"
  595. });
  596. } else {
  597. this.errMessages = response;
  598. this.errDialog = true;
  599. }
  600. this.fileLoading = false;
  601. this.logoDialog = false;
  602. this.removeFile();
  603. this.searchForm();
  604. },
  605. uploadError() {
  606. this.$notify({
  607. message: "上传失败",
  608. type: "error"
  609. });
  610. this.fileLoading = false;
  611. },
  612. //确定上传
  613. submitUpload() {
  614. if (!this.checkUpload()) {
  615. return false;
  616. }
  617. this.$refs.upload.submit();
  618. this.fileLoading = true;
  619. },
  620. checkUpload() {
  621. var fileList = this.$refs.upload.uploadFiles;
  622. if (fileList.length == 0) {
  623. this.$notify({
  624. message: "上传文件不能为空",
  625. type: "error"
  626. });
  627. return false;
  628. }
  629. if (fileList.length > 1) {
  630. this.$notify({
  631. message: "每次只能上传一个文件",
  632. type: "error"
  633. });
  634. return false;
  635. }
  636. for (let file of fileList) {
  637. var fileName = file.name;
  638. if (
  639. !fileName.endsWith(".jpg") &&
  640. !fileName.endsWith(".gif") &&
  641. !fileName.endsWith(".png")
  642. ) {
  643. this.$notify({
  644. message: "上传文件必须为[jpg,gif,png]",
  645. type: "error"
  646. });
  647. this.initUpload();
  648. return false;
  649. }
  650. }
  651. return true;
  652. },
  653. //清空文件
  654. removeFile() {
  655. this.fileList = [];
  656. if (this.$refs.upload) {
  657. this.$refs.upload.clearFiles();
  658. }
  659. }
  660. },
  661. //初始化查询
  662. created() {
  663. this.searchForm();
  664. this.uploadHeaders = {
  665. key: this.user.key,
  666. token: this.user.token
  667. };
  668. }
  669. };
  670. </script>
  671. <style scoped>
  672. .page {
  673. margin-top: 10px;
  674. }
  675. .el-upload {
  676. width: 80px;
  677. }
  678. .editSchoolForm .pull_length {
  679. width: 200px;
  680. }
  681. </style>