messageReviewList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="mainBox">
  3. <!--搜索功能 start------------------------------------------------------------>
  4. <div class="layerBox_search">
  5. <div class="layerBoxLine">
  6. <el-row>
  7. <el-col :span="6">
  8. <div class="searchBox">
  9. <div class="searchTitle">留言标题:</div>
  10. <el-input placeholder="请输入留言标题" autocomplete="off" v-model="getApiData.keyword" />
  11. </div>
  12. </el-col>
  13. <el-col :span="6">
  14. <div class="searchBox">
  15. <div class="searchTitle">审核状态:</div>
  16. <el-select v-model="getApiData.is_master" placeholder="请选择..">
  17. <el-option label="全部" value="0"></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-col :span="12">
  24. <div class="tag_webSite_head_btn_box">
  25. <div class="searchTitle"><span></span></div>
  26. <el-button type="primary" @click="getData('search')">搜索</el-button>
  27. <el-button type="info" @click="clearSearchList">重置</el-button>
  28. </div>
  29. </el-col>
  30. </el-row>
  31. </div>
  32. </div>
  33. <!--搜索功能 end------------------------------------------------------------>
  34. <!--表格内容 start------------------------------------------------------------>
  35. <div class="layerBox">
  36. <tableTitle :name="tableDivTitle" />
  37. <el-row>
  38. <template>
  39. <el-table :data="tableData" style="width: 100%">
  40. <el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
  41. <el-table-column prop="title" label="留言标题" width="240"></el-table-column>
  42. <el-table-column prop="created_at" label="创建时间" width="240"></el-table-column>
  43. <el-table-column prop="updated_at" label="修改时间"></el-table-column>
  44. <el-table-column prop="status" label="状态">
  45. <template slot-scope="scope">
  46. <span v-if="scope.row.status == 0" class="status0">待审核</span>
  47. <span v-if="scope.row.status == 1" class="status1">已通过</span>
  48. <span v-if="scope.row.status == 2" class="status2">已拒绝</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column fixed="right" label="操作" width="350" header-align="center">
  52. <template slot-scope="scope">
  53. <div class="listBtnBox">
  54. <div class="listMainBtn" @click="editData(scope.row.id)" v-if="creatNews_user_type==10000">
  55. <i class="el-icon-check"></i>审核
  56. </div>
  57. <div class="listDeleteBtn" @click="deleteData(scope.row.id)">
  58. <i class="el-icon-delete"></i>删除
  59. </div>
  60. <div class="listEditBtn" @click="gotoEdit(scope.row.id)">
  61. <i class="el-icon-edit-outline"></i>编辑
  62. </div>
  63. </div>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. </template>
  68. </el-row>
  69. </div>
  70. <div class="alignBox">
  71. <el-row>
  72. <el-col :span="24">
  73. <el-pagination :current-page="getApiData.page" @size-change="handleSizeChange"
  74. @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper"
  75. :total="allCount"></el-pagination>
  76. </el-col>
  77. </el-row>
  78. </div>
  79. <!--表格内容 end------------------------------------------------------------>
  80. </div>
  81. </template>
  82. <script>
  83. //获得用户身份
  84. import { getWebSiteId, getUseType } from '@/utils/auth'
  85. //表格标题
  86. import tableTitle from './components/tableTitle';
  87. //引入公用样式
  88. import '@/styles/global.less';
  89. export default {
  90. components: {
  91. tableTitle,//表格标题
  92. },
  93. data() {
  94. //0.全局操作 start ------------------------------------------------------------>
  95. let self = this;
  96. //0.全局操作 end ------------------------------------------------------------>
  97. return {
  98. creatNews_user_type:0,//用户身份
  99. //1.列表和分页相关 start ------------------------------------------------------------>
  100. tableDivTitle: "留言列表",
  101. tableData: [],//内容
  102. getApiData: {
  103. is_master: "0",//是否为审核列表 0=待审核列表 1=已审核列表
  104. title: "",//留言标题
  105. page: 1,//当前是第几页
  106. page_size: 10,//一共多少条
  107. },
  108. allCount: 0,//总条数
  109. //分页相关 end ------------------------------------------------------------>
  110. }
  111. },
  112. methods: {
  113. //1.列表和分页相关 start ------------------------------------------------------------>
  114. //1.1 开始请求列表信息方法
  115. getData(type) {
  116. //如果是搜索,重新加载第一页==搜索
  117. if (type == "search") {
  118. this.getApiData.page = 1;
  119. this.getApiData.title = "";
  120. }
  121. this.$store.dispatch('news/getMessageList', this.getApiData).then(res => {
  122. //列表
  123. this.tableData = res.data.data;
  124. //页数
  125. this.allCount = res.data.count;
  126. }).catch(() => {
  127. this.$message({
  128. type: 'info',
  129. message: '网络错误,请重试!'
  130. });
  131. })
  132. },
  133. //1.2 删除内容
  134. deleteData(id) {
  135. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  136. confirmButtonText: '确定',
  137. cancelButtonText: '取消',
  138. type: 'warning'
  139. }).then(() => {
  140. console.log("当前删除:" + id)
  141. this.$store.dispatch('news/delMessage', {id:id}).then(res => {
  142. if(res.code == 200) {
  143. this.$message({
  144. type: 'success',
  145. message: '删除成功!'
  146. });
  147. } else {
  148. this.$message.error(res.message);
  149. }
  150. this.getData();
  151. })
  152. }).catch(() => {
  153. this.$message({
  154. type: 'warning',
  155. message: '已取消删除'
  156. });
  157. });
  158. },
  159. editData(id){
  160. this.$confirm('允许该留言通过审核吗?', '提示', {
  161. confirmButtonText: '确定',
  162. cancelButtonText: '取消',
  163. type: 'success'
  164. }).then(() => {
  165. let data = {
  166. id:id,
  167. status:1,
  168. reason:""
  169. }
  170. this.$store.dispatch('news/upMessageStatus', data).then(res => {
  171. if(res.code == 200) {
  172. this.$message({
  173. type: 'success',
  174. message: '审核已通过!'
  175. });
  176. } else {
  177. this.$message.error(res.message);
  178. }
  179. this.getData();
  180. })
  181. }).catch(() => {
  182. this.$message({
  183. type: 'warning',
  184. message: '已取消操作'
  185. });
  186. });
  187. },
  188. //1.3 列表内容分页
  189. handleSizeChange(val) {
  190. this.getApiData.page = val;
  191. this.getData();
  192. },
  193. //1.4 点击分页
  194. handleCurrentChange(val) {
  195. this.getApiData.page = val;
  196. this.getData();
  197. },
  198. //1.6 重置按钮
  199. clearSearchList() {
  200. this.tableData = [];
  201. this.getApiData.keyword = "";
  202. this.getApiData.name = "";
  203. this.getApiData.website_column_id = [];
  204. this.getApiData.city_id = [];
  205. this.getApiData.city_arr_id = [];
  206. this.getApiData.page = 1;
  207. this.getApiData.pageSize = 10;
  208. this.getData();
  209. },
  210. //列表和分页相关 end ------------------------------------------------------------>
  211. //跳转到添加留言页面 start ------------------------------------------------------------>
  212. // gotoCreat() {
  213. // this.$router.push({
  214. // path: '/messageCreat',
  215. // query: {
  216. // type: 'add',
  217. // page: 'messageReviewList'
  218. // }
  219. // });
  220. // },
  221. //编辑
  222. gotoEdit(id) {
  223. this.$router.push({
  224. path: '/messageCreat',
  225. query: {
  226. id: id,
  227. type: 'edit',
  228. page: 'messageReviewList'
  229. }
  230. });
  231. },
  232. //跳转到添加留言页面 end ------------------------------------------------------------>
  233. },
  234. mounted() {
  235. //获得第一页
  236. this.getData();
  237. //1.获得用户身份
  238. this.creatNews_user_type = getUseType()
  239. },
  240. }
  241. </script>
  242. <style scoped lang="less">
  243. .status0 {
  244. color: #5570F1;
  245. }
  246. .status1 {
  247. color: #519C66;
  248. }
  249. .status2 {
  250. color: #CC5F5F;
  251. }
  252. //执行v-deep穿透scope选择器 start------------------------------------------------------------>*/
  253. ::v-deep .custom-form-item>.el-form-item__label {
  254. line-height: 140px !important;
  255. }
  256. ::v-deep .custom-textarea .el-textarea__inner {
  257. resize: none;
  258. /* 禁止用户拖拽调整大小 */
  259. }
  260. ::v-deep .custom-align-right .el-form-item__label {
  261. text-align: right;
  262. /* 设置标签文字右对齐 */
  263. }
  264. //执行v-deep穿透scope选择器 end------------------------------------------------------------>*/
  265. .tag_webSite_head_btn_box {
  266. overflow: hidden;
  267. }
  268. .tag_webSite_head_btn_box .searchTitle {
  269. opacity: 0;
  270. span {
  271. display: block;
  272. height: 16px;
  273. }
  274. }
  275. .tag_webSite_head_btn_box button {
  276. float: right;
  277. }
  278. .tag_webSite_head_btn_box button:nth-of-type(1) {
  279. margin-left: 10px;
  280. }
  281. </style>