提交 4b922a3a authored 作者: lidongxu's avatar lidongxu

fix(promotion/plan): 新增编辑时,检验所有表单

修复下班时间小时选下一个小时以后,分钟选不了 0 等
上级 b273c54f
...@@ -13,7 +13,7 @@ let downloadLoadingInstance; ...@@ -13,7 +13,7 @@ let downloadLoadingInstance;
export let isRelogin = { show: false }; export let isRelogin = { show: false };
// 促销系统后台 baseURL // 促销系统后台 baseURL
export const promotionBaseURL = import.meta.env.VITE_APP_PROMOTION_BASE_API export const promotionBaseURL = import.meta.env.VITE_APP_PROMOTION
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例 // 创建axios实例
...@@ -31,7 +31,7 @@ service.interceptors.request.use(config => { ...@@ -31,7 +31,7 @@ service.interceptors.request.use(config => {
// 是否需要防止数据重复提交 // 是否需要防止数据重复提交
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
if (getToken() && !isToken) { if (getToken() && !isToken) {
if (config.url.indexOf(promotionBaseURL) >= 0) { if (config.baseURL === promotionBaseURL) {
// 促销后台不能带 Bearer 前缀 // 促销后台不能带 Bearer 前缀
config.headers['Authorization'] = getToken() config.headers['Authorization'] = getToken()
} else { } else {
......
...@@ -234,13 +234,14 @@ ...@@ -234,13 +234,14 @@
<el-dialog :title="(addOrEditPlanForm.id ? '修改' : '新增') + '计划'" <el-dialog :title="(addOrEditPlanForm.id ? '修改' : '新增') + '计划'"
v-model="addOrEditPlanVisible" v-model="addOrEditPlanVisible"
width="60%"> width="60%">
<!-- 日期表单 --> <!-- 表单 -->
<el-form :model="addOrEditPlanForm" <el-form :model="addOrEditPlanForm"
label-width="150px" label-width="150px"
:rules="addOrEditPlanFormRules" :rules="addOrEditPlanFormRules"
ref="addOrEditPlanRef"
inline> inline>
<el-row> <el-row>
<el-col :span="10"> <el-col :span="12">
<!-- 门店列表 --> <!-- 门店列表 -->
<el-form-item label="门店列表" <el-form-item label="门店列表"
prop="storeCode"> prop="storeCode">
...@@ -265,11 +266,11 @@ ...@@ -265,11 +266,11 @@
<a class="link" <a class="link"
v-show="isInfoError" v-show="isInfoError"
target="_blank" target="_blank"
href="https://cloud.region2.qince.com/sysapp/react/web/main.html#/home" >跳转勤策系统</a> href="https://cloud.region2.qince.com/sysapp/react/web/main.html#/home">跳转勤策系统</a>
</div> </div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="12">
<!-- 活动日期 --> <!-- 活动日期 -->
<el-form-item label="活动日期" <el-form-item label="活动日期"
prop="date"> prop="date">
...@@ -282,14 +283,15 @@ ...@@ -282,14 +283,15 @@
</el-row> </el-row>
<el-row> <el-row>
<!-- 活动模式 --> <!-- 活动模式 -->
<el-col :span="10"> <el-col :span="12">
<el-form-item label="活动模式" <el-form-item label="活动模式"
prop="pattern"> prop="pattern">
<el-select v-model="addOrEditPlanForm.pattern" <el-select v-model="addOrEditPlanForm.pattern"
placeholder="请选择活动模式" placeholder="请选择活动模式"
filterable filterable
clearable clearable
style="width: 95%"> style="width: 95%"
@change="selPattern">
<el-option v-for="item in activityModeList" <el-option v-for="item in activityModeList"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
...@@ -297,7 +299,7 @@ ...@@ -297,7 +299,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="12">
<!-- 归属人 --> <!-- 归属人 -->
<el-form-item label="归属人" <el-form-item label="归属人"
prop="employeeNo"> prop="employeeNo">
...@@ -306,7 +308,8 @@ ...@@ -306,7 +308,8 @@
filterable filterable
clearable clearable
style="width: 95%" style="width: 95%"
:disabled="cityManagerPrivilege"> :disabled="cityManagerPrivilege"
@change="selEmployee">
<el-option v-for="item in managerList" <el-option v-for="item in managerList"
:key="item.employeeNo" :key="item.employeeNo"
:label="item.label" :label="item.label"
...@@ -316,7 +319,7 @@ ...@@ -316,7 +319,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="10"> <el-col :span="12">
<!-- 上班打卡时间 --> <!-- 上班打卡时间 -->
<el-form-item label="上班打卡时间" <el-form-item label="上班打卡时间"
prop="clockInTime"> prop="clockInTime">
...@@ -326,7 +329,7 @@ ...@@ -326,7 +329,7 @@
style="width: 95%" /> style="width: 95%" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="12">
<!-- 下班打卡时间 --> <!-- 下班打卡时间 -->
<el-form-item label="下班打卡时间" <el-form-item label="下班打卡时间"
prop="clockOutTime"> prop="clockOutTime">
...@@ -342,7 +345,7 @@ ...@@ -342,7 +345,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="10"> <el-col :span="12">
<!-- 工资 --> <!-- 工资 -->
<el-form-item label="工资" <el-form-item label="工资"
prop="salary"> prop="salary">
...@@ -351,7 +354,7 @@ ...@@ -351,7 +354,7 @@
placeholder="请输入工资" /> placeholder="请输入工资" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="12">
<!-- 杂费 --> <!-- 杂费 -->
<el-form-item label="杂费" <el-form-item label="杂费"
prop="incidentals"> prop="incidentals">
...@@ -422,6 +425,8 @@ const getProCity = async () => { ...@@ -422,6 +425,8 @@ const getProCity = async () => {
value: item.num value: item.num
})) }))
} else { } else {
queryParams.cityId = undefined
cityList.value = []
provinceList.value = data.map(item => ({ provinceList.value = data.map(item => ({
label: item.name, label: item.name,
value: item.num value: item.num
...@@ -430,6 +435,7 @@ const getProCity = async () => { ...@@ -430,6 +435,7 @@ const getProCity = async () => {
getPlanList() getPlanList()
} }
getProCity() getProCity()
// 查询经销商列表 // 查询经销商列表
const zoneList = ref([]) const zoneList = ref([])
const getDealerList = async () => { const getDealerList = async () => {
...@@ -692,7 +698,7 @@ const planTableList = ref([]) ...@@ -692,7 +698,7 @@ const planTableList = ref([])
const dialogVisible = ref(false) const dialogVisible = ref(false)
const confirmExcelUUID = ref('') const confirmExcelUUID = ref('')
const confirmTableColumns = [ const confirmTableColumns = [
{ {
label: '活动 ID', label: '活动 ID',
prop: 'id', prop: 'id',
width: 90, width: 90,
...@@ -824,7 +830,8 @@ const formatterConfirm = (row, col, value) => { ...@@ -824,7 +830,8 @@ const formatterConfirm = (row, col, value) => {
return value return value
} }
} }
// 确认计划-保存表格到计划库 const addOrEditPlanRef = ref(null)
// 表格上传计划确认保存
const confirmPlanBtn = async () => { const confirmPlanBtn = async () => {
await savePlanAPI(confirmExcelUUID.value) await savePlanAPI(confirmExcelUUID.value)
ElMessage.success('保存成功') ElMessage.success('保存成功')
...@@ -835,8 +842,13 @@ const confirmPlanBtn = async () => { ...@@ -835,8 +842,13 @@ const confirmPlanBtn = async () => {
// 新增/编辑计划 // 新增/编辑计划
const addOrEditPlanVisible = ref(false) const addOrEditPlanVisible = ref(false)
const addOrEditPlanForm = ref({ const addOrEditPlanForm = ref({
}) })
// 重置表单
const resetAddOrEditPlanForm = () => {
addOrEditPlanForm.value = {}
selecteStoreInfo.value = ''
isInfoError.value = false
}
// 新增/编辑计划-表单验证(所有都是必填项 // 新增/编辑计划-表单验证(所有都是必填项
const addOrEditPlanFormRules = reactive({ const addOrEditPlanFormRules = reactive({
storeCode: [ storeCode: [
...@@ -915,6 +927,7 @@ const disabledDateFn = (time) => { ...@@ -915,6 +927,7 @@ const disabledDateFn = (time) => {
} }
} }
const handleAdd = () => { const handleAdd = () => {
resetAddOrEditPlanForm()
addOrEditPlanVisible.value = true addOrEditPlanVisible.value = true
} }
const activityModeList = ref([ const activityModeList = ref([
...@@ -945,8 +958,14 @@ const disabledHours = (h) => { ...@@ -945,8 +958,14 @@ const disabledHours = (h) => {
return makeRange(0, date.getHours() - 1); return makeRange(0, date.getHours() - 1);
} }
const disabledMinutes = (h, m) => { const disabledMinutes = (h, m) => {
const date = new Date(addOrEditPlanForm.value.clockInTime) // 如果小时大于上班打卡时间小时,则不限制分钟
return makeRange(0, date.getMinutes() - 1); const inDate = new Date(addOrEditPlanForm.value.clockInTime)
if (h > inDate.getHours()) {
return makeRange(0, -1);
} else {
const date = new Date(addOrEditPlanForm.value.clockInTime)
return makeRange(0, date.getMinutes() - 1);
}
} }
const disabledSeconds = (h, m, s) => { const disabledSeconds = (h, m, s) => {
const date = new Date(addOrEditPlanForm.value.clockInTime) const date = new Date(addOrEditPlanForm.value.clockInTime)
...@@ -956,12 +975,13 @@ const disabledSeconds = (h, m, s) => { ...@@ -956,12 +975,13 @@ const disabledSeconds = (h, m, s) => {
// 编辑计划 // 编辑计划
const editFn = (row) => { const editFn = (row) => {
addOrEditPlanForm.value = { ...row } addOrEditPlanForm.value = { ...row }
console.log('编辑', addOrEditPlanForm.value)
addOrEditPlanVisible.value = true addOrEditPlanVisible.value = true
} }
// 保存新增/编辑计划 // 保存新增/编辑计划
const handleAddOrEditPlan = async () => { const handleAddOrEditPlan = async () => {
// 表单校验
await addOrEditPlanRef.value.validate()
addOrEditPlanForm.value.operNo = store.state.value.user.userInfo.userName addOrEditPlanForm.value.operNo = store.state.value.user.userInfo.userName
addOrEditPlanForm.value.operName = store.state.value.user.userInfo.nickName addOrEditPlanForm.value.operName = store.state.value.user.userInfo.nickName
addOrEditPlanForm.value.operId = store.state.value.user.userInfo.userId addOrEditPlanForm.value.operId = store.state.value.user.userInfo.userId
...@@ -1034,12 +1054,22 @@ const selStoreInfo = (storeCode) => { ...@@ -1034,12 +1054,22 @@ const selStoreInfo = (storeCode) => {
// 门店系统名称、经销商不可为空,请到勤策中修改; // 门店系统名称、经销商不可为空,请到勤策中修改;
selecteStoreInfo.value = '' selecteStoreInfo.value = ''
} }
// 清除表单验证提示
addOrEditPlanRef.value.clearValidate('storeCode');
} }
// 门店搜索 // 门店搜索
const remoteStoreMethod = (query) => { const remoteStoreMethod = (query) => {
addOrEditPlanForm.value.storeName = query addOrEditPlanForm.value.storeName = query
getStoreList() getStoreList()
} }
// 新增计划表单-选完以后去掉错误提示
const selPattern = () => {
addOrEditPlanRef.value.clearValidate('pattern');
}
const selEmployee = () => {
addOrEditPlanRef.value.clearValidate('employeeNo');
}
</script> </script>
<style scoped <style scoped
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论