notice.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <style>
  2. .table-body {
  3. padding: 20px;
  4. background-color: #fff;
  5. }
  6. .input-item {
  7. display: inline-block;
  8. width: 250px;
  9. margin: 0 0 20px;
  10. }
  11. .input-item .el-input__inner {
  12. border-right: 0;
  13. }
  14. .input-item .el-input__inner:hover {
  15. border: 1px solid #dcdfe6;
  16. border-right: 0;
  17. outline: 0;
  18. }
  19. .input-item .el-input__inner:focus {
  20. border: 1px solid #dcdfe6;
  21. border-right: 0;
  22. outline: 0;
  23. }
  24. .input-item .el-input-group__append {
  25. background-color: #fff;
  26. border-left: 0;
  27. width: 10%;
  28. padding: 0;
  29. }
  30. .input-item .el-input-group__append .el-button {
  31. padding: 0;
  32. }
  33. .input-item .el-input-group__append .el-button {
  34. margin: 0;
  35. }
  36. .table-body .el-button {
  37. padding: 0 !important;
  38. border: 0;
  39. margin: 0 5px;
  40. }
  41. .el-table th > .cell {
  42. color: #333;
  43. font-weight: bold;
  44. font-size: 14px;
  45. }
  46. .el-table__footer-wrapper, .el-table__header-wrapper {
  47. border-bottom: 1.4px solid #D6D6D6;
  48. }
  49. .el-button--primary2 {
  50. color: #FFF;
  51. background-color: #03C5FF;
  52. border-color: #03C5FF;
  53. }
  54. </style>
  55. <div id="app" v-cloak>
  56. <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  57. <div slot="header">
  58. <div>
  59. <span>系统通知</span>
  60. </div>
  61. </template>
  62. </div>
  63. <div class="table-body">
  64. <el-button class="el-button--primary2" style="padding: 9px 15px!important; float: right;" type="primary"
  65. @click="addgsForm()" size="small">新增
  66. </el-button>
  67. <div class="input-item" style="float: left;">
  68. <el-input @keyup.enter.native="search" size="small"
  69. placeholder="搜索系统通知"
  70. v-model="keyword"
  71. clearable
  72. @clear="search">
  73. <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
  74. </el-input>
  75. </div>
  76. <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
  77. <el-table-column prop="id" label="ID" min-width="80" align="center"></el-table-column>
  78. <el-table-column
  79. label="系统通知内容"
  80. min-width="150"
  81. align="center">
  82. <template slot-scope="scope">
  83. <com-ellipsis :line="2">{{scope.row.content}}</com-ellipsis>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="scope" width="180" label="创建时间">
  87. <template slot-scope="scope">
  88. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="scope" width="180" label="修改时间">
  92. <template slot-scope="scope">
  93. {{scope.row.updated_at|dateTimeFormat('Y-m-d H:i:s')}}
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. label="操作"
  98. min-width="180"
  99. align="center">
  100. <template slot-scope="scope">
  101. <el-button circle size="mini" type="text" @click="getEdit(scope.row)">
  102. 编辑
  103. </el-button>
  104. <el-button circle size="mini" type="text" @click="delNotice(scope.row)">
  105. 删除
  106. </el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <div style="text-align: right;margin: 20px 0;">
  111. <el-pagination v-if="pagination" :page-size="pagination.pageSize"
  112. style="display: inline-block;float: right;" background @current-change="pageChange"
  113. layout="prev, pager, next" :total="pagination.total_count">
  114. </el-pagination>
  115. </div>
  116. </div>
  117. <!--弹框添加分类开始-->
  118. <el-dialog :title="title" width="30%" :visible.sync="dialogAddgsVisible"
  119. :modal-append-to-body="false">
  120. <el-form :model="addForm" ref="addForm" :rules="addRule" >
  121. <el-form-item label="系统通知" prop="content">
  122. <el-input type="textarea" v-model="addForm.content" @input="sortChange" placeholder="请填写系统通知"></el-input>
  123. </el-form-item>
  124. </el-form>
  125. <span slot="footer" class="dialog-footer">
  126. <el-button @click="dialogAddgsVisible = false">取 消</el-button>
  127. <el-button type="primary" :loading="btnLoading" @click="handle('edit','addForm')">确 定</el-button>
  128. </span>
  129. </el-dialog>
  130. <!--弹框添加分类结束-->
  131. </el-card>
  132. </div>
  133. <script>
  134. const app = new Vue({
  135. el: '#app',
  136. data() {
  137. var validatePass = (rule, value, callback) => {
  138. var reg = /^[\u4e00-\u9fa5\w]+$/;
  139. if (reg.test(value)) {
  140. callback();
  141. }else{
  142. callback(new Error('规则名不能含有特殊字符'));
  143. }
  144. };
  145. return {
  146. list: [],
  147. id: null,
  148. sort: 0,
  149. keyword: '',
  150. listLoading: false,
  151. btnLoading: false,
  152. pagination:null,
  153. page: 1,
  154. pageCount: 0,
  155. //弹框配置
  156. addForm: {
  157. id:'',
  158. centent : '',
  159. },
  160. addRule: {
  161. content: [
  162. {required: true, message: '请填写系统通知', trigger: 'change'},
  163. {
  164. validator: (rule, value, callback) => {
  165. if(value.length>500){
  166. callback('最大长度在500个字内');
  167. }
  168. callback();
  169. }
  170. },
  171. ],
  172. },
  173. ptypeList: [
  174. {key: "0", value: "成功"},
  175. {key: "1", value: "失败"},
  176. ],
  177. title:'',
  178. dialogAddgsVisible: false,
  179. dataList: [],
  180. // 对话框显示与否
  181. dialogVisible: false,
  182. dataloading: false,
  183. addGroupVisible: false,
  184. };
  185. },
  186. methods: {
  187. sortChange(){
  188. this.$forceUpdate();
  189. },
  190. editSort(row) {
  191. this.id = row.id;
  192. this.sort = row.sort;
  193. },
  194. quit() {
  195. this.id = null;
  196. },
  197. search() {
  198. this.page = 1;
  199. this.getList();
  200. },
  201. pageChange(currentPage) {
  202. let self = this;
  203. self.page = currentPage; //console.log(currentPage,999999);
  204. self.getList();
  205. },
  206. getList() {
  207. let self = this;
  208. self.listLoading = true;
  209. request({
  210. params: {
  211. r: 'admin/setting/notice',
  212. page: self.page,
  213. keyword: this.keyword
  214. },
  215. method: 'get',
  216. }).then(e => {
  217. self.listLoading = false;
  218. self.list = e.data.data.list;
  219. this.pagination = e.data.data.pagination;
  220. this.pagination.pageSize = e.data.data.page_size;
  221. this.pagination.total_count = e.data.data.count;
  222. }).catch(e => {
  223. console.log(e);
  224. });
  225. },
  226. getEdit(data) {
  227. this.dialogAddgsVisible = true;
  228. this.title = "编辑系统通知";
  229. this.addForm.id = data.id;
  230. this.addForm.content = data.content;
  231. },
  232. handle(type,data = null){
  233. this.$refs[data].validate((valid) => {
  234. let self = this;
  235. if (valid) {
  236. if(this.addForm.id){
  237. this.send({content : self.addForm.content,id:this.addForm.id});
  238. }else{
  239. this.send({content : self.addForm.content});
  240. }
  241. } else {
  242. console.log('error submit!!');
  243. return false;
  244. }
  245. });
  246. },
  247. send(data){
  248. let self = this;
  249. self.btnLoading = true;
  250. request({
  251. params: {
  252. r: 'admin/setting/notice-edit',
  253. },
  254. method: 'post',
  255. data:data,
  256. }).then(e => {
  257. this.dialogAddgsVisible = false;
  258. this.btnLoading = false;
  259. if (e.data.code == 0) {
  260. self.$message.success(e.data.msg);
  261. self.getList();
  262. } else {
  263. self.$message.error(e.data.msg);
  264. }
  265. }).catch(e => {
  266. console.log(e);
  267. });
  268. },
  269. delNotice(data){
  270. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  271. let self = this;
  272. self.btnLoading = true;
  273. request({
  274. params: {
  275. r: 'admin/setting/notice-del',
  276. },
  277. method: 'post',
  278. data:{id: data.id,status:-1},
  279. }).then(e => {
  280. this.dialogAddgsVisible = false;
  281. this.btnLoading = false;
  282. if (e.data.code == 0) {
  283. self.$message.success(e.data.msg);
  284. self.getList();
  285. } else {
  286. self.$message.error(e.data.msg);
  287. }
  288. }).catch(e => {
  289. console.log(e);
  290. });
  291. })
  292. },
  293. /**
  294. *点击新增按钮,弹出新增模态框
  295. * @param
  296. */
  297. addgsForm() {
  298. this.dialogAddgsVisible = true;
  299. this.title = "添加系统通知";
  300. this.addForm.id = '';
  301. this.addForm.sort = 99;
  302. },
  303. /**
  304. *关闭或取消模态框,清空值
  305. * @param
  306. */
  307. closeDialogAddgsVisible() {
  308. this.$refs.addForm.resetFields();//element封装的方法,清空模态框的值
  309. this.title = "" //初始化title的值
  310. this.addForm = {//初始化addForm中的值
  311. name: "",
  312. }
  313. },
  314. },
  315. mounted: function () {
  316. this.getList();
  317. }
  318. });
  319. </script>