ncomplaintList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="mainBox">
  3. <!--搜索功能 start------------------------------------------------------------>
  4. <div class="layerBox_search">
  5. <div class="layerBoxLine">
  6. <el-row>
  7. <el-col :span="8">
  8. <div class="searchBox">
  9. <div class="searchTitle">标题:</div>
  10. <el-input placeholder="请输入标题" autocomplete="off" v-model="getApiData.title" />
  11. </div>
  12. </el-col>
  13. <el-col :span="8">
  14. <div class="searchBox">
  15. <div class="searchTitle">公告级别:</div>
  16. <el-select v-model="getApiData.level" placeholder="请选择..">
  17. <el-option label="常规" value="1"></el-option>
  18. <el-option label="紧急" value="2"></el-option>
  19. <el-option label="特急" value="3"></el-option>
  20. </el-select>
  21. </div>
  22. </el-col>
  23. </el-row>
  24. </div>
  25. </div>
  26. <div class="layerBoxNoBg">
  27. <div>
  28. <el-button type="primary" @click="goCreat">发布通知</el-button>
  29. </div>
  30. <div>
  31. <el-button @click="clearSearchList">重置</el-button>
  32. <el-button type="primary" @click="getData('search')">搜索</el-button>
  33. </div>
  34. </div>
  35. <!--搜索功能 end------------------------------------------------------------>
  36. <!--表格内容 start------------------------------------------------------------>
  37. <div class="layerBox">
  38. <tableTitle :name="tableDivTitle" />
  39. <el-row>
  40. <template>
  41. <el-table :data="tableData" style="width: 100%">
  42. <el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
  43. <el-table-column prop="title" label="标题" width="">
  44. </el-table-column>
  45. <el-table-column prop="type" label="类型" width="">
  46. <template slot-scope="scope">
  47. <span v-if="scope.row.type == 1">
  48. 公告
  49. </span>
  50. <span v-if="scope.row.type == 2">
  51. 通知
  52. </span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="level" label="级别" width="">
  56. <template slot-scope="scope">
  57. <span v-if="scope.row.level == 1">
  58. 常规
  59. </span>
  60. <span v-if="scope.row.level == 2">
  61. 紧急
  62. </span>
  63. <span v-if="scope.row.level == 3">
  64. 特急
  65. </span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="start" label="开始时间" width="">
  69. </el-table-column>
  70. <el-table-column prop="end" label="到期时间" width=""></el-table-column>
  71. <el-table-column prop="created_at" label="创建时间" width=""></el-table-column>
  72. <el-table-column fixed="right" label="操作" width="200" header-align="center">
  73. <template slot-scope="scope">
  74. <div class="listBtnBox">
  75. <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i
  76. class="el-icon-delete"></i>删除</div>
  77. <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i
  78. class="el-icon-edit-outline"></i>编辑</div>
  79. </div>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. </template>
  84. </el-row>
  85. </div>
  86. <!--分页 start------------------------------------------------------------>
  87. <div class="alignBox">
  88. <el-row>
  89. <el-col :span="24">
  90. <el-pagination @size-change="handleSizeChange" :current-page="getApiData.page"
  91. @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper"
  92. :total="allCount"></el-pagination>
  93. </el-col>
  94. </el-row>
  95. </div>
  96. <!--分页 end------------------------------------------------------------>
  97. <!--表格内容 end------------------------------------------------------------>
  98. </div>
  99. </template>
  100. <script>
  101. //表格标题
  102. import tableTitle from './components/tableTitle';
  103. //引入公用样式
  104. import '@/styles/global.less';
  105. export default {
  106. components: {
  107. tableTitle,//表格标题
  108. },
  109. data() {
  110. return {
  111. //1.列表和分页相关 start ------------------------------------------------------------>
  112. tableDivTitle: "通知列表",
  113. tableData: [],//内容
  114. editId: 0,//要修改的网站id
  115. getApiData: {
  116. name: "",//标题
  117. category_name: "",//导航池id
  118. website_name: "",//网站名称
  119. type_id: "",//发布类型
  120. page: 1,//当前是第几页
  121. page_size: 10,//一共多少条
  122. },
  123. allCount: 0,//总条数
  124. //分页相关 end ------------------------------------------------------------>
  125. }
  126. },
  127. methods: {
  128. //1.列表和分页相关 start ------------------------------------------------------------>
  129. //1.1 开始请求列表信息方法
  130. getData(type) {
  131. if (type == "search") {
  132. this.getApiData.page = 1;
  133. }
  134. console.log(this.getApiData, '---1--')
  135. this.$store.dispatch('news/getNoticeList', this.getApiData).then(res => {
  136. console.log(this.getApiData, '---2-')
  137. let data = [];
  138. for (let item of res.data.rows) {
  139. data.push(item)
  140. }
  141. this.tableData = res.data.rows; //给与内容
  142. this.allCount = res.data.count; //给与总条数
  143. })
  144. },
  145. //1.2 删除内容
  146. deleteRow(id) {
  147. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  148. confirmButtonText: '确定',
  149. cancelButtonText: '取消',
  150. type: 'warning'
  151. }).then(() => {
  152. console.log("当前删除:" + id)
  153. this.$store.dispatch('news/deleteNotice', { id: id }).then(res => {
  154. this.getData();
  155. this.$message({
  156. type: 'success',
  157. message: '删除成功!'
  158. });
  159. }).catch(() => {
  160. this.$message({
  161. type: 'warning',
  162. message: '网络错误,请重试!'
  163. });
  164. })
  165. }).catch(() => {
  166. this.$message({
  167. type: 'warning',
  168. message: '已取消删除'
  169. });
  170. });
  171. },
  172. //1.3 修改网站状态
  173. upRow(id, status) {
  174. let data = {
  175. id: id,
  176. status: status
  177. }
  178. this.$store.dispatch('news/upArticleStatus', data).then(res => {
  179. if (res.code == 200) {
  180. this.$message({
  181. type: 'success',
  182. message: '通知状态已修改!'
  183. });
  184. }
  185. }).catch(() => {
  186. this.$message({
  187. type: 'warning',
  188. message: '已取消删除'
  189. });
  190. });
  191. },
  192. //1.4 列表内容分页
  193. //直接跳转
  194. handleSizeChange(val) {
  195. this.getApiData.page = val;
  196. this.getData();
  197. },
  198. //1.5 点击分页
  199. handleCurrentChange(val) {
  200. this.getApiData.page = val;
  201. this.getData();
  202. },
  203. //1.6 重置按钮
  204. clearSearchList() {
  205. this.tableData = [];
  206. this.getApiData.title = "";
  207. this.getApiData.level = "";
  208. this.getApiData.page = 1;
  209. this.getApiData.pageSize = 10;
  210. this.getData();
  211. },
  212. //列表和分页相关 end ------------------------------------------------------------>
  213. //2.添加新闻 start ------------------------------------------------------------>
  214. //跳转到通知发布页面
  215. goCreat() {
  216. this.$router.push({
  217. path: '/addNotice',
  218. });
  219. },
  220. goEdit(id) {
  221. let data = {
  222. id: id
  223. }
  224. this.$router.push({
  225. path: '/addNotice',
  226. query: data
  227. });
  228. }
  229. //添加新闻 end ------------------------------------------------------------>
  230. },
  231. mounted() {
  232. //1.获得初始数据
  233. this.getData();
  234. }
  235. }
  236. </script>
  237. <style scoped lang="less"></style>