exam_site.vue 14 KB

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