onlineExamOrgSettings.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <div>
  3. <LinkTitlesCustom
  4. :currentPaths="['考试管理', '考试信息', '学习中心设置']"
  5. />
  6. <section class="content">
  7. <div class="box-body">
  8. <el-form
  9. :model="formSearch"
  10. :inline="true"
  11. label-position="right"
  12. label-width="80px"
  13. >
  14. <el-form-item label="学习中心">
  15. <el-select
  16. class="select"
  17. :remote-method="getOrgList4Search"
  18. :loading="loadingOrg4Search"
  19. remote
  20. filterable
  21. clearable
  22. v-model="formSearch.orgId"
  23. placeholder="请选择"
  24. >
  25. <el-option
  26. v-for="item in orgList4Search"
  27. :label="item.name"
  28. :value="item.id"
  29. :key="item.id"
  30. >
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item class="d-block">
  35. <el-button
  36. size="small"
  37. type="primary"
  38. icon="el-icon-search"
  39. @click="resetPageAndSearch"
  40. >查询</el-button
  41. >
  42. <el-button
  43. size="small"
  44. type="primary"
  45. icon="el-icon-plus"
  46. @click="showAddOrgSetting"
  47. >新增</el-button
  48. >
  49. <el-button size="small" type="primary" @click="back"
  50. >返 回</el-button
  51. >
  52. </el-form-item>
  53. </el-form>
  54. <!-- 页面列表 -->
  55. <el-table
  56. :data="tableData"
  57. border
  58. style="width: 100%;text-align:center;"
  59. v-loading="loading4FormSearch"
  60. >
  61. <el-table-column prop="id" width="80" label="ID"></el-table-column>
  62. <el-table-column
  63. prop="orgCode"
  64. label="学习中心代码"
  65. ></el-table-column>
  66. <el-table-column
  67. prop="orgName"
  68. label="学习中心名称"
  69. ></el-table-column>
  70. <el-table-column prop="beginTime" width="155" label="开始时间">
  71. </el-table-column>
  72. <el-table-column prop="endTime" width="155" label="结束时间">
  73. </el-table-column>
  74. <el-table-column width="110" label="是否可以考试">
  75. <span slot-scope="scope">
  76. <span v-if="!scope.row.examLimit">
  77. <el-tooltip
  78. class="item"
  79. effect="dark"
  80. content="是"
  81. placement="left"
  82. >
  83. <i class="el-icon-success" style="color:green;"></i>
  84. </el-tooltip>
  85. </span>
  86. <span v-else>
  87. <el-tooltip
  88. class="item"
  89. effect="dark"
  90. content="否"
  91. placement="left"
  92. >
  93. <i class="el-icon-error" style="color:red;"></i>
  94. </el-tooltip>
  95. </span>
  96. </span>
  97. </el-table-column>
  98. <el-table-column prop="updateTime" width="155" label="更新时间">
  99. </el-table-column>
  100. <el-table-column label="操作" width="200">
  101. <template slot-scope="scope">
  102. <div>
  103. <el-button
  104. v-if="scope.row.examLimit"
  105. size="mini"
  106. type="primary"
  107. plain
  108. icon="el-icon-edit"
  109. @click="updateExamLimit(scope.row)"
  110. >
  111. 开考
  112. </el-button>
  113. <el-button
  114. v-else
  115. size="mini"
  116. type="primary"
  117. plain
  118. icon="el-icon-edit"
  119. @click="updateExamLimit(scope.row)"
  120. >
  121. 禁考
  122. </el-button>
  123. <el-button
  124. size="mini"
  125. type="primary"
  126. plain
  127. icon="el-icon-edit"
  128. @click="showUpdateOrgSetting(scope.row)"
  129. >
  130. 编辑
  131. </el-button>
  132. </div>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <div class="page pull-right">
  137. <el-pagination
  138. @current-change="handleCurrentChange"
  139. :current-page="currentPage"
  140. :page-size="pageSize"
  141. :page-sizes="[10, 20, 50, 100]"
  142. @size-change="handleSizeChange"
  143. layout="total, sizes, prev, pager, next, jumper"
  144. :total="total"
  145. >
  146. </el-pagination>
  147. </div>
  148. <!-- 新增 -->
  149. <el-dialog
  150. title="新增学习中心考试设置"
  151. size="tiny"
  152. :visible.sync="addOrgSettingDialog"
  153. >
  154. <el-form
  155. :model="orgSetting"
  156. :rules="orgSettingRules"
  157. ref="addOrgSettingForm"
  158. label-position="right"
  159. :inline="true"
  160. inline-message
  161. >
  162. <el-row>
  163. <el-form-item label="学习中心" prop="orgId" label-width="120px">
  164. <el-select
  165. class="select"
  166. :remote-method="getOrgList4InsertOrUpdate"
  167. :loading="loadingOrg4InsertOrUpdate"
  168. remote
  169. filterable
  170. clearable
  171. v-model="orgSetting.orgId"
  172. placeholder="请选择"
  173. >
  174. <el-option
  175. v-for="item in orgList4InsertOrUpdate"
  176. :label="item.name"
  177. :value="item.id"
  178. :key="item.id"
  179. >
  180. </el-option>
  181. </el-select>
  182. </el-form-item>
  183. </el-row>
  184. <el-row>
  185. <el-form-item
  186. label="考试时间"
  187. prop="orgSettingDatetimeRange"
  188. label-width="120px"
  189. >
  190. <el-date-picker
  191. v-model="orgSettingDatetimeRange"
  192. type="datetimerange"
  193. range-separator="至"
  194. start-placeholder="开始日期"
  195. end-placeholder="结束日期"
  196. value-format="yyyy-MM-dd HH:mm:ss"
  197. >
  198. </el-date-picker>
  199. </el-form-item>
  200. </el-row>
  201. <el-row>
  202. <el-form-item label="是否可以考试" label-width="120px">
  203. <el-radio-group v-model="orgSetting.examLimit" class="input">
  204. <el-radio label="true">否</el-radio>
  205. <el-radio label="false">是</el-radio>
  206. </el-radio-group>
  207. </el-form-item>
  208. </el-row>
  209. <el-row>
  210. <div style="text-align:center;">
  211. <el-button type="primary" @click="addOrgSetting"
  212. >确 定</el-button
  213. >
  214. <el-button @click="addOrgSettingDialog = false"
  215. >取 消</el-button
  216. >
  217. </div>
  218. </el-row>
  219. </el-form>
  220. </el-dialog>
  221. <!-- 修改 -->
  222. <el-dialog
  223. title="修改学习中心考试设置"
  224. size="tiny"
  225. :visible.sync="updateOrgSettingDialog"
  226. >
  227. <el-form
  228. :model="orgSetting"
  229. :rules="orgSettingRules"
  230. ref="updateOrgSettingForm"
  231. label-position="right"
  232. :inline="true"
  233. inline-message
  234. >
  235. <el-row>
  236. <el-form-item label="学习中心" prop="orgId" label-width="120px">
  237. <el-select
  238. class="select"
  239. :remote-method="getOrgList4InsertOrUpdate"
  240. :loading="loadingOrg4InsertOrUpdate"
  241. remote
  242. filterable
  243. clearable
  244. :disabled="true"
  245. v-model="orgSetting.orgId"
  246. placeholder="请选择"
  247. >
  248. <el-option
  249. v-for="item in orgList4InsertOrUpdate"
  250. :label="item.name"
  251. :value="item.id"
  252. :key="item.id"
  253. >
  254. </el-option>
  255. </el-select>
  256. </el-form-item>
  257. </el-row>
  258. <el-row>
  259. <el-form-item
  260. label="考试时间"
  261. prop="orgSettingDatetimeRange"
  262. label-width="120px"
  263. >
  264. <el-date-picker
  265. v-model="orgSettingDatetimeRange"
  266. type="datetimerange"
  267. range-separator="至"
  268. start-placeholder="开始日期"
  269. end-placeholder="结束日期"
  270. value-format="yyyy-MM-dd HH:mm:ss"
  271. >
  272. </el-date-picker>
  273. </el-form-item>
  274. </el-row>
  275. <el-row>
  276. <el-form-item label="是否可以考试" label-width="120px">
  277. <el-radio-group v-model="orgSetting.examLimit" class="input">
  278. <el-radio label="true">否</el-radio>
  279. <el-radio label="false">是</el-radio>
  280. </el-radio-group>
  281. </el-form-item>
  282. </el-row>
  283. <el-row>
  284. <div style="margin-left:30%">
  285. <el-button type="primary" @click="updateOrgSetting"
  286. >确 定</el-button
  287. >
  288. <el-button @click="updateOrgSettingDialog = false"
  289. >取 消</el-button
  290. >
  291. </div>
  292. </el-row>
  293. </el-form>
  294. </el-dialog>
  295. </div>
  296. </section>
  297. </div>
  298. </template>
  299. <script>
  300. import { CORE_API, EXAM_WORK_API } from "@/constants/constants.js";
  301. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  302. export default {
  303. components: { LinkTitlesCustom },
  304. data() {
  305. return {
  306. examId: null,
  307. loading4FormSearch: false,
  308. formSearch: {
  309. examId: null,
  310. orgId: ""
  311. },
  312. loadingOrg4Search: false,
  313. orgList4Search: [],
  314. tableData: [],
  315. currentPage: 1,
  316. pageSize: 10,
  317. total: 0,
  318. orgSetting: {
  319. examId: null,
  320. orgId: null,
  321. beginTime: null,
  322. endTime: null,
  323. examLimit: "false",
  324. properties: {
  325. CAN_UPLOAD_ATTACHMENT: "true"
  326. }
  327. },
  328. orgSettingDatetimeRange: [],
  329. addOrgSettingDialog: false,
  330. updateOrgSettingDialog: false,
  331. orgList4InsertOrUpdate: [],
  332. loadingOrg4InsertOrUpdate: false,
  333. orgSettingRules: {
  334. orgId: [
  335. { required: true, message: "请选择学习中心", trigger: "blur,change" }
  336. ]
  337. }
  338. };
  339. },
  340. methods: {
  341. getOrgList4Search(name) {
  342. this.loadingOrg4Search = true;
  343. var url = CORE_API + "/org/query?" + new URLSearchParams({ name: name });
  344. this.$httpWithMsg
  345. .get(url)
  346. .then(response => {
  347. this.orgList4Search = response.data;
  348. this.loadingOrg4Search = false;
  349. })
  350. .catch(response => {
  351. console.log(response);
  352. this.loadingOrg4Search = false;
  353. });
  354. },
  355. getOrgList4InsertOrUpdate(name) {
  356. this.loadingOrg4InsertOrUpdate = true;
  357. var url = CORE_API + "/org/query?" + new URLSearchParams({ name: name });
  358. this.$httpWithMsg
  359. .get(url)
  360. .then(response => {
  361. this.orgList4InsertOrUpdate = response.data;
  362. this.loadingOrg4InsertOrUpdate = false;
  363. })
  364. .catch(response => {
  365. console.log(response);
  366. this.loadingOrg4InsertOrUpdate = false;
  367. });
  368. },
  369. updateExamLimit(row) {
  370. row.examLimit = !row.examLimit;
  371. let url = EXAM_WORK_API + "/exam/examOrgSettings";
  372. this.$httpWithMsg.post(url, row).then(response => {
  373. row.updateTime = response.data.updateTime;
  374. });
  375. },
  376. updateOrgSetting() {
  377. if (!this.orgSettingDatetimeRange) {
  378. this.orgSetting.beginTime = null;
  379. this.orgSetting.endTime = null;
  380. } else {
  381. this.orgSetting.beginTime = this.orgSettingDatetimeRange[0];
  382. this.orgSetting.endTime = this.orgSettingDatetimeRange[1];
  383. }
  384. this.$refs.updateOrgSettingForm.validate(valid => {
  385. if (valid) {
  386. let url = EXAM_WORK_API + "/exam/examOrgSettings";
  387. this.$httpWithMsg.post(url, this.orgSetting).then(response => {
  388. console.log(response);
  389. this.$notify({
  390. type: "success",
  391. message: "保存成功"
  392. });
  393. this.search();
  394. this.updateOrgSettingDialog = false;
  395. });
  396. } else {
  397. return false;
  398. }
  399. });
  400. },
  401. addOrgSetting() {
  402. if (!this.orgSettingDatetimeRange) {
  403. this.orgSetting.beginTime = null;
  404. this.orgSetting.endTime = null;
  405. } else {
  406. this.orgSetting.beginTime = this.orgSettingDatetimeRange[0];
  407. this.orgSetting.endTime = this.orgSettingDatetimeRange[1];
  408. }
  409. this.$refs.addOrgSettingForm.validate(valid => {
  410. if (valid) {
  411. let url = EXAM_WORK_API + "/exam/examOrgSettings";
  412. this.$httpWithMsg.put(url, this.orgSetting).then(response => {
  413. console.log(response);
  414. this.$notify({
  415. type: "success",
  416. message: "保存成功"
  417. });
  418. this.search();
  419. this.addOrgSettingDialog = false;
  420. });
  421. } else {
  422. return false;
  423. }
  424. });
  425. },
  426. back() {
  427. this.$router.push({ path: "/examwork/examInfo" });
  428. },
  429. getCanUpload(row) {
  430. if (row.properties.CAN_UPLOAD_ATTACHMENT === null) {
  431. if (Date.now() > row.endTime) {
  432. return "不允许";
  433. } else {
  434. return "允许";
  435. }
  436. } else {
  437. return row.properties.CAN_UPLOAD_ATTACHMENT == "true"
  438. ? "允许"
  439. : "不允许";
  440. }
  441. },
  442. handleCurrentChange(val) {
  443. this.currentPage = val;
  444. this.search();
  445. },
  446. handleSizeChange(val) {
  447. this.pageSize = val;
  448. this.search();
  449. },
  450. showUpdateOrgSetting(row) {
  451. this.orgSetting.examId = row.examId;
  452. this.orgSetting.beginTime = row.beginTime;
  453. this.orgList4InsertOrUpdate = [{ id: row.orgId, name: row.orgName }];
  454. this.orgSetting.orgId = row.orgId;
  455. this.orgSetting.endTime = row.endTime;
  456. this.orgSetting.examLimit = row.examLimit ? "true" : "false";
  457. this.orgSetting.properties.CAN_UPLOAD_ATTACHMENT =
  458. row.properties.CAN_UPLOAD_ATTACHMENT;
  459. if (row.beginTime && row.endTime) {
  460. this.orgSettingDatetimeRange = [row.beginTime, row.endTime];
  461. }
  462. this.updateOrgSettingDialog = true;
  463. },
  464. showAddOrgSetting() {
  465. this.orgSetting.examId = this.examId;
  466. this.orgSetting.beginTime = null;
  467. this.orgList4InsertOrUpdate = [];
  468. this.orgSetting.orgId = null;
  469. this.orgSetting.endTime = null;
  470. this.orgSetting.properties.CAN_UPLOAD_ATTACHMENT = "true";
  471. this.orgSettingDatetimeRange = [];
  472. this.addOrgSettingDialog = true;
  473. },
  474. resetPageAndSearch() {
  475. this.currentPage = 1;
  476. this.search();
  477. },
  478. search() {
  479. let param = new URLSearchParams(this.formSearch);
  480. let url =
  481. EXAM_WORK_API +
  482. "/exam/getExamOrgSettingsList/" +
  483. (this.currentPage - 1) +
  484. "/" +
  485. this.pageSize +
  486. "?" +
  487. param;
  488. this.loading4FormSearch = true;
  489. this.$httpWithMsg
  490. .get(url)
  491. .then(response => {
  492. console.log(response);
  493. this.tableData = response.data.list;
  494. this.total = response.data.total;
  495. this.loading4FormSearch = false;
  496. })
  497. .catch(response => {
  498. console.log(response);
  499. this.loading4FormSearch = false;
  500. });
  501. },
  502. init() {
  503. this.search();
  504. }
  505. },
  506. created() {
  507. this.examId = this.$route.params.id;
  508. this.formSearch.examId = this.examId;
  509. this.init();
  510. }
  511. };
  512. </script>
  513. <style scoped></style>