New file |
| | |
| | | <template> |
| | | <el-dialog :close-on-click-modal="false" :visible.sync="islook" width="35rem" class="add-rule-set-dialog" |
| | | @close="shutdown"> |
| | | <div slot="title" class="tac drawerHeader">规则设置</div> |
| | | <div class="dialog-content-box"> |
| | | <el-form ref="form" class="form-box" :rules="rules" :model="form" |
| | | label-width="150px" |
| | | label-position="right"> |
| | | <el-form-item label="工作日加班规则:" prop="weekdayRule"> |
| | | <el-radio-group v-model="form.weekdayRule"> |
| | | <el-radio :label="1" style="width:100%"> |
| | | 不启用工作日加班 |
| | | </el-radio> |
| | | <el-radio :label="2" style="width:100%"> |
| | | 超过 |
| | | <el-form-item label="" label-width="0" |
| | | class="margin_left_10px margin_right_10px" |
| | | style="width:120px;display:inline-block" |
| | | prop="overTimeStart" |
| | | :rules="[{ required: form.weekdayRule==2? true : false, message: '请输入' },{ |
| | | validator: this.validatorNum, |
| | | trigger: 'blur', |
| | | }]"> |
| | | <el-input v-model.number="form.overTimeStart" |
| | | placeholder="请输入"></el-input> |
| | | </el-form-item> |
| | | 小时算加班 |
| | | </el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="休息日加班规则:" prop="restDayRule"> |
| | | <el-radio-group v-model="form.restDayRule"> |
| | | <el-radio :label="1" style="width:100%"> |
| | | 不启用休息日加班 |
| | | </el-radio> |
| | | <el-radio :label="2" style="width:100%"> |
| | | 超过 |
| | | <el-form-item label="" label-width="0" prop="restDayStart" |
| | | class="margin_left_10px margin_right_10px" |
| | | style="width:120px;display:inline-block" |
| | | :rules="[{ required: form.restDayRule==2? true : false, message: '请输入' },{ |
| | | validator: this.validatorNum, |
| | | trigger: 'blur', |
| | | }]"> |
| | | <el-input v-model.number="form.restDayStart" |
| | | placeholder="请输入"></el-input> |
| | | </el-form-item> |
| | | 小时算加班 |
| | | </el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <div slot="footer" class="dialog-footer tac"> |
| | | <el-button @click="shutdown">取消</el-button> |
| | | <el-button type="primary" @click="onSubmit(form)">确定</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getAttendanceRule,saveAttendanceRule } from "@/api/employeeSalary/attendanceManage.js" |
| | | export default { |
| | | props: {}, |
| | | data() { |
| | | return { |
| | | islook: false, |
| | | form: { |
| | | weekdayRule: 1, |
| | | overTimeStart: null, |
| | | restDayRule:1, |
| | | restDayStart:null, |
| | | }, |
| | | rules: { |
| | | cycle: [ |
| | | { |
| | | required: true, |
| | | message: "请输入", |
| | | trigger: "blur", |
| | | }, |
| | | { |
| | | validator: this.validatorNum, |
| | | trigger: "blur", |
| | | }, |
| | | ], |
| | | }, |
| | | procedureIdsList: [], |
| | | }; |
| | | }, |
| | | mounted() { |
| | | }, |
| | | watch: { |
| | | islook(newVal) { |
| | | if (newVal) { |
| | | this.getAttendanceRule(); |
| | | this.$nextTick(() => { |
| | | this.$refs["form"].resetFields(); |
| | | }); |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | validatorNum(rule, value, callback) { |
| | | if (value) { |
| | | if (value == undefined || value == null) { |
| | | callback(new Error("请输入有效数字")); |
| | | } else { |
| | | var reg = /^\+?[1-9]\d*$/; |
| | | if (!reg.test(value)) { |
| | | callback(new Error("请填写不小于0的数字")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | } else { |
| | | callback(); |
| | | } |
| | | }, |
| | | async getAttendanceRule() { |
| | | await getAttendanceRule().then((res) => { |
| | | if (res.code == 200) { |
| | | if (res.data) { |
| | | this.form=JSON.parse(JSON.stringify(res.data)); |
| | | this.form.overTimeStart=this.form.overTimeStart==0?null:this.form.overTimeStart |
| | | this.form.restDayStart=this.form.restDayStart==0?null:this.form.restDayStart |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | onSubmit() { |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | console.log(this.form); |
| | | let params =JSON.parse(JSON.stringify(this.form)); |
| | | params.overTimeStart=Number(params.overTimeStart) |
| | | params.restDayStart=Number(params.restDayStart) |
| | | saveAttendanceRule(params).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "保存成功!", |
| | | type: "success", |
| | | }); |
| | | // 保存 |
| | | this.shutdown("save"); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | shutdown(val) { |
| | | this.islook = false; |
| | | this.$emit("closeClick", val); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .add-rule-set-dialog { |
| | | .form-box { |
| | | .el-form-item { |
| | | width: 100%; |
| | | .el-radio{ |
| | | height:40px; |
| | | line-height:40px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | ::v-deep .el-input__inner { |
| | | font-size: 13px !important; |
| | | color: rgba(0, 0, 0, 0.9); |
| | | text-align: left; |
| | | } |
| | | </style> |