exam_site.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <div>
  3. <LinkTitlesCustom :currentPaths="['机构管理 ', '中心列表', '考点设置']" />
  4. <section class="content">
  5. <div class="box box-info">
  6. <div class="box-body">
  7. <!-- 表单 -->
  8. <ecs-form-search :model="formSearch">
  9. <el-row>
  10. <el-form-item label="学习中心">
  11. <el-input v-model="orgName" disabled />
  12. </el-form-item>
  13. <el-form-item label="考点代码">
  14. <el-input
  15. placeholder="请输入考点代码"
  16. v-model="formSearch.code"
  17. />
  18. </el-form-item>
  19. <el-form-item label="考点名称">
  20. <el-input
  21. placeholder="请输入考点名称"
  22. v-model="formSearch.name"
  23. />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button
  27. size="small"
  28. type="primary"
  29. icon="el-icon-search"
  30. @click="searchForm"
  31. >
  32. 查询
  33. </el-button>
  34. <el-button
  35. size="small"
  36. icon="el-icon-refresh"
  37. @click="resetSearchForm"
  38. >
  39. 重置
  40. </el-button>
  41. <el-button
  42. size="small"
  43. type="primary"
  44. icon="el-icon-plus"
  45. @click="insert"
  46. >
  47. 新增
  48. </el-button>
  49. <el-button
  50. size="small"
  51. type="primary"
  52. icon="el-icon-arrow-left"
  53. @click="back"
  54. >
  55. 退回
  56. </el-button>
  57. </el-form-item>
  58. </el-row>
  59. </ecs-form-search>
  60. <!-- 添加考点信息弹出框 -->
  61. <el-dialog
  62. title="考点信息"
  63. width="450px"
  64. :visible.sync="examSiteDialog"
  65. @before-close="dialogBeforeClose"
  66. >
  67. <el-form
  68. :inline="true"
  69. inline-message
  70. :model="examSiteForm"
  71. ref="examSiteForm"
  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="orgName"
  81. auto-complete="off"
  82. placeholder="中心代码"
  83. disabled
  84. />
  85. </el-form-item>
  86. </el-row>
  87. <el-row>
  88. <el-form-item label="考点代码" label-width="120px" prop="code">
  89. <el-input
  90. class="pull_length"
  91. v-model="examSiteForm.code"
  92. auto-complete="off"
  93. placeholder="考点代码"
  94. :disabled="null != examSiteForm.id"
  95. />
  96. </el-form-item>
  97. </el-row>
  98. <el-row>
  99. <el-form-item label="考点名称" label-width="120px" prop="name">
  100. <el-input
  101. class="pull_length"
  102. v-model="examSiteForm.name"
  103. auto-complete="off"
  104. placeholder="考点名称"
  105. />
  106. </el-form-item>
  107. </el-row>
  108. <el-row>
  109. <el-form-item label="负责人" label-width="120px">
  110. <el-input
  111. class="pull_length"
  112. v-model="examSiteForm.contacts"
  113. auto-complete="off"
  114. placeholder="负责人"
  115. />
  116. </el-form-item>
  117. </el-row>
  118. <el-row>
  119. <el-form-item label="联系方式" label-width="120px">
  120. <el-input
  121. class="pull_length"
  122. v-model="examSiteForm.telephone"
  123. auto-complete="off"
  124. placeholder="联系方式"
  125. />
  126. </el-form-item>
  127. </el-row>
  128. <el-row>
  129. <el-form-item label="备注" label-width="120px">
  130. <el-input
  131. class="pull_length"
  132. v-model="examSiteForm.remark"
  133. auto-complete="off"
  134. placeholder="备注"
  135. />
  136. </el-form-item>
  137. </el-row>
  138. <el-row class="d-flex justify-content-center">
  139. <el-button type="primary" @click="submitForm">保 存</el-button>
  140. <el-button @click="examSiteDialog = false">取 消</el-button>
  141. </el-row>
  142. </el-form>
  143. </el-dialog>
  144. <span>操作:</span>
  145. <el-button
  146. size="small"
  147. type="danger"
  148. icon="el-icon-delete"
  149. @click="deleteByIds"
  150. >
  151. 删除
  152. </el-button>
  153. <div style="width: 100%;margin-bottom: 10px;"></div>
  154. <!-- 页面列表 -->
  155. <el-table
  156. :data="tableData"
  157. border
  158. resizable
  159. stripe
  160. @selection-change="selectChange"
  161. >
  162. <el-table-column type="selection" width="35" />
  163. <el-table-column prop="id" width="70" label="ID" />
  164. <el-table-column prop="code" label="考点代码" />
  165. <el-table-column prop="name" label="考点名称" />
  166. <el-table-column prop="contacts" width="100" label="负责人" />
  167. <el-table-column prop="telephone" width="100" label="联系方式" />
  168. <el-table-column prop="remark" width="120" label="备注" />
  169. <el-table-column prop="updateTime" width="180" label="更新时间" />
  170. <el-table-column label="操作" width="200">
  171. <div slot-scope="scope">
  172. <el-button
  173. size="mini"
  174. type="primary"
  175. icon="el-icon-edit"
  176. plain
  177. @click="edit(scope.row)"
  178. >
  179. 编辑
  180. </el-button>
  181. <el-button
  182. size="mini"
  183. type="danger"
  184. @click="deleteById(scope.row)"
  185. icon="el-icon-delete"
  186. >
  187. 删除
  188. </el-button>
  189. </div>
  190. </el-table-column>
  191. </el-table>
  192. <div class="page pull-right">
  193. <el-pagination
  194. @current-change="handleCurrentChange"
  195. :current-page="currentPage"
  196. :page-size="pageSize"
  197. :page-sizes="[10, 20, 50, 100]"
  198. @size-change="handleSizeChange"
  199. layout="total, sizes, prev, pager, next, jumper"
  200. :total="total"
  201. />
  202. </div>
  203. </div>
  204. </div>
  205. </section>
  206. </div>
  207. </template>
  208. <script>
  209. import { CORE_API } from "@/constants/constants.js";
  210. import { mapState } from "vuex";
  211. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  212. export default {
  213. name: "ExamSite",
  214. data() {
  215. return {
  216. orgId: null,
  217. formSearch: {
  218. code: "",
  219. name: "",
  220. orgId: ""
  221. },
  222. examSiteForm: {
  223. id: null,
  224. name: "",
  225. code: "",
  226. contacts: "",
  227. telephone: "",
  228. orgId: "",
  229. remark: ""
  230. },
  231. examSiteDialog: false,
  232. selectedExamSiteIds: [],
  233. loading: true,
  234. tableData: [],
  235. currentPage: 1,
  236. pageSize: 10,
  237. total: 10,
  238. orgName: "",
  239. rules: {
  240. code: [{ required: true, message: "请输入代码", trigger: "blur" }],
  241. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  242. contacts: [
  243. { required: false, message: "请输入负责人", trigger: "blur" }
  244. ],
  245. telphone: [
  246. { required: false, message: "请输入联系方式", trigger: "blur" }
  247. ]
  248. }
  249. };
  250. },
  251. computed: {
  252. ...mapState({ user: state => state.user }),
  253. examSiteIds() {
  254. var examSiteIds = "";
  255. for (let examSiteId of this.selectedExamSiteIds) {
  256. if (!examSiteIds) {
  257. examSiteIds += examSiteId;
  258. } else {
  259. examSiteIds += "," + examSiteId;
  260. }
  261. }
  262. return examSiteIds;
  263. }
  264. },
  265. methods: {
  266. back() {
  267. this.$router.back();
  268. },
  269. resetSearchForm() {
  270. this.formSearch.code = "";
  271. this.formSearch.name = "";
  272. },
  273. handleCurrentChange(val) {
  274. this.currentPage = val;
  275. this.searchForm();
  276. },
  277. handleSizeChange(val) {
  278. this.pageSize = val;
  279. this.searchForm();
  280. },
  281. //查询
  282. searchForm() {
  283. this.loading = true;
  284. var param = new URLSearchParams(this.formSearch);
  285. var url =
  286. CORE_API +
  287. "/examSite/examSitePage/" +
  288. (this.currentPage - 1) +
  289. "/" +
  290. this.pageSize +
  291. "?" +
  292. param;
  293. this.$http.get(url).then(response => {
  294. this.tableData = response.data.content;
  295. this.total = response.data.totalElements;
  296. this.loading = false;
  297. });
  298. },
  299. selectChange(row) {
  300. this.selectedExamSiteIds = [];
  301. row.forEach(element => {
  302. this.selectedExamSiteIds.push(element.id);
  303. });
  304. console.log(this.selectedExamSiteIds);
  305. },
  306. //重置
  307. resetForm() {
  308. this.$refs.examSiteForm.resetFields();
  309. },
  310. //提交
  311. submitForm() {
  312. this.$refs.examSiteForm.validate(valid => {
  313. if (valid) {
  314. var url = CORE_API + "/examSite";
  315. if (this.examSiteForm.id) {
  316. this.$http.put(url, this.examSiteForm).then(
  317. () => {
  318. this.$notify({
  319. type: "success",
  320. message: "修改成功!"
  321. });
  322. this.searchForm();
  323. this.resetForm();
  324. this.examSiteDialog = false;
  325. },
  326. response => {
  327. if (response.status == 500) {
  328. this.$notify({
  329. showClose: true,
  330. message: response.data.desc,
  331. type: "error"
  332. });
  333. }
  334. }
  335. );
  336. } else {
  337. this.$http.post(url, this.examSiteForm).then(
  338. () => {
  339. this.$notify({
  340. type: "success",
  341. message: "新增成功!"
  342. });
  343. this.searchForm();
  344. this.resetForm();
  345. this.examSiteDialog = false;
  346. },
  347. response => {
  348. if (response.status == 500) {
  349. this.$notify({
  350. showClose: true,
  351. message: response.data.desc,
  352. type: "error"
  353. });
  354. }
  355. }
  356. );
  357. }
  358. } else {
  359. console.log("error submit!");
  360. return false;
  361. }
  362. });
  363. },
  364. dialogBeforeClose() {
  365. this.$refs.examSiteForm.clearValidate();
  366. },
  367. //新增
  368. insert() {
  369. this.examSiteForm.id = null;
  370. this.examSiteForm.code = null;
  371. this.examSiteForm.name = null;
  372. this.examSiteForm.orgId = this.orgId;
  373. this.examSiteForm.telephone = null;
  374. this.examSiteForm.contacts = null;
  375. this.examSiteForm.remark = null;
  376. this.examSiteDialog = true;
  377. },
  378. //修改
  379. edit(row) {
  380. this.examSiteForm.id = row.id;
  381. this.examSiteForm.code = row.code;
  382. this.examSiteForm.name = row.name;
  383. this.examSiteForm.orgId = row.orgId;
  384. this.examSiteForm.telephone = row.telephone;
  385. this.examSiteForm.contacts = row.contacts;
  386. this.examSiteForm.remark = row.remark;
  387. this.examSiteDialog = true;
  388. },
  389. //删除单个数据
  390. deleteById(row) {
  391. this.$confirm("是否删除该考点?", "提示", {
  392. confirmButtonText: "确定",
  393. cancelButtonText: "取消",
  394. type: "warning"
  395. }).then(() => {
  396. var url = CORE_API + "/examSite/" + row.id;
  397. this.$http
  398. .delete(url)
  399. .then(() => {
  400. this.$notify({
  401. type: "success",
  402. message: "删除成功!"
  403. });
  404. this.searchForm();
  405. })
  406. .catch(response => {
  407. if (response.status == 500) {
  408. this.$notify({
  409. showClose: true,
  410. message: response.data.desc,
  411. type: "error"
  412. });
  413. }
  414. });
  415. });
  416. },
  417. //删除多条数据
  418. deleteByIds() {
  419. if (this.selectedExamSiteIds.length === 0) {
  420. this.$notify({
  421. type: "warning",
  422. message: "请选择要删除的考点"
  423. });
  424. } else {
  425. this.$confirm("是否删除这些考点?", "提示", {
  426. confirmButtonText: "确定",
  427. cancelButtonText: "取消",
  428. type: "error"
  429. }).then(() => {
  430. var url = CORE_API + "/examSite/" + this.examSiteIds;
  431. this.$http
  432. .delete(url)
  433. .then(() => {
  434. this.$notify({
  435. type: "success",
  436. message: "删除成功!"
  437. });
  438. this.searchForm();
  439. })
  440. .catch(response => {
  441. if (response.status == 500) {
  442. this.$notify({
  443. showClose: true,
  444. message: response.data.desc,
  445. type: "error"
  446. });
  447. }
  448. });
  449. });
  450. }
  451. },
  452. init() {
  453. var url = CORE_API + "/org/subOrg/" + this.orgId;
  454. this.$http
  455. .get(url)
  456. .then(response => {
  457. this.orgName = response.data.name;
  458. this.searchForm();
  459. })
  460. .catch(response => {
  461. if (response.status == 500) {
  462. this.$notify({
  463. showClose: true,
  464. message: response.data.desc,
  465. type: "error"
  466. });
  467. }
  468. });
  469. }
  470. },
  471. created() {
  472. this.orgId = this.$route.params.orgId;
  473. this.formSearch.orgId = this.$route.params.orgId;
  474. this.init();
  475. },
  476. components: {
  477. LinkTitlesCustom
  478. }
  479. };
  480. </script>
  481. <style scoped>
  482. .page {
  483. margin-top: 10px;
  484. }
  485. .el-upload {
  486. width: 80px;
  487. }
  488. .pull_length {
  489. width: 200px;
  490. }
  491. </style>