notice.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <!-- 正文信息 -->
  5. <div class="box-body">
  6. <el-form
  7. :inline="true"
  8. :model="formSearch"
  9. label-position="left"
  10. label-width="70px"
  11. >
  12. <el-form-item label="标题" class="pull-left">
  13. <el-input
  14. v-model="formSearch.title"
  15. auto-complete="off"
  16. width="200px"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item class="d-block">
  20. <el-button
  21. size="small"
  22. type="primary"
  23. icon="el-icon-search"
  24. @click="resetPageAndSearchForm"
  25. >查询</el-button
  26. >
  27. <el-button
  28. size="small"
  29. type="primary"
  30. icon="el-icon-plus"
  31. @click="addNoticeDialog"
  32. >新增</el-button
  33. >
  34. </el-form-item>
  35. </el-form>
  36. <div class="block-seperator"></div>
  37. <span>批量操作:</span>
  38. <el-button
  39. size="small"
  40. type="danger"
  41. icon="el-icon-delete"
  42. @click="deleteByIds"
  43. >删除</el-button
  44. >
  45. <div style="width: 100%; margin-bottom: 10px"></div>
  46. <!-- 页面列表 -->
  47. <el-table
  48. v-loading="loading"
  49. element-loading-text="拼命加载中"
  50. :data="tableData"
  51. border
  52. style="width: 100%; text-align: center"
  53. @selection-change="selectChange"
  54. >
  55. <el-table-column type="selection" width="40"></el-table-column>
  56. <el-table-column
  57. prop="id"
  58. width="60"
  59. label="ID"
  60. sortable
  61. ></el-table-column>
  62. <el-table-column prop="title" label="标题"></el-table-column>
  63. <!-- <el-table-column prop="publishObject" label="发送对象"></el-table-column> -->
  64. <el-table-column label="发送对象" width="180">
  65. <template slot-scope="scope">
  66. <el-popover
  67. :title="getRuleTypeName(scope.row.ruleType)"
  68. trigger="hover"
  69. placement="top-start"
  70. width="200px"
  71. >
  72. <div style="max-width: 450px">
  73. <el-tag
  74. v-for="item in scope.row.publishObject"
  75. :key="'po' + item.id"
  76. style="margin-right: 5px; margin-top: 5px"
  77. type="info"
  78. effect="plain"
  79. >{{ item.name }}</el-tag
  80. >
  81. </div>
  82. <!-- <p v-html="getPublishObject(scope.row.publishObject)"></p> -->
  83. <div slot="reference" style="text-align: left">
  84. <!-- <el-tag size="medium"> -->
  85. {{ getPublishObject(scope.row.publishObject) }}
  86. <!-- </el-tag> -->
  87. </div>
  88. </el-popover>
  89. </template>
  90. </el-table-column>
  91. <el-table-column
  92. width="80"
  93. prop="publisher"
  94. label="发布者"
  95. ></el-table-column>
  96. <el-table-column width="80" label="状态" sortable>
  97. <template slot-scope="scope">
  98. <div>
  99. <span>{{ getPublishStatus(scope.row.publishStatus) }}</span>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="publishTime"
  105. width="155"
  106. label="发送时间"
  107. sortable
  108. ></el-table-column>
  109. <el-table-column label="操作" width="270">
  110. <div slot-scope="scope">
  111. <el-button
  112. size="mini"
  113. type="primary"
  114. icon="el-icon-view"
  115. plain
  116. @click="viewNoticeDialog(scope.row)"
  117. >详情</el-button
  118. >
  119. <el-button
  120. v-if="scope.row.publishStatus == 'DRAFT'"
  121. size="mini"
  122. type="primary"
  123. icon="el-icon-message"
  124. @click="sendMsg(scope.row.id)"
  125. >发送</el-button
  126. >
  127. <el-dropdown
  128. style="margin-left: 10px"
  129. :disabled="scope.row.publishStatus != 'DRAFT'"
  130. >
  131. <el-button type="primary" plain size="mini">
  132. 更多 <i class="el-icon-arrow-down el-icon--right"></i>
  133. </el-button>
  134. <el-dropdown-menu slot="dropdown">
  135. <el-dropdown-item>
  136. <el-button
  137. :disabled="scope.row.publishStatus != 'DRAFT'"
  138. size="mini"
  139. type="primary"
  140. icon="el-icon-edit"
  141. plain
  142. @click="editNoticeDialog(scope.row)"
  143. >编辑</el-button
  144. >
  145. </el-dropdown-item>
  146. <el-dropdown-item>
  147. <el-button
  148. :disabled="scope.row.publishStatus != 'DRAFT'"
  149. size="mini"
  150. type="danger"
  151. icon="el-icon-delete"
  152. @click="deleteById(scope.row)"
  153. >删除</el-button
  154. >
  155. </el-dropdown-item>
  156. <el-dropdown-item>
  157. <el-button
  158. v-if="scope.row.publishStatus == 'PUBLISHED'"
  159. size="mini"
  160. type="warning"
  161. icon="el-icon-back"
  162. @click="recallMsg(scope.row.id)"
  163. >撤回</el-button
  164. >
  165. </el-dropdown-item>
  166. </el-dropdown-menu>
  167. </el-dropdown>
  168. </div>
  169. </el-table-column>
  170. </el-table>
  171. <div class="page pull-right">
  172. <el-pagination
  173. v-if="paginationShow"
  174. :current-page="currentPage"
  175. :page-size="pageSize"
  176. :page-sizes="[10, 20, 50, 100, 200, 300]"
  177. layout="total, sizes, prev, pager, next, jumper"
  178. :total="total"
  179. @current-change="handleCurrentChange"
  180. @size-change="handleSizeChange"
  181. ></el-pagination>
  182. </div>
  183. <!-- 弹出窗口 -->
  184. <el-dialog
  185. v-if="editNoticeDialogVisible"
  186. width="700px"
  187. :title="
  188. operateType == 'add'
  189. ? '新增公告'
  190. : operateType == 'edit'
  191. ? '编辑公告'
  192. : '公告详情'
  193. "
  194. :visible.sync="editNoticeDialogVisible"
  195. :before-close="handleClose"
  196. :close-on-click-modal="false"
  197. @close="cancel"
  198. >
  199. <el-form
  200. ref="noticeForm"
  201. :model="noticeForm"
  202. inline-message
  203. size="large"
  204. :rules="rules"
  205. :inline="true"
  206. label-width="85px"
  207. class="editForm"
  208. >
  209. <el-form-item label="标题" prop="title">
  210. <el-input
  211. v-model="noticeForm.title"
  212. class="input"
  213. :readonly="operateType == 'view'"
  214. auto-complete="off"
  215. maxlength="50"
  216. ></el-input>
  217. </el-form-item>
  218. <el-form-item label="发布人" prop="publisher">
  219. <el-input
  220. v-model="noticeForm.publisher"
  221. class="input"
  222. :readonly="operateType == 'view'"
  223. maxlength="50"
  224. ></el-input>
  225. </el-form-item>
  226. <el-form-item label="发送对象" prop="ruleType">
  227. <el-select
  228. v-model="noticeForm.ruleType"
  229. :disabled="operateType == 'view'"
  230. class="input"
  231. clearable
  232. placeholder="请选择"
  233. @change="showSelectReceiver"
  234. >
  235. <el-option
  236. v-for="item in receiverRuleTypes"
  237. :key="item.code"
  238. :label="item.name"
  239. :value="item.code"
  240. ></el-option>
  241. </el-select>
  242. <el-button
  243. v-show="
  244. (noticeForm.ruleType == 'TEACHER_OF_MARK_WORK' ||
  245. noticeForm.ruleType == 'STUDENTS_OF_EXAM') &&
  246. operateType != 'view'
  247. "
  248. style="margin-left: 5px"
  249. @click="showSelectReceiver"
  250. >选 择</el-button
  251. >
  252. </el-form-item>
  253. <el-row v-if="selectedExam.length != 0" :gutter="10">
  254. <el-col :xs="30" :sm="30" :md="30" :lg="30">
  255. <el-form-item label="已选">
  256. <el-tag
  257. v-for="tag in selectedExam"
  258. :key="'res-exam' + tag.id"
  259. style="margin-left: 5px; margin-top: 5px"
  260. :closable="false"
  261. :close-transition="false"
  262. type="info"
  263. @close="examTagClose(tag)"
  264. >{{ tag.name }}</el-tag
  265. >
  266. </el-form-item>
  267. </el-col>
  268. </el-row>
  269. <el-row v-if="selectedMark.length != 0" :gutter="10">
  270. <el-col :xs="30" :sm="30" :md="30" :lg="30">
  271. <el-form-item label="已选">
  272. <el-tag
  273. v-for="tag in selectedMark"
  274. :key="'res-mark' + tag.id"
  275. style="margin-left: 5px; margin-top: 5px"
  276. :closable="false"
  277. :close-transition="false"
  278. type="info"
  279. @close="markTagClose(tag)"
  280. >{{ tag.name }}</el-tag
  281. >
  282. </el-form-item>
  283. </el-col>
  284. </el-row>
  285. <el-form-item label="公告内容" prop="content">
  286. <div>
  287. <ckeditor
  288. v-model="noticeForm.content"
  289. extrabuttons="Font,FontSize,TextColor"
  290. :readonly="operateType == 'view'"
  291. width="650px"
  292. ></ckeditor>
  293. </div>
  294. </el-form-item>
  295. </el-form>
  296. <div style="text-align: center">
  297. <el-button
  298. v-show="operateType != 'view'"
  299. type="primary"
  300. :loading="noticeFormLoading"
  301. @click="saveNotice"
  302. >保 存</el-button
  303. >
  304. <el-button @click="cancel">关 闭</el-button>
  305. </div>
  306. <!-- 考试弹框 start-->
  307. <el-dialog
  308. width="600px"
  309. :before-close="handleClose"
  310. title="发送对象"
  311. :visible.sync="examReceiverVisible"
  312. append-to-body
  313. :close-on-click-modal="false"
  314. @close="examCancel"
  315. >
  316. <el-form
  317. inline-message
  318. :inline="true"
  319. :model="examFormSearch"
  320. label-position="right"
  321. label-width="70px"
  322. >
  323. <el-row v-if="selectedExam.length != 0" :gutter="10">
  324. <el-col :xs="30" :sm="30" :md="30" :lg="30">
  325. <el-form-item label="已选">
  326. <el-tag
  327. v-for="tag in selectedExam"
  328. :key="'exam' + tag.id"
  329. :closable="true"
  330. :close-transition="false"
  331. type="info"
  332. @close="examTagClose(tag)"
  333. >{{ tag.name }}</el-tag
  334. >
  335. </el-form-item>
  336. </el-col>
  337. </el-row>
  338. <el-form-item label="考试名称" class="pull-left">
  339. <el-input
  340. v-model="examFormSearch.name"
  341. auto-complete="off"
  342. width="200px"
  343. ></el-input>
  344. </el-form-item>
  345. <el-form-item class="d-block">
  346. <el-button
  347. size="small"
  348. type="primary"
  349. icon="el-icon-search"
  350. @click="resetExamPageAndSearchForm"
  351. >查询</el-button
  352. >
  353. </el-form-item>
  354. </el-form>
  355. <div class="table-native" style="height: 400px">
  356. <el-table
  357. ref="examTable"
  358. v-loading="loading"
  359. stripe
  360. element-loading-text="拼命加载中"
  361. :data="examTableData"
  362. border
  363. @selection-change="examSelectChange"
  364. >
  365. <el-table-column type="selection" width="55"></el-table-column>
  366. <el-table-column label="考试id" prop="id"></el-table-column>
  367. <el-table-column label="考试名称" prop="name"></el-table-column>
  368. <el-table-column width="130" label="考试类型" sortable>
  369. <template slot-scope="scope">
  370. <div>
  371. <span>{{ getExamType(scope.row.examType) }}</span>
  372. </div>
  373. </template>
  374. </el-table-column>
  375. </el-table>
  376. <div class="page pull-right">
  377. <el-pagination
  378. v-if="examPaginationShow"
  379. small
  380. :current-page="examCurrentPage"
  381. :page-size="examPageSize"
  382. :page-sizes="[10]"
  383. layout="total, sizes, prev, pager, next, jumper"
  384. :total="examTotal"
  385. @current-change="handleExamCurrentChange"
  386. @size-change="handleExamSizeChange"
  387. ></el-pagination>
  388. </div>
  389. </div>
  390. <div style="margin-top: 20px; text-align: center">
  391. <el-button @click="examConfirm">确 定</el-button>
  392. <el-button @click="examCancel">取消</el-button>
  393. </div>
  394. </el-dialog>
  395. <!-- 考试弹框 end-->
  396. <!-- 阅卷工作弹框 start-->
  397. <el-dialog
  398. :before-close="handleClose"
  399. width="600px"
  400. title="发送对象"
  401. :visible.sync="markReceiverVisible"
  402. append-to-body
  403. :close-on-click-modal="false"
  404. @close="markCancel"
  405. >
  406. <el-form
  407. inline-message
  408. :inline="true"
  409. :model="markFormSearch"
  410. label-position="right"
  411. label-width="110px"
  412. >
  413. <el-row v-if="selectedMark.length != 0" :gutter="10">
  414. <el-col :xs="30" :sm="30" :md="30" :lg="30">
  415. <el-form-item label="已选">
  416. <el-tag
  417. v-for="tag in selectedMark"
  418. :key="'mark' + tag.id"
  419. :closable="true"
  420. :close-transition="false"
  421. type="info"
  422. @close="markTagClose(tag)"
  423. >{{ tag.name }}</el-tag
  424. >
  425. </el-form-item>
  426. </el-col>
  427. </el-row>
  428. <el-form-item label="评卷工作名称" class="pull-left">
  429. <el-input
  430. v-model="markFormSearch.workName"
  431. auto-complete="off"
  432. width="200px"
  433. ></el-input>
  434. </el-form-item>
  435. <el-form-item class="d-block">
  436. <el-button
  437. size="small"
  438. type="primary"
  439. icon="el-icon-search"
  440. @click="resetMarkPageAndSearchForm"
  441. >查询</el-button
  442. >
  443. </el-form-item>
  444. </el-form>
  445. <div class="table-native" style="height: 400px">
  446. <el-table
  447. ref="markTable"
  448. v-loading="loading"
  449. stripe
  450. element-loading-text="拼命加载中"
  451. :data="markTableData"
  452. border
  453. @selection-change="markSelectChange"
  454. >
  455. <el-table-column type="selection" width="55"></el-table-column>
  456. <!-- <el-table-column label="考试id" prop="id"></el-table-column> -->
  457. <el-table-column
  458. label="评卷工作名称"
  459. prop="name"
  460. ></el-table-column>
  461. <el-table-column label="考试名称-类型" width="300">
  462. <template slot-scope="scope"
  463. ><div>
  464. <span
  465. v-for="item in scope.row.examNameAndType"
  466. :key="item.index"
  467. style="display: block"
  468. >{{ item }}</span
  469. >
  470. </div></template
  471. >
  472. </el-table-column>
  473. </el-table>
  474. <div class="page pull-right">
  475. <el-pagination
  476. v-if="markPaginationShow"
  477. small
  478. :current-page="markCurrentPage"
  479. :page-size="markPageSize"
  480. :page-sizes="[10]"
  481. layout="total, sizes, prev, pager, next, jumper"
  482. :total="markTotal"
  483. @current-change="handleMarkCurrentChange"
  484. @size-change="handleMarkSizeChange"
  485. ></el-pagination>
  486. </div>
  487. </div>
  488. <div style="margin-top: 20px; text-align: center">
  489. <el-button @click="markConfirm">确 定</el-button>
  490. <el-button @click="markCancel">取消</el-button>
  491. </div>
  492. </el-dialog>
  493. <!-- 阅卷工作弹框 end-->
  494. </el-dialog>
  495. </div>
  496. </div>
  497. </section>
  498. </template>
  499. <script>
  500. import {
  501. EXAM_WORK_API,
  502. EXAM_TYPE,
  503. PUBLISH_STATUS,
  504. NOTICE_RECEIVER_RULE_TYPE,
  505. MARKING_API,
  506. } from "@/constants/constants.js";
  507. import { mapState } from "vuex";
  508. import ckeditor from "@/components/ckeditor.vue";
  509. export default {
  510. components: { ckeditor },
  511. data() {
  512. return {
  513. noticeFormLoading: false,
  514. formSearch: {
  515. title: "",
  516. },
  517. examFormSearch: {
  518. enable: true,
  519. name: "",
  520. },
  521. markFormSearch: {
  522. workName: "",
  523. },
  524. selectedExam: [],
  525. tempSelectedExam: [],
  526. selectedMark: [],
  527. tempSelectedMark: [],
  528. examTableData: [],
  529. markTableData: [],
  530. operateType: "add",
  531. examTypeList: EXAM_TYPE,
  532. noticeForm: {
  533. id: null,
  534. title: "",
  535. content: "",
  536. publisher: "",
  537. ruleType: "", //规则类型
  538. publishObjectId: "", //发送对象id
  539. noticeStatus: "",
  540. },
  541. receiverForm: {
  542. receiverObjectType: null,
  543. receiverObject: "",
  544. ruleType: "", //规则类型
  545. publishObjectId: "", //发送对象id
  546. },
  547. receiverRuleTypes: NOTICE_RECEIVER_RULE_TYPE,
  548. loading: false,
  549. publishStatusList: PUBLISH_STATUS,
  550. tableData: [],
  551. paginationShow: false,
  552. examPaginationShow: false,
  553. markPaginationShow: false,
  554. editNoticeDialogVisible: false,
  555. examReceiverVisible: false,
  556. markReceiverVisible: false,
  557. currentPage: 1,
  558. pageSize: 10,
  559. total: 10,
  560. examCurrentPage: 1,
  561. examPageSize: 10,
  562. examTotal: 10,
  563. markCurrentPage: 1,
  564. markPageSize: 10,
  565. markTotal: 10,
  566. selectedNoticeIds: [],
  567. button: {},
  568. rules: {
  569. title: [{ required: true, message: "请输入标题", trigger: "blur" }],
  570. content: [{ required: true, message: "请输入内容", trigger: "blur" }],
  571. ruleType: [
  572. { required: true, message: "请选择接收人", trigger: "change" },
  573. ],
  574. publisher: [
  575. { required: true, message: "请输入发布人", trigger: "blur" },
  576. ],
  577. },
  578. };
  579. },
  580. computed: {
  581. ...mapState({ user: (state) => state.user }),
  582. noticeIds() {
  583. var strNoticeIds = "";
  584. for (let nid of this.selectedNoticeIds) {
  585. if (!strNoticeIds) {
  586. strNoticeIds += nid;
  587. } else {
  588. strNoticeIds += "," + nid;
  589. }
  590. }
  591. return strNoticeIds;
  592. },
  593. selectedExamIds() {
  594. var selectedIds = "";
  595. for (let exam of this.selectedExam) {
  596. if (!selectedIds) {
  597. selectedIds += exam.id;
  598. } else {
  599. selectedIds += "," + exam.id;
  600. }
  601. }
  602. return selectedIds;
  603. },
  604. selectedMarkIds() {
  605. var selectedIds = "";
  606. for (let mark of this.selectedMark) {
  607. if (!selectedIds) {
  608. selectedIds += mark.id;
  609. } else {
  610. selectedIds += "," + mark.id;
  611. }
  612. }
  613. return selectedIds;
  614. },
  615. },
  616. //初始化查询
  617. created() {
  618. this.searchForm();
  619. },
  620. methods: {
  621. closeEditNoticeDialog() {
  622. this.editNoticeDialogVisible = false;
  623. },
  624. selectChange(row) {
  625. this.selectedNoticeIds = [];
  626. row.forEach((element, index) => {
  627. console.log(index);
  628. this.selectedNoticeIds.push(element.id);
  629. });
  630. console.log(this.selectedNoticeIds);
  631. },
  632. handleCurrentChange(val) {
  633. this.currentPage = val;
  634. this.searchForm();
  635. },
  636. handleSizeChange(val) {
  637. this.pageSize = val;
  638. this.searchForm();
  639. },
  640. resetPageAndSearchForm() {
  641. this.currentPage = 1;
  642. this.searchForm();
  643. },
  644. examSelectChange(row) {
  645. if (this.getAfterAddCount(this.selectedExam, row) > 10) {
  646. this.warn("一次最多只能选择10个考试!");
  647. return;
  648. }
  649. this.tempSelectedExam = row;
  650. var selectedExams = this.selectedExam;
  651. row.forEach((element) => {
  652. if (
  653. !selectedExams.some((se) => se.id == element.id) &&
  654. selectedExams.length < 10
  655. ) {
  656. selectedExams.push(element);
  657. }
  658. });
  659. this.selectedExam = selectedExams;
  660. },
  661. markSelectChange(row) {
  662. if (this.getAfterAddCount(this.selectedMark, row) > 10) {
  663. this.warn("一次最多只能选择10个阅卷工作!");
  664. return;
  665. }
  666. this.tempSelectedMark = row;
  667. var selectedMarks = this.selectedMark;
  668. row.forEach((element) => {
  669. if (
  670. !selectedMarks.some((sm) => sm.id == element.id) &&
  671. selectedMarks.length < 10
  672. ) {
  673. selectedMarks.push(element);
  674. }
  675. });
  676. this.selectedMark = selectedMarks;
  677. },
  678. getAfterAddCount(selecteds, row) {
  679. const selectedids = selecteds.map((x) => x.id);
  680. const temcount =
  681. row.filter((key) => selectedids.includes(key.id) === false).length +
  682. selectedids.length;
  683. return temcount;
  684. },
  685. handleExamCurrentChange(val) {
  686. this.examCurrentPage = val;
  687. this.searchExamForm();
  688. },
  689. handleExamSizeChange(val) {
  690. this.examPageSize = val;
  691. this.searchExamForm();
  692. },
  693. handleMarkCurrentChange(val) {
  694. this.markCurrentPage = val;
  695. this.searchMarkForm();
  696. },
  697. handleMarkSizeChange(val) {
  698. this.markPageSize = val;
  699. this.searchMarkForm();
  700. },
  701. resetExamPageAndSearchForm() {
  702. this.examCurrentPage = 1;
  703. this.searchExamForm();
  704. },
  705. resetMarkPageAndSearchForm() {
  706. this.markCurrentPage = 1;
  707. this.searchMarkForm();
  708. },
  709. //查询方法
  710. searchForm() {
  711. var param = new URLSearchParams(this.formSearch);
  712. var url =
  713. EXAM_WORK_API +
  714. "/notice/getPagedNoticeList/" +
  715. (this.currentPage - 1) +
  716. "/" +
  717. this.pageSize +
  718. "?" +
  719. param;
  720. this.loading = true;
  721. this.$httpWithMsg.get(url).then((response) => {
  722. console.log(response);
  723. this.tableData = response.data.list;
  724. this.total = response.data.total;
  725. this.loading = false;
  726. this.paginationShow = true;
  727. });
  728. },
  729. searchExamForm() {
  730. var param = new URLSearchParams(this.examFormSearch);
  731. var url =
  732. EXAM_WORK_API +
  733. "/exam/queryPage/" +
  734. (this.examCurrentPage - 1) +
  735. "/" +
  736. this.examPageSize +
  737. "?" +
  738. param;
  739. this.loading = true;
  740. this.$httpWithMsg.get(url).then((response) => {
  741. console.log(response);
  742. this.examTableData = response.data.list;
  743. this.examTotal = response.data.total;
  744. this.loading = false;
  745. this.examPaginationShow = true;
  746. });
  747. },
  748. searchMarkForm() {
  749. var param = new URLSearchParams(this.markFormSearch);
  750. var url =
  751. MARKING_API +
  752. "/markWorks/getMarkWorkPage/" +
  753. this.markCurrentPage +
  754. "/" +
  755. this.markPageSize +
  756. "?" +
  757. param;
  758. this.loading = true;
  759. this.$httpWithMsg.get(url).then((response) => {
  760. console.log(response);
  761. this.markTableData = response.data.list;
  762. this.markTotal = response.data.total;
  763. this.loading = false;
  764. this.markPaginationShow = true;
  765. });
  766. },
  767. getExamType(examType) {
  768. for (let tempExamType of this.examTypeList) {
  769. if (tempExamType.value == examType) {
  770. return tempExamType.label;
  771. }
  772. }
  773. },
  774. addNoticeDialog() {
  775. this.operateType = "add";
  776. this.noticeForm.id = null;
  777. this.noticeForm.title = "";
  778. this.noticeForm.content = "";
  779. this.noticeForm.publisher = "";
  780. this.noticeForm.ruleType = "";
  781. this.noticeForm.noticeStatus = "";
  782. this.editNoticeDialogVisible = true;
  783. this.selectedExam = [];
  784. this.selectedMark = [];
  785. this.noticeForm = {};
  786. },
  787. editNoticeDialog(row) {
  788. this.operateType = "edit";
  789. this.noticeForm = Object.assign({}, row);
  790. this.selectedExam = [];
  791. this.selectedMark = [];
  792. if (row.publishObject && row.publishObject.length > 0) {
  793. if (row.ruleType == "STUDENTS_OF_EXAM") {
  794. this.selectedExam = row.publishObject;
  795. } else if (row.ruleType == "TEACHER_OF_MARK_WORK") {
  796. this.selectedMark = row.publishObject;
  797. }
  798. }
  799. this.editNoticeDialogVisible = true;
  800. },
  801. viewNoticeDialog(row) {
  802. this.operateType = "view";
  803. this.noticeForm = Object.assign({}, row);
  804. if (row.publishObject && row.publishObject.length > 0) {
  805. if (row.ruleType == "STUDENTS_OF_EXAM") {
  806. this.selectedExam = row.publishObject;
  807. } else if (row.ruleType == "TEACHER_OF_MARK_WORK") {
  808. this.selectedMark = row.publishObject;
  809. }
  810. }
  811. this.editNoticeDialogVisible = true;
  812. },
  813. getPublishObject(publishObjectList) {
  814. if (publishObjectList == null || publishObjectList.length == 0) {
  815. return "";
  816. }
  817. let ruleType = publishObjectList[0].ruleType;
  818. if (
  819. ruleType == "ALL_STUDENTS_OF_ROOT_ORG" ||
  820. ruleType == "COMMON_USERS_OF_ROLE"
  821. ) {
  822. return publishObjectList[0].name;
  823. }
  824. let strName = "";
  825. for (let po of publishObjectList) {
  826. strName += po.name + ";";
  827. }
  828. if (strName.lastIndexOf(";") == strName.length - 1) {
  829. strName = strName.substring(0, strName.length - 1);
  830. }
  831. if (strName.length > 15) {
  832. strName = strName.substr(0, 15) + "...";
  833. }
  834. return strName;
  835. },
  836. getRuleTypeName(ruleType) {
  837. for (let rt of this.receiverRuleTypes) {
  838. if (ruleType == rt.code) {
  839. return rt.name;
  840. }
  841. }
  842. },
  843. getPublishStatus(publishStatus) {
  844. for (let status of this.publishStatusList) {
  845. if (status.code == publishStatus) {
  846. return status.name;
  847. }
  848. }
  849. },
  850. //删除单个数据
  851. deleteById(row) {
  852. this.$confirm("是否删除该通知?", "提示", {
  853. confirmButtonText: "确定",
  854. cancelButtonText: "取消",
  855. type: "warning",
  856. }).then(() => {
  857. var url = EXAM_WORK_API + "/notice/" + row.id;
  858. this.$httpWithMsg.delete(url).then(() => {
  859. this.$notify({
  860. type: "success",
  861. message: "删除成功!",
  862. });
  863. this.searchForm();
  864. });
  865. });
  866. },
  867. //删除多条数据
  868. deleteByIds() {
  869. if (this.selectedNoticeIds.length === 0) {
  870. this.warn("请选择要删除的通知");
  871. } else {
  872. this.$confirm("是否删除这些通知?", "提示", {
  873. confirmButtonText: "确定",
  874. cancelButtonText: "取消",
  875. type: "error",
  876. }).then(() => {
  877. var url = EXAM_WORK_API + "/notice/" + this.noticeIds;
  878. this.$httpWithMsg.delete(url).then(() => {
  879. this.success("删除成功!");
  880. this.searchForm();
  881. });
  882. });
  883. }
  884. },
  885. sendMsg(id) {
  886. this.$httpWithMsg
  887. .get(EXAM_WORK_API + "/notice/sendMsg/" + id)
  888. .then(() => {
  889. this.success("发送成功");
  890. this.searchForm();
  891. });
  892. },
  893. recallMsg(id) {
  894. this.$httpWithMsg
  895. .get(EXAM_WORK_API + "/notice/recallMsg/" + id)
  896. .then(() => {
  897. this.success("撤回成功");
  898. this.searchForm();
  899. });
  900. },
  901. saveNotice() {
  902. this.noticeForm.noticeStatus = "DRAFT";
  903. this.$refs["noticeForm"].validate((valid) => {
  904. if (valid) {
  905. if (
  906. this.noticeForm.ruleType == "STUDENTS_OF_EXAM" ||
  907. this.noticeForm.ruleType == "TEACHER_OF_MARK_WORK"
  908. ) {
  909. if (this.noticeForm.ruleType == "STUDENTS_OF_EXAM") {
  910. this.noticeForm.publishObjectId = this.selectedExamIds;
  911. } else if (this.noticeForm.ruleType == "TEACHER_OF_MARK_WORK") {
  912. this.noticeForm.publishObjectId = this.selectedMarkIds;
  913. }
  914. if (this.noticeForm.publishObjectId == "") {
  915. this.warn("请选择发送对象!");
  916. return;
  917. }
  918. }
  919. this.noticeFormLoading = true;
  920. //修改
  921. if ("edit" == this.operateType) {
  922. this.$httpWithMsg
  923. .post(EXAM_WORK_API + "/notice/updateNotice", this.noticeForm)
  924. .then(
  925. () => {
  926. this.success("修改成功!");
  927. this.searchForm();
  928. this.noticeFormLoading = false;
  929. this.editNoticeDialogVisible = false;
  930. },
  931. () => {
  932. this.editNoticeDialogVisible = true;
  933. this.noticeFormLoading = false;
  934. }
  935. );
  936. }
  937. //新增
  938. else {
  939. this.noticeForm.noticeStatus = "DRAFT";
  940. this.$httpWithMsg
  941. .post(EXAM_WORK_API + "/notice/addNotice", this.noticeForm)
  942. .then(
  943. () => {
  944. this.success("新增成功!");
  945. this.editNoticeDialogVisible = false;
  946. this.noticeFormLoading = false;
  947. this.searchForm();
  948. },
  949. () => {
  950. this.editNoticeDialogVisible = true;
  951. this.noticeFormLoading = false;
  952. }
  953. );
  954. }
  955. } else {
  956. console.log("error submit!");
  957. return false;
  958. }
  959. });
  960. },
  961. showSelectReceiver() {
  962. if (this.noticeForm.ruleType == "STUDENTS_OF_EXAM") {
  963. this.selectedMark = [];
  964. this.examFormSearch.name = "";
  965. this.resetExamPageAndSearchForm();
  966. this.examReceiverVisible = true;
  967. } else if (this.noticeForm.ruleType == "TEACHER_OF_MARK_WORK") {
  968. this.selectedExam = [];
  969. this.markFormSearch.workName = "";
  970. this.resetMarkPageAndSearchForm();
  971. this.markReceiverVisible = true;
  972. } else {
  973. this.examReceiverVisible = false;
  974. this.markReceiverVisible = false;
  975. }
  976. },
  977. examTagClose(tag) {
  978. for (let [index, exam] of this.selectedExam.entries()) {
  979. if (tag.id == exam.id) {
  980. this.toggleExamSelection(
  981. this.examTableData.find((p) => p.id == exam.id)
  982. );
  983. this.examTableData.splice(
  984. this.examTableData.findIndex((p) => p.id == exam.id),
  985. 1
  986. );
  987. this.selectedExam.splice(index, 1);
  988. }
  989. }
  990. },
  991. markTagClose(tag) {
  992. for (let [index, mark] of this.selectedMark.entries()) {
  993. if (tag.id == mark.id) {
  994. this.toggleMarkSelection(
  995. this.markTableData.find((p) => p.id == mark.id)
  996. );
  997. this.markTableData.splice(
  998. this.markTableData.findIndex((p) => p.id == mark.id),
  999. 1
  1000. );
  1001. this.selectedMark.splice(index, 1);
  1002. }
  1003. }
  1004. },
  1005. toggleExamSelection(row) {
  1006. if (
  1007. this.tempSelectedExam &&
  1008. this.tempSelectedExam.length > 0 &&
  1009. this.tempSelectedExam.some((p) => p.id == row.id)
  1010. ) {
  1011. this.$refs.examTable.toggleRowSelection(row);
  1012. }
  1013. },
  1014. toggleMarkSelection(row) {
  1015. if (
  1016. this.tempSelectedMark &&
  1017. this.tempSelectedMark.length > 0 &&
  1018. this.tempSelectedMark.some((p) => p.id == row.id)
  1019. ) {
  1020. this.$refs.markTable.toggleRowSelection(row);
  1021. }
  1022. },
  1023. examConfirm() {
  1024. this.examReceiverVisible = false;
  1025. },
  1026. markConfirm() {
  1027. this.markReceiverVisible = false;
  1028. },
  1029. resetForm(formName) {
  1030. this.$refs[formName].resetFields();
  1031. },
  1032. cancel() {
  1033. this.markReceiverVisible = false;
  1034. this.examReceiverVisible = false;
  1035. this.selectedExam = [];
  1036. this.selectedMark = [];
  1037. this.editNoticeDialogVisible = false;
  1038. },
  1039. examCancel() {
  1040. this.examReceiverVisible = false;
  1041. },
  1042. markCancel() {
  1043. this.markReceiverVisible = false;
  1044. },
  1045. warn(msg) {
  1046. this.$notify({
  1047. type: "warning",
  1048. message: msg,
  1049. });
  1050. },
  1051. success(msg) {
  1052. this.$notify({
  1053. type: "success",
  1054. message: msg,
  1055. });
  1056. },
  1057. handleClose(done) {
  1058. done();
  1059. // this.$confirm("确认关闭?")
  1060. // .then(() => {
  1061. // done();
  1062. // })
  1063. // .catch(() => {});
  1064. },
  1065. },
  1066. };
  1067. </script>
  1068. <style scoped>
  1069. .input {
  1070. width: 400px;
  1071. }
  1072. .ckeditor-readOnly {
  1073. width: 650px;
  1074. height: 270px;
  1075. border-width: 1px;
  1076. border-style: solid;
  1077. border-color: rgb(211, 213, 218);
  1078. padding: 5px;
  1079. margin-bottom: 10px;
  1080. word-wrap: break-word;
  1081. word-break: break-all;
  1082. }
  1083. .div-ckeditor-readOnly {
  1084. width: 655px;
  1085. height: 275px;
  1086. overflow-x: auto;
  1087. overflow-y: auto;
  1088. }
  1089. </style>