Blame view

src/views/oa/addAttendanceClassesStaffList.vue 3.74 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
d4a6b78f   wuxw   OA 中考勤功能开发完成
2
3
    <div class="add-attendance-classes-staff-container">
      <el-card>
caba9d96   wuxw   oa 中除了 工作办理没有测试其他...
4
        <div slot="header" class="flex justify-between">
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
          <span>{{ $t('addAttendanceClassesStaff.title') }}</span>
          <el-button type="primary" size="small" class="float-right" @click="handleGoBack">
            <i class="el-icon-close"></i>
            {{ $t('common.back') }}
          </el-button>
        </div>
  
        <el-row>
          <el-col :span="24">
            <el-form label-width="120px">
              <el-form-item :label="$t('addAttendanceClassesStaff.staffName')" class="text-left">
                <el-input v-model="form.staffName" style="width: 80%;" :placeholder="$t('addAttendanceClassesStaff.staffNamePlaceholder')"
                  disabled></el-input>
                <el-button type="primary" @click="handleChooseStaff" class="ml-10">
                  <i class="el-icon-search"></i>
                  {{ $t('common.select') }}
                </el-button>
              </el-form-item>
  
              <el-form-item :label="$t('addAttendanceClassesStaff.attendanceFace')">
                <upload-image-url ref="uploadImage" :image-count="1"
                @notifyUploadCoverImage="handleImageUpload"></upload-image-url>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
  
        <div class="text-right mt-20">
          <el-button type="warning" @click="handleGoBack" class="mr-20">
            {{ $t('common.back') }}
          </el-button>
          <el-button type="primary" @click="handleSubmit">
            <i class="el-icon-check"></i>
            {{ $t('common.submit') }}
          </el-button>
        </div>
      </el-card>
  
      <select-staff ref="selectStaff" @selectStaff="handleStaffChange"></select-staff>
    </div>
  </template>
  
  <script>
  import UploadImageUrl from '@/components/upload/UploadImageUrl'
  import SelectStaff from '@/components/staff/SelectStaff'
  import { saveAttendanceClassesStaff } from '@/api/oa/addAttendanceClassesStaffApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'AddAttendanceClassesStaffList',
    components: {
      UploadImageUrl,
      SelectStaff
    },
    data() {
      return {
        form: {
          csId: '',
          classesId: '',
          staffId: '',
          staffName: '',
          photo: '',
          communityId: ''
        }
      }
    },
    created() {
      this.form.classesId = this.$route.query.classesId
      this.form.communityId = getCommunityId()
    },
    methods: {
      handleChooseStaff() {
        this.$refs.selectStaff.open(this.form)
      },
      handleStaffChange(staff) {
        this.form.staffId = staff.staffId
        this.form.staffName = staff.staffName
      },
      handleImageUpload(photos) {
        if (photos.length > 0) {
          this.form.photo = photos[0]
        }
      },
      async handleSubmit() {
        if (!this.validateForm()) {
          return
        }
  
        try {
          const res = await saveAttendanceClassesStaff(this.form)
          if (res.code === 0) {
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
96
            this.$message.success(this.$t('common.operationSuccess'))
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
            this.handleGoBack()
          } else {
            this.$message.error(res.msg)
          }
        } catch (error) {
          this.$message.error(this.$t('common.addFailed'))
        }
      },
      validateForm() {
        if (!this.form.staffName) {
          this.$message.error(this.$t('addAttendanceClassesStaff.staffNameRequired'))
          return false
        }
        return true
      },
      handleGoBack() {
        this.$router.go(-1)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .add-attendance-classes-staff-container {
    padding: 20px;
  
    .el-form-item {
      margin-bottom: 22px;
    }
  
    .ml-10 {
      margin-left: 10px;
    }
  
    .mt-20 {
      margin-top: 20px;
    }
  
    .mr-20 {
      margin-right: 20px;
    }
  
    .text-right {
      text-align: right;
    }
  
    .float-right {
      float: right;
    }
  }
  </style>