提交 6ae9746a authored 作者: lidongxu's avatar lidongxu

feat(mobile/plan): 新增判断编辑和删除_无法操作已执行和之前计划

同上
上级 1c6e8287
/**
export const usePromotionHooks = () => { * 判断计划是否可编辑/删除
/** * @param {*} row 计划信息对象
* 判断某个身份在指定日期号码是否有上传权限 * @returns boolean true 可编辑/删除,false 不可编辑/删除
* @param {*} isCityManager 城市经理 true,职能角色 false */
* @param {*} dateNum 指定日期号码 1-31 export const checkPlanExpire = (row) => {
* @returns const date = new Date()
*/ const rowDate = new Date(row.clockInTime)
const isUpDisRef = ref(true) rowDate.setHours(rowDate.getHours() + 1)
const checkUpDis = (isCityManager, dateNum) => { return !(rowDate < date || row.planStatus === 1)
isUpDisRef.value = (new Date().getDate() >= dateNum && isCityManager.value) }
} \ No newline at end of file
return {
isUpDisRef,
checkUpDis
}
}
...@@ -62,7 +62,7 @@ defineOptions({ ...@@ -62,7 +62,7 @@ defineOptions({
}) })
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
import { checkPlanExpire } from '@/hooks'
import { getPromotionActiveStatus } from '@/dicts' import { getPromotionActiveStatus } from '@/dicts'
import { getChargeListAPI, getPlanListAPI, deletePlanAPI } from '@/api' import { getChargeListAPI, getPlanListAPI, deletePlanAPI } from '@/api'
import PlanSearch from './plan-search.vue' import PlanSearch from './plan-search.vue'
...@@ -150,11 +150,17 @@ const onRefresh = () => { ...@@ -150,11 +150,17 @@ const onRefresh = () => {
// 编辑计划 // 编辑计划
const editPlan = (row) => { const editPlan = (row) => {
if (!checkPlanExpire(row)) {
return proxy.$modal.msgWarning('无法编辑,已执行或之前计划')
}
router.push(`/m/promotion_plan_editing/${row.id}`) router.push(`/m/promotion_plan_editing/${row.id}`)
} }
// 删除计划 // 删除计划
const deletePlan = (row) => { const deletePlan = (row) => {
if (!checkPlanExpire(row)) {
return proxy.$modal.msgWarning('无法删除,已执行或之前计划')
}
proxy.$modal.confirm(`确认删除计划吗?`).then(async () => { proxy.$modal.confirm(`确认删除计划吗?`).then(async () => {
await deletePlanAPI({ await deletePlanAPI({
planIds: [row.id], planIds: [row.id],
...@@ -184,13 +190,7 @@ const deletePlan = (row) => { ...@@ -184,13 +190,7 @@ const deletePlan = (row) => {
.van-cell { .van-cell {
margin-top: 10px; margin-top: 10px;
::v-deep(.van-swipe-cell__right) {
display: flex;
button {
height: 100%;
}
}
::v-deep(.van-cell__label) { ::v-deep(.van-cell__label) {
font-size: 14px !important; font-size: 14px !important;
...@@ -208,6 +208,14 @@ const deletePlan = (row) => { ...@@ -208,6 +208,14 @@ const deletePlan = (row) => {
margin: 0; margin: 0;
} }
} }
::v-deep(.van-swipe-cell__right) {
display: flex;
button {
height: 100%;
}
}
} }
} }
} }
......
...@@ -450,7 +450,7 @@ ...@@ -450,7 +450,7 @@
<script setup> <script setup>
import { getPlanListAPI, uploadFileToOSSAPI, addPlanAPI, savePlanAPI, deletePlanAPI, addPlanByRoleAPI, getProCityAPI, getDealerListAPI, getWarZoneListAPI, getChargeListAPI, addPlanByWebAPI, updatePlanByWebAPI, getPlanStoreListAPI, updatePlanAPI, batchUpdatePlanAPI } from '@/api' import { getPlanListAPI, uploadFileToOSSAPI, addPlanAPI, savePlanAPI, deletePlanAPI, addPlanByRoleAPI, getProCityAPI, getDealerListAPI, getWarZoneListAPI, getChargeListAPI, addPlanByWebAPI, updatePlanByWebAPI, getPlanStoreListAPI, updatePlanAPI, batchUpdatePlanAPI } from '@/api'
import { useDatePickerOptions } from '@/hooks' import { useDatePickerOptions, checkPlanExpire } from '@/hooks'
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import store from '@/store' import store from '@/store'
import userStore from '@/store/modules/user' import userStore from '@/store/modules/user'
...@@ -458,7 +458,6 @@ import { getPromotionRole, getPromotionActiveStatus } from '@/dicts' ...@@ -458,7 +458,6 @@ import { getPromotionRole, getPromotionActiveStatus } from '@/dicts'
import { CITY_MANAGER, PROMOTION_STATUS } from '@/dicts' import { CITY_MANAGER, PROMOTION_STATUS } from '@/dicts'
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
import { ElMessage, ElMessageBox } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus';
import { usePromotionHooks } from '@/hooks'
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const isCityManager = ref(userStore().promotionIdentity) const isCityManager = ref(userStore().promotionIdentity)
...@@ -762,18 +761,7 @@ const formatter = (row, col, value) => { ...@@ -762,18 +761,7 @@ const formatter = (row, col, value) => {
return value return value
} }
} }
// 判断计划是否过期(上班开始后 1 小时无法编辑和删除)
const checkPlanExpire = (row) => {
const date = new Date()
const rowDate = new Date(row.clockInTime)
rowDate.setHours(rowDate.getHours() + 1)
if (rowDate < date || row.planStatus === 1) {
// 过期/已经开始不可以操作
return false
} else {
return true
}
}
// 计划是否可选和编辑和删除按钮禁用 // 计划是否可选和编辑和删除按钮禁用
const selectableFn = (row) => { const selectableFn = (row) => {
return checkPlanExpire(row) return checkPlanExpire(row)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论