messageNotification.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <!-- 消息通知 -->
  3. <div class="messageNotification">
  4. <div class="pAHeader">
  5. <div class="pAHeader1">消息通知</div>
  6. </div>
  7. <hr>
  8. <div class="twoSelectInp">
  9. <div class="selectTwo">
  10. <div class="selectsBlock">
  11. <el-input v-model="selectInput" style="width:200px" placeholder="请输入"></el-input>
  12. <el-button type="primary" class="btn2" @click="getCourseManagement">查询</el-button>
  13. </div>
  14. </div>
  15. <el-button type="primary" class="btn" @click="addMessage" size="mini">新建全站通知</el-button>
  16. </div>
  17. <!-- 通知表格开始 -->
  18. <div class="projectBlock">
  19. <el-table
  20. :data="tableData"
  21. tooltip-effect="dark"
  22. stripe
  23. class="fontSize"
  24. :header-cell-style="{ background: '#f2f2f2',color:'#000' }"
  25. >
  26. <el-table-column
  27. prop="title"
  28. label="通知内容"
  29. align="center"
  30. min-width="25%">
  31. </el-table-column>
  32. <el-table-column
  33. prop="tname"
  34. label="创建者"
  35. align="center"
  36. min-width="20%">
  37. </el-table-column>
  38. <el-table-column
  39. prop="create_at"
  40. label="创建时间"
  41. align="center"
  42. min-width="25%">
  43. </el-table-column>
  44. <el-table-column
  45. prop="operation"
  46. label="操作"
  47. align="center"
  48. min-width="30%"
  49. >
  50. <template #default="scope">
  51. <div class="operations">
  52. <!-- <el-button type="primary" > -->
  53. <el-button type="primary" size="mini" @click="lookIntro(scope.row.newId)">查看信息</el-button>
  54. <el-button type="primary" size="mini" @click="del(scope.row.newId)" >删除</el-button>
  55. <!-- </el-button> -->
  56. </div>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </div>
  61. <!-- 通知表格结束-->
  62. <!-- 分页 -->
  63. <el-pagination
  64. @current-change="handleCurrentChange"
  65. :current-page="table.currentPage"
  66. :page-size="table.packageSize"
  67. layout=" prev, pager, next"
  68. background
  69. class="paginations"
  70. :total="table.total">
  71. </el-pagination>
  72. <!-- 分页结束 -->
  73. <!-- 添加全站通知开始 -->
  74. <el-dialog
  75. title="添加全站通知"
  76. :visible.sync="dialogVisible"
  77. width="600px"
  78. class="addDialog">
  79. <div class="addDialogLogo">LOGO</div>
  80. <div class="addDialogMid">
  81. <div class="addDialogTit">
  82. <span>通知标题</span>
  83. <el-input v-model="addMess.tit" placeholder="请输入内容"></el-input>
  84. </div>
  85. <div class="addDialogTit addDialogCon">
  86. <span style="position: relative;top: -8px;">通知内容</span>
  87. <el-input
  88. type="textarea"
  89. :rows="10"
  90. resize="none"
  91. placeholder="请输入内容"
  92. v-model="addMess.con">
  93. </el-input>
  94. </div>
  95. </div>
  96. <span slot="footer" class="dialog-footer">
  97. <el-button type="primary" @click="confirmAdd" >确认添加</el-button>
  98. <el-button @click="init" >取 消</el-button>
  99. </span>
  100. </el-dialog>
  101. <!-- 添加全站通知结束-->
  102. <!-- 删除通知开始 -->
  103. <el-dialog
  104. title="删除通知"
  105. :visible.sync="dialogVisible1"
  106. width="600px"
  107. class="delDialog">
  108. <div class="addDialogLogo">LOGO</div>
  109. <span class="deleteContent">确定删除通知?</span>
  110. <span slot="footer" class="dialog-footer">
  111. <el-button type="primary" @click="confirmDel" >确认删除</el-button>
  112. <el-button @click="dialogVisible1=false" >取消</el-button>
  113. </span>
  114. </el-dialog>
  115. <!-- 删除通知结束-->
  116. <!-- 查看通知开始 -->
  117. <el-dialog
  118. title="查看通知"
  119. :visible.sync="dialogVisible2"
  120. width="600px"
  121. class="addDialog">
  122. <div class="addDialogLogo">LOGO</div>
  123. <div class="addDialogMid">
  124. <div class="addDialogTit1">
  125. <div style="font-size:18px;color:#000">{{ messageCon.title }}</div>
  126. <div style="margin-top: 13px;font-size: 14px;">{{ messageCon.tname }}</div>
  127. </div>
  128. <hr>
  129. <div class="addDialogTit2">
  130. {{ messageCon.brief }}
  131. </div>
  132. </div>
  133. <span slot="footer" class="dialog-footer">
  134. <el-button type="primary" @click="dialogVisible2=false" class="btn5">关闭</el-button>
  135. </span>
  136. </el-dialog>
  137. <!-- 查看通知结束 -->
  138. </div>
  139. </template>
  140. <script>
  141. export default {
  142. data() {
  143. return {
  144. textarea:'',
  145. //查询框
  146. selectInput:"",
  147. dialogVisible:false,
  148. dialogVisible1:false,
  149. dialogVisible2:false,
  150. input:'',
  151. infromId:'',
  152. //列表数据
  153. tableData:[],
  154. // 分页数据
  155. table:{
  156. total:0,
  157. packageSize:9,
  158. currentPage:1
  159. },
  160. messageCon:{},
  161. // 添加数据
  162. addMess:{
  163. tit:'',
  164. con:''
  165. }
  166. }
  167. },
  168. methods:{
  169. del(val){
  170. this.infromId=val
  171. this.dialogVisible1=true;
  172. },
  173. confirmDel(){ //删除内容
  174. let param={
  175. uid:this.$store.state.userInfo.userid,
  176. nid:this.infromId
  177. }
  178. this.ajax
  179. .post(this.$store.state.api+"/DeleteNotification",param)
  180. .then(res=>{
  181. // console.log(res);
  182. this.getCourseManagement()
  183. this.dialogVisible1=false;
  184. if (res.data) {
  185. this.$message.success('删除成功')
  186. }else{
  187. this.$message.error('删除失败')
  188. }
  189. },err=>{
  190. console.log(err);
  191. })
  192. },
  193. init(){
  194. //重置
  195. // if(this.textarea==''||this.input=='')return;
  196. // const date = new Date();
  197. // let data = {
  198. // projectName:this.input,
  199. // date:`${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`,
  200. // founder:"覃罡彤",
  201. // }
  202. // this.tableData.push(data);
  203. this.dialogVisible=false;
  204. this.dialogVisible1=false;
  205. this.dialogVisible2=false;
  206. },
  207. addMessage(){
  208. this.dialogVisible=true;
  209. },
  210. confirmAdd(){ //新建全站通知发送数据
  211. if(this.addMess.tit =='' || this.addMess.con ==''){
  212. this.$message.error('请输入内容')
  213. return
  214. }
  215. let param ={
  216. uid:this.$store.state.userInfo.userid,
  217. title:this.addMess.tit,
  218. brief:this.addMess.con,
  219. }
  220. // console.log(param)
  221. this.ajax
  222. .post(this.$store.state.api+"/CreateNewNotification",param)
  223. .then(res=>{
  224. // console.log(res);
  225. this.dialogVisible=false;
  226. this.addMess.tit='';
  227. this.addMess.con='';
  228. this.getCourseManagement();
  229. if (res.data) {
  230. this.$message.success('创建成功')
  231. }else{
  232. this.$message.error('创建失败')
  233. }
  234. },err=>{
  235. console.log(err);
  236. })
  237. },
  238. lookIntro(val){ //查看信息通知
  239. console.log(val);
  240. let param={
  241. uid:this.$store.state.userInfo.userid,
  242. nid:val
  243. }
  244. this.ajax
  245. .get(this.$store.state.api+'/SelectNotificationDetail',param)
  246. .then(res=>{
  247. console.log(res)
  248. this.messageCon=res.data[0][0]
  249. // console.log(res);
  250. },err=>{
  251. console.log(err);
  252. })
  253. this.dialogVisible2=true;
  254. },
  255. getCourseManagement(){ //分页获取数据请求
  256. // if(this.value==1){
  257. // this.value=''
  258. // }
  259. let currentPage=this.table.currentPage;
  260. const param={
  261. uid:this.$store.state.userInfo.userid,
  262. title:this.selectInput,
  263. nowPage:currentPage,
  264. lim:9
  265. }
  266. this.ajax
  267. .get(this.$store.state.api+'/SelectNotification',param)
  268. .then(res=>{
  269. // 不是在第一页进行分页请求,请求数据为空,再发送一次请求获取数据,判断是否为第一页,防止无限循环
  270. // console.log(res)
  271. if(this.table.currentPage!==1 && res.data[0].length==0){
  272. this.table.currentPage=1
  273. this.getCourseManagement();
  274. }
  275. this.tableData=res.data[0];
  276. this.table.total=res.data[1][0].total;
  277. },err=>{
  278. console.log(err);
  279. })
  280. },
  281. // 分页
  282. handleCurrentChange(val) { //当页数发生改变的时候调用获取列表数据请求
  283. // console.log(`当前页: ${val}`);
  284. this.table.currentPage=val
  285. this.getCourseManagement()
  286. },
  287. },
  288. watch:{
  289. selectInput:{
  290. handler(){
  291. immediate:true
  292. deep:true
  293. this.getCourseManagement()
  294. },
  295. },
  296. },
  297. mounted(){
  298. this.getCourseManagement()
  299. }
  300. }
  301. </script>
  302. <style lang="less">
  303. .messageNotification{
  304. .pagination{
  305. float: right;
  306. margin: 20px 35px 10px;
  307. }
  308. .el-dialog{
  309. border-radius:5px;
  310. overflow: hidden;
  311. }
  312. .btn{
  313. height: 35px;
  314. width: 125px;
  315. background: #477edd;
  316. font-size: 16px;
  317. }
  318. .delDialog{
  319. font-size: 18px;
  320. .el-dialog{
  321. border-radius: 5px;
  322. overflow: hidden;
  323. }
  324. .deleteContent{
  325. margin: 30px 0;
  326. font-size: 22px;
  327. color: #000;
  328. }
  329. .el-dialog__body{
  330. display: flex;
  331. justify-content: center;
  332. }
  333. .addDialogLogo{
  334. width: 60px;
  335. height: 30px;
  336. border-radius: 5px;
  337. display: flex;
  338. justify-content: center;
  339. line-height: 30px;
  340. background: #f2f2f2;
  341. position: absolute;
  342. left: 20px; top: 15px;
  343. }
  344. .el-dialog__header{
  345. background: #32455b;
  346. }
  347. .el-dialog__title{
  348. color:#fff;
  349. display: flex;
  350. justify-content: center;
  351. font-size: 18px;
  352. position: relative;
  353. top: -2px;
  354. }
  355. .addDialogMid{
  356. box-sizing: border-box;
  357. padding:0 60px 0 10px;
  358. .addDialogTit{
  359. display: flex;
  360. span{
  361. width: 80px;
  362. font-size: 16px;
  363. line-height: 40px;
  364. text-align: left;
  365. }
  366. }
  367. .addDialogTit1{
  368. display: flex;
  369. justify-content: space-between;
  370. margin-bottom: 15px;
  371. }
  372. .addDialogTit2{
  373. margin-top: 10px;
  374. font-size: 16px;
  375. color: #000;
  376. text-indent: 2em;
  377. text-align: left;
  378. line-height: 1.7em;
  379. }
  380. .addDialogCon{
  381. margin-top: 20px;
  382. }
  383. }
  384. }
  385. .addDialog{
  386. font-size: 18px;
  387. .el-dialog{
  388. border-radius: 5px;
  389. overflow: hidden;
  390. }
  391. .deleteContent{
  392. margin: 30px 0;
  393. font-size: 22px;
  394. color: #000;
  395. }
  396. .addDialogLogo{
  397. width: 60px;
  398. height: 30px;
  399. display: flex;
  400. justify-content: center;
  401. line-height: 30px;
  402. border-radius: 5px;
  403. background: #f2f2f2;
  404. position: absolute;
  405. left: 20px; top: 15px;
  406. }
  407. .el-dialog__header{
  408. background: #32455b;
  409. }
  410. .el-dialog__title{
  411. color:#fff;
  412. display: flex;
  413. justify-content: center;
  414. font-size: 18px;
  415. position: relative;
  416. top: -2px;
  417. }
  418. .addDialogMid{
  419. box-sizing: border-box;
  420. padding:0 30px 0 10px;
  421. .addDialogTit{
  422. display: flex;
  423. justify-content: center;
  424. span{
  425. width: 90px;
  426. font-size: 16px;
  427. line-height: 40px;
  428. text-align: left;
  429. }
  430. }
  431. .addDialogTit1{
  432. display: flex;
  433. justify-content: space-between;
  434. margin-bottom: 15px;
  435. }
  436. .addDialogTit2{
  437. margin-top: 10px;
  438. font-size: 16px;
  439. color: #000;
  440. text-indent: 2em;
  441. text-align: left;
  442. line-height: 1.7em;
  443. }
  444. .addDialogCon{
  445. margin-top: 20px;
  446. }
  447. }
  448. }
  449. .dialog-footer{ //对话框按钮
  450. display: flex;
  451. justify-content: center;
  452. box-sizing: border-box;
  453. .btn5{
  454. width: 300px;
  455. font-size: 16px;
  456. }
  457. }
  458. }
  459. </style>