topic.vue 11 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="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.type" placeholder="请选择课题分类..">
  17. <!-- <el-option label="科研" value="1"></el-option>
  18. <el-option label="维权" value="2"></el-option> -->
  19. <el-option :label="item.label" :value="item.value" v-for="item in topicType"></el-option>
  20. </el-select>
  21. </div>
  22. </el-col>
  23. <el-col :span="8">
  24. <div class="searchBox">
  25. <div class="searchTitle">作者:</div>
  26. <el-input placeholder="请输入作者姓名" autocomplete="off" v-model="getApiData.nickname"/>
  27. </div>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. <div class="layerBoxLineTwo">
  32. <el-row>
  33. <el-col :span="8">
  34. <div class="searchBox">
  35. <div class="searchTitle">审核状态:</div>
  36. <el-select v-model="getApiData.status" placeholder="请选择审核状态..">
  37. <!-- <el-option label="待审核" value="1"></el-option>
  38. <el-option label="已通过" value="2"></el-option>
  39. <el-option label="已拒绝" value="3"></el-option> -->
  40. <el-option :label="item.label" :value="item.value" v-for="item in topicStatus"></el-option>
  41. </el-select>
  42. </div>
  43. </el-col>
  44. </el-row>
  45. </div>
  46. </div>
  47. <div class="layerBoxNoBg">
  48. <div>
  49. <el-button type="primary" @click="goCreat">发布课题</el-button>
  50. </div>
  51. <div>
  52. <el-button @click="clearSearchList">重置</el-button>
  53. <el-button type="primary" @click="getData('search')">搜索</el-button>
  54. </div>
  55. </div>
  56. <!--搜索功能 end------------------------------------------------------------>
  57. <!--表格内容 start------------------------------------------------------------>
  58. <div class="layerBox">
  59. <tableTitle :name="tableDivTitle"/>
  60. <el-row>
  61. <template>
  62. <el-table :data="tableData" style="width: 100%">
  63. <el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
  64. <el-table-column prop="title" label="课题标题" width=""></el-table-column>
  65. <el-table-column prop="type" label="课题分类" width="">
  66. <!-- <template slot-scope="scope">
  67. <div v-if="scope.row.type==1">科研</div>
  68. <div v-if="scope.row.type==2">维权</div>
  69. <div v-if="scope.row.type==3">讨论</div>
  70. </template> -->
  71. </el-table-column>
  72. <el-table-column prop="author" label="作者" width=""></el-table-column>
  73. <el-table-column prop="created_at" label="创建时间" width=""></el-table-column>
  74. <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
  75. <el-table-column prop="status" label="状态" width="">
  76. <template slot-scope="scope">
  77. <div v-if="scope.row.status==1" class="status1">待审核</div>
  78. <div v-if="scope.row.status==2" class="status2">已通过</div>
  79. <div v-if="scope.row.status==3" class="status3">已拒绝</div>
  80. </template>
  81. </el-table-column>
  82. <el-table-column fixed="right" label="操作" width="280" header-align="center">
  83. <template slot-scope="scope">
  84. <div class="listBtnBox">
  85. <div class="listDeleteBtn" @click="deleteRow(scope.row.id)"><i class="el-icon-delete"></i>删除</div>
  86. <div class="listEditBtn" @click="goEdit(scope.row.id)"><i class="el-icon-edit-outline"></i>编辑</div>
  87. <div class="listMainBtn" @click="openEditWindow(scope.row.id)" v-if="$store.state.user.role_id==1||$store.state.user.role_id==21||$store.state.user.role_id==23"><i class="el-icon-edit-outline"></i>审核</div>
  88. </div>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. </template>
  93. </el-row>
  94. </div>
  95. <!--分页 start------------------------------------------------------------>
  96. <div class="alignBox">
  97. <el-row>
  98. <el-col :span="24">
  99. <el-pagination @size-change="handleSizeChange" :current-page="getApiData.page" @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper" :total="allCount"></el-pagination>
  100. </el-col>
  101. </el-row>
  102. </div>
  103. <!--分页 end------------------------------------------------------------>
  104. <!--表格内容 end------------------------------------------------------------>
  105. <!--审核状态弹出框 start------------------------------------------------------------>
  106. <el-dialog :visible.sync="auditStatus" title="审核状态" :close-on-click-modal="false" width="420px">
  107. <div>
  108. <div class="contentBox">
  109. <el-radio-group v-model="form.radio">
  110. <el-radio :label="2">通过</el-radio>
  111. <el-radio :label="3">拒绝</el-radio>
  112. </el-radio-group>
  113. </div>
  114. <div class="footerButtonBox">
  115. <el-button type="info" @click="auditStatus = false">取消</el-button>
  116. <el-button type="primary" @click="editStatus">确定</el-button>
  117. </div>
  118. </div>
  119. </el-dialog>
  120. <!--审核状态弹出框 end------------------------------------------------------------>
  121. </div>
  122. </template>
  123. <script>
  124. //表格标题
  125. import tableTitle from './components/tableTitle';
  126. //引入公用样式
  127. import '@/styles/global.less';
  128. export default {
  129. components: {
  130. tableTitle,//表格标题
  131. },
  132. data() {
  133. return {
  134. //1.列表和分页相关 start ------------------------------------------------------------>
  135. tableDivTitle:"课题列表",
  136. tableData:[],//内容
  137. editId:0,//要修改的网站id
  138. topicType:[],//课题分类
  139. topicStatus:[],//课题状态
  140. getApiData:{
  141. title:"",//标题
  142. type:"",//课题分类
  143. nickname:"",//作者
  144. status:"",//审核状态
  145. page:1,//当前是第几页
  146. page_size:10,//一共多少条
  147. },
  148. allCount:0,//总条数
  149. auditStatus:false,//审核状态弹出框
  150. form:{
  151. radio:2 //1=通过 2=拒绝
  152. }
  153. //分页相关 end ------------------------------------------------------------>
  154. }
  155. },
  156. methods: {
  157. //1.列表和分页相关 start ------------------------------------------------------------>
  158. //1.1 开始请求商圈列表
  159. getData(type){
  160. if(type=="search"){
  161. this.getApiData.page = 1;
  162. }
  163. this.$store.dispatch('chat/getTopicsList',this.getApiData).then(res=> {
  164. this.tableData = res.data.data; //给与内容
  165. this.allCount = res.data.total; //给与总条数
  166. //把数字转换为汉字
  167. for(let item of res.data.data){
  168. for(let item2 of this.topicType){
  169. if(item.type == item2.value){
  170. item.type = item2.label;
  171. }
  172. }
  173. }
  174. }).catch(() => {
  175. this.$message({
  176. type: 'warning',
  177. message: '网络错误,请重试!'
  178. });
  179. })
  180. },
  181. //1.2 删除商圈
  182. deleteRow(id){
  183. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  184. confirmButtonText: '确定',
  185. cancelButtonText: '取消',
  186. type: 'warning'
  187. }).then(() => {
  188. console.log("当前删除:" + id)
  189. let data = {
  190. id:id+""
  191. }
  192. this.$store.dispatch('chat/delTopic',data).then(res=> {
  193. this.getData();
  194. this.$message({
  195. type: 'success',
  196. message: '删除成功!'
  197. });
  198. }).catch(() => {
  199. this.$message({
  200. type: 'warning',
  201. message: '网络错误,请重试!'
  202. });
  203. })
  204. }).catch(() => {
  205. this.$message({
  206. type: 'warning',
  207. message: '已取消删除'
  208. });
  209. });
  210. },
  211. //1.4 列表内容分页
  212. //直接跳转
  213. handleSizeChange(val) {
  214. this.getApiData.page = val;
  215. this.getData();
  216. },
  217. //1.5 点击分页
  218. handleCurrentChange(val) {
  219. this.getApiData.page = val;
  220. this.getData();
  221. },
  222. //1.6 重置按钮
  223. clearSearchList(){
  224. this.tableData = [];
  225. this.getApiData.title = "";
  226. this.getApiData.type = "";
  227. this.getApiData.nickname = "";
  228. this.getApiData.status = "";
  229. this.getApiData.page = 1;
  230. this.getApiData.pageSize = 10;
  231. this.getData();
  232. },
  233. //1.7 查询商圈分类
  234. getTopicType(){
  235. this.$store.dispatch('chat/topicType',this.getApiData).then(res=> {
  236. this.topicType = res.data;
  237. console.log(this.topicType)
  238. }).catch(() => {
  239. this.$message.error("查询商圈分类失败!");
  240. })
  241. },
  242. //1.8 查询商圈状态
  243. getTopicStatus(){
  244. this.$store.dispatch('chat/topicStatus',this.getApiData).then(res=> {
  245. this.topicStatus = res.data;
  246. console.log(res)
  247. }).catch(() => {
  248. this.$message.error("查询商圈状态失败!");
  249. })
  250. },
  251. //列表和分页相关 end ------------------------------------------------------------>
  252. //2.添加商圈 start ------------------------------------------------------------>
  253. //跳转到资讯发布页面
  254. goCreat(){
  255. this.$router.push({
  256. path: '/creatTopic',
  257. });
  258. },
  259. goEdit(id){
  260. let data = {
  261. id:id
  262. }
  263. this.$router.push({
  264. path: '/creatTopic',
  265. query: data
  266. });
  267. },
  268. //添加商圈 end ------------------------------------------------------------>
  269. //3.审核 start ------------------------------------------------------------>
  270. openEditWindow(id){
  271. this.editId = id;
  272. this.auditStatus = true;
  273. },
  274. editStatus(){
  275. let data = {
  276. id:this.editId + "",
  277. status:this.form.radio + ""
  278. }
  279. this.$store.dispatch('chat/applyTopic',data).then(res=> {
  280. console.log(res)
  281. this.getData();
  282. this.auditStatus = false;
  283. });
  284. },
  285. //3.审核 end ------------------------------------------------------------>
  286. },
  287. mounted(){
  288. //1.获得初始数据
  289. this.getData();
  290. //2.查询课题分类
  291. this.getTopicType();
  292. // //3.查询课题状态
  293. this.getTopicStatus();
  294. }
  295. }
  296. </script>
  297. <style scoped lang="less">
  298. .contentBox {
  299. padding: 0 0 20px 0;
  300. }
  301. .footerButtonBox {
  302. text-align: right;
  303. }
  304. .status1 {
  305. color: #F19655;
  306. }
  307. .status2 {
  308. color: #519C66;
  309. }
  310. .status3 {
  311. color: #CC5F5F;
  312. }
  313. </style>