school.vue 21 KB

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