exam_site.vue 14 KB

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