messageList.vue 12 KB

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