cloud_job.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div id="cloud-job">
  3. <el-select v-model="selected" @change="changeSelect" placeholder="筛选">
  4. <el-option v-for="(item, index) of statuses" :key="index" :label="item" :value="index">
  5. <span>{{item}}</span>
  6. </el-option>
  7. </el-select>
  8. <div class="table">
  9. <el-table
  10. v-if="tableData.length"
  11. height="100%"
  12. border
  13. style="width: 100%"
  14. :data="tableData"
  15. :row-class-name="tableRowClassName"
  16. >
  17. <el-table-column
  18. v-for="(prop, index) of tableProps"
  19. :key="index"
  20. :prop="prop"
  21. :label="tableHeaders[index]"
  22. >
  23. <template slot-scope="scope">
  24. <el-button
  25. type="text"
  26. v-if="prop === 'ctrl'"
  27. @click="clickDetail(scope.row['id'])"
  28. >{{scope.row[prop]}}</el-button>
  29. <span v-else-if="prop === 'status'">{{scope.row['statusName']}}</span>
  30. <span v-else>{{scope.row[prop]}}</span>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. </div>
  35. <el-pagination
  36. @current-change="changePagination"
  37. :current-page.sync="currentPage"
  38. :page-size="10"
  39. layout="total, prev, pager, next"
  40. :total="totalCount"
  41. ></el-pagination>
  42. </div>
  43. </template>
  44. <script>
  45. const tableHeaders = [
  46. "企业方",
  47. "名称",
  48. "地点",
  49. "简介",
  50. "核定价格/预算区间",
  51. "已完成月数",
  52. "用户来源",
  53. "审核人员",
  54. "创建时间",
  55. "状态",
  56. "操作"
  57. ]
  58. const tableProps = [
  59. "nickname",
  60. "title",
  61. "address",
  62. "description",
  63. "salary",
  64. "work_hours",
  65. "remark_user_from",
  66. "remark_checked_user",
  67. "createTime",
  68. "status",
  69. "ctrl"
  70. ]
  71. export default {
  72. data() {
  73. return {
  74. // 筛选状态
  75. statuses: [],
  76. selected: "",
  77. // 数据总条目
  78. totalCount: 0,
  79. currentPage: 1,
  80. // 列表头显示内容
  81. tableHeaders,
  82. // 列表头字段
  83. tableProps,
  84. // 列表数据
  85. tableData: []
  86. }
  87. },
  88. mounted() {
  89. this.getFilters()
  90. },
  91. methods: {
  92. // 筛选框变动
  93. changeSelect(index) {
  94. this.currentPage = 1
  95. this.getTableData(index)
  96. },
  97. // 获取筛选
  98. async getFilters() {
  99. const res = await this.$post("/api/admin/job/job_status_map")
  100. const data = res.data
  101. this.statuses = data || []
  102. if(data.length) this.selected = data[0]
  103. this.getTableData()
  104. },
  105. // 点击详情
  106. clickDetail(id) {
  107. window.open(`/rooter/cloudjobitem/${id}`)
  108. },
  109. // 根据状态显示图表样式
  110. tableRowClassName({ row, rowIndex }) {
  111. // console.log({row, rowIndex})
  112. let className = ""
  113. if(row.status === "1") className = "success-row"
  114. return className
  115. },
  116. // 格式化列表数据
  117. formatTableData(data) {
  118. return data.map(i => ({
  119. ...i,
  120. nickname: i.companyUser.nickname,
  121. ctrl: "详情"
  122. }))
  123. },
  124. // 页码变动
  125. changePagination(page) {
  126. this.getTableData()
  127. },
  128. // 获取列表数据
  129. async getTableData(status = 0) {
  130. this.tableData = []
  131. const p = this.currentPage
  132. const res = await this.$post("/api/admin/job/jobs", { p, status })
  133. // console.log(res)
  134. const data = res.data
  135. const list = data.list
  136. this.tableData = this.formatTableData(list)
  137. this.totalCount = Number(data.total)
  138. this.totalPage = data.totalPage
  139. }
  140. }
  141. }
  142. </script>
  143. <style scoped>
  144. .table {
  145. height: 100%;
  146. height: calc(100% - 80px);
  147. }
  148. </style>