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