messageReviewList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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="listRefuseBtn" @click="refuseData(scope.row.id)" v-if="creatNews_user_type==10000">
  58. <i class="el-icon-close"></i>拒绝
  59. </div>
  60. <div class="listDeleteBtn" @click="deleteData(scope.row.id)">
  61. <i class="el-icon-delete"></i>删除
  62. </div>
  63. <div class="listEditBtn" @click="gotoEdit(scope.row.id)">
  64. <i class="el-icon-edit-outline"></i>编辑
  65. </div>
  66. </div>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. </template>
  71. </el-row>
  72. </div>
  73. <div class="alignBox">
  74. <el-row>
  75. <el-col :span="24">
  76. <el-pagination :current-page="getApiData.page" @size-change="handleSizeChange"
  77. @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper"
  78. :total="allCount"></el-pagination>
  79. </el-col>
  80. </el-row>
  81. </div>
  82. <!--表格内容 end------------------------------------------------------------>
  83. </div>
  84. </template>
  85. <script>
  86. //获得用户身份
  87. import { getWebSiteId, getUseType } from '@/utils/auth'
  88. //表格标题
  89. import tableTitle from './components/tableTitle';
  90. //引入公用样式
  91. import '@/styles/global.less';
  92. export default {
  93. components: {
  94. tableTitle,//表格标题
  95. },
  96. data() {
  97. //0.全局操作 start ------------------------------------------------------------>
  98. let self = this;
  99. //0.全局操作 end ------------------------------------------------------------>
  100. return {
  101. creatNews_user_type:0,//用户身份
  102. //1.列表和分页相关 start ------------------------------------------------------------>
  103. tableDivTitle: "留言列表",
  104. tableData: [],//内容
  105. getApiData: {
  106. website_id: 0,
  107. is_master: "0",//是否为审核列表 0=待审核列表 1=已审核列表
  108. title: "",//留言标题
  109. page: 1,//当前是第几页
  110. page_size: 10,//一共多少条
  111. },
  112. allCount: 0,//总条数
  113. //分页相关 end ------------------------------------------------------------>
  114. }
  115. },
  116. methods: {
  117. //1.列表和分页相关 start ------------------------------------------------------------>
  118. //1.1 开始请求列表信息方法
  119. getData(type) {
  120. //如果是搜索,重新加载第一页==搜索
  121. if (type == "search") {
  122. this.getApiData.page = 1;
  123. this.getApiData.title = "";
  124. }
  125. this.$store.dispatch('news/getMessageList', this.getApiData).then(res => {
  126. //列表
  127. this.tableData = res.data.data;
  128. //页数
  129. this.allCount = res.data.count;
  130. }).catch(() => {
  131. this.$message({
  132. type: 'info',
  133. message: '网络错误,请重试!'
  134. });
  135. })
  136. },
  137. //1.2 删除内容
  138. deleteData(id) {
  139. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  140. confirmButtonText: '确定',
  141. cancelButtonText: '取消',
  142. type: 'warning'
  143. }).then(() => {
  144. console.log("当前删除:" + id)
  145. this.$store.dispatch('news/delMessage', {id:id}).then(res => {
  146. if(res.code == 200) {
  147. this.$message({
  148. type: 'success',
  149. message: '删除成功!'
  150. });
  151. } else {
  152. this.$message.error(res.message);
  153. }
  154. this.getData();
  155. })
  156. }).catch(() => {
  157. this.$message({
  158. type: 'warning',
  159. message: '已取消删除'
  160. });
  161. });
  162. },
  163. editData(id){
  164. this.$confirm('允许该留言通过审核吗?', '提示', {
  165. confirmButtonText: '确定',
  166. cancelButtonText: '取消',
  167. type: 'success'
  168. }).then(() => {
  169. let data = {
  170. id:id,
  171. status:1,
  172. reason:""
  173. }
  174. this.$store.dispatch('news/upMessageStatus', data).then(res => {
  175. if(res.code == 200) {
  176. this.$message({
  177. type: 'success',
  178. message: '审核已通过!'
  179. });
  180. } else {
  181. this.$message.error(res.message);
  182. }
  183. this.getData();
  184. })
  185. }).catch(() => {
  186. this.$message({
  187. type: 'warning',
  188. message: '已取消操作'
  189. });
  190. });
  191. },
  192. refuseData(id){
  193. this.$prompt('请输入拒绝理由', '拒绝', {
  194. confirmButtonText: '确定',
  195. cancelButtonText: '取消',
  196. inputPlaceholder: '请输入拒绝理由',
  197. inputPattern: /\S+/, // 匹配非空内容(至少一个非空白字符)
  198. inputErrorMessage: '拒绝理由不能为空'
  199. }).then(({ value }) => {
  200. let data = {
  201. id:id,
  202. status:2,
  203. reason:value
  204. }
  205. this.$store.dispatch('news/upMessageStatus', data).then(res => {
  206. if(res.code == 200) {
  207. this.$message({
  208. type: 'success',
  209. message: '已拒绝该留言!'
  210. });
  211. this.getData();
  212. } else {
  213. this.$message.error(res.message);
  214. }
  215. })
  216. })
  217. },
  218. //1.3 列表内容分页
  219. handleSizeChange(val) {
  220. this.getApiData.page = val;
  221. this.getData();
  222. },
  223. //1.4 点击分页
  224. handleCurrentChange(val) {
  225. this.getApiData.page = val;
  226. this.getData();
  227. },
  228. //1.6 重置按钮
  229. clearSearchList() {
  230. this.tableData = [];
  231. this.getApiData.keyword = "";
  232. this.getApiData.name = "";
  233. this.getApiData.website_column_id = [];
  234. this.getApiData.city_id = [];
  235. this.getApiData.city_arr_id = [];
  236. this.getApiData.page = 1;
  237. this.getApiData.pageSize = 10;
  238. this.getData();
  239. },
  240. //列表和分页相关 end ------------------------------------------------------------>
  241. //跳转到添加留言页面 start ------------------------------------------------------------>
  242. // gotoCreat() {
  243. // this.$router.push({
  244. // path: '/messageCreat',
  245. // query: {
  246. // type: 'add',
  247. // page: 'messageReviewList'
  248. // }
  249. // });
  250. // },
  251. //编辑
  252. gotoEdit(id) {
  253. this.$router.push({
  254. path: '/messageCreat',
  255. query: {
  256. id: id,
  257. type: 'edit',
  258. page: 'messageReviewList'
  259. }
  260. });
  261. },
  262. //跳转到添加留言页面 end ------------------------------------------------------------>
  263. },
  264. mounted() {
  265. //获得第一页
  266. this.getData();
  267. //1.获得用户身份
  268. this.creatNews_user_type = getUseType()
  269. //2.获得站点id
  270. this.getApiData.website_id = getWebSiteId();
  271. //3.获得页面操作方式
  272. this.behavior = this.$route.query.behavior;
  273. },
  274. }
  275. </script>
  276. <style scoped lang="less">
  277. .status0 {
  278. color: #5570F1;
  279. }
  280. .status1 {
  281. color: #519C66;
  282. }
  283. .status2 {
  284. color: #CC5F5F;
  285. }
  286. //执行v-deep穿透scope选择器 start------------------------------------------------------------>*/
  287. ::v-deep .custom-form-item>.el-form-item__label {
  288. line-height: 140px !important;
  289. }
  290. ::v-deep .custom-textarea .el-textarea__inner {
  291. resize: none;
  292. /* 禁止用户拖拽调整大小 */
  293. }
  294. ::v-deep .custom-align-right .el-form-item__label {
  295. text-align: right;
  296. /* 设置标签文字右对齐 */
  297. }
  298. //执行v-deep穿透scope选择器 end------------------------------------------------------------>*/
  299. .tag_webSite_head_btn_box {
  300. overflow: hidden;
  301. }
  302. .tag_webSite_head_btn_box .searchTitle {
  303. opacity: 0;
  304. span {
  305. display: block;
  306. height: 16px;
  307. }
  308. }
  309. .tag_webSite_head_btn_box button {
  310. float: right;
  311. }
  312. .tag_webSite_head_btn_box button:nth-of-type(1) {
  313. margin-left: 10px;
  314. }
  315. </style>