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

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

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