notice.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="pb_content" style="background: unset">
  3. <div
  4. class="pb_content_body"
  5. style="
  6. background: #fff;
  7. padding: 0px 25px;
  8. box-sizing: border-box;
  9. border-radius: 5px;
  10. "
  11. >
  12. <div class="pb_head">
  13. <span>通知公告</span>
  14. </div>
  15. </div>
  16. <div class="pb_content_body">
  17. <div class="student_table">
  18. <el-table
  19. ref="table"
  20. :data="tableData"
  21. border
  22. :height="tableHeight"
  23. :fit="true"
  24. style="width: 100%"
  25. :header-cell-style="{ background: '#f1f1f1' }"
  26. :row-class-name="tableRowClassName"
  27. v-loading="loading"
  28. >
  29. <el-table-column
  30. prop="content"
  31. label="通知内容"
  32. min-width="35"
  33. align="center"
  34. :show-overflow-tooltip="true"
  35. >
  36. <template slot-scope="scope"
  37. ><div v-html="snippet(scope.row.content)"></div
  38. ></template>
  39. </el-table-column>
  40. <!-- <el-table-column
  41. prop="creater"
  42. label="创建者"
  43. min-width="15"
  44. align="center"
  45. ><template slot-scope="scope">
  46. {{ scope.row.creater ? scope.row.creater : "未知" }}
  47. </template>
  48. </el-table-column> -->
  49. <el-table-column
  50. prop="creatMen"
  51. label="创建者"
  52. min-width="25"
  53. align="center"
  54. >
  55. 管理员
  56. </el-table-column>
  57. <el-table-column
  58. prop="creatTime"
  59. label="创建时间"
  60. min-width="25"
  61. align="center"
  62. >
  63. </el-table-column>
  64. <el-table-column label="操作" min-width="20">
  65. <template slot-scope="scope">
  66. <el-button
  67. type="primary"
  68. size="small"
  69. @click="getNewDetail(scope.row.newsid)"
  70. >查看通知</el-button
  71. >
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </div>
  76. <div class="student_page">
  77. <el-pagination
  78. background
  79. layout="prev, pager, next"
  80. :page-size="10"
  81. :total="total"
  82. v-if="page"
  83. @current-change="handleCurrentChange"
  84. >
  85. </el-pagination>
  86. </div>
  87. </div>
  88. <el-dialog
  89. title="查看通知"
  90. :visible.sync="dialogVisible"
  91. :append-to-body="true"
  92. width="50%"
  93. :before-close="handleClose"
  94. class="look_notice"
  95. >
  96. <div slot="title" class="header-title">
  97. <div class="logoImg">
  98. <img src="../../assets/logo.png" alt="" />
  99. </div>
  100. <div class="title_add_student">查看通知</div>
  101. </div>
  102. <div>
  103. <div class="pb_head">
  104. <span style="font-size: 20px">{{ res.title }}</span>
  105. <span style="font-size: 15px; line-height: 35px">管理员</span>
  106. </div>
  107. <div class="notice_content cont" v-html="res.newscontent"></div>
  108. </div>
  109. <span slot="footer" class="dialog-footer">
  110. <el-button class="close" @click="dialogVisible = false" type="primary"
  111. >关闭</el-button
  112. >
  113. </span>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. export default {
  119. data() {
  120. return {
  121. tableHeight: "500px",
  122. page: 1,
  123. total: 0,
  124. isLoading: false,
  125. formLabelWidth: "100px",
  126. dialogVisible: false,
  127. title: "",
  128. tableData: [],
  129. res: [],
  130. userid: this.$route.query.userid,
  131. };
  132. },
  133. mounted() {
  134. this.$nextTick(function () {
  135. this.tableHeight =
  136. window.innerHeight - this.$refs.table.$el.offsetTop - 200;
  137. if (this.tableHeight <= 530) {
  138. this.tableHeight = 530;
  139. }
  140. // 监听窗口大小变化
  141. let self = this;
  142. window.onresize = function () {
  143. self.tableHeight =
  144. window.innerHeight - self.$refs.table.$el.offsetTop - 200;
  145. if (self.tableHeight <= 530) {
  146. self.tableHeight = 530;
  147. }
  148. };
  149. });
  150. },
  151. methods: {
  152. tableRowClassName({ row, rowIndex }) {
  153. if ((rowIndex + 1) % 2 === 0) {
  154. return "even_row";
  155. } else {
  156. return "";
  157. }
  158. },
  159. snippet(value) {
  160. return value.replace(/<[^>]*>/g, "");
  161. },
  162. tableRowClassName({ row, rowIndex }) {
  163. if ((rowIndex + 1) % 2 === 0) {
  164. return "even_row";
  165. } else {
  166. return "";
  167. }
  168. },
  169. handleCurrentChange(val) {
  170. this.page = val;
  171. this.getNews();
  172. },
  173. handleClose(done) {
  174. done();
  175. },
  176. getNewDetail(id) {
  177. this.dialogVisible = true;
  178. let params = { nid: id };
  179. this.ajax
  180. .get(this.$store.state.api + "selectNewDetail", params)
  181. .then((res) => {
  182. this.dialogVisible = true;
  183. this.res = res.data[0][0];
  184. })
  185. .catch((err) => {
  186. this.loading = false;
  187. });
  188. },
  189. getNews() {
  190. this.loading = true;
  191. let params = { uid: this.userid, page: this.page };
  192. this.ajax
  193. .get(this.$store.state.api + "getNewsTeacher", params)
  194. .then((res) => {
  195. this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  196. this.loading = false;
  197. this.tableData = res.data[0];
  198. })
  199. .catch((err) => {
  200. this.loading = false;
  201. });
  202. },
  203. },
  204. created() {
  205. this.getNews();
  206. },
  207. };
  208. </script>
  209. <style scoped>
  210. .pb_head {
  211. display: flex;
  212. justify-content: space-between;
  213. }
  214. .student_head {
  215. margin-bottom: 20px;
  216. }
  217. .student_search {
  218. display: flex;
  219. }
  220. .student_search > div:nth-child(1) {
  221. line-height: 35px;
  222. font-size: 14px;
  223. }
  224. .student_search >>> .el-input__inner {
  225. width: 190px;
  226. height: 35px;
  227. margin-left: 10px;
  228. }
  229. .student_table >>> .el-table--border td {
  230. border-right: 0px !important;
  231. }
  232. .header-title {
  233. display: flex;
  234. }
  235. .logoImg {
  236. width: 30px;
  237. }
  238. .logoImg > img {
  239. width: 100%;
  240. height: 100%;
  241. }
  242. .title_add_student {
  243. margin: 0 auto;
  244. color: #fff;
  245. }
  246. .look_notice >>> .el-dialog__header {
  247. padding: 20px 20px 10px;
  248. text-align: center;
  249. background: #32455b;
  250. }
  251. .look_notice >>> .el-dialog__title {
  252. font-size: 14px !important;
  253. color: #fff !important;
  254. }
  255. .look_notice >>> .el-dialog__headerbtn {
  256. font-size: 20px !important;
  257. }
  258. .look_notice >>> .el-form-item__label {
  259. margin-left: 65px;
  260. }
  261. .look_notice >>> .el-form-item {
  262. display: flex;
  263. }
  264. .look_notice >>> .el-form-item__content {
  265. margin: 0 !important;
  266. }
  267. .look_notice >>> .el-dialog__footer {
  268. text-align: center !important;
  269. }
  270. .look_notice >>> .el-dialog {
  271. min-width: 450px;
  272. }
  273. .notice_content {
  274. width: 100%;
  275. word-wrap: break-word;
  276. word-break: break-all;
  277. overflow: hidden;
  278. font-size: 18px;
  279. line-height: 35px;
  280. text-indent: 35px;
  281. min-width: 385px;
  282. }
  283. .close {
  284. width: 320px;
  285. height: 30px;
  286. line-height: 30px;
  287. font-size: 14px;
  288. background: #0e72e6;
  289. padding: 0 !important;
  290. }
  291. /* table 样式 */
  292. .cont >>> table {
  293. border-top: 1px solid #ccc;
  294. border-left: 1px solid #ccc;
  295. }
  296. .cont >>> table td,
  297. .cont >>> table th {
  298. border-bottom: 1px solid #ccc;
  299. border-right: 1px solid #ccc;
  300. padding: 3px 5px;
  301. }
  302. .cont >>> table th {
  303. border-bottom: 2px solid #ccc;
  304. text-align: center;
  305. }
  306. /* blockquote 样式 */
  307. .cont >>> blockquote {
  308. display: block;
  309. border-left: 8px solid #d0e5f2;
  310. padding: 5px 10px;
  311. margin: 10px 0;
  312. line-height: 1.4;
  313. font-size: 100%;
  314. background-color: #f1f1f1;
  315. }
  316. /* code 样式 */
  317. .cont >>> code {
  318. display: inline-block;
  319. *display: inline;
  320. *zoom: 1;
  321. background-color: #f1f1f1;
  322. border-radius: 3px;
  323. padding: 3px 5px;
  324. margin: 0 3px;
  325. }
  326. .cont >>> pre code {
  327. display: block;
  328. }
  329. /* ul ol 样式 */
  330. .cont >>> ul,
  331. ol {
  332. margin: 10px 0 10px 20px;
  333. }
  334. .el-table >>> .even_row {
  335. background-color: #f1f1f1;
  336. }
  337. .student_page {
  338. margin-top: 10px;
  339. }
  340. .pb_head {
  341. margin: 0 !important;
  342. width: 100% !important;
  343. }
  344. .student_table >>> .el-table,.student_table >>> .el-table__body-wrapper{
  345. height: auto !important;
  346. }
  347. </style>