school.vue 22 KB

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