赵士淞
2023-01-18 fddeb9856d840c9cf0c0da3282f5ff9eeba2eeb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">员工ID</label>
        <el-input v-model="query.userId" clearable placeholder="员工ID" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">项目ID</label>
        <el-input v-model="query.projectId" clearable placeholder="项目ID" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">绩效年月</label>
        <el-input v-model="query.yearMonth" clearable placeholder="绩效年月" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="员工ID" prop="userId">
            未设置字典,请手动设置 Select
          </el-form-item>
          <el-form-item label="绩效工时" prop="performanceHours">
            <el-input v-model="form.performanceHours" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="项目ID" prop="projectId">
            未设置字典,请手动设置 Select
          </el-form-item>
          <el-form-item label="绩效年月" prop="yearMonth">
            <el-date-picker v-model="form.yearMonth" type="datetime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="userId" label="员工ID" />
        <el-table-column prop="performanceHours" label="绩效工时" />
        <el-table-column prop="projectId" label="项目ID" />
        <el-table-column prop="yearMonth" label="绩效年月" />
        <el-table-column v-if="checkPer(['admin','projectPerformanceDetail:edit','projectPerformanceDetail:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>
 
<script>
import crudProjectPerformanceDetail from '@/api/projectPerformanceDetail'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
 
const defaultForm = { id: null, userId: null, performanceHours: null, projectId: null, yearMonth: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'ProjectPerformanceDetail',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '项目绩效详细', url: 'api/projectPerformanceDetail', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectPerformanceDetail }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'projectPerformanceDetail:add'],
        edit: ['admin', 'projectPerformanceDetail:edit'],
        del: ['admin', 'projectPerformanceDetail:del']
      },
      rules: {
        userId: [
          { required: true, message: '员工ID不能为空', trigger: 'blur' }
        ],
        performanceHours: [
          { required: true, message: '绩效工时不能为空', trigger: 'blur' }
        ],
        projectId: [
          { required: true, message: '项目ID不能为空', trigger: 'blur' }
        ],
        yearMonth: [
          { required: true, message: '绩效年月不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'userId', display_name: '员工ID' },
        { key: 'projectId', display_name: '项目ID' },
        { key: 'yearMonth', display_name: '绩效年月' }
      ]
    }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>
 
<style scoped>
 
</style>