Commit 8a7af916 by 姜鹏凯

商品中心调试

1 parent f06cadfd
......@@ -132,7 +132,8 @@ export function setOrderSync() {
export function exportOrder(data) {
return request({
url: service + '/order/export',
params: data
params: data,
responseType: 'blob',
})
}
......@@ -157,10 +158,47 @@ export function getGoodsTotal() {
})
}
// 商品分析
// 商品分析 折线图
export function getLineChartTotal(data) {
return request({
url: service + '/analyze/lineChart',
method: 'post',
data
})
}
// 商品分析 商品top5
export function getGoodsTop5(data) {
return request({
url: service + '/analyze/top5',
method: 'post',
data
})
}
// 商品分析 员工top5
export function getMembersTop5(data) {
return request({
url: service + '/analyze/user/top5',
method: 'post',
data
})
}
// 商品分析 数据报表
export function getTableTotal(data) {
return request({
url: service + '/analyze/data/report',
params: data
})
}
// 商品分析 数据报表 导出
export function getTableExport(params) {
return request({
url: service + '/analyze/data/report/export',
method: 'post',
responseType: 'blob',
params,
})
}
\ No newline at end of file
<script>
import { getCosConfig, getVideoPic } from '@/api/common'
import { dateFormat, uuid } from '@/utils/index'
import Video from 'video.js'
import Cos from 'cos-js-sdk-v5'
import BenzAMRRecorder from 'benz-amr-recorder'
import MP4Box from 'mp4box'
import { getCosConfig, getVideoPic } from '@/api/common'
import { dateFormat, uuid } from '@/utils/index'
import Video from 'video.js'
import Cos from 'cos-js-sdk-v5'
import BenzAMRRecorder from 'benz-amr-recorder'
import MP4Box from 'mp4box'
export default {
components: {},
props: {
// 单文件上传时使用
fileUrl: {
type: String,
default: '',
},
fileName: {
type: String,
default: '',
},
export default {
components: {},
props: {
// 单文件上传时使用
fileUrl: {
type: String,
default: ''
},
fileName: {
type: String,
default: ''
},
// 多文件上传时使用,例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
fileList: {
type: Array,
default: () => [],
},
// 多文件上传时使用,例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
fileList: {
type: Array,
default: () => []
},
// 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
type: {
type: String,
default: '0',
validator: function (value) {
// 这个值必须匹配下列字符串中的一个
return ['0', '1', '2', '3'].includes(value)
// 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
type: {
type: String,
default: '0',
validator: function (value) {
// 这个值必须匹配下列字符串中的一个
return ['0', '1', '2', '3'].includes(value)
}
},
},
// 上传文件大小不能超过 maxSize MB, 各类型有默认限制 参见: maxSizeDefault
maxSize: {
type: Number,
default: undefined,
},
// 图片的宽高像素限制 [width(number), height(number)],默认null不限制
maxImgPx: {
type: Array,
default: null, // () => [100, 100]
},
// 允许上传的文件格式后缀名 eg:["jpg", "png"],['*']为不限制,各类型有默认限制 参见: formatDefault
format: {
type: Array,
default: undefined,
},
// 选择上传文件类型, 用于过滤系统选择文件类型, 默认根据类型自动匹配:见 acceptAuto,
accept: {
type: String,
default: '',
},
// 是否能上传多个
multiple: {
type: Boolean,
default: false,
},
// multiple为true是有效,最多上传几个,默认不限制,最小为1,大于1是自动开启可多选,
limit: {
type: Number,
default: undefined,
},
// onProgress: {
// type: Function,
// default: null,
// },
// beforeUpload: {
// type: Function,
// default: function() {
// return function() {}
// },
// },
// 上传文件大小不能超过 maxSize MB, 各类型有默认限制 参见: maxSizeDefault
maxSize: {
type: Number,
default: undefined
},
// 图片的宽高像素限制 [width(number), height(number)],默认null不限制
maxImgPx: {
type: Array,
default: null // () => [100, 100]
},
// 允许上传的文件格式后缀名 eg:["jpg", "png"],['*']为不限制,各类型有默认限制 参见: formatDefault
format: {
type: Array,
default: undefined
},
// 选择上传文件类型, 用于过滤系统选择文件类型, 默认根据类型自动匹配:见 acceptAuto,
accept: {
type: String,
default: ''
},
// 是否能上传多个
multiple: {
type: Boolean,
default: false
},
// multiple为true是有效,最多上传几个,默认不限制,最小为1,大于1是自动开启可多选,
limit: {
type: Number,
default: undefined
}
// onProgress: {
// type: Function,
// default: null,
// },
// beforeUpload: {
// type: Function,
// default: function() {
// return function() {}
// },
// },
// 图片操作 目前支持有 view:查看,remove:删除,download:下载
// action: {
// type: Array,
// default: () => ["view", "remove"],
// },
},
data() {
return {
loading: false,
// 图片操作 目前支持有 view:查看,remove:删除,download:下载
// action: {
// type: Array,
// default: () => ["view", "remove"],
// },
},
data() {
return {
loading: false,
fileUrlWatch: this.fileUrl,
fileNameWatch: this.fileName,
fileListWatch: this.fileList,
fileUrlWatch: this.fileUrl,
fileNameWatch: this.fileName,
fileListWatch: this.fileList,
picUrl: '', // 视频第一帧
file: undefined,
speed: 0, // 上传网速
percentage: 0, //上传进度
picUrl: '', // 视频第一帧
file: undefined,
speed: 0, // 上传网速
percentage: 0, //上传进度
// cos配置信息
cosConfig: { bucketName: '', cosImgUrlPrefix: '', region: '' },
cosInstance: undefined, // cos实例
}
},
watch: {
fileUrl: {
handler(value) {
this.fileUrlWatch = value
},
// cos配置信息
cosConfig: { bucketName: '', cosImgUrlPrefix: '', region: '' },
cosInstance: undefined // cos实例
}
},
fileName: {
handler(value) {
this.fileNameWatch = value
watch: {
fileUrl: {
handler(value) {
this.fileUrlWatch = value
}
},
fileName: {
handler(value) {
this.fileNameWatch = value
}
},
fileList: {
handler(value) {
this.fileListWatch = value
}
},
loading(val) {
this.$emit('loadingChange', val)
}
},
loading(val) {
this.$emit('loadingChange', val)
},
},
computed: {
// 识别选择文件类型
acceptAuto() {
return ['image/*', 'amr/*', 'video/*'][this.type]
computed: {
// 识别选择文件类型
acceptAuto() {
return ['image/*', 'amr/*', 'video/*'][this.type]
}
},
},
created() {
getCosConfig().then((res) => {
this.cosConfig = res
this.cosInstance = new Cos({
SecretId: res.secretId,
SecretKey: res.secretKey,
created() {
getCosConfig().then((res) => {
this.cosConfig = res
this.cosInstance = new Cos({
SecretId: res.secretId,
SecretKey: res.secretKey
})
})
})
},
mounted() {
// const cosInstance = new Cos({
// // getAuthorization 必选参数
// getAuthorization: function (options, callback) {
// // 服务端例子:https://github.com/tencentyun/qcloud-cos-sts-sdk/blob/master/scope.md
// // 异步获取临时密钥
// var url = window.lwConfig.SYSTEM_API + '/file/get/config' // url替换成您自己的后端服务
// var xhr = new XMLHttpRequest()
// xhr.open('get', url, true)
// xhr.setRequestHeader('Content-Type', 'application/json')
// xhr.onload = function (e) {
// try {
// var data = JSON.parse(e.target.responseText)
// var credentials = data.credentials
// } catch (e) {}
// if (!data || !credentials) {
// return console.error('credentials invalid:\n' + JSON.stringify(data, null, 2))
// }
// callback({
// TmpSecretId: decrypt(credentials.secretId),
// TmpSecretKey: credentials.secretKey,
// SecurityToken: credentials.sessionToken,
// // 建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
// StartTime: data.startTime, // 时间戳,单位秒,如:1580000000
// ExpiredTime: data.expiredTime, // 时间戳,单位秒,如:1580000000
// // ScopeLimit: true, // 细粒度控制权限需要设为 true,会限制密钥只在相同请求时重复使用
// })
// }
// xhr.send()
// // xhr.send(JSON.stringify(options.Scope))
// },
// })
},
methods: {
upload() {
this.loading = true
let file = undefined
if (!this.multiple || this.limit == 1) {
file = this.file
} else {
// 多选上传是多次调用单传的
file = this.file.shift()
}
let date = new Date()
let format = file.name.match(/\.(\w+)$/g)
format = format && format[0]
const params = {
Bucket: this.cosConfig.bucketName /* 填入您自己的存储桶,必须字段 */,
Region: this.cosConfig.region /* 存储桶所在地域,例如ap-beijing,必须字段 */,
Key: `/${dateFormat(date, 'yyyy-MM-dd')}/t${date.getTime()}-${uuid()}${format}`,
/* 存储在桶里的对象键(例如1.jpg,a/b/test.txt),必须字段。*/
// 此处使用的格式: /日期/t时间戳-uid-文件后缀名
}
},
mounted() {
// const cosInstance = new Cos({
// // getAuthorization 必选参数
// getAuthorization: function (options, callback) {
// // 服务端例子:https://github.com/tencentyun/qcloud-cos-sts-sdk/blob/master/scope.md
// // 异步获取临时密钥
// var url = window.lwConfig.SYSTEM_API + '/file/get/config' // url替换成您自己的后端服务
// var xhr = new XMLHttpRequest()
// xhr.open('get', url, true)
// xhr.setRequestHeader('Content-Type', 'application/json')
// xhr.onload = function (e) {
// try {
// var data = JSON.parse(e.target.responseText)
// var credentials = data.credentials
// } catch (e) {}
// if (!data || !credentials) {
// return console.error('credentials invalid:\n' + JSON.stringify(data, null, 2))
// }
// callback({
// TmpSecretId: decrypt(credentials.secretId),
// TmpSecretKey: credentials.secretKey,
// SecurityToken: credentials.sessionToken,
// // 建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
// StartTime: data.startTime, // 时间戳,单位秒,如:1580000000
// ExpiredTime: data.expiredTime, // 时间戳,单位秒,如:1580000000
// // ScopeLimit: true, // 细粒度控制权限需要设为 true,会限制密钥只在相同请求时重复使用
// })
// }
// xhr.send()
// // xhr.send(JSON.stringify(options.Scope))
// },
// })
},
methods: {
upload() {
this.loading = true
let file = undefined
if (!this.multiple || this.limit == 1) {
file = this.file
} else {
// 多选上传是多次调用单传的
file = this.file.shift()
}
let date = new Date()
let format = file.name.match(/\.(\w+)$/g)
format = format && format[0]
const params = {
Bucket: this.cosConfig.bucketName /* 填入您自己的存储桶,必须字段 */,
Region: this.cosConfig.region /* 存储桶所在地域,例如ap-beijing,必须字段 */,
Key: `/${dateFormat(date, 'yyyy-MM-dd')}/t${date.getTime()}-${uuid()}${format}`
/* 存储在桶里的对象键(例如1.jpg,a/b/test.txt),必须字段。*/
// 此处使用的格式: /日期/t时间戳-uid-文件后缀名
}
// 实例可能未初始化完成
if (!this.cosInstance) {
this.$message.error('存储空间正忙,请稍后再试')
return
}
// 实例可能未初始化完成
if (!this.cosInstance) {
this.$message.error('存储空间正忙,请稍后再试')
return
}
this.cosInstance.uploadFile(
{
...params,
Body: file /* 必须,上传文件对象,可以是input[type="file"]的file对象 */,
onProgress: (progressData) => {
this.percentage = progressData.percent * 100
this.speed = (progressData.speed / 1024 / 1024).toFixed(2)
// this.onProgress && this.onProgress(this.percentage, this.speed)
this.cosInstance.uploadFile(
{
...params,
Body: file /* 必须,上传文件对象,可以是input[type="file"]的file对象 */,
onProgress: (progressData) => {
this.percentage = progressData.percent * 100
this.speed = (progressData.speed / 1024 / 1024).toFixed(2)
// this.onProgress && this.onProgress(this.percentage, this.speed)
}
},
},
(err1, data) => {
this.percentage = this.speed = 0
(err1, data) => {
this.percentage = this.speed = 0
if (err1) {
this.loading = false
this.$message.error('上传失败,请稍后再试')
} else {
let location = 'https://' + data.Location
if (err1) {
this.loading = false
this.$message.error('上传失败,请稍后再试')
} else {
let location = 'https://' + data.Location
this.type == 2
? //获取视频第一帧画面
getVideoPic({ url: location }).then((res) => {
this.loading = false
this.$emit('getPicUrl', res.data.url)
})
: (this.loading = false)
this.type == 2
? //获取视频第一帧画面
getVideoPic({ url: location }).then((res) => {
this.loading = false
this.$emit('getPicUrl', res.data.url)
})
: (this.loading = false)
// 使用本地链接提供预览,避免上传后下载的问题
let url = window.URL.createObjectURL(file)
// 使用本地链接提供预览,避免上传后下载的问题
let url = window.URL.createObjectURL(file)
let name = file.name
if (!this.multiple) {
this.fileUrlWatch = url
this.$emit('update:fileUrl', location)
this.$emit('update:fileName', (this.fileNameWatch = name))
} else {
this.fileListWatch = this.fileListWatch.concat({ name, url })
this.$emit('update:fileList', this.fileList.concat({ name, url: location }))
let name = file.name
if (!this.multiple) {
this.fileUrlWatch = url
this.$emit('update:fileUrl', location)
this.$emit('update:fileName', (this.fileNameWatch = name))
} else {
this.fileListWatch = this.fileListWatch.concat({ name, url })
this.$emit('update:fileList', this.fileList.concat({ name, url: location }))
}
}
}
},
)
},
remove(i) {
this.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
let clone = JSON.parse(JSON.stringify(this.fileList))
this.fileListWatch.splice(i, 1)
clone.splice(i, 1)
this.$emit('update:fileList', clone)
})
},
handleExceed(file, fileList) {
this.$message.error('最多上传' + this.limit + '张')
this.loading = false
},
async handleBeforeUpload(file, filelist) {
this.loading = true
let isFormat = true
let isSize = true
)
},
remove(i) {
this.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let clone = JSON.parse(JSON.stringify(this.fileList))
this.fileListWatch.splice(i, 1)
clone.splice(i, 1)
this.$emit('update:fileList', clone)
})
},
handleExceed(file, fileList) {
this.$message.error('最多上传' + this.limit + '张')
this.loading = false
},
async handleBeforeUpload(file, filelist) {
this.loading = true
let isFormat = true
let isSize = true
// type: 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
// type: 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
// 统一校验文件后缀名格式
// 如果没有显示配置 format 格式限制,则使用默认下面校验
let format = this.format
let tip = ''
if (!format || !format.length) {
let formatDefault = {
0: { tip: 'png/jpg', value: ['png', 'jpg', 'jpeg'] },
1: { value: ['amr'] },
2: { value: ['mp4'] },
3: { tip: 'word/pdf/ppt', value: ['doc', 'docx', 'pdf', 'ppt', 'pptx', 'pps', 'pptsx'] },
// 统一校验文件后缀名格式
// 如果没有显示配置 format 格式限制,则使用默认下面校验
let format = this.format
let tip = ''
if (!format || !format.length) {
let formatDefault = {
0: { tip: 'png/jpg', value: ['png', 'jpg', 'jpeg'] },
1: { value: ['amr'] },
2: { value: ['mp4'] },
3: { tip: 'word/pdf/ppt', value: ['doc', 'docx', 'pdf', 'ppt', 'pptx', 'pps', 'pptsx'] }
}
format = formatDefault[this.type].value
tip = formatDefault[this.type].tip
}
let match = file.name.match(/\.(\w+)$/g)
let fileFormat = match && match[0].replace('.', '').toLowerCase()
isFormat = format[0] === '*' || format.includes(fileFormat)
if (!isFormat) {
this.$message.error('文件格式错误,仅支持 ' + (tip || format.join(',')) + ' 格式!')
this.loading = false
return Promise.reject()
}
format = formatDefault[this.type].value
tip = formatDefault[this.type].tip
}
let match = file.name.match(/\.(\w+)$/g)
let fileFormat = match && match[0].replace('.', '').toLowerCase()
isFormat = format[0] === '*' || format.includes(fileFormat)
if (!isFormat) {
this.$message.error('文件格式错误,仅支持 ' + (tip || format.join(',')) + ' 格式!')
this.loading = false
return Promise.reject()
}
// 统一校验文件体积
// 如果没有显式配置 maxSize 限制大小,则使用下面默认值,单位 MB,
let maxSize = this.maxSize
if (!maxSize) {
let maxSizeDefault = { 0: 2, 1: 2, 2: 100, 3: 50 }
maxSize || (maxSize = maxSizeDefault[this.type])
}
isSize = file.size / 1024 / 1024 < maxSize
if (!isSize) {
this.$message.error('上传文件大小不能超过 ' + maxSize + 'MB!')
this.loading = false
return Promise.reject()
}
// 统一校验文件体积
// 如果没有显式配置 maxSize 限制大小,则使用下面默认值,单位 MB,
let maxSize = this.maxSize
if (!maxSize) {
let maxSizeDefault = { 0: 2, 1: 2, 2: 100, 3: 50 }
maxSize || (maxSize = maxSizeDefault[this.type])
}
isSize = file.size / 1024 / 1024 < maxSize
if (!isSize) {
this.$message.error('上传文件大小不能超过 ' + maxSize + 'MB!')
this.loading = false
return Promise.reject()
}
// 各类型独有的校验
let validate = true
if (this.type === '0') {
// 图片
let maxImgPx = this.maxImgPx
if (maxImgPx) {
try {
await new Promise((resolve) => {
let width, height
let image = new Image()
//加载图片获取图片真实宽度和高度
image.onload = () => {
width = image.width
height = image.height
if (width > maxImgPx[0]) {
validate = false
this.$message.error(`图片“宽”度超过${maxImgPx[0]}像素,请重新选择`)
} else if (height > maxImgPx[1]) {
this.$message.error(`图片“高”度超过${maxImgPx[1]}像素,请重新选择`)
validate = false
// 各类型独有的校验
let validate = true
if (this.type === '0') {
// 图片
let maxImgPx = this.maxImgPx
if (maxImgPx) {
try {
await new Promise((resolve) => {
let width, height
let image = new Image()
//加载图片获取图片真实宽度和高度
image.onload = () => {
width = image.width
height = image.height
if (width > maxImgPx[0]) {
validate = false
this.$message.error(`图片“宽”度超过${maxImgPx[0]}像素,请重新选择`)
} else if (height > maxImgPx[1]) {
this.$message.error(`图片“高”度超过${maxImgPx[1]}像素,请重新选择`)
validate = false
}
window.URL && window.URL.revokeObjectURL(image.src)
resolve()
}
window.URL && window.URL.revokeObjectURL(image.src)
resolve()
}
if (window.URL) {
let url = window.URL.createObjectURL(file)
image.src = url
} else if (window.FileReader) {
let reader = new FileReader()
reader.onload = function (e) {
let data = e.target.result
image.src = data
if (window.URL) {
let url = window.URL.createObjectURL(file)
image.src = url
} else if (window.FileReader) {
let reader = new FileReader()
reader.onload = function (e) {
let data = e.target.result
image.src = data
}
reader.readAsDataURL(file)
}
reader.readAsDataURL(file)
}
})
} catch (e) {
console.error(e)
})
} catch (e) {
console.error(e)
}
}
}
} else if (this.type === '1') {
// 语音
let amr = new BenzAMRRecorder()
try {
await amr.initWithBlob(file)
validate = amr.getDuration() <= 60
if (!validate) {
this.$message.error('上传文件时长不能超过 60秒!')
} else if (this.type === '1') {
// 语音
let amr = new BenzAMRRecorder()
try {
await amr.initWithBlob(file)
validate = amr.getDuration() <= 60
if (!validate) {
this.$message.error('上传文件时长不能超过 60秒!')
}
} catch (error) {
console.log(error)
this.$message.error('文件已损坏')
}
} else if (this.type === '2') {
// 视频
let result = await this.checkVideoCode(file)
if (result.mime.indexOf('video/mp4') === -1) {
this.$message.error('mp4 格式不正确, 请使用标准编码视频!')
this.loading = false
return Promise.reject()
}
} catch (error) {
console.log(error)
this.$message.error('文件已损坏')
} else if (this.type === '3') {
// 普通文件
}
} else if (this.type === '2') {
// 视频
let result = await this.checkVideoCode(file)
if (result.mime.indexOf('video/mp4') === -1) {
this.$message.error('mp4 格式不正确, 请使用标准编码视频!')
if (!validate) {
this.loading = false
return Promise.reject()
}
} else if (this.type === '3') {
// 普通文件
}
if (!validate) {
this.loading = false
}
// if (beforeUpload) {
// return beforeUpload(file)
// }
if (!this.multiple || this.limit == 1) {
this.file = file
} else {
Array.isArray(this.file) || (this.file = []) // 多选
this.file.push(file)
}
return validate || Promise.reject()
},
onError(err, file, fileList) {
this.loading = false
this.$message.error('上传文件失败')
},
checkVideoCode(file) {
return new Promise((resolve, reject) => {
const mp4boxFile = MP4Box.createFile()
const reader = new FileReader()
reader.readAsArrayBuffer(file)
reader.onload = function (e) {
const arrayBuffer = e.target.result
arrayBuffer.fileStart = 0
mp4boxFile.appendBuffer(arrayBuffer)
}
mp4boxFile.onReady = function (info) {
resolve(info)
// if (beforeUpload) {
// return beforeUpload(file)
// }
if (!this.multiple || this.limit == 1) {
this.file = file
} else {
Array.isArray(this.file) || (this.file = []) // 多选
this.file.push(file)
}
mp4boxFile.onError = function (info) {
reject(info)
}
})
},
showView(index) {
let imager = index !== undefined ? this.$refs.image[index] : this.$refs.image
imager.clickHandler()
this.$nextTick(() => {
// 为遮罩层添加关闭事件
let maskEl = imager.$children[0].$refs['el-image-viewer__wrapper'].firstChild
maskEl.addEventListener('click', () => {
event.stopPropagation()
imager.closeViewer()
return validate || Promise.reject()
},
onError(err, file, fileList) {
this.loading = false
this.$message.error('上传文件失败')
},
checkVideoCode(file) {
return new Promise((resolve, reject) => {
const mp4boxFile = MP4Box.createFile()
const reader = new FileReader()
reader.readAsArrayBuffer(file)
reader.onload = function (e) {
const arrayBuffer = e.target.result
arrayBuffer.fileStart = 0
mp4boxFile.appendBuffer(arrayBuffer)
}
mp4boxFile.onReady = function (info) {
resolve(info)
}
mp4boxFile.onError = function (info) {
reject(info)
}
})
})
// this.$refs.image.$refs.closeViewer();
},
},
}
},
showView(index) {
let imager = index !== undefined ? this.$refs.image[index] : this.$refs.image
imager.clickHandler()
this.$nextTick(() => {
// 为遮罩层添加关闭事件
let maskEl = imager.$children[0].$refs['el-image-viewer__wrapper'].firstChild
maskEl.addEventListener('click', () => {
event.stopPropagation()
imager.closeViewer()
})
})
// this.$refs.image.$refs.closeViewer();
}
}
}
</script>
<template>
......@@ -423,7 +428,8 @@ export default {
:src="item.url"
fit="contain"
:preview-src-list="fileListWatch.map((e) => e.url)"
alt="" />
alt=""
/>
<div class="action-mask">
<i class="el-icon-search mr5" @click="showView(index)"></i>
<!-- <span v-if="action.includes('download')" @click="download(item)">
......@@ -451,7 +457,8 @@ export default {
:limit="limit"
:on-error="onError"
:on-exceed="handleExceed"
:before-upload="handleBeforeUpload">
:before-upload="handleBeforeUpload"
>
<!--
element-loading-text="正在上传..."
:on-success="onSuccess"
......@@ -469,7 +476,7 @@ export default {
<circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
</svg>
</div>
<div class="cc" style="margin-top: 35px">
<div class="cc" style="margin-top: 35px;">
{{ speed + 'M/s' }}
</div>
</div>
......@@ -483,7 +490,8 @@ export default {
:src="fileUrlWatch"
class="upload-img"
:preview-src-list="[fileUrlWatch]"
fit="contain" />
fit="contain"
/>
<div class="action-mask" @click.self.stop>
<i class="el-icon-search" @click.prevent.stop="showView()"></i>
......@@ -507,10 +515,11 @@ export default {
playsinline="true"
:autoplay="false"
:key="fileUrlWatch"
preload="auto">
preload="auto"
>
<source :src="fileUrlWatch" type="video/mp4" />
</video>
<div class="action-mask" style="height: 50%" @click.self.stop>
<div class="action-mask" style="height: 50%;" @click.self.stop>
<i class="el-icon-edit"></i>
</div>
</div>
......@@ -519,7 +528,7 @@ export default {
<i class="el-icon-edit ml10"></i>
<!-- a链接用本地视频打不开,视频地址使用远程地址 -->
<a @click.stop :href="/\.mp4$/.test(fileNameWatch) ? fileUrl : fileUrlWatch" target="_blank">
<i class="el-icon-view ml10" style="vertical-align: middle"></i>
<i class="el-icon-view ml10" style="vertical-align: middle;"></i>
</a>
</div>
</template>
......@@ -535,76 +544,76 @@ export default {
</template>
<style lang="scss" scoped>
::v-deep.uploader {
display: inline-block;
vertical-align: middle;
.el-upload {
border-radius: 6px;
cursor: pointer;
::v-deep.uploader {
display: inline-block;
vertical-align: middle;
.el-upload {
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
}
.upload-action {
width: 178px;
height: 178px;
position: relative;
text-align: center;
}
.uploader-icon {
display: block;
font-size: 28px;
line-height: 178px;
text-align: center;
color: #8c939d;
border-radius: 6px;
border: 1px dashed #d9d9d9;
transition: all 0.3s;
&:hover {
border-color: $blue;
color: $blue;
}
}
.progress {
overflow: hidden;
}
}
.upload-action {
width: 178px;
height: 178px;
position: relative;
text-align: center;
}
.uploader-icon {
display: block;
font-size: 28px;
line-height: 178px;
text-align: center;
color: #8c939d;
border-radius: 6px;
border: 1px dashed #d9d9d9;
transition: all 0.3s;
&:hover {
border-color: $blue;
color: $blue;
.upload-img {
width: 178px;
height: 178px;
display: block;
}
.tip {
color: #aaa;
font-size: 12px;
}
.img-item {
position: relative;
display: inline-block;
vertical-align: middle;
margin: 0 10px 10px 0;
transition: all 0.3s;
}
.action-mask {
position: absolute;
display: flex;
justify-content: space-around;
align-items: center;
padding: 0 30px;
width: 100%;
height: 100%;
left: 0;
top: 0;
cursor: pointer;
text-align: center;
color: #fff;
opacity: 0;
font-size: 20px;
transition: opacity 0.3s;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
}
.action-mask:hover {
opacity: 1;
}
}
.progress {
overflow: hidden;
}
.upload-img {
width: 178px;
height: 178px;
display: block;
}
.tip {
color: #aaa;
font-size: 12px;
}
.img-item {
position: relative;
display: inline-block;
vertical-align: middle;
margin: 0 10px 10px 0;
transition: all 0.3s;
}
.action-mask {
position: absolute;
display: flex;
justify-content: space-around;
align-items: center;
padding: 0 30px;
width: 100%;
height: 100%;
left: 0;
top: 0;
cursor: pointer;
text-align: center;
color: #fff;
opacity: 0;
font-size: 20px;
transition: opacity 0.3s;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
}
.action-mask:hover {
opacity: 1;
}
</style>
......@@ -34,16 +34,23 @@
multiple: true,
total: 0,
list: [],
lastSyncTime: 0
lastSyncTime: 0,
fileList: []
}
},
computed: {},
created() {
this.$store.dispatch(
'app/setBusininessDesc',
`
<div>快捷创建商品图册,员工一键发送给客户,客户直接购买。</div>
`
)
this.getList()
},
methods: {
resetForm() {
this.query.name = 1
this.query.name = ''
this.getList(1)
},
getList(page) {
......@@ -62,12 +69,18 @@
})
},
edit(data) {
data
? api.getDetail(data.id).then((res) => {
this.form = res.data
this.form.attachments = this.form.attachments.split(',')
this.fileList = []
if (data) {
api.getDetail(data.id).then((res) => {
this.form = res.data
let arr = this.form.attachments.split(',')
arr.forEach((dd) => {
this.fileList.push({ url: dd })
})
: (this.form = JSON.parse(JSON.stringify(defaultForm)))
})
} else {
this.form = JSON.parse(JSON.stringify(defaultForm))
}
this.dialogVisible = true
},
sync() {
......@@ -92,7 +105,7 @@
this.$refs['form'].validate((valid) => {
let form = JSON.parse(JSON.stringify(this.form))
form.price = form.price.toFixed(2)
form.attachments = form.attachments.join(',')
form.attachments = this.fileList.map((dd) => dd.url).join(',')
this.submitLoading = true
api[form.id ? 'update' : 'add'](form, form.id)
.then(() => {
......@@ -136,7 +149,7 @@
}
</script>
<template>
<div class="">
<div class="g-card g-pad20">
<el-form ref="queryForm" :inline="true" :model="query" label-width="110px" class="top-search">
<el-form-item label="商品名称或描述" prop="name">
<el-input v-model="query.name" placeholder="请输入"></el-input>
......@@ -157,7 +170,7 @@
<div slot-scope="{ row }">
<div style="display: flex;">
<el-image
style="width: 50px; height: 50px; margin-right: 3px; flex-shrink: 0;"
style="width: 50px; height: 50px; margin-right: 5px; flex-shrink: 0;"
:src="row.picture"
></el-image>
<span class="limit_span">{{ row.describe }}</span>
......@@ -214,7 +227,7 @@
></el-input>
</el-form-item>
<el-form-item label="商品详情">
<upload :fileUrls.sync="form.attachments" :limit="8" type="0">
<upload :fileList.sync="fileList" :multiple="true" :limit="8" type="0">
<div slot="tip" class="tip">最多添加八张详情</div>
</upload>
</el-form-item>
......@@ -230,12 +243,7 @@
></el-image>
<div class="price">¥{{ form.price }}</div>
<div class="content">{{ form.describe }}</div>
<el-image
v-for="(item, index) in form.attachments"
class="commodity-img"
:src="item"
:key="index"
></el-image>
<el-image v-for="(item, index) in fileList" class="commodity-img" :src="item.url" :key="index"></el-image>
</div>
</PhoneTemplate>
</el-col>
......
<template>
<div class="">
<div class="g-card g-pad20">
<el-form :inline="true" label-width="110px" class="top-search">
<el-form-item label="商品名称或描述" prop="productName">
<el-input v-model="query.productName" placeholder="请输入商品名称或描述"></el-input>
......@@ -74,6 +74,24 @@
{{ { 1: '@微信', 2: '@企业微信' }[row.externalType] }}
</span>
</div>
<div v-if="row.address && row.phone" class="ml10" style="align-self: baseline;">
<el-popover trigger="hover" width="400">
<el-form ref="form" label-width="100px">
<el-form-item label="联系人:">
{{ row.contact }}
</el-form-item>
<el-form-item label="联系地址:">
{{ row.address }}
</el-form-item>
<el-form-item label="联系电话:">
{{ row.phone }}
</el-form-item>
</el-form>
<div style="display: inline;" slot="reference">
<i class="el-icon-warning"></i>
</div>
</el-popover>
</div>
</div>
</template>
</el-table-column>
......@@ -81,8 +99,28 @@
<el-table-column label="付款金额(元)" align="center" prop="totalFee" />
<el-table-column label="收款员工" align="center" prop="weUserName" />
<el-table-column label="收款商户" align="center" prop="mchName"> </el-table-column>
<el-table-column label="交易状态" align="center" prop="orderStateStr" />
<el-table-column label="退款状态" align="center" prop="refundStateStr" />
<el-table-column label="交易状态" align="center" prop="orderStateStr">
<template slot-scope="{ row }">
<a
v-if="row.orderStateStr"
style="color: #0079de; border-bottom: 1px solid #0079de;"
@click="tradingStateFn(row.orderNo)"
>{{ row.orderStateStr }}</a
>
<span v-else> - </span>
</template>
</el-table-column>
<el-table-column label="退款状态" align="center" prop="refundStateStr">
<template slot-scope="{ row }">
<a
v-if="row.refundStateStr"
style="color: #0079de; border-bottom: 1px solid #0079de;"
@click="refundStateFn(row.refundNo)"
>{{ row.refundStateStr }}</a
>
<span v-else> - </span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
......@@ -97,13 +135,15 @@
<el-col :span="12">
<el-form ref="form" label-width="100px">
<el-form-item label="交易时间:">
<!-- {{}} -->
{{ orderState.payTime }}
</el-form-item>
<el-form-item label="交易单号:">
<!-- {{}} -->
{{ orderState.orderNo }}
<el-button type="text" plain size="mini" @click="handleCopy(orderState.orderNo)">复制</el-button>
</el-form-item>
<el-form-item label="商户单号:">
<!-- {{}} -->
{{ orderState.mchNo }}
<el-button type="text" plain size="mini" @click="handleCopy(orderState.mchNo)">复制</el-button>
</el-form-item>
</el-form>
</el-col>
......@@ -117,19 +157,20 @@
<el-col :span="12">
<el-form ref="form" label-width="100px">
<el-form-item label="退款发起时间:">
<!-- {{}} -->
{{ refundState.refundTime }}
</el-form-item>
<el-form-item label="退款发起人:">
<!-- {{}} -->
{{ refundState.refundUserName }}
</el-form-item>
<el-form-item label="退款备注:">
<!-- {{}} -->
{{ refundState.remark }}
</el-form-item>
<el-form-item label="退款金额(元)">
<!-- {{}} -->
{{ refundState.refundFee }}
</el-form-item>
<el-form-item label="退款单号:">
<!-- {{}} -->
{{ refundState.refundNo }}
<el-button type="text" plain size="mini" @click="handleCopy(orderState.refundNo)">复制</el-button>
</el-form-item>
</el-form>
</el-col>
......@@ -149,6 +190,8 @@
<script>
import * as api from '@/api/commodityCenter/commodityManage'
import { dateFormat } from '@/utils/index'
export default {
components: {},
props: {},
......@@ -176,19 +219,53 @@
dialogVisibleSelect: false,
dateRange: [],
dialogStateVisible: false,
dialogVisible: false
dialogVisible: false,
orderState: {
payTime: '',
orderNo: '',
mchNo: ''
},
refundState: {
refundTime: '',
refundNo: '',
refundUserName: '',
refundFee: '',
remark: ''
}
}
},
computed: {},
created() {
this.$store.dispatch(
'app/setBusininessDesc',
`
<div>查看商品所有订单及明细记录。</div>
`
)
this.getList()
},
methods: {
handleCopy(text) {
const input = document.createElement('input')
input.style.cssText = 'opacity: 0;'
input.type = 'text'
input.value = text // 修改文本框的内容
document.body.appendChild(input)
input.select() // 选中文本
document.execCommand('copy') // 执行浏览器复制命令
this.$message({ message: '复制成功', type: 'success' })
},
tradingStateFn(id) {
api.getOrderState(id)
api.getOrderState(id).then((res) => {
this.orderState = res.data
this.dialogVisible = true
})
},
refundStateFn(orderNo) {
api.getRefundOrderState(orderNo)
refundStateFn(id) {
api.getRefundOrderState(id).then((res) => {
this.refundState = res.data
this.dialogStateVisible = true
})
},
resetForm() {
this.query = {
......@@ -227,10 +304,31 @@
background: 'rgba(0, 0, 0, 0.7)'
})
api
.exportOrder()
.exportOrder({
productName: this.query.productName,
externalName: this.query.externalName,
weUserId: this.query.weUserId,
orderState: this.query.orderState,
refundState: this.query.refundState,
beginTime: this.query.beginTime,
endTime: this.query.endTime
})
.then((res) => {
if (!res) return
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
if (window.navigator.msSaveOrOpenBlob) {
//兼容IE10
navigator.msSaveBlob(blob, '订单')
} else {
const href = URL.createObjectURL(blob)
const a = document.createElement('a')
a.style.display = 'none'
a.href = href
a.download = dateFormat(new Date(), 'yyyy-MM-dd') + '_订单.xlsx'
a.click() //触发下载
URL.revokeObjectURL(a.href) //释放URL对象
}
loading.close()
console.log(res)
})
.catch(() => {
loading.close()
......
......@@ -14,19 +14,69 @@
</div>
</div>
</div>
<div class="g-card g-pad20" style="margin-top: 20px;">
<div class="title">
访问场景top5
</div>
<div class="data-content" style="margin-top: 20px;">
<div class="chart-content">
<search-title @search="getTop5Fn"></search-title>
<div class="column">
<div class="column-item">
<chart-bar style="height: 300px;" :xData="bar1" :series="value1" :legend="barLegend1"></chart-bar>
<div class="column">
<div class="column-item" style="margin-right: 20px;">
<div class="g-card g-pad20" style="margin-top: 20px; height: 450px;">
<div class="title">
商品订单top5
</div>
<div class="data-content" style="margin-top: 20px;">
<div class="chart-content">
<search-title @search="getGoodsTop5Fn"></search-title>
<el-table v-loading="goodsTableLoading" :data="goodsTableList" style="width: 100%;">
<el-table-column label="商品" align="center" width="200" prop="xtime" show-overflow-tooltip>
<div slot-scope="{ row }">
<div style="display: flex;">
<el-image
style="width: 50px; height: 50px; margin-right: 5px; flex-shrink: 0;"
:src="row.picture"
></el-image>
<span class="limit_span">{{ row.productDesc }}</span>
</div>
</div>
</el-table-column>
<el-table-column label="订单总数" align="center" prop="orderNum" show-overflow-tooltip />
<el-table-column
label="订单总额(元)"
align="center"
prop="totalFee"
show-overflow-tooltip
></el-table-column>
<el-table-column
label="净收入(元)"
align="center"
prop="netIncome"
show-overflow-tooltip
></el-table-column>
</el-table>
</div>
<div class="column-item">
<chart-bar style="height: 300px;" :xData="bar2" :series="value2" :legend="barLegend2"></chart-bar>
</div>
</div>
</div>
<div class="column-item">
<div class="g-card g-pad20" style="margin-top: 20px; height: 450px;">
<div class="title">
员工订单top5
</div>
<div class="data-content" style="margin-top: 20px;">
<div class="chart-content">
<search-title @search="getMemebersTop5Fn"></search-title>
<el-table v-loading="memberTableLoading" :data="memberTableList" style="width: 100%;">
<el-table-column
label="员工"
align="center"
min-width="100"
prop="weUserName"
show-overflow-tooltip
></el-table-column>
<el-table-column label="订单总数" align="center" prop="orderNum" show-overflow-tooltip />
<el-table-column
label="订单总额(元)"
align="center"
prop="totalFee"
show-overflow-tooltip
></el-table-column>
</el-table>
</div>
</div>
</div>
......@@ -43,46 +93,26 @@
</div>
<div class="table-content">
<el-table v-loading="loading" :data="tableList" style="width: 100%;">
<el-table-column label="日期" align="center" min-width="100" prop="xtime" show-overflow-tooltip />
<el-table-column
label="访问客户总数"
align="center"
min-width="100"
prop="visitTotalCnt"
show-overflow-tooltip
/>
<el-table-column
label="咨询客户总数"
align="center"
prop="consultTotalCnt"
min-width="100"
show-overflow-tooltip
></el-table-column>
<el-table-column
label="接待客户总数"
align="center"
prop="receptionTotalCnt"
min-width="100"
show-overflow-tooltip
></el-table-column>
<el-table-column label="日期" align="center" min-width="100" prop="dateStr" show-overflow-tooltip />
<el-table-column label="订单总数" align="center" min-width="100" prop="orderNum" show-overflow-tooltip />
<el-table-column
label="今日新增访问客户"
label="订单总额(元)"
align="center"
prop="tdVisitCnt"
prop="totalFee"
min-width="100"
show-overflow-tooltip
></el-table-column>
<el-table-column
label="今日新增咨询客户"
label="退款总额(元)"
align="center"
prop="tdConsultCnt"
prop="refundFee"
min-width="100"
show-overflow-tooltip
></el-table-column>
<el-table-column
label="今日新增接待客户"
label="净收入(元)"
align="center"
prop="tdReceptionCnt"
prop="netIncome"
min-width="100"
show-overflow-tooltip
></el-table-column>
......@@ -106,7 +136,8 @@
import {
getTableExport,
getTableTotal,
getBarTop5Total,
getGoodsTop5,
getMembersTop5,
getLineChartTotal,
getGoodsTotal
} from '@/api/commodityCenter/commodityManage'
......@@ -123,8 +154,6 @@
data() {
return {
exportLoading: false,
barLegend1: ['访问客户总数'],
barLegend2: ['咨询客户总数'],
legend: ['订单总额(元)', '退款总额(元)', '净收入(元)'],
xdata: [],
series: [],
......@@ -186,10 +215,10 @@
},
tableList: [],
loading: false,
bar1: [],
bar2: [],
value1: [],
value2: [],
goodsTableLoading: false,
goodsTableList: [],
memberTableLoading: false,
memberTableList: [],
tableSearch: {}
}
},
......@@ -202,20 +231,20 @@
})
.then(() => {
this.exportLoading = true
return getTableExport(Object.assign({}, this.query, this.tableSearch))
return getTableExport(Object.assign({}, this.tableSearch))
})
.then((res) => {
if (!res) return
const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) // 构造一个blob对象来处理数据,并设置文件类型
if (window.navigator.msSaveOrOpenBlob) {
//兼容IE10
navigator.msSaveBlob(blob, '场景分析')
navigator.msSaveBlob(blob, '商品分析')
} else {
const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象
const a = document.createElement('a') //创建a标签
a.style.display = 'none'
a.href = href // 指定下载链接
a.download = dateFormat(new Date(), 'yyyy-MM-dd') + '_场景分析.xlsx' //指定下载文件名
a.download = dateFormat(new Date(), 'yyyy-MM-dd') + '_商品分析.xlsx' //指定下载文件名
a.click() //触发下载
URL.revokeObjectURL(a.href) //释放URL对象
}
......@@ -246,6 +275,7 @@
getLineData(data) {
this.$forceUpdate()
getLineChartTotal({
type: 'customization',
startDate: data.beginTime,
endDate: data.endTime
}).then((res) => {
......@@ -254,41 +284,33 @@
let arr1 = []
let arr2 = []
let arr3 = []
if (res.data && res.data.length) {
res.data.forEach((dd) => {
this.xdata.push(dd.xtime)
arr1.push(dd.visitTotalCnt)
arr2.push(dd.consultTotalCnt)
arr3.push(dd.receptionTotalCnt)
})
this.series = [arr1, arr2, arr3]
}
this.xdata = res.data.xAxis.data
arr1 = res.data.series[0].data
arr2 = res.data.series[1].data
arr3 = res.data.series[2].data
this.series = [arr1, arr2, arr3]
})
},
getTop5Fn(data) {
getBarTop5Total(data).then((res) => {
if (res.data.consult && res.data.consult.length) {
this.bar1 = []
this.value1 = []
res.data.consult.forEach((dd) => {
this.bar1.push(dd.sceneName)
this.value1.push(dd.total)
})
} else {
this.bar1 = []
this.value1 = []
}
if (res.data.visit && res.data.visit.length) {
this.bar2 = []
this.value2 = []
res.data.visit.forEach((dd) => {
this.bar2.push(dd.sceneName)
this.value2.push(dd.total)
})
} else {
this.bar2 = []
this.value2 = []
}
getGoodsTop5Fn(data) {
this.goodsTableLoading = true
getGoodsTop5({
type: 'customization',
startDate: data.beginTime,
endDate: data.endTime
}).then((res) => {
this.goodsTableList = res.data
this.goodsTableLoading = false
})
},
getMemebersTop5Fn(data) {
this.memberTableLoading = true
getMembersTop5({
type: 'customization',
startDate: data.beginTime,
endDate: data.endTime
}).then((res) => {
this.memberTableList = res.data
this.memberTableLoading = false
})
},
getTableChangeSize() {
......@@ -301,8 +323,13 @@
},
getTableFn(data) {
this.loading = true
this.tableSearch = data
getTableTotal(Object.assign({}, this.query, data)).then((res) => {
let obj = {
type: 'customization',
startDate: data.beginTime,
endDate: data.endTime
}
this.tableSearch = obj
getTableTotal(Object.assign({}, this.query, obj)).then((res) => {
this.tableList = res.rows
this.total = Number(res.total)
this.loading = false
......@@ -310,6 +337,12 @@
}
},
created() {
this.$store.dispatch(
'app/setBusininessDesc',
`
<div>全部商品及订单数据总览与数据分析。</div>
`
)
this.getSceneTotalFn()
}
}
......@@ -326,6 +359,12 @@
color: #333;
font-weight: 600;
}
.column {
display: flex;
.column-item {
flex: 1;
}
}
.data-content {
margin-top: 10px;
.chart-content {
......@@ -333,12 +372,6 @@
.my_button {
float: right;
}
.column {
display: flex;
.column-item {
flex: 1;
}
}
}
.search-content {
display: flex;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!