index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div id="stationLetter">
  3. <div style="margin-bottom: 10px">
  4. <p>
  5. 共{{ total }}封,其中<span style="color: red">{{ dontRead }}</span>
  6. 个消息未读
  7. </p>
  8. <div>
  9. <el-button size="mini" type="primary" plain @click="haveRead"
  10. >标记为已读</el-button
  11. ><el-button v-if="false" size="mini" type="primary" plain @click="notHaveRead"
  12. >标记为未读</el-button
  13. ><span style="font-size: 14px; margin-left: 10px">状态:</span
  14. ><el-select
  15. size="mini"
  16. v-model="formData.receiptStatus"
  17. placeholder="请选择状态"
  18. @change="changeStatus"
  19. >
  20. <el-option
  21. v-for="item in options"
  22. :key="item.value"
  23. :label="item.label"
  24. :value="item.value"
  25. >
  26. </el-option>
  27. </el-select>
  28. </div>
  29. </div>
  30. <el-table
  31. :data="tableData"
  32. style="width: 100%"
  33. border
  34. row-key="id"
  35. ref="tableData"
  36. >
  37. <el-table-column
  38. type="selection"
  39. width="55"
  40. align="center"
  41. reserve-selection
  42. :selectable="canSelect"
  43. >
  44. </el-table-column>
  45. <template v-for="(item, index) in tableSet">
  46. <el-table-column
  47. :width="item.width"
  48. :key="index"
  49. :label="item.label"
  50. align="center"
  51. :sortable="item.prop === 'sort'"
  52. :show-overflow-tooltip="true"
  53. header-align="center"
  54. :prop="item.prop"
  55. sort-by="sort"
  56. >
  57. <template slot-scope="scope">
  58. <i
  59. v-if="item.scope === 'icon'"
  60. :style="
  61. scope.row[item.prop] === 0
  62. ? 'color:#409EFF;'
  63. : scope.row[item.prop] === 1
  64. ? 'color:#eee;'
  65. : ''
  66. "
  67. style="font-size: 18px"
  68. class="el-icon-s-comment"
  69. ></i>
  70. <span v-else-if="item.scope === 'theme'">
  71. <strong style="margin-left: 10px">{{
  72. scope.row[item.prop1]
  73. }}</strong
  74. ><span>{{ scope.row[item.prop2] }}</span>
  75. </span>
  76. <span v-else-if="item.scope === 'aTimeList'">{{
  77. $methodsTools.onlyForma(scope.row[item.prop])
  78. }}</span>
  79. <span v-else>{{ scope.row[item.prop] }}</span></template
  80. ></el-table-column
  81. ></template
  82. ><el-table-column label="操作" align="center" fixed="right" width="180px">
  83. <template slot-scope="scope">
  84. <el-button size="mini" @click="newSee(scope.row)" type="text"
  85. >立即查看</el-button
  86. ><el-button
  87. size="mini"
  88. :disabled="scope.row.receiptStatus === 1"
  89. @click="haveReadID(scope.row.id)"
  90. type="text"
  91. >标记为已读</el-button
  92. >
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <pagination
  97. :total="total"
  98. :pageSize="formData.pageSize"
  99. :currentPage="formData.pageNum"
  100. @handleSizeChange="handleSizeChange"
  101. @handleCurrentChange="handleCurrentChange"
  102. />
  103. <el-dialog
  104. :visible.sync="dialogCG"
  105. width="760px"
  106. :show-close="false"
  107. :close-on-click-modal="false"
  108. >
  109. <div slot="title" class="hearders">
  110. <div class="leftTitle">查看消息</div>
  111. <div class="rightBoxs">
  112. <img
  113. src="@/assets/images/Close@2x.png"
  114. alt=""
  115. @click="dialogCG = false"
  116. />
  117. </div>
  118. </div>
  119. <h3 style="color: #333; font-weight: bold">{{ newData.remind }}</h3>
  120. <p>{{ newData.text }}</p>
  121. <span slot="footer" class="dialog-footer">
  122. <el-button @click="dialogCG = false">关闭</el-button>
  123. <el-button type="primary" @click="submitChecks">查看学员</el-button>
  124. </span>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import pagination from "@/components/pagination";
  130. export default {
  131. name: "StationLetter",
  132. components: { pagination },
  133. data() {
  134. return {
  135. newData: {}, //当前数据
  136. options: [
  137. {
  138. label: "全部",
  139. value: "",
  140. },
  141. {
  142. label: "已读",
  143. value: 1,
  144. },
  145. {
  146. label: "未读",
  147. value: 0,
  148. },
  149. ],
  150. total: 0,
  151. dontRead: 0, //未读
  152. formData: {
  153. pageSize: 10,
  154. pageNum: 1,
  155. receiptStatus: "",
  156. systemStatus: 1,
  157. },
  158. tableSet: [
  159. {
  160. label: "状态",
  161. prop: "receiptStatus",
  162. scope: "icon",
  163. width: "80px",
  164. },
  165. {
  166. label: "主题",
  167. prop1: "remind",
  168. prop2: "text",
  169. scope: "theme",
  170. },
  171. {
  172. label: "发送时间",
  173. prop: "sendTime",
  174. scope: "aTimeList",
  175. width: "220px",
  176. },
  177. ],
  178. tableData: [],
  179. loading: false,
  180. dialogCG: false,
  181. };
  182. },
  183. mounted() {
  184. this.search();
  185. if (this.$route.params.id) {
  186. this.$api.informsys_user(this.$route.params.id).then((res) => {
  187. if (res.data) {
  188. this.newSee(res.data);
  189. }
  190. });
  191. }
  192. },
  193. methods: {
  194. /**
  195. * 查看消息
  196. */
  197. newSee(data) {
  198. this.newData = JSON.parse(JSON.stringify(data));
  199. this.dialogCG = true;
  200. if (data.receiptStatus !== 1) {
  201. this.haveReadID(data.id, false);
  202. }
  203. },
  204. /**
  205. * 单个标记已读
  206. */
  207. haveReadID(id, status = true) {
  208. this.$api
  209. .editupdateReadStatusBatch({ ids: [id], receiptStatus: 1 })
  210. .then((res) => {
  211. if (status) {
  212. this.$message.success("已读成功");
  213. this.$refs.tableData.clearSelection();
  214. }
  215. this.search();
  216. });
  217. },
  218. /**
  219. * 切换消息状态
  220. */
  221. changeStatus(val) {
  222. this.formData.pageSize = 10;
  223. this.formData.pageNum = 1;
  224. this.search();
  225. },
  226. search() {
  227. this.loading = true;
  228. this.$api
  229. .inquireinformsys_userlist(this.formData)
  230. .then((res) => {
  231. this.total = res.total;
  232. this.tableData = res.rows;
  233. })
  234. .finally(() => {
  235. this.loading = false;
  236. });
  237. this.$api
  238. .inquireinformsys_userinformUnReadSum({ systemStatus: 1 })
  239. .then((res) => {
  240. this.dontRead = res.data;
  241. });
  242. },
  243. /**
  244. * 查看学员
  245. */
  246. submitChecks() {
  247. this.dialogCG = false;
  248. const jump = () => {
  249. //学员详情
  250. this.$router.push({
  251. name: "StudentXQ",
  252. query: {
  253. id: this.newData.studentUserId,
  254. },
  255. });
  256. };
  257. const statusPage = this.$store.state.tagsView.visitedViews.some(
  258. (item) => {
  259. return item.name == "StudentXQ";
  260. }
  261. );
  262. if (statusPage) {
  263. this.$store
  264. .dispatch("tagsView/delCachedView", {
  265. name: "StudentXQ",
  266. })
  267. .then((res) => {
  268. jump();
  269. });
  270. } else {
  271. jump();
  272. }
  273. },
  274. /**
  275. * 已读
  276. */
  277. haveRead() {
  278. const idList = this.$refs.tableData.selection.map((item) => {
  279. return item.id;
  280. });
  281. if (idList.length == 0) {
  282. this.$message.warning("请选择需要标记已读的数据");
  283. return;
  284. }
  285. this.$api
  286. .editupdateReadStatusBatch({ ids: idList, receiptStatus: 1 })
  287. .then((res) => {
  288. this.$message.success("已读成功");
  289. this.$refs.tableData.clearSelection();
  290. this.search();
  291. });
  292. console.log(idList);
  293. },
  294. notHaveRead() {
  295. const idList = this.$refs.tableData.selection.map((item) => {
  296. return item.id;
  297. });
  298. if (idList.length == 0) {
  299. this.$message.warning("请选择需要标记已读的数据");
  300. return;
  301. }
  302. this.$api
  303. .editupdateReadStatusBatch({ ids: idList, receiptStatus: 0 })
  304. .then((res) => {
  305. this.$message.success("未读成功");
  306. this.$refs.tableData.clearSelection();
  307. this.search();
  308. });
  309. console.log(idList);
  310. },
  311. handleSizeChange(v) {
  312. this.formData.pageSize = v;
  313. this.formData.pageNum = 1;
  314. this.search();
  315. },
  316. handleCurrentChange(v) {
  317. this.formData.pageNum = v;
  318. this.search();
  319. },
  320. canSelect(row, index) {
  321. if (row.receiptStatus === 0) {
  322. return true;
  323. } else {
  324. return false;
  325. }
  326. },
  327. },
  328. };
  329. </script>
  330. <style lang="less" scoped>
  331. /deep/.el-button {
  332. border-radius: 8px;
  333. }
  334. /deep/.el-dialog {
  335. border-radius: 8px;
  336. .el-dialog__header {
  337. padding: 0;
  338. .hearders {
  339. height: 40px;
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. padding: 0px 18px 0px 20px;
  344. border-bottom: 1px solid #e2e2e2;
  345. .leftTitle {
  346. font-size: 14px;
  347. font-weight: bold;
  348. color: #2f4378;
  349. }
  350. .rightBoxs {
  351. display: flex;
  352. align-items: center;
  353. img {
  354. width: 14px;
  355. height: 14px;
  356. margin-left: 13px;
  357. cursor: pointer;
  358. }
  359. }
  360. }
  361. }
  362. .el-dialog__body {
  363. max-height: 500px;
  364. overflow: auto;
  365. }
  366. .el-dialog__footer {
  367. padding: 0;
  368. .dialog-footer {
  369. padding: 0px 40px;
  370. height: 70px;
  371. border-top: 1px solid #e2e2e2;
  372. display: flex;
  373. align-items: center;
  374. justify-content: flex-end;
  375. }
  376. }
  377. }
  378. .imgBox {
  379. width: 100%;
  380. // height: 210px;
  381. border: 1px solid #e2e2e2;
  382. border-radius: 8px;
  383. padding: 8px 8px 3px;
  384. display: flex;
  385. flex-direction: column;
  386. align-items: center;
  387. .imgLabel {
  388. flex: 1;
  389. width: 100%;
  390. border: 1px dotted #e2e2e2;
  391. color: #999;
  392. font-size: 14px;
  393. cursor: pointer;
  394. border-radius: 8px;
  395. .msPhoto {
  396. display: flex;
  397. justify-content: center;
  398. align-items: center;
  399. max-width: 100%;
  400. max-height: 270px;
  401. img {
  402. max-width: 100%;
  403. max-height: 270px;
  404. }
  405. }
  406. .imgbbx {
  407. display: flex;
  408. flex-direction: column;
  409. align-items: center;
  410. justify-content: center;
  411. width: 100%;
  412. height: 100%;
  413. i {
  414. font-weight: bold;
  415. margin: 14px 0;
  416. font-size: 24px;
  417. }
  418. }
  419. }
  420. p {
  421. margin: 5px 0px;
  422. }
  423. }
  424. </style>