Admin
2022-08-05 4a125073dfb0acfefc473e9439ff6a551735e0e5
src/views/system/personShiftManage/personTimeManage/holidayTimeGroup/index.vue
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 复制
@@ -29,8 +29,8 @@
                  @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">
@@ -56,7 +56,7 @@
         </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
@@ -64,7 +64,7 @@
                     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
@@ -82,7 +82,7 @@
            </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
@@ -90,9 +90,9 @@
               >
               </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">
@@ -138,15 +138,13 @@
   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,
@@ -185,8 +183,7 @@
         chosenIndex: null,
         searchWord: '',
         tableData: [],
         pageRecord: [],
         workTimeList: [],
         holidayTimeList: [],
         multipleSelection: [],
         dialogDetails: false,
         dialogAddRecord: false,
@@ -207,7 +204,7 @@
      })
      interface User {
         name: string,
         list: [],
         list: Array<any>,
         info: string
      }
      const multipleTableRef = ref<InstanceType<typeof ElTable>>()
@@ -242,20 +239,19 @@
      // 页面载入时执行方法
      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
            })
@@ -275,9 +271,9 @@
         }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)
                  }
               }
            }
@@ -286,11 +282,10 @@
      }
      // 获取工作时段列表
      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',
@@ -318,7 +313,7 @@
      // 添加工作时段方法
      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',
@@ -335,7 +330,7 @@
      // 修改工作时段方法
      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',
@@ -358,13 +353,12 @@
               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
@@ -377,7 +371,7 @@
      // 删除工作时间组方法
      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',
@@ -415,7 +409,7 @@
      };
      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({
@@ -449,9 +443,9 @@
         }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)
                  }
               }
            }
@@ -505,7 +499,7 @@
         deleteRecordBtn,
         conFirmDelete,
         getListByPage,
         getWorkTimePeriod,
         getAllBreak,
         reLoadData,
         deleteRecord,
         deleteBatchBtn,