cloud_job.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view 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. <z-table :data="tableData" :keys="tableProps" :labels="tableHeaders" />
  9. <!-- <el-pagination
  10. @current-change="changePagination"
  11. :current-page.sync="currentPage"
  12. :page-size="20"
  13. layout="total, prev, pager, next"
  14. :total="totalCount"
  15. :pager-count="7"
  16. ></el-pagination> -->
  17. </view>
  18. </template>
  19. <script>
  20. import tableMixin from '../mixins/table'
  21. const tableHeaders = [
  22. '企业方',
  23. '名称',
  24. '地点',
  25. '简介',
  26. '核定价格/预算区间',
  27. '已完成月数',
  28. '用户来源',
  29. '审核人员',
  30. '创建时间',
  31. '状态',
  32. '操作'
  33. ]
  34. const tableProps = [
  35. 'nickname',
  36. 'title',
  37. 'address',
  38. 'description',
  39. 'salary',
  40. 'work_hours',
  41. 'remark_user_from',
  42. 'remark_checked_user',
  43. 'create_time',
  44. 'status',
  45. 'ctrl'
  46. ]
  47. export default {
  48. mixins: [tableMixin],
  49. data() {
  50. return {
  51. // 筛选状态
  52. statuses: [],
  53. selected: '',
  54. // 数据总条目
  55. totalCount: 0,
  56. currentPage: 1,
  57. // 列表头显示内容
  58. tableHeaders,
  59. // 列表头字段
  60. tableProps,
  61. // 列表数据
  62. tableData: []
  63. }
  64. },
  65. mounted() {
  66. this.getFilters()
  67. },
  68. methods: {
  69. // 筛选框变动
  70. changeSelect(index) {
  71. this.currentPage = 1
  72. this.getTableData(index)
  73. },
  74. // 获取筛选
  75. async getFilters() {
  76. const res = await this.$post('/api/admin/job/job_status_map')
  77. const data = res.data
  78. this.statuses = data || []
  79. if(data.length) this.selected = data[0]
  80. this.getTableData()
  81. },
  82. // 点击详情
  83. clickDetail(id) {
  84. window.open(`/rooter/cloudjobitem/${id}`)
  85. },
  86. // 根据状态显示图表样式
  87. tableRowClassName({ row, rowIndex }) {
  88. // console.log({row, rowIndex})
  89. let className = ''
  90. if(row.status === '1') className = 'success-row'
  91. return className
  92. },
  93. // 格式化列表数据
  94. formatTableData(data) {
  95. return data.map(i => ({
  96. ...i,
  97. nickname: i.companyUser.nickname,
  98. ctrl: '详情',
  99. }))
  100. },
  101. // 页码变动
  102. changePagination(page) {
  103. this.getTableData()
  104. },
  105. // 获取列表数据
  106. async getTableData(status = 0) {
  107. const p = this.currentPage
  108. const res = await this.$post('/api/admin/job/jobs', { p, status })
  109. // console.log(res)
  110. const data = res.data
  111. const list = data.list
  112. this.tableData = this.formatTableData(list)
  113. this.totalCount = Number(data.total)
  114. this.totalPage = data.totalPage
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang='less' scoped>
  120. #cloud-job {
  121. .table {
  122. height: 100%;
  123. height: calc(100% - 80px);
  124. }
  125. }
  126. </style>