|
@@ -0,0 +1,142 @@
|
|
|
+<template>
|
|
|
+ <section>
|
|
|
+ <h4 style="width:450px;margin:0 auto;">工作时长设置</h4>
|
|
|
+ <!--设置内容-->
|
|
|
+ <el-form style="width:500px;margin:0 auto;padding:10px;" ref="form1" :model="timeType" :rules="rules" label-width="100px">
|
|
|
+ <el-form-item label="全天时长" prop="allday">
|
|
|
+ <el-select v-model="timeType.allday" placeholder="请选择工作时长" style="width:120px;" @change="timeChange">
|
|
|
+ <el-option v-for="item in times" :key="item" :label="item" :value="item"></el-option>
|
|
|
+ </el-select>
|
|
|
+ 小时
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="上午时长" prop="am" >
|
|
|
+ <el-select v-model="timeType.am" placeholder="请选择工作时长" style="width:120px;" @change="timeChange">
|
|
|
+ <el-option v-for="item in halfTime" :key="item" :label="item" :value="item"></el-option>
|
|
|
+ </el-select>
|
|
|
+ 小时
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="下午时长" prop="pm" >
|
|
|
+ <el-select v-model="timeType.pm" disabled placeholder="请选择工作时长" style="width:120px;" >
|
|
|
+ <el-option v-for="item in halfTime" :key="item" :label="item" :value="item"></el-option>
|
|
|
+ </el-select>
|
|
|
+ 小时
|
|
|
+ </el-form-item>
|
|
|
+ <div style="float:right;margin-right:300px;" >
|
|
|
+ <el-button type="primary" @click="submitInsert" :loading="addLoading">保存</el-button>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ </section>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import util from "../../common/js/util";
|
|
|
+
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ times:[],
|
|
|
+ halfTime:[],
|
|
|
+ user: JSON.parse(sessionStorage.getItem("user")),
|
|
|
+ timeType:{},
|
|
|
+ rules: {
|
|
|
+ allday: [{ required: true, message: "请选择全天工作时长", trigger: "blur" }],
|
|
|
+ am: [{ required: true, message: "请输入上午工作时长", trigger: "blur" }],
|
|
|
+ pm: [{ required: true, message: "请输入下午工作时长", trigger: "blur" }],
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ timeChange() {
|
|
|
+ this.halfTime = [];
|
|
|
+ for (var i=1;i<=this.timeType.allday; i++) {
|
|
|
+ this.halfTime.push(i);
|
|
|
+ }
|
|
|
+ if (this.timeType.allday < this.timeType.am) {
|
|
|
+ this.timeType.am = this.timeType.allday;
|
|
|
+ }
|
|
|
+ this.timeType.pm = this.timeType.allday - this.timeType.am;
|
|
|
+
|
|
|
+ },
|
|
|
+ initTime() {
|
|
|
+ for (var i=1; i<=24; i++) {
|
|
|
+ this.times.push(i);
|
|
|
+ if ( i <= 12) {
|
|
|
+ this.halfTime.push(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ submitInsert() {
|
|
|
+ this.$refs.form1.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.http.post('/time-type/save',this.timeType,
|
|
|
+ res => {
|
|
|
+ this.listLoading = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: '保存成功',
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ this.listLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取本公司的工作时间设置
|
|
|
+ getCompanyTimeSetting() {
|
|
|
+ this.http.post('/time-type/getCompanyTimeSetting',{
|
|
|
+ companyId: this.user.companyId
|
|
|
+ },
|
|
|
+ res => {
|
|
|
+ this.listLoading = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.timeType = res.data;
|
|
|
+ this.timeChange();
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ this.listLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ let height = window.innerHeight;
|
|
|
+ this.tableHeight = height - 195;
|
|
|
+ const that = this;
|
|
|
+ window.onresize = function temp() {
|
|
|
+ that.tableHeight = window.innerHeight - 195;
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.initTime();
|
|
|
+ this.getCompanyTimeSetting();
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|