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, |