yaozc
2023-04-28 bdf99bb9ab8b0250c073e85e4d676c3c745aed8b
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-select v-model="query.businessPlanId" clearable placeholder="所属营业计划" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in businessPlanList"
            :key="item.id"
            :label="item.businessContent"
            :value="item.id"
          />
        </el-select>
        <el-select v-model="query.userId" clearable placeholder="所属用户" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in userList"
            :key="item.id"
            :label="item.nickName"
            :value="item.id"
          />
        </el-select>
        <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="600px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="140px">
          <el-form-item label="所属营业计划" prop="businessPlanId">
            <el-select v-model="form.businessPlanId" placeholder="请选择" filterable clearable style="width: 410px;">
              <el-option
                v-for="item in businessPlanList"
                :key="item.id"
                :label="item.businessContent"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="所属用户" prop="userId">
            <el-select v-model="form.userId" placeholder="请选择" filterable clearable style="width: 410px;">
              <el-option
                v-for="item in userList"
                :key="item.id"
                :label="item.nickName"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="营业计划开始日期" prop="businessPlanStartDate">
            <el-date-picker v-model="form.businessPlanStartDate" type="date" style="width: 410px;" />
          </el-form-item>
          <el-form-item label="营业计划结束日期" prop="businessPlanEndDate">
            <el-date-picker v-model="form.businessPlanEndDate" type="date" style="width: 410px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 410px;" />
          </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 :show-overflow-tooltip="true" prop="businessPlanContent" label="所属营业计划" />
        <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属用户" />
        <el-table-column :show-overflow-tooltip="true" prop="businessPlanStartDate" label="营业计划开始日期">
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.businessPlanStartDate) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="businessPlanEndDate" label="营业计划结束日期">
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.businessPlanEndDate) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
        <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" />
        <el-table-column v-if="checkPer(['admin','businessPlanPersonnel:edit','businessPlanPersonnel: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 crudBusinessPlanPersonnel from '@/api/business/planPersonnel'
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'
import crudBusinessPlan from '@/api/business/plan'
import crudUser from '@/api/system/user'
 
const defaultForm = { id: null, businessPlanId: null, userId: null, businessPlanStartDate: null, businessPlanEndDate: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'BusinessPlanPersonnel',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '营业计划人员', url: 'api/businessPlanPersonnel', idField: 'id', sort: 'id,desc', crudMethod: { ...crudBusinessPlanPersonnel }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'businessPlanPersonnel:add'],
        edit: ['admin', 'businessPlanPersonnel:edit'],
        del: ['admin', 'businessPlanPersonnel:del'],
        download: ['admin', 'businessPlanPersonnel:download']
      },
      rules: {
        businessPlanId: [
          { required: true, message: '所属营业计划不能为空', trigger: 'change' }
        ],
        userId: [
          { required: true, message: '所属用户不能为空', trigger: 'change' }
        ],
        businessPlanStartDate: [
          { required: true, message: '营业计划开始日期不能为空', trigger: 'change' }
        ],
        businessPlanEndDate: [
          { required: true, message: '营业计划结束日期不能为空', trigger: 'change' }
        ]
      },
      queryTypeOptions: [
        { key: 'businessPlanId', display_name: '所属营业计划' },
        { key: 'userId', display_name: '所属用户' }
      ],
      // 营业计划列表
      businessPlanList: [],
      // 用户列表
      userList: []
    }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 获取营业计划
      this.getBusinessPlan()
      // 获取用户
      this.getUser()
      return true
    },
    // 获取营业计划
    getBusinessPlan() {
      // 获取营业计划
      crudBusinessPlan.getAll().then(res => {
        // 营业计划列表
        this.businessPlanList = res
      })
    },
    // 获取用户
    getUser() {
      // 获取用户
      crudUser.getAll().then(res => {
        // 用户列表
        this.userList = res
      })
    }
  }
}
</script>
 
<style scoped>
 
</style>