messageNotification.vue 14 KB

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