| | |
| | | <template> |
| | | <div class="home-container"> |
| | | <el-scrollbar height="100%"> |
| | | <div style="height: 100%"> |
| | | <el-row class="homeCard"> |
| | | <el-col :span="8"> |
| | | <div class="grid-content topInfo"> |
| | |
| | | ref="multipleTableRef" |
| | | :data="tableData" |
| | | style="width: 100%" |
| | | height="calc(100% - 100px)" |
| | | :header-cell-style="{background: '#fafafa'}" |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | <div class="pageBtn"> |
| | | <el-pagination |
| | | v-model:currentPage="currentPage" |
| | | v-model:page-size="pageSize" |
| | | :page-sizes="[10, 15]" |
| | | small=false |
| | | background |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="100" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | /> |
| | | <div class="pageBtn"> |
| | | <el-pagination |
| | | v-model:currentPage="currentPage" |
| | | v-model:page-size="pageSize" |
| | | :page-sizes="[10, 15]" |
| | | small=false |
| | | background |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="100" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </el-scrollbar> |
| | | </div> |
| | | <el-dialog v-model="dialogDetails" title="排班方案"> |
| | | <el-form :model="details" label-width="120px"> |
| | | <el-form-item label="名称"> |
| | |
| | | interface type { |
| | | |
| | | } |
| | | // export default defineComponent({ |
| | | // name: 'workCheckinRecord', |
| | | // setup() { |
| | | const userInfo = useUserInfo() |
| | | const { userInfos } = storeToRefs(userInfo); |
| | | const state = reactive<stateType>({}); |
| | | const currentPage = ref(1) |
| | | const pageSize = ref(10) |
| | | const chosenIndex = ref(-1) |
| | | const chosenShiftIndex = ref(-1) |
| | | const handleSizeChange = (val: number) => { |
| | | console.log(`${val} items per page`) |
| | | } |
| | | const handleCurrentChange = (val: number) => { |
| | | console.log(`current page: ${val}`) |
| | | } |
| | | const casProps = { |
| | | expandTrigger: 'hover', |
| | | } |
| | | const tableData = reactive( |
| | | [ |
| | | const userInfo = useUserInfo() |
| | | const { userInfos } = storeToRefs(userInfo); |
| | | const state = reactive<stateType>({}); |
| | | const currentPage = ref(1) |
| | | const pageSize = ref(10) |
| | | const chosenIndex = ref(-1) |
| | | const chosenShiftIndex = ref(-1) |
| | | const handleSizeChange = (val: number) => { |
| | | console.log(`${val} items per page`) |
| | | } |
| | | const handleCurrentChange = (val: number) => { |
| | | console.log(`current page: ${val}`) |
| | | } |
| | | const casProps = { |
| | | expandTrigger: 'hover', |
| | | } |
| | | const tableData = reactive( |
| | | [ |
| | | { |
| | | name: '三班三倒', |
| | | type: '循环班', |
| | | shiftSteps:[ |
| | | { |
| | | name: '三班三倒', |
| | | type: '循环班', |
| | | shiftSteps:[ |
| | | { |
| | | name: '第一班', |
| | | days: '5', |
| | | rest: '1', |
| | | timeRange: '三班三倒早班' |
| | | }, |
| | | { |
| | | name: '第二班', |
| | | days: '5', |
| | | rest: '2', |
| | | timeRange: '三班三倒中班' |
| | | }, |
| | | { |
| | | name: '第三班', |
| | | days: '5', |
| | | rest: '3', |
| | | timeRange: '三班三倒夜班' |
| | | } |
| | | ] |
| | | name: '第一班', |
| | | days: '5', |
| | | rest: '1', |
| | | timeRange: '三班三倒早班' |
| | | }, |
| | | { |
| | | name: '常白班', |
| | | type: '固定班' |
| | | name: '第二班', |
| | | days: '5', |
| | | rest: '2', |
| | | timeRange: '三班三倒中班' |
| | | }, |
| | | { |
| | | name: '第三班', |
| | | days: '5', |
| | | rest: '3', |
| | | timeRange: '三班三倒夜班' |
| | | } |
| | | ] |
| | | ) |
| | | const handleChange = (value) => { |
| | | addRecord.value.content = [] |
| | | console.log(JSON.parse(JSON.stringify(value))) |
| | | }, |
| | | { |
| | | name: '常白班', |
| | | type: '固定班' |
| | | } |
| | | const addRef = ref<FormInstance>() |
| | | const addShiftRef = ref<FormInstance>() |
| | | const addRules = reactive<FormRules>({ |
| | | name:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | type:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | timeRange:[{required: true, message: '该内容不能为空',trigger:'blur'}] |
| | | }) |
| | | const addShiftRules = reactive<FormRules>({ |
| | | name:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | days:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | rest:[{required: true,message: '该内容不能为空',trigger: 'blur'}], |
| | | timeRange:[{required: true, message: '该内容不能为空',trigger:'blur'}] |
| | | }) |
| | | const dialogDetails = ref(false) |
| | | const dialogAddRecord = ref(false) |
| | | const deleteDialog = ref(false) |
| | | const deleteShiftDialog = ref(false) |
| | | const dialogAddShift = ref(false) |
| | | const addRecord = ref({}) |
| | | const addShift = ref({}) |
| | | const details = ref({}) |
| | | const viewRecord = (row) =>{ |
| | | details.value = JSON.parse(JSON.stringify(row)) |
| | | dialogDetails.value = true |
| | | } |
| | | const deleteRecord = (index) =>{ |
| | | chosenIndex.value = index |
| | | deleteDialog.value = true |
| | | } |
| | | const conFirmDelete = ()=> { |
| | | tableData.splice(chosenIndex.value,1) |
| | | deleteDialog.value = false |
| | | } |
| | | const confirmAddRecord = async (formEl: FormInstance | undefined) =>{ |
| | | if (!formEl) return |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | if(chosenIndex.value == -1){ |
| | | if(addRecord.value.type == '循环班' && (!addRecord.value.shiftSteps || addRecord.value.shiftSteps.length == 0)){ |
| | | ElMessage({ |
| | | message: '请先设置自定义排班后再提交', |
| | | type: 'warning', |
| | | }) |
| | | return |
| | | }else{ |
| | | tableData.unshift(addRecord.value) |
| | | } |
| | | }else{ |
| | | if(addRecord.value.type == '循环班' && addRecord.value.shiftSteps.length == 0){ |
| | | ElMessage({ |
| | | message: '请先设置自定义排班后再提交', |
| | | type: 'warning', |
| | | }) |
| | | return |
| | | }else{ |
| | | if(addRecord.value.type == '固定班'){delete addRecord.value.shiftSteps} |
| | | console.log(addRecord.value,'addRecord') |
| | | tableData[chosenIndex.value] = addRecord.value |
| | | } |
| | | } |
| | | dialogAddRecord.value =false |
| | | } else { |
| | | console.log('error submit!', fields) |
| | | ] |
| | | ) |
| | | const handleChange = (value) => { |
| | | addRecord.value.content = [] |
| | | console.log(JSON.parse(JSON.stringify(value))) |
| | | } |
| | | const addRef = ref<FormInstance>() |
| | | const addShiftRef = ref<FormInstance>() |
| | | const addRules = reactive<FormRules>({ |
| | | name:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | type:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | timeRange:[{required: true, message: '该内容不能为空',trigger:'blur'}] |
| | | }) |
| | | const addShiftRules = reactive<FormRules>({ |
| | | name:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | days:[{required: true, message: '该内容不能为空',trigger:'blur'}], |
| | | rest:[{required: true,message: '该内容不能为空',trigger: 'blur'}], |
| | | timeRange:[{required: true, message: '该内容不能为空',trigger:'blur'}] |
| | | }) |
| | | const dialogDetails = ref(false) |
| | | const dialogAddRecord = ref(false) |
| | | const deleteDialog = ref(false) |
| | | const deleteShiftDialog = ref(false) |
| | | const dialogAddShift = ref(false) |
| | | const addRecord = ref({}) |
| | | const addShift = ref({}) |
| | | const details = ref({}) |
| | | const viewRecord = (row) =>{ |
| | | details.value = JSON.parse(JSON.stringify(row)) |
| | | dialogDetails.value = true |
| | | } |
| | | const deleteRecord = (index) =>{ |
| | | chosenIndex.value = index |
| | | deleteDialog.value = true |
| | | } |
| | | const conFirmDelete = ()=> { |
| | | tableData.splice(chosenIndex.value,1) |
| | | deleteDialog.value = false |
| | | } |
| | | const confirmAddRecord = async (formEl: FormInstance | undefined) =>{ |
| | | if (!formEl) return |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | if(chosenIndex.value == -1){ |
| | | if(addRecord.value.type == '循环班' && (!addRecord.value.shiftSteps || addRecord.value.shiftSteps.length == 0)){ |
| | | ElMessage({ |
| | | message: '请先设置自定义排班后再提交', |
| | | type: 'warning', |
| | | }) |
| | | return |
| | | }else{ |
| | | tableData.unshift(addRecord.value) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | const closeAdd =()=>{ |
| | | addRecord.value={} |
| | | chosenIndex.value = -1 |
| | | addShift.value={} |
| | | chosenShiftIndex.value = -1 |
| | | } |
| | | const indexClear = ()=>{ |
| | | chosenIndex.value = -1 |
| | | } |
| | | const indexShiftClear = ()=>{ |
| | | chosenShiftIndex.value = -1 |
| | | } |
| | | const editRecord =(index, row)=>{ |
| | | dialogAddRecord.value = true |
| | | chosenIndex.value = index |
| | | addRecord.value = JSON.parse(JSON.stringify(row)) |
| | | } |
| | | |
| | | // 添加删除排班步骤 |
| | | const addFlow = (index) => { |
| | | dialogAddShift.value = true |
| | | chosenShiftIndex.value = index |
| | | } |
| | | const deleteFlow = (index) => { |
| | | deleteShiftDialog.value = true |
| | | chosenShiftIndex.value = index |
| | | } |
| | | const conFirmShiftDelete = () => { |
| | | addRecord.value.shiftSteps.splice( chosenShiftIndex.value,1) |
| | | deleteShiftDialog.value = false |
| | | } |
| | | const confirmAddShift = async (formEl: FormInstance | undefined) => { |
| | | if (!formEl) return |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | if(addRecord.value.shiftSteps){ |
| | | addRecord.value.shiftSteps.splice(chosenShiftIndex.value+1,0,addShift.value) |
| | | }else{ |
| | | addRecord.value.shiftSteps = [] |
| | | addRecord.value.shiftSteps.unshift(addShift.value) |
| | | } |
| | | dialogAddShift.value = false |
| | | } else { |
| | | console.log('error submit!', fields) |
| | | }else{ |
| | | if(addRecord.value.type == '循环班' && addRecord.value.shiftSteps.length == 0){ |
| | | ElMessage({ |
| | | message: '请先设置自定义排班后再提交', |
| | | type: 'warning', |
| | | }) |
| | | return |
| | | }else{ |
| | | if(addRecord.value.type == '固定班'){delete addRecord.value.shiftSteps} |
| | | console.log(addRecord.value,'addRecord') |
| | | tableData[chosenIndex.value] = addRecord.value |
| | | } |
| | | }) |
| | | } |
| | | dialogAddRecord.value =false |
| | | } else { |
| | | console.log('error submit!', fields) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | const closeAdd =()=>{ |
| | | addRecord.value={} |
| | | chosenIndex.value = -1 |
| | | addShift.value={} |
| | | chosenShiftIndex.value = -1 |
| | | } |
| | | const indexClear = ()=>{ |
| | | chosenIndex.value = -1 |
| | | } |
| | | const indexShiftClear = ()=>{ |
| | | chosenShiftIndex.value = -1 |
| | | } |
| | | const editRecord =(index, row)=>{ |
| | | dialogAddRecord.value = true |
| | | chosenIndex.value = index |
| | | addRecord.value = JSON.parse(JSON.stringify(row)) |
| | | } |
| | | |
| | | // 添加删除排班步骤 |
| | | const addFlow = (index) => { |
| | | dialogAddShift.value = true |
| | | chosenShiftIndex.value = index |
| | | } |
| | | const deleteFlow = (index) => { |
| | | deleteShiftDialog.value = true |
| | | chosenShiftIndex.value = index |
| | | } |
| | | const conFirmShiftDelete = () => { |
| | | addRecord.value.shiftSteps.splice( chosenShiftIndex.value,1) |
| | | deleteShiftDialog.value = false |
| | | } |
| | | const confirmAddShift = async (formEl: FormInstance | undefined) => { |
| | | if (!formEl) return |
| | | await formEl.validate((valid, fields) => { |
| | | if (valid) { |
| | | if(addRecord.value.shiftSteps){ |
| | | addRecord.value.shiftSteps.splice(chosenShiftIndex.value+1,0,addShift.value) |
| | | }else{ |
| | | addRecord.value.shiftSteps = [] |
| | | addRecord.value.shiftSteps.unshift(addShift.value) |
| | | } |
| | | dialogAddShift.value = false |
| | | } else { |
| | | console.log('error submit!', fields) |
| | | } |
| | | const closeAddShift =()=>{ |
| | | addShift.value={} |
| | | chosenShiftIndex.value = -1 |
| | | } |
| | | // 折线图 |
| | | const renderMenu = async (value: string) => { |
| | | Session.set('projectId',value) |
| | | userInfos.value.projectId = value |
| | | await initBackEndControlRoutes(); |
| | | }; |
| | | // return { |
| | | // renderMenu, |
| | | // multipleTableRef, |
| | | // tableData, |
| | | // currentPage, |
| | | // pageSize, |
| | | // dialogDetails, |
| | | // details, |
| | | // deleteDialog, |
| | | // dialogAddRecord, |
| | | // viewRecord, |
| | | // deleteRecord, |
| | | // handleSizeChange, |
| | | // handleCurrentChange, |
| | | // Plus, |
| | | // Edit, |
| | | // Delete, |
| | | // Search, |
| | | // Download, |
| | | // handleSelectionChange, |
| | | // Refresh, |
| | | // ...toRefs(state), |
| | | // }; |
| | | // }, |
| | | // }); |
| | | }) |
| | | |
| | | } |
| | | const closeAddShift =()=>{ |
| | | addShift.value={} |
| | | chosenShiftIndex.value = -1 |
| | | } |
| | | // 折线图 |
| | | const renderMenu = async (value: string) => { |
| | | Session.set('projectId',value) |
| | | userInfos.value.projectId = value |
| | | await initBackEndControlRoutes(); |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | $homeNavLengh: 8; |
| | | .home-container { |
| | | height: 100%; |
| | | 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; |
| | |
| | | white-space: nowrap; |
| | | margin-right: 20px; |
| | | } |
| | | } |
| | | } |
| | | .mainPages{ |
| | | height: 100%; |
| | | display: flex; |
| | | flex-direction: column; |
| | | justify-content: space-between; |
| | | } |
| | | .main-card{ |
| | | width: 100%; |
| | | .cardTop{ |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | margin-bottom: 20px; |
| | | .mainCardBtn{ |
| | | margin: 0; |
| | | } |
| | | } |
| | | } |
| | | .pageBtn{ |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: right; |
| | | margin-top: 20px; |
| | | |
| | | .demo-pagination-block + .demo-pagination-block { |
| | | margin-top: 10px; |
| | | } |
| | | .demo-pagination-block .demonstration { |
| | | margin-bottom: 16px; |
| | | } |
| | | } |
| | | } |