jobRecruitingList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.keyword"/>
  11. </div>
  12. </el-col>
  13. </el-row>
  14. </div>
  15. </div>
  16. <div class="layerBoxNoBg">
  17. <div>
  18. <el-button type="primary" @click="goCreat">发布职位</el-button>
  19. </div>
  20. <div>
  21. <el-button @click="clearSearchList">重置</el-button>
  22. <el-button type="primary" @click="getData('search')">搜索</el-button>
  23. </div>
  24. </div>
  25. <!--搜索功能 end------------------------------------------------------------>
  26. <!--表格内容 start------------------------------------------------------------>
  27. <div class="layerBox">
  28. <tableTitle :name="tableDivTitle"/>
  29. <el-row>
  30. <template>
  31. <el-table :data="tableData" style="width: 100%">
  32. <el-table-column fixed prop="id" label="编号" width="100"></el-table-column>
  33. <el-table-column prop="title" label="职位名称" width=""></el-table-column>
  34. <el-table-column prop="website_name" label="网站名称" width=""></el-table-column>
  35. <el-table-column prop="user_name" label="发布人" width=""></el-table-column>
  36. <el-table-column prop="created_at" label="创建时间" width=""></el-table-column>
  37. <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
  38. <el-table-column fixed="right" label="操作" width="200" header-align="center">
  39. <template slot-scope="scope">
  40. <div class="listBtnBox">
  41. <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i class="el-icon-delete"></i>移除</div>
  42. <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i class="el-icon-edit-outline"></i>编辑</div>
  43. </div>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. </template>
  48. </el-row>
  49. </div>
  50. <!--分页 start------------------------------------------------------------>
  51. <div class="alignBox">
  52. <el-row>
  53. <el-col :span="24">
  54. <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>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. <!--分页 end------------------------------------------------------------>
  59. <!--表格内容 end------------------------------------------------------------>
  60. </div>
  61. </template>
  62. <script>
  63. //表格标题
  64. import tableTitle from './components/tableTitle';
  65. //引入公用样式
  66. import '@/styles/global.less';
  67. export default {
  68. components: {
  69. tableTitle,//表格标题
  70. },
  71. data() {
  72. return {
  73. //1.列表和分页相关 start ------------------------------------------------------------>
  74. tableDivTitle:"职位列表",
  75. tableData:[],//内容
  76. editId:0,//要修改的网站id
  77. getApiData:{
  78. title:"",//职位名称
  79. website_name:"",//网站名称
  80. user_name:"",//发布人
  81. created_at:"",//创建时间
  82. updated_at:"",//修改时间
  83. page:1,//当前是第几页
  84. page_size:10,//一共多少条
  85. },
  86. allCount:0,//总条数
  87. //分页相关 end ------------------------------------------------------------>
  88. }
  89. },
  90. methods: {
  91. //1.列表和分页相关 start ------------------------------------------------------------>
  92. //1.1 开始请求列表信息方法
  93. getData(type){
  94. if(type=="search"){
  95. this.getApiData.page = 1;
  96. }
  97. this.$store.dispatch('news/getJobRecruitingList',this.getApiData).then(res=> {
  98. let data = [];
  99. console.log(res.data.rows)
  100. this.tableData = res.data.rows; //给与内容
  101. this.allCount = res.data.count; //给与总条数
  102. }).catch(() => {
  103. this.$message({
  104. type: 'warning',
  105. message: '网络错误,请重试!'
  106. });
  107. })
  108. },
  109. //1.2 删除内容
  110. deleteRow(id){
  111. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  112. confirmButtonText: '确定',
  113. cancelButtonText: '取消',
  114. type: 'warning'
  115. }).then(() => {
  116. console.log("当前删除:" + id)
  117. this.$store.dispatch('news/delJobRecruiting',{id:id}).then(res=> {
  118. this.getData();
  119. this.$message({
  120. type: 'success',
  121. message: '删除成功!'
  122. });
  123. }).catch(() => {
  124. this.$message({
  125. type: 'warning',
  126. message: '网络错误,请重试!'
  127. });
  128. })
  129. }).catch(() => {
  130. this.$message({
  131. type: 'warning',
  132. message: '已取消删除'
  133. });
  134. });
  135. },
  136. //1.3 修改网站状态
  137. upRow(id,status){
  138. let data = {
  139. id:id,
  140. status:status
  141. }
  142. this.$store.dispatch('news/upArticleStatus',data).then(res=> {
  143. if(res.code==200){
  144. this.$message({
  145. type: 'success',
  146. message: '职位状态已修改!'
  147. });
  148. }
  149. }).catch(() => {
  150. this.$message({
  151. type: 'warning',
  152. message: '已取消删除'
  153. });
  154. });
  155. },
  156. //1.4 列表内容分页
  157. //直接跳转
  158. handleSizeChange(val) {
  159. this.getApiData.page = val;
  160. this.getData();
  161. },
  162. //1.5 点击分页
  163. handleCurrentChange(val) {
  164. this.getApiData.page = val;
  165. this.getData();
  166. },
  167. //1.6 重置按钮
  168. clearSearchList(){
  169. this.getApiData.keyword = "";
  170. this.getApiData.page = 1;
  171. this.getApiData.page_size = 10;
  172. this.getData();
  173. },
  174. //列表和分页相关 end ------------------------------------------------------------>
  175. //2.添加新闻 start ------------------------------------------------------------>
  176. //跳转到职位发布页面
  177. goCreat(){
  178. this.$router.push({
  179. path: '/creatJob',
  180. });
  181. },
  182. goEdit(id){
  183. let data = {
  184. id:id
  185. }
  186. this.$router.push({
  187. path: '/creatJob',
  188. query: data
  189. });
  190. }
  191. //添加新闻 end ------------------------------------------------------------>
  192. },
  193. mounted(){
  194. //1.获得初始数据
  195. this.getData();
  196. }
  197. }
  198. </script>
  199. <style scoped lang="less">
  200. </style>