提交 e96c275b authored 作者: lidongxu's avatar lidongxu

refactor(plan-search): 拆分搜索计划组件为单独的 vue 文件

同上
上级 c3f7190e
...@@ -7,21 +7,7 @@ export function getPlanListAPI(queryParams) { ...@@ -7,21 +7,7 @@ export function getPlanListAPI(queryParams) {
baseURL: VITE_APP_PROMOTION, baseURL: VITE_APP_PROMOTION,
url: '/plan/v2/query/page', url: '/plan/v2/query/page',
method: 'POST', method: 'POST',
data: { data: queryParams
pageNum: queryParams.pageNum,
pageSize: queryParams.pageSize,
queryParams: {
activityStartDate: queryParams.activityDate && queryParams.activityDate[0],
activityEndDate: queryParams.activityDate && queryParams.activityDate[1],
planStatus: queryParams.planStatus,
province: queryParams.province,
city: queryParams.city,
dealerId: queryParams.zoneId,
orgQcId: queryParams.warzoneId,
employeeId: queryParams.employeeId,
storeNameLike: queryParams.storeName
}
}
}) })
} }
......
<template> <template>
<div> <van-popup
<van-popup v-model:show="innerShowPicker" destroy-on-close
destroy-on-close round
round teleport="body"
position="bottom" position="bottom"
@close="onPopupClose"> @close="onPopupClose">
<van-picker <van-picker :columns="columns"
:columns="columns" :cancel-button-text="searchShow ? '' : '取消'"
:cancel-button-text="searchShow ? '' : '取消'" @confirm="onConfirm">
@confirm="onConfirm"> <template #title>
<template #title> <!-- 搜索框 -->
<!-- 搜索框 --> <van-search v-if="searchShow"
<van-search v-if="searchShow" v-model="searchText"
v-model="searchText" :placeholder="placeholder"
:placeholder="placeholder" shape="round"
shape="round" @update:model-value="onSearch" />
@update:model-value="onSearch" /> </template>
</template> <template #empty>
<template #empty> <van-empty image="https://fastly.jsdelivr.net/npm/@vant/assets/custom-empty-image.png"
<van-empty image="https://fastly.jsdelivr.net/npm/@vant/assets/custom-empty-image.png" image-size="40"
image-size="40" description="暂无数据" />
description="暂无数据" /> </template>
</template> </van-picker>
</van-picker> </van-popup>
</van-popup>
</div>
</template> </template>
<script setup> <script setup>
const props = defineProps({ const props = defineProps({
// 控制弹窗显示隐藏
modelValue: {
type: Boolean,
default: false
},
// 选择器列数据 // 选择器列数据
columns: { columns: {
type: Array, type: Array,
...@@ -52,22 +45,15 @@ const props = defineProps({ ...@@ -52,22 +45,15 @@ const props = defineProps({
}); });
// 定义向外触发的事件 // 定义向外触发的事件
const emit = defineEmits(['update:modelValue', 'confirm', 'search']); const emit = defineEmits(['confirm', 'search']);
// 内部显示状态
const innerShowPicker = ref(props.modelValue);
// 搜索文本 // 搜索文本
const searchText = ref(''); const searchText = ref('');
// 监听 props 变化更新内部状态
watch(() => props.modelValue, (newValue) => {
innerShowPicker.value = newValue;
});
// 弹窗关闭时触发 // 弹窗关闭时触发
const onPopupClose = () => { const onPopupClose = () => {
searchText.value = ''; searchText.value = '';
emit('update:modelValue', false); emit('search', '');
}; };
/** /**
...@@ -77,8 +63,6 @@ const onPopupClose = () => { ...@@ -77,8 +63,6 @@ const onPopupClose = () => {
*/ */
const onConfirm = (values) => { const onConfirm = (values) => {
emit('confirm', values); emit('confirm', values);
emit('update:modelValue', false);
}; };
/** /**
......
...@@ -11,17 +11,15 @@ export const getPromotionRole = (role) => { ...@@ -11,17 +11,15 @@ export const getPromotionRole = (role) => {
} }
// 促销活动状态 // 促销活动状态
export const NOT_EXECUTION = 'NOT_EXECUTION' // 未执行 // 后台:返回数字,又让我传给他英文字符,页面展示中文
export const EXECUTION = 'EXECUTION' // 执行
// 后台:返回数字,又让我传给他英文字符
export const PROMOTION_STATUS = { export const PROMOTION_STATUS = {
0: { 0: {
label: '未执行', label: '未执行',
value: NOT_EXECUTION value: 'NOT_EXECUTION'
}, },
1: { 1: {
label: '执行', label: '执行',
value: EXECUTION value: 'EXECUTION'
} }
} }
export const getPromotionActiveStatus = (statusNum) => { export const getPromotionActiveStatus = (statusNum) => {
......
...@@ -231,7 +231,7 @@ const decreaseCount = async () => { ...@@ -231,7 +231,7 @@ const decreaseCount = async () => {
temNum: form.value.temNum - 1, temNum: form.value.temNum - 1,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
form.value.temNum--; form.value.temNum--;
} }
...@@ -243,7 +243,7 @@ const increaseCount = async () => { ...@@ -243,7 +243,7 @@ const increaseCount = async () => {
temNum: form.value.temNum + 1, temNum: form.value.temNum + 1,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
form.value.temNum++; form.value.temNum++;
}; };
...@@ -302,14 +302,14 @@ const storePictureRead = async (file) => { ...@@ -302,14 +302,14 @@ const storePictureRead = async (file) => {
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate() const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().getEmployeeNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().employeeNo}/${uuidv4()}.png`, file.file)
await createExamine({ await createExamine({
id: form.value.id, id: form.value.id,
storePicture: pictureUrl, storePicture: pictureUrl,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
// 删除店铺门头照 // 删除店铺门头照
...@@ -319,7 +319,7 @@ const deleteStorePicture = async () => { ...@@ -319,7 +319,7 @@ const deleteStorePicture = async () => {
storePicture: '', storePicture: '',
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -331,7 +331,7 @@ const planStatusChange = async (val) => { ...@@ -331,7 +331,7 @@ const planStatusChange = async (val) => {
planStatus: form.value.planStatus, planStatus: form.value.planStatus,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -342,7 +342,7 @@ const changeStoreDd = async () => { ...@@ -342,7 +342,7 @@ const changeStoreDd = async () => {
storeDd: form.value.storeDd, storeDd: form.value.storeDd,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -357,7 +357,7 @@ const changeTemOnWork = async () => { ...@@ -357,7 +357,7 @@ const changeTemOnWork = async () => {
temOnWork: form.value.temOnWork, temOnWork: form.value.temOnWork,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
const changeTemOnWorkTimeRange = () => { const changeTemOnWorkTimeRange = () => {
...@@ -378,7 +378,7 @@ const changeTemHs = async () => { ...@@ -378,7 +378,7 @@ const changeTemHs = async () => {
temHs: form.value.temHs, temHs: form.value.temHs,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
const changeTemWl = async () => { const changeTemWl = async () => {
...@@ -387,7 +387,7 @@ const changeTemWl = async () => { ...@@ -387,7 +387,7 @@ const changeTemWl = async () => {
temWl: form.value.temWl, temWl: form.value.temWl,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
const changeTemZz = async () => { const changeTemZz = async () => {
...@@ -396,7 +396,7 @@ const changeTemZz = async () => { ...@@ -396,7 +396,7 @@ const changeTemZz = async () => {
temZz: form.value.temZz, temZz: form.value.temZz,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -406,7 +406,7 @@ const temWorkPhotosRead = async (file) => { ...@@ -406,7 +406,7 @@ const temWorkPhotosRead = async (file) => {
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate() const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().getEmployeeNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().employeeNo}/${uuidv4()}.png`, file.file)
// 如果当前对象包含 objectUrl 则是组件上传的,替换当前元素的对象 // 如果当前对象包含 objectUrl 则是组件上传的,替换当前元素的对象
const index = form.value.temWorkPhotos.findIndex(o => o.objectUrl) const index = form.value.temWorkPhotos.findIndex(o => o.objectUrl)
form.value.temWorkPhotos[index] = { form.value.temWorkPhotos[index] = {
...@@ -418,7 +418,7 @@ const temWorkPhotosRead = async (file) => { ...@@ -418,7 +418,7 @@ const temWorkPhotosRead = async (file) => {
temWorkPhotos: form.value.temWorkPhotos.map(o => o.url), temWorkPhotos: form.value.temWorkPhotos.map(o => o.url),
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -429,7 +429,7 @@ const deleteTemWorkPhotos = async () => { ...@@ -429,7 +429,7 @@ const deleteTemWorkPhotos = async () => {
temWorkPhotos: form.value.temWorkPhotos.map(o => o.url), temWorkPhotos: form.value.temWorkPhotos.map(o => o.url),
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -439,14 +439,14 @@ const storeTcPhotoRead = async (file) => { ...@@ -439,14 +439,14 @@ const storeTcPhotoRead = async (file) => {
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate() const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().getEmployeeNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().employeeNo}/${uuidv4()}.png`, file.file)
await createExamine({ await createExamine({
id: form.value.id, id: form.value.id,
storeTcPhoto: pictureUrl, storeTcPhoto: pictureUrl,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -457,7 +457,7 @@ const deleteStoreTcPhoto = async () => { ...@@ -457,7 +457,7 @@ const deleteStoreTcPhoto = async () => {
storeTcPhoto: '', storeTcPhoto: '',
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -467,14 +467,14 @@ const temOnWorkPictureRead = async (file) => { ...@@ -467,14 +467,14 @@ const temOnWorkPictureRead = async (file) => {
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate() const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().getEmployeeNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().employeeNo}/${uuidv4()}.png`, file.file)
await createExamine({ await createExamine({
id: form.value.id, id: form.value.id,
storeZhjPhoto: pictureUrl, storeZhjPhoto: pictureUrl,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
// 删除主货架照片 // 删除主货架照片
...@@ -484,7 +484,7 @@ const deleteStoreZhjPhoto = async () => { ...@@ -484,7 +484,7 @@ const deleteStoreZhjPhoto = async () => {
storeZhjPhoto: '', storeZhjPhoto: '',
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -494,7 +494,7 @@ const posPhotosRead = async (file) => { ...@@ -494,7 +494,7 @@ const posPhotosRead = async (file) => {
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate() const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().getEmployeeNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`examine/${date.getFullYear()}-${month}/${theDate}/${planId.value}/${userStore().employeeNo}/${uuidv4()}.png`, file.file)
// 判断 objectUrl // 判断 objectUrl
const index = form.value.posPhotos.findIndex(o => o.objectUrl) const index = form.value.posPhotos.findIndex(o => o.objectUrl)
form.value.posPhotos[index] = { form.value.posPhotos[index] = {
...@@ -506,7 +506,7 @@ const posPhotosRead = async (file) => { ...@@ -506,7 +506,7 @@ const posPhotosRead = async (file) => {
posPhotos: form.value.posPhotos.map(o => o.url), posPhotos: form.value.posPhotos.map(o => o.url),
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
// 删除 POS 照片 // 删除 POS 照片
...@@ -516,7 +516,7 @@ const deletePosPhotos = async () => { ...@@ -516,7 +516,7 @@ const deletePosPhotos = async () => {
posPhotos: form.value.posPhotos.map(o => o.url), posPhotos: form.value.posPhotos.map(o => o.url),
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
...@@ -527,7 +527,7 @@ const posRmbChange = async () => { ...@@ -527,7 +527,7 @@ const posRmbChange = async () => {
posRmb: form.value.posRmb || 0, posRmb: form.value.posRmb || 0,
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
} }
......
...@@ -95,7 +95,7 @@ import { parseTime } from '@/utils' ...@@ -95,7 +95,7 @@ import { parseTime } from '@/utils'
import userStore from '@/store/modules/user' import userStore from '@/store/modules/user'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const isCityManager = ref(userStore().getPromotionIdentity) const isCityManager = ref(userStore().promotionIdentity)
// 获取路由路径上的 id 参数 // 获取路由路径上的 id 参数
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
...@@ -215,7 +215,7 @@ const clickExamine = async () => { ...@@ -215,7 +215,7 @@ const clickExamine = async () => {
planStatus: planDetail.value.planStatus === 0 ? '否' : '是', planStatus: planDetail.value.planStatus === 0 ? '否' : '是',
employeeId: userStore().userInfo.userId, // 稽查人id employeeId: userStore().userInfo.userId, // 稽查人id
employeeName: userStore().userInfo.nickName, // 稽查人名字 employeeName: userStore().userInfo.nickName, // 稽查人名字
employeeNo: userStore().getEmployeeNo, // 稽查人工号 employeeNo: userStore().employeeNo, // 稽查人工号
}) })
if (!result.data) { if (!result.data) {
return proxy.$modal.msgError('创建稽查任务失败') return proxy.$modal.msgError('创建稽查任务失败')
......
...@@ -153,7 +153,7 @@ import userStore from '@/store/modules/user' ...@@ -153,7 +153,7 @@ import userStore from '@/store/modules/user'
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
const myForm = ref({}) const myForm = ref({})
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const isCityManager = ref(userStore().getPromotionIdentity) const isCityManager = ref(userStore().promotionIdentity)
const form = reactive({}) const form = reactive({})
const router = useRouter(); const router = useRouter();
const route = useRoute() const route = useRoute()
...@@ -197,7 +197,7 @@ const validatorIncidentals = (value, obj) => { ...@@ -197,7 +197,7 @@ const validatorIncidentals = (value, obj) => {
} }
} }
const onSubmit = async () => { const onSubmit = async () => {
const data = userStore().getEmployeeInfo const data = userStore().employeeInfo
for (const key in data) { for (const key in data) {
form[key] = data[key] form[key] = data[key]
} }
...@@ -278,8 +278,8 @@ const getBelongList = async () => { ...@@ -278,8 +278,8 @@ const getBelongList = async () => {
columns.value = allBelongList.value columns.value = allBelongList.value
// 判断如果是城市经理,则设置默认归属人为自己 // 判断如果是城市经理,则设置默认归属人为自己
if (isCityManager.value) { if (isCityManager.value) {
form.employeeName = userStore().getEmployeeName form.employeeName = userStore().employeeName
form.employeeNo = userStore().getEmployeeNo form.employeeNo = userStore().employeeNo
} }
} }
getBelongList() getBelongList()
......
<template>
<!-- 搜索组件 -->
<van-popup position="right"
class="wrap">
<!-- 快捷日期 -->
<van-field readonly
label="快捷日期">
<template #input>
<van-button size="small"
type="primary"
v-for="item in pickerOptions"
@click="pickerSelDate(item)">{{ item.text }}</van-button>
</template>
</van-field>
<!-- 日期区间 -->
<van-field :modelValue="searchDateStr"
is-link
readonly
label="日期范围"
placeholder="选择日期"
@click="selSearchCalendar">
</van-field>
<van-calendar v-model:show="showCalendar"
:min-date="searchMinDate"
:show-mark="false"
type="range"
allow-same-day
teleport="body"
:default-date="[query.activityStartDate, query.activityEndDate]"
@confirm="confirmCalendar" />
<!-- 活动类型 -->
<van-field v-model="query.planStatus"
is-link
readonly
label="活动状态"
placeholder="选择活动状态"
@click="showPlanStatus = true">
</van-field>
<van-popup v-model:show="showPlanStatus"
destroy-on-close
teleport="body"
position="bottom">
<van-picker :model-value="[planColumns.find(o => o.text === query.planStatus)?.value]"
:columns="planColumns"
@cancel="showPlanStatus = false"
@confirm="confirmPlan" />
</van-popup>
<!-- 归属人 -->
<van-field :model-value="showEmployeeList.find(o => o.value === query.employeeId)?.text"
is-link
readonly
label="归属人"
placeholder="选择归属人"
:disabled="promotionIdentity"
@click="showEmployee = true">
</van-field>
<PickerSearch v-model:show="showEmployee"
:columns="showEmployeeList"
placeholder="搜索归属人"
@confirm="onEmployeeConfirm"
@search="searchEmployee" />
<!-- 店铺名 -->
<van-field v-model="query.storeNameLike"
label="店铺名"
placeholder="请输入店铺名"
@update:model-value="searchByStoreName"
clearable />
<!-- 重置按钮 -->
<van-button icon="replay"
class="reset-btn"
block
@click="resetFn">重置</van-button>
</van-popup>
</template>
<script setup>
import { parseTime } from '@/utils'
import { useDatePickerOptions } from '@/hooks'
import userStore from '@/store/modules/user'
const promotionIdentity = computed(() => userStore().promotionIdentity)
const employeeNo = computed(() => userStore().employeeNo)
const { recentPickerOptions: pickerOptions } = useDatePickerOptions()
const query = reactive({})
const props = defineProps({
planColumns: { // 活动状态列表
type: Array,
default: []
},
allEmpolyeeList: { // 所有归属人
type: Array,
default: []
}
})
const emits = defineEmits(['query'])
watch(query, () => {
emits('query', query)
}, { deep: true })
// 选择快捷日期
const pickerSelDate = (item) => {
let [startTime, endTime] = item.value() // 拿到日期对象
// 同步更新单独选择日期的选择器和参数
query.activityStartDate = startTime
query.activityEndDate = endTime
}
// 选择日期区间
const showCalendar = ref(false)
const searchDateStr = computed(() => {
if (!query.activityStartDate || !query.activityEndDate) {
return ''
}
return [query.activityStartDate, query.activityEndDate].map(o => parseTime(o, "{y}-{m}-{d}")).join(' 至 ')
})
// 日历最小范围
const searchMinDate = computed(() => {
return new Date(!query.activityStartDate ? new Date().getFullYear() - 1 : query.activityStartDate.getFullYear() - 1, 0, 1)
})
// 日期日历范围
const selSearchCalendar = () => {
// 默认设置今日日期
if (!query.activityStartDate || !query.activityEndDate) {
query.activityStartDate = new Date()
query.activityEndDate = new Date()
}
showCalendar.value = true
}
// 确定日期
const confirmCalendar = (value) => {
showCalendar.value = false
query.activityStartDate = value[0]
query.activityEndDate = value[1]
}
// 活动状态
const showPlanStatus = ref(false)
// 选中的活动状态
const confirmPlan = (val) => {
query.planStatus = val.selectedOptions[0].text
showPlanStatus.value = false
}
// 归属人
const showEmployee = ref(false)
// 展示归属人
const showEmployeeList = ref([])
watch(() => props.allEmpolyeeList, (newValue) => {
showEmployeeList.value = newValue
// 如果是城市经理默认填充
if (promotionIdentity.value) {
// 找到员工的 id
const obj = newValue.find(o => o.employeeNo === employeeNo.value)
query.employeeId = obj.value
}
})
const searchEmployee = (searchName) => {
showEmployeeList.value = props.allEmpolyeeList.filter(item => {
return item.text.includes(searchName)
})
}
// 确定归属人
const onEmployeeConfirm = (val) => {
query.employeeId = val.selectedOptions[0].value
showEmployee.value = false
}
// 店铺名
const searchByStoreName = (val) => {
query.storeNameLike = val
}
// 重置
const resetFn = () => {
query.activityStartDate = ''
query.activityEndDate = ''
query.planStatus = ''
query.employeeId = ''
query.storeNameLike = ''
}
</script>
<style scoped
lang="scss">
.wrap {
--van-field-label-width: 80px;
height: 100vh;
width: 85% !important;
.van-field:first-of-type {
.van-button {
margin: 0 2.5px;
padding: 0 5px;
font-size: 12px !important;
}
}
.van-search {
width: 60%;
}
.reset-btn {
margin-top: 20px;
}
}
</style>
\ No newline at end of file
...@@ -95,11 +95,11 @@ export default defineStore( ...@@ -95,11 +95,11 @@ export default defineStore(
}, },
getters: { getters: {
// 获取促销系统身份(true 城市经理) // 获取促销系统身份(true 城市经理)
getPromotionIdentity(state) { promotionIdentity(state) {
return getPromotionRole(state.userInfo.privilegeId) === CITY_MANAGER return getPromotionRole(state.userInfo.privilegeId) === CITY_MANAGER
}, },
// 获取员工工号,姓名,id // 获取员工工号,姓名,id
getEmployeeInfo(state) { employeeInfo(state) {
return { return {
operNo: state.userInfo.userName, operNo: state.userInfo.userName,
operName: state.userInfo.nickName, operName: state.userInfo.nickName,
...@@ -107,11 +107,11 @@ export default defineStore( ...@@ -107,11 +107,11 @@ export default defineStore(
} }
}, },
// 获取员工工号 // 获取员工工号
getEmployeeNo(state) { employeeNo(state) {
return state.userInfo.userName return state.userInfo.userName
}, },
// 获取员工姓名 // 获取员工姓名
getEmployeeName(state) { employeeName(state) {
return state.userInfo.nickName return state.userInfo.nickName
} }
} }
......
// 把日期对象转成年-月-日前面补0 的数组
/**
* 把日期对象转成年-月-日前面补0 的数组
* @param {*} date 日期对象
* @returns [年,月,日]
* @example 2023-09-01 => [2023, 09, 01]
*/
export function formatDateToArr(date) {
const year = date.getFullYear(); // 获取年份
const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份并补零
const day = String(date.getDate()).padStart(2, '0'); // 获取日期并补零
return [year, month, day];
}
/** /**
* 生成时间列表 * 生成时间列表
* @param {*} startDate 起始时间 * @param {*} startDate 起始时间
...@@ -207,13 +221,3 @@ export function addDateRange(params, dateRange, propName) { ...@@ -207,13 +221,3 @@ export function addDateRange(params, dateRange, propName) {
return search; return search;
} }
/**
* 生成唯一字符串
* @returns {string}
*/
export function createUniqueString() {
const timestamp = +new Date() + ''
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
return (+(randomNum + timestamp)).toString(32)
}
\ No newline at end of file
...@@ -461,7 +461,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'; ...@@ -461,7 +461,7 @@ import { ElMessage, ElMessageBox } from 'element-plus';
import { usePromotionHooks } from '@/hooks' import { usePromotionHooks } from '@/hooks'
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const isCityManager = ref(userStore().getPromotionIdentity) const isCityManager = ref(userStore().promotionIdentity)
const { recentPickerOptions: pickerOptions } = useDatePickerOptions() const { recentPickerOptions: pickerOptions } = useDatePickerOptions()
const queryParams = reactive({ const queryParams = reactive({
...@@ -707,9 +707,9 @@ const getPlanList = async () => { ...@@ -707,9 +707,9 @@ const getPlanList = async () => {
// 城市经理查自己,职能角色查所有 // 城市经理查自己,职能角色查所有
if (isCityManager.value) { if (isCityManager.value) {
// 城市经理 (用员工 ID(1,2,3),而不是工号,employeeNo 是工号(000535)) // 城市经理 (用员工 ID(1,2,3),而不是工号,employeeNo 是工号(000535))
queryParams.employeeId = belongPerList.value.find(item => item.employeeNo === userStore().getEmployeeNo)?.value queryParams.employeeId = belongPerList.value.find(item => item.employeeNo === userStore().employeeNo)?.value
// 先从归属人查询当前登录用户的战区 ID // 先从归属人查询当前登录用户的战区 ID
queryParams.warzoneId = belongPerList.value.find(item => item.employeeNo === userStore().getEmployeeNo)?.deptQcId queryParams.warzoneId = belongPerList.value.find(item => item.employeeNo === userStore().employeeNo)?.deptQcId
} }
// 日期格式化一下 // 日期格式化一下
if (queryParams.activityDate?.length > 0) { if (queryParams.activityDate?.length > 0) {
...@@ -811,11 +811,11 @@ const uploadFile = async (file) => { ...@@ -811,11 +811,11 @@ const uploadFile = async (file) => {
// 拼接当前月数为文件夹名 // 拼接当前月数为文件夹名
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const excelUrl = await uploadFileToOSSAPI(`planExcel/${date.getFullYear()}-${month}/${userStore().getEmployeeNo}/${uuidv4()}.xlsx`, file.file) const excelUrl = await uploadFileToOSSAPI(`planExcel/${date.getFullYear()}-${month}/${userStore().employeeNo}/${uuidv4()}.xlsx`, file.file)
const targetAPI = isCityManager.value ? addPlanAPI : addPlanByRoleAPI const targetAPI = isCityManager.value ? addPlanAPI : addPlanByRoleAPI
const res = await targetAPI({ const res = await targetAPI({
"excelUrl": excelUrl, "excelUrl": excelUrl,
"employeeNo": userStore().getEmployeeNo "employeeNo": userStore().employeeNo
}) })
planTableList.value = res.data.table planTableList.value = res.data.table
confirmExcelUUID.value = res.data.uuid confirmExcelUUID.value = res.data.uuid
...@@ -1061,7 +1061,7 @@ const handleAdd = () => { ...@@ -1061,7 +1061,7 @@ const handleAdd = () => {
resetAddOrEditPlanForm() resetAddOrEditPlanForm()
// 只有城市经理情况下,默认填充当前登录人为归属人 // 只有城市经理情况下,默认填充当前登录人为归属人
if (isCityManager.value) { if (isCityManager.value) {
addOrEditPlanForm.value.employeeNo = userStore().getEmployeeNo addOrEditPlanForm.value.employeeNo = userStore().employeeNo
} }
addOrEditPlanVisible.value = true addOrEditPlanVisible.value = true
} }
...@@ -1116,7 +1116,7 @@ const editFn = (row) => { ...@@ -1116,7 +1116,7 @@ const editFn = (row) => {
const handleAddOrEditPlan = async () => { const handleAddOrEditPlan = async () => {
// 表单校验 // 表单校验
await addOrEditPlanRef.value.validate() await addOrEditPlanRef.value.validate()
addOrEditPlanForm.value.operNo = userStore().getEmployeeNo addOrEditPlanForm.value.operNo = userStore().employeeNo
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
...@@ -1154,7 +1154,7 @@ const handleDelete = async () => { ...@@ -1154,7 +1154,7 @@ const handleDelete = async () => {
}) })
await deletePlanAPI({ await deletePlanAPI({
planIds: checkedRowList.value.map(o => o.id), planIds: checkedRowList.value.map(o => o.id),
employeeNo: userStore().getEmployeeNo employeeNo: userStore().employeeNo
}) })
ElMessage.success('删除成功') ElMessage.success('删除成功')
getPlanList() getPlanList()
...@@ -1221,10 +1221,10 @@ const uploadChangeFile = async (file) => { ...@@ -1221,10 +1221,10 @@ const uploadChangeFile = async (file) => {
// 拼接当前月数为文件夹名 // 拼接当前月数为文件夹名
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const excelUrl = await uploadFileToOSSAPI(`planExcel/${date.getFullYear()}-${month}/${userStore().getEmployeeNo}/${uuidv4()}.xlsx`, file.file) const excelUrl = await uploadFileToOSSAPI(`planExcel/${date.getFullYear()}-${month}/${userStore().employeeNo}/${uuidv4()}.xlsx`, file.file)
const res = await updatePlanAPI({ const res = await updatePlanAPI({
"excelUrl": excelUrl, "excelUrl": excelUrl,
"employeeNo": userStore().getEmployeeNo "employeeNo": userStore().employeeNo
}) })
planTableList.value = res.data.table planTableList.value = res.data.table
confirmExcelUUID.value = res.data.uuid confirmExcelUUID.value = res.data.uuid
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论