onlineExamOrgSettings.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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 prop="updateTime" width="155" label="更新时间">
  75. </el-table-column>
  76. <el-table-column width="80" label="上传附件">
  77. <span slot-scope="scope"> {{ getCanUpload(scope.row) }} </span>
  78. </el-table-column>
  79. <el-table-column label="操作" width="80">
  80. <template slot-scope="scope">
  81. <div>
  82. <el-button
  83. size="mini"
  84. type="primary"
  85. plain
  86. icon="el-icon-edit"
  87. @click="showUpdateOrgSetting(scope.row)"
  88. >
  89. 编辑
  90. </el-button>
  91. </div>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <div class="page pull-right">
  96. <el-pagination
  97. @current-change="handleCurrentChange"
  98. :current-page="currentPage"
  99. :page-size="pageSize"
  100. :page-sizes="[10, 20, 50, 100]"
  101. @size-change="handleSizeChange"
  102. layout="total, sizes, prev, pager, next, jumper"
  103. :total="total"
  104. >
  105. </el-pagination>
  106. </div>
  107. <!-- 新增 -->
  108. <el-dialog
  109. title="新增学习中心考试设置"
  110. size="tiny"
  111. :visible.sync="addOrgSettingDialog"
  112. >
  113. <el-form
  114. :model="orgSetting"
  115. :rules="orgSettingRules"
  116. ref="addOrgSettingForm"
  117. label-position="right"
  118. :inline="true"
  119. inline-message
  120. >
  121. <el-row>
  122. <el-form-item label="学习中心" prop="orgId" label-width="120px">
  123. <el-select
  124. class="select"
  125. :remote-method="getOrgList4InsertOrUpdate"
  126. :loading="loadingOrg4InsertOrUpdate"
  127. remote
  128. filterable
  129. clearable
  130. v-model="orgSetting.orgId"
  131. placeholder="请选择"
  132. >
  133. <el-option
  134. v-for="item in orgList4InsertOrUpdate"
  135. :label="item.name"
  136. :value="item.id"
  137. :key="item.id"
  138. >
  139. </el-option>
  140. </el-select>
  141. </el-form-item>
  142. </el-row>
  143. <el-row>
  144. <el-form-item
  145. label="考试时间"
  146. prop="orgSettingDatetimeRange"
  147. label-width="120px"
  148. >
  149. <el-date-picker
  150. v-model="orgSettingDatetimeRange"
  151. type="datetimerange"
  152. range-separator="至"
  153. start-placeholder="开始日期"
  154. end-placeholder="结束日期"
  155. value-format="yyyy-MM-dd HH:mm:ss"
  156. :clearable="false"
  157. >
  158. </el-date-picker>
  159. </el-form-item>
  160. </el-row>
  161. <el-row>
  162. <el-form-item label-width="120px" label="上传附件">
  163. <el-radio-group
  164. v-model="orgSetting.properties.CAN_UPLOAD_ATTACHMENT"
  165. >
  166. <el-radio label="true">允许</el-radio>
  167. <el-radio label="false">不允许</el-radio>
  168. </el-radio-group>
  169. </el-form-item>
  170. </el-row>
  171. <el-row>
  172. <div style="text-align:center;">
  173. <el-button type="primary" @click="addOrgSetting"
  174. >确 定</el-button
  175. >
  176. <el-button @click="addOrgSettingDialog = false"
  177. >取 消</el-button
  178. >
  179. </div>
  180. </el-row>
  181. </el-form>
  182. </el-dialog>
  183. <!-- 修改 -->
  184. <el-dialog
  185. title="修改学习中心考试设置"
  186. size="tiny"
  187. :visible.sync="updateOrgSettingDialog"
  188. >
  189. <el-form
  190. :model="orgSetting"
  191. :rules="orgSettingRules"
  192. ref="updateOrgSettingForm"
  193. label-position="right"
  194. :inline="true"
  195. inline-message
  196. >
  197. <el-row>
  198. <el-form-item label="学习中心" prop="orgId" label-width="120px">
  199. <el-select
  200. class="select"
  201. :remote-method="getOrgList4InsertOrUpdate"
  202. :loading="loadingOrg4InsertOrUpdate"
  203. remote
  204. filterable
  205. clearable
  206. :disabled="true"
  207. v-model="orgSetting.orgId"
  208. placeholder="请选择"
  209. >
  210. <el-option
  211. v-for="item in orgList4InsertOrUpdate"
  212. :label="item.name"
  213. :value="item.id"
  214. :key="item.id"
  215. >
  216. </el-option>
  217. </el-select>
  218. </el-form-item>
  219. </el-row>
  220. <el-row>
  221. <el-form-item
  222. label="考试时间"
  223. prop="orgSettingDatetimeRange"
  224. label-width="120px"
  225. >
  226. <el-date-picker
  227. v-model="orgSettingDatetimeRange"
  228. type="datetimerange"
  229. range-separator="至"
  230. start-placeholder="开始日期"
  231. end-placeholder="结束日期"
  232. value-format="yyyy-MM-dd HH:mm:ss"
  233. :clearable="false"
  234. >
  235. </el-date-picker>
  236. </el-form-item>
  237. </el-row>
  238. <el-row>
  239. <el-form-item label-width="120px" label="上传附件">
  240. <el-radio-group
  241. v-model="orgSetting.properties.CAN_UPLOAD_ATTACHMENT"
  242. >
  243. <el-radio label="true">允许</el-radio>
  244. <el-radio label="false">不允许</el-radio>
  245. </el-radio-group>
  246. </el-form-item>
  247. </el-row>
  248. <el-row>
  249. <div style="margin-left:30%">
  250. <el-button type="primary" @click="updateOrgSetting"
  251. >确 定</el-button
  252. >
  253. <el-button @click="updateOrgSettingDialog = false"
  254. >取 消</el-button
  255. >
  256. </div>
  257. </el-row>
  258. </el-form>
  259. </el-dialog>
  260. </div>
  261. </section>
  262. </div>
  263. </template>
  264. <script>
  265. import { CORE_API, EXAM_WORK_API } from "@/constants/constants.js";
  266. import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
  267. let _this = null;
  268. let validateOrgSettingDatetimeRange = (rule, value, callback) => {
  269. let examDatetimeRange = _this.orgSettingDatetimeRange;
  270. if (!examDatetimeRange || 0 == examDatetimeRange.length) {
  271. callback(new Error("请输入考试时间"));
  272. _this.activeName = "tab1";
  273. } else {
  274. callback();
  275. }
  276. };
  277. export default {
  278. components: { LinkTitlesCustom },
  279. data() {
  280. return {
  281. examId: null,
  282. loading4FormSearch: false,
  283. formSearch: {
  284. examId: null,
  285. orgId: ""
  286. },
  287. loadingOrg4Search: false,
  288. orgList4Search: [],
  289. tableData: [],
  290. currentPage: 1,
  291. pageSize: 10,
  292. total: 0,
  293. orgSetting: {
  294. examId: null,
  295. orgId: null,
  296. beginTime: null,
  297. endTime: null,
  298. properties: {
  299. CAN_UPLOAD_ATTACHMENT: "true"
  300. }
  301. },
  302. orgSettingDatetimeRange: [],
  303. addOrgSettingDialog: false,
  304. updateOrgSettingDialog: false,
  305. orgList4InsertOrUpdate: [],
  306. loadingOrg4InsertOrUpdate: false,
  307. orgSettingRules: {
  308. orgId: [
  309. { required: true, message: "请选择学习中心", trigger: "blur,change" }
  310. ],
  311. orgSettingDatetimeRange: [
  312. {
  313. required: true,
  314. validator: validateOrgSettingDatetimeRange,
  315. trigger: "blur"
  316. }
  317. ]
  318. }
  319. };
  320. },
  321. methods: {
  322. getOrgList4Search(name) {
  323. this.loadingOrg4Search = true;
  324. var url = CORE_API + "/org/query?" + new URLSearchParams({ name: name });
  325. this.$httpWithMsg
  326. .get(url)
  327. .then(response => {
  328. this.orgList4Search = response.data;
  329. this.loadingOrg4Search = false;
  330. })
  331. .catch(response => {
  332. console.log(response);
  333. this.loadingOrg4Search = false;
  334. });
  335. },
  336. getOrgList4InsertOrUpdate(name) {
  337. this.loadingOrg4InsertOrUpdate = true;
  338. var url = CORE_API + "/org/query?" + new URLSearchParams({ name: name });
  339. this.$httpWithMsg
  340. .get(url)
  341. .then(response => {
  342. this.orgList4InsertOrUpdate = response.data;
  343. this.loadingOrg4InsertOrUpdate = false;
  344. })
  345. .catch(response => {
  346. console.log(response);
  347. this.loadingOrg4InsertOrUpdate = false;
  348. });
  349. },
  350. updateOrgSetting() {
  351. this.orgSetting.beginTime = this.orgSettingDatetimeRange[0];
  352. this.orgSetting.endTime = this.orgSettingDatetimeRange[1];
  353. this.$refs.updateOrgSettingForm.validate(valid => {
  354. if (valid) {
  355. let url = EXAM_WORK_API + "/exam/examOrgSettings";
  356. this.$httpWithMsg.post(url, this.orgSetting).then(response => {
  357. console.log(response);
  358. this.$notify({
  359. type: "success",
  360. message: "保存成功"
  361. });
  362. this.search();
  363. this.updateOrgSettingDialog = false;
  364. });
  365. } else {
  366. return false;
  367. }
  368. });
  369. },
  370. addOrgSetting() {
  371. this.orgSetting.beginTime = this.orgSettingDatetimeRange[0];
  372. this.orgSetting.endTime = this.orgSettingDatetimeRange[1];
  373. this.$refs.addOrgSettingForm.validate(valid => {
  374. if (valid) {
  375. let url = EXAM_WORK_API + "/exam/examOrgSettings";
  376. this.$httpWithMsg.put(url, this.orgSetting).then(response => {
  377. console.log(response);
  378. this.$notify({
  379. type: "success",
  380. message: "保存成功"
  381. });
  382. this.search();
  383. this.addOrgSettingDialog = false;
  384. });
  385. } else {
  386. return false;
  387. }
  388. });
  389. },
  390. back() {
  391. this.$router.push({ path: "/examwork/examInfo" });
  392. },
  393. getCanUpload(row) {
  394. if (row.properties.CAN_UPLOAD_ATTACHMENT === null) {
  395. if (Date.now() > row.endTime) {
  396. return "不允许";
  397. } else {
  398. return "允许";
  399. }
  400. } else {
  401. return row.properties.CAN_UPLOAD_ATTACHMENT == "true"
  402. ? "允许"
  403. : "不允许";
  404. }
  405. },
  406. handleCurrentChange(val) {
  407. this.currentPage = val;
  408. this.search();
  409. },
  410. handleSizeChange(val) {
  411. this.pageSize = val;
  412. this.search();
  413. },
  414. showUpdateOrgSetting(row) {
  415. this.orgSetting.examId = row.examId;
  416. this.orgSetting.beginTime = row.beginTime;
  417. this.orgList4InsertOrUpdate = [{ id: row.orgId, name: row.orgName }];
  418. this.orgSetting.orgId = row.orgId;
  419. this.orgSetting.endTime = row.endTime;
  420. this.orgSetting.properties.CAN_UPLOAD_ATTACHMENT =
  421. row.properties.CAN_UPLOAD_ATTACHMENT;
  422. if (row.beginTime && row.endTime) {
  423. this.orgSettingDatetimeRange = [row.beginTime, row.endTime];
  424. }
  425. this.updateOrgSettingDialog = true;
  426. },
  427. showAddOrgSetting() {
  428. this.orgSetting.examId = this.examId;
  429. this.orgSetting.beginTime = null;
  430. this.orgList4InsertOrUpdate = [];
  431. this.orgSetting.orgId = null;
  432. this.orgSetting.endTime = null;
  433. this.orgSetting.properties.CAN_UPLOAD_ATTACHMENT = "true";
  434. this.orgSettingDatetimeRange = [];
  435. this.addOrgSettingDialog = true;
  436. },
  437. resetPageAndSearch() {
  438. this.currentPage = 1;
  439. this.search();
  440. },
  441. search() {
  442. let param = new URLSearchParams(this.formSearch);
  443. let url =
  444. EXAM_WORK_API +
  445. "/exam/getExamOrgSettingsList/" +
  446. (this.currentPage - 1) +
  447. "/" +
  448. this.pageSize +
  449. "?" +
  450. param;
  451. this.loading4FormSearch = true;
  452. this.$httpWithMsg
  453. .get(url)
  454. .then(response => {
  455. console.log(response);
  456. this.tableData = response.data.list;
  457. this.total = response.data.total;
  458. this.loading4FormSearch = false;
  459. })
  460. .catch(response => {
  461. console.log(response);
  462. this.loading4FormSearch = false;
  463. });
  464. },
  465. init() {
  466. this.search();
  467. }
  468. },
  469. created() {
  470. _this = this;
  471. this.examId = this.$route.params.id;
  472. this.formSearch.examId = this.examId;
  473. this.init();
  474. }
  475. };
  476. </script>
  477. <style scoped></style>