Commit 16046c50 by 李伟康

提交需求

1 parent daa38f04
......@@ -1956,7 +1956,7 @@
}
},
"vue-loader-v16": {
"version": "npm:vue-loader@16.8.3",
"version": "npm:vue-loader-v16@16.8.3",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz",
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
"dev": true,
......@@ -8887,6 +8887,11 @@
"integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==",
"dev": true
},
"number-precision": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/number-precision/-/number-precision-1.6.0.tgz",
"integrity": "sha512-05OLPgbgmnixJw+VvEh18yNPUo3iyp4BEWJcrLu4X9W05KmMifN7Mu5exYvQXqxxeNWhvIF+j3Rij+HmddM/hQ=="
},
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmmirror.com/oauth-sign/-/oauth-sign-0.9.0.tgz",
......
......@@ -14,6 +14,7 @@
"glsx-common": "^2.1.0",
"glsx-components": "^1.5.7",
"lodash": "^4.17.21",
"number-precision": "^1.6.0",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
......
......@@ -14,31 +14,31 @@ const getCategoryListApi = params => {
}
// 分页查询选品库商品
const getGoodsListApi = params => {
params.method = `${defaultPath}goods.list`
return http({
url,
data: params,
sign: true
})
params.method = `${defaultPath}goods.list`
return http({
url,
data: params,
sign: true
})
}
// 平台商品批量入库
const addWarehouseApi = params => {
params.method = `${defaultPath}goods.batch.add`
return http({
url,
data: params,
sign: true
})
params.method = `${defaultPath}goods.batch.add`
return http({
url,
data: params,
sign: true
})
}
// 分页查询仓库/销售中商品
const getListApi = params => {
params.method = `${defaultPath}goods.stockroom.page`
return http({
url,
data: params,
sign: true
})
params.method = `${defaultPath}goods.stockroom.page`
return http({
url,
data: params,
sign: true
})
}
// 平台商品批量移出仓库
const batchRemoveApi = params => {
......@@ -124,19 +124,60 @@ const getSaleOrderDetail = params => {
sign: true
})
}
/**
* 获取油劵列表
*/
const getOilCouponList = params => {
params.method = 'scrm.api.shopmall.goods.oil.coupon.list'
return http({
url,
data: params
})
}
/**
* 更新油劵信息(图片/销售价/上下架开关)
*/
const updateOilCoupon = params => {
params.method = 'scrm.api.shopmall.goods.oil.coupon.update'
return http({
url,
data: params
})
}
/**
* 油券订单列表
*/
const getOilCouponOrderList = params => {
params.method = 'scrm.api.shopmall.goods.oil.coupon.order.list'
return http({
url,
data: params
})
}
/**导出油券订单 */
const exportOilCouponOrderList = params => {
params.method = 'scrm.api.shopmall.goods.oil.coupon.order.list.export'
return http({
url,
data: params
})
}
export default {
getCategoryListApi,
getGoodsListApi,
addWarehouseApi,
getListApi,
batchRemoveApi,
batchSaleApi,
batchOffApi,
goodsDetailApi,
modifyPriceApi,
getOrderList,
getOrderDetail,
getSaleOrderList,
getSaleOrderDetail
getCategoryListApi,
getGoodsListApi,
addWarehouseApi,
getListApi,
batchRemoveApi,
batchSaleApi,
batchOffApi,
goodsDetailApi,
modifyPriceApi,
getOrderList,
getOrderDetail,
getSaleOrderList,
getSaleOrderDetail,
getOilCouponList,
updateOilCoupon,
getOilCouponOrderList,
exportOilCouponOrderList
}
......@@ -34,6 +34,29 @@ function exportFn (url) {
iframe.src = url
document.body.appendChild(iframe)
}
function uploadImg (e, _this, maxSize = 2) {
return new Promise((resolve, reject) => {
const file = e.srcElement.files[0]
if (!file) return reject()
const size = file.size / 1024 / 1024
if (maxSize && size > maxSize) {
_this.$message.error(`图片体积需小于${maxSize}M`)
return reject()
}
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = async event => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(',')
const splitStr = file.name.split('.')
const fileUrl = splitStr[splitStr.length - 1] + '@' + arrBase64[1]
const res = await _this.$apis.beforeSale.uploadImgApi({ file: fileUrl })
if (res) resolve({ url: res, name: file.name })
else reject('上传失败')
}
})
}
export {
exportFn
exportFn,
uploadImg
}
\ No newline at end of file
......@@ -8,58 +8,71 @@
:formData="searchFormData"
@handleOk="handleSearch"
@handleRest="handleReset"
@submit.native.prevent
></GLCombiForm>
</div>
<div class="tabelList">
<GLTable
ref="listRef"
:getListApi="getListApi"
:searchForm="tableSearchForm"
:noDataImg="url"
:tableData="tableData"
:tableParams="tableParams"
:pageConf="pageConf"
:tableTotal="tableTotal"
@refreshTable="getOilCouponList"
v-loading="loading"
>
<template
slot="IMG"
slot-scope="scope"
>
<template>
<img
class="img"
:src="scope.scope.goodsImage"
<el-popover
placement="top"
trigger="hover"
>
</template>
<img
class="img-plus"
:src="scope.scope.aliasUrl"
/>
<div
slot="reference"
class="img"
>
<img :src="scope.scope.aliasUrl">
<div class="mask">
<img
src="@/assets/images/icon-edit.png"
class="icon"
>
<input
type="file"
:ref="`file-${scope.scope.id}`"
accept="image/png, image/jpeg, image/gif, image/jpg"
@change="uploadImg($event, scope.scope)"
/>
</div>
</div>
</el-popover>
</template>
<template
slot="INPUT"
slot-scope="scope"
>
<el-form
@submit.native.prevent
:model="scope.scope"
:ref="`inputRef-${scope.scope.id}`"
:key="scope.scope.id"
>
<el-form-item
class="form-input"
prop="brandId"
:rules="rules(scope.scope)"
>
<el-input
v-model.trim="scope.scope.brandId"
size="small"
@blur="handleInput(scope.scope)"
></el-input>
</el-form-item>
</el-form>
<el-input
v-model="scope.scope.salesPrice"
size="small"
@blur="handleBlur(scope.scope)"
></el-input>
</template>
<template
slot="SWITCH"
slot-scope="scope"
>
<el-switch
v-model="scope.scope.usedAmount"
v-model="scope.scope.status"
@change="change($event,scope.scope)"
:active-value="1"
:inactive-value="0"
></el-switch>
</template>
</GLTable>
......@@ -68,35 +81,30 @@
</template>
<script type='text/ecmascript-6'>
import url from '@/assets/images/empty.png'
import * as dayjs from 'dayjs'
import NP from 'number-precision'
import { uploadImg } from '@/common/constant'
export default {
name: 'list',
data () {
return {
url,
whiteListKey: 0,
loading: false,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchForm: {
activityName: '',
aliasName: '',
},
searchFormData: [
{
label: '商品信息',
name: 'activityName',
name: 'aliasName',
type: 'input',
maxlength: 40
}
],
getListApi: this.$apis.goodsCouponApi.getCouponsList,
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '商品编码',
prop: 'activityName',
prop: 'alias',
minWidth: 100
},
{
......@@ -106,7 +114,7 @@ export default {
},
{
label: '商品信息',
prop: 'brandId',
prop: 'aliasName',
minWidth: 100
},
{
......@@ -116,24 +124,24 @@ export default {
},
{
label: '面额/元',
prop: 'amount',
prop: 'faceValue',
minWidth: 150
},
{
label: '成本/元',
prop: 'denomination',
prop: 'sellPrice',
minWidth: 100
},
{
label: '库存',
prop: 'usableAmount',
prop: 'stock',
minWidth: 100
},
{
label: '销售量',
prop: 'activityStatusStr',
prop: 'salesVolume',
minWidth: 100
},
{
......@@ -143,53 +151,97 @@ export default {
},
]
},
tableData: [],
tableTotal: 0
}
},
mounted () {
this.getOilCouponList()
},
methods: {
rules (row) {
return [{
required: true, trigger: 'blur',
validator: (rule, value, callback) => {
if (!value) callback(new Error('请填写销售价'))
else {
if (value < row.denomination) {
callback(new Error('销售价需大于等于成本价'))
}
else callback()
}
}
}]
async getOilCouponList () {
try {
this.loading = true
const {
pageNum,
pageSize,
} = this.$refs.listRef.page,
{ searchForm } = this,
{ list, total } = await this.$apis.platformGoods.getOilCouponList({
pageNum,
pageSize,
...searchForm
}) || {}
list && list.map(e => {
e.salesPrice = e.salesPrice ? NP.divide(e.salesPrice, 100).toFixed(2) : ''
})
this.tableData = list || []
this.tableTotal = total || 0
this.loading = false
} catch (error) {
this.loading = false
if (error) this.$message.error(error)
}
},
handleSearch () {
this.$refs.listRef.refreshTable()
this.getOilCouponList()
},
handleReset () {
this.searchForm = this.$options.data.call(this).searchForm
this.handleSearch()
},
change (e, row) {
if (e) this.$refs[`inputRef-${row.id}`].validate(valid => {
if (valid) {
console.log(valid)
} else {
row.usedAmount = false
if (!row.brandId) this.$message.error('请填写销售价')
}
async change (e, row) {
if (e && !row.salesPrice) {
row.status = 0
return this.$message.error('请填写销售价')
}
this.update({
type: 2,
id: row.id,
status: e
})
},
handleInput (row) {
let val = row.brandId?.trim().replace(/^0+/, '')
handleBlur (row) {
let val = row.salesPrice?.trim().replace(/^0+/, '')
if (val) {
if (val.startsWith('.')) row.brandId = '0' + val
if (!/^\d+(\.\d+)?$/.test(val)) val = ''
val = `${Math.abs(val)}`
if (val.startsWith('.')) row.salesPrice = '0' + val
if (val < Number(row.sellPrice)) val = `${row.sellPrice}`
if (val > 1000) val = '999.99'
const [integerPart, decimalPart] = val.split('.')
if (decimalPart && decimalPart.length > 2) row.brandId = `${integerPart || '0'}.${decimalPart.slice(0, 2)}`
else row.brandId = val
}
if (decimalPart && decimalPart.length > 2) row.salesPrice = `${integerPart || '0'}.${decimalPart.slice(0, 2)}`
else row.salesPrice = val
} else row.salesPrice = ''
if (row.salesPrice) this.update({
type: 1,
id: row.id,
salesPrice: NP.times(row.salesPrice, 100)
})
},
async uploadImg (e, target) {
const { url } = await uploadImg(e, this)
this.$refs[`file-${target.id}`].value = ''
if (url) this.update({
type: 0,
id: target.id,
aliasUrl: url
})
},
async update (params) {
try {
this.loading = true
const res = await this.$apis.platformGoods.updateOilCoupon(params)
if (res) {
this.loading = false
this.$message.success('更新成功')
this.handleSearch()
} else throw '更新失败'
} catch (error) {
this.loading = false
if (error) this.$message.error(error)
}
}
}
}
</script>
......@@ -205,6 +257,39 @@ export default {
.img {
width: 36px;
height: 36px;
position: relative;
.mask {
display: none;
background-color: rgba($color: #000000, $alpha: 0.5);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 2;
align-items: center;
justify-content: center;
cursor: pointer;
.icon {
width: 16px;
height: 16px;
}
input {
opacity: 0;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
}
img {
width: 100%;
height: 100%;
}
&:hover .mask {
display: flex;
}
}
.form-input {
padding-top: 14px;
......@@ -213,4 +298,8 @@ export default {
padding-top: 2px;
}
}
.img-plus {
width: 200px;
height: 200px;
}
</style>
......@@ -2,7 +2,7 @@
<div class="container">
<GLCombiForm
ref="showSearch"
:rowNumber="1"
:rowNumber="2"
:formObj="searchForm"
:formData="searchFormData"
@handleOk="handleSearch"
......@@ -21,16 +21,15 @@
:tableParams="tableParams"
:pageConf="pageConf"
>
<span
slot="auth-button"
<template
slot="statusStr"
slot-scope="scope"
>
<GLTableButton
:buttonList="tableButtonList"
:buttonItem="scope.scope"
:buttonNum="3"
></GLTableButton>
</span>
<div class="status-box">
<span :class="['status',`status-${scope.scope.status}`]"></span>
{{scope.scope.statusStr}}
</div>
</template>
</GLTable>
</div>
</div>
......@@ -48,15 +47,18 @@ export default {
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchForm: {
merchantName: '',
merchantId: '',
staffName: ''
phone: '',
orderCode: '',
oilCouponName: '',
status: '',
time: []
},
searchFormData: [
{
label: '用户手机号',
name: 'activityName',
name: 'phone',
type: 'input',
maxlength: 100
maxlength: 13
},
{
label: '出单门店',
......@@ -66,13 +68,13 @@ export default {
},
{
label: '订单编号',
name: 'wechatName',
name: 'orderCode',
type: 'input',
maxlength: 100
},
{
label: '下单时间',
name: 'showTime',
name: 'time',
type: 'datePicker',
valueFormat: 'yyyy-MM-dd',
isClear: true,
......@@ -88,91 +90,91 @@ export default {
},
{
label: '商品信息',
name: 'userPhone',
name: 'oilCouponName',
type: 'input',
maxlength: 11
},
{
label: '订单状态',
name: 'statuses',
name: 'status',
type: 'select',
maxlength: 100,
optionList: [
{ text: '全部', id: '-1,0,1' },
{ text: '待付款', id: '0' },
{ text: '已取消', id: '1' },
{ text: '发放中', id: '-1' },
{ text: '发放成功', id: '-2' },
{ text: '发放失败', id: '-3' },
{ text: '全部', id: '' },
{ text: '待付款', id: '5' },
{ text: '已取消', id: '6' },
{ text: '发放中', id: '1' },
{ text: '发放成功', id: '2' },
{ text: '发放失败', id: '4' },
],
optionId: 'id',
optionLabel: 'text'
},
],
getListApi: this.$apis.goodsCouponApi.getCouponsList,
getListApi: this.$apis.platformGoods.getOilCouponOrderList,
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '商品编码',
prop: 'userPhone',
minWidth: 100
prop: 'oilCouponAlias',
minWidth: 200
},
{
label: '商品信息',
prop: 'wechatName',
minWidth: 100
prop: 'oilCouponName',
minWidth: 200
},
{
label: '销售价/元',
prop: 'activityName',
minWidth: 100
minWidth: 100,
formatter: cellValue => {
return (cellValue.salesPrice / 100).toFixed(2)
}
},
{
label: '订单金额/元',
minWidth: 100,
prop: 'activityName',
minWidth: 130,
formatter: cellValue => {
return (cellValue.orderPrice / 100).toFixed(2)
}
},
{
label: '所用积分',
minWidth: 100,
prop: 'activityName',
prop: 'redeemPoints',
},
{
label: '出单门店',
minWidth: 150,
formatter: cell => `${dayjs(cell.activityStartTime).format('YYYY/MM/DD')}-${dayjs(cell.activityEndTime).format('YYYY/MM/DD')}`
prop: 'merchantName',
minWidth: 200,
},
{
label: '用户手机号',
prop: 'activityType',
prop: 'phone',
minWidth: 150,
formatter: cell => {
// 0:随机红包;1:九宫格;2:翻牌;3:大转盘;
return { 0: '随机红包', 1: '九宫格', 2: '翻牌', 3: '大转盘' }[cell.activityType]
}
},
{
label: '充值手机号',
prop: 'link',
prop: 'rechargePhone',
minWidth: 150
},
{
label: '订单状态',
prop: 'showTime',
minWidth: 150
minWidth: 150,
addHtml: 'statusStr'
},
{
label: '订单编号',
prop: 'showTime',
minWidth: 150
prop: 'orderCode',
minWidth: 200
},
{
label: '下单时间',
prop: 'lotteryDrawTime',
minWidth: 150
prop: 'receiveTime',
minWidth: 200
},
]
},
......@@ -192,31 +194,20 @@ export default {
this.handleSearch()
},
handleExport () {
console.log(exportFn)
const params = this.getParams()
this.$apis.redenvelope.exportRedEnvelopeRecord(params).then(res => {
this.$apis.platformGoods.exportOilCouponOrderList({...params,...this.$refs.listRef.page}).then(res => {
exportFn(res)
})
},
getParams () {
let params = JSON.parse(JSON.stringify(this.searchForm))
this.updateParams(params, 'showTime', 'showTime', 'startShowTime', 'endShowTime');
this.updateParams(params, 'lotteryDrawTime', 'lotteryDrawTime', 'startLotteryDrawTime', 'endLotteryDrawTime');
return params
},
updateParams (params, paramKey, formKey, beginKey, endKey) {
if (params[paramKey]) {
params[beginKey] = this.searchForm[formKey][0];
params[endKey] = this.searchForm[formKey][1];
delete params[paramKey];
} else {
delete params[beginKey];
delete params[endKey];
if (params.time.length) {
params.startReceiveTimeStr = `${dayjs(params.time[0]).format('YYYY-MM-DD')} 00:00:00`
params.endReceiveTimeStr = `${dayjs(params.time[1]).format('YYYY-MM-DD')} 23:59:59`
delete params.time
}
// delete params[paramKey];
return params
}
},
}
}
</script>
......@@ -239,4 +230,21 @@ export default {
}
}
}
.status-box {
display: flex;
align-items: center;
.status {
width: 6px;
height: 6px;
border-radius: 4px;
background: #fdb757;
margin-right: 8px;
}
.status-2 {
background: #2cca74;
}
.status-4 {
background: #999999;
}
}
</style>
......@@ -4,7 +4,6 @@
<GLTabs
v-model="currentComponent"
:tabPaneList="tabPaneList"
@tab-click="handleClick"
></GLTabs>
</div>
<div class="component">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!