exam_site.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. @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">
  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="40" />
  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, 200, 300]"
  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.$httpWithMsg.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.$httpWithMsg.put(url, this.examSiteForm).then(() => {
  317. this.$notify({
  318. type: "success",
  319. message: "修改成功!"
  320. });
  321. this.searchForm();
  322. this.resetForm();
  323. this.examSiteDialog = false;
  324. });
  325. } else {
  326. this.$httpWithMsg.post(url, this.examSiteForm).then(() => {
  327. this.$notify({
  328. type: "success",
  329. message: "新增成功!"
  330. });
  331. this.searchForm();
  332. this.resetForm();
  333. this.examSiteDialog = false;
  334. });
  335. }
  336. } else {
  337. console.log("error submit!");
  338. return false;
  339. }
  340. });
  341. },
  342. dialogBeforeClose() {
  343. this.$refs.examSiteForm.clearValidate();
  344. },
  345. //新增
  346. insert() {
  347. this.examSiteForm.id = null;
  348. this.examSiteForm.code = null;
  349. this.examSiteForm.name = null;
  350. this.examSiteForm.orgId = this.orgId;
  351. this.examSiteForm.telephone = null;
  352. this.examSiteForm.contacts = null;
  353. this.examSiteForm.remark = null;
  354. this.examSiteDialog = true;
  355. },
  356. //修改
  357. edit(row) {
  358. this.examSiteForm.id = row.id;
  359. this.examSiteForm.code = row.code;
  360. this.examSiteForm.name = row.name;
  361. this.examSiteForm.orgId = row.orgId;
  362. this.examSiteForm.telephone = row.telephone;
  363. this.examSiteForm.contacts = row.contacts;
  364. this.examSiteForm.remark = row.remark;
  365. this.examSiteDialog = true;
  366. },
  367. //删除单个数据
  368. deleteById(row) {
  369. this.$confirm("是否删除该考点?", "提示", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning"
  373. }).then(() => {
  374. var url = CORE_API + "/examSite/" + row.id;
  375. this.$httpWithMsg.delete(url).then(() => {
  376. this.$notify({
  377. type: "success",
  378. message: "删除成功!"
  379. });
  380. this.searchForm();
  381. });
  382. });
  383. },
  384. //删除多条数据
  385. deleteByIds() {
  386. if (this.selectedExamSiteIds.length === 0) {
  387. this.$notify({
  388. type: "warning",
  389. message: "请选择要删除的考点"
  390. });
  391. } else {
  392. this.$confirm("是否删除这些考点?", "提示", {
  393. confirmButtonText: "确定",
  394. cancelButtonText: "取消",
  395. type: "error"
  396. }).then(() => {
  397. var url = CORE_API + "/examSite/" + this.examSiteIds;
  398. this.$httpWithMsg.delete(url).then(() => {
  399. this.$notify({
  400. type: "success",
  401. message: "删除成功!"
  402. });
  403. this.searchForm();
  404. });
  405. });
  406. }
  407. },
  408. init() {
  409. var url = CORE_API + "/org/subOrg/" + this.orgId;
  410. this.$httpWithMsg.get(url).then(response => {
  411. this.orgName = response.data.name;
  412. this.searchForm();
  413. });
  414. }
  415. },
  416. created() {
  417. this.orgId = this.$route.params.orgId;
  418. this.formSearch.orgId = this.$route.params.orgId;
  419. this.init();
  420. },
  421. components: {
  422. LinkTitlesCustom
  423. }
  424. };
  425. </script>
  426. <style scoped>
  427. .page {
  428. margin-top: 10px;
  429. }
  430. .el-upload {
  431. width: 80px;
  432. }
  433. .pull_length {
  434. width: 200px;
  435. }
  436. </style>