school.vue 22 KB

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