Commit 00710f1f by zhangxw

优惠券版本

1 parent 3ee29398
......@@ -13,6 +13,7 @@
"@tinymce/tinymce-vue": "^6.3.0",
"@types/lodash-es": "^4.17.12",
"ant-design-vue": "~4.2.1",
"autumn-vue": "^0.4.47",
"axios": "~1.7.6",
"china-area-data": "^5.0.1",
"clipboard": "^2.0.11",
......@@ -1909,6 +1910,42 @@
"@vue/shared": "3.5.13"
}
},
"node_modules/@vue/reactivity-transform": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.47.tgz",
"integrity": "sha512-m8lGXw8rdnPVVIdIFhf0LeQ/ixyHkH5plYuS83yop5n7ggVJU+z5v0zecwEnX7fa7HNLBhh2qngJJkxpwEEmYA==",
"dependencies": {
"@babel/parser": "^7.16.4",
"@vue/compiler-core": "3.2.47",
"@vue/shared": "3.2.47",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7"
}
},
"node_modules/@vue/reactivity-transform/node_modules/@vue/compiler-core": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.47.tgz",
"integrity": "sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==",
"dependencies": {
"@babel/parser": "^7.16.4",
"@vue/shared": "3.2.47",
"estree-walker": "^2.0.2",
"source-map": "^0.6.1"
}
},
"node_modules/@vue/reactivity-transform/node_modules/@vue/shared": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.47.tgz",
"integrity": "sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ=="
},
"node_modules/@vue/reactivity-transform/node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"dependencies": {
"sourcemap-codec": "^1.4.8"
}
},
"node_modules/@vue/runtime-core": {
"version": "3.5.13",
"resolved": "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.5.13.tgz",
......@@ -2827,6 +2864,135 @@
"node": ">= 4.5.0"
}
},
"node_modules/autumn-vue": {
"version": "0.4.47",
"resolved": "https://registry.npmmirror.com/autumn-vue/-/autumn-vue-0.4.47.tgz",
"integrity": "sha512-nwMfRisWri6ys2z6cUpUjXkMRiINS6yMdC/xrlbfaUJpDWhHR3at9YZH3sxk4l5xrvyU4ZdYw3WsB1aJHJ/OKQ==",
"dependencies": {
"axios": "~1.7.6",
"image-conversion": "^2.1.1",
"vue": "~3.2.26",
"vue-facing-decorator": "^3.0.4",
"vue-i18n": "^9.14.5",
"vue-router": "^4.0.12",
"vuex": "^4.0.0-0"
}
},
"node_modules/autumn-vue/node_modules/@vue/compiler-core": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.47.tgz",
"integrity": "sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==",
"dependencies": {
"@babel/parser": "^7.16.4",
"@vue/shared": "3.2.47",
"estree-walker": "^2.0.2",
"source-map": "^0.6.1"
}
},
"node_modules/autumn-vue/node_modules/@vue/compiler-dom": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.2.47.tgz",
"integrity": "sha512-dBBnEHEPoftUiS03a4ggEig74J2YBZ2UIeyfpcRM2tavgMWo4bsEfgCGsu+uJIL/vax9S+JztH8NmQerUo7shQ==",
"dependencies": {
"@vue/compiler-core": "3.2.47",
"@vue/shared": "3.2.47"
}
},
"node_modules/autumn-vue/node_modules/@vue/compiler-sfc": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.2.47.tgz",
"integrity": "sha512-rog05W+2IFfxjMcFw10tM9+f7i/+FFpZJJ5XHX72NP9eC2uRD+42M3pYcQqDXVYoj74kHMSEdQ/WmCjt8JFksQ==",
"dependencies": {
"@babel/parser": "^7.16.4",
"@vue/compiler-core": "3.2.47",
"@vue/compiler-dom": "3.2.47",
"@vue/compiler-ssr": "3.2.47",
"@vue/reactivity-transform": "3.2.47",
"@vue/shared": "3.2.47",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7",
"postcss": "^8.1.10",
"source-map": "^0.6.1"
}
},
"node_modules/autumn-vue/node_modules/@vue/compiler-ssr": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.2.47.tgz",
"integrity": "sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==",
"dependencies": {
"@vue/compiler-dom": "3.2.47",
"@vue/shared": "3.2.47"
}
},
"node_modules/autumn-vue/node_modules/@vue/reactivity": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.2.47.tgz",
"integrity": "sha512-7khqQ/75oyyg+N/e+iwV6lpy1f5wq759NdlS1fpAhFXa8VeAIKGgk2E/C4VF59lx5b+Ezs5fpp/5WsRYXQiKxQ==",
"dependencies": {
"@vue/shared": "3.2.47"
}
},
"node_modules/autumn-vue/node_modules/@vue/runtime-core": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.2.47.tgz",
"integrity": "sha512-RZxbLQIRB/K0ev0K9FXhNbBzT32H9iRtYbaXb0ZIz2usLms/D55dJR2t6cIEUn6vyhS3ALNvNthI+Q95C+NOpA==",
"dependencies": {
"@vue/reactivity": "3.2.47",
"@vue/shared": "3.2.47"
}
},
"node_modules/autumn-vue/node_modules/@vue/runtime-dom": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.2.47.tgz",
"integrity": "sha512-ArXrFTjS6TsDei4qwNvgrdmHtD930KgSKGhS5M+j8QxXrDJYLqYw4RRcDy1bz1m1wMmb6j+zGLifdVHtkXA7gA==",
"dependencies": {
"@vue/runtime-core": "3.2.47",
"@vue/shared": "3.2.47",
"csstype": "^2.6.8"
}
},
"node_modules/autumn-vue/node_modules/@vue/server-renderer": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.2.47.tgz",
"integrity": "sha512-dN9gc1i8EvmP9RCzvneONXsKfBRgqFeFZLurmHOveL7oH6HiFXJw5OGu294n1nHc/HMgTy6LulU/tv5/A7f/LA==",
"dependencies": {
"@vue/compiler-ssr": "3.2.47",
"@vue/shared": "3.2.47"
},
"peerDependencies": {
"vue": "3.2.47"
}
},
"node_modules/autumn-vue/node_modules/@vue/shared": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.47.tgz",
"integrity": "sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ=="
},
"node_modules/autumn-vue/node_modules/csstype": {
"version": "2.6.21",
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz",
"integrity": "sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w=="
},
"node_modules/autumn-vue/node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.25.9.tgz",
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
"dependencies": {
"sourcemap-codec": "^1.4.8"
}
},
"node_modules/autumn-vue/node_modules/vue": {
"version": "3.2.47",
"resolved": "https://registry.npmmirror.com/vue/-/vue-3.2.47.tgz",
"integrity": "sha512-60188y/9Dc9WVrAZeUVSDxRQOZ+z+y5nO2ts9jWXSTkMvayiWxCWOWtBQoYjLeccfXkiiPZWAHcV+WTPhkqJHQ==",
"dependencies": {
"@vue/compiler-dom": "3.2.47",
"@vue/compiler-sfc": "3.2.47",
"@vue/runtime-dom": "3.2.47",
"@vue/server-renderer": "3.2.47",
"@vue/shared": "3.2.47"
}
},
"node_modules/available-typed-arrays": {
"version": "1.0.7",
"resolved": "https://registry.npmmirror.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
......@@ -9156,7 +9322,6 @@
"version": "0.6.1",
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
......@@ -9206,6 +9371,12 @@
"dev": true,
"peer": true
},
"node_modules/sourcemap-codec": {
"version": "1.4.8",
"resolved": "https://registry.npmmirror.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
"deprecated": "Please use @jridgewell/sourcemap-codec instead"
},
"node_modules/split-string": {
"version": "3.1.0",
"resolved": "https://registry.npmmirror.com/split-string/-/split-string-3.1.0.tgz",
......
......@@ -13,6 +13,7 @@
"@tinymce/tinymce-vue": "^6.3.0",
"@types/lodash-es": "^4.17.12",
"ant-design-vue": "~4.2.1",
"autumn-vue": "^0.4.47",
"axios": "~1.7.6",
"china-area-data": "^5.0.1",
"clipboard": "^2.0.11",
......
......@@ -5,7 +5,7 @@
<a-flex justify="space-between">
<div class="logo">
<img src="/assets/images/logo.png"/>
<h3>广联二手车</h3>
<h3>优加二手车</h3>
<breadcrumb-bar></breadcrumb-bar>
</div>
......
import { AxiosResponse, AxiosStatic } from 'axios';
export class DiscountController {
// 获取优惠券管理列表
static couponTemplatePage(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/template/page', params);
}
// 创建优惠券模板
static createCouponTemplate(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/template/add', params);
}
// 编辑优惠券模板
static editCouponTemplate(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/template/update', params);
}
static PAGE_COUPON_TEMPLATE = 'coupon/template/page';
// 获取优惠券模板详情
static couponTemplateDetail(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/template/detail', params);
}
// 停用启用优惠券模板
static couponTemplateChangeStatus(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/template/changeStatus', params);
}
// 手动发放优惠券
static couponManualIssuance(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/template/manualDistribution', params);
}
// 获取优惠券活动管理列表
static couponActivityPage(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/activity/page', params);
}
static PAGE_COUPON_ACTIVITY = 'coupon/activity/page'
// 获取优惠券活动详情
static couponActivityDetail(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/activity/detail', params);
}
// 创建优惠券活动
static createCouponActivity(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/activity/add', params);
}
// 编辑优惠券活动
static editCouponActivity(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/activity/update', params);
}
// 停用启用优惠券活动
static couponActivityChangeStatus(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/activity/changeStatus', params);
}
// 删除优惠券活动
static couponActivityDelete(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/activity/delete', params);
}
// 获取优惠券发放统计数据
static couponStatistics(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/distribution/statistics', params);
}
// 获取优惠券发放记录列表
static couponRecordList(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/distribution/record/page', params);
}
static PAGE_COUPON_RECORD = 'coupon/distribution/record/page'
// 导出优惠券发放记录数据
static couponRecordExport(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/distribution/record/export', params);
}
// 重新发放优惠券
static couponReissue(axios: AxiosStatic, params: any): Promise<AxiosResponse> {
return axios.post('coupon/distribution/record/reissue', params);
}
}
\ No newline at end of file
......@@ -139,7 +139,7 @@
:allow-clear="field.allowHalf" :autofocus="field.autofocus"/>
</template>
<!-- select -->
<a-select v-else-if="field.type === 'select'" v-model:value="form[field.fieldName]" :mode="field.mode" class="form-item-control"
<a-select v-else-if="field.type === 'select'" v-model:value="form[field.fieldName]" :mode="field.mode" :maxTagCount="field.maxTagCount" class="form-item-control"
@change="field.change" :showSearch="field.showSearch" @search="field.search" :token-separators="field.tokenSeparators"
:placeholder="field.placeholder" :allowClear="field.allowClear" :options="field.optionItems" :disabled="field.disabled"/>
<!-- slot -->
......
......@@ -35,12 +35,5 @@ export const DiscountRouter: Array<RouteRecordRaw> = [
meta: {
breadcrumbs: [{ name: '优惠卡券管理' }, { name: '优惠券发放记录' }]
}
},
{
path: '/discount/record/view',
component: () => import('@/views/discount/record/DiscountRecordView.vue'),
meta: {
breadcrumbs: [{ name: '优惠卡券管理' }, { name: '优惠券发放记录', path: '/discount/record' }, { name: '优惠券发放记录详情' }]
}
},
}
];
......@@ -101,7 +101,7 @@
<a-input-number v-model:value="formState.delayMinute" addon-before="自动延时" :min="0" :step="1" :max="9999" :maxlength="4" addon-after="分钟" placeholder="请输入"/>
</a-form-item>
<a-form-item label="可参拍城市" name="cities" :rules="[{ required: true, message: '请输入可参拍城市!' },{validator: verifyCities,message: '参拍城市不能超过20个'}]" :label-col="{span: 3}"
<a-form-item label="可参拍城市" name="cities" :rules="[{validator: verifyCities,message: '参拍城市不能超过20个'}]" :label-col="{span: 3}"
:wrapper-col="{span: 19}" class="row-item">
<a-cascader v-model:value="formState.cities" :options="areaData" multiple placeholder="请选择" :show-checked-strategy="'SHOW_CHILD'" @change="handleCitiesChange"/>
</a-form-item>
......
......@@ -17,32 +17,108 @@
:row-key="record => record.id" :scroll="{ y: 'calc(100vh - 350px)' }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'activityName'">
<div @click="handleAdd({...record, pageState: 'VIEW'})">
<a style="text-decoration: underline;" class="text_hide" :title="record.activityName">{{ record.activityName }}</a>
<div class="text_hide second_text" :title="record.activityId">ID:{{ record.activityId }}</div>
</div>
</template>
<template v-if="column.key === 'validTime'">
<span>{{ record.validStartTime }}</span>
<span class="split">至</span>
<span>{{ record.validEndTime }}</span>
</template>
<template v-if="column.key === 'activityType'">
{{activityTypeList.find(item => item.value === record.activityType)?.label || '-'}}
<div v-if="record.activityType === 1 && record.priceRanges?.length > 0">
<div class="second_text" v-if="record.priceRanges.length === 1">触发价格:[{{ (record.priceRanges[0].priceMin / 10000).toFixed(2) }}, {{ (record.priceRanges[0].priceMax / 10000).toFixed(2) }}]万</div>
<div class="second_text" v-else>
<a-tooltip placement="top">
<template #title>
<div class="price-ranges-tooltip">
<div v-for="(range, index) in record.priceRanges" :key="index" class="range-item">
阶梯 {{ index + 1 }}:[{{ (range.priceMin / 10000).toFixed(2) }}, {{ (range.priceMax / 10000).toFixed(2) }}]万
</div>
</div>
</template>
{{ record.priceRanges?.length }}个价格阶梯
</a-tooltip>
</div>
</div>
</template>
<template v-if="column.key === 'couponIds'">
<div v-if="record.couponTemplates?.length === 1">
<a-tooltip :title="`${record.couponTemplates[0].templateName} 券面额:${record.couponTemplates[0].faceAmount}`">
{{ record.couponTemplates[0].templateName }}
</a-tooltip>
</div>
<div style="text-decoration: underline;" v-else-if="record.couponTemplates?.length > 1">
<a-tooltip>
<template #title>
<div v-for="(range, index) in record.couponTemplates" :key="index" class="range-item">
{{ range?.templateName }} 券面额:{{ range?.faceAmount }}
</div>
</template>
<span>共 {{ record.couponTemplates.length }} 种</span>
</a-tooltip>
</div>
</template>
<template v-if="column.key === 'targetType'">
<div v-if="record.targetType === 1">全部用户</div>
<a v-else style="text-decoration: underline;" :href="`#/discount/record?keyword=${record.activityName}`" target="_blank">指定用户</a>
</template>
<template v-if="column.key === 'distributionQuantity'">
{{ (record.usedCount ?? '') === '' ? '-' : record.usedCount }} / {{ (record.totalGrantCount ?? '') === '' ? '-' : record.totalGrantCount }}
</template>
<template v-if="column.key === 'writeOffRate'">
{{ (record.writeOffRate ?? '') !== '' ? `${record.writeOffRate}%` : '-' }}
</template>
<template v-if="column.key === 'status'">
{{statusList.find(item => item.value === record.status)?.label || '-'}}
<a-tag :color="statusList.find(item => item.value === record.status)?.color" :style="{ color: statusList.find(item => item.value === record.status)?.textColor }"
:bordered="false">
{{statusList.find(item => item.value === record.status)?.label || '-'}}
</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-button type="link" v-if="record.status === 1" @click="handleAdd({ ...record, pageState: 'EDIT' })"
size="small">编辑</a-button>
<a-button type="link" v-if="record.status === 1" @click="handleCopy(record)"
size="small">复制</a-button>
<a-button type="link" v-if="record.status === 4" @click="handleTurnOn(record)"
size="small" style="color: #00AD74">启用</a-button>
<a-button type="link" v-if="record.status === 2" danger @click="handleTurnOff(record)"
size="small">停用</a-button>
<a-button type="link" v-if="record.status === 2 || record.status === 3 || record.status === 4"
@click="handleViewData(record)"
size="small">查看数据</a-button>
<a-button type="link" v-if="record.status === 2 || record.status === 3 || record.status === 4"
@click="handleCopy(record)" size="small">复制</a-button>
<a-button type="link" v-if="record.status === 2 || record.status === 3 || record.status === 4"
@click="handleAdd({ ...record, pageState: 'VIEW' })"
size="small">查看详情</a-button>
<a-button type="link" v-if="record.status === 1" @click="handleDelete(record)" danger
size="small">删除</a-button>
</template>
</template>
</a-table>
</a-card>
<DiscountActivityAddForm ref="activityAddFormRef" @emitOk="handlePageReload" />
</template>
<script lang="ts">
import { createVNode } from "vue";
import { Component } from 'vue-facing-decorator';
import { message, TableColumnsType } from "ant-design-vue";
import { message, TableColumnsType, Modal } from "ant-design-vue";
import { Operator, Order } from "lib/src/core/page/Pagination";
import { PaginationComponent } from "@/components/PaginationComponent";
import { Vehicle } from "lib/src/entity/vehicle/entity/Vehicle";
import { DetectionController } from "@/api/DetectionController";
import { DiscountController } from "@/api/DiscountController";
import DiscountActivityAddForm from "@/views/discount/activity/components/DiscountActivityAddForm.vue";
import { InfoCircleFilled } from '@ant-design/icons-vue';
@Component({
components: {}
components: { DiscountActivityAddForm }
})
export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
......@@ -53,10 +129,10 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
];
statusList = [
{ label: '待启动', value: 1 },
{ label: '进行中', value: 2 },
{ label: '已结束', value: 3 },
{ label: '已停用', value: 4 },
{ label: '待启动', value: 1, color: '#F0F2F5', textColor: '#777C85' },
{ label: '进行中', value: 2, color: '#E8F8F2', textColor: '#00A870' },
{ label: '已结束', value: 3, color: '#E9F2FC', textColor: '#2A82E4'},
{ label: '已停用', value: 4, color: '#FFF3E5', textColor: '#FC8B0A' },
];
/**
......@@ -69,18 +145,16 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
return (this.getPagination().pageIndex - 1) * this.getPagination().pageSize + index + 1;
},
},
{ title: '活动名称/ID', dataIndex: 'activityName', key: 'activityName', align: 'center', width: 150, resizable: true, ellipsis: true },
{ title: '活动有效期', dataIndex: 'templateName', key: 'templateName', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '发放策略', dataIndex: 'activityType', key: 'activityType', align: 'center', width: 150, resizable: true, ellipsis: true },
{ title: '关联优惠券', dataIndex: 'couponIds', key: 'couponIds', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '面额/最高抵扣(元)', dataIndex: 'faceAmount', key: 'faceAmount', align: 'center', width: 240, resizable: true, ellipsis: true },
{ title: '关联活动数', dataIndex: ['vehicle', 'baseInfo', "licensePlate"], key: 'licensePlate', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '生效人群', dataIndex: 'totalQuantity', key: 'totalQuantity', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '发放/使用数量(张)', dataIndex: 'scoreLevel', key: 'scoreLevel', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '核销率', dataIndex: 'scoreLevel', key: 'scoreLevel', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '创建时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '状态', dataIndex: 'status', key: 'status', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '操作', key: 'action', width: 170, align: 'center', fixed: 'right' },
{ title: '活动名称/ID', dataIndex: 'activityName', key: 'activityName', align: 'left', width: 150, resizable: true, ellipsis: true },
{ title: '活动有效期', dataIndex: 'validTime', key: 'validTime', align: 'left', width: 320, resizable: true, ellipsis: true },
{ title: '发放策略', dataIndex: 'activityType', key: 'activityType', align: 'left', width: 220, resizable: true, ellipsis: true },
{ title: '关联优惠券', dataIndex: 'couponIds', key: 'couponIds', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '生效人群', dataIndex: 'targetType', key: 'targetType', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '使用/发放数量(张)', dataIndex: 'distributionQuantity', key: 'distributionQuantity', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '核销率', dataIndex: 'writeOffRate', key: 'writeOffRate', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '状态', dataIndex: 'status', key: 'status', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '操作', key: 'action', width: 250, align: 'left', fixed: 'right' },
];
getPagination() {
......@@ -91,7 +165,15 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
* 初始化配置
*/
created(): void {
this.init(this.axios, DetectionController.PAGE_INSPECTOR_REPORT);
this.init(this.axios, DiscountController.PAGE_COUPON_ACTIVITY);
const pageQuery = this.$route.query
// 从优惠券管理列表跳转 直接打开活动详情
if (pageQuery?.activityId) {
this.$nextTick(() => {
this.handleAdd({ id: pageQuery.activityId, pageState: "VIEW" });
this.$router.replace({ query: { ...this.$route.query, activityId: undefined } })
})
}
this.buildQueryForm({
keyword: [null, { label: '活动名称/ID', field: 'keyword', placeholder: '请输入活动名称/ID', operator: Operator.like }],
status: [null, { label: '活动状态', field: 'status', type: 'select', allowClear: true, optionItems: this.statusList, operator: Operator.eq }],
......@@ -112,7 +194,141 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
this.pageReset();
}
handleAdd(data: any) {
this.$refs.activityAddFormRef?.init({ ...data, pageState: data?.pageState || "ADD" });
}
handleTurnOff(record: any) {
Modal.confirm({
title: "确认停用活动",
icon: createVNode(InfoCircleFilled, { style: { color: "#EB2F2F" } }),
content: createVNode("div", { style: { lineHeight: "22px" } }, [
createVNode(
"p",
{ style: { marginBottom: "8px" } },
`确认要停用活动"${record.activityName}"吗?停用后将立即停止发放优惠券。`
)
]),
okText: "确认停用",
okButtonProps: {
danger: true
},
cancelText: "取消",
onOk: () => {
DiscountController.couponActivityChangeStatus(this.axios, { id: record?.id, enable: 0 }).then((res) => {
let { code, message: msg } = res.data
if (code === '200') {
message.success("停用成功");
this.pageReload();
} else {
message.error(msg);
}
});
},
});
}
handleTurnOn(record: any) {
Modal.confirm({
title: "确认启用活动",
icon: createVNode(InfoCircleFilled, { style: { color: "#1956FE" } }),
content: createVNode("div", { style: { lineHeight: "22px" } }, [
createVNode(
"p",
{ style: { marginBottom: "8px" } },
`确认要启用活动"${record.activityName}"吗?启用后将根据活动有效期开始发放优惠券。`
)
]),
okText: "确认启用",
cancelText: "取消",
onOk: () => {
DiscountController.couponActivityChangeStatus(this.axios, { id: record?.id, enable: 1 }).then((res) => {
let { code, message: msg } = res.data
if (code === '200') {
message.success("启用成功");
this.pageReload();
} else {
message.error(msg);
}
});
},
});
}
handleCopy(record: any) {
this.$refs.activityAddFormRef.init({ ...record, pageState: "COPY" });
}
handleDelete(record: any) {
Modal.confirm({
title: "确认删除活动",
icon: createVNode(InfoCircleFilled, { style: { color: "#EB2F2F" } }),
content: createVNode("div", { style: { lineHeight: "22px" } }, [
createVNode(
"p",
{ style: { marginBottom: "8px" } },
`确认要删除活动"${record.activityName}"吗?删除后将立即停止发放优惠券`
),
]),
okText: "确认删除",
okButtonProps: {
danger: true
},
cancelText: "取消",
onOk: () => {
DiscountController.couponActivityDelete(this.axios, { id: record?.id }).then((res) => {
let { code, message: msg } = res.data
if (code === '200') {
message.success("删除成功");
this.pageReload();
} else {
message.error(msg);
}
});
},
});
}
handleViewData(record: any) {
const keyword = encodeURIComponent(String(record?.activityName || ""));
window.open(`#/discount/record?keyword=${keyword}`, "_blank");
}
isInValidTime(record: any) {
const now = Date.now();
const start = new Date(record?.validStartTime).getTime();
const end = new Date(record?.validEndTime).getTime();
if (!Number.isFinite(start) || !Number.isFinite(end)) return true;
return now >= start && now <= end;
}
}
</script>
<style scoped lang="less"></style>
<style scoped lang="less">
.text_hide {
width: 100%;
height: 22px;
font-size: 14px;
font-weight: 400;
font-family: "HarmonyOSSansSC";
text-align: left;
line-height: 22px;
margin-top: 9px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.activity_name {
text-decoration: underline;
color: #185EFE;
}
.second_text {
margin-top: 4px;
font-size: 12px;
color: #C4C7CC;
}
.split {
margin: 0 8px;
color: #C4C7CC;
}
</style>
<template>
<div>
<a-drawer width="936" :title="titleVisible" :maskClosable="false" :keyboard="false" placement="right"
:open="dialogVisible" @close="onClose">
<template #extra>
<a-space v-if="!isViewMode">
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="handleOk()">创建</a-button>
</a-space>
<a-space v-else>
<a-button type="primary" @click="onClose">返回</a-button>
</a-space>
</template>
<a-spin :spinning="submitted" style="margin-top: 16px;">
<a-form layout="vertical" :model="postData" :label-col="labelCol" :wrapper-col="wrapperCol"
ref="formRef" :disabled="isViewMode">
<title-divider title="活动基本信息"></title-divider>
<a-form-item name="activityName" label="活动名称"
:rules="[{ required: true, message: '请输入活动名称' }]">
<a-input v-model:value="postData.activityName" class="wid_376" :maxlength="30"
placeholder="请输入优惠券名称或进行模糊" />
</a-form-item>
<a-form-item name="activityId" label="活动ID" v-if="pageState !== 'ADD'">
<a-input v-model:value="postData.activityId" disabled class="wid_376" placeholder="AC1001" />
</a-form-item>
<a-form-item name="activityRange" label="活动有效期"
:rules="[{ required: true, type: 'array', message: '请选择开始日期和结束日期' }]">
<a-range-picker v-model:value="postData.activityRange" :format="'YYYY-MM-DD'" class="wid_376"
:placeholder="['开始日期', '结束日期']" />
<div class="form-tip">此时间不等于用户领到券后的使用有效期,券的使用有效期由优惠券模板定义</div>
</a-form-item>
<a-form-item name="activityDesc" label="活动备注">
<a-textarea v-model:value="postData.activityDesc" show-count :maxlength="200"
placeholder="可填写活动的背景、目的、负责人等信息,仅后台可见" :rows="4" style="width: 580px;" />
</a-form-item>
<a-form-item name="agreementId" label="关联活动说明"
:rules="[{ required: true, message: '请选择关联活动说明' }]">
<div class="relation-row">
<a-select v-model:value="postData.agreementId" show-search option-filter-prop="label" class="wid_376"
placeholder="请选择活动规则/协议">
<a-select-option v-for="item in relationAgreementOptions" :label="item.agreementName" :value="item.agreementId" :key="item.agreementId">{{ item.agreementName }}</a-select-option>
</a-select>
<a-button class="relation-preview-btn" @click="handlePreviewAgreement"
:disabled="!currentRelationAgreement">
<EyeOutlined style="margin-right: 4px;" />
预览
</a-button>
</div>
<div class="form-tip">此内容将在小程序活动详情页展示,作为活动的正式规则说明</div>
</a-form-item>
<a-form-item name="sendNotification" label="是否发送活动通知">
<a-switch v-model:checked="postData.sendNotification" :checked-value="1" :un-checked-value="2" />
<div class="form-tip">开启后,满足条件的用户进入小程序首页时,会弹出活动提醒弹窗</div>
</a-form-item>
<title-divider title="活动策略配置"></title-divider>
<a-form-item name="activityType" label="发放策略"
:rules="[{ required: true, message: '请选择发放策略' }]">
<a-radio-group v-model:value="postData.activityType" @change="handleActivityTypeChange">
<a-radio :value="1">自动触发发放</a-radio>
<a-radio :value="2">直接发放</a-radio>
</a-radio-group>
</a-form-item>
<template v-if="postData.activityType === 1">
<a-form-item name="triggerTime" label="触发时机">
<div>订单完结时</div>
<div class="form-tip">当车商拍下车辆并完成过户(订单状态变更为"已完结")时,系统根据订单最终成交价匹配规则并发放优惠券</div>
</a-form-item>
<a-form-item label="触发规则列表" required>
<div class="rule-wrap">
<div class="rule-header">
<a-button v-if="!isViewMode" type="link" @click="addTriggerRule">+ 添加规则</a-button>
</div>
<div v-for="(rule, index) in postData.priceRanges" :key="rule._key" class="rule-item">
<div class="rule-item-title">
<div class="rule-item-name">规则{{ index + 1 }}</div>
<a-button v-if="index > 0 && !isViewMode" type="link" danger class="rule-delete"
@click="removeTriggerRule(index)">删除</a-button>
</div>
<div class="rule-row">
<div class="rule-label">价格区间(元)</div>
<div class="rule-fields">
<a-form-item :name="['priceRanges', index, 'priceMin']"
:rules="priceMinRules(index)" :validateFirst="true" validate-trigger="blur" class="rule-price-item">
<a-input v-model:value="rule.priceMin" class="wid_376" placeholder="下限(含)"
@input="handlePositiveIntNativeInput(index, 'priceMin', $event)" />
</a-form-item>
<div class="rule-split">≤ 成交价 &lt;</div>
<a-form-item :name="['priceRanges', index, 'priceMax']"
:rules="priceMaxRules(index)" :validateFirst="true" validate-trigger="blur" class="rule-price-item">
<a-input v-model:value="rule.priceMax" class="wid_376" placeholder="上限(不含)"
@input="handlePositiveIntNativeInput(index, 'priceMax', $event)" />
</a-form-item>
</div>
</div>
<div class="rule-row">
<div class="rule-label">选择优惠券</div>
<div class="rule-fields single">
<a-form-item :name="['priceRanges', index, 'templateId']"
:rules="[{ required: true, message: '请选择优惠券' }]">
<a-select v-model:value="rule.templateId" style="width: 840px;" placeholder="请选择优惠券"
show-search :options="couponTemplateOptions" />
</a-form-item>
<div v-if="getCouponBrief(rule.templateId)" class="coupon-brief">
{{ getCouponBrief(rule.templateId) }}
</div>
</div>
</div>
</div>
</div>
</a-form-item>
</template>
<template v-else>
<a-form-item name="templateId" label="选择优惠券"
:rules="[{ required: true, message: '请选择优惠券' }]">
<a-select v-model:value="postData.templateId" class="wid_376" placeholder="请选择优惠券"
show-search :options="couponTemplateOptions" />
<div v-if="getCouponBrief(postData.templateId)" class="coupon-brief">
{{ getCouponBrief(postData.templateId) }}
</div>
</a-form-item>
<a-form-item name="distributionQuantity" label="发放数量"
:rules="distributionQuantityRules" :validateFirst="true" validate-trigger="blur">
<div class="input-affix inline-row affix-suffix-only">
<span class="affix suffix">张/人</span>
<a-input v-model:value="postData.distributionQuantity" class="wid_376"
placeholder="请输入数量" @input="handlePerUserQuantityInput" />
</div>
</a-form-item>
</template>
<template v-if="postData.activityType === 1">
<div class="crowd_box">
<span class="label">生效人群:</span>
<span>触发订单的买家</span>
</div>
</template>
<template v-if="postData.activityType === 2">
<a-form-item name="crowdName" label="生效人群">
<a-radio-group v-model:value="postData.applicableType" placeholder="请输入适用人群" button-style="solid">
<template v-for="applicableType in applicableTypes" :key="applicableType">
<a-radio-button :value="applicableType">{{ $t('enum.commissionRule.applicableType.' + applicableType) }}</a-radio-button>
</template>
</a-radio-group>
</a-form-item>
<a-form-item v-if="postData.applicableType==='ACCOUNT'" label="指定用户" name="accounts" :rules="[{ required: true, message: '请选择要添加的指定用户!' }]">
<a-button type="default" style="margin-bottom: 8px;" @click="showAccountSelector">选择用户</a-button>
<div class="list-content" v-if="postData.accounts">
<a-list :data-source="postData.accounts" size="small" :bordered="false">
<template #renderItem="{ item,index }">
<a-list-item>
<template #actions>
<account-type-tag :account-type="item.accountType"></account-type-tag>
<a-button type="link" @click="removeAccount(index)">删除</a-button>
</template>
<a-list-item-meta>
<template #title>
{{ item.accountName }}
<a-divider type="vertical"/>
{{ item.nickName }}
</template>
<template #description>
{{ item.mobile }}
</template>
<template #avatar>
<a-avatar :src="item.avatar?.url" :size="42"></a-avatar>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</div>
</a-form-item>
<a-form-item v-if="postData.applicableType==='TAG'" label="选择标签" name="accountTags" :rules="[{ required: true, message: '请选择要添加的标签!' }]">
<a-select v-model:value="postData.accountTags" mode="multiple" placeholder="请选择要添加的标签" option-filter-prop="label" :labelInValue="true" show-search>
<a-select-option v-for="item in tags" :value="item.tagId" :key="item.tagId" :label="item.tagName">
<span role="img" :aria-label="item.color" :style="{backgroundColor:item.color}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
&nbsp;&nbsp;
{{ item.tagName }}
</a-select-option>
</a-select>
</a-form-item>
</template>
</a-form>
</a-spin>
</a-drawer>
</div>
</template>
<script lang="ts">
import { Component } from "vue-facing-decorator";
import { message } from "ant-design-vue";
import { EnhanceFormComponent } from "@/core/form/EnhanceFormComponent";
import TitleDivider from "@/components/TitleDivider.vue";
import ViewAgreement from "@/views/business/agreement/ViewAgreement.vue";
import { EyeOutlined } from "@ant-design/icons-vue";
import { ModalService } from "@/components/ModalService";
import { AgreementController } from "@/api/AgreementController";
import { DiscountController } from "@/api/DiscountController";
import { formatDate, parseDate } from "lib/src/utils/DateTimeUtils";
import { COMMISSION_RULE_APPLICABLE_TYPES, CommissionRule } from "lib/src/entity/account/entity/CommissionRule";
import AccountPicker from "@/views/account/account/AccountPicker.vue";
import {AccountTag} from "lib/src/entity/account/entity/AccountTag";
import AccountTypeTag from "@/views/account/account/tag/AccountTypeTag.vue";
import {AccountController} from "@/api/AccountController";
type OptionItem = { label: string; value: string; brief?: string };
type AgreementOption = { agreementId?: string; agreementName?: string; agreement?: any; content?: string; label?: string; value?: string };
@Component({
components: { TitleDivider, ViewAgreement, EyeOutlined, AccountTypeTag },
})
export default class DiscountActivityAddForm extends EnhanceFormComponent<any> {
applicableTypes = COMMISSION_RULE_APPLICABLE_TYPES;
couponTemplateOptions: OptionItem[] = [];
relationAgreementOptions: AgreementOption[] = [];
activeAutoActivities: any[] = [];
dialogVisible = false;
titleVisible = "创建发放活动";
pageState: "ADD" | "EDIT" | "VIEW" | "COPY" = "ADD";
labelCol = { xs: 24, sm: 24, md: 24 };
wrapperCol = { xs: 24, sm: 24, md: 24 };
crowdModalOpen = false;
triggerRuleKeySeed = 0;
postData: any = {};
initPostData = {
activityId: "",
activityName: "",
activityRange: [],
activityDesc: "",
relationRemark: "",
agreementId: undefined as any,
sendNotification: 1,
activityType: 1,
triggerTime: "",
priceRanges: [{ priceMin: "", priceMax: "", templateId: undefined as any, _key: "rule_0" }],
templateId: undefined as any,
distributionQuantity: "",
crowdId: "",
crowdName: "",
applicableType: "ACCOUNT"
};
tags: AccountTag[] = [];
get isViewMode() {
return this.pageState === "VIEW";
}
get triggerTimeOptions() {
return [
{ label: "订单完成时", value: "ORDER_COMPLETED" },
];
}
get currentRelationAgreement() {
const id = this.postData.agreementId;
if (id === null || id === undefined || id === "") return null;
return this.relationAgreementOptions.find(item => String((item as any)?.agreementId ?? (item as any)?.value) === String(id)) || null;
}
genTriggerRuleKey() {
this.triggerRuleKeySeed += 1;
return `rule_${Date.now()}_${this.triggerRuleKeySeed}`;
}
parsePositiveInt(val: any) {
if (val === null || val === undefined || val === "") return null;
const num = typeof val === "number" ? val : Number(String(val));
if (!Number.isFinite(num)) return null;
if (!Number.isInteger(num) || num <= 0) return null;
return num;
}
isOverlap(aMin: number, aMax: number, bMin: number, bMax: number) {
return aMin < bMax && bMin < aMax;
}
isTriggerRangeOverlapped(currentIndex: number, min: number, max: number) {
const rules = Array.isArray(this.postData.priceRanges) ? this.postData.priceRanges : [];
for (let i = 0; i < rules.length; i += 1) {
if (i === currentIndex) continue;
const otherMin = this.parsePositiveInt(rules[i]?.priceMin);
const otherMax = this.parsePositiveInt(rules[i]?.priceMax);
if (otherMin === null || otherMax === null) continue;
if (!(otherMax > otherMin)) continue;
if (this.isOverlap(min, max, otherMin, otherMax)) return true;
}
return false;
}
priceMinRules(index: number) {
return [
{ required: true, message: "请输入下限" },
{
validator: async (_rule: any, value: any) => {
if (value === null || value === undefined || value === "") {
return Promise.resolve();
}
const min = this.parsePositiveInt(value);
if (min === null) {
return Promise.reject(new Error("下限必须为正整数"));
}
const max = this.parsePositiveInt(this.postData.priceRanges?.[index]?.priceMax);
if (max !== null && !(max > min)) {
return Promise.reject(new Error("上限值必须大于下限值"));
}
if (max !== null && this.isTriggerRangeOverlapped(index, min, max)) {
return Promise.reject(new Error("价格区间不可重叠"));
}
return Promise.resolve();
},
},
];
}
priceMaxRules(index: number) {
return [
{ required: true, message: "请输入上限" },
{
validator: async (_rule: any, value: any) => {
if (value === null || value === undefined || value === "") {
return Promise.resolve();
}
const max = this.parsePositiveInt(value);
if (max === null) {
return Promise.reject(new Error("上限必须为正整数"));
}
const min = this.parsePositiveInt(this.postData.priceRanges?.[index]?.priceMin);
if (min !== null && !(max > min)) {
return Promise.reject(new Error("上限值必须大于下限值"));
}
if (min !== null && this.isTriggerRangeOverlapped(index, min, max)) {
return Promise.reject(new Error("价格区间不可重叠"));
}
return Promise.resolve();
},
},
];
}
get distributionQuantityRules() {
return [
{ required: true, message: "请输入发放数量" },
{
validator: async (_rule: any, value: any) => {
if (value === null || value === undefined || value === "") {
return Promise.resolve();
}
const n = this.parsePositiveInt(value);
if (n === null) {
return Promise.reject(new Error("发放数量必须为正整数"));
}
return Promise.resolve();
},
},
];
}
handlePositiveIntNativeInput(index: number, field: "priceMin" | "priceMax", e: any) {
const raw = e?.target?.value ?? "";
const next = String(raw).replace(/[^\d]/g, "").replace(/^0+/, "");
if (this.postData.priceRanges?.[index]) {
this.postData.priceRanges[index][field] = next;
}
}
handlePerUserQuantityInput(e: any) {
const raw = e?.target?.value ?? "";
this.postData.distributionQuantity = String(raw).replace(/[^\d]/g, "").replace(/^0+/, "") || "";
}
getCouponBrief(templateId: any) {
const id = String(templateId || "");
if (!id) return "";
const opt = (this.couponTemplateOptions || []).find(item => String(item.value) === id);
return String(opt?.brief ?? "");
}
showAccountSelector(): void {
const ids = this.postData.accounts?.map(account => account.accountId) ?? [];
const modal = ModalService.confirm({
title: '选择用户', component: AccountPicker, closable: true, appContext: this.$.appContext,
props: {ids: ids},
onOk: (component): void => {
component.selectAccounts();
},
emits: {
handleOk: (accounts: Account[]) => {
modal.destroy();
if (!this.postData.accounts) {
this.postData.accounts = [];
}
if (accounts) {
for (const account of accounts) {
const exist = this.postData.accounts.some(item => item.accountId === account.accountId);
if (!exist) {
this.postData.accounts.push(account);
}
}
}
}
},
});
}
removeAccount(account: Account): void {
this.postData.accounts.splice(this.postData.accounts.indexOf(account), 1);
}
init(data: any): void {
this.postData = JSON.parse(JSON.stringify(this.initPostData));
// 获取协议数据
AgreementController.pageAgreement(this.axios, { limit: 9999 }).then(res => {
this.relationAgreementOptions = Array.isArray(res.data?.content) ? res.data?.content : [];
})
// 获取优惠券模板数据
DiscountController.couponTemplatePage(this.axios, { limit: 9999 }).then(res => {
const templates = Array.isArray(res.data?.content) ? res.data?.content : [];
this.couponTemplateOptions = templates.map(t => ({
label: t.templateName,
value: t.id
}))
})
// 获取人群标签数据
AccountController.getAccountTags(this.axios).then(res => {
this.tags = res.data;
});
const pageState = data?.pageState;
this.pageState = pageState === "VIEW" ? "VIEW" : pageState === "ADD" ? "ADD" : pageState === "COPY" ? "COPY" : "EDIT";
this.titleVisible = (this.pageState === "ADD" || this.pageState === "COPY") ? "创建发放活动" : (this.pageState === "VIEW" ? "查看发放活动" : "编辑发放活动");
if (pageState !== 'ADD') {
DiscountController.couponActivityDetail(this.axios, { id: data?.id }).then(res => {
let responseData = res.data.data as any;
if (responseData) {
responseData = {
...responseData,
activityRange: responseData.validStartTime && responseData.validEndTime ? [parseDate(responseData.validStartTime), parseDate(responseData.validEndTime)] : [],
applicableType: responseData?.targetType == 1 ? 'ALL' : responseData?.targetType == 2 ? 'ACCOUNT' : 'ACCOUNT',
activityName: this.pageState === "COPY" ? `${responseData.activityName}_副本` : responseData.activityName,
}
}
this.postData = responseData
})
}
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs.formRef?.clearValidate()
})
}
onClose() {
this.dialogVisible = false;
}
openCrowdModal() {
if (this.isViewMode) return;
this.crowdModalOpen = true;
}
handleCrowdOk() {
if (!this.postData.crowdId) {
this.postData.crowdId = "TEMP";
this.postData.crowdName = "已选择人群";
}
this.crowdModalOpen = false;
const formRef: any = (this.$refs as any)?.formRef;
if (formRef?.validateFields) {
formRef.validateFields(["crowdName"]).catch(() => undefined);
}
}
handlePreviewAgreement() {
const option = this.currentRelationAgreement;
if (!option) return;
const agreementFromOption = (option as any)?.agreement ?? option;
const agreement = {
agreementName: (agreementFromOption as any)?.agreementName ?? (option as any)?.agreementName ?? (option as any)?.label ?? "",
createBy: (agreementFromOption as any)?.createBy ?? "",
updateBy: (agreementFromOption as any)?.updateBy ?? "",
createTime: (agreementFromOption as any)?.createTime ?? "",
updateTime: (agreementFromOption as any)?.updateTime ?? "",
agreementKey: (agreementFromOption as any)?.agreementKey ?? "",
versionCode: (agreementFromOption as any)?.versionCode ?? "",
agreementState: (agreementFromOption as any)?.agreementState ?? "PUBLISHED",
versionDesc: (agreementFromOption as any)?.versionDesc ?? "",
content: (agreementFromOption as any)?.content ?? (option as any)?.content ?? "",
};
const modal = ModalService.confirm({
title: '协议预览',
component: ViewAgreement,
closable: true,
appContext: this.$.appContext,
props: {
agreement,
},
onOk: (): void => {
modal.destroy();
},
emits: {
handleOk: () => {
modal.destroy();
}
},
});
}
handleActivityTypeChange() {
if (this.postData.activityType === 1) {
this.postData.templateId = undefined;
this.postData.distributionQuantity = "";
if (!Array.isArray(this.postData.priceRanges) || this.postData.priceRanges.length === 0) {
this.postData.priceRanges = [{ priceMin: "", priceMax: "", templateId: undefined as any, _key: this.genTriggerRuleKey() }];
}
} else {
this.postData.triggerTime = "";
this.postData.priceRanges = [{ priceMin: "", priceMax: "", templateId: undefined as any, _key: this.genTriggerRuleKey() }];
}
}
addTriggerRule() {
if (this.isViewMode) return;
this.postData.priceRanges.push({ priceMin: "", priceMax: "", templateId: undefined as any, _key: this.genTriggerRuleKey() });
}
removeTriggerRule(index: number) {
if (this.isViewMode) return;
if (index === 0) return;
this.postData.priceRanges.splice(index, 1);
if (this.postData.priceRanges.length === 0) {
this.postData.priceRanges.push({ priceMin: "", priceMax: "", templateId: undefined as any, _key: this.genTriggerRuleKey() });
}
}
toNumberOrNull(value: unknown) {
if (value === null || value === undefined || value === "") return null;
const num = Number(value);
return Number.isFinite(num) ? num : null;
}
buildSubmitPayload() {
const [start, end] = this.postData.activityRange || [];
const payload: any = {
id: this.pageState === "COPY" ? undefined : (this.postData.id || undefined),
activityName: this.postData.activityName || undefined,
activityType: this.postData.activityType,
validStartTime: `${formatDate(start)} 00:00:00`,
validEndTime: `${formatDate(end)} 23:59:59`,
templateId: this.postData.templateId,
distributionQuantity: this.toNumberOrNull(this.postData.distributionQuantity),
agreementId: this.postData.agreementId,
targetType: this.postData.applicableType === "ALL" ? 1 : this.postData.applicableType === "ACCOUNT" ? 2 : 2,
sendNotification: this.postData.sendNotification,
priceRanges: this.postData.activityType === 1
? (this.postData.priceRanges || []).map((r: any) => ({
priceMin: this.toNumberOrNull(r.priceMin),
priceMax: this.toNumberOrNull(r.priceMax),
templateId: r.templateId,
}))
: [],
targetPhoneNumbers: this.postData.accounts?.map((account: any) => account.mobile) || [],
remark: this.postData.remark,
};
return payload;
}
handleOk() {
this.$refs.formRef.validate().then(() => {
this.submitted = true;
const payload = this.buildSubmitPayload()
console.log("submit payload", payload)
DiscountController[this.pageState === "EDIT" ? "updateCouponActivity" : "createCouponActivity"](this.axios, payload).then((res) => {
this.submitted = false;
let { code, message: msg } = res.data;
if (code !== '200') {
message.error(msg || "操作失败");
return;
}
message.success(this.pageState === "EDIT" ? "更新成功" : "创建成功");
this.$emit("emitOk", { ...this.postData });
this.dialogVisible = false;
}).catch((err: any) => {
this.submitted = false;
const msg = String(err?.message || "");
if (msg && msg.includes("保存失败!价格区间")) {
message.error(msg);
}
});
}).catch(() => {
})
}
}
</script>
<style scoped lang="less">
.manual-crowd-value {
margin-top: 8px;
line-height: 22px;
color: rgba(0, 0, 0, 0.65);
}
.wid_376 {
width: 376px;
}
.input-affix {
position: relative;
display: inline-block;
width: 376px;
}
.input-affix .affix {
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 2;
color: rgba(0, 0, 0, 0.45);
pointer-events: none;
white-space: nowrap;
}
.input-affix .affix.prefix {
left: 12px;
}
.input-affix .affix.suffix {
right: 12px;
}
.input-affix.affix-suffix-only :deep(.ant-input) {
padding-right: 60px;
}
.form-tip {
font-size: 12px;
color: #C4C7CC;
margin-top: 8px;
}
.relation-row {
display: flex;
align-items: center;
gap: 12px;
}
.relation-preview-btn {
display: inline-flex;
align-items: center;
}
.inline-row {
display: flex;
align-items: center;
gap: 12px;
}
.inline-suffix {
color: rgba(0, 0, 0, 0.65);
}
.rule-wrap {
border-radius: 8px;
position: relative;
}
.rule-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
position: absolute;
top: -34px;
right: 0;
}
.rule-title {
font-size: 14px;
font-weight: 500;
color: rgba(0, 0, 0, 0.85);
}
.rule-item {
background: #F5F7FA;
margin-bottom: 8px;
padding: 16px;
}
.rule-item + .rule-item {
margin-top: 12px;
}
.rule-item-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.rule-item-name {
font-size: 14px;
font-weight: 500;
color: rgba(0, 0, 0, 0.85);
}
.crowd_box {
padding: 14px 16px;
background: #1956FE1A;
color: #2F3133;
.label {
color: #777C85;
}
}
.rule-row {
// display: flex;
// align-items: flex-start;
// gap: 12px;
}
// .rule-row + .rule-row {
// margin-top: 12px;
// }
.rule-label {
width: 90px;
line-height: 32px;
color: rgba(0, 0, 0, 0.85);
}
.rule-fields {
display: flex;
align-items: flex-start;
gap: 12px;
flex: 1;
}
.rule-fields.single {
flex-direction: column;
}
.rule-split {
line-height: 32px;
color: rgba(0, 0, 0, 0.65);
}
.coupon-brief {
margin-top: 6px;
line-height: 20px;
color: rgba(0, 0, 0, 0.65);
}
.list-content {
height: 280px; /* 固定内容区域高度 */
overflow-y: auto; /* 内容滚动 */
}
</style>
......@@ -22,40 +22,96 @@
:row-key="record => record.id" :scroll="{ y: 'calc(100vh - 350px)' }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'couponType'">
{{couponTypeList.find(item => item.value === record.couponType)?.label || '-'}}
<template v-if="column.key === 'woId'">
<div v-if="record.validityType === 1">{{ record.validStartTime && record.validEndTime ? `${record.validStartTime?.substring(0, 10).replace(/-/g, '/')} 至 ${record.validEndTime?.substring(0, 10).replace(/-/g, '/')}` : '-' }}</div>
<div v-else>发放后{{ record.delayDays }}天生效,有效期{{ record.validDays }}天</div>
</template>
<template v-if="column.key === 'faceAmount'">
<div v-if="record.couponType === 1">{{ record.faceAmount }}</div>
<div v-else>
<a-tooltip placement="top">
<template #title>
<div class="price-ranges-tooltip">
<div v-for="(range, index) in record.tierRules" :key="index" class="range-item">
中拍价≥{{range.thresholdAmount}}元,抵扣{{ (range.deductionAmount) }}元
</div>
</div>
</template>
<span style="text-decoration: underline;">{{ record.faceAmount }}</span>
</a-tooltip>
</div>
</template>
<template v-if="column.key === 'relatedActivities'">
<div v-if="record.relatedActivities && record.relatedActivities.length === 1">
<a style="text-decoration: underline;" :href="`#/discount/activity?activityId=${record.relatedActivities[0].id}`" target="_blank">{{ record.relatedActivities[0].activityName }}</a>
</div>
<div v-else-if="record.relatedActivities && record.relatedActivities.length > 1">
<a style="text-decoration: underline;" :href="`#/discount/activity?activityId=${record.relatedActivities[0].id}`" target="_blank">关联{{ record.relatedActivities.length }}个活动</a>
</div>
<div v-else>-</div>
</template>
<template v-if="column.key === 'deductionType'">
{{deductionTypeList.find(item => item.value === record.deductionType)?.label || '-'}}
<a-tag :color="deductionTypeList.find(item => item.value === record.deductionType)?.color" :style="{ color: deductionTypeList.find(item => item.value === record.deductionType)?.textColor }"
:bordered="false">
{{deductionTypeList.find(item => item.value === record.deductionType)?.label || '-'}}
</a-tag>
</template>
<template v-if="column.key === 'remark'">
<a-tooltip :title="record.remark">
<div class="text_hide">{{ record.remark || '-' }}</div>
</a-tooltip>
</template>
<template v-if="column.key === 'status'">
{{statusList.find(item => item.value === record.status)?.label || '-'}}
<a-tag :color="statusList.find(item => item.value === record.status)?.color" :style="{ color: statusList.find(item => item.value === record.status)?.textColor }"
:bordered="false">
{{statusList.find(item => item.value === record.status)?.label || '-'}}
</a-tag>
</template>
<template v-if="column.key === 'updateTime'">
<div>{{ record.createTime }}</div>
<div style="color: #777C85">{{ record.updateTime }}</div>
</template>
<template v-if="column.key === 'action'">
<a-button type="link" @click="handleAdd({ ...record, pageState: 'EDIT' })"
size="small">编辑</a-button>
<a-button type="link" v-if="record.status === 1" danger @click="handleTurnOff(record)"
size="small">停用</a-button>
<a-button type="link" v-if="record.status === 2" @click="handleTurnOn(record)"
size="small" style="color: #00AD74">启用</a-button>
<a-tooltip v-if="getManualIssuanceState(record).disabled" :title="getManualIssuanceState(record).reason">
<span>
<a-button type="link" disabled size="small">手动发放</a-button>
</span>
</a-tooltip>
<a-button v-else type="link" @click="handleManualIssuance(record)" size="small">手动发放</a-button>
<a-button type="link" @click="handleAdd({ ...record, pageState: 'VIEW' })"
size="small">查看详情</a-button>
</template>
</template>
</a-table>
<CouponAddForm ref="couponAddFormRef" @emitOk="handlePageReload" />
<ManualIssuanceModal ref="manualIssuanceModalRef" @submitted="handleManualIssuanceSubmitted" :templateIdDisabled="true" />
</a-card>
</template>
<script lang="ts">
import { createVNode } from "vue";
import { Component } from 'vue-facing-decorator';
import { message, TableColumnsType } from "ant-design-vue";
import { message, Modal, TableColumnsType } from "ant-design-vue";
import { Operator, Order } from "lib/src/core/page/Pagination";
import { PaginationComponent } from "@/components/PaginationComponent";
import { Vehicle } from "lib/src/entity/vehicle/entity/Vehicle";
import { DetectionController } from "@/api/DetectionController";
import { DiscountController } from "@/api/DiscountController";
import CouponAddForm from "@/views/discount/coupon/components/CouponAddForm.vue";
import { PlusOutlined } from '@ant-design/icons-vue';
import ManualIssuanceModal from "@/views/discount/coupon/components/ManualIssuanceModal.vue";
import dayjs, { Dayjs } from "dayjs";
import { InfoCircleFilled, PlusOutlined } from '@ant-design/icons-vue';
@Component({
components: { PlusOutlined, CouponAddForm }
components: { PlusOutlined, CouponAddForm, ManualIssuanceModal }
})
export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
......@@ -66,13 +122,13 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
];
deductionTypeList = [
{ label: '抵扣车款', value: 1 },
{ label: '抵扣佣金', value: 2 },
{ label: '抵扣车款', value: 1, color: '#E9F2FC', textColor: '#2A82E4' },
{ label: '抵扣佣金', value: 2, color: '#F1ECFC', textColor: '#7948EA' },
];
statusList = [
{ label: '启用中', value: 1 },
{ label: '已停用', value: 2 },
{ label: '启用中', value: 1, color: '#E8F8F2', textColor: '#00A870' },
{ label: '已停用', value: 2, color: '#F0F2F5', textColor: '#777C85' },
];
/**
......@@ -80,22 +136,22 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
*/
columns: TableColumnsType = [
{
title: '序号', key: 'index', width: 70, align: 'center', sorter: false,
title: '序号', key: 'index', width: 70, align: 'left', sorter: false,
customRender: ({ index }) => {
return (this.getPagination().pageIndex - 1) * this.getPagination().pageSize + index + 1;
},
},
{ title: '优惠券ID', dataIndex: 'templateId', key: 'templateId', align: 'center', width: 150, resizable: true, ellipsis: true },
{ title: '优惠券名称', dataIndex: 'templateName', key: 'templateName', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '优惠券有效期', dataIndex: "woId", key: 'woId', align: 'center', width: 150, resizable: true, ellipsis: true },
{ title: '抵扣类型', dataIndex: 'deductionType', key: 'deductionType', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '面额/最高抵扣(元)', dataIndex: 'faceAmount', key: 'faceAmount', align: 'center', width: 240, resizable: true, ellipsis: true },
{ title: '关联活动数', dataIndex: ['vehicle', 'baseInfo', "licensePlate"], key: 'licensePlate', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '发放总量', dataIndex: 'totalQuantity', key: 'totalQuantity', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '优惠券说明', dataIndex: 'scoreLevel', key: 'scoreLevel', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '状态', dataIndex: 'status', key: 'status', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '创建/更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '操作', key: 'action', width: 170, align: 'center', fixed: 'right' },
{ title: '优惠券ID', dataIndex: 'templateId', key: 'templateId', align: 'left', width: 220, resizable: true, ellipsis: true },
{ title: '优惠券名称', dataIndex: 'templateName', key: 'templateName', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '优惠券有效期', dataIndex: "woId", key: 'woId', align: 'left', width: 200, resizable: true, ellipsis: true },
{ title: '抵扣类型', dataIndex: 'deductionType', key: 'deductionType', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '面额/最高抵扣(元)', dataIndex: 'faceAmount', key: 'faceAmount', align: 'left', width: 240, resizable: true, ellipsis: true },
{ title: '关联活动数', dataIndex: 'relatedActivities', key: 'relatedActivities', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '发放总量', dataIndex: 'totalQuantity', key: 'totalQuantity', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '备注', dataIndex: 'remark', key: 'remark', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '状态', dataIndex: 'status', key: 'status', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '创建/更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '操作', key: 'action', width: 250, align: 'left', fixed: 'right' },
];
getPagination() {
......@@ -106,7 +162,7 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
* 初始化配置
*/
created(): void {
this.init(this.axios, DetectionController.PAGE_INSPECTOR_REPORT);
this.init(this.axios, DiscountController.PAGE_COUPON_TEMPLATE)
this.buildQueryForm({
templateName: [null, { label: '优惠券名称', field: 'templateName', placeholder: '请输入优惠券名称', operator: Operator.like }],
templateId: [null, { label: '优惠券ID', field: 'templateId', placeholder: '请输入优惠券ID', operator: Operator.like }],
......@@ -130,10 +186,107 @@ export default class DiscountCouponPage extends PaginationComponent<Vehicle> {
}
handleAdd(data) {
this.$refs.couponAddFormRef.init(data);
this.$refs.couponAddFormRef.init({ ...data });
}
handleTurnOff(record: any) {
Modal.confirm({
title: "确认停用",
icon: createVNode(InfoCircleFilled, { style: { color: "#1956FE" } }),
content: createVNode("div", { style: { lineHeight: "22px" } }, [
createVNode(
"p",
{ style: { marginBottom: "8px" } },
"确认停用吗?"
),
createVNode(
"p",
{ style: { marginBottom: "8px" } },
"停用后,当前优惠券将无法被新的发放活动关联,且已关联的【自动发放】活动同步停售。"
),
createVNode(
"p",
{ style: { marginBottom: "8px" } },
"注意:此操作不影响已成功发放给用户的优惠券,用户仍可按原规则正常使用。"
),
]),
okText: "确认停用",
cancelText: "取消",
onOk: () => {
DiscountController.couponTemplateChangeStatus(this.axios, { id: record?.id, status: 2 }).then(() => {
message.success("操作成功");
this.pageReload();
})
},
});
}
handleTurnOn(record: any) {
DiscountController.couponTemplateChangeStatus(this.axios, { id: record?.id, status: 1 }).then(() => {
message.success('已启用优惠券');
this.pageReload();
})
}
handleManualIssuance(record: any) {
const modalRef: any = (this.$refs as any)?.manualIssuanceModalRef;
if (modalRef?.openByRecord) {
modalRef.openByRecord(record);
}
}
getManualIssuanceState(record: any) {
const status = Number(record?.status);
if (status !== 1) {
return { disabled: true, reason: "该券已停用,无法手动发放" };
}
const validityType = Number(record?.validityType);
if (validityType === 1) {
const now = Date.now();
const startMs = this.getFixedValidityTimeMs(record?.validStartTime, "start");
const endMs = this.getFixedValidityTimeMs(record?.validEndTime, "end");
if (typeof startMs === "number" && now < startMs) {
return { disabled: true, reason: "该券未生效,无法手动发放" };
}
if (typeof endMs === "number" && now > endMs) {
return { disabled: true, reason: "该券已过期,无法手动发放" };
}
}
if ((record?.remainingQuantity ?? '') === '') {
return { disabled: false, reason: "" };
}
const remainingQuantity = Number(record?.remainingQuantity ?? 0);
if (!(remainingQuantity > 0)) {
return { disabled: true, reason: "剩余库存不足,无法手动发放" };
}
return { disabled: false, reason: "" };
}
getFixedValidityTimeMs(input: any, type: "start" | "end") {
const raw = String(input ?? "").trim();
if (!raw) return undefined;
const d = dayjs(raw);
if (!d.isValid()) return undefined;
if (raw.length <= 10) {
return type === "end" ? d.endOf("day").valueOf() : d.startOf("day").valueOf();
}
return d.valueOf();
}
handleManualIssuanceSubmitted() {
this.pageReload();
}
}
</script>
<style scoped lang="less"></style>
<style scoped lang="less">
.text_hide {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
<template>
<div>
<a-drawer width="680" :title="titleVisible" placement="right" :open="dialogVisible" @close="onClose">
<a-drawer width="936" :title="titleVisible" :maskClosable="false" :keyboard="false" placement="right" :open="dialogVisible" @close="onClose">
<template #extra>
<a-space>
<a-space v-if="!isViewMode">
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="handleOk()">保存</a-button>
<a-button type="primary" @click="handleOk()">创建</a-button>
</a-space>
<a-space v-else>
<a-button type="primary" @click="onClose">返回</a-button>
</a-space>
</template>
<a-spin :spinning="submitted" style="margin-top: 16px;">
<a-form layout="vertical" :model="postData" :label-col="labelCol" :wrapper-col="wrapperCol"
ref="formRef">
ref="formRef" :disabled="isViewMode">
<title-divider title="基础信息"></title-divider>
<a-form-item name="couponType" label="优惠券类型" :rules="[{ required: true, message: '请选择优惠券类型' }]">
<a-select v-model:value="postData.couponType" style="width: 100%;">
<a-select-option value="1">固定面额券</a-select-option>
<a-select-option value="2">阶梯满减券</a-select-option>
</a-select>
<a-radio-group v-model:value="postData.couponType" @change="handleCouponTypeChange">
<a-radio :value="1">固定面额券</a-radio>
<a-radio :value="2">阶梯满减券</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item name="templateName" label="优惠券名称" :rules="[{ required: true, message: '请输入优惠券名称' }]">
<a-input v-model:value="postData.templateName" maxlength="100" placeholder="请输入优惠券名称" />
<a-form-item name="templateName" label="优惠券名称" :rules="templateNameRules" validate-trigger="blur">
<a-input v-model:value="postData.templateName" class="wid_376" :maxlength="20" placeholder="请输入优惠券名称" @blur="handleTemplateNameBlur" />
</a-form-item>
<a-form-item name="totalQuantity" label="发放总量" :rules="[{ required: true, message: '请选择发放总量' }]">
<a-select v-model:value="postData.totalQuantity" style="width: 100%;">
<a-select-option value="1">不限制</a-select-option>
<a-select-option value="2">固定数量</a-select-option>
</a-select>
<a-form-item name="totalQuantityType" label="发放总量" :rules="[{ required: true, message: '请选择发放总量' }]">
<div class="inline-row nowrap-row">
<a-radio-group class="nowrap-radio" v-model:value="postData.totalQuantityType"
@change="handleTotalQuantityTypeChange">
<a-radio :value="1">不限制</a-radio>
<a-radio :value="2">固定数量</a-radio>
</a-radio-group>
<a-form-item v-if="postData.totalQuantityType === 2" name="totalQuantity" :rules="totalQuantityRules" validate-trigger="blur" class="inline-embed-item">
<a-input v-model:value="postData.totalQuantity"
placeholder="请输入数量" style="width: 190px;" @input="handleIntNativeInput('totalQuantity', $event)" />
</a-form-item>
</div>
</a-form-item>
<title-divider title="抵扣规则"></title-divider>
<a-form-item name="remark" label="使用说明">
<a-textarea v-model:value="postData.remark" show-count :maxlength="200"
<a-form-item v-if="postData.couponType === 1" name="faceAmount" label="券面额"
:rules="faceAmountRules" validate-trigger="blur">
<div class="input-affix wid_376 affix-suffix-only">
<span class="affix suffix">元</span>
<a-input v-model:value="postData.faceAmount"
placeholder="请输入面额" @input="handleDecimalNativeInput('faceAmount', $event)" />
</div>
</a-form-item>
<a-form-item v-if="postData.couponType === 1" name="thresholdAmount" label="使用门槛"
:rules="thresholdAmountRules" validate-trigger="blur">
<div class="input-affix wid_376 affix-both">
<span class="affix prefix">中拍价满</span>
<span class="affix suffix">元</span>
<a-input v-model:value="postData.thresholdAmount" placeholder="0代表无门槛" @input="handleDecimalNativeInput('thresholdAmount', $event)" />
</div>
</a-form-item>
<template v-if="postData.couponType === 2">
<a-form-item name="faceAmount" label="券面额" :rules="ladderDisplayAmountRules" validate-trigger="blur">
<div class="input-affix wid_376 affix-suffix-only">
<span class="affix suffix">元</span>
<a-input v-model:value="postData.faceAmount"
placeholder="请输入券面额" :disabled="isLadderDisplayAmountDisabled" @input="handleDecimalNativeInput('faceAmount', $event)" @blur="handleLadderDisplayAmountBlur" />
</div>
<div v-if="isLadderDisplayAmountDisabled" class="form-tip">已自动提取阶梯规则中的最高抵扣金额作为券面额</div>
</a-form-item>
<a-form-item label="阶梯规则配置" required>
<div class="ladder-wrap">
<div v-for="(item, index) in postData.tierRules" :key="item._key" class="ladder-row">
<span class="ladder-label">中拍价≥</span>
<a-form-item :name="['tierRules', index, 'thresholdAmount']"
:rules="ladderThresholdRules(index)" validate-trigger="blur" class="ladder-field">
<a-input v-model:value="item.thresholdAmount"
placeholder="门槛价" style="width: 322px;" @input="handleLadderDecimalNativeInput(index, 'thresholdAmount', $event)" @blur="handleLadderThresholdBlur(index)" />
</a-form-item>
<span class="ladder-text">元,抵扣</span>
<a-form-item :name="['tierRules', index, 'deductionAmount']"
:rules="ladderDeductionRules(index)" validate-trigger="blur" class="ladder-field">
<a-input v-model:value="item.deductionAmount"
placeholder="抵扣金额" style="width: 322px;" @input="handleLadderDecimalNativeInput(index, 'deductionAmount', $event)" @blur="handleLadderDeductionBlur(index)" />
</a-form-item>
<span class="ladder-text">元</span>
<a-button v-if="index > 0 && !isViewMode" type="text" class="ladder-delete" @click="removeLadder(index)">
<CloseOutlined />
</a-button>
</div>
<div class="ladder-tips">最多可添加5个阶梯。当车辆中拍价满足多个阶梯时,适用最高门槛的优惠规则。</div>
<div class="ladder-footer" v-if="canAddLadder">
<a-button v-if="!isViewMode" type="link" @click="addLadder">+ 添加阶梯</a-button>
</div>
</div>
</a-form-item>
</template>
<title-divider title="使用规则"></title-divider>
<a-form-item name="validityType" label="优惠券有效期" :rules="[{ required: true, message: '请选择优惠券有效期' }]">
<a-radio-group class="validity-radio-group" v-model:value="postData.validityType"
@change="handleValidityTypeChange">
<div class="validity-row">
<a-radio :value="1">固定时间</a-radio>
<div v-if="postData.validityType === 1" class="validity-option-content">
<a-form-item name="validityRange" class="validity-embed-item"
:rules="[{ required: true, type: 'array', message: '请选择开始日期和结束日期' }]">
<a-range-picker v-model:value="postData.validityRange" :format="'YYYY-MM-DD'"
class="wid_376" :placeholder="['开始日期', '结束日期']" />
</a-form-item>
</div>
</div>
<div class="validity-row">
<a-radio :value="2">相对时间</a-radio>
<div v-if="postData.validityType === 2" class="validity-option-content">
<a-form-item name="delayDays" class="relative-embed-item"
:rules="delayDaysRules" validate-trigger="blur">
<div class="input-affix wid_184 affix-delay">
<span class="affix prefix">发放</span>
<span class="affix suffix">天后生效</span>
<a-input v-model:value="postData.delayDays" class="wid_184"
@input="handleIntNativeInput('delayDays', $event)" />
</div>
</a-form-item>
<a-form-item name="validDays" class="relative-embed-item"
:rules="validDaysRules" validate-trigger="blur">
<div class="input-affix wid_184 affix-valid">
<span class="affix prefix">有效期</span>
<span class="affix suffix">天</span>
<a-input v-model:value="postData.validDays" class="wid_184"
@input="handleIntNativeInput('validDays', $event)" />
</div>
</a-form-item>
</div>
</div>
</a-radio-group>
</a-form-item>
<a-form-item name="deductionType" label="抵扣类型" :rules="[{ required: true, message: '请选择抵扣类型' }]">
<a-radio-group v-model:value="postData.deductionType">
<a-radio :value="1">抵扣车款</a-radio>
<a-radio :value="2">抵扣佣金</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item name="description" label="使用说明" :rules="[{ required: true, message: '请输入优惠券使用说明' }]">
<a-textarea v-model:value="postData.description" show-count :maxlength="200"
placeholder="请输入优惠券使用说明,此内容将展示给前端用户" :rows="4" style="width: 580px;" />
</a-form-item>
<a-form-item name="remark" label="备注">
<a-textarea v-model:value="postData.remark" show-count :maxlength="200"
placeholder="仅用于后台运营人员记录信息,不会展示给前端用户" :rows="4" style="width: 580px;" />
</a-form-item>
</a-form>
</a-spin>
</a-drawer>
......@@ -45,50 +160,759 @@
</template>
<script lang="ts">
import { Component } from 'vue-facing-decorator';
import { nextTick } from "vue";
import { Component, Watch } from "vue-facing-decorator";
import { EnhanceFormComponent } from "@/core/form/EnhanceFormComponent";
import { message } from "ant-design-vue";
import { User } from "lib/src/entity/security/entity/User";
import TitleDivider from "@/components/TitleDivider.vue";
import { formatDate, parseDate } from "lib/src/utils/DateTimeUtils";
import { CloseOutlined } from "@ant-design/icons-vue";
import { DiscountController } from "@/api/DiscountController";
@Component({
components: { TitleDivider }
components: { TitleDivider, CloseOutlined }
})
export default class CouponAddForm extends EnhanceFormComponent<User> {
export default class CouponAddForm extends EnhanceFormComponent<any> {
dialogVisible = false;
titleVisible = "创建优惠券";
pageState: "ADD" | "EDIT" | "VIEW" = "ADD";
ladderKeySeed = 0;
pageData = {};
labelCol = { xs: 24, sm: 24, md: 24 };
wrapperCol = { xs: 24, sm: 24, md: 24 };
originalTemplateName = "";
isLadderDisplayAmountManuallyEditing = false;
postData: any = {};
//提交数据
postData = {
id: "",
inspectionAddress: "",
initPostData = {
templateId: "",
couponType: 1,
templateName: "",
totalQuantityType: 1,
totalQuantity: null,
faceAmount: null,
thresholdAmount: null,
tierRules: [{ thresholdAmount: null, deductionAmount: null, _key: "ladder_0" }],
validityType: 1,
validityRange: [],
delayDays: "",
validDays: "",
deductionType: 2,
description: "",
remark: "",
}
init(data): void {
this.pageData = data || {};
this.titleVisible = data.pageState === 'ADD' ? '创建优惠券' : '编辑优惠券';
this.postData = JSON.parse(JSON.stringify(this.initPostData));
this.pageState = data.pageState === "VIEW" ? "VIEW" : (data.pageState === "ADD" ? "ADD" : "EDIT");
this.titleVisible = this.pageState === "ADD" ? "创建优惠券" : (this.pageState === "VIEW" ? "查看优惠券" : "编辑优惠券");
if (["VIEW", "EDIT"].includes(data.pageState)) {
DiscountController.couponTemplateDetail(this.axios, { id: data?.id }).then(res => {
let responseData = res?.data?.data || {};
if (responseData) {
responseData.totalQuantityType = (responseData.totalQuantity ?? '') === '' ? 1 : 2
if (responseData.validStartTime && responseData.validEndTime) {
responseData.validityRange = [parseDate(responseData.validStartTime), parseDate(responseData.validEndTime)];
} else if (responseData.delayDays !== undefined || responseData.validDays !== undefined) {
responseData.delayDays = String(responseData.delayDays ?? "");
responseData.validDays = String(responseData.validDays ?? "");
}
if (responseData.couponType === 2 && Array.isArray(responseData.tierRules) && responseData.tierRules.length > 0) {
responseData.tierRules = responseData.tierRules.map((item: any, index: number) => ({
thresholdAmount: item.thresholdAmount ?? null,
deductionAmount: item.deductionAmount ?? null,
_key: `ladder_${Date.now()}_${index}`,
}));
}
}
this.postData = responseData
})
}
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs.formRef?.clearValidate()
})
}
get isViewMode() {
return this.pageState === "VIEW";
}
@Watch("postData.tierRules", { deep: true })
watchLadderRules() {
this.syncLadderDisplayAmount();
}
get canAddLadder() {
return this.postData.couponType === 2 && this.postData.tierRules.length < 5;
}
get isLadderDisplayAmountDisabled() {
return this.postData.couponType === 2 && this.postData.tierRules.length >= 2;
}
get templateNameRules() {
return [
{
required: true,
whitespace: true,
message: "请输入优惠券名称",
},
{
validator: async (_rule: any, value: unknown) => {
const name = String(value ?? "").trim();
if (name.length > 20) {
return Promise.reject(new Error("长度限制为1-20个字符"));
}
return Promise.resolve();
},
},
];
}
get ladderDisplayAmountRules() {
return [
{
required: true,
message: "请输入券面额",
},
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.couponType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.resolve();
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入券面额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
return Promise.resolve();
},
},
];
}
get delayDaysRules() {
return [
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.validityType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入生效天数"));
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入生效天数"));
if (!Number.isInteger(num) || num < 0) return Promise.reject(new Error("生效天数必须为大于等于0的整数"));
return Promise.resolve();
},
},
];
}
get validDaysRules() {
return [
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.validityType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入有效期天数"));
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入有效期天数"));
if (!Number.isInteger(num) || num <= 0) return Promise.reject(new Error("有效期必须为大于0的整数"));
return Promise.resolve();
},
},
];
}
get totalQuantityRules() {
return [
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.totalQuantityType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入发放数量"));
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入发放数量"));
if (!Number.isInteger(num) || num <= 0) return Promise.reject(new Error("必须为大于0的正整数"));
return Promise.resolve();
},
},
];
}
toNumberOrNull(value: unknown) {
if (value === null || value === undefined || value === "") return null;
const num = Number(value);
return Number.isFinite(num) ? num : null;
}
toIntOrNull(value: unknown) {
if (value === null || value === undefined || value === "") return null;
const num = Number(value);
if (!Number.isFinite(num)) return null;
return Number.isInteger(num) ? num : null;
}
sanitizeIntText(raw: string) {
return raw.replace(/[^\d]/g, "");
}
sanitizeDecimalText(raw: string, decimalScale = 2) {
const cleaned = raw.replace(/[^\d.]/g, "");
if (!cleaned) return "";
const firstDot = cleaned.indexOf(".");
if (firstDot === -1) return cleaned;
const intPart = cleaned.slice(0, firstDot);
let fracPart = cleaned.slice(firstDot + 1).replace(/\./g, "");
fracPart = fracPart.slice(0, decimalScale);
const nextInt = intPart === "" ? "0" : intPart;
return `${nextInt}.${fracPart}`;
}
getFormRef() {
return (this.$refs as any)?.formRef;
}
genLadderKey() {
this.ladderKeySeed += 1;
return `ladder_${Date.now()}_${this.ladderKeySeed}`;
}
clearLadderValidate() {
const formRef: any = this.getFormRef();
if (formRef?.clearValidate) {
const paths: any[] = [];
for (let i = 0; i < 5; i += 1) {
paths.push(["tierRules", i, "thresholdAmount"]);
paths.push(["tierRules", i, "deductionAmount"]);
}
formRef.clearValidate(paths);
}
}
validateLadderFields(namePaths: any[]) {
const formRef: any = this.getFormRef();
if (!formRef?.validateFields) return;
formRef.validateFields(namePaths).catch(() => undefined);
}
handleIntNativeInput(field: "totalQuantity" | "delayDays" | "validDays", event: any) {
const inputEl = event?.target as undefined | HTMLInputElement;
const raw = inputEl ? String(inputEl.value ?? "") : String(event ?? "");
const next = this.sanitizeIntText(raw);
if (inputEl && inputEl.value !== next) inputEl.value = next;
this.postData[field] = next;
}
handleDecimalNativeInput(field: "faceAmount" | "thresholdAmount", event: any) {
const inputEl = event?.target as undefined | HTMLInputElement;
const raw = inputEl ? String(inputEl.value ?? "") : String(event ?? "");
const next = this.sanitizeDecimalText(raw, 2);
if (inputEl && inputEl.value !== next) inputEl.value = next;
this.postData[field] = next;
}
handleLadderDecimalNativeInput(index: number, field: "thresholdAmount" | "deductionAmount", event: any) {
const inputEl = event?.target as undefined | HTMLInputElement;
const raw = inputEl ? String(inputEl.value ?? "") : String(event ?? "");
const row = this.postData.tierRules[index];
if (!row) return;
const next = this.sanitizeDecimalText(raw, 2);
if (inputEl && inputEl.value !== next) inputEl.value = next;
row[field] = next;
}
get faceAmountRules() {
return [
{
required: true,
message: "请输入券面额",
},
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.couponType !== 1) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.resolve();
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入券面额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
return Promise.resolve();
},
},
];
}
get thresholdAmountRules() {
return [
{
required: true,
message: "请输入使用门槛",
},
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.couponType !== 1) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.resolve();
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入使用门槛"));
if (num < 0) return Promise.reject(new Error("必须为非负数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
return Promise.resolve();
},
},
];
}
ladderThresholdRules(index: number) {
return [
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.couponType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入中拍价门槛"));
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入中拍价门槛"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
const prev = this.postData.tierRules[index - 1]?.thresholdAmount;
const prevNum = typeof prev === "number" ? prev : Number(prev);
if (index > 0 && Number.isFinite(prevNum) && !(num > prevNum)) {
return Promise.reject(new Error("中拍价门槛必须逐级递增"));
}
return Promise.resolve();
},
},
];
}
ladderDeductionRules(index: number) {
return [
{
validator: async (_rule: any, value: unknown) => {
if (this.postData.couponType !== 2) return Promise.resolve();
if (value === null || value === undefined || value === "") return Promise.reject(new Error("请输入抵扣金额"));
const num = typeof value === "number" ? value : Number(value);
if (!Number.isFinite(num)) return Promise.reject(new Error("请输入抵扣金额"));
if (num <= 0) return Promise.reject(new Error("必须为大于0的正数"));
const delta = Math.abs(num * 100 - Math.round(num * 100));
if (delta > 1e-9) return Promise.reject(new Error("最多支持小数点后两位"));
const threshold = this.postData.tierRules[index]?.thresholdAmount;
const thresholdNum = typeof threshold === "number" ? threshold : Number(threshold);
if (Number.isFinite(thresholdNum) && !(num < thresholdNum)) {
return Promise.reject(new Error("抵扣金额必须小于中拍价上限,请修正确保利润。"));
}
const prev = this.postData.tierRules[index - 1]?.deductionAmount;
const prevNum = typeof prev === "number" ? prev : Number(prev);
if (index > 0 && Number.isFinite(prevNum) && !(num > prevNum)) {
return Promise.reject(new Error("抵扣金额必须逐级递增"));
}
return Promise.resolve();
},
},
];
}
handleTemplateNameBlur() {
const formRef: any = (this.$refs as any)?.formRef;
if (formRef?.validateFields) {
formRef.validateFields(["templateName"]);
}
}
onClose() {
this.dialogVisible = false;
}
handleOk() {
this.$refs.formRef.validate().then((valid) => {
if (valid) {
this.$refs.formRef.validate().then(() => {
this.submitted = true;
const payload = this.buildSubmitPayload();
DiscountController[this.pageState === 'EDIT' ? 'editCouponTemplate' : 'createCouponTemplate'](this.axios, payload).then(res => {
let { code, message: msg } = res?.data || {};
if (code !== '200') {
message.error(msg || (this.pageState === 'EDIT' ? '更新失败' : '创建失败'));
return;
}
message.success(this.postData.templateId ? "更新成功" : "创建成功");
this.$emit("emitOk", payload);
this.dialogVisible = false;
})
}).finally(() => this.submitted = false);
}
buildSubmitPayload() {
const payload: any = {
id: this.postData.id || undefined,
templateId: this.postData.templateId || undefined,
couponType: this.postData.couponType,
templateName: this.postData.templateName,
totalQuantityType: this.postData.totalQuantityType,
totalQuantity: this.postData.totalQuantityType === 2 ? this.toIntOrNull(this.postData.totalQuantity) : null,
faceAmount: this.toNumberOrNull(this.postData.faceAmount),
thresholdAmount: this.postData.couponType === 1 ? this.toNumberOrNull(this.postData.thresholdAmount) : null,
tierRules: this.postData.couponType === 2
? this.postData.tierRules.map((r: any, i) => ({
tierLevel: i + 1,
thresholdAmount: this.toNumberOrNull(r.thresholdAmount),
deductionAmount: this.toNumberOrNull(r.deductionAmount),
}))
: [],
validityType: this.postData.validityType,
deductionType: this.postData.deductionType,
description: this.postData.description,
remark: this.postData.remark,
};
if (this.postData.validityType === 1) {
const [start, end] = this.postData.validityRange || [];
payload.validStartTime = `${formatDate(start)} 00:00:00`;
payload.validEndTime = `${formatDate(end)} 23:59:59`;
} else {
payload.delayDays = this.toIntOrNull(this.postData.delayDays);
payload.validDays = this.toIntOrNull(this.postData.validDays);
}
return payload;
}
addLadder() {
if (this.postData.tierRules.length >= 5) return;
this.postData.tierRules.push({ thresholdAmount: null, deductionAmount: null, _key: this.genLadderKey() });
this.syncLadderDisplayAmount();
nextTick(() => this.clearLadderValidate());
}
removeLadder(index: number) {
if (index === 0) return
this.postData.tierRules.splice(index, 1);
if (this.postData.tierRules.length === 0) {
this.postData.tierRules.push({ thresholdAmount: null, deductionAmount: null, _key: this.genLadderKey() });
}
this.syncLadderDisplayAmount();
nextTick(() => this.clearLadderValidate());
}
handleTotalQuantityTypeChange() {
if (this.postData.totalQuantityType !== 2) {
this.postData.totalQuantity = null;
} else {
const formRef: any = (this.$refs as any)?.formRef;
if (formRef?.validateFields) {
formRef.validateFields(["totalQuantity"]);
}
}
}
handleValidityTypeChange() {
if (this.postData.validityType !== 1) {
this.postData.validityRange = [];
}
}
handleCouponTypeChange() {
if (this.postData.couponType === 2) {
this.postData.tierRules = [{ thresholdAmount: null, deductionAmount: null, _key: this.genLadderKey() }];
} else {
this.postData.thresholdAmount = null;
this.postData.faceAmount = null;
this.isLadderDisplayAmountManuallyEditing = false;
this.syncLadderDisplayAmount();
}
}
handleLadderDisplayAmountBlur() {
if (this.postData.couponType !== 2) return;
if (this.postData.tierRules.length !== 1) return;
this.isLadderDisplayAmountManuallyEditing = true;
this.postData.tierRules[0].deductionAmount = this.postData.faceAmount;
this.validateLadderFields([["tierRules", 0, "deductionAmount"]]);
}
handleLadderThresholdBlur(index: number) {
if (this.postData.couponType !== 2) return;
const currentDeduction = this.postData.tierRules[index]?.deductionAmount;
const paths: any[] = [["tierRules", index, "thresholdAmount"]];
if (currentDeduction !== null && currentDeduction !== undefined && currentDeduction !== "") {
paths.push(["tierRules", index, "deductionAmount"]);
} else {
const formRef: any = this.getFormRef();
if (formRef?.clearValidate) {
formRef.clearValidate([["tierRules", index, "deductionAmount"]]);
}
}
if (index + 1 < this.postData.tierRules.length) {
const nextThreshold = this.postData.tierRules[index + 1]?.thresholdAmount;
if (nextThreshold !== null && nextThreshold !== undefined && nextThreshold !== "") {
paths.push(["tierRules", index + 1, "thresholdAmount"]);
} else {
const formRef: any = this.getFormRef();
if (formRef?.clearValidate) {
formRef.clearValidate([["tierRules", index + 1, "thresholdAmount"]]);
}
}
}
this.validateLadderFields(paths);
}
handleLadderDeductionBlur(index: number) {
if (this.postData.couponType !== 2) return;
const paths: any[] = [["tierRules", index, "deductionAmount"]];
if (index + 1 < this.postData.tierRules.length) {
const nextDeduction = this.postData.tierRules[index + 1]?.deductionAmount;
if (nextDeduction !== null && nextDeduction !== undefined && nextDeduction !== "") {
paths.push(["tierRules", index + 1, "deductionAmount"]);
} else {
const formRef: any = this.getFormRef();
if (formRef?.clearValidate) {
formRef.clearValidate([["tierRules", index + 1, "deductionAmount"]]);
}
}
}
this.validateLadderFields(paths);
if (index !== 0) return;
if (this.postData.tierRules.length !== 1) return;
this.isLadderDisplayAmountManuallyEditing = false;
this.postData.faceAmount = this.postData.tierRules[0].deductionAmount;
}
syncLadderDisplayAmount() {
if (this.postData.couponType !== 2) return;
if (this.postData.tierRules.length >= 2) {
const nums = this.postData.tierRules
.map((r) => this.toNumberOrNull(r.deductionAmount))
.filter((n) => typeof n === "number") as number[];
if (nums.length === 0) {
this.postData.faceAmount = null;
return;
}
});
this.postData.faceAmount = String(Math.max(...nums));
return;
}
const first = this.postData.tierRules[0]?.deductionAmount;
const firstNum = this.toNumberOrNull(first);
if (!this.isLadderDisplayAmountManuallyEditing && typeof firstNum === "number") {
this.postData.faceAmount = String(firstNum);
}
}
}
</script>
<style scoped lang="less"></style>
\ No newline at end of file
<style scoped lang="less">
.inline-row {
display: flex;
align-items: flex-start;
gap: 16px;
max-width: 100%;
}
.nowrap-row {
flex-wrap: nowrap;
}
.nowrap-radio {
margin-top: 8px;
flex: 0 0 auto;
}
:deep(.nowrap-radio.ant-radio-group) {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 16px;
}
:deep(.ant-form-item-control) {
flex: 1 1 auto;
max-width: 100%;
}
:deep(.ant-form-item-control-input) {
width: 100%;
}
:deep(.ant-form-item-control-input-content) {
width: 100%;
}
.input-affix {
position: relative;
display: inline-block;
}
.input-affix :deep(.ant-input) {
width: 100%;
}
.input-affix .affix {
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 2;
color: rgba(0, 0, 0, 0.45);
pointer-events: none;
white-space: nowrap;
}
.input-affix .affix.prefix {
left: 12px;
}
.input-affix .affix.suffix {
right: 12px;
}
.input-affix.affix-suffix-only :deep(.ant-input) {
padding-right: 30px;
}
.input-affix.affix-both :deep(.ant-input) {
padding-left: 72px;
padding-right: 30px;
}
.affix-delay {
margin-right: 8px;
}
.input-affix.affix-delay :deep(.ant-input) {
padding-left: 45px;
padding-right: 70px;
}
.input-affix.affix-valid :deep(.ant-input) {
padding-left: 58px;
padding-right: 30px;
}
:deep(.validity-radio-group.ant-radio-group) {
display: flex;
flex-direction: column;
gap: 12px;
}
.validity-row {
display: flex;
flex-direction: column;
gap: 8px;
}
:deep(.validity-radio-group .ant-radio-wrapper) {
align-self: flex-start;
margin-right: 0;
}
.validity-option-content {
padding-left: 24px;
display: flex;
}
.form-tip {
margin-top: 6px;
line-height: 20px;
color: rgba(0, 0, 0, 0.45);
}
.number-unit {
display: flex;
align-items: center;
gap: 8px;
}
.unit {
color: rgba(0, 0, 0, 0.45);
}
.wid_376 {
width: 376px;
}
.wid_184 {
width: 184px;
}
.ladder-wrap {
width: 100%;
position: relative;
}
.ladder-row {
display: flex;
align-items: flex-start;
gap: 8px;
margin-bottom: 8px;
flex-wrap: nowrap;
overflow-x: auto;
max-width: 100%;
background: #F5F7FA;
padding: 16px;
}
.ladder-delete {
padding: 0 4px;
}
.ladder-tips {
font-size: 12px;
color: #C4C7CC;
}
.ladder-footer {
position: absolute;
top: -35px;
right: 0;
display: flex;
justify-content: flex-start;
}
:deep(.ladder-field.ant-form-item) {
margin-bottom: 0;
}
.ladder-label {
color: rgba(0, 0, 0, 0.65);
margin-top: 6px;
}
.ladder-text {
color: rgba(0, 0, 0, 0.65);
margin-top: 6px;
}
.relative-row {
display: flex;
align-items: flex-start;
gap: 8px;
}
.relative-text {
color: rgba(0, 0, 0, 0.65);
flex-shrink: 0;
margin-top: 6px;
}
.ml-16 {
margin-left: 16px;
}
:deep(.inline-embed-item.ant-form-item) {
margin-bottom: 0;
}
:deep(.validity-embed-item.ant-form-item) {
margin-bottom: 0;
}
:deep(.relative-embed-item.ant-form-item) {
margin-bottom: 0;
}
:deep(.relative-embed-item .ant-form-item-explain) {
min-height: 22px;
}
</style>
<template>
<a-drawer width="936" title="手动发放优惠券" :maskClosable="false" :keyboard="false" placement="right" :open="dialogVisible" @close="onClose">
<a-form layout="vertical" :model="form" ref="formRef">
<a-form-item name="templateId" label="选择优惠券" :rules="[{ required: true, message: '请选择优惠券' }]">
<a-select v-model:value="form.templateId" placeholder="请选择优惠券" style="width: 376px;" :disabled="templateIdDisabled" @change="onTemplateChange">
<a-select-option v-for="option in couponTemplateOptions" :value="option.value" :key="option.value">
{{ option.label }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item name="templateId" label="优惠券信息" v-if="form?.templateId" :rules="[{ required: true, message: '请选择优惠券' }]">
<div class="coupon-info-display">
<a-row :gutter="16">
<a-col :span="12">
<div>
<div class="template_lable">优惠券名称</div>
<div>{{ form.templateName }}</div>
</div>
</a-col>
<a-col :span="12">
<div>
<div class="template_lable">可用库存</div>
<div>{{ (form.remainingQuantity ?? '') === '' ? '无限制' : form.remainingQuantity }}</div>
</div>
</a-col>
</a-row>
<a-row :gutter="16" style="margin-top: 8px;">
<a-col :span="12">
<div>
<div class="template_lable">券有效期</div>
<div v-if="form.validityType === 1">{{ form.validStartTime && form.validEndTime ? `${form.validStartTime?.substring(0, 10).replace(/-/g, '/')} 至 ${form.validEndTime?.substring(0, 10).replace(/-/g, '/')}` : '-' }}</div>
<div v-else>发放后{{ form.delayDays }}天生效,有效期{{ form.validDays }}天</div>
</div>
</a-col>
</a-row>
</div>
</a-form-item>
<a-form-item name="applicableType" label="适用人群" :rules="[{ required: true, message: '请选择适用人群!' }]">
<a-radio-group v-model:value="form.applicableType" placeholder="请输入适用人群" button-style="solid">
<template v-for="applicableType in applicableTypes" :key="applicableType">
<a-radio-button :value="applicableType">{{ $t('enum.commissionRule.applicableType.' + applicableType) }}</a-radio-button>
</template>
</a-radio-group>
</a-form-item>
<a-form-item v-if="form.applicableType==='ACCOUNT'" label="指定用户" name="accounts" :rules="[{ required: true, message: '请选择要添加的指定用户!' }]">
<a-button type="default" style="margin-bottom: 8px;" @click="showAccountSelector">选择用户</a-button>
<div class="list-content" v-if="form.accounts && form.accounts.length > 0">
<a-list :data-source="form.accounts" size="small" :bordered="false">
<template #renderItem="{ item,index }">
<a-list-item>
<template #actions>
<account-type-tag :account-type="item.accountType"></account-type-tag>
<a-button type="link" @click="removeAccount(index)">删除</a-button>
</template>
<a-list-item-meta>
<template #title>
{{ item.accountName }}
<a-divider type="vertical"/>
{{ item.nickName }}
</template>
<template #description>
{{ item.mobile }}
</template>
<template #avatar>
<a-avatar :src="item.avatar?.url" :size="42"></a-avatar>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
</div>
</a-form-item>
<a-form-item v-if="form.applicableType==='TAG'" label="选择标签" name="accountTags" :rules="[{ required: true, message: '请选择要添加的标签!' }]">
<a-select v-model:value="form.accountTags" style="width: 376px;" mode="multiple" placeholder="请选择要添加的标签" option-filter-prop="label" :labelInValue="true" show-search>
<a-select-option v-for="item in tags" :value="item.tagId" :key="item.tagId" :label="item.tagName">
<span role="img" :aria-label="item.color" :style="{backgroundColor:item.color}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
&nbsp;&nbsp;
{{ item.tagName }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item name="remark" label="发放备注" :rules="[{ required: true, message: '请输入发放备注' }]">
<a-textarea v-model:value="form.remark" show-count :maxlength="200"
placeholder="请说明本次发放的原因,如:XX活动用户补偿" :rows="4" />
</a-form-item>
</a-form>
<div class="footer_btn">
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="handleOk()">创建</a-button>
</div>
</a-drawer>
</template>
<script lang="ts">
import { message } from "ant-design-vue";
import { Component, Prop, Vue } from "vue-facing-decorator";
import AccountPicker from "@/views/account/account/AccountPicker.vue";
import {AccountTag} from "lib/src/entity/account/entity/AccountTag";
import AccountTypeTag from "@/views/account/account/tag/AccountTypeTag.vue";
import { AccountController } from "@/api/AccountController";
import { ModalService } from "@/components/ModalService";
import { COMMISSION_RULE_APPLICABLE_TYPES, CommissionRule } from "lib/src/entity/account/entity/CommissionRule";
import { DiscountController } from "@/api/DiscountController";
import { Account } from "lib/src/entity/account/entity/Account";
type OptionItem = { label: string; value: string };
@Component({
name: "ManualIssuanceModal",
components: { AccountTypeTag },
})
export default class ManualIssuanceModal extends Vue {
@Prop({ required: false, default: false }) templateIdDisabled!: boolean;
applicableTypes = COMMISSION_RULE_APPLICABLE_TYPES;
dialogVisible = false;
crowdModalOpen = false;
tags: AccountTag[] = [];
form = {
templateId: undefined as string | undefined,
templateName: "",
applicableType: "ACCOUNT",
accounts: [],
accountTags: [],
remark: "",
};
couponTemplateOptions: OptionItem[] = [];
openByRecord(record: any) {
// 获取人员标签数据
AccountController.getAccountTags(this.axios).then(res => {
this.tags = res.data;
});
// 获取优惠券模板数据
DiscountController.couponTemplatePage(this.axios, { limit: 9999 }).then(res => {
const templates = Array.isArray(res.data?.content) ? res.data?.content : [];
templates?.forEach(val => {
val.label = val.templateName;
val.value = val.id;
})
this.couponTemplateOptions = templates
})
this.dialogVisible = true;
this.$nextTick(() => {
const formRef: any = (this.$refs as any)?.formRef;
formRef.resetFields();
this.form = {
...this.form,
...record,
templateId: record.id ?? undefined,
remark: ""
}
});
}
onTemplateChange(value: string) {
const obj = this.couponTemplateOptions.find(option => option.value === value);
this.form = {
...this.form,
templateId: obj?.id,
templateName: obj?.templateName,
remainingQuantity: obj?.remainingQuantity,
validityType: obj?.validityType,
validStartTime: obj?.validStartTime,
validEndTime: obj?.validEndTime,
delayDays: obj?.delayDays,
validDays: obj?.validDays,
}
console.log(obj)
}
onClose() {
this.dialogVisible = false;
}
showAccountSelector(): void {
const ids = this.form.accounts?.map(account => account.accountId) ?? [];
const modal = ModalService.confirm({
title: '选择用户', component: AccountPicker, closable: true, appContext: this.$.appContext,
props: {ids: ids},
onOk: (component): void => {
component.selectAccounts();
},
emits: {
handleOk: (accounts: Account[]) => {
modal.destroy();
if (!this.form.accounts) {
this.form.accounts = [];
}
if (accounts) {
for (const account of accounts) {
const exist = this.form.accounts.some(item => item.accountId === account.accountId);
if (!exist) {
this.form.accounts.push(account);
}
}
}
}
},
});
}
removeAccount(account: Account): void {
this.form.accounts.splice(this.form.accounts.indexOf(account), 1);
}
handleOk() {
const formRef: any = (this.$refs as any)?.formRef;
formRef.validate().then(() => {
DiscountController.couponManualIssuance(this.axios, {
templateId: this.form.templateId,
// applicableType: this.form.applicableType,
accountIds: this.form.accounts?.map(account => account.accountId) ?? [],
// accountTags: this.form.accountTags ?? [],
remark: this.form.remark,
}).then((res) => {
let { code, data, message: msg } = res.data;
if (code !== '200') {
message.error(msg || "提交失败");
return;
}
message.success("已提交");
this.$emit("submitted");
this.dialogVisible = false;
})
});
}
}
</script>
<style scoped lang="less">
.manual-crowd-value {
margin-top: 8px;
line-height: 22px;
color: rgba(0, 0, 0, 0.65);
}
.coupon-info-display {
padding: 16px;
background: #F7F8F9;
border-radius: 8px;
color: #2F3133;
font-size: 14px;
.template_lable {
color: #777C85;
margin-bottom: 4px;
}
}
.list-content {
max-height: 280px;
overflow-y: auto;
}
.footer_btn {
width: calc(100% - 16px);
background: #FFFFFF;
position: absolute;
padding: 12px 0;
bottom: 0px;
right: 16px;
display: flex;
justify-content: end;
align-items: center;
gap: 8px;
}
</style>
<template>
<a-card class="tabs-card" :bordered="false">
<!-- <div class="record-stat-wrap">
<div class="record-stat-header">
<div class="record-stat-title">数据统计</div>
<div class="record-stat-actions">
<a-segmented v-model:value="statSegment" :options="statSegments" @change="queryRecordStat" />
<a-range-picker v-if="statSegment === 'custom'" v-model:value="customStatRange"
class="record-stat-range" :format="'YYYY-MM-DD'" @change="queryRecordStat" />
</div>
</div>
<a-row :gutter="12" class="record-stat-cards">
<a-col :span="4">
<div class="record-stat-card">
<div>
<img class="image" src="@/assets/discount/todo_icon.png" alt="">
</div>
<div>
<div class="record-stat-label">总发放量(张)</div>
<div class="record-stat-value">{{ recordStat.totalDistributionCount }}</div>
<div class="record-stat-sub" :style="{ color: recordStat.distributionCountChange > 0 ? '#00AD74' : ''}">
较上一周期 {{ (recordStat.distributionCountChange ?? '') !== '' ? `${recordStat.distributionCountChange > 0 ? '+' : recordStat.distributionCountChange < 0 ? '-' : ''}${recordStat.distributionCountChange}%` : '-' }}
</div>
</div>
</div>
</a-col>
<a-col :span="4">
<div class="record-stat-card">
<div>
<img class="image" src="@/assets/discount/todo_icon.png" alt="">
</div>
<div>
<div class="record-stat-label">已核销(张)</div>
<div class="record-stat-value">{{ recordStat.verifiedCount }}</div>
<div class="record-stat-sub">核销率:{{ (recordStat.verificationRate ?? '') !== '' ? `${recordStat.verificationRate}%` : '-' }}</div>
</div>
</div>
</a-col>
<a-col :span="4">
<div class="record-stat-card">
<div>
<img class="image" src="@/assets/discount/total_amount_icon.png" alt="">
</div>
<div>
<div class="record-stat-label">累计抵扣金额(元)</div>
<div class="record-stat-value">¥{{ recordStat.totalDeductionAmount }}</div>
</div>
</div>
</a-col>
<a-col :span="4">
<div class="record-stat-card">
<div>
<img class="image" src="@/assets/discount/todo_icon.png" alt="">
</div>
<div>
<div class="record-stat-label">降级使用(张)</div>
<div class="record-stat-value">{{ recordStat.downgradedCount }}</div>
<div class="record-stat-sub">占比:{{ (recordStat.downgradedRate ?? '') !== '' ? `${recordStat.downgradedRate}%` : '-' }}</div>
</div>
</div>
</a-col>
<a-col :span="4">
<div class="record-stat-card">
<div>
<img class="image" src="@/assets/discount/todo_icon.png" alt="">
</div>
<div>
<div class="record-stat-label">已失效(张)</div>
<div class="record-stat-value">{{ recordStat.expiredCount }}</div>
</div>
</div>
</a-col>
<a-col :span="4">
<div class="record-stat-card">
<div>
<img class="image" src="@/assets/discount/todo_icon.png" alt="">
</div>
<div>
<div class="record-stat-label">已退回(张)</div>
<div class="record-stat-value">{{ recordStat.returnedCount }}</div>
</div>
</div>
</a-col>
</a-row>
</div> -->
<!--查询栏-->
<m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm"
@onSearch="handlePageReload" @onReset="handleReset" :simpleFieldNum="4"></m-pagination-query-render>
<!--查询栏end-->
<div class="table-operations" style="margin-bottom: 16px;width: 100%;float: left;">
<div class="flex justify-end" style="float: left;">
已选 {{ selectedItems.length }} 项
</div>
<div class="flex justify-end" style="float: right;">
<a-button type="primary" @click="handleAdd({})">手动发放</a-button>
<a-button @click="downloadExcel()" :disabled="exporting">导出</a-button>
<a-button type="primary" @click="handleAdd({})">手动发放</a-button>
</div>
</div>
<a-table :columns="columns" :data-source="pagination.content" :loading="loading" :bordered="false"
@change="pageRefresh" @resizeColumn="this.$filters.tableResizeColumn" size="small" :pagination="pageState"
:row-key="record => record.id" :scroll="{ y: 'calc(100vh - 350px)' }">
:row-key="record => record.id" :scroll="{ y: 'calc(100vh - 350px)' }" :row-selection="{ selectedRowKeys: selectIds, onChange: onSelectChange, type: 'checkbox', preserveSelectedRowKeys: true, }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'activityType'">
{{activityTypeList.find(item => item.value === record.activityType)?.label || '-'}}
<template v-if="column.key === 'activityName'">
<div v-if="record.distributionType === 2">-- / 手动发放</div>
<div v-else>
<div class="text_hide" :title="record.activityId">ID:{{ record.activityId }}</div>
<div class="text_hide second_text" :title="record.activityName">{{ record.activityName }}</div>
</div>
</template>
<template v-if="column.key === 'status'">
{{statusList.find(item => item.value === record.status)?.label || '-'}}
<template v-if="column.key === 'templateName'">
<div class="text_hide" :title="record.couponId">{{ record.couponId }}</div>
<div class="text_hide second_text" :title="record.templateName">{{ record.templateName }}</div>
</template>
<template v-if="column.key === 'accountName'">
<div class="text_hide" :title="record.accountName">{{ record.accountName }}</div>
<div class="text_hide second_text" :title="record.mobile">{{ record.mobile }}</div>
</template>
<template v-if="column.key === 'distributionType'">
{{distributionTypeList.find(item => item.value === record.distributionType)?.label || '-'}}
</template>
<template v-if="column.key === 'couponStatus'">
<a-tag :color="couponStatusList.find(item => item.value === record.couponStatus)?.color" :style="{ color: couponStatusList.find(item => item.value === record.couponStatus)?.textColor }"
:bordered="false">
{{couponStatusList.find(item => item.value === record.couponStatus)?.label || '-'}}
</a-tag>
</template>
<template v-if="column.key === 'orderCode'">
<div v-if="record.couponStatus === 2 || record.couponStatus === 4">
<div class="text_hide" :title="record.orderCode">{{ record.orderCode }}</div>
<div class="text_hide second_text" :title="record.vehicleInfo">{{ record.vehicleInfo }}</div>
</div>
<div v-else>-</div>
</template>
<template v-if="column.key === 'transactionAmount'">
<div v-if="record.couponStatus === 2">
<div class="text_hide" :title="`成交价:${record.transactionAmount}元`">成交价: {{ record.transactionAmount }} 元</div>
<div class="text_hide second_text" :title="`实际抵扣:${record.actualDeduction}元`">实际抵扣:{{ record.actualDeduction }}元</div>
</div>
<div v-else>-</div>
</template>
<template v-if="column.key === 'useTime'">
<div v-if="record.couponStatus === 2">
<div class="text_hide">使用时间</div>
<div class="text_hide second_text">{{ record.useTime }}</div>
</div>
<div v-else>
<div class="text_hide">过期时间</div>
<div class="text_hide second_text">{{ record.expireTime }}</div>
</div>
</template>
<template v-if="column.key === 'action'">
<a-button type="link" v-if="record.couponStatus === 2" @click="handleOrder(record)"
size="small">查看订单</a-button>
<a-button type="link" v-if="record.couponStatus === 2" @click="handleVehicleProfile(record)"
size="small">车辆档案</a-button>
<a-button type="link" v-if="(record.couponStatus === 3 || record.couponStatus === 4) && record.distributionType === 2" @click="handleReissue(record)"
size="small">重新发放</a-button>
</template>
</template>
</a-table>
<ManualIssuanceModal ref="manualIssuanceModalRef" @submitted="handleManualIssuanceSubmitted" />
</a-card>
</template>
<script lang="ts">
import { createVNode } from "vue";
import { Component } from 'vue-facing-decorator';
import { message, TableColumnsType } from "ant-design-vue";
import { message, TableColumnsType, Modal } from "ant-design-vue";
import { Operator, Order } from "lib/src/core/page/Pagination";
import { PaginationComponent } from "@/components/PaginationComponent";
import { Vehicle } from "lib/src/entity/vehicle/entity/Vehicle";
import { DetectionController } from "@/api/DetectionController";
import { DiscountController } from '@/api/DiscountController';
import dayjs, { Dayjs } from "dayjs";
import { ExportUtil } from "@/common/ExportUtil";
import { InfoCircleFilled } from '@ant-design/icons-vue';
import ManualIssuanceModal from "@/views/discount/coupon/components/ManualIssuanceModal.vue";
@Component({
components: {}
components: {ManualIssuanceModal}
})
export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
activityTypeList = [
{ label: '自动触发发放', value: 1 },
{ label: '直接发放', value: 2 },
selectedItems = [];
statSegments = [{ label: '今日', value: 'today' }, { label: '昨日', value: 'yesterday' }, { label: '近7天', value: 'last7' }, { label: '近30天', value: 'last30' }, { label: '自定义', value: 'custom' }];
statSegment = 'last30';
customStatRange: Dayjs[] = null;
recordStat = {
totalIssued: 0,
totalIssuedDiffText: '--',
redeemed: 0,
redeemedRateText: '--',
totalDeductAmountText: '0.00',
downgradedUsed: 0,
downgradedRateText: '--',
expired: 0,
returned: 0,
};
distributionTypeList = [
{ label: '自动触发', value: 1 },
{ label: '手动发放', value: 2 },
{ label: '直接发放活动', value: 3 },
];
statusList = [
{ label: '待启动', value: 1 },
{ label: '进行中', value: 2 },
{ label: '已结束', value: 3 },
{ label: '已停用', value: 4 },
couponStatusList = [
{ label: '待使用', value: 1, color: '#E7EEFE', textColor: '#185EFE' },
{ label: '已核销', value: 2, color: '#E8F8F2', textColor: '#00A870' },
{ label: '已失效', value: 3, color: '#F0F2F5', textColor: '#777C85' },
{ label: '已退回', value: 4, color: '#FFF3E5', textColor: '#FC8B0A' },
];
/**
......@@ -64,21 +217,21 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
*/
columns: TableColumnsType = [
{
title: '序号', key: 'index', width: 70, align: 'center', sorter: false,
title: '序号', key: 'index', width: 70, align: 'left', sorter: false,
customRender: ({ index }) => {
return (this.getPagination().pageIndex - 1) * this.getPagination().pageSize + index + 1;
},
},
{ title: '活动ID / 名称', dataIndex: 'activityName', key: 'activityName', align: 'center', width: 150, resizable: true, ellipsis: true },
{ title: '优惠券ID / 名称', dataIndex: 'templateName', key: 'templateName', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '发放用户名 / 手机号', dataIndex: 'activityType', key: 'activityType', align: 'center', width: 150, resizable: true, ellipsis: true },
{ title: '发放类型', dataIndex: 'couponIds', key: 'couponIds', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '优惠券状态', dataIndex: 'faceAmount', key: 'faceAmount', align: 'center', width: 240, resizable: true, ellipsis: true },
{ title: '关联订单号 / 车型', dataIndex: ['vehicle', 'baseInfo', "licensePlate"], key: 'licensePlate', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '成交价 / 抵扣金额', dataIndex: 'totalQuantity', key: 'totalQuantity', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '发放时间', dataIndex: 'scoreLevel', key: 'scoreLevel', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '使用/过期时间', dataIndex: 'scoreLevel', key: 'scoreLevel', align: 'center', width: 170, resizable: true, ellipsis: true },
{ title: '操作', key: 'action', width: 170, align: 'center', fixed: 'right' },
{ title: '活动ID / 名称', dataIndex: 'activityName', key: 'activityName', align: 'left', width: 220, resizable: true, ellipsis: true },
{ title: '优惠券ID / 名称', dataIndex: 'templateName', key: 'templateName', align: 'left', width: 200, resizable: true, ellipsis: true },
{ title: '发放用户名 / 手机号', dataIndex: 'accountName', key: 'accountName', align: 'left', width: 150, resizable: true, ellipsis: true },
{ title: '发放类型', dataIndex: 'distributionType', key: 'distributionType', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '优惠券状态', dataIndex: 'couponStatus', key: 'couponStatus', align: 'left', width: 150, resizable: true, ellipsis: true },
{ title: '关联订单号 / 车型', dataIndex: 'orderCode', key: 'orderCode', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '成交价 / 抵扣金额', dataIndex: 'transactionAmount', key: 'transactionAmount', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '发放时间', dataIndex: 'distributionTime', key: 'distributionTime', align: 'left', width: 170, resizable: true, ellipsis: true },
{ title: '使用/过期时间', dataIndex: 'useTime', key: 'useTime', align: 'left', width: 130, resizable: true, ellipsis: true },
{ title: '操作', key: 'action', width: 170, align: 'left', fixed: 'right' },
];
getPagination() {
......@@ -89,30 +242,236 @@ export default class DiscountActivityPage extends PaginationComponent<Vehicle> {
* 初始化配置
*/
created(): void {
this.init(this.axios, DetectionController.PAGE_INSPECTOR_REPORT);
this.init(this.axios, DiscountController.PAGE_COUPON_RECORD);
this.buildQueryForm({
activityId: [null, { label: '活动信息', field: 'activityId', placeholder: '输入活动名称或ID', operator: Operator.like }],
userId: [null, { label: '用户信息', field: 'userId', placeholder: '输入用户名或手机号', operator: Operator.like }],
status: [null, { label: '优惠券状态', field: 'status', type: 'select', allowClear: true, optionItems: this.statusList, operator: Operator.eq }],
activityType: [null, { label: '发放类型', type: 'select', optionItems: this.activityTypeList, allowClear: true, field: 'activityType', operator: Operator.eq }],
orderId: [null, { label: '关联订单号', field: 'orderId', placeholder: '输入订单号', operator: Operator.like }],
createTime: [null, { label: '发放时间', field: 'createTime', operator: Operator.dateBetween, type: 'date-range' }],
keyword: [null, { label: '活动信息', field: 'keyword', placeholder: '输入活动名称或ID', operator: Operator.like }],
userInfo: [null, { label: '用户信息', field: 'userInfo', placeholder: '输入用户名或手机号', operator: Operator.like }],
couponStatus: [null, { label: '优惠券状态', field: 'couponStatus', type: 'select', allowClear: true, optionItems: this.couponStatusList, operator: Operator.eq }],
distributionType: [null, { label: '发放类型', type: 'select', optionItems: this.distributionTypeList, allowClear: true, field: 'distributionType', operator: Operator.eq }],
orderCode: [null, { label: '关联订单号', field: 'orderCode', placeholder: '输入订单号', operator: Operator.like }],
distributionTime: [null, { label: '发放时间', field: 'distributionTime', operator: Operator.dateBetween, type: 'date-range' }],
});
this.pagination.setDefaultSort('createTime', Order.desc);
const pageQuery = this.$route.query
// 从优惠券管理列表跳转 直接打开活动详情
if (pageQuery?.keyword) {
this.buildQueryForm({
keyword: [String(pageQuery.keyword), { label: '活动信息', field: 'keyword', placeholder: '输入活动名称或ID', operator: Operator.like }],
});
this.$router.replace({ query: { ...this.$route.query, keyword: undefined } })
}
this.pagination.setDefaultSort('distributionTime', Order.desc);
this.pageLoad();
// this.queryRecordStat();
}
//查询
handlePageReload() {
this.selectedItems = [];
this.pageReload();
}
//重置查询条件
handleReset() {
this.selectedItems = [];
this.pageReset();
}
onSelectChange(selectedRowKeys: number[], selectedRows: []): void {
this.selectedItems = selectedRows;
}
// queryRecordStat() {
// const range = this.getStatRange();
// if (this.statSegment === 'custom' && (!range || range.length !== 2)) {
// return;
// }
// DiscountController.couponStatistics(this.axios, { startDate: range[0], endDate: range[1] }).then(res => {
// this.recordStat = res?.data?.data || {}
// })
// }
getStatRange(): Dayjs[] {
if (this.statSegment === 'custom') return this.customStatRange;
const end = dayjs().endOf('day');
if (this.statSegment === 'today') return [dayjs().startOf('day'), end];
if (this.statSegment === 'yesterday') {
const d = dayjs().subtract(1, 'day');
return [d.startOf('day'), d.endOf('day')];
}
if (this.statSegment === 'last30') return [dayjs().subtract(29, 'day').startOf('day'), end];
return [dayjs().subtract(6, 'day').startOf('day'), end];
}
// 查看订单
handleOrder(record: any) {
window.open(`#/auction/order/view?orderId=${record.orderCode}`, "_blank");
}
// 查看车辆档案
handleVehicleProfile(record: any) {
window.open(`#/vehicle/view?vehicleId=${record.vehicleId}`, "_blank");
}
// 重新发放
handleReissue(record: any) {
Modal.confirm({
title: "重新发放",
icon: createVNode(InfoCircleFilled, { style: { color: "#1956FE" } }),
content: createVNode("div", { style: { lineHeight: "22px" } }, [
createVNode(
"p",
{ style: { marginBottom: "8px" } },
`确认向用户 [${record.accountName}-${record.mobile}] 重新发放一张【${record.templateName}】?`
),
]),
okText: "发放",
cancelText: "取消",
onOk: () => {
DiscountController.couponReissue(this.axios, { recordId: record?.id }).then((res) => {
let { code, message: msg } = res.data
if (code === '200') {
message.success("已重新发放");
this.pageReload();
} else {
message.error(msg);
}
});
},
});
}
// 手动发放
handleAdd() {
const modalRef: any = (this.$refs as any)?.manualIssuanceModalRef;
if (modalRef?.openByRecord) {
modalRef.openByRecord({});
}
}
handleManualIssuanceSubmitted() {
this.pageReload();
}
downloadExcel(): void {
this.exporting = true;
let paramsData = {
...this.pagination.requestParams,
id: this.selectedItems.map(item => item.id),
}
DiscountController.couponRecordExport(this.axios, paramsData, { responseType: 'blob' }).then(response => {
message.success('导出任务已创建,请在下载中心查看');
ExportUtil.downloadExcelFile(response.data, this.getNewTime() + '-优惠券发放记录');
}).catch(error => {
console.error('Error downloading Word file:', error);
}).finally(() => {
this.exporting = false;
});
}
getNewTime() {
//获取当前年月日时分秒
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const monthStr = month < 10 ? '0' + month : month;
const day = date.getDate();
const dayStr = day < 10 ? '0' + day : day;
const hour = date.getHours();
const minute = date.getMinutes();
const minuteStr = minute < 10 ? '0' + minute : minute;
return `${year}-${monthStr}-${dayStr}-${hour}-${minuteStr}`
}
}
</script>
<style scoped lang="less"></style>
<style scoped lang="less">
.text_hide {
width: 100%;
height: 22px;
color: #2f3133;
font-size: 14px;
font-weight: 400;
font-family: "HarmonyOSSansSC";
text-align: left;
line-height: 22px;
margin-top: 9px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.second_text {
color: #C4C7CC;
font-size: 12px;
margin-top: 4px;
}
.record-stat-wrap {
background: #fff;
border-radius: 8px;
padding: 12px;
margin-bottom: 12px;
}
.record-stat-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.record-stat-title {
font-size: 16px;
font-weight: 600;
color: rgba(0, 0, 0, 0.85);
}
.record-stat-actions {
display: flex;
align-items: center;
gap: 12px;
}
::v-deep .ant-segmented-item-selected {
color: #1956FE !important;
}
.record-stat-range {
width: 260px;
}
.record-stat-card {
background: #f7f8fa;
border-radius: 8px;
padding: 24px 16px;
height: 120px;
box-sizing: border-box;
display: flex;
gap: 16px;
.image {
width: 36px;
height: 36px;
}
}
.record-stat-label {
font-size: 14px;
color: #777C85;
}
.record-stat-value {
font-size: 20px;
font-weight: 500;
line-height: 24px;
color: #2F3133;
margin: 8px 0;
}
.record-stat-sub {
font-size: 10px;
color: #777C85;
}
</style>
<template>
<div>
</div>
</template>
\ No newline at end of file
......@@ -118,7 +118,7 @@ export default class AppraiseVehiclePage extends PaginationComponent<AppraisePri
address: [null, {label: '车辆所在地址', field: 'vehicle.custodianInfo.handoverAddress', operator: Operator.like}],
custodianName: [null, {label: '车辆保管人', field: 'vehicle.custodianInfo.custodianName', operator: Operator.like}],
});
this.pagination.setDefaultSort('createTime', Order.asc);
this.pagination.setDefaultSort('createTime', Order.desc);
this.pagination.addDefaultFilter('auditState', 'UNAUDITED');
this.pageLoad();
VenueController.getEnabledVenueOptionItems(this.axios).then(response => {
......
......@@ -20,7 +20,7 @@
<uni-list-item showArrow title="隐私条款与概要" to="/module/profile/TransactionRulePage"></uni-list-item>
<uni-list-item showArrow title="个人信息收集清单" to="/module/profile/FeedbackPage"></uni-list-item>
<uni-list-item showArrow title="第三方共享个人信息清单" to="/module/profile/FeedbackPage"></uni-list-item>
<uni-list-item showArrow title="关于广联" to="/module/profile/FeedbackPage"></uni-list-item>
<uni-list-item showArrow title="关于优加" to="/module/profile/FeedbackPage"></uni-list-item>
</uni-list>
<view class="divider"></view>
<uni-list class="menu-list">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!