eladmin-web-master/src/views/attendance/attendanceBusinessTravel/index.vue
@@ -3,7 +3,15 @@ <!--工具栏--> <div class="head-container"> <div> <el-select v-model="query.userId" filterable clearable placeholder="申请人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.userId" filterable clearable placeholder="申请人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in users" :key="item.id" @@ -11,7 +19,15 @@ :value="item.id" /> </el-select> <el-select v-model="query.approvalUserId" filterable clearable placeholder="审批者" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.approvalUserId" filterable clearable placeholder="审批者" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in users" :key="item.id" @@ -19,7 +35,15 @@ :value="item.id" /> </el-select> <el-select v-model="query.approvalStatus" filterable clearable placeholder="审批状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.approvalStatus" filterable clearable placeholder="审批状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in dict[dictBussinessStatus]" :key="item.value" @@ -44,6 +68,7 @@ class="filter-item" value-format="yyyy-MM-dd HH:mm:ss" placeholder="出差结束日期" @change="handleDateChange" /> <rrOperation /> </div> @@ -51,12 +76,16 @@ <crudOperation :permission="permission"> <el-button slot="right" class="filter-item" size="mini" type="primary" icon="el-icon-circle-check" :disabled="crud.selections.length < 1 || !crud.selections.every(selection => selection.approvalStatus === dictGoOutAppRev)" :disabled=" crud.selections.length < 1 || !crud.selections.every( selection => selection.approvalStatus === dictGoOutAppRev ) " style="margin-left: 4px !important;" @click="toAgree(1, crud.selections)" > @@ -64,12 +93,16 @@ </el-button> <el-button slot="right" class="filter-item" size="mini" type="primary" icon="el-icon-error" :disabled="crud.selections.length < 1 || !crud.selections.every(selection => selection.approvalStatus === dictGoOutAppRev)" :disabled=" crud.selections.length < 1 || !crud.selections.every( selection => selection.approvalStatus === dictGoOutAppRev ) " style="margin-left: 4px !important;" @click="toAgree(2, crud.selections)" > @@ -77,10 +110,29 @@ </el-button> </crudOperation> <!--表单组件--> <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px" > <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px" > <el-form-item label="申请人" prop="userId"> <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form)"> <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form)" > <el-option v-for="item in users" :key="item.id" @@ -91,7 +143,17 @@ </el-select> </el-form-item> <el-form-item label="审批者" prop="approvalUserId"> <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn"> <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " > <el-option v-for="item in approvalUsers" :key="item.id" @@ -111,10 +173,16 @@ align="right" :picker-options="{ disabledDate(time) { return form.travelEndTime ? time.getTime() > new Date(form.travelEndTime).getTime() - 8.64e7 : false; return form.travelEndTime ? time.getTime() > new Date(form.travelEndTime).getTime() - 8.64e7 : false; } }" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " @change="checkTime" /> </el-form-item> @@ -128,42 +196,109 @@ align="right" :picker-options="{ disabledDate(time) { return form.travelStartTime ? time.getTime() < new Date(form.travelStartTime).getTime() - 8.64e7 : false; return form.travelStartTime ? time.getTime() < new Date(form.travelStartTime).getTime() - 8.64e7 : false; } }" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " @change="checkTime" /> </el-form-item> <el-form-item label="出差时长" prop="travelDuration"> <el-input v-model="form.travelDuration" disabled style="width: 340px;"> <template slot="append">{{ dict.label[dictLeaveTimeType][form.durationUnit] }}</template> <el-input v-model="form.travelDuration" disabled style="width: 340px;" > <template slot="append">{{ dict.label[dictLeaveTimeType][form.durationUnit] }}</template> </el-input> </el-form-item> <el-form-item label="出差原因"> <el-input v-model="form.travelReason" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" /> <el-input v-model="form.travelReason" type="textarea" rows="3" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " /> </el-form-item> <el-form-item label="出发城市"> <el-input v-model="form.departureCity" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" /> <el-input v-model="form.departureCity" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " /> </el-form-item> <el-form-item label="到达城市"> <el-input v-model="form.arrivalCity" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" /> <el-input v-model="form.arrivalCity" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " /> </el-form-item> <el-form-item label="审批说明"> <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" disabled /> <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" disabled /> </el-form-item> <el-form-item label="备注"> <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" /> <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " /> </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> <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU" >确认</el-button > </div> </el-dialog> <!--审核表单--> <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" title="出差审批" width="500px"> <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" title="出差审批" width="500px" > <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px" > <el-form-item label="申请人"> {{ form.userName }} </el-form-item> @@ -180,63 +315,188 @@ {{ crud.toDate(form.travelEndTime) }} </el-form-item> <el-form-item label="出差时长"> {{ form.travelDuration + '(' + dict.label[dictLeaveTimeType][form.durationUnit] + ')' }} {{ form.travelDuration + "(" + dict.label[dictLeaveTimeType][form.durationUnit] + ")" }} </el-form-item> <el-form-item label="出差原因"> {{ form.travelReason }} </el-form-item> <el-form-item v-if="form.approvalStatus === dictGoOutReturn" label="退回原因" prop="approvalDescription"> <div style="color: red;">*审核退回需要填写退回原因,请填写后再次点击审核退回</div> <el-input v-model="form.approvalDescription" type="textarea" :rows="3" style="width: 340px;" /> <el-form-item v-if="form.approvalStatus === dictGoOutReturn" label="退回原因" prop="approvalDescription" > <div style="color: red;"> *审核退回需要填写退回原因,请填写后再次点击审核退回 </div> <el-input v-model="form.approvalDescription" type="textarea" :rows="3" style="width: 340px;" /> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="danger" style="margin-right: 10px;" @click="approveFunction(1,form)">审核退回</el-button> <el-button v-if="form.approvalStatus !== dictGoOutReturn" :loading="successLoading" type="success" @click="approveFunction(2,form)">审核通过</el-button> <el-button type="danger" style="margin-right: 10px;" @click="approveFunction(1, form)" >审核退回</el-button > <el-button v-if="form.approvalStatus !== dictGoOutReturn" :loading="successLoading" type="success" @click="approveFunction(2, form)" >审核通过</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 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 prop="userName" label="申请人" width="100" fixed="left" show-overflow-tooltip> <el-table-column prop="userName" label="申请人" width="100" fixed="left" show-overflow-tooltip > <template slot-scope="scope"> <el-tag>{{ scope.row.userName }}</el-tag> </template> </el-table-column> <el-table-column prop="appUserName" label="审批者" width="100" fixed="left" show-overflow-tooltip> <el-table-column prop="appUserName" label="审批者" width="100" fixed="left" show-overflow-tooltip > <template slot-scope="scope"> <el-tag>{{ scope.row.appUserName }}</el-tag> </template> </el-table-column> <el-table-column prop="travelStartTime" label="出差开始时间" width="140" show-overflow-tooltip> <el-table-column prop="travelStartTime" label="出差开始时间" width="140" show-overflow-tooltip > <template slot-scope="scope"> {{ crud.toDate(scope.row.travelStartTime) }} </template> </el-table-column> <el-table-column prop="travelEndTime" label="出差结束时间" width="140" show-overflow-tooltip> <el-table-column prop="travelEndTime" label="出差结束时间" width="140" show-overflow-tooltip > <template slot-scope="scope"> {{ crud.toDate(scope.row.travelEndTime) }} </template> </el-table-column> <el-table-column prop="travelDuration" label="出差时长" width="80" show-overflow-tooltip> <el-table-column prop="travelDuration" label="出差时长" width="80" show-overflow-tooltip > <template slot-scope="scope"> {{ scope.row.travelDuration + '(' + dict.label[dictLeaveTimeType][scope.row.durationUnit] + ')' }} {{ scope.row.travelDuration + "(" + dict.label[dictLeaveTimeType][scope.row.durationUnit] + ")" }} </template> </el-table-column> <el-table-column prop="travelReason" label="出差原因" width="140" show-overflow-tooltip /> <el-table-column prop="departureCity" label="出发城市" width="80" show-overflow-tooltip /> <el-table-column prop="arrivalCity" label="到达城市" width="80" show-overflow-tooltip /> <el-table-column prop="approvalStatus" label="审批状态" width="80" show-overflow-tooltip> <el-table-column prop="travelReason" label="出差原因" width="140" show-overflow-tooltip /> <el-table-column prop="departureCity" label="出发城市" width="80" show-overflow-tooltip /> <el-table-column prop="arrivalCity" label="到达城市" width="80" show-overflow-tooltip /> <el-table-column prop="approvalStatus" label="审批状态" width="80" show-overflow-tooltip > <template slot-scope="scope"> <el-tag v-if="scope.row.approvalStatus === dictGoOutAppRev" type="warning">{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictGoOutAgree" type="success">{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictGoOutReturn" type="danger">{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictGoOutAppRev" type="warning" >{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag > <el-tag v-if="scope.row.approvalStatus === dictGoOutAgree" type="success" >{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag > <el-tag v-if="scope.row.approvalStatus === dictGoOutReturn" type="danger" >{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag > </template> </el-table-column> <el-table-column prop="approvalDescription" label="审批说明" width="140" show-overflow-tooltip /> <el-table-column prop="remarks" label="备注" width="140" show-overflow-tooltip /> <el-table-column prop="createTime" label="创建时间" width="140" show-overflow-tooltip /> <el-table-column v-if="checkPer(['admin','attendanceBusinessTravel:approve'])" label="审核操作" width="180px" align="center" fixed="right"> <el-table-column prop="approvalDescription" label="审批说明" width="140" show-overflow-tooltip /> <el-table-column prop="remarks" label="备注" width="140" show-overflow-tooltip /> <el-table-column prop="createTime" label="创建时间" width="140" show-overflow-tooltip /> <el-table-column v-if="checkPer(['admin', 'attendanceBusinessTravel:approve'])" label="审核操作" width="180px" align="center" fixed="right" > <template slot-scope="scope"> <el-button v-if="scope.row.approvalUserId === $store.state.user.user.id" @@ -245,18 +505,25 @@ size="mini" type="primary" icon="el-icon-s-check" :disabled="scope.row.approvalStatus === dictGoOutAppRev ? false : true" :disabled=" scope.row.approvalStatus === dictGoOutAppRev ? false : true " @click="toApprove(scope.row)" >审核 </el-button> <el-popover :ref="`popover_${scope.row.id}`" width="200" > <el-popover :ref="`popover_${scope.row.id}`" width="200"> <p>确定撤销该记录?</p> <div style="text-align: right; margin: 0"> <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button> <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> <el-button size="mini" type="primary" @click="canel(scope.row)" >取消</el-button > <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)" >确定</el-button > </div> <el-button v-if="scope.row.approvalUserId === $store.state.user.user.id" @@ -265,18 +532,29 @@ type="danger" icon="el-icon-edit-outline" size="mini" :disabled="scope.row.approvalStatus === dictGoOutAppRev ? true : false" :disabled=" scope.row.approvalStatus === dictGoOutAppRev ? true : false " >撤销 </el-button> </el-popover> </template> </el-table-column> <el-table-column v-if="checkPer(['admin','attendanceBusinessTravel:edit','attendanceBusinessTravel:del'])" label="操作" width="150px" align="center" fixed="right"> <el-table-column v-if=" checkPer([ 'admin', 'attendanceBusinessTravel:edit', 'attendanceBusinessTravel:del' ]) " label="操作" width="150px" align="center" fixed="right" > <template slot-scope="scope"> <udOperation :data="scope.row" :permission="permission" /> <udOperation :data="scope.row" :permission="permission" /> </template> </el-table-column> </el-table> @@ -287,60 +565,84 @@ </template> <script> import crudAttendanceBusinessTravel from '@/api/attendance/attendanceBusinessTravel' import CRUD, { presenter, header, form, crud } from '@crud/crud' import rrOperation from '@crud/RR.operation' import crudUser from '@/api/system/user' import { mapGetters } from 'vuex' import crudOperation from '@crud/CRUD.operation' import udOperation from '@crud/UD.operation' import pagination from '@crud/Pagination' import constant from '../../../utils/constant' import crudAttendanceBusinessTravel from "@/api/attendance/attendanceBusinessTravel"; import CRUD, { presenter, header, form, crud } from "@crud/crud"; import rrOperation from "@crud/RR.operation"; import crudUser from "@/api/system/user"; import { mapGetters } from "vuex"; import crudOperation from "@crud/CRUD.operation"; import udOperation from "@crud/UD.operation"; import pagination from "@crud/Pagination"; import constant from "../../../utils/constant"; const defaultForm = { id: null, userId: null, approvalUserId: null, travelStartTime: null, travelEndTime: null, travelDuration: null, durationUnit: null, travelReason: null, departureCity: null, arrivalCity: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } const defaultForm = { id: null, userId: null, approvalUserId: null, travelStartTime: null, travelEndTime: null, travelDuration: null, durationUnit: null, travelReason: null, departureCity: null, arrivalCity: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }; export default { name: 'AttendanceBusinessTravel', name: "AttendanceBusinessTravel", components: { pagination, crudOperation, rrOperation, udOperation }, mixins: [presenter(), header(), form(defaultForm), crud()], cruds() { return CRUD({ title: '出差记录', url: 'api/attendanceBusinessTravel', idField: 'id', sort: 'travelStartTime,desc', crudMethod: { ...crudAttendanceBusinessTravel }}) return CRUD({ title: "出差记录", url: "api/attendanceBusinessTravel", idField: "id", sort: "travelStartTime,desc", crudMethod: { ...crudAttendanceBusinessTravel } }); }, // 数据字典constant dicts: [constant.BUSSINESS_APPROVE_STATUS, constant.LEAVE_TIME_TYPE], data() { return { permission: { add: ['admin', 'attendanceBusinessTravel:add'], edit: ['admin', 'attendanceBusinessTravel:edit'], del: ['admin', 'attendanceBusinessTravel:del'], download: ['admin', 'attendanceBusinessTravel:download'], approve: ['admin', 'attendanceBusinessTravel:approve'], updateAgree: ['admin', 'attendanceBusinessTravel:updateAgree'] add: ["admin", "attendanceBusinessTravel:add"], edit: ["admin", "attendanceBusinessTravel:edit"], del: ["admin", "attendanceBusinessTravel:del"], download: ["admin", "attendanceBusinessTravel:download"], approve: ["admin", "attendanceBusinessTravel:approve"], updateAgree: ["admin", "attendanceBusinessTravel:updateAgree"] }, rules: { userId: [ { required: true, message: '申请人不能为空', trigger: 'change' } { required: true, message: "申请人不能为空", trigger: "change" } ], approvalUserId: [ { required: true, message: '审批者不能为空', trigger: 'change' } { required: true, message: "审批者不能为空", trigger: "change" } ], travelStartTime: [ { required: true, message: '出差开始日期不能为空', trigger: 'change' } { required: true, message: "出差开始日期不能为空", trigger: "change" } ], travelEndTime: [ { required: true, message: '出差结束日期不能为空', trigger: 'change' } { required: true, message: "出差结束日期不能为空", trigger: "change" } ], travelDuration: [ { required: true, message: '出差时长不能为空', trigger: 'blur' } { required: true, message: "出差时长不能为空", trigger: "blur" } ], durationUnit: [ { required: true, message: '时长单位不能为空', trigger: 'change' } { required: true, message: "时长单位不能为空", trigger: "change" } ], approvalDescription: [ { required: true, message: '退回原因不能为空', trigger: 'blur' } { required: true, message: "退回原因不能为空", trigger: "blur" } ], approvalStatus: [ { required: true, message: '审批状态不能为空', trigger: 'change' } { required: true, message: "审批状态不能为空", trigger: "change" } ] }, users: [], @@ -358,182 +660,201 @@ roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY, // 角色级别: 总经理 roleLevelGenerl: constant.ROLE_LEVEL_GENERAL } }; }, computed: { ...mapGetters([ 'user' ]) ...mapGetters(["user"]) }, created() { this.getUsers() this.getApprovalUsers() this.getUsers(); this.getApprovalUsers(); }, methods: { // 钩子:在获取表格数据之前执行,false 则代表不获取数据 [CRUD.HOOK.beforeRefresh]() { // 用户角色级别数组 const userRolesLevel = this.user.roles.map(({ level }) => level) const userRolesLevel = this.user.roles.map(({ level }) => level); // 用户最大角色级别 this.userRolesLevelMin = Math.min(...userRolesLevel) return true this.userRolesLevelMin = Math.min(...userRolesLevel); return true; }, // 钩子:新建 - 之前 [CRUD.HOOK.beforeToAdd]() { this.form.durationUnit = this.dictLeaveTimeTypeDay this.form.durationUnit = this.dictLeaveTimeTypeDay; // 判断用户最大角色级别是否大于总经理角色:赋值 if (this.userRolesLevelMin > this.roleLevelGenerl) { // 表单赋值 this.form.userId = this.user.id this.form.userId = this.user.id; } }, // 禁用 disabledUser(data) { if (this.userRolesLevelMin > this.roleLevelGenerl) { return true return true; } if (data.approvalStatus !== null && data.approvalStatus === this.dictGoOutAgree || data.approvalStatus === this.dictGoOutReturn) { return true if ( (data.approvalStatus !== null && data.approvalStatus === this.dictGoOutAgree) || data.approvalStatus === this.dictGoOutReturn ) { return true; } }, // 查询员工 getUsers() { crudUser.getAll().then(res => { this.users = res }) this.users = res; }); }, // 查询审核人 getApprovalUsers() { crudUser.getApprovalUsers().then(res => { this.approvalUsers = res }) this.approvalUsers = res; }); }, // 设定条件查询日期结尾 handleDateChange(value) { if (value) { this.query.travelEndTime = value.substring(0, 11) + "23:59:59"; } }, // 计算时长 checkTime() { var data = JSON.stringify({ 'travelStartTime': this.form.travelStartTime, 'travelEndTime': this.form.travelEndTime }) travelStartTime: this.form.travelStartTime, travelEndTime: this.form.travelEndTime }); crudAttendanceBusinessTravel.getRemainingTime(data).then(res => { this.form.travelDuration = res }) this.form.travelDuration = res; }); }, // 审批页面赋值 toApprove(data, Number) { if (Number !== '1') { this.makeUpCardVisible = true if (Number !== "1") { this.makeUpCardVisible = true; } this.form.id = data.id this.form.userId = data.userId this.form.userName = data.userName this.form.travelStartTime = data.travelStartTime this.form.travelEndTime = data.travelEndTime this.form.departureCity = data.departureCity this.form.arrivalCity = data.arrivalCity this.form.travelDuration = data.travelDuration this.form.durationUnit = data.durationUnit this.form.approvalStatus = data.approvalStatus this.form.travelReason = data.travelReason this.form.remarks = data.remarks this.form.id = data.id; this.form.userId = data.userId; this.form.userName = data.userName; this.form.travelStartTime = data.travelStartTime; this.form.travelEndTime = data.travelEndTime; this.form.departureCity = data.departureCity; this.form.arrivalCity = data.arrivalCity; this.form.travelDuration = data.travelDuration; this.form.durationUnit = data.durationUnit; this.form.approvalStatus = data.approvalStatus; this.form.travelReason = data.travelReason; this.form.remarks = data.remarks; }, // 审核提交功能 approveFunction(Number, data) { this.form.userId = data.userId const msg = Number === 2 ? '通过' : '拒绝' this.$refs['form'].validate(valid => { this.form.userId = data.userId; const msg = Number === 2 ? "通过" : "拒绝"; this.$refs["form"].validate(valid => { if (!valid) { return return; } // 判断通过状态 if (Number === 2) { this.form.approvalStatus = this.dictGoOutAgree this.form.approvalStatus = this.dictGoOutAgree; } else { // 退回改状态显示退回原因 this.form.approvalStatus = this.dictGoOutReturn this.form.approvalStatus = this.dictGoOutReturn; if (this.form.approvalDescription == null) { return return; } } this.successLoading = true crudAttendanceBusinessTravel.approve(this.form).then(res => { this.crud.refresh() this.makeUpCardVisible = false this.successLoading = false this.successLoading = true; crudAttendanceBusinessTravel .approve(this.form) .then(res => { this.crud.refresh(); this.makeUpCardVisible = false; this.successLoading = false; this.$message({ type: 'success', message: '审核' + msg + '成功' type: "success", message: "审核" + msg + "成功" }); }) }).catch(() => { this.makeUpCardVisible = false this.successLoading = false }) if (this.$refs['form']) { this.$refs['form'].resetFields() .catch(() => { this.makeUpCardVisible = false; this.successLoading = false; }); if (this.$refs["form"]) { this.$refs["form"].resetFields(); } }) }); }, // 批量审核 toAgree(Number, data) { const msg = Number === 2 ? '批量拒绝' : '批量同意' const msg1 = Number === 2 ? 'error' : 'success' const msg = Number === 2 ? "批量拒绝" : "批量同意"; const msg1 = Number === 2 ? "error" : "success"; // 确认框 this.$confirm('此操作将' + msg + '审核内容是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', this.$confirm("此操作将" + msg + "审核内容是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: msg1 }).then(() => { const ids = [] const ids = []; // 循环数据 for (let i = 0; i < data.length; i++) { // ID列表 ids.push(data[i].id) ids.push(data[i].id); } crudAttendanceBusinessTravel.updateAgree({ crudAttendanceBusinessTravel .updateAgree({ num: Number, ids: ids }).then(res => { }) .then(res => { // 消息提示 this.$message({ type: 'success', message: msg + '!' }) type: "success", message: msg + "!" }); // 刷新数据 this.crud.refresh() }) }) this.crud.refresh(); }); }); }, // 撤消功能 revoke(data) { this.toApprove(data, '1') this.form.approvalStatus = this.dictGoOutAppRev this.successLoading = true crudAttendanceBusinessTravel.approve(this.form).then(res => { this.crud.refresh() this.successLoading = false this.$message({ type: 'success', message: '撤销成功' }) this.$refs[`popover_${data.id}`].showPopper = false }).catch((error) => { this.$message({ type: 'error', message: error.response.data.message }) this.toApprove(data, "1"); this.form.approvalStatus = this.dictGoOutAppRev; this.successLoading = true; crudAttendanceBusinessTravel .approve(this.form) .then(res => { this.crud.refresh(); this.successLoading = false; this.$message({ type: "success", message: "撤销成功" }); this.$refs[`popover_${data.id}`].showPopper = false; }) if (this.$refs['form']) { this.$refs['form'].resetFields() .catch(error => { this.$message({ type: "error", message: error.response.data.message }); }); if (this.$refs["form"]) { this.$refs["form"].resetFields(); } this.crud.cancelCU() this.crud.cancelCU(); }, // 关闭 closeCard() { if (this.$refs['form']) { this.$refs['form'].resetFields() if (this.$refs["form"]) { this.$refs["form"].resetFields(); } this.crud.cancelCU() this.makeUpCardVisible = false this.crud.cancelCU(); this.makeUpCardVisible = false; }, // 取消 canel(data) { this.$refs[`popover_${data.id}`].showPopper = false this.$refs[`popover_${data.id}`].showPopper = false; } } } }; </script> <style scoped> eladmin-web-master/src/views/attendance/attendanceCardReplacement/index.vue
@@ -24,12 +24,13 @@ type="daterange" clearable class="filter-item" value-format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择补卡日期" range-separator=" ~ " start-placeholder="开始日期" end-placeholder="结束日期" style="width: 285px;" @change="handleDateChange" /> <el-select v-model="query.approvalStatus" filterable clearable placeholder="审批状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-option @@ -375,6 +376,15 @@ this.approvalUsers = res }) }, // 设定日期结尾 handleDateChange(value) { if (value && value[1]) { this.query.cardReplacementTime[1] = value[1].substring(0,11) + '23:59:59' } }, formatDate(date, time) { return new Date(date.getFullYear(), date.getMonth(), date.getDate(), ...time.split(':')).toISOString(); }, // 审批页面赋值 toApprove(data) { this.makeUpCardVisible = true eladmin-web-master/src/views/attendance/attendanceGoOut/index.vue
@@ -3,7 +3,15 @@ <!--工具栏--> <div class="head-container"> <div> <el-select v-model="query.userId" filterable clearable placeholder="申请人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.userId" filterable clearable placeholder="申请人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in users" :key="item.id" @@ -11,7 +19,15 @@ :value="item.id" /> </el-select> <el-select v-model="query.approvalUserId" filterable clearable placeholder="审批者" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.approvalUserId" filterable clearable placeholder="审批者" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in users" :key="item.id" @@ -19,7 +35,15 @@ :value="item.id" /> </el-select> <el-select v-model="query.outOfOfficeType" filterable clearable placeholder="外出类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.outOfOfficeType" filterable clearable placeholder="外出类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in dict[dictGoOutTypr]" :key="item.value" @@ -27,7 +51,15 @@ :value="item.value" /> </el-select> <el-select v-model="query.approvalStatus" filterable clearable placeholder="审批状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> <el-select v-model="query.approvalStatus" filterable clearable placeholder="审批状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" > <el-option v-for="item in dict[dictApprovalStart]" :key="item.value" @@ -45,6 +77,7 @@ range-separator=" : " start-placeholder="开始时间" end-placeholder="开始时间" @change="handleDateChange" /> <el-date-picker v-model="query.outEndTime" @@ -56,6 +89,7 @@ range-separator=" : " start-placeholder="结束时间" end-placeholder="结束时间" @change="handleDateChange1" /> <rrOperation /> </div> @@ -68,7 +102,12 @@ size="mini" type="primary" icon="el-icon-circle-check" :disabled="crud.selections.length < 1 || !crud.selections.every(selection => selection.approvalStatus === dictGoOutAppRev)" :disabled=" crud.selections.length < 1 || !crud.selections.every( selection => selection.approvalStatus === dictGoOutAppRev ) " style="margin-left: 4px !important;" @click="toAgree(1, crud.selections)" > @@ -81,7 +120,12 @@ size="mini" type="primary" icon="el-icon-error" :disabled="crud.selections.length < 1 || !crud.selections.every(selection => selection.approvalStatus === dictGoOutAppRev)" :disabled=" crud.selections.length < 1 || !crud.selections.every( selection => selection.approvalStatus === dictGoOutAppRev ) " style="margin-left: 4px !important;" @click="toAgree(2, crud.selections)" > @@ -89,10 +133,29 @@ </el-button> </crudOperation> <!--表单组件--> <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px" > <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px" > <el-form-item label="申请人" prop="userId"> <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form)"> <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="disabledUser(form)" > <el-option v-for="item in users" :key="item.id" @@ -103,7 +166,17 @@ </el-select> </el-form-item> <el-form-item label="审批者" prop="approvalUserId"> <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn"> <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " > <el-option v-for="item in approvalUsers" :key="item.id" @@ -114,7 +187,13 @@ </el-select> </el-form-item> <el-form-item label="外出类型" prop="outOfOfficeType"> <el-select v-model="form.outOfOfficeType" filterable clearable placeholder="请选择" style="width: 340px;"> <el-select v-model="form.outOfOfficeType" filterable clearable placeholder="请选择" style="width: 340px;" > <el-option v-for="item in dict[dictGoOutTypr]" :key="item.value" @@ -133,11 +212,19 @@ align="right" :picker-options="{ disabledDate(time) { return form.outEndTime ? time.getTime() > new Date(form.outEndTime).getTime() - 8.64e7 : false; return form.outEndTime ? time.getTime() > new Date(form.outEndTime).getTime() - 8.64e7 : false; } }" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" :default-time=" $store.state.user.user.sysRostering.workStartTime + ':00' " :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " @change="checkTime" /> </el-form-item> @@ -151,37 +238,88 @@ align="right" :picker-options="{ disabledDate(time) { return form.outStartTime ? time.getTime() < new Date(form.outStartTime).getTime() - 8.64e7 : false; return form.outStartTime ? time.getTime() < new Date(form.outStartTime).getTime() - 8.64e7 : false; } }" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" :default-time=" $store.state.user.user.sysRostering.workEndTime + ':00' " :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " @change="checkTime" /> </el-form-item> <el-form-item label="外出时长" prop="outDuration"> <el-input v-model="form.outDuration" disabled style="width: 340px;"> <template slot="append">{{ dict.label[dictLeaveTimeType][form.durationUnit] }}</template> <template slot="append">{{ dict.label[dictLeaveTimeType][form.durationUnit] }}</template> </el-input> </el-form-item> <el-form-item label="外出原因"> <el-input v-model="form.outReason" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" /> <el-input v-model="form.outReason" type="textarea" rows="3" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " /> </el-form-item> <el-form-item label="审批说明"> <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" disabled /> <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 340px;" disabled /> </el-form-item> <el-form-item label="备注"> <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled="form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn" /> <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" :disabled=" form.approvalStatus == dictGoOutAgree || form.approvalStatus == dictGoOutReturn " /> </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> <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU" >确认</el-button > </div> </el-dialog> <!--审核表单--> <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" title="外出审批" width="500px"> <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" title="外出审批" width="500px" > <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px" > <el-form-item label="申请人"> {{ form.userName }} </el-form-item> @@ -195,58 +333,180 @@ {{ form.outEndTime }} </el-form-item> <el-form-item label="外出时长"> {{ form.outDuration + '(' + dict.label[dictLeaveTimeType][form.durationUnit] + ')' }} {{ form.outDuration + "(" + dict.label[dictLeaveTimeType][form.durationUnit] + ")" }} </el-form-item> <el-form-item label="外出原因"> {{ form.outReason }} </el-form-item> <el-form-item v-if="form.approvalStatus === dictGoOutReturn" label="退回原因" prop="approvalDescription"> <div style="color: red;">*审核退回需要填写退回原因,请填写后再次点击审核退回</div> <el-input v-model="form.approvalDescription" type="textarea" :rows="3" style="width: 340px;" /> <el-form-item v-if="form.approvalStatus === dictGoOutReturn" label="退回原因" prop="approvalDescription" > <div style="color: red;"> *审核退回需要填写退回原因,请填写后再次点击审核退回 </div> <el-input v-model="form.approvalDescription" type="textarea" :rows="3" style="width: 340px;" /> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="danger" style="margin-right: 10px;" @click="approveFunction(1,form)">审核退回</el-button> <el-button v-if="form.approvalStatus !== dictGoOutReturn" :loading="successLoading" type="success" @click="approveFunction(2,form)">审核通过</el-button> <el-button type="danger" style="margin-right: 10px;" @click="approveFunction(1, form)" >审核退回</el-button > <el-button v-if="form.approvalStatus !== dictGoOutReturn" :loading="successLoading" type="success" @click="approveFunction(2, form)" >审核通过</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 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 prop="userName" label="申请人" min-width="100" fixed="left" show-overflow-tooltip> <el-table-column prop="userName" label="申请人" min-width="100" fixed="left" show-overflow-tooltip > <template slot-scope="scope"> <el-tag>{{ scope.row.userName }}</el-tag> </template> </el-table-column> <el-table-column prop="appUserName" label="审批者" min-width="100" fixed="left" show-overflow-tooltip> <el-table-column prop="appUserName" label="审批者" min-width="100" fixed="left" show-overflow-tooltip > <template slot-scope="scope"> <el-tag>{{ scope.row.appUserName }}</el-tag> </template> </el-table-column> <el-table-column prop="outStartTime" label="外出开始时间" min-width="140" show-overflow-tooltip /> <el-table-column prop="outEndTime" label="外出结束时间" min-width="140" show-overflow-tooltip /> <el-table-column prop="outDuration" label="外出时长" min-width="80" show-overflow-tooltip> <el-table-column prop="outStartTime" label="外出开始时间" min-width="140" show-overflow-tooltip /> <el-table-column prop="outEndTime" label="外出结束时间" min-width="140" show-overflow-tooltip /> <el-table-column prop="outDuration" label="外出时长" min-width="80" show-overflow-tooltip > <template slot-scope="scope"> {{ scope.row.outDuration + '(' + dict.label[dictLeaveTimeType][scope.row.durationUnit] + ')' }} {{ scope.row.outDuration + "(" + dict.label[dictLeaveTimeType][scope.row.durationUnit] + ")" }} </template> </el-table-column> <el-table-column prop="outOfOfficeType" label="外出类型" min-width="80" show-overflow-tooltip> <el-table-column prop="outOfOfficeType" label="外出类型" min-width="80" show-overflow-tooltip > <template slot-scope="scope"> <el-tag>{{ dict.label[dictGoOutTypr][scope.row.outOfOfficeType] }}</el-tag> <el-tag>{{ dict.label[dictGoOutTypr][scope.row.outOfOfficeType] }}</el-tag> </template> </el-table-column> <el-table-column prop="outReason" label="外出原因" min-width="140" show-overflow-tooltip /> <el-table-column prop="approvalStatus" label="审批状态" min-width="80" show-overflow-tooltip> <el-table-column prop="outReason" label="外出原因" min-width="140" show-overflow-tooltip /> <el-table-column prop="approvalStatus" label="审批状态" min-width="80" show-overflow-tooltip > <template slot-scope="scope"> <el-tag v-if="scope.row.approvalStatus === dictGoOutAppRev" type="warning">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictGoOutAgree" type="success">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictGoOutReturn" type="danger">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictGoOutAppRev" type="warning" >{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag > <el-tag v-if="scope.row.approvalStatus === dictGoOutAgree" type="success" >{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag > <el-tag v-if="scope.row.approvalStatus === dictGoOutReturn" type="danger" >{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag > </template> </el-table-column> <el-table-column prop="approvalDescription" label="审批说明" min-width="140" show-overflow-tooltip /> <el-table-column prop="remarks" label="备注" min-width="140" show-overflow-tooltip /> <el-table-column prop="createTime" label="创建时间" min-width="140" show-overflow-tooltip /> <el-table-column v-if="checkPer(['admin','attendanceGoOut:approve'])" label="审核操作" width="180px" align="center" fixed="right"> <el-table-column prop="approvalDescription" label="审批说明" min-width="140" show-overflow-tooltip /> <el-table-column prop="remarks" label="备注" min-width="140" show-overflow-tooltip /> <el-table-column prop="createTime" label="创建时间" min-width="140" show-overflow-tooltip /> <el-table-column v-if="checkPer(['admin', 'attendanceGoOut:approve'])" label="审核操作" width="180px" align="center" fixed="right" > <template slot-scope="scope"> <el-button v-if="scope.row.approvalUserId === $store.state.user.user.id" @@ -255,18 +515,25 @@ size="mini" type="primary" icon="el-icon-s-check" :disabled="scope.row.approvalStatus === dictGoOutAppRev ? false : true" :disabled=" scope.row.approvalStatus === dictGoOutAppRev ? false : true " @click="toApprove(scope.row)" >审核 </el-button> <el-popover :ref="`popover_${scope.row.id}`" width="200" > <el-popover :ref="`popover_${scope.row.id}`" width="200"> <p>确定撤销该记录?</p> <div style="text-align: right; margin: 0"> <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button> <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> <el-button size="mini" type="primary" @click="canel(scope.row)" >取消</el-button > <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)" >确定</el-button > </div> <el-button v-if="scope.row.approvalUserId === $store.state.user.user.id" @@ -275,18 +542,25 @@ type="danger" icon="el-icon-edit-outline" size="mini" :disabled="scope.row.approvalStatus === dictGoOutAppRev ? true : false" :disabled=" scope.row.approvalStatus === dictGoOutAppRev ? true : false " >撤销 </el-button> </el-popover> </template> </el-table-column> <el-table-column v-if="checkPer(['admin','attendanceGoOut:edit','attendanceGoOut:del'])" label="操作" width="150px" align="center" fixed="right"> <el-table-column v-if=" checkPer(['admin', 'attendanceGoOut:edit', 'attendanceGoOut:del']) " label="操作" width="150px" align="center" fixed="right" > <template slot-scope="scope"> <udOperation :data="scope.row" :permission="permission" /> <udOperation :data="scope.row" :permission="permission" /> </template> </el-table-column> </el-table> @@ -297,63 +571,90 @@ </template> <script> import crudAttendanceGoOut from '@/api/attendance/attendanceGoOut' import CRUD, { presenter, header, form, crud } from '@crud/crud' import rrOperation from '@crud/RR.operation' import { mapGetters } from 'vuex' import crudUser from '@/api/system/user' import crudOperation from '@crud/CRUD.operation' import udOperation from '@crud/UD.operation' import pagination from '@crud/Pagination' import constant from '@/utils/constant' import crudAttendanceGoOut from "@/api/attendance/attendanceGoOut"; import CRUD, { presenter, header, form, crud } from "@crud/crud"; import rrOperation from "@crud/RR.operation"; import { mapGetters } from "vuex"; import crudUser from "@/api/system/user"; import crudOperation from "@crud/CRUD.operation"; import udOperation from "@crud/UD.operation"; import pagination from "@crud/Pagination"; import constant from "@/utils/constant"; const defaultForm = { id: null, userId: null, approvalUserId: null, outStartTime: null, outEndTime: null, outDuration: null, durationUnit: null, outOfOfficeType: null, outReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } const defaultForm = { id: null, userId: null, approvalUserId: null, outStartTime: null, outEndTime: null, outDuration: null, durationUnit: null, outOfOfficeType: null, outReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }; export default { name: 'AttendanceGoOut', name: "AttendanceGoOut", components: { pagination, crudOperation, rrOperation, udOperation }, mixins: [presenter(), header(), form(defaultForm), crud()], cruds() { return CRUD({ title: '外出记录', url: 'api/attendanceGoOut', idField: 'id', sort: 'outStartTime,desc', crudMethod: { ...crudAttendanceGoOut }}) return CRUD({ title: "外出记录", url: "api/attendanceGoOut", idField: "id", sort: "outStartTime,desc", crudMethod: { ...crudAttendanceGoOut } }); }, // 数据字典 dicts: [constant.LEAVE_TIME_TYPE, constant.GO_OUT_TYPE, constant.GO_OUT_APPROVE_STATUS], dicts: [ constant.LEAVE_TIME_TYPE, constant.GO_OUT_TYPE, constant.GO_OUT_APPROVE_STATUS ], data() { return { permission: { add: ['admin', 'attendanceGoOut:add'], edit: ['admin', 'attendanceGoOut:edit'], del: ['admin', 'attendanceGoOut:del'], download: ['admin', 'attendanceGoOut:download'], approve: ['admin', 'attendanceGoOut:approve'], updateAgree: ['admin', 'attendanceGoOut:updateAgree'] add: ["admin", "attendanceGoOut:add"], edit: ["admin", "attendanceGoOut:edit"], del: ["admin", "attendanceGoOut:del"], download: ["admin", "attendanceGoOut:download"], approve: ["admin", "attendanceGoOut:approve"], updateAgree: ["admin", "attendanceGoOut:updateAgree"] }, rules: { userId: [ { required: true, message: '申请人不能为空', trigger: 'change' } { required: true, message: "申请人不能为空", trigger: "change" } ], approvalUserId: [ { required: true, message: '审批者不能为空', trigger: 'change' } { required: true, message: "审批者不能为空", trigger: "change" } ], outStartTime: [ { required: true, message: '外出开始时间不能为空', trigger: 'change' } { required: true, message: "外出开始时间不能为空", trigger: "change" } ], outEndTime: [ { required: true, message: '外出结束时间不能为空', trigger: 'change' } { required: true, message: "外出结束时间不能为空", trigger: "change" } ], outDuration: [ { required: true, message: '外出时长不能为空', trigger: 'blur' } { required: true, message: "外出时长不能为空", trigger: "blur" } ], durationUnit: [ { required: true, message: '时长单位不能为空', trigger: 'change' } { required: true, message: "时长单位不能为空", trigger: "change" } ], outOfOfficeType: [ { required: true, message: '外出类型不能为空', trigger: 'change' } { required: true, message: "外出类型不能为空", trigger: "change" } ], approvalStatus: [ { required: true, message: '审批状态不能为空', trigger: 'change' } { required: true, message: "审批状态不能为空", trigger: "change" } ], approvalDescription: [ { required: true, message: '审批说明不能为空', trigger: 'blur' } { required: true, message: "审批说明不能为空", trigger: "blur" } ] }, users: [], @@ -371,181 +672,206 @@ // 角色级别:普通用户 roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY, // 角色级别: 总经理 roleLevelGenerl: constant.ROLE_LEVEL_GENERAL } roleLevelGenerl: constant.ROLE_LEVEL_GENERAL }; }, computed: { ...mapGetters([ 'user' ]) ...mapGetters(["user"]) }, created() { this.getUsers() this.getApprovalUsers() this.getUsers(); this.getApprovalUsers(); }, methods: { // 钩子:在获取表格数据之前执行,false 则代表不获取数据 [CRUD.HOOK.beforeRefresh]() { // 用户角色级别数组 const userRolesLevel = this.user.roles.map(({ level }) => level) const userRolesLevel = this.user.roles.map(({ level }) => level); // 用户最大角色级别 this.userRolesLevelMin = Math.min(...userRolesLevel) return true this.userRolesLevelMin = Math.min(...userRolesLevel); return true; }, // 钩子:新建 - 之前 [CRUD.HOOK.beforeToAdd]() { // 判断用户最大角色级别是否大于总经理角色:赋值 if (this.userRolesLevelMin > this.roleLevelGenerl) { // 表单赋值 this.form.userId = this.user.id this.form.userId = this.user.id; } }, // 禁用 disabledUser(data) { if (this.userRolesLevelMin > this.roleLevelGenerl) { return true return true; } if (data.approvalStatus !== null && data.approvalStatus === this.dictGoOutAgree || data.approvalStatus === this.dictGoOutReturn) { return true if ( (data.approvalStatus !== null && data.approvalStatus === this.dictGoOutAgree) || data.approvalStatus === this.dictGoOutReturn ) { return true; } }, // 查询员工 getUsers() { crudUser.getAll().then(res => { this.users = res }) this.users = res; }); }, // 查询审核人 getApprovalUsers() { crudUser.getApprovalUsers().then(res => { this.approvalUsers = res }) this.approvalUsers = res; }); }, // 设定条件查询日期结尾 handleDateChange(value) { if (value && value[1]) { this.query.outStartTime[1] = value[1].substring(0, 11) + "23:59:59"; } }, handleDateChange1(value) { if (value && value[1]) { this.query.outEndTime[1] = value[1].substring(0, 11) + "23:59:59"; } }, // 计算时长 checkTime() { this.form.durationUnit = this.dictLeaveTimeTypeHour this.form.durationUnit = this.dictLeaveTimeTypeHour; var data = JSON.stringify({ 'outStartTime': this.form.outStartTime, 'outEndTime': this.form.outEndTime }) outStartTime: this.form.outStartTime, outEndTime: this.form.outEndTime }); crudAttendanceGoOut.getRemainingTime(data).then(res => { this.form.outDuration = res }) this.form.outDuration = res; }); }, // 批量审核 toAgree(Number, data) { const msg = Number === 2 ? '批量拒绝' : '批量同意' const msg1 = Number === 2 ? 'error' : 'success' const msg = Number === 2 ? "批量拒绝" : "批量同意"; const msg1 = Number === 2 ? "error" : "success"; // 确认框 this.$confirm('此操作将' + msg + '审核内容是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', this.$confirm("此操作将" + msg + "审核内容是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: msg1 }).then(() => { const ids = [] const ids = []; // 循环数据 for (let i = 0; i < data.length; i++) { // ID列表 ids.push(data[i].id) ids.push(data[i].id); } crudAttendanceGoOut.updateAgree({ crudAttendanceGoOut .updateAgree({ num: Number, ids: ids }).then(res => { }) .then(res => { // 消息提示 this.$message({ type: 'success', message: msg + '!' }) type: "success", message: msg + "!" }); // 刷新数据 this.crud.refresh() }) }) this.crud.refresh(); }); }); }, // 审批页面赋值 toApprove(data, Number) { if (Number !== '1') { this.makeUpCardVisible = true if (Number !== "1") { this.makeUpCardVisible = true; } this.form.id = data.id this.form.userId = data.userId this.form.userName = data.userName this.form.outOfOfficeType = data.outOfOfficeType this.form.outStartTime = data.outStartTime this.form.outEndTime = data.outEndTime this.form.outDuration = data.outDuration this.form.durationUnit = data.durationUnit this.form.approvalStatus = data.approvalStatus this.form.outReason = data.outReason this.form.remarks = data.remarks this.form.id = data.id; this.form.userId = data.userId; this.form.userName = data.userName; this.form.outOfOfficeType = data.outOfOfficeType; this.form.outStartTime = data.outStartTime; this.form.outEndTime = data.outEndTime; this.form.outDuration = data.outDuration; this.form.durationUnit = data.durationUnit; this.form.approvalStatus = data.approvalStatus; this.form.outReason = data.outReason; this.form.remarks = data.remarks; }, // 审核提交功能 approveFunction(Number, data) { this.form.userId = data.userId const msg = Number === 2 ? '通过' : '拒绝' this.$refs['form'].validate(valid => { this.form.userId = data.userId; const msg = Number === 2 ? "通过" : "拒绝"; this.$refs["form"].validate(valid => { if (!valid) { return return; } // 判断通过状态 if (Number === 2) { this.form.approvalStatus = this.dictGoOutAgree this.form.approvalStatus = this.dictGoOutAgree; } else { // 退回改状态显示退回原因 this.form.approvalStatus = this.dictGoOutReturn this.form.approvalStatus = this.dictGoOutReturn; if (this.form.approvalDescription == null) { return return; } } this.successLoading = true crudAttendanceGoOut.approve(this.form).then(res => { this.crud.refresh() this.makeUpCardVisible = false this.successLoading = false this.successLoading = true; crudAttendanceGoOut .approve(this.form) .then(res => { this.crud.refresh(); this.makeUpCardVisible = false; this.successLoading = false; this.$message({ type: 'success', message: '审核' + msg + '成功' type: "success", message: "审核" + msg + "成功" }); }) }).catch(() => { this.makeUpCardVisible = false this.successLoading = false }) if (this.$refs['form']) { this.$refs['form'].resetFields() .catch(() => { this.makeUpCardVisible = false; this.successLoading = false; }); if (this.$refs["form"]) { this.$refs["form"].resetFields(); } }) }); }, // 撤消功能 revoke(data) { this.toApprove(data, '1') this.form.approvalStatus = this.dictGoOutAppRev this.successLoading = true crudAttendanceGoOut.approve(this.form).then(res => { this.crud.refresh() this.successLoading = false this.$message({ type: 'success', message: '撤销成功' }) this.$refs[`popover_${data.id}`].showPopper = false }).catch((error) => { this.$message({ type: 'error', message: error.response.data.message }) this.toApprove(data, "1"); this.form.approvalStatus = this.dictGoOutAppRev; this.successLoading = true; crudAttendanceGoOut .approve(this.form) .then(res => { this.crud.refresh(); this.successLoading = false; this.$message({ type: "success", message: "撤销成功" }); this.$refs[`popover_${data.id}`].showPopper = false; }) if (this.$refs['form']) { this.$refs['form'].resetFields() .catch(error => { this.$message({ type: "error", message: error.response.data.message }); }); if (this.$refs["form"]) { this.$refs["form"].resetFields(); } this.crud.cancelCU() this.crud.cancelCU(); }, // 关闭 closeCard() { if (this.$refs['form']) { this.$refs['form'].resetFields() if (this.$refs["form"]) { this.$refs["form"].resetFields(); } this.crud.cancelCU() this.makeUpCardVisible = false this.crud.cancelCU(); this.makeUpCardVisible = false; }, // 取消 canel(data) { this.$refs[`popover_${data.id}`].showPopper = false this.$refs[`popover_${data.id}`].showPopper = false; } } } }; </script> <style scoped> eladmin-web-master/src/views/attendance/attendanceLeave/index.vue
@@ -45,6 +45,7 @@ range-separator=" : " start-placeholder="开始日期" end-placeholder="开始日期" @change="handleDateChange" /> <el-date-picker v-model="query.leaveEndTime" @@ -56,6 +57,7 @@ range-separator=" : " start-placeholder="结束日期" end-placeholder="结束日期" @change="handleDateChange1" /> <rrOperation /> </div> @@ -520,6 +522,17 @@ }) }) }, // 设定条件查询日期结尾 handleDateChange(value) { if (value && value[1]) { this.query.leaveStartTime[1] = value[1].substring(0,11) + '23:59:59' } }, handleDateChange1(value) { if (value && value[1]) { this.query.leaveEndTime[1] = value[1].substring(0,11) + '23:59:59' } }, // 审核提交功能 approveFunction(Number, data) { this.form.userId = data.userId eladmin-web-master/src/views/attendance/attendanceOvertime/index.vue
@@ -37,6 +37,7 @@ range-separator=" : " start-placeholder="开始日期" end-placeholder="开始日期" @change="handleDateChange" /> <el-date-picker v-model="query.overtimeEndTime" @@ -48,6 +49,7 @@ range-separator=" : " start-placeholder="结束日期" end-placeholder="结束日期" @change="handleDateChange1" /> <rrOperation /> </div> @@ -420,6 +422,17 @@ return true } }, // 设定条件查询日期结尾 handleDateChange(value) { if (value && value[1]) { this.query.overtimeStartTime[1] = value[1].substring(0, 11) + "23:59:59"; } }, handleDateChange1(value) { if (value && value[1]) { this.query.overtimeEndTime[1] = value[1].substring(0, 11) + "23:59:59"; } }, // 计算加班时长 checkLeaveTime() { if(this.form.userId != null && this.form.overtimeStartTime != null && this.form.overtimeEndTime != null) {