Browse Source

日历

intex_online20250117
张立 3 weeks ago
parent
commit
b4de9c590f
  1. 3
      src/locales/en-US.ts
  2. 3
      src/locales/zh-CN.ts
  3. 251
      src/views/wms/basicDataManage/supplierManage/receivedCalendar/index.vue

3
src/locales/en-US.ts

@ -1322,6 +1322,7 @@ export default {
:'Detail', :'Detail',
退:'Return', 退:'Return',
: 'Invalid successfully', : 'Invalid successfully',
'索赔金额不能为0,请修改后提交。': 'The claim amount cannot be 0, please modify and submit.' '索赔金额不能为0,请修改后提交。': 'The claim amount cannot be 0, please modify and submit.',
: 'Create Shift'
}, },
} }

3
src/locales/zh-CN.ts

@ -1321,7 +1321,8 @@ export default {
: '创建开票申请', : '创建开票申请',
:'作废成功', :'作废成功',
退: '退回', 退: '退回',
'索赔金额不能为0,请修改后提交。':'索赔金额不能为0,请修改后提交。' '索赔金额不能为0,请修改后提交。': '索赔金额不能为0,请修改后提交。',
:'新增班次'
}, },
} }

251
src/views/wms/basicDataManage/supplierManage/receivedCalendar/index.vue

@ -1,29 +1,23 @@
<template> <template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="ReceivedCalendar.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ReceivedCalendar.allSchemas"
/>
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-calendar ref='calendar'> <el-calendar ref='calendar'>
<template #header="{ date }"> <template #header="{ date }">
<el-select v-model="value" placeholder="受入号" style="width: 240px">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<ButtonBaseMore :Butttondata="HeadButttondata" @button-base-click="buttonTableClick($event,row)" />
<div style="display: flex;justify-content: center;align-items: center;width: 100%;"> <div style="display: flex;justify-content: center;align-items: center;width: 100%;">
<el-button size="small" text @click="selectDate('prev-month')"> <el-button size="small" text @click="selectDate('prev-month',date)">
<Icon icon="ep:arrow-left" size="18px"/> <Icon icon="ep:arrow-left" size="18px"/>
</el-button> </el-button>
<span style="padding: 0px 20px;">{{ date }}</span> <span style="padding: 0px 20px;">{{ date }}</span>
<el-button size="small" text @click="selectDate('next-month')"> <el-button size="small" text @click="selectDate('next-month',date)">
<Icon icon="ep:arrow-right" size="18px"/> <Icon icon="ep:arrow-right" size="18px"/>
</el-button> </el-button>
</div> </div>
@ -38,7 +32,6 @@
<div class="text">白班</div> <div class="text">白班</div>
<Icon class="mr-5px" icon="ep:delete" color="#409eff" size="14px" @click="deleteShift(data.day,1)" /> <Icon class="mr-5px" icon="ep:delete" color="#409eff" size="14px" @click="deleteShift(data.day,1)" />
</div> </div>
<!-- 做监听 -->
<div class="sun" v-if="isSpecialDate(data.day) && !isSpecialDate(data.day).isHideMoon"> <div class="sun" v-if="isSpecialDate(data.day) && !isSpecialDate(data.day).isHideMoon">
<el-image style="width: 1.1vw; height: 1.1vw" src="/src/assets/svgs/moon.svg" /> <el-image style="width: 1.1vw; height: 1.1vw" src="/src/assets/svgs/moon.svg" />
<div class="text">夜班</div> <div class="text">夜班</div>
@ -62,22 +55,13 @@
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" :isBusiness="false"
/> />
</template>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="ReceivedCalendar.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/basic/received-calendar/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import { ReceivedCalendar,ReceivedCalendarRules } from './receivedCalendar.data' import { ReceivedCalendar,ReceivedCalendarRules } from './receivedCalendar.data'
import * as ReceivedCalendarApi from '@/api/wms/receivedCalendar' import * as ReceivedCalendarApi from '@/api/wms/receivedCalendar'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
import { ElCalendar } from 'element-plus' import { ElCalendar } from 'element-plus'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import type { CalendarDateType, CalendarInstance } from 'element-plus' import type { CalendarDateType, CalendarInstance } from 'element-plus'
@ -92,6 +76,7 @@ const routeName = ref()
routeName.value = route.name routeName.value = route.name
const tableColumns = ref(ReceivedCalendar.allSchemas.tableColumns) const tableColumns = ref(ReceivedCalendar.allSchemas.tableColumns)
//
const dayData = ref([{ const dayData = ref([{
day:'2025-01-01', day:'2025-01-01',
isHideSun:false, isHideSun:false,
@ -108,75 +93,23 @@ const dayData = ref([{
isHideSun:true, isHideSun:true,
}]) }])
const getDatesInCurrentMonth=() =>{
const today = new Date();
const year1 = today.getFullYear();
const month1 = today.getMonth(); // 0011112
const date1 = 1; // 1
const firstDayOfMonth = new Date(year1, month1, date1);
const lastDayOfMonth = new Date(year1, month1 + 1, 0); // 0
const daysInMonth = lastDayOfMonth.getDate();
const dates = [];
for (let i = 1; i <= daysInMonth; i++) {
const year =new Date(year1, month1, i).getFullYear();
const month = new Date(year1, month1, i).getMonth() + 1 >= 10 ? new Date(year1, month1, i).getMonth() + 1 : '0' + (new Date(year1, month1, i).getMonth() + 1);
const date = new Date(year1, month1, i).getDate()>= 10 ? new Date(year1, month1, i).getDate() : '0' + (new Date(year1, month1, i).getDate());
const day = `${year}-${month}-${date}`
const isHaveDay = dayData.value.find(item => (item.day == day))
dates.push({
day:`${year}-${month}-${date}`,
isHideSun:isHaveDay&&isHaveDay.isHideSun ? isHaveDay.isHideSun : false,
isHideMoon:isHaveDay&&isHaveDay.isHideMoon ? isHaveDay.isHideMoon : false,
});
}
return dates;
}
// 使 const isSpecialDate = (date) => {
const datesInCurrentMonth = ref(getDatesInCurrentMonth());
const isSpecialDate=(date)=> {
return datesInCurrentMonth.value.find(item=>item.day == date); return datesInCurrentMonth.value.find(item=>item.day == date);
} }
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: ReceivedCalendarApi.getReceivedCalendarPage //
})
//
const { getList, setSearchParams } = tableMethods
// //
const HeadButttondata = [ const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'basic:received-calendar:create'}), // defaultButtons.defaultAddBtn({
defaultButtons.defaultImportBtn({hasPermi:'basic:received-calendar:import'}), // label: t(`ts.新增班次`).replace('ts.', ''),
defaultButtons.defaultExportBtn({hasPermi:'basic:received-calendar:export'}), // name: 'add',
defaultButtons.defaultFreshBtn(null), // hide: false,
defaultButtons.defaultFilterBtn(null), // type: 'primary',
defaultButtons.defaultSetBtn(null), // icon: '',
// { color: '',
// label: '', hasPermi: ''
// name: 'zdy', }), //
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
] ]
// //
@ -194,22 +127,6 @@ const buttonBaseClick = (val, item) => {
console.log('其他按钮', item) console.log('其他按钮', item)
} }
} }
// -
const butttondata = [
defaultButtons.mainListEditBtn({hasPermi:'wms:receivedCalendar:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'wms:receivedCalendar:delete'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const basicFormRef = ref()
const openForm = (type: string, row?: any) => { const openForm = (type: string, row?: any) => {
@ -265,64 +182,6 @@ const formsSuccess = async (formType, data) => {
getList() getList()
} }
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicReceivedCalendar')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ReceivedCalendarApi.deleteReceivedCalendar(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const exportLoading = ref(false) //
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ReceivedCalendarApi.exportReceivedCalendar(tableObject.params)
download.excel(data, '受入日历.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '受入日历导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
// //
const deleteShift=(day,type) =>{ const deleteShift=(day,type) =>{
console.log(dayData.value) console.log(dayData.value)
@ -341,17 +200,73 @@ const deleteShift=(day,type) =>{
} }
})) }))
} }
console.log(item)
} }
//
const datesInCurrentMonth =ref([])//
const getDatesInCurrentMonth = (yearParams, monthParams) => {
const lastDayOfMonth = new Date(yearParams, monthParams+1, 0); // 0
const daysInMonth = lastDayOfMonth.getDate();
const dates = [];
for (let i = 1; i <= daysInMonth; i++) {
const year =new Date(yearParams, monthParams, i).getFullYear();
const month = new Date(yearParams, monthParams, i).getMonth() + 1 >= 10 ? new Date(yearParams, monthParams, i).getMonth() + 1 : '0' + (new Date(yearParams, monthParams, i).getMonth() + 1);
const date = new Date(yearParams, monthParams, i).getDate()>= 10 ? new Date(yearParams, monthParams, i).getDate() : '0' + (new Date(yearParams, monthParams, i).getDate());
const day = `${year}-${month}-${date}`
const isHaveDay = dayData.value.find(item => (item.day == day))
dates.push({
day:`${year}-${month}-${date}`,
isHideSun:isHaveDay&&isHaveDay.isHideSun ? isHaveDay.isHideSun : false,
isHideMoon:isHaveDay&&isHaveDay.isHideMoon ? isHaveDay.isHideMoon : false,
});
}
datesInCurrentMonth.value = dates;
}
//
const getData=async () =>{
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth(); // 0011112
await getDatesInCurrentMonth(year,month)
}
// 使
getData()
const calendar = ref<CalendarInstance>() const calendar = ref<CalendarInstance>()
const selectDate = (val: CalendarDateType) => { const selectDate =async (val: CalendarDateType,date) => {
if (!calendar.value) return if (!calendar.value) return
//
let regex = /(\d{4}) 年 (\d{1,2}) 月/;
let match = date.match(regex);
let year = match[1]; //
let month = match[2]; //
calendar.value.selectDate(val) calendar.value.selectDate(val)
//
const yearOrMonth = await getPreviousMonth(val, year, month)
await getDatesInCurrentMonth(yearOrMonth.year,yearOrMonth.month-1)
}
//
const getPreviousMonth = async(type,year,month)=> {
if (type == 'prev-month') {
// 11112
if (month == 1) {
month = 12;
year--;
} else {
month--; // 1
}
}else if( 'next-month') {
// 11112
if (month == 12) {
month = 1;
year++;
} else {
month++; // 1
}
}
return { year, month };
} }
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
getList()
importTemplateData.templateUrl = await ReceivedCalendarApi.importTemplate()
}) })
</script> </script>

Loading…
Cancel
Save