提交 3e263fa4 authored 作者: lidongxu's avatar lidongxu

refactor(all): 尝试把新改代码合过来

上级 89f48a93
......@@ -89,7 +89,10 @@ export function getPlanStoreListAPI(queryParams = {}) {
baseURL: VITE_APP_PROMOTION,
url: '/user/clientele/query/store/list',
method: 'POST',
data: queryParams
data: {
storeNameVague: queryParams.storeName,
storeCode: queryParams.storeCode,
}
})
}
......
import { parseTime } from '@/utils'
/**
* 判断计划是否可变更/删除
* 判断计划是否可编辑/删除
* @param {*} row 计划信息对象
* @returns boolean true 可变更/删除,false 不可变更/删除
* @returns boolean true 可编辑/删除,false 不可编辑/删除
*/
export const checkPlanExpire = (row) => {
// 1. 计划已经开始,不可变更/删除
// 2. 计划未开始,但是上班时间已经 1 小时后,不可变更/删除
// 1. 计划已经开始,不可编辑/删除
if (row.planStatus === 0) {
return false
}
// 2. 计划未开始,但是上班时间已经 1 小时后,不可编辑/删除
const date = new Date()
const rowDate = new Date(row.clockInTime)
rowDate.setHours(rowDate.getHours() + 1)
return !(rowDate < date || row.planStatus === 1)
if (row.planStatus === 1 && rowDate < date) {
return false
}
// 3. 计划为 2 和 3(审核中/审核拒绝),不可编辑/删除
if (row.planStatus === 2 || row.planStatus === 3) {
return false
}
}
/**
......
......@@ -241,7 +241,7 @@ const selStoreName = async () => {
// 获取门店列表
const getStoreList = async (storeName) => {
const res = await getPlanStoreListAPI({
storeNameVague: storeName
storeName
})
columns.value = res.data.map(item => ({
text: item.storeName,
......
......@@ -82,7 +82,7 @@
link
:disabled="!selectableFn(scope.row)"
@click="editFn(scope.row)">
变更
编辑
</el-button>
<el-button type="danger"
link
......@@ -152,7 +152,8 @@
clearable
@change="selStoreInfo"
remote
:remote-method="remoteStoreMethod">
:remote-method="remoteStoreMethod"
:disabled="!!addOrEditPlanForm.id">
<el-option v-for="item in storeList"
:key="item.value"
:label="item.label"
......@@ -177,7 +178,8 @@
:clearable="false"
start-placeholder="活动日期"
value-format="YYYY-MM-DDTHH:mm:ss"
:disabled-date="disabledDateFn" />
:disabled-date="disabledDateFn"
:disabled="!!addOrEditPlanForm.id" />
</el-form-item>
</el-col>
</el-row>
......@@ -387,8 +389,7 @@ const handleAdd = () => {
addOrEditPlanVisible.value = true
}
/*************** 变更计划 ***************/
const editStoreListByDealerId = ref(null)
/*************** 修改计划 ***************/
// 批量
const uploadChangeFile = async (file) => {
proxy.$modal.loading("正在上传数据,请稍后...");
......@@ -409,18 +410,15 @@ const uploadChangeFile = async (file) => {
// 单条
const editFn = (row) => {
addOrEditPlanForm.value = {
...row,
...row,
inTime: parseTime(row.clockInTime, "{h}:{i}:{s}"),
outTime: parseTime(row.clockOutTime, "{h}:{i}:{s}")
}
// 重新搜索符合经销商 ID 的门店列表
editStoreListByDealerId.value = row.dealerId
getStoreList()
addOrEditPlanVisible.value = true
}
/*************** 新增/改计划弹框 ***************/
// 新增/更改计划表单弹框
/*************** 新增/改计划弹框 ***************/
// 新增/编辑计划表单弹框
const addOrEditPlanVisible = ref(false)
const addOrEditPlanForm = ref({})
const activityModeList = ref(PROMOTION_ACTIVITY_MODE_LIST) // 活动模式
......@@ -428,7 +426,6 @@ const activityModeList = ref(PROMOTION_ACTIVITY_MODE_LIST) // 活动模式
const resetAddOrEditPlanForm = () => {
addOrEditPlanForm.value = {}
selecteStoreInfo.value = ''
editStoreListByDealerId.value = null
isInfoError.value = false
}
// 表单验证(所有都是必填项)
......@@ -496,10 +493,8 @@ const allStoreList = ref([])
const selecteStoreInfo = ref('')
const isInfoError = ref(false)
const getStoreList = async () => {
console.log(editStoreListByDealerId, 'editStoreListByDealerId')
const { data } = await getPlanStoreListAPI({
storeNameVague: addOrEditPlanForm.value.storeName,
dealerId: editStoreListByDealerId.value,
storeName: addOrEditPlanForm.value.storeName
})
allStoreList.value = data
storeList.value = data.map(item => {
......@@ -592,7 +587,7 @@ const selEmployee = () => {
}
// 保存新增/更改计划
// 保存新增/编辑计划
const handleAddOrEditPlan = async () => {
// 表单校验
await proxy.$refs.addOrEditPlanRef.validate()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论