Commit 98ad500c by xinla

--no commit message

1 parent 80460fc8
import request from '@/utils/request'
const service = window.CONFIG.services.system + '/product'
/**
* 商品列表
* @param {*} params
* {
* beginTime,string,开始时间
endTime,string,结束时间
name,string,商品描述
price,string,商品价格
* }
*/
export function getList(params) {
return request({
url: service + '/page/list',
params,
})
}
/**
* 商品列表同步
* @param {*} params
*
*/
export function sync() {
return request({
url: service + '/page/list/sync',
})
}
/**
* 商品详情
* @param {*} params
*
*/
export function getDetail(id) {
return request({
url: service + '/get/' + id,
})
}
/**
* 新增商品
* @param {Object} data
{
attachments: [
String appID; 小程序appid(可以在微信公众平台上查询),必须是关联到企业的小程序应用
String content *;
String description *;
String linkURL *;
String mediaID *;
String msgType *; 消息类型 文本:text, 图片:image, 语音:voice, 视频:video, 文件:file, 文本卡片:textcard, 图文:news, 图文消息:link,小程序:miniprogram
String picURL *; 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150。(文本卡片、图文 必传)
String title *;
] ,
String describe;
String picture;
String price;
}
*/
export function add(data) {
return request({
url: service + '/add',
method: 'post',
data,
})
}
/**
* 修改
* @param {*} data 同新增
*/
export function update(id, data) {
return request({
url: service + '/update/' + id,
method: 'put',
data,
})
}
/**
* 删除
* @param {*} ids
*/
export function remove(ids) {
return request({
url: service + '/' + ids,
method: 'DELETE',
})
}
<template>
<div class="preview">
<div class="title">{{ name }}</div>
<div class="content">
<slot />
</div>
</div>
</template>
<script>
export default {
components: {},
props: {
name: {
type: String,
default: '小微',
},
},
data() {
return {}
},
computed: {},
created() {},
mounted() {},
methods: {},
}
</script>
<style lang="scss" scoped>
.preview {
margin: 0 auto;
position: relative;
width: 300px;
height: 640px;
background: url(../assets/drainageCode/preview-bg.png);
background-repeat: no-repeat;
background-size: 100% 100%;
.title {
position: absolute;
top: 37px;
left: 50%;
transform: translateX(-50%);
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
}
.content {
position: absolute;
height: 545px;
width: 280px;
overflow-y: auto;
top: 70px;
left: 50%;
transform: translateX(-50%);
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
padding: 20px;
}
}
</style>
<script>
// import * as customerApi from '@/api/operateCenter/customerAnalysis'
// import * as groupApi from '@/api/operateCenter/groupAnalysis'
// import * as conversationApi from '@/api/operateCenter/conversationAnalysis'
import { getList as getGroupList } from '@/api/customer/group'
export default {
name: '',
components: {
ChartLine: () => import('@/components/ChartLine'),
ChartBar: () => import('@/components/ChartBar'),
},
props: {
// 图表类型
type: {
type: String, // lineChart, barChart, table
default: '',
},
// 图表图例; 单个图例可传字符串,多个图例传数组
legend: {
type: [Array, String],
default: null,
},
// 接口请求
request: {
type: Function,
default: () => {},
},
// 是否显示时间查询
isTimeQuery: {
type: Boolean,
default: false,
},
// 是否显示选择群主
isGroupOwnerQuery: {
type: Boolean,
default: false,
},
// 是否显示选择群聊
isGroupQuery: {
type: Boolean,
default: false,
},
// 是否显示选择部门或员工
isDepartOrStaff: {
type: Boolean,
default: false,
},
// 导出接口请求
requestExport: {
type: Function,
default: null,
},
// 自定义图表配置项,使用loadsh.merge(origin, option)和原有的配置进行覆盖合并
// loadsh.merge: https://www.html.cn/doc/lodash/#_mergeobject-sources
option: {
type: Object,
default: null,
},
// 导出接口请求
dealDataFun: {
type: Function,
default: null,
},
},
data() {
return {
loading: false,
timeRange: 7,
total: 0,
// 表格数据
data: [],
xData: [],
// 日期范围
dateRange: [],
// 查询参数
query: {
pageNum: undefined,
pageSize: undefined,
deptIds: [],
userIds: [],
chatIds: [],
ownerIds: [],
beginTime: undefined,
endTime: undefined,
},
// 群聊
groupChats: [],
tableProps: [],
userArray: [], // 选择人员
dialogVisible: false,
dialogType: '',
}
},
computed: {},
watch: {},
created() {
this.setTime(7)
},
mounted() {},
methods: {
getList(page) {
if (this.type == 'table') {
this.query.pageSize || (this.query.pageSize = 10)
}
if (this.dateRange) {
this.query.beginTime = this.dateRange[0]
this.query.endTime = this.dateRange[1]
} else {
this.query.beginTime = ''
this.query.endTime = ''
}
if (this.dialogType === '_users') {
if (Array.isArray(this.userArray)) {
this.query.deptIds = this.userArray
.filter((e) => e.isParty)
.map((e) => e.id)
.join(',')
this.query.userIds = this.userArray
.filter((e) => !e.isParty)
.map((e) => e.userId)
.join(',')
} else {
this.query.deptIds = this.query.userIds = ''
}
} else if (this.dialogType === '_groupOwners') {
if (Array.isArray(this.userArray)) {
this.query.ownerIds = this.userArray
.filter((e) => !e.isParty)
.map((e) => e.userId)
.join(',')
} else {
this.query.ownerIds = ''
}
}
this.loading = true
page && (this.query.pageNum = page)
this.request(this.query)
.then(({ rows, total, data }) => {
this.series = []
data = data || rows
if (!data || !data.length) {
return
}
if (this.type == 'table') {
// 表格
this.data = data
this.total = Number(total)
} else {
this.dealDataFun && this.dealDataFun(data, this.data, this.xData)
}
})
.catch((e) => {
console.error(e)
})
.finally(() => {
this.loading = false
})
},
getGroupList(params) {
getGroupList(params)
.then(({ rows }) => {
this.groupChats = rows
})
.catch(() => {})
},
getTime(datePar) {
const d = datePar ? new Date(datePar) : new Date()
d.setMinutes(d.getMinutes() - d.getTimezoneOffset())
return d.toJSON().substr(0, 10)
},
setTime(days) {
this.timeRange = days
if (days) {
let date = new Date()
date.setDate(date.getDate() - days)
this.dateRange = [this.getTime(date), this.getTime()]
this.getList()
} else {
this.dateRange = null
}
},
showDialog(type) {
this.dialogType = type
this.dialogVisible = true
},
getSelectUser(data) {
this.userArray = data
this.query[this.dialogType] = data.map((e) => e.userId).join(',')
if (['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(this.type)) {
this.query.chatIds = ''
this.getGroupList({
userIds: this.query[this.dialogType],
})
}
this.getList()
},
exprotTable() {
this.$confirm('是否确认导出吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.loading = true
let query = Object.assign({}, this.query, { pageNum: undefined, pageSize: undefined })
return this.requestExport(query)
})
.then((res) => {
this.download(res.data)
})
.catch((error) => {
console.error(error)
})
.finally(() => {
this.loading = false
})
},
},
}
</script>
<template>
<div>
<div class="operation">
<template v-if="isTimeQuery">
<el-button-group>
<el-button type="primary" :plain="timeRange != 7" @click="setTime(7)">近一周</el-button>
<el-button type="primary" :plain="timeRange != 30" @click="setTime(30)"
>近一月
</el-button>
<el-button type="primary" :plain="!!timeRange" @click="setTime()">自定义 </el-button>
</el-button-group>
<el-date-picker
v-if="!timeRange"
v-model="dateRange"
class="ml20"
style="width: 260px"
value-format="yyyy-MM-dd"
type="daterange"
:clearable="false"
:picker-options="pickerOptions"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="getList(1)"
></el-date-picker>
</template>
<el-input
v-if="isGroupOwnerQuery"
style="width: 180px; margin-left: 20px"
:value="userArray.map((e) => e.name) + ''"
readonly
@focus="showDialog('_groupOwners')"
placeholder="请选择群主"
>
</el-input>
<el-select
style="margin-left: 20px"
v-if="isGroupQuery"
v-model="query.chatIds"
placeholder="请选择群聊"
clearable
@change="getList()"
>
<el-option
v-for="item in groupChats"
:key="item.chatId"
:label="item.groupName"
:value="item.chatId"
>
</el-option>
</el-select>
<el-input
v-if="isDepartOrStaff"
style="width: 180px; margin-left: 20px"
:value="userArray.map((e) => e.name) + ''"
readonly
@focus="showDialog('_users')"
placeholder="请选择部门或员工"
/>
<el-button v-if="requestExport" class="fr" type="primary" @click="exprotTable"
>导出 Excel</el-button
>
</div>
<div v-loading="loading">
<ChartLine
v-if="type == 'lineChart'"
:xData="xData"
:legend="legend"
:series="data"
></ChartLine>
<template v-else-if="type == 'table'">
<el-table :data="data" style="width: 100%">
<el-table-column
v-for="(item, index) in tableProps[type]"
:key="index"
:prop="item.prop"
:label="item.label"
align="center"
>
</el-table-column>
</el-table>
<pagination
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
@pagination="getList()"
/>
</template>
<ChartBar v-else-if="'barChart'.includes(type)" :xData="xData" :series="data"></ChartBar>
<ChartLine
v-else-if="'rowEchart'.includes('vChart')"
:xData="xData"
:legend="legend"
:series="data"
:option="option"
></ChartLine>
</div>
<SelectWeUser
:visible.sync="dialogVisible"
title="组织架构"
:defaultValues="userArray"
@success="getSelectUser"
:isOnlyLeaf="dialogType === '_groupOwners'"
></SelectWeUser>
</div>
</template>
<style lang="scss" scoped></style>
...@@ -33,6 +33,7 @@ Vue.component('SelectUser', () => import('@/components/SelectUser')) ...@@ -33,6 +33,7 @@ Vue.component('SelectUser', () => import('@/components/SelectUser'))
Vue.component('SelectWeUser', () => import('@/components/SelectWeUser')) Vue.component('SelectWeUser', () => import('@/components/SelectWeUser'))
Vue.component('SelectStaffForm', () => import('@/components/SelectStaffForm')) Vue.component('SelectStaffForm', () => import('@/components/SelectStaffForm'))
Vue.component('CoRemoteSelect', () => import('@/components/CoRemoteSelect')) Vue.component('CoRemoteSelect', () => import('@/components/CoRemoteSelect'))
Vue.component('PhoneTemplate', () => import('@/components/PhoneTemplate'))
// 全局方法挂载 // 全局方法挂载
import ClipboardJS from 'clipboard' import ClipboardJS from 'clipboard'
// class ClipboardJS extends clipboard { // class ClipboardJS extends clipboard {
......
<script>
import RemoteDataView from '@/components/RemoteDataView'
import CardGroupIndex from '@/components/CardGroupIndex'
import * as api from '@/api/commodityCenter/commodityManage'
export default {
name: '',
components: { RemoteDataView, CardGroupIndex },
data() {
return {
cardData: [],
active: 0,
api,
}
},
computed: {},
watch: {},
created() {
this.getList()
},
mounted() {},
methods: {
getList() {
this.loading = true
api
.getDetail()
.then(({ data }) => {
this.cardData = [
{
title: '订单总数',
value: data.totalCnt,
},
{
title: '订单总额(元)',
value: data.tdCnt,
},
{
title: '退款总额(元)',
value: data.tdLostCnt,
},
{
title: '净收入(元)',
value: data.tdNetCnt,
},
{
title: '昨日发送申请',
value: data.ydNewApplyCnt,
},
]
})
.catch((e) => {
console.log(e)
})
.finally(() => {
this.loading = false
})
},
dealDataFun(res, series, xData) {
xData = res.map((e) => e.xtime)
series.push(res.map((e) => e.addCnt))
series.push(res.map((e) => e.lostCnt))
series.push(res.map((e) => e.lostCnt))
},
},
}
</script>
<template>
<div>
<CardGroupIndex :data="cardData"></CardGroupIndex>
<div class="g-card g-pad20" style="margin-top: 0">
<div class="title">数据趋势</div>
<RemoteDataView
type="lineChart"
:legend="['订单总额(', '退款总额', '净收入']"
:request="api.getTotalCnt"
:dealDataFun="dealDataFun"
></RemoteDataView>
</div>
<div class="g-card g-pad20" style="margin-top: 20px">
<div class="title">员工订单Top5</div>
<RemoteDataView type="table" :request="api.getRankCnt"></RemoteDataView>
</div>
</div>
</template>
<style lang="scss" scoped>
.title {
font-size: 16px;
color: #333;
font-weight: 600;
margin-bottom: 20px;
}
</style>
<script>
import * as api from '@/api/commodityCenter/commodityManage'
export default {
components: {},
props: {},
data() {
return {
query: {
pageNum: 1,
pageSize: 10,
name: '',
},
// 遮罩层
loading: false,
dialogVisible: false,
// 表单参数
form: {
groupName: '',
weTags: [],
},
// 添加标签输入框
newInput: '',
// 添加标签显隐
newInputVisible: false,
// 表单验证规则
rules: Object.freeze({
picture: [{ required: true, message: '必填项', trigger: 'change' }],
groupName: [{ required: true, message: '必填项', trigger: 'blur' }],
groupName: [{ required: true, message: '必填项', trigger: 'blur' }],
}),
// 选中数组
ids: [],
// 非多个禁用
multiple: true,
// 总条数
total: 0,
// 表格数据
list: [],
lastSyncTime: 0,
}
},
computed: {},
created() {
// this.query.groupTagType = this.type
this.getList()
},
methods: {
getList(page) {
page && (this.query.pageNum = page)
this.loading = true
api
.getList(this.query)
.then(({ rows, total, lastSyncTime }) => {
this.list = rows
this.total = +total
this.lastSyncTime = lastSyncTime
this.loading = false
})
.catch(() => {
this.loading = false
})
},
edit(data, type) {
this.form = JSON.parse(
JSON.stringify(Object.assign({ groupTagType: this.type, weTags: [] }, data || {}))
)
this.dialogVisible = true
},
syncTag() {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
})
api
.sync()
.then(() => {
loading.close()
this.msgSuccess('后台开始同步数据,请稍后关注进度')
this.getList()
})
.catch(() => {
loading.close()
})
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.groupId)
this.multiple = !selection.length
},
/** 删除按钮操作 */
remove(id) {
const operIds = id || this.ids + ''
this.$confirm('是否确认删除吗?', '警告', {
type: 'warning',
})
.then(function () {
return api.remove(operIds)
})
.then(() => {
this.getList()
this.msgSuccess('删除成功')
})
},
},
}
</script>
<template>
<div class="">
<el-form ref="queryForm" :inline="true" :model="query" label-width="100px" class="top-search">
<el-form-item label="商品名称" prop="name">
<el-input v-model="query.name" placeholder="请输入"></el-input>
</el-form-item>
<el-form-item label=" ">
<!-- v-hasPermi="['customerManage:customer:query']" -->
<el-button type="primary" @click="getList(1)">查询</el-button>
<el-button type="success" @click="resetForm()">重置</el-button>
</el-form-item>
</el-form>
<div class="mid-action">
<!-- v-hasPermi="['customerManage:tag:add']" -->
<el-button type="primary" class="mr10" @click="edit()">新建商品</el-button>
<!-- v-hasPermi="['customerManage:tag:remove']" -->
<el-button :disabled="!ids.length" type="danger" @click="remove()">批量删除</el-button>
</div>
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="商品" align="center" prop="groupName">
<div slot-scope="{ row }" class="toe">
<el-image style="width: 50px; height: 50px" :src="row.picture"></el-image>
<span>{{ row.describe }}}</span>
</div>
</el-table-column>
<el-table-column label="单价(元)" align="center" prop="price" />
<el-table-column label="订单总数" align="center" prop="groupName" />
<el-table-column label="订单总额(元)" align="center" prop="groupName" />
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="最近操作时间" align="center" prop="operTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.operTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="{ row, index }">
<!-- v-hasPermi="['customerManage:tag:edit']" -->
<el-button type="text" @click="goRoute(row, index)">详情</el-button>
<el-button type="text" @click="edit(row, index)">编辑</el-button>
<el-button @click="remove(row.groupId)" type="text">删除</el-button>
<!-- v-hasPermi="['customerManage:tag:remove']" -->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
@pagination="getList()"
/>
<!-- 弹窗 -->
<el-dialog
:title="form.id ? '修改' : '新建'"
:visible.sync="dialogVisible"
width="600px"
:close-on-click-modal="false"
>
<el-row>
<el-col :span="12">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="商品封面" prop="picture">
<upload :fileUrl.sync="form.picture" type="0">
<div slot="tip">支持jpg/jpeg/png格式,图片大小不超过20M</div>
</upload>
</el-form-item>
<el-form-item label="商品单价(元)" prop="price">
<el-input-number
v-model="form.price"
:precision="2"
:step="0.1"
:min="0"
:max="50000"
></el-input-number>
<div class="tip">精确到小数点后两位,不超过5万元</div>
</el-form-item>
<el-form-item label="商品描述" prop="describe">
<el-input
v-model="form.describe"
type="textarea"
:maxlength="300"
show-word-limit
:autosize="{ minRows: 2, maxRows: 50 }"
placeholder="请输入"
></el-input>
</el-form-item>
<el-form-item label="商品详情">
<upload :fileUrl.sync="form.attachments" type="0">
<div slot="tip">
最多添加八张详情,支持JPG,PNG格式,图片大小不超过2M,建议上传宽高1:1的图片
</div>
</upload>
</el-form-item>
<div slot="footer" class="dialog-footer">
<el-button type="primary" v-loading="submitLoading" @click="submit">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</div>
</el-form>
</el-col>
<el-col :span="12">
<PhoneTemplate>
<el-image style="width: 100%; height: 50px" :src="form.picture"></el-image>
<div class="price">¥{{ form.picture }}</div>
<div class="content">{{ form.describe }}</div>
<el-image
v-for="(item, index) of form.attachments"
style="width: 100%; height: 50px"
:src="item.picURL"
:key="index"
></el-image>
</PhoneTemplate>
</el-col>
</el-row>
</el-dialog>
</div>
</template>
<style lang="scss" scoped></style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!