提交 8edfc188 authored 作者: lidongxu's avatar lidongxu

refactor(promotion): 合并

合并 pro 过来 ldx
......@@ -16,4 +16,3 @@ VITE_APP_PUBLIC_PATH = '/'
# 第三方服务回调地址
VITE_APP_REDIRECT_URL = 'http://localhost:8080/'
......@@ -13,4 +13,3 @@ VITE_APP_PUBLIC_PATH = './'
# 第三方服务回调地址
VITE_APP_REDIRECT_URL = 'http://111.198.15.68:86/link/'
......@@ -12,4 +12,4 @@ VITE_APP_ENV = 'staging'
VITE_APP_PUBLIC_PATH = './'
# 第三方服务回调地址
VITE_APP_REDIRECT_URL = 'http://111.198.15.68:85/link/'
VITE_APP_REDIRECT_URL = 'http://111.198.15.68:85/link/'
\ No newline at end of file
......@@ -19,6 +19,7 @@
"@element-plus/icons-vue": "2.3.1",
"@vueup/vue-quill": "1.2.0",
"@vueuse/core": "10.11.0",
"ali-oss": "^6.22.0",
"axios": "0.28.1",
"clipboard": "2.0.11",
"echarts": "^5.4.0",
......@@ -32,6 +33,7 @@
"nprogress": "0.2.0",
"pinia": "2.1.7",
"splitpanes": "3.1.5",
"uuid": "^11.0.5",
"vue": "^3.5.13",
"vue-count-to": "^1.0.13",
"vue-cropper": "1.1.1",
......
import request from '@/utils/request'
import OSS from 'ali-oss'
const ossAuthURL = `${import.meta.env.VITE_APP_PROMOTION}/user/aliyun/sts_token` // 后台获取阿里云 OSS 权限信息接口
// OSS 上传文件
export const uploadFileToOSSAPI = (fileName, filePath) => {
return new Promise(async (resolve, reject) => {
const authRes = await request({
baseURL: ossAuthURL,
url: ''
})
const { accessKeyId, securityToken, accessKeySecret, expiration, region, web_js_link } = authRes.data;
const client = new OSS({
// Bucket 所在地域
region: `oss-${region}`,
// 从 STS 服务获取的临时访问密钥(AccessKey ID 和 AccessKey Secret)
accessKeyId: accessKeyId,
accessKeySecret: accessKeySecret,
// 从STS服务获取的安全令牌(SecurityToken)。
stsToken: securityToken,
// 刷新临时访问凭证的时间间隔,单位为毫秒。
refreshSTSTokenInterval: expiration,
// 填写Bucket名称。
bucket: web_js_link
});
// 发送请求上传文件 (文件名包含路径文件夹名字)
const res = await client.put(fileName, filePath)
resolve(res.url) // 上传成功
})
}
\ No newline at end of file
export * from './common/login'
export * from './common/menu'
export * from './common/region'
export * from './common/openQuery'
export * from './common/region'
export * from './common/upload'
export * from './bi/competitor'
export * from './bi/finance'
export * from './bi/livecate'
......@@ -13,6 +14,7 @@ export * from './monitor/job'
export * from './monitor/jobLog'
export * from './monitor/online'
export * from './monitor/server'
export * from './promotion/plan'
export * from './promotion/task'
export * from './system/dict/data'
export * from './system/dict/type'
......
import request from '@/utils/request'
const VITE_APP_PROMOTION = import.meta.env.VITE_APP_PROMOTION
// 获取计划列表
export function getPlanListAPI(queryParams) {
return request({
baseURL: VITE_APP_PROMOTION,
url: '/plan/v2/query/page',
method: 'POST',
data: {
"pageNum": queryParams.pageNum,
"pageSize": queryParams.pageSize,
"queryParams": {
"activityStartDate": queryParams.activityDate[0],
"activityEndDate": queryParams.activityDate[1]
}
}
})
}
// 表格新增计划
export function addPlanAPI(data) {
return request({
baseURL: VITE_APP_PROMOTION,
url: '/plan/v2/core/self/upload',
method: 'POST',
data
})
}
\ No newline at end of file
......@@ -36,6 +36,7 @@ export function updateUser(data) {
})
}
// 删除用户
export function delUser(userId) {
return request({
......@@ -133,4 +134,4 @@ export function deptTreeSelectList() {
url: '/system/user/deptTree',
method: 'get'
})
}
}
\ No newline at end of file
......@@ -12,7 +12,8 @@ export default defineStore(
name: '',
avatar: '',
roles: [],
permissions: []
permissions: [],
userInfo: ''
}),
actions: {
/**
......@@ -61,6 +62,7 @@ export default defineStore(
this.id = user.userId
this.name = user.nickName
this.avatar = avatar
this.userInfo = user
resolve(res)
}).catch(error => {
reject(error)
......
......@@ -12,7 +12,7 @@ let downloadLoadingInstance;
// 是否显示重新登录
export let isRelogin = { show: false };
// 其他系统后台 baseURL
// 促销系统后台 baseURL
export const promotionBaseURL = import.meta.env.VITE_APP_PROMOTION_BASE_API
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
......@@ -31,8 +31,8 @@ service.interceptors.request.use(config => {
// 是否需要防止数据重复提交
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
if (getToken() && !isToken) {
console.log(config.url, promotionBaseURL)
if (config.url.includes(promotionBaseURL)) {
if (config.url.indexOf(promotionBaseURL)) {
// 促销后台不能带 Bearer 前缀
config.headers['Authorization'] = getToken()
} else {
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
......
......@@ -231,7 +231,7 @@
</template>
<script setup>
import { getBrandListAPI, getTasteListAPI, getSpecListAPI, getSeriesListAPI, getProductListAPI, getFinanceListAPI, getFinanceDetailAPI, getFinanceSubListAPI, downloadFinanceListAPI } from '@/api'
import { getBrandListAPI, getTasteListAPI, getSpecListAPI, getSeriesListAPI, getProductListAPI, getFinanceListAPI, getFinanceDetailAPI, getFinanceSubListAPI, downloadFinanceListAPI, addPlanAPI } from '@/api'
import { useDatePickerOptions } from '@/hooks'
import { formatNumberWithUnit, parseTime } from '@/utils'
......@@ -783,7 +783,6 @@ const detailFormatter = (row, column, value) => {
const changeShowOver = () => {
showOverFlowToolTip.value = !showOverFlowToolTip.value
}
</script>
<style scoped
......
<template>
<div class="app-container">
<div class="container">
<!-- 查询表单 -->
<el-form :model="queryParams"
inline
label-width="68px">
<el-form-item label="选择日期"
prop="date">
<el-date-picker v-model="queryParams.activityDate"
type="daterange"
:clearable="false"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:shortcuts="pickerOptions" />
</el-form-item>
<el-form-item label="上传计划">
<el-upload class="upload-demo"
action="#"
accept=".xls,.xlsx"
:http-request="uploadFile"
:show-file-list="false"
:limit="1">
<template #trigger>
<el-button type="primary">选择 Excel</el-button>
</template>
</el-upload>
</el-form-item>
</el-form>
<!-- 表格列表 -->
<el-table :data="tableList"
:cell-style="{ 'word-wrap': 'break-word', 'white-space': 'normal' }"
border
style="width: 100%"
show-overflow-tooltip>
<el-table-column type="selection"
width="55">
</el-table-column>
<el-table-column v-for="item in columns"
:key="item.label"
:prop="item.prop"
:label="item.label"
:width="item.width"
:formatter="formatter"
:fixed="item.fixed" />
</el-table>
<!-- 弹窗确认上传计划 -->
<el-dialog title="上传计划"
v-model="dialogVisible"
width="80%">
<div>
<!-- 计划表格 -->
<el-table :data="planTableList"
border
style="width: 100%">
<el-table-column prop="name"
label="文件名"
width="200">
</el-table-column>
</el-table>
</div>
</el-dialog>
</div>
</div>
</template>
<script setup>
import { getPlanListAPI, uploadFileToOSSAPI, addPlanAPI } from '@/api'
import { useDatePickerOptions } from '@/hooks'
import { v4 as uuidv4 } from 'uuid';
import store from '@/store'
const { recentPickerOptions: pickerOptions, last7Date } = useDatePickerOptions(0)
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
activityDate: last7Date
})
// 任务列表
const tableList = ref([])
const columns = ref([
{
label: '活动 ID',
prop: 'id',
width: 90,
fixed: true
},
{
label: '负责人',
prop: 'employeeName',
width: 90,
fixed: true
},
{
label: '经销商',
prop: 'dealerName',
width: 220
},
{
label: '系统名称',
prop: 'lineName',
width: 100
},
{
label: '店铺名称',
prop: 'storeName',
width: 200
},
{
label: '活动状态',
prop: 'planStatus',
width: 100
},
{
label: '活动模式',
prop: 'pattern',
width: 100
},
{
label: '省份',
prop: 'province',
width: 100
},
{
label: '城市',
prop: 'city',
width: 100
},
{
label: '最后修改时间',
prop: 'modifyTime',
width: 250
},
{
label: '上传文件名称',
prop: '',
width: 150
},
{
label: '操作',
prop: ''
},
])
const getPlanList = async () => {
const res = await getPlanListAPI(queryParams)
tableList.value = res.data.records
}
getPlanList()
const formatter = (row, col, value) => {
if (col.property === 'planStatus') {
return value == 0 ? '执行中' : '取消'
} else {
return value
}
}
// 上传计划
const uploadFile = async (file) => {
console.log(store.state)
// 拼接当前月数为文件夹名
const date = new Date()
const month = date.getMonth() + 1
const excelUrl = await uploadFileToOSSAPI(`planExcel/${date.getFullYear()}-${month}/${store.state.value.user.userInfo.userName}/${uuidv4()}.xlsx`, file.file)
const res = await addPlanAPI({
"excelUrl": excelUrl,
"employeeNo": store.state.value.user.userInfo.userName
})
console.log(res)
dialogVisible.value = true
}
// 确认计划
const planTableList = ref([])
const dialogVisible = ref(false)
</script>
<style scoped
lang="scss"></style>
\ No newline at end of file
......@@ -113,7 +113,6 @@ import { useDatePickerOptions } from '@/hooks'
import { getWarZoneListAPI, getChargeListAPI, getTaskListAPI, getProCityAPI } from '@/api'
import { parseTime } from '@/utils'
const { recentPickerOptions: pickerOptions, last7Date } = useDatePickerOptions(0)
const queryParams = reactive({
date: last7Date,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论