exam_site.vue 14 KB

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