Blame view

src/views/org/scheduleClassesPageList.vue 8.88 KB
03f63ab4   wuxw   优化到商户信息
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
  <template>
    <div class="schedule-classes-container animated fadeInRight">
      <!-- 查询条件 -->
      <el-card class="box-card">
        <div slot="header" class="flex justify-between">
          <span>{{ $t('scheduleClassesPage.searchConditions') }}</span>
          <el-button style="float: right; padding: 3px 0" type="text" @click="_moreCondition()">
            {{ scheduleClassesPageInfo.moreCondition ? $t('common.hide') : $t('common.more') }}
          </el-button>
        </div>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-input v-model="scheduleClassesPageInfo.conditions.staffNameLike"
              :placeholder="$t('scheduleClassesPage.staffNamePlaceholder')" clearable />
          </el-col>
          <el-col :span="8">
            <el-select v-model="scheduleClassesPageInfo.conditions.scheduleId" style="width:100%"
              :placeholder="$t('scheduleClassesPage.schedulePlaceholder')">
              <el-option :label="$t('scheduleClassesPage.selectSchedule')" value="" />
              <el-option v-for="(item, index) in scheduleClassesPageInfo.scheduleClassess" :key="index" :label="item.name"
                :value="item.scheduleId" />
            </el-select>
          </el-col>
          <el-col :span="6">
            <el-date-picker v-model="scheduleClassesPageInfo.conditions.curDate" type="month"
              :placeholder="$t('scheduleClassesPage.datePlaceholder')" format="yyyy-MM" value-format="yyyy-MM"
              style="width:100%" @change="handleDateChange" />
          </el-col>
          <el-col :span="4">
            <el-button type="primary" @click="_queryScheduleClassesMethod()">
              {{ $t('common.search') }}
            </el-button>
            <el-button type="primary" @click="_exportScheduleClasses()">
              <i class="el-icon-upload" />
              {{ $t('common.export') }}
            </el-button>
          </el-col>
        </el-row>
  
        <el-row v-show="scheduleClassesPageInfo.moreCondition" :gutter="20" style="margin-top:15px">
          <el-col :span="6">
            <el-input v-model="scheduleClassesPageInfo.conditions.orgName" readonly
              :placeholder="$t('scheduleClassesPage.orgPlaceholder')" @focus="_staffChangeOrg()" />
          </el-col>
        </el-row>
      </el-card>
  
      <!-- 排班表 -->
      <el-card class="box-card" style="margin-top:20px">
        <div slot="header" class="flex justify-between">
          <span>{{ $t('scheduleClassesPage.scheduleTable') }}</span>
        </div>
27dcfde5   wuxw   系统全面测试完成
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
        <div class="hc-table-div" >
          <table class="custom-table">
            <thead>
              <tr>
                <th
                  style=" text-align: center;  border: 1px solid #ebeef5; background-color: #fafafa;">
                  {{ $t('scheduleClassesPage.staffName') }}
                </th>
                <th v-for="index in scheduleClassesPageInfo.maxDay" :key="index"
                  style="text-align: center;  border: 1px solid #ebeef5; background-color: #fafafa;">
                  {{ index }}{{ $t('scheduleClassesPage.day') }}
                </th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(staff, staffIndex) in scheduleClassesPageInfo.staffs" :key="staffIndex">
                <td style="text-align: center;  border: 1px solid #ebeef5;" class="padding-lg">
                  {{ staff.staffName }}
                </td>
                <td v-for="(day, dayIndex) in staff.days" :key="dayIndex"
                  style="text-align: center; border: 1px solid #ebeef5; vertical-align: top;">
                  <div class="text-center border padding-lg labeling-strip"
                    style="border-radius: 5px; cursor: pointer; margin: 2px 0;">
                    <div>{{ day.workdayName || $t('scheduleClassesPage.rest') }}</div>
                    <div v-for="(time, timeIndex) in day.times" :key="timeIndex">
                      {{ time.startTime }}-{{ time.endTime }}
                    </div>
03f63ab4   wuxw   优化到商户信息
80
                  </div>
27dcfde5   wuxw   系统全面测试完成
81
82
83
84
                </td>
              </tr>
            </tbody>
          </table>
03f63ab4   wuxw   优化到商户信息
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
        </div>
  
        <!-- 分页 -->
        <el-pagination :current-page.sync="page.current" :page-sizes="[10, 20, 30, 50]" :page-size="page.size"
          :total="page.total" layout="total, sizes, prev, pager, next, jumper" style="margin-top:20px;text-align:right"
          @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </el-card>
  
      <!-- 选择组织弹窗 -->
      <choose-org-tree ref="chooseOrgTree" @switchOrg="handleSwitchOrg" />
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { listScheduleClasses, staffMonthScheduleClasses, exportData } from '@/api/org/scheduleClassesPageApi'
  import ChooseOrgTree from '@/components/org/ChooseOrgTree'
  
  export default {
    name: 'ScheduleClassesPageList',
    components: {
      ChooseOrgTree
    },
    data() {
      return {
        communityId: '',
        scheduleClassesPageInfo: {
          staffs: [],
          scheduleClassess: [],
          maxDay: 30,
          curMonth: '',
          curYear: '',
          total: 0,
          records: 1,
          moreCondition: false,
          conditions: {
            staffNameLike: '',
            scheduleId: '',
            curDate: '',
            orgId: '',
            orgName: ''
          }
        },
        page: {
          current: 1,
          size: 10,
          total: 0
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.initStaffDate()
      this._listScheduleClassess()
      this._listStaffScheduleClassess(this.page.current, this.page.size)
    },
    methods: {
      initStaffDate() {
        const date = new Date()
        this.scheduleClassesPageInfo.curMonth = date.getMonth() + 1
        this.scheduleClassesPageInfo.curYear = date.getFullYear()
        this.scheduleClassesPageInfo.conditions.curDate = `${date.getFullYear()}-${date.getMonth() + 1}`
        this.scheduleClassesPageInfo.maxDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate()
      },
      handleDateChange(val) {
        if (val) {
          const values = val.split('-')
          this.scheduleClassesPageInfo.curYear = values[0]
          this.scheduleClassesPageInfo.curMonth = values[1]
          this._listStaffScheduleClassess(this.page.current, this.page.size)
        }
      },
      async _listStaffScheduleClassess(page, size) {
        try {
          const params = {
            ...this.scheduleClassesPageInfo.conditions,
            page,
            row: size,
            communityId: this.communityId
          }
          const { data, total, records } = await staffMonthScheduleClasses(params)
          this.scheduleClassesPageInfo.staffs = data
          this.scheduleClassesPageInfo.total = total
          this.scheduleClassesPageInfo.records = records
          this.page.total = total
        } catch (error) {
          console.error('获取员工排班表失败:', error)
        }
      },
      async _listScheduleClassess() {
        try {
          const params = {
            page: 1,
            row: 100,
            communityId: this.communityId
          }
          const { data } = await listScheduleClasses(params)
          this.scheduleClassesPageInfo.scheduleClassess = data
        } catch (error) {
          console.error('获取班次列表失败:', error)
        }
      },
      _queryScheduleClassesMethod() {
        this.page.current = 1
        this._listStaffScheduleClassess(this.page.current, this.page.size)
      },
      _moreCondition() {
        this.scheduleClassesPageInfo.moreCondition = !this.scheduleClassesPageInfo.moreCondition
      },
      async _exportScheduleClasses() {
        try {
          const params = {
            ...this.scheduleClassesPageInfo.conditions,
            communityId: this.communityId,
            pagePath: 'reportStaffMonthScheduleClasses'
          }
          await exportData(params)
          this.$message.success(this.$t('common.exportSuccess'))
        } catch (error) {
          console.error('导出失败:', error)
          this.$message.error(this.$t('common.exportFailed'))
        }
      },
      _staffChangeOrg() {
        this.$refs.chooseOrgTree.open()
      },
      handleSwitchOrg(org) {
        this.scheduleClassesPageInfo.conditions.orgId = org.orgId
        this.scheduleClassesPageInfo.conditions.orgName = org.allOrgName
      },
27dcfde5   wuxw   系统全面测试完成
215
  
03f63ab4   wuxw   优化到商户信息
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
      handleSizeChange(val) {
        this.page.size = val
        this._listStaffScheduleClassess(this.page.current, val)
      },
      handleCurrentChange(val) {
        this.page.current = val
        this._listStaffScheduleClassess(val, this.page.size)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .schedule-classes-container {
    padding: 20px;
  
    .box-card {
      margin-bottom: 20px;
    }
  
    .hc-table-div {
      overflow-x: auto;
    }
  
27dcfde5   wuxw   系统全面测试完成
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
    .custom-table {
      width: 100%;
      border-collapse: collapse;
      border: 1px solid #ebeef5;
  
      th,
      td {
        border: 1px solid #ebeef5;
        padding: 12px 8px;
        text-align: center;
      }
  
      th {
        background-color: #fafafa;
        font-weight: 500;
        color: #606266;
      }
  
      td {
        background-color: #fff;
      }
  
      tbody tr:hover {
        background-color: #f5f7fa;
      }
    }
  
03f63ab4   wuxw   优化到商户信息
267
    .labeling-strip {
03f63ab4   wuxw   优化到商户信息
268
269
270
271
272
      margin: 2px;
      border: 1px solid #ebeef5;
    }
  }
  </style>