已重命名2个文件
已修改1个文件
已添加6个文件
已删除2个文件
已复制4个文件
对比新文件 |
| | |
| | | import request from '/@/utils/request'; |
| | | |
| | | export function holidayTimeApi() { |
| | | return { |
| | | // 分页获取休息日列表 |
| | | getAllBreakTimeRuleByPage: (data: object) => { |
| | | return request({ |
| | | url: `/breakTime/getAllBreakTimeRuleByPage`, |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | }, |
| | | |
| | | // 新增休息日 |
| | | addBreakTime: (data: object) => { |
| | | return request({ |
| | | url: `/breakTime/addBreakTimeRule`, |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | }, |
| | | |
| | | // 修改休息日 |
| | | updateBreakTime: (data: object) => { |
| | | return request({ |
| | | url: `/breakTime/updateBreakTimeRule`, |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | }, |
| | | |
| | | // 删除休息日 |
| | | deleteBreakTime: (data: object) => { |
| | | return request({ |
| | | url: `/breakTime/deleteBreakTimeRule`, |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | }, |
| | | |
| | | // 删除休息日 |
| | | deleteBatch: (data: object) => { |
| | | return request({ |
| | | url: `/breakTime/deleteBatchBreakTimeRule`, |
| | | method: 'post', |
| | | data: data |
| | | }); |
| | | }, |
| | | }; |
| | | } |
对比新文件 |
| | |
| | | import request from '/@/utils/request'; |
| | | |
| | | export function holidayGroupApi() { |
| | | return { |
| | | //休息时间组分页列表 |
| | | getRecordPage: (data: object)=>{ |
| | | return request({ |
| | | url: `/breakTime/getAllBreakTimeGroupByPage`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 休息时间组新增 |
| | | addRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/breakTime/addBreakTimeGroup`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 休息时间组修改 |
| | | updateRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/breakTime/updateBreakTimeGroup`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 休息时间组删除 |
| | | deleteRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/breakTime/deleteBreakTimeGroup`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 休息时间组批量删除 |
| | | deletBatchRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/breakTime/deleteBatchBreakTimeGroup`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | //休息时间列表 |
| | | getAllBreak: ()=>{ |
| | | return request({ |
| | | url: `/breakTime/getAllBreakTimeRule`, |
| | | method: 'get' |
| | | }) |
| | | }, |
| | | }; |
| | | } |
对比新文件 |
| | |
| | | import request from '/@/utils/request'; |
| | | |
| | | export function teamManageApi() { |
| | | return { |
| | | //班组分页列表 |
| | | getRecordPage: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/page/list`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | //班组列表 |
| | | getRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/list`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | //班组-班组成员分页列表 |
| | | getAllRecordPage: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/member/page/list`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | //所有部门列表 |
| | | getAllDepartment: ()=>{ |
| | | return request({ |
| | | url: `/department/list`, |
| | | method: 'post' |
| | | }) |
| | | }, |
| | | |
| | | |
| | | //用户-部门所有用户 |
| | | getAllMember: (data: number)=>{ |
| | | return request({ |
| | | url: `/account/dep/list?depId=${data}`, |
| | | method: 'get', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组-班组成员列表 |
| | | getAllRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/member/list`, |
| | | method: 'get', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组新增 |
| | | addRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/add`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组修改 |
| | | updateRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/mod`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组删除 |
| | | deleteRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/group/del`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略批量删除 |
| | | // deletBatchRecord: (data: object)=>{ |
| | | // return request({ |
| | | // url: `/timeStrategy/deleteBatchTimeStrategy`, |
| | | // method: 'post', |
| | | // data: data |
| | | // }) |
| | | // }, |
| | | }; |
| | | } |
对比新文件 |
| | |
| | | import request from '/@/utils/request'; |
| | | |
| | | export function teamStrategyApi() { |
| | | return { |
| | | |
| | | //获取班组策略分页列表 |
| | | getRecordPage: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/groupStrategy/page/list`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组策略新增 |
| | | addRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/groupStrategy/add`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组策略修改 |
| | | updateRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/groupStrategy/mod`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 班组策略删除 |
| | | deleteRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/schedule/groupStrategy/del`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略批量删除 |
| | | // deletBatchRecord: (data: object)=>{ |
| | | // return request({ |
| | | // url: `/timeStrategy/deleteBatchTimeStrategy`, |
| | | // method: 'post', |
| | | // data: data |
| | | // }) |
| | | // }, |
| | | }; |
| | | } |
对比新文件 |
| | |
| | | import request from '/@/utils/request'; |
| | | |
| | | export function timeStrategyApi() { |
| | | return { |
| | | //获取工作时间组列表 |
| | | getWorkTimeList: ()=>{ |
| | | return request({ |
| | | url: `/workTime/getWorkTimeGroup`, |
| | | method: 'get' |
| | | }) |
| | | }, |
| | | |
| | | //获取休息时间组列表 |
| | | getRestTimeList: ()=>{ |
| | | return request({ |
| | | url: `/breakTime/getAllBreakTimeGroup`, |
| | | method: 'get' |
| | | }) |
| | | }, |
| | | |
| | | //时间策略分页列表 |
| | | getRecordPage: (data: object)=>{ |
| | | return request({ |
| | | url: `/timeStrategy/getAllTimeStrategyByPage`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略全部列表 |
| | | getAllRecord: ()=>{ |
| | | return request({ |
| | | url: `/timeStrategy/getAllTimeStrategy`, |
| | | method: 'get' |
| | | }) |
| | | }, |
| | | |
| | | |
| | | |
| | | //根据id获取时间策略列表 |
| | | getRecordById: (data:object)=>{ |
| | | return request({ |
| | | url: `/timeStrategy/getTimeStrategyById`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略新增 |
| | | addRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/timeStrategy/addTimeStrategy`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略修改 |
| | | updateRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/timeStrategy/updateTimeStrategy`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略删除 |
| | | deleteRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/timeStrategy/deleteTimeStrategy`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | |
| | | // 时间策略批量删除 |
| | | deletBatchRecord: (data: object)=>{ |
| | | return request({ |
| | | url: `/timeStrategy/deleteBatchTimeStrategy`, |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | }, |
| | | }; |
| | | } |
| | |
| | | export function workingHoursApi() { |
| | | return { |
| | | // 获取工作时间段列表 |
| | | getWorkTimePeriod: (value: { name: string }) => { |
| | | getWorkTimePeriod: () => { |
| | | return request({ |
| | | url: `/workTime/getWorkTimePeriod`, |
| | | method: 'get' |
copy from src/views/system/personShiftManage/workingHoursSet/index.vue
copy to src/views/system/personShiftManage/personTimeManage/holidayTime/index.vue
文件从 src/views/system/personShiftManage/workingHoursSet/index.vue 复制 |
| | |
| | | <el-row class="homeCard"> |
| | | <el-col :span="8"> |
| | | <div class="grid-content topInfo"> |
| | | <el-input v-model="searchWord" placeholder="休息时间组名称"></el-input> |
| | | <el-input v-model="searchWord" placeholder="休息日名称"></el-input> |
| | | <el-button type="primary" @click="searchRecord">查询</el-button> |
| | | <el-button plain @click="clearSearch">重置</el-button> |
| | | </div> |
| | |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="100" /> |
| | | <el-table-column property="name" label="工作时间组名称"/> |
| | | <el-table-column property="list" :formatter="toNames" label="关联工作时段"/> |
| | | <el-table-column property="name" label="休息日名称"/> |
| | | <el-table-column property="typeName" label="休息日类型"/> |
| | | <el-table-column property="ruleName" label="休息日规则"/> |
| | | <el-table-column property="ruleNumber" label="休息日"/> |
| | | <el-table-column property="info" label="描述信息"/> |
| | | <el-table-column fixed="right" label="操作" align="center" width="250"> |
| | | <template #default="scope"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-dialog v-model="dialogDetails" title="工作时间组"> |
| | | <el-dialog v-model="dialogDetails" title="休息时间"> |
| | | <el-form :model="details" label-width="120px"> |
| | | <el-form-item label="时间组名称"> |
| | | <el-form-item label="名称"> |
| | | <el-input |
| | | v-model="details.name" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" v-if="details.list.length>0"> |
| | | <el-form-item label="休假类型"> |
| | | <el-input |
| | | v-model="details.list" |
| | | v-model="details.typeName" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="休假规则" v-if="details.type == 2"> |
| | | <el-input |
| | | v-model="details.ruleName" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="休假时间" v-if="details.type == 2"> |
| | | <el-input |
| | | v-model="details.ruleNumber" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | <el-dialog v-model="dialogAddRecord" title="工作时间组编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-dialog v-model="dialogAddRecord" title="休息时间编辑" @close="closeAdd"> |
| | | <el-form :model="addRecord" label-width="120px" ref="addRef" :rules="addRules"> |
| | | <el-form-item label="时间组名称" prop="name"> |
| | | <el-form-item label="休息日名称" prop="name"> |
| | | <el-input |
| | | v-model="addRecord.name" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" prop="list"> |
| | | <el-select v-model="addRecord.list" multiple> |
| | | <el-option v-for="(item,index) in workTimeList" :key="index" :label="item.name" :value="item.id" /> |
| | | <el-form-item label="休假类型" prop="type"> |
| | | <el-select v-model="addRecord.type" placeholder="请选择休假类型" style="width: 100%" @change="typeChange"> |
| | | <el-option v-for="(item,index) in typeList" :key="index" :label="item.name" :value="item.value"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="休假规则" prop="rule" v-if="addRecord.type == '自定义休息日' || addRecord.type == 2"> |
| | | <el-select v-model="addRecord.rule" placeholder="请选择休假规则" style="width: 100%" @change="ruleChange"> |
| | | <el-option v-for="(item,index) in ruleList" :key="index" :label="item.name" :value="item.value"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="选择休假时间" prop="ruleNumber" v-if="addRecord.rule == '每周'|| addRecord.rule == 1"> |
| | | <el-checkbox-group v-model="addRecord.ruleNumber"> |
| | | <el-checkbox v-for="(item,i) in weekDays" :label="item.value" :key="i">{{item.name}}</el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | <el-form-item label="选择休假时间" prop="ruleNumber" v-if="addRecord.rule == '每月'|| addRecord.rule == 2"> |
| | | <el-checkbox-group v-model="addRecord.ruleNumber"> |
| | | <el-checkbox v-for="index in 31" :label="index" :key="index"/> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" prop="info"> |
| | | <el-input |
| | |
| | | import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue' |
| | | import { ElTable } from 'element-plus' |
| | | import { FormInstance, FormRules, ElMessage } from 'element-plus' |
| | | import { workingHoursSetApi } from '/@/api/basicDateManage/personShiftManage/workingHoursSet'; |
| | | import { workingHoursApi } from '/@/api/basicDateManage/personShiftManage/workingHours'; |
| | | import { holidayTimeApi } from '/@/api/basicDateManage/personShiftManage/holidayTime'; |
| | | import {workingHoursSetApi} from "/@/api/basicDateManage/personShiftManage/workingHoursSet"; |
| | | |
| | | |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface stateType { |
| | | tableData: Array<string>, |
| | | pageRecord: Array<string>, |
| | | workTimeList: Array<string>, |
| | | multipleSelection: Array<any>, |
| | | deleteArr: Array<any>, |
| | | weekDays: Array<any>, |
| | | typeList: Array<any>, |
| | | ruleList: Array<any>, |
| | | dialogDetails: boolean, |
| | | dialogAddRecord: boolean, |
| | | deleteDialog: boolean, |
| | | deleteSetDialog: boolean; |
| | | deleteSetDialog: boolean, |
| | | pageIndex: number, |
| | | pageSize: number, |
| | | chosenIndex: null | number, |
| | | deleteId: null | number, |
| | | searchWord: string, |
| | | chosenIndex: null| number, |
| | | casProps: object, |
| | | deleteId: null| number, |
| | | totalSize: number, |
| | | addRecord: { |
| | | name: string, |
| | | list: Array<any>, |
| | | type: number | string, |
| | | rule: number | string, |
| | | ruleNumber: Array<number> | string, |
| | | info: string |
| | | }, |
| | | details: { |
| | | name: string, |
| | | list: Array<any>, |
| | | type: string, |
| | | rule: string, |
| | | ruleNumber: string, |
| | | info: string |
| | | } |
| | | } |
| | |
| | | chosenIndex: null, |
| | | searchWord: '', |
| | | tableData: [], |
| | | pageRecord: [], |
| | | workTimeList: [], |
| | | typeList: [ |
| | | { |
| | | name: '每周公休假日', |
| | | value: 0 |
| | | }, |
| | | { |
| | | name: '国家法定节假日', |
| | | value: 1 |
| | | }, |
| | | { |
| | | name: '自定义休息日', |
| | | value: 2 |
| | | } |
| | | ], |
| | | ruleList: [ |
| | | { |
| | | name: '每周', |
| | | value: 1 |
| | | }, |
| | | { |
| | | name: '每月', |
| | | value: 2 |
| | | } |
| | | ], |
| | | multipleSelection: [], |
| | | dialogDetails: false, |
| | | dialogAddRecord: false, |
| | | deleteDialog: false, |
| | | deleteSetDialog: false, |
| | | weekDays: [ |
| | | { |
| | | name: '周一', |
| | | value: 1 |
| | | }, |
| | | { |
| | | name: '周二', |
| | | value: 2 |
| | | }, |
| | | { |
| | | name: '周三', |
| | | value: 3 |
| | | }, |
| | | { |
| | | name: '周四', |
| | | value: 4 |
| | | }, |
| | | { |
| | | name: '周五', |
| | | value: 5 |
| | | }, |
| | | { |
| | | name: '周六', |
| | | value: 6 |
| | | }, |
| | | { |
| | | name: '周日', |
| | | value: 7 |
| | | } |
| | | ], |
| | | casProps: { |
| | | expandTrigger: 'hover', |
| | | }, |
| | | addRecord: { |
| | | name: '', |
| | | list: [], |
| | | type: '', |
| | | rule: '', |
| | | ruleNumber: [], |
| | | info: '' |
| | | }, |
| | | details: { |
| | | name: '', |
| | | list: [], |
| | | type: '', |
| | | rule: '', |
| | | ruleNumber: '', |
| | | info: '' |
| | | }, |
| | | deleteId: null, |
| | |
| | | }) |
| | | interface User { |
| | | name: string, |
| | | list: [], |
| | | type: number | string, |
| | | rule: number | string, |
| | | ruleNumber: Array<number> | string, |
| | | info: string |
| | | } |
| | | |
| | | // 排序 |
| | | const compare = (x,y)=> { |
| | | if (x < y) { |
| | | return -1; |
| | | } else if (x > y) { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | const handleChange = (value) => { |
| | | state.addRecord.content = [] |
| | | console.log(JSON.parse(JSON.stringify(value))) |
| | | } |
| | | |
| | | const multipleTableRef = ref<InstanceType<typeof ElTable>>() |
| | | const toggleSelection = (rows?: User[]) => { |
| | | if (rows) { |
| | |
| | | } |
| | | } |
| | | |
| | | // 休息类型改变时操作 |
| | | const typeChange =()=>{ |
| | | state.addRecord.rule = '' |
| | | state.addRecord.ruleNumber = [] |
| | | } |
| | | // 休息规则改变时操作 |
| | | const ruleChange =()=>{ |
| | | state.addRecord.ruleNumber = [] |
| | | } |
| | | |
| | | // 多选 |
| | | const handleSelectionChange = (val: User[]) => { |
| | | state.multipleSelection = JSON.parse(JSON.stringify(val)) |
| | |
| | | const addRef = ref<FormInstance>() |
| | | const addRules = reactive<FormRules>({ |
| | | name: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | list: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | type: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | rule: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | ruleNumber: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | }) |
| | | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | // getWorkTimePeriod() |
| | | getListByPage() |
| | | getWorkTimePeriod() |
| | | }) |
| | | |
| | | // 分页获取工作时间组列表 |
| | | // 休假类型格式化 |
| | | // const typeName =(row, column, cellValue, index) =>{ |
| | | // return row.type == 0? '每周公休假日':(row.type == 1? '国家法定节假日': '自定义休息日') |
| | | // } |
| | | |
| | | // 分页获取工作时段列表 |
| | | const getListByPage = async ()=>{ |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{name: state.searchWord}} |
| | | let res = await workingHoursSetApi().postWorkTimeGroupPage(data); |
| | | let res = await holidayTimeApi().getAllBreakTimeRuleByPage(data); |
| | | if (res.data.code === '200') { |
| | | state.pageRecord = res.data.data |
| | | state.tableData = res.data.data.map((item)=>{ |
| | | if(item.list == null){ |
| | | item.list = [] |
| | | }else{ |
| | | item.list= Array.from(item.list,({workTimePeriodId})=>workTimePeriodId) |
| | | } |
| | | item.typeName = item.type===0?'每周公休假日':(item.type===1?'国家法定节假日':(item.type===2?'自定义休息日':'')) |
| | | item.ruleName = item.rule===1?'每周':(item.rule===2?'每月':'') |
| | | return item |
| | | }) |
| | | console.log(state.tableData,'列表获取的tableData') |
| | | state.totalSize = res.data.total |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 表格数据格式化 |
| | | const toNames =(row, column, cellValue, index) => { |
| | | if(row.list==[]){ |
| | | return [] |
| | | }else{ |
| | | const nameList = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | nameList.push(state.workTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | | return nameList.join() |
| | | } |
| | | } |
| | | |
| | | // 获取工作时段列表 |
| | | const getWorkTimePeriod = async () => { |
| | | let res = await workingHoursApi().getWorkTimePeriod(); |
| | | if (res.data.code === '200') { |
| | | state.workTimeList = res.data.data |
| | | console.log(state.workTimeList,'list') |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | |
| | | getListByPage() |
| | | } |
| | | |
| | | // 添加工作时段方法 |
| | | // 添加休息时间 |
| | | const addRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().addWorkTimeGroup(data); |
| | | let res = await holidayTimeApi().addBreakTime(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | } |
| | | }; |
| | | |
| | | // 修改工作时段方法 |
| | | // 修改休息时间 |
| | | const editRecordBtn = (index, row) => { |
| | | state.dialogAddRecord = true |
| | | state.chosenIndex = index |
| | | console.log(row,'编辑时的row') |
| | | console.log(state.tableData,'编辑时的tableData') |
| | | state.addRecord = JSON.parse(JSON.stringify(row)) |
| | | state.addRecord.ruleNumber = row.ruleNumber.split(',').map((i)=>{ |
| | | return Number(i) |
| | | }) |
| | | console.log(state.addRecord) |
| | | } |
| | | |
| | | const editRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().updateWorkTimeGroup(data); |
| | | let res = await holidayTimeApi().updateBreakTime(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | const data = { |
| | | name: state.addRecord.name, |
| | | info: state.addRecord.info, |
| | | workTimePeriodIds: state.addRecord.list |
| | | type: Number(state.addRecord.type), |
| | | rule: Number(state.addRecord.rule), |
| | | ruleNumber: state.addRecord.ruleNumber.sort(compare).join(',') |
| | | } |
| | | if (state.chosenIndex == null) { |
| | | await addRecord(data) |
| | | if(data.type == 2 && data.ruleNumber==''){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '请至少选择一个休息时间' |
| | | }); |
| | | return |
| | | } else{ |
| | | await addRecord(data) |
| | | } |
| | | } else { |
| | | data.id = JSON.stringify(state.addRecord.id), |
| | | console.log(data,'修改参数') |
| | | data.id = state.addRecord.id, |
| | | console.log(data,'提交时的参数data') |
| | | await editRecord(data) |
| | | } |
| | | state.dialogAddRecord = false |
| | |
| | | }) |
| | | |
| | | } |
| | | const closeAdd = () => { |
| | | state.addRecord = { |
| | | name: '', |
| | | type: '', |
| | | rule: '', |
| | | ruleNumber: [], |
| | | info: '' |
| | | } |
| | | state.chosenIndex = null |
| | | } |
| | | |
| | | // 删除工作时间组方法 |
| | | // 删除工作时段 |
| | | const deleteRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().deleteWorkTimeGroup(data); |
| | | let res = await holidayTimeApi().deleteBreakTime(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | }; |
| | | |
| | | const conFirmDeleteBatch = async () => { |
| | | let res = await workingHoursSetApi().deletBatchWorkTimeGroup({ids: state.deleteArr}); |
| | | let res = await holidayTimeApi().deleteBatch({ids: state.deleteArr}); |
| | | if (res.data.code === '200') { |
| | | state.deleteSetDialog = false |
| | | ElMessage({ |
| | |
| | | // 查看记录 |
| | | const viewRecord = (row) => { |
| | | state.details = JSON.parse(JSON.stringify(row)) |
| | | if(row.list==[]){ |
| | | state.details.list = [] |
| | | }else{ |
| | | state.details.list = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | state.details.list.push(state.workTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | state.dialogDetails = true |
| | | } |
| | | |
| | |
| | | const reLoadData = async () =>{ |
| | | getListByPage() |
| | | } |
| | | // 点击修改 |
| | | const editRecordBtn = (index, row) => { |
| | | state.dialogAddRecord = true |
| | | state.chosenIndex = index |
| | | state.addRecord = JSON.parse(JSON.stringify(row)) |
| | | } |
| | | const closeAdd = () => { |
| | | state.addRecord = {} |
| | | state.chosenIndex = null |
| | | } |
| | | const openAdd = () => { |
| | | if (state.chosenIndex == null) { |
| | | state.addRecord.info = '' |
| | | } |
| | | } |
| | | |
| | | const indexClear = () => { |
| | | state.deleteId = null |
| | | } |
| | |
| | | Delete, |
| | | Refresh, |
| | | Plus, |
| | | toNames, |
| | | typeChange, |
| | | ruleChange, |
| | | compare, |
| | | toggleSelection, |
| | | handleSelectionChange, |
| | | deleteBatchBtn, |
| | | conFirmDeleteBatch, |
| | | searchRecord, |
| | | clearSearch, |
| | | viewRecord, |
| | | deleteRecordBtn, |
| | | conFirmDelete, |
| | | getListByPage, |
| | | getWorkTimePeriod, |
| | | reLoadData, |
| | | deleteRecord, |
| | | deleteBatchBtn, |
| | | conFirmDeleteBatch, |
| | | handleSizeChange, |
| | | handleCurrentChange, |
| | | confirmAddRecord, |
| | | closeAdd, |
| | | openAdd, |
| | | indexClear, |
| | | editRecordBtn, |
| | | ...toRefs(state) |
copy from src/views/system/personShiftManage/workingHoursSet/index.vue
copy to src/views/system/personShiftManage/personTimeManage/holidayTimeGroup/index.vue
文件从 src/views/system/personShiftManage/workingHoursSet/index.vue 复制 |
| | |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="100" /> |
| | | <el-table-column property="name" label="工作时间组名称"/> |
| | | <el-table-column property="list" :formatter="toNames" label="关联工作时段"/> |
| | | <el-table-column property="name" label="休息时间组名称"/> |
| | | <el-table-column property="list" :formatter="toNames" label="关联休息时间"/> |
| | | <el-table-column property="info" label="描述信息"/> |
| | | <el-table-column fixed="right" label="操作" align="center" width="250"> |
| | | <template #default="scope"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-dialog v-model="dialogDetails" title="工作时间组"> |
| | | <el-dialog v-model="dialogDetails" title="休息时间组"> |
| | | <el-form :model="details" label-width="120px"> |
| | | <el-form-item label="时间组名称"> |
| | | <el-input |
| | |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" v-if="details.list.length>0"> |
| | | <el-form-item label="关联休息时间" v-if="details.list.length>0"> |
| | | <el-input |
| | | v-model="details.list" |
| | | readonly |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | <el-dialog v-model="dialogAddRecord" title="工作时间组编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-dialog v-model="dialogAddRecord" title="休息时间组编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-form :model="addRecord" label-width="120px" ref="addRef" :rules="addRules"> |
| | | <el-form-item label="时间组名称" prop="name"> |
| | | <el-input |
| | |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" prop="list"> |
| | | <el-form-item label="关联休息时间" prop="list"> |
| | | <el-select v-model="addRecord.list" multiple> |
| | | <el-option v-for="(item,index) in workTimeList" :key="index" :label="item.name" :value="item.id" /> |
| | | <el-option v-for="(item,index) in holidayTimeList" :key="index" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" prop="info"> |
| | |
| | | import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue' |
| | | import { ElTable } from 'element-plus' |
| | | import { FormInstance, FormRules, ElMessage } from 'element-plus' |
| | | import { workingHoursSetApi } from '/@/api/basicDateManage/personShiftManage/workingHoursSet'; |
| | | import { workingHoursApi } from '/@/api/basicDateManage/personShiftManage/workingHours'; |
| | | import { holidayGroupApi } from '/@/api/basicDateManage/personShiftManage/holidayTimeGroup'; |
| | | |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface stateType { |
| | | tableData: Array<string>, |
| | | pageRecord: Array<string>, |
| | | workTimeList: Array<string>, |
| | | holidayTimeList: Array<string>, |
| | | multipleSelection: Array<any>, |
| | | deleteArr: Array<any>, |
| | | dialogDetails: boolean, |
| | |
| | | chosenIndex: null, |
| | | searchWord: '', |
| | | tableData: [], |
| | | pageRecord: [], |
| | | workTimeList: [], |
| | | holidayTimeList: [], |
| | | multipleSelection: [], |
| | | dialogDetails: false, |
| | | dialogAddRecord: false, |
| | |
| | | }) |
| | | interface User { |
| | | name: string, |
| | | list: [], |
| | | list: Array<any>, |
| | | info: string |
| | | } |
| | | const multipleTableRef = ref<InstanceType<typeof ElTable>>() |
| | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | getListByPage() |
| | | getWorkTimePeriod() |
| | | getAllBreak() |
| | | }) |
| | | |
| | | // 分页获取工作时间组列表 |
| | | // 分页获取休息时间组列表 |
| | | const getListByPage = async ()=>{ |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{name: state.searchWord}} |
| | | let res = await workingHoursSetApi().postWorkTimeGroupPage(data); |
| | | let res = await holidayGroupApi().getRecordPage(data); |
| | | if (res.data.code === '200') { |
| | | state.pageRecord = res.data.data |
| | | state.tableData = res.data.data.map((item)=>{ |
| | | if(item.list == null){ |
| | | item.list = [] |
| | | }else{ |
| | | item.list= Array.from(item.list,({workTimePeriodId})=>workTimePeriodId) |
| | | item.list= Array.from(item.list,({breakTimeRuleId})=>breakTimeRuleId) |
| | | } |
| | | return item |
| | | }) |
| | |
| | | }else{ |
| | | const nameList = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | nameList.push(state.workTimeList[t].name) |
| | | for(let t=0;t<state.holidayTimeList.length;t++){ |
| | | if(row.list[i]==state.holidayTimeList[t].id){ |
| | | nameList.push(state.holidayTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // 获取工作时段列表 |
| | | const getWorkTimePeriod = async () => { |
| | | let res = await workingHoursApi().getWorkTimePeriod(); |
| | | const getAllBreak = async () => { |
| | | let res = await holidayGroupApi().getAllBreak(); |
| | | if (res.data.code === '200') { |
| | | state.workTimeList = res.data.data |
| | | console.log(state.workTimeList,'list') |
| | | state.holidayTimeList = res.data.data |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | |
| | | |
| | | // 添加工作时段方法 |
| | | const addRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().addWorkTimeGroup(data); |
| | | let res = await holidayGroupApi().addRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | |
| | | // 修改工作时段方法 |
| | | const editRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().updateWorkTimeGroup(data); |
| | | let res = await holidayGroupApi().updateRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | const data = { |
| | | name: state.addRecord.name, |
| | | info: state.addRecord.info, |
| | | workTimePeriodIds: state.addRecord.list |
| | | breakTimeRuleIds: state.addRecord.list |
| | | } |
| | | if (state.chosenIndex == null) { |
| | | await addRecord(data) |
| | | } else { |
| | | data.id = JSON.stringify(state.addRecord.id), |
| | | console.log(data,'修改参数') |
| | | await editRecord(data) |
| | | } |
| | | state.dialogAddRecord = false |
| | |
| | | |
| | | // 删除工作时间组方法 |
| | | const deleteRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().deleteWorkTimeGroup(data); |
| | | let res = await holidayGroupApi().deleteRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | }; |
| | | |
| | | const conFirmDeleteBatch = async () => { |
| | | let res = await workingHoursSetApi().deletBatchWorkTimeGroup({ids: state.deleteArr}); |
| | | let res = await holidayGroupApi().deletBatchRecord({ids: state.deleteArr}); |
| | | if (res.data.code === '200') { |
| | | state.deleteSetDialog = false |
| | | ElMessage({ |
| | |
| | | }else{ |
| | | state.details.list = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | state.details.list.push(state.workTimeList[t].name) |
| | | for(let t=0;t<state.holidayTimeList.length;t++){ |
| | | if(row.list[i]==state.holidayTimeList[t].id){ |
| | | state.details.list.push(state.holidayTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | |
| | | deleteRecordBtn, |
| | | conFirmDelete, |
| | | getListByPage, |
| | | getWorkTimePeriod, |
| | | getAllBreak, |
| | | reLoadData, |
| | | deleteRecord, |
| | | deleteBatchBtn, |
copy from src/views/system/personShiftManage/workingHoursSet/index.vue
copy to src/views/system/personShiftManage/personTimeManage/timeStrategy/index.vue
文件从 src/views/system/personShiftManage/workingHoursSet/index.vue 复制 |
| | |
| | | <el-row class="homeCard"> |
| | | <el-col :span="8"> |
| | | <div class="grid-content topInfo"> |
| | | <el-input v-model="searchWord" placeholder="休息时间组名称"></el-input> |
| | | <el-input v-model="searchWord" placeholder="时间策略名称"></el-input> |
| | | <el-button type="primary" @click="searchRecord">查询</el-button> |
| | | <el-button plain @click="clearSearch">重置</el-button> |
| | | </div> |
| | |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="100" /> |
| | | <el-table-column property="name" label="工作时间组名称"/> |
| | | <el-table-column property="list" :formatter="toNames" label="关联工作时段"/> |
| | | <el-table-column property="name" label="时间策略名称"/> |
| | | <el-table-column property="workList" label="关联工作时间组"/> |
| | | <el-table-column property="restList" label="关联休息时间组"/> |
| | | <el-table-column property="info" label="描述信息"/> |
| | | <el-table-column fixed="right" label="操作" align="center" width="250"> |
| | | <template #default="scope"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-dialog v-model="dialogDetails" title="工作时间组"> |
| | | <el-dialog v-model="dialogDetails" title="时间策略"> |
| | | <el-form :model="details" label-width="120px"> |
| | | <el-form-item label="时间组名称"> |
| | | <el-form-item label="策略名称"> |
| | | <el-input |
| | | v-model="details.name" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" v-if="details.list.length>0"> |
| | | <el-form-item label="关联工作时间组"> |
| | | <el-input |
| | | v-model="details.list" |
| | | v-model="details.workList" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="关联休息时间组"> |
| | | <el-input |
| | | v-model="details.restList" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | <el-dialog v-model="dialogAddRecord" title="工作时间组编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-dialog v-model="dialogAddRecord" title="时间策略编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-form :model="addRecord" label-width="120px" ref="addRef" :rules="addRules"> |
| | | <el-form-item label="时间组名称" prop="name"> |
| | | <el-form-item label="策略名称" prop="name"> |
| | | <el-input |
| | | v-model="addRecord.name" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" prop="list"> |
| | | <el-select v-model="addRecord.list" multiple> |
| | | <el-form-item label="关联工作时间组" prop="workList"> |
| | | <el-select v-model="addRecord.workList"> |
| | | <el-option v-for="(item,index) in workTimeList" :key="index" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="关联休息时间组" prop="restList"> |
| | | <el-select v-model="addRecord.restList"> |
| | | <el-option v-for="(item,index) in restTimeList" :key="index" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" prop="info"> |
| | |
| | | import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue' |
| | | import { ElTable } from 'element-plus' |
| | | import { FormInstance, FormRules, ElMessage } from 'element-plus' |
| | | import { workingHoursSetApi } from '/@/api/basicDateManage/personShiftManage/workingHoursSet'; |
| | | import { workingHoursApi } from '/@/api/basicDateManage/personShiftManage/workingHours'; |
| | | import { timeStrategyApi } from '/@/api/basicDateManage/personShiftManage/timeStrategy'; |
| | | |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface stateType { |
| | | tableData: Array<string>, |
| | | pageRecord: Array<string>, |
| | | workTimeList: Array<string>, |
| | | restTimeList: Array<string>, |
| | | multipleSelection: Array<any>, |
| | | deleteArr: Array<any>, |
| | | dialogDetails: boolean, |
| | |
| | | totalSize: number, |
| | | addRecord: { |
| | | name: string, |
| | | list: Array<any>, |
| | | workList: string, |
| | | restList: string, |
| | | info: string |
| | | }, |
| | | details: { |
| | | name: string, |
| | | list: Array<any>, |
| | | workList: string, |
| | | restList: string, |
| | | info: string |
| | | } |
| | | } |
| | |
| | | chosenIndex: null, |
| | | searchWord: '', |
| | | tableData: [], |
| | | pageRecord: [], |
| | | workTimeList: [], |
| | | restTimeList: [], |
| | | multipleSelection: [], |
| | | dialogDetails: false, |
| | | dialogAddRecord: false, |
| | |
| | | deleteSetDialog: false, |
| | | addRecord: { |
| | | name: '', |
| | | list: [], |
| | | workList: '', |
| | | restList: '', |
| | | info: '' |
| | | }, |
| | | details: { |
| | | name: '', |
| | | list: [], |
| | | workList: '', |
| | | restList: '', |
| | | info: '' |
| | | }, |
| | | deleteId: null, |
| | |
| | | }) |
| | | interface User { |
| | | name: string, |
| | | list: [], |
| | | workList: string, |
| | | restList: string, |
| | | info: string |
| | | } |
| | | const multipleTableRef = ref<InstanceType<typeof ElTable>>() |
| | |
| | | const addRef = ref<FormInstance>() |
| | | const addRules = reactive<FormRules>({ |
| | | name: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | list: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | workList: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | restList: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | }) |
| | | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | getListByPage() |
| | | getWorkTimePeriod() |
| | | getWorkTimeList() |
| | | getRestTimeList() |
| | | }) |
| | | |
| | | // 分页获取工作时间组列表 |
| | | // 分页获取休息时间组列表 |
| | | const getListByPage = async ()=>{ |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{name: state.searchWord}} |
| | | let res = await workingHoursSetApi().postWorkTimeGroupPage(data); |
| | | let res = await timeStrategyApi().getRecordPage(data); |
| | | if (res.data.code === '200') { |
| | | state.pageRecord = res.data.data |
| | | state.tableData = res.data.data.map((item)=>{ |
| | | if(item.list == null){ |
| | | item.list = [] |
| | | // if(item.workTimeGroupRespDTO == null || item.workTimeGroupRespDTO.list == []){ |
| | | // item.workList = [] |
| | | // }else{ |
| | | // item.workList= Array.from(item.workTimeGroupRespDTO.list,({workTimeGroupId})=>workTimeGroupId) |
| | | // } |
| | | // if(item.breakTimeGroupRespDTO == null || item.breakTimeGroupRespDTO.list == []){ |
| | | // item.restList = [] |
| | | // }else{ |
| | | // item.restList= Array.from(item.breakTimeGroupRespDTO.list,({breakTimeGroupId})=>breakTimeGroupId) |
| | | // } |
| | | if(item.workTimeGroupRespDTO == null){ |
| | | item.workList = '' |
| | | }else{ |
| | | item.list= Array.from(item.list,({workTimePeriodId})=>workTimePeriodId) |
| | | item.workList= item.workTimeGroupRespDTO.name |
| | | } |
| | | if(item.breakTimeGroupRespDTO == null){ |
| | | item.restList = '' |
| | | }else{ |
| | | item.restList= item.breakTimeGroupRespDTO.name |
| | | } |
| | | return item |
| | | }) |
| | | console.log(state.tableData,'state.tableData') |
| | | state.totalSize = res.data.total |
| | | } else { |
| | | ElMessage({ |
| | |
| | | } |
| | | } |
| | | |
| | | // 表格数据格式化 |
| | | const toNames =(row, column, cellValue, index) => { |
| | | if(row.list==[]){ |
| | | return [] |
| | | }else{ |
| | | const nameList = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | nameList.push(state.workTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | | return nameList.join() |
| | | // 获取工作时间组列表 |
| | | const getWorkTimeList = async () => { |
| | | let res = await timeStrategyApi().getWorkTimeList(); |
| | | if (res.data.code === '200') { |
| | | state.workTimeList = res.data.data |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 获取工作时段列表 |
| | | const getWorkTimePeriod = async () => { |
| | | let res = await workingHoursApi().getWorkTimePeriod(); |
| | | // 获取休息时间组列表 |
| | | const getRestTimeList = async () => { |
| | | let res = await timeStrategyApi().getRestTimeList(); |
| | | if (res.data.code === '200') { |
| | | state.workTimeList = res.data.data |
| | | console.log(state.workTimeList,'list') |
| | | state.restTimeList = res.data.data |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | |
| | | |
| | | // 添加工作时段方法 |
| | | const addRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().addWorkTimeGroup(data); |
| | | let res = await timeStrategyApi().addRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | |
| | | // 修改工作时段方法 |
| | | const editRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().updateWorkTimeGroup(data); |
| | | let res = await timeStrategyApi().updateRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | const data = { |
| | | name: state.addRecord.name, |
| | | info: state.addRecord.info, |
| | | workTimePeriodIds: state.addRecord.list |
| | | workTimeGroupId: state.addRecord.workList, |
| | | breakTimeGroupId: state.addRecord.restList |
| | | } |
| | | if (state.chosenIndex == null) { |
| | | await addRecord(data) |
| | | } else { |
| | | data.id = JSON.stringify(state.addRecord.id), |
| | | console.log(data,'修改参数') |
| | | data.id = JSON.stringify(state.addRecord.id) |
| | | if(typeof state.addRecord.workList == 'string'){ |
| | | data.workTimeGroupId = state.addRecord.workTimeGroupId |
| | | } |
| | | if(typeof state.addRecord.restList == 'string'){ |
| | | data.breakTimeGroupId = state.addRecord.breakTimeGroupId |
| | | } |
| | | await editRecord(data) |
| | | } |
| | | state.dialogAddRecord = false |
| | |
| | | |
| | | // 删除工作时间组方法 |
| | | const deleteRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().deleteWorkTimeGroup(data); |
| | | let res = await timeStrategyApi().deleteRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | }; |
| | | |
| | | const conFirmDeleteBatch = async () => { |
| | | let res = await workingHoursSetApi().deletBatchWorkTimeGroup({ids: state.deleteArr}); |
| | | let res = await timeStrategyApi().deletBatchRecord({ids: state.deleteArr}); |
| | | if (res.data.code === '200') { |
| | | state.deleteSetDialog = false |
| | | ElMessage({ |
| | |
| | | // 查看记录 |
| | | const viewRecord = (row) => { |
| | | state.details = JSON.parse(JSON.stringify(row)) |
| | | if(row.list==[]){ |
| | | state.details.list = [] |
| | | }else{ |
| | | state.details.list = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | state.details.list.push(state.workTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | state.dialogDetails = true |
| | | } |
| | | |
| | |
| | | state.dialogAddRecord = true |
| | | state.chosenIndex = index |
| | | state.addRecord = JSON.parse(JSON.stringify(row)) |
| | | console.log(state.addRecord,'state.addRecord') |
| | | } |
| | | const closeAdd = () => { |
| | | state.addRecord = {} |
| | |
| | | Delete, |
| | | Refresh, |
| | | Plus, |
| | | toNames, |
| | | toggleSelection, |
| | | handleSelectionChange, |
| | | searchRecord, |
| | |
| | | deleteRecordBtn, |
| | | conFirmDelete, |
| | | getListByPage, |
| | | getWorkTimePeriod, |
| | | getWorkTimeList, |
| | | getRestTimeList, |
| | | reLoadData, |
| | | deleteRecord, |
| | | deleteBatchBtn, |
文件名从 src/views/system/personShiftManage/workingHoursSet/index.vue 修改 |
| | |
| | | // 定义接口来定义对象的类型 |
| | | interface stateType { |
| | | tableData: Array<string>, |
| | | pageRecord: Array<string>, |
| | | workTimeList: Array<string>, |
| | | multipleSelection: Array<any>, |
| | | deleteArr: Array<any>, |
| | |
| | | chosenIndex: null, |
| | | searchWord: '', |
| | | tableData: [], |
| | | pageRecord: [], |
| | | workTimeList: [], |
| | | multipleSelection: [], |
| | | dialogDetails: false, |
| | |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{name: state.searchWord}} |
| | | let res = await workingHoursSetApi().postWorkTimeGroupPage(data); |
| | | if (res.data.code === '200') { |
| | | state.pageRecord = res.data.data |
| | | state.tableData = res.data.data.map((item)=>{ |
| | | if(item.list == null){ |
| | | item.list = [] |
copy from src/views/system/personShiftManage/workingHoursSet/index.vue
copy to src/views/system/personShiftManage/shiftManage/teamManage/index.vue
文件从 src/views/system/personShiftManage/workingHoursSet/index.vue 复制 |
| | |
| | | <el-row class="homeCard"> |
| | | <el-col :span="8"> |
| | | <div class="grid-content topInfo"> |
| | | <el-input v-model="searchWord" placeholder="休息时间组名称"></el-input> |
| | | <el-input v-model="searchWord" placeholder="时间策略名称"></el-input> |
| | | <el-button type="primary" @click="searchRecord">查询</el-button> |
| | | <el-button plain @click="clearSearch">重置</el-button> |
| | | </div> |
| | |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="100" /> |
| | | <el-table-column property="name" label="工作时间组名称"/> |
| | | <el-table-column property="list" :formatter="toNames" label="关联工作时段"/> |
| | | <el-table-column property="info" label="描述信息"/> |
| | | <el-table-column property="groupName" label="班组名称"/> |
| | | <el-table-column property="groupMembers" label="班组人员" width="180" :show-overflow-tooltip="true"/> |
| | | <el-table-column property="groupInfo" label="描述"/> |
| | | <el-table-column fixed="right" label="操作" align="center" width="250"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" :icon="View" @click="viewRecord(scope.row)">查看</el-button> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-dialog v-model="dialogDetails" title="工作时间组"> |
| | | <el-dialog v-model="dialogDetails" title="时间策略"> |
| | | <el-form :model="details" label-width="120px"> |
| | | <el-form-item label="时间组名称"> |
| | | <el-form-item label="班组名称"> |
| | | <el-input |
| | | v-model="details.name" |
| | | v-model="details.groupName" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" v-if="details.list.length>0"> |
| | | <el-input |
| | | v-model="details.list" |
| | | readonly |
| | | /> |
| | | <el-form-item label="班组人员"> |
| | | <el-input v-model="details.groupMembers" type="textarea" readonly/> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" v-if="details.info"> |
| | | <el-input |
| | | v-model="details.info" |
| | | type="textarea" |
| | | readonly |
| | | /> |
| | | <el-form-item label="描述"> |
| | | <el-input v-model="details.groupInfo" type="textarea" readonly/> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="dialogDetails = false" size="default">确认</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | <el-dialog v-model="dialogAddRecord" title="工作时间组编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-dialog v-model="dialogAddRecord" title="时间策略编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-form :model="addRecord" label-width="120px" ref="addRef" :rules="addRules"> |
| | | <el-form-item label="时间组名称" prop="name"> |
| | | <el-form-item label="班组名称" prop="groupName"> |
| | | <el-input |
| | | v-model="addRecord.name" |
| | | v-model="addRecord.groupName" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="关联工作时段" prop="list"> |
| | | <el-select v-model="addRecord.list" multiple> |
| | | <el-option v-for="(item,index) in workTimeList" :key="index" :label="item.name" :value="item.id" /> |
| | | <el-form-item label="选择部门" prop="department"> |
| | | <el-cascader |
| | | v-model="addRecord.department" |
| | | :options="departmentList" |
| | | :props="casProps" |
| | | :show-all-levels="false" |
| | | @change="handleChange" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="选择人员" prop="groupMembers" v-if="addRecord.department !== ''"> |
| | | <el-select v-model="addRecord.groupMembers" multiple> |
| | | <el-option v-for="(item,index) in workerList" :label="item.username" :key="index" :value="item.uid">{{item.username}}</el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" prop="info"> |
| | | <el-form-item label="描述" prop="groupInfo"> |
| | | <el-input |
| | | v-model="addRecord.info" |
| | | v-model="addRecord.groupInfo" |
| | | type="textarea" |
| | | > |
| | | </el-input> |
| | |
| | | import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue' |
| | | import { ElTable } from 'element-plus' |
| | | import { FormInstance, FormRules, ElMessage } from 'element-plus' |
| | | import { workingHoursSetApi } from '/@/api/basicDateManage/personShiftManage/workingHoursSet'; |
| | | import { workingHoursApi } from '/@/api/basicDateManage/personShiftManage/workingHours'; |
| | | import { teamManageApi } from '/@/api/basicDateManage/personShiftManage/teamManage'; |
| | | |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface stateType { |
| | | tableData: Array<string>, |
| | | pageRecord: Array<string>, |
| | | workTimeList: Array<string>, |
| | | departmentList: Array<any>, |
| | | workerList: Array<string>, |
| | | casProps: {}, |
| | | multipleSelection: Array<any>, |
| | | deleteArr: Array<any>, |
| | | dialogDetails: boolean, |
| | |
| | | searchWord: string, |
| | | totalSize: number, |
| | | addRecord: { |
| | | name: string, |
| | | list: Array<any>, |
| | | info: string |
| | | groupName: string, |
| | | department: number | null, |
| | | depId: number | null, |
| | | groupMembers: Array<any>, |
| | | groupInfo: string |
| | | }, |
| | | details: { |
| | | name: string, |
| | | list: Array<any>, |
| | | info: string |
| | | groupName: string, |
| | | department: number | null, |
| | | groupMembers: Array<any>, |
| | | groupInfo: string |
| | | } |
| | | } |
| | | |
| | |
| | | chosenIndex: null, |
| | | searchWord: '', |
| | | tableData: [], |
| | | pageRecord: [], |
| | | workTimeList: [], |
| | | departmentList: [], |
| | | department: '', |
| | | workerList: [], |
| | | casProps: { |
| | | expandTrigger: 'hover', |
| | | emitPath: false, |
| | | value: 'depId', |
| | | label: 'depName' |
| | | }, |
| | | multipleSelection: [], |
| | | dialogDetails: false, |
| | | dialogAddRecord: false, |
| | | deleteDialog: false, |
| | | deleteSetDialog: false, |
| | | addRecord: { |
| | | name: '', |
| | | list: [], |
| | | info: '' |
| | | groupName: '', |
| | | department: null, |
| | | groupMembers: [], |
| | | depId: null, |
| | | groupInfo: '' |
| | | }, |
| | | details: { |
| | | name: '', |
| | | list: [], |
| | | info: '' |
| | | groupName: '', |
| | | department: null, |
| | | groupMembers: [], |
| | | depId: null, |
| | | groupInfo: '' |
| | | }, |
| | | deleteId: null, |
| | | deleteArr: [] |
| | | }) |
| | | interface User { |
| | | name: string, |
| | | list: [], |
| | | info: string |
| | | groupName: string, |
| | | department: number | null, |
| | | depId: number, |
| | | groupMembers: Array<any>, |
| | | groupInfo: string |
| | | } |
| | | const multipleTableRef = ref<InstanceType<typeof ElTable>>() |
| | | const toggleSelection = (rows?: User[]) => { |
| | |
| | | |
| | | const addRef = ref<FormInstance>() |
| | | const addRules = reactive<FormRules>({ |
| | | name: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | list: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | groupName: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | department: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | groupMembers: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | }) |
| | | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | getListByPage() |
| | | getWorkTimePeriod() |
| | | getAllDepartment() |
| | | }) |
| | | |
| | | // 分页获取工作时间组列表 |
| | | // 分页获取班组管理列表 |
| | | const getListByPage = async ()=>{ |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{name: state.searchWord}} |
| | | let res = await workingHoursSetApi().postWorkTimeGroupPage(data); |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{groupName: state.searchWord,containGroupMemberEnable: true}} |
| | | let res = await teamManageApi().getRecordPage(data); |
| | | if (res.data.code === '200') { |
| | | state.pageRecord = res.data.data |
| | | state.tableData = res.data.data.map((item)=>{ |
| | | if(item.list == null){ |
| | | item.list = [] |
| | | if(!item.groupMembers || item.groupMembers == null){ |
| | | item.groupMembers = [] |
| | | }else{ |
| | | item.list= Array.from(item.list,({workTimePeriodId})=>workTimePeriodId) |
| | | item.groupMembers= Array.from(item.groupMembers,({username})=>username) |
| | | } |
| | | return item |
| | | }) |
| | |
| | | } |
| | | } |
| | | |
| | | // 表格数据格式化 |
| | | const toNames =(row, column, cellValue, index) => { |
| | | if(row.list==[]){ |
| | | return [] |
| | | }else{ |
| | | const nameList = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | nameList.push(state.workTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | | return nameList.join() |
| | | // 获取部门列表 |
| | | const getAllDepartment = async () => { |
| | | let res = await teamManageApi().getAllDepartment(); |
| | | if (res.data.code === '200') { |
| | | state.departmentList = res.data.data |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 获取工作时段列表 |
| | | const getWorkTimePeriod = async () => { |
| | | let res = await workingHoursApi().getWorkTimePeriod(); |
| | | if (res.data.code === '200') { |
| | | state.workTimeList = res.data.data |
| | | console.log(state.workTimeList,'list') |
| | | } else { |
| | | const handleChange = async (value)=>{ |
| | | state.addRecord.depId = value |
| | | console.log(state.addRecord.department,'de') |
| | | let res = await teamManageApi().getAllMember(value); |
| | | if(res.data.code === '200'){ |
| | | state.workerList = res.data.data |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | |
| | | getListByPage() |
| | | } |
| | | |
| | | // 添加工作时段方法 |
| | | // 添加班组管理方法 |
| | | const addRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().addWorkTimeGroup(data); |
| | | let res = await teamManageApi().addRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | }; |
| | | |
| | | // 修改工作时段方法 |
| | | const editRecordBtn = async (index, row) => { |
| | | state.addRecord = JSON.parse(JSON.stringify(row)) |
| | | state.addRecord.department = '' |
| | | state.addRecord.groupMembers = [] |
| | | state.dialogAddRecord = true |
| | | state.chosenIndex = index |
| | | } |
| | | |
| | | const editRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().updateWorkTimeGroup(data); |
| | | let res = await teamManageApi().updateRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | await formEl.validate(async (valid, fields) => { |
| | | if (valid) { |
| | | const data = { |
| | | name: state.addRecord.name, |
| | | info: state.addRecord.info, |
| | | workTimePeriodIds: state.addRecord.list |
| | | groupName: state.addRecord.groupName, |
| | | groupInfo: state.addRecord.groupInfo, |
| | | depId: state.addRecord.depId, |
| | | groupMemberIds: state.addRecord.groupMembers |
| | | } |
| | | if (state.chosenIndex == null) { |
| | | await addRecord(data) |
| | | } else { |
| | | data.id = JSON.stringify(state.addRecord.id), |
| | | console.log(data,'修改参数') |
| | | data.groupId = JSON.stringify(state.addRecord.groupId) |
| | | await editRecord(data) |
| | | } |
| | | state.dialogAddRecord = false |
| | |
| | | |
| | | // 删除工作时间组方法 |
| | | const deleteRecord = async (data:any) => { |
| | | let res = await workingHoursSetApi().deleteWorkTimeGroup(data); |
| | | let res = await teamManageApi().deleteRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | } |
| | | |
| | | const deleteRecordBtn = (row) => { |
| | | state.deleteId = row.id |
| | | console.log(row,'row') |
| | | state.deleteId = row.groupId |
| | | state.deleteDialog = true |
| | | } |
| | | |
| | | const conFirmDelete = () => { |
| | | deleteRecord({ id: state.deleteId }) |
| | | deleteRecord({ groupId: state.deleteId }) |
| | | state.deleteDialog = false |
| | | } |
| | | |
| | | // 批量删除 |
| | | const deleteBatchBtn = async () => { |
| | | if (state.deleteArr.length > 0) { |
| | | state.deleteSetDialog = true |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '请先选择要删除的记录' |
| | | }); |
| | | } |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '抱歉,本页面暂不支持批量删除' |
| | | }); |
| | | // if (state.deleteArr.length > 0) { |
| | | // state.deleteSetDialog = true |
| | | // } else { |
| | | // ElMessage({ |
| | | // type: 'warning', |
| | | // message: '请先选择要删除的记录' |
| | | // }); |
| | | // } |
| | | }; |
| | | |
| | | const conFirmDeleteBatch = async () => { |
| | | let res = await workingHoursSetApi().deletBatchWorkTimeGroup({ids: state.deleteArr}); |
| | | if (res.data.code === '200') { |
| | | state.deleteSetDialog = false |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: res.data.msg |
| | | }); |
| | | getListByPage() |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | state.deleteSetDialog = false |
| | | } |
| | | } |
| | | // const conFirmDeleteBatch = async () => { |
| | | // let res = await teamManageApi().deletBatchRecord({ids: state.deleteArr}); |
| | | // if (res.data.code === '200') { |
| | | // state.deleteSetDialog = false |
| | | // ElMessage({ |
| | | // type: 'success', |
| | | // message: res.data.msg |
| | | // }); |
| | | // getListByPage() |
| | | // } else { |
| | | // ElMessage({ |
| | | // type: 'warning', |
| | | // message: res.data.msg |
| | | // }); |
| | | // state.deleteSetDialog = false |
| | | // } |
| | | // } |
| | | |
| | | const handleSizeChange = (val: number) => { |
| | | state.pageSize = val |
| | |
| | | // 查看记录 |
| | | const viewRecord = (row) => { |
| | | state.details = JSON.parse(JSON.stringify(row)) |
| | | if(row.list==[]){ |
| | | state.details.list = [] |
| | | }else{ |
| | | state.details.list = [] |
| | | for(let i=0;i<row.list.length;i++){ |
| | | for(let t=0;t<state.workTimeList.length;t++){ |
| | | if(row.list[i]==state.workTimeList[t].id){ |
| | | state.details.list.push(state.workTimeList[t].name) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | state.dialogDetails = true |
| | | } |
| | | |
| | |
| | | const reLoadData = async () =>{ |
| | | getListByPage() |
| | | } |
| | | // 点击修改 |
| | | const editRecordBtn = (index, row) => { |
| | | state.dialogAddRecord = true |
| | | state.chosenIndex = index |
| | | state.addRecord = JSON.parse(JSON.stringify(row)) |
| | | } |
| | | |
| | | const closeAdd = () => { |
| | | state.addRecord = {} |
| | | state.chosenIndex = null |
| | |
| | | Delete, |
| | | Refresh, |
| | | Plus, |
| | | toNames, |
| | | handleChange, |
| | | toggleSelection, |
| | | handleSelectionChange, |
| | | searchRecord, |
| | |
| | | deleteRecordBtn, |
| | | conFirmDelete, |
| | | getListByPage, |
| | | getWorkTimePeriod, |
| | | reLoadData, |
| | | deleteRecord, |
| | | deleteBatchBtn, |
| | | conFirmDeleteBatch, |
| | | handleSizeChange, |
| | | handleCurrentChange, |
| | | confirmAddRecord, |
对比新文件 |
| | |
| | | <template> |
| | | <div class="home-container"> |
| | | <div style="height: 100%"> |
| | | <el-row class="homeCard"> |
| | | <el-col :span="8"> |
| | | <div class="grid-content topInfo"> |
| | | <el-input v-model="searchWord" placeholder="时间策略名称"></el-input> |
| | | <el-button type="primary" @click="searchRecord">查询</el-button> |
| | | <el-button plain @click="clearSearch">重置</el-button> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | <div class="homeCard"> |
| | | <div class="main-card"> |
| | | <el-row class="cardTop"> |
| | | <el-col :span="12" class="mainCardBtn"> |
| | | <el-button type="primary" :icon="Plus" size="default" @click="dialogAddRecord=true">新建</el-button> |
| | | <!-- <el-button type="warning" :icon="Edit" size="default" plain>修改</el-button>--> |
| | | <el-button type="danger" :icon="Delete" size="default" plain @click="deleteBatchBtn">删除</el-button> |
| | | </el-col> |
| | | <el-button type="primary" :icon="Refresh" size="default" @click="reLoadData()"/> |
| | | </el-row> |
| | | <el-table |
| | | ref="multipleTableRef" |
| | | :data="tableData" |
| | | style="width: 100%" |
| | | height="calc(100% - 100px)" |
| | | :header-cell-style="{background: '#fafafa'}" |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="100" /> |
| | | <el-table-column property="groupStrategyName" label="班组策略名称"/> |
| | | <el-table-column property="timeStrategy" label="时间策略" width="180" :show-overflow-tooltip="true"/> |
| | | <el-table-column property="cycleName" label="循环类型" :show-overflow-tooltip="true"/> |
| | | <el-table-column property="groupNames" label="班组"/> |
| | | <el-table-column property="cycleStartTime" label="排班开始时间" width="160"/> |
| | | <el-table-column property="groupStrategyInfo" label="描述信息"/> |
| | | <el-table-column fixed="right" label="操作" align="center" width="250"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" :icon="View" @click="viewRecord(scope.row)">查看</el-button> |
| | | <el-button link type="primary" size="small" :icon="Edit" @click="editRecordBtn(scope.$index ,scope.row)">修改</el-button> |
| | | <el-button link type="danger" size="small" :icon="Delete" @click="deleteRecordBtn(scope.row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div class="pageBtn"> |
| | | <el-pagination |
| | | v-model:currentPage="pageIndex" |
| | | v-model:page-size="pageSize" |
| | | :page-sizes="[10, 15]" |
| | | small=false |
| | | background |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="totalSize" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <el-dialog v-model="dialogDetails" title="班组策略"> |
| | | <el-form :model="details" label-width="120px"> |
| | | <el-form-item label="策略名称"> |
| | | <el-input |
| | | v-model="details.groupStrategyName" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="时间策略"> |
| | | <el-input |
| | | v-model="details.timeStrategy" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="循环类型"> |
| | | <el-input |
| | | v-model="details.cycleName" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="班组"> |
| | | <el-input |
| | | v-model="details.groupNames" |
| | | type="textarea" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="排班开始时间"> |
| | | <el-input |
| | | v-model="details.cycleStartTime" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" v-if="details.groupStrategyInfo"> |
| | | <el-input |
| | | v-model="details.groupStrategyInfo" |
| | | type="textarea" |
| | | readonly |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="dialogDetails = false" size="default">确认</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | <el-dialog v-model="dialogAddRecord" title="班组策略编辑" @close="closeAdd" @open="openAdd"> |
| | | <el-form :model="addRecord" label-width="120px" ref="addRef" :rules="addRules"> |
| | | <el-form-item label="策略名称" prop="groupStrategyName"> |
| | | <el-input |
| | | v-model="addRecord.groupStrategyName" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="时间策略" prop="timeStrategyId"> |
| | | <el-select v-model="addRecord.timeStrategyId"> |
| | | <el-option v-for="(item,index) in timeList" :key="index" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="循环类型" prop="cycle"> |
| | | <el-select v-model="addRecord.cycle"> |
| | | <el-option v-for="(item,index) in cycleList" :key="index" :label="item.name" :value="item.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="班组选择" prop="groupIds" > |
| | | <el-select v-model="addRecord.groupIds" multiple> |
| | | <el-option v-for="(item,index) in teamList" :key="index" :label="item.groupName" :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="排班开始时间" prop="cycleStartTime"> |
| | | <el-date-picker v-model="addRecord.cycleStartTime" type="date" value-format="YYYY-MM-DD"/> |
| | | </el-form-item> |
| | | <el-form-item label="描述信息" prop="groupStrategyInfo"> |
| | | <el-input |
| | | v-model="addRecord.groupStrategyInfo" |
| | | type="textarea" |
| | | > |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="warning" @click="dialogAddRecord = false" size="default" plain>取消</el-button> |
| | | <el-button type="primary" @click="confirmAddRecord(addRef)" size="default">确认</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | | <el-dialog v-model="deleteDialog" title="提示" width="30%" center @close="indexClear"> |
| | | <span>您确定要删除该条记录吗?</span> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="deleteDialog = false" size="default">取消</el-button> |
| | | <el-button type="primary" @click="conFirmDelete" size="default">确认</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | <el-dialog v-model="deleteSetDialog" title="提示" width="30%" center> |
| | | <span>您确定要删除这些记录吗?</span> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="deleteSetDialog = false" size="default">取消</el-button> |
| | | <el-button type="primary" @click="conFirmDeleteBatch" size="default">确认</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { toRefs, reactive, ref, onMounted } from 'vue'; |
| | | import { storeToRefs } from 'pinia'; |
| | | import { initBackEndControlRoutes } from '/@/router/backEnd'; |
| | | import {useUserInfo} from "/@/stores/userInfo"; |
| | | import { Session } from '/@/utils/storage'; |
| | | import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue' |
| | | import { ElTable } from 'element-plus' |
| | | import { FormInstance, FormRules, ElMessage } from 'element-plus' |
| | | import { teamStrategyApi } from '/@/api/basicDateManage/personShiftManage/teamStrategy'; |
| | | import { timeStrategyApi } from '/@/api/basicDateManage/personShiftManage/timeStrategy'; |
| | | import { teamManageApi } from '/@/api/basicDateManage/personShiftManage/teamManage'; |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface stateType { |
| | | tableData: Array<string>, |
| | | pageRecord: Array<string>, |
| | | timeList: Array<any>, |
| | | teamList: Array<any>, |
| | | cycleList: Array<any>, |
| | | multipleSelection: Array<any>, |
| | | deleteArr: Array<any>, |
| | | dialogDetails: boolean, |
| | | dialogAddRecord: boolean, |
| | | deleteDialog: boolean, |
| | | deleteSetDialog: boolean; |
| | | pageIndex: number, |
| | | pageSize: number, |
| | | chosenIndex: null | number, |
| | | deleteId: null | number, |
| | | searchWord: string, |
| | | totalSize: number, |
| | | addRecord: { |
| | | groupStrategyName: string, |
| | | timeStrategyId: number | null, |
| | | timeStrategy: string, |
| | | groupIds: Array<number>, |
| | | cycle: number | null, |
| | | cycleName: string, |
| | | cycleStartTime: string, |
| | | groupStrategyInfo: string, |
| | | groupStrategyId: number | null |
| | | }, |
| | | details: { |
| | | groupStrategyName: string, |
| | | timeStrategyId: number | null, |
| | | timeStrategy: string, |
| | | groups: Array<any>, |
| | | cycle: number | null, |
| | | cycleName: string, |
| | | cycleStartTime: string, |
| | | groupStrategyInfo: string |
| | | } |
| | | } |
| | | |
| | | export default { |
| | | name: 'teamStrategy', |
| | | components:{}, |
| | | setup() { |
| | | const userInfo = useUserInfo() |
| | | const {userInfos} = storeToRefs(userInfo); |
| | | |
| | | const state = reactive<stateType>({ |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | totalSize: 0, |
| | | chosenIndex: null, |
| | | searchWord: '', |
| | | tableData: [], |
| | | pageRecord: [], |
| | | timeList: [], |
| | | teamList: [], |
| | | cycleList: [ |
| | | { |
| | | name: '周', |
| | | value: 3 |
| | | }, |
| | | { |
| | | name: '月', |
| | | value: 2 |
| | | }, |
| | | { |
| | | name: '年', |
| | | value: 1 |
| | | } |
| | | ], |
| | | multipleSelection: [], |
| | | dialogDetails: false, |
| | | dialogAddRecord: false, |
| | | deleteDialog: false, |
| | | deleteSetDialog: false, |
| | | addRecord: { |
| | | groupStrategyName: '', |
| | | timeStrategyId: null, |
| | | timeStrategy: '', |
| | | groupIds: [], |
| | | cycle: null, |
| | | cycleName: '', |
| | | cycleStartTime: '', |
| | | groupStrategyInfo: '', |
| | | groupStrategyId: null |
| | | }, |
| | | details: { |
| | | groupStrategyName: '', |
| | | timeStrategyId: null, |
| | | timeStrategy: '', |
| | | groups: [], |
| | | cycle: null, |
| | | cycleName: '', |
| | | cycleStartTime: '', |
| | | groupStrategyInfo: '' |
| | | }, |
| | | deleteId: null, |
| | | deleteArr: [] |
| | | }) |
| | | interface User { |
| | | groupStrategyName: string, |
| | | timeStrategyId: null | number, |
| | | timeStrategy: string, |
| | | groups: Array<any>, |
| | | cycle: null | number, |
| | | cycleName: string, |
| | | cycleStartTime: string, |
| | | groupStrategyInfo: string |
| | | } |
| | | const multipleTableRef = ref<InstanceType<typeof ElTable>>() |
| | | const toggleSelection = (rows?: User[]) => { |
| | | if (rows) { |
| | | rows.forEach((row) => { |
| | | // TODO: improvement typing when refactor table |
| | | // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| | | // @ts-expect-error |
| | | multipleTableRef.value!.toggleRowSelection(row, undefined) |
| | | }) |
| | | } else { |
| | | multipleTableRef.value!.clearSelection() |
| | | } |
| | | } |
| | | |
| | | // 多选 |
| | | const handleSelectionChange = (val: User[]) => { |
| | | state.multipleSelection = JSON.parse(JSON.stringify(val)) |
| | | state.deleteArr = state.multipleSelection.map((item)=>{ |
| | | item = item.id |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | const addRef = ref<FormInstance>() |
| | | const addRules = reactive<FormRules>({ |
| | | groupStrategyName: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | timeStrategyId: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | groupIds: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | cycle: [{required: true, message: '该内容不能为空', trigger: 'blur'}], |
| | | cycleStartTime: [{required: true, message: '该内容不能为空', trigger: 'blur'}] |
| | | }) |
| | | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | getListByPage() |
| | | getTimeList() |
| | | getTeamList() |
| | | }) |
| | | |
| | | // 分页获取班组策略列表 |
| | | const getListByPage = async ()=>{ |
| | | const data = {pageSize: state.pageSize,pageIndex: state.pageIndex,searchParams:{name: state.searchWord,containGroupEnable:true}} |
| | | let res = await teamStrategyApi().getRecordPage(data); |
| | | if (res.data.code === '200') { |
| | | state.pageRecord = res.data.data |
| | | state.tableData = res.data.data.map((item)=>{ |
| | | item.cycleName = item.cycle==1?'年':(item.cycle==2?'月':(item.cycle==3?'周':'')) |
| | | if(!item.groups || item.groups == null){ |
| | | item.groups = [] |
| | | }else{ |
| | | item.groups = item.groups.map((i) =>{ |
| | | return Object.assign({},{'groupId':i.groupId,'groupName':i.groupName}) |
| | | }) |
| | | item.groupIds= Array.from(item.groups,({groupId})=> groupId) |
| | | item.groupNames= Array.from(item.groups,({groupName})=> groupName) |
| | | } |
| | | return item |
| | | }) |
| | | state.tableData.map(async(item)=>{ |
| | | if(!item.timeStrategyId || item.timeStrategyId == null){ |
| | | item.timeStrategy = '' |
| | | }else{ |
| | | let op = await timeStrategyApi().getRecordById({id: item.timeStrategyId}) |
| | | if(op.data.code&&op.data.code === '200'){ |
| | | if(op.data.data){ |
| | | item.timeStrategy = op.data.data.name |
| | | }else{ |
| | | item.timeStrategy = '' |
| | | } |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | return item |
| | | }) |
| | | console.log(state.tableData,'state.tableData') |
| | | state.totalSize = res.data.total |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 循环类型格式化 |
| | | // const toNames =(row, column, cellValue, index) =>{ |
| | | // return row.cycle == 1? '年':(row.type == 2? '月': '周') |
| | | // } |
| | | |
| | | // 时间策略格式化 |
| | | // const timeName = async (row, column, cellValue, index) =>{ |
| | | // let res = await timeStrategyApi().getRecordById({id: row.timeStrategyId}) |
| | | // if (res.data.code === '200') { |
| | | // return row.timeStrategyId = res.name |
| | | // } else { |
| | | // ElMessage({ |
| | | // type: 'warning', |
| | | // message: res.data.msg |
| | | // }); |
| | | // } |
| | | // } |
| | | |
| | | // 获取时间策略列表 |
| | | const getTimeList = async () => { |
| | | let res = await timeStrategyApi().getAllRecord(); |
| | | if (res.data.code === '200') { |
| | | console.log(res.data.data,'timestrategy') |
| | | state.timeList = res.data.data |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 获取班组列表 |
| | | const getTeamList = async () => { |
| | | let res = await teamManageApi().getRecord({name: ''}); |
| | | if (res.data.code === '200') { |
| | | state.teamList = res.data.data |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 关键词查询记录 |
| | | const searchRecord = async()=>{ |
| | | if(state.searchWord==''){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '请输入查询关键词' |
| | | }); |
| | | }else{ |
| | | getListByPage() |
| | | } |
| | | } |
| | | |
| | | const clearSearch = async()=>{ |
| | | state.searchWord='' |
| | | getListByPage() |
| | | } |
| | | |
| | | // 添加班组策略方法 |
| | | const addRecord = async (data:any) => { |
| | | let res = await teamStrategyApi().addRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: res.data.msg |
| | | }); |
| | | getListByPage() |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | // 修改工作时段方法 |
| | | const editRecord = async (data:any) => { |
| | | let res = await teamStrategyApi().updateRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: res.data.msg |
| | | }); |
| | | getListByPage() |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | // 新增修改记录 |
| | | const confirmAddRecord = async (formEl: FormInstance | undefined) => { |
| | | if (!formEl) return |
| | | await formEl.validate(async (valid, fields) => { |
| | | if (valid) { |
| | | const data = { |
| | | groupStrategyName: state.addRecord.groupStrategyName, |
| | | groupStrategyInfo: state.addRecord.groupStrategyInfo, |
| | | groupStrategyCycleType: state.addRecord.cycle, |
| | | timeStrategyId: state.addRecord.timeStrategyId, |
| | | groupIds: state.addRecord.groupIds, |
| | | cycleStartTime: state.addRecord.cycleStartTime |
| | | } |
| | | if (state.chosenIndex == null) { |
| | | await addRecord(data) |
| | | } else { |
| | | data.groupStrategyId = JSON.stringify(state.addRecord.groupStrategyId) |
| | | await editRecord(data) |
| | | } |
| | | state.dialogAddRecord = false |
| | | } else { |
| | | console.log('error submit!', fields) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | |
| | | // 删除班组策略方法 |
| | | const deleteRecord = async (data:any) => { |
| | | let res = await teamStrategyApi().deleteRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: res.data.msg |
| | | }); |
| | | getListByPage() |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | const deleteRecordBtn = (row) => { |
| | | state.deleteId = row.groupStrategyId |
| | | state.deleteDialog = true |
| | | } |
| | | |
| | | const conFirmDelete = () => { |
| | | deleteRecord({ groupStrategyId: state.deleteId }) |
| | | state.deleteDialog = false |
| | | } |
| | | |
| | | // 批量删除 |
| | | const deleteBatchBtn = async () => { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '抱歉,本页面暂不支持批量删除' |
| | | }); |
| | | // if (state.deleteArr.length > 0) { |
| | | // state.deleteSetDialog = true |
| | | // } else { |
| | | // ElMessage({ |
| | | // type: 'warning', |
| | | // message: '请先选择要删除的记录' |
| | | // }); |
| | | // } |
| | | }; |
| | | |
| | | // const conFirmDeleteBatch = async () => { |
| | | // let res = await timeStrategyApi().deletBatchRecord({ids: state.deleteArr}); |
| | | // if (res.data.code === '200') { |
| | | // state.deleteSetDialog = false |
| | | // ElMessage({ |
| | | // type: 'success', |
| | | // message: res.data.msg |
| | | // }); |
| | | // getListByPage() |
| | | // } else { |
| | | // ElMessage({ |
| | | // type: 'warning', |
| | | // message: res.data.msg |
| | | // }); |
| | | // state.deleteSetDialog = false |
| | | // } |
| | | // } |
| | | |
| | | const handleSizeChange = (val: number) => { |
| | | state.pageSize = val |
| | | getListByPage() |
| | | } |
| | | const handleCurrentChange = (val: number) => { |
| | | state.pageIndex = val |
| | | getListByPage() |
| | | } |
| | | |
| | | // 查看记录 |
| | | const viewRecord = (row) => { |
| | | state.details = JSON.parse(JSON.stringify(row)) |
| | | state.dialogDetails = true |
| | | } |
| | | |
| | | // 刷新 |
| | | const reLoadData = async () =>{ |
| | | getListByPage() |
| | | } |
| | | // 点击修改 |
| | | const editRecordBtn = (index, row) => { |
| | | state.dialogAddRecord = true |
| | | state.chosenIndex = index |
| | | state.addRecord = JSON.parse(JSON.stringify(row)) |
| | | console.log(state.addRecord,'state.addRecord') |
| | | } |
| | | const closeAdd = () => { |
| | | state.addRecord = {} |
| | | state.chosenIndex = null |
| | | } |
| | | const openAdd = () => { |
| | | if (state.chosenIndex == null) { |
| | | state.addRecord.info = '' |
| | | } |
| | | } |
| | | const indexClear = () => { |
| | | state.deleteId = null |
| | | } |
| | | |
| | | // 折线图 |
| | | const renderMenu = async (value: string) => { |
| | | Session.set('projectId', value) |
| | | userInfos.value.projectId = value |
| | | await initBackEndControlRoutes(); |
| | | }; |
| | | return { |
| | | addRef, |
| | | addRules, |
| | | View, |
| | | Edit, |
| | | Delete, |
| | | Refresh, |
| | | Plus, |
| | | toggleSelection, |
| | | handleSelectionChange, |
| | | searchRecord, |
| | | clearSearch, |
| | | viewRecord, |
| | | deleteRecordBtn, |
| | | conFirmDelete, |
| | | getListByPage, |
| | | reLoadData, |
| | | deleteRecord, |
| | | deleteBatchBtn, |
| | | handleSizeChange, |
| | | handleCurrentChange, |
| | | confirmAddRecord, |
| | | closeAdd, |
| | | openAdd, |
| | | indexClear, |
| | | editRecordBtn, |
| | | ...toRefs(state) |
| | | }; |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | $homeNavLengh: 8; |
| | | .home-container { |
| | | height: calc(100vh - 114px); |
| | | box-sizing: border-box; |
| | | overflow: hidden; |
| | | .homeCard{ |
| | | width: 100%; |
| | | padding: 20px; |
| | | box-sizing: border-box; |
| | | background: #fff; |
| | | border-radius: 4px; |
| | | |
| | | .main-card{ |
| | | width: 100%; |
| | | height: 100%; |
| | | .cardTop{ |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | margin-bottom: 20px; |
| | | .mainCardBtn{ |
| | | margin: 0; |
| | | } |
| | | } |
| | | .pageBtn{ |
| | | height: 60px; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: right; |
| | | |
| | | .demo-pagination-block + .demo-pagination-block { |
| | | margin-top: 10px; |
| | | } |
| | | .demo-pagination-block .demonstration { |
| | | margin-bottom: 16px; |
| | | } |
| | | } |
| | | } |
| | | &:last-of-type{ |
| | | height: calc(100% - 100px); |
| | | } |
| | | } |
| | | .el-row{ |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 20px; |
| | | &:last-child { |
| | | margin-bottom: 0; |
| | | } |
| | | .grid-content{ |
| | | align-items: center; |
| | | min-height: 36px; |
| | | } |
| | | |
| | | .topInfo { |
| | | display: flex; |
| | | align-items: center; |
| | | font-size: 16px; |
| | | font-weight: bold; |
| | | |
| | | &>div{ |
| | | white-space: nowrap; |
| | | margin-right: 20px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | .el-input{ |
| | | width: 100% !important; |
| | | } |
| | | .el-date-editor::v-deep{ |
| | | width: 100%; |
| | | } |
| | | .el-select{ |
| | | width: 100%; |
| | | } |
| | | </style> |