Commit e25c40bf authored by dragondean@qq.com's avatar dragondean@qq.com

优惠券-金额满减

parent 69ddd604
import request from '@/utils/request'
// 创建优惠券信息
export function createCoupon(data) {
return request({
url: '/ecw/coupon/createOrUpdate',
method: 'post',
data: data
})
}
// 更新优惠券信息
export function updateCoupon(data) {
return request({
url: '/ecw/coupon/createOrUpdate',
method: 'post',
data: data
})
}
// 删除优惠券信息
export function deleteCoupon(id) {
return request({
url: '/ecw/coupon/delete?id=' + id,
method: 'delete'
})
}
// 获得优惠券信息
export function getCoupon(id) {
return request({
url: '/ecw/coupon/get?id=' + id,
method: 'get'
})
}
// 获得优惠券信息分页
export function getCouponPage(query) {
return request({
url: '/ecw/coupon/page',
method: 'get',
params: query
})
}
// 导出优惠券信息 Excel
export function exportCouponExcel(query) {
return request({
url: '/ecw/coupon/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}
...@@ -43,6 +43,15 @@ export function getCustomerPage(query) { ...@@ -43,6 +43,15 @@ export function getCustomerPage(query) {
}) })
} }
// 获得客户下来
export function getCustomerSelect(query) {
return request({
url: '/ecw/customer/select',
method: 'get',
params: query
})
}
// 导出客户 Excel // 导出客户 Excel
export function exportCustomerExcel(query) { export function exportCustomerExcel(query) {
return request({ return request({
......
<template>
<el-row class="" :gutter="10">
<el-col :span="10">
<el-card>
<div slot="header" class="header">
<el-input v-model="queryParams.searchKey" placeholder="用户名/手机/邮箱" style="width:200px" />
<dict-selector :type="DICT_TYPE.USER_TYPE" v-model="queryParams.customerType" style="width:100px" />
<el-button type="primary" @click="reLoad">搜搜1</el-button>
</div>
<div class="list">
<div class="item" v-for="item in list" :key="item.id">
<el-link class="el-icon-plus" @click="choose(item)" :disabled="customerIds.indexOf(item.id) > -1" />
{{item.name}}{{item.defaultContactName}}
</div>
</div>
</el-card>
</el-col>
<el-col :span="10">
<el-card>
<div slot="header" class="header">
已选客户
</div>
<div class="list">
<div class="item" v-for="item in choosedList" :key="item.id">
<el-link class="el-icon-delete" @click="remove(item)" />
{{item.name}}{{item.defaultContactName}}
</div>
</div>
</el-card>
</el-col>
</el-row>
</template>
<script>
import {getCustomerSelect} from '@/api/ecw/customer'
export default {
data(){
return {
list:[],
/* page: 1,
pages: 1, */
queryParams:{
page: 1,
name: null,
level: null
},
choosedList:[]
}
},
computed:{
customerIds(){
let arr = []
this.choosedList.forEach(item => {
arr.push(item.id)
})
return arr
}
},
watch:{
customerIds(val){
this.$emit('input', val)
}
},
created(){
this.reLoad()
},
methods:{
reLoad(){
this.queryParams.page = 1
this.list = []
this.getList()
},
loadNextPage(){
if(this.page >= this.pages){
return this.$message.error('已加载全部')
}
this.queryParams.page ++
this.getList()
},
getList(){
getCustomerSelect(this.queryParams).then(res => {
this.list = res.data
})
},
choose(customer){
this.choosedList.push(customer)
},
remove(customer){
this.choosedList.forEach((item,index) => {
if(item.id==customer.id) this.choosedList.splice(index,1)
})
}
}
}
</script>
<style scoped lang="scss">
.header{
>div{
margin-right: 5px;
}
}
.list{
height: 200px;
border: 1px solid #ccc;
overflow-y: auto;
overflow-x: hidden;
padding: 0 10px;
}
</style>
\ No newline at end of file
<template> <template>
<el-select v-model="valueSync" :placeholder="placeholder" clearable :multiple="multiple"> <div class="dict-selector">
<el-option v-for="dict in getList(type)" <el-select v-if="formType == 'select'" v-model="valueSync" :placeholder="placeholder" clearable :multiple="multiple">
<el-option v-for="dict in dictList"
:key="dict.value" :label="dict.label" :value="dict.value"/> :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select> </el-select>
<el-radio-group v-if="formType == 'radio'" v-model="valueSync">
<el-radio v-for="dict in dictList" :label="dict.value" :key="dict.value">{{dict.label}}</el-radio>
</el-radio-group>
<el-checkbox-group v-if="formType == 'checkbox'" v-model="valueSync">
<el-checkbox v-for="dict in dictList" :label="dict.value" :key="dict.value">{{dict.label}}</el-checkbox>
</el-checkbox-group>
</div>
</template> </template>
<script> <script>
const selfDefinedDict = {
_yesno: [
{label: '', value: '1'},
{label: '', value: '0'}
]
}
export default { export default {
props:{ props:{
placeholder: { placeholder: {
...@@ -20,14 +22,24 @@ export default { ...@@ -20,14 +22,24 @@ export default {
type: String, type: String,
value: [String, Number, Array], value: [String, Number, Array],
multiple: Boolean, multiple: Boolean,
formType:{
type: String,
default: 'select'
},
forceString: { forceString: {
type: Boolean, type: Boolean,
default: true default: true
} },
defaultable: Boolean, // 是否默认选择第一个
}, },
data(){ data(){
return { return {
valueSync: null valueSync: this.multiple ? [] : null
}
},
computed:{
dictList(){
return this.getList(this.type)
} }
}, },
watch:{ watch:{
...@@ -36,21 +48,36 @@ export default { ...@@ -36,21 +48,36 @@ export default {
}, },
value(val){ value(val){
this.setValueSync() this.setValueSync()
},
dictList(){
this.setDefault()
} }
}, },
created(){ created(){
this.setValueSync() this.setValueSync()
this.setDefault()
}, },
methods:{ methods:{
setValueSync(){ setValueSync(){
if(!this.value || this.value == '') return if(!this.value || this.value == '') return
if(this.forceString && this.multiple){ if(this.forceString && this.multiple){
this.valueSync = val.split(',') this.valueSync = this.value.split(',')
}else this.valueSync = this.forceString ? String(this.value) : this.value }else this.valueSync = this.forceString ? String(this.value) : this.value
}, },
getList(){ getList(){
return selfDefinedDict[this.type] || this.getDictDatas(this.type) return this.getDictDatas(this.type)
},
setDefault(){
if(!this.defaultable) return
if(this.dictList.length && (this.valueSync === null || this.valueSync == '')){
this.valueSync = this.dictList[0].value
}
} }
} }
} }
</script> </script>
<style scoped>
.dict-selector{
display: inline-block;
}
</style>
\ No newline at end of file
<template>
<el-row class="" :gutter="10">
<el-col :span="10">
<el-card>
<div slot="header" class="header">
<el-select v-model="queryParams.typeId" placeholder="选择类型" style="width:120px" clearable>
<el-option v-for="item in typeList" :key="item.id" :label="item.titleZh" :value="item.id" />
</el-select>
<el-select v-model="queryParams.attrId" placeholder="选择属性" style="width:120px" clearable>
<el-option v-for="item in attrList" :key="item.id" :label="item.attrName" :value="item.id" />
</el-select>
<el-input v-model="queryParams.titleZh" placeholder="产品关键字" style="width:120px" clearable />
<el-button type="primary" @click="reLoad">搜搜</el-button>
</div>
<div class="list">
<div class="item" v-for="item in list" :key="item.id">
<el-checkbox @change="toggleCheck(item, $event)" :value="ids.indexOf(item.id) > -1" /> {{item.titleZh}}
<div>{{item.titleEn}}</div>
</div>
</div>
</el-card>
</el-col>
<el-col :span="10">
<el-card>
<div slot="header" class="header">
已选产品
</div>
<div class="list">
<div class="item" v-for="(choosed) in choosedList" :key="choosed.id" :data-data="JSON.stringify(choosed)">
<el-link class="el-icon-delete" @click="remove(choosed)" /> {{choosed.titleZh}}
<div>{{choosed.titleEn}}</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
</template>
<script>
import {getProductPage} from '@/api/ecw/product'
import {getProductTypeList} from '@/api/ecw/productType'
import {getProductAttrList} from '@/api/ecw/productAttr'
export default {
data(){
return {
list:[],
page: 1,
pages: 1,
queryParams:{
page: 1,
attrId: null,
titleZh: null,
typeId: null
},
choosedList:[],
typeList:[],
attrList:[]
}
},
computed:{
ids(){
let arr = []
this.choosedList.forEach(item => {
arr.push(item.id)
})
return arr
}
},
watch:{
ids(val){
this.$emit('input', val)
}
},
created(){
getProductTypeList().then(res => this.typeList = res.data)
getProductAttrList().then(res => this.attrList = res.data)
this.reLoad()
},
methods:{
reLoad(){
this.queryParams.page = 1
this.list = []
this.getList()
},
loadNextPage(){
if(this.page >= this.pages){
return this.$message.error('已加载全部')
}
this.queryParams.page ++
this.getList()
},
getList(){
getProductPage(this.queryParams).then(res => {
this.list = res.data.list //.concat(res.data.list || [])
this.page = res.data.page
this.pages = res.data.pages
})
},
toggleCheck(item, checked){
if(checked){
this.choose(item)
}else{
this.remove(item)
}
},
choose(item){
this.choosedList.push(item)
},
remove(item){
this.choosedList.forEach((choosed,index) => {
if(choosed.id==item.id) this.choosedList.splice(index,1)
})
}
}
}
</script>
<style scoped lang="scss">
.header{
>div{
margin-right: 5px;
}
}
.list{
height: 200px;
border: 1px solid #ccc;
overflow-y: auto;
overflow-x: hidden;
padding: 0 10px;
display: flex;
flex-wrap: wrap;
.item{
width: 50%;
line-height: 20px;
height: 50px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>
\ No newline at end of file
<template>
<el-select v-model="valueSync" :multiple="multiple">
<el-option v-for="item in optionsFormated" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
<script>
export default {
data(){
return {
valueSync: null
}
},
props:{
options: Array,
value: [String, Number, Boolean, Object],
labelField: {
type: String,
default: 'label'
},
valueField: {
type: String,
default: 'value'
},
multiple: Boolean,
clearable: Boolean,
defaultable: Boolean, // 没有值的时候是否选择第一项
},
computed:{
optionsFormated(){
let arr = []
this.options.forEach(item => {
arr.push({
label: item[this.labelField],
value: item[this.valueField]
})
})
return arr
}
},
watch:{
valueSync(val){
this.$emit('input', val)
},
value(value){
this.valueSync = value
},
optionsFormated(){
this.setDefault()
}
},
created(){
this.valueSync = this.value
this.setDefault()
},
methods:{
setDefault(){
if(!this.defaultable){
return false
}
if(this.optionsFormated.length && (this.valueSync == null || this.valueSync == '')){
this.valueSync = this.optionsFormated[0].value
}
}
}
}
</script>
\ No newline at end of file
...@@ -68,6 +68,20 @@ export const DICT_TYPE = { ...@@ -68,6 +68,20 @@ export const DICT_TYPE = {
ECW_PACKAGING_TYPE: 'packaging_type', //包装要求 ECW_PACKAGING_TYPE: 'packaging_type', //包装要求
ECW_CONTAINER_LOCATION: 'container_location', //默认货柜位置 ECW_CONTAINER_LOCATION: 'container_location', //默认货柜位置
ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS: 'special_req_for_line_products', // 特殊需求 ECW_SPECIAL_REQ_FOR_LINE_PRODUCTS: 'special_req_for_line_products', // 特殊需求
ECW_COUPON_TYPE: 'coupon_type', // 优惠券类型
ECW_COUPON_STATUS: 'coupon_status', // 优惠券状态
ECW_COUPON_COST_TYPE: 'coupon_cost_type', // 优惠券费用类型
ECW_COUPON_OVERDUE_STATUS: 'coupon_overdue_status', // 优惠券状态
ECW_COUPON_PUTON_STATUS: 'coupon_puton_status',
ECW_SUITABLE_USER_TYPE:'suitable_user_type', // 适用用户类型
ECW_SUITABLE_LINE_TYPE: 'suitable_line_type', // 适用线路类型
ECW_SUITABLE_PROD_TYPE: 'suitable_prod_type', // 适用产品类型
ECW_ORDER_ATTR: 'order_attr', // 订单属性
ECW_YESNO: 'yesno', // 是否 1,0
ECW_COMPANY_TYPE: 'company_type', // 供应商类别
ECW_COOPERATION_TYPE: 'cooperation_type', // 合作类型
ECW_SHIPPING_DECLARATION_TYPE: 'shipping_declaration_type', // 出货报关方式(与订单报关方式相同)
ECW_CUSTOMS_TYPE: 'customs_type', // 订单报关方式(非出货报关),优惠券中的单证报关
//--------ecw--------- //--------ecw---------
CUSTOMER_STATUS: 'customer_status', CUSTOMER_STATUS: 'customer_status',
CUSTOMER_SOURCE: 'customer_source', CUSTOMER_SOURCE: 'customer_source',
......
<template>
<div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="类型" prop="type" :rules='[{required: true, message: "请选择类型"}]'>
<dict-selector
:type="DICT_TYPE.ECW_COUPON_TYPE"
v-model.number="form.type"
placeholder="请选择类型"
/>
</el-form-item>
<el-form-item label="标题中文" prop="titleZh" :rules='[{required: true, message: "不能为空"}]'>
<el-input
v-model="form.titleZh"
placeholder="请输入标题-中文"
type="number"
/>
</el-form-item>
<el-form-item label="标题英文" prop="titleEn" :rules='[{required: true, message: "不能为空"}]'>
<el-input
v-model="form.titleEn"
placeholder="请输入标题-英文"
/>
</el-form-item>
<el-form-item label="有效期" prop="titleEn">
<el-date-picker
clearable
v-model="form.startTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择开始时间"
/>
~
<el-date-picker
clearable
v-model="form.endTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择结束时间"
/>
注意:留空则表示永久有效
</el-form-item>
<el-form-item label="*运费">
<div class="fee-item" v-for="(item, index) in freightFeeList" :key="index">
<el-input v-model="item.fullAmount" style="width:100px" />
<!-- <el-select v-model="item.fullCurrencyId" style="width:100px" >
<el-option v-for="item in currencyList" :key="item.id" :label="item.titleZh" :value="item.id" />
</el-select> -->
<Selector v-model="item.fullCurrencyId" :options="currencyList" label-field="titleZh" value-field="id" defaultable style="width:100px" />
<el-input type="number" v-model="item.reduceAmount" style="width:100px" />
<!-- <el-select v-model="item.reduceCurrencyId" style="width:100px" >
<el-option v-for="item in currencyList" :key="item.id" :label="item.titleZh" :value="item.id" />
</el-select> -->
<Selector v-model="item.fullCurrencyId" :options="currencyList" label-field="titleZh" value-field="id" defaultable style="width:100px" />
<el-button class="el-icon-plus" size="mini" type="primary" @click="freightFeeList.push({})" />
<el-button v-if="freightFeeList.length > 1" class="el-icon-minus" size="mini" type="danger" @click="freightFeeList.splice(index,1)" />
</div>
</el-form-item>
<el-form-item label="清关费">
<div class="fee-item" v-for="(item, index) in clearanceFeeList" :key="index">
<el-input v-model="item.fullAmount" style="width:100px" />
<Selector v-model="item.fullCurrencyId" :options="currencyList" label-field="titleZh" value-field="id" defaultable style="width:100px" />
<el-input v-model="item.reduceAmount" style="width:100px" />
<Selector v-model="item.fullCurrencyId" :options="currencyList" label-field="titleZh" value-field="id" defaultable style="width:100px" />
<el-button class="el-icon-plus" size="mini" type="primary" @click="clearanceFeeList.push({})" />
<el-button v-if="clearanceFeeList.length > 1" class="el-icon-minus" size="mini" type="danger" @click="clearanceFeeList.splice(index,1)" />
</div>
</el-form-item>
<!-- <el-form-item label="使用条件(优惠卷专用)" prop="cashCondition">
<el-input
v-model="form.cashCondition"
placeholder="请输入使用条件(优惠卷专用)"
/>
</el-form-item>
<el-form-item label="减免金额(优惠卷专用)" prop="reduceAmount">
<el-input
v-model="form.reduceAmount"
placeholder="请输入减免金额(优惠卷专用)"
/>
</el-form-item>
<el-form-item label="条件货币ID" prop="conditionCurrencyId">
<el-input
v-model="form.conditionCurrencyId"
placeholder="请输入条件货币ID"
/>
</el-form-item>
<el-form-item label="开始时间" prop="startTime">
<el-date-picker
clearable
v-model="form.startTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择开始时间"
/>
</el-form-item>
<el-form-item label="减免货币ID" prop="reduceCurrencyId">
<el-input
v-model="form.reduceCurrencyId"
placeholder="请输入减免货币ID"
/>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
</el-form-item>
<el-form-item label="领券后X天起生效" prop="afterReceiveDays">
<el-input
v-model="form.afterReceiveDays"
placeholder="请输入领券后X天起生效"
/>
</el-form-item>
<el-form-item label="有效天数" prop="validDays">
<el-input
v-model="form.validDays"
placeholder="请输入有效天数"
/>
</el-form-item>
<el-form-item
label="费用类型"
prop="costType"
>
<dict-selector :type="DICT_TYPE.ECW_COUPON_COST_TYPE" v-model="form.costType"/>
</el-form-item> -->
<!-- <el-form-item label="优惠清单" prop="discountDetailed">
<el-input
v-model="form.discountDetailed"
placeholder="请输入优惠清单"
/>
</el-form-item>
-->
<el-form-item
label="同类叠加"
prop="isSimilarSuperposition"
>
<dict-selector
:type="DICT_TYPE.INFRA_BOOLEAN_STRING"
v-model="form.isSimilarSuperposition"
placeholder="请选择类型"
/>
</el-form-item>
<el-form-item label="可叠加优惠劵列表" prop="couponIds">
<el-input
v-model="form.couponIds"
placeholder="请输入可叠加优惠劵列表"
/>
</el-form-item>
<el-form-item
label="适用用户"
prop="suitableUserType"
>
<dict-selector :type="DICT_TYPE.ECW_SUITABLE_USER_TYPE" v-model="form.suitableUserType" defaultable />
<customers-selector v-if="showCustomerSelector" v-model="form.customerIds" style="margin-top:5px" />
</el-form-item>
<el-form-item
label="适用线路类型"
prop="suitableLineType"
>
<dict-selector :type="DICT_TYPE.ECW_SUITABLE_LINE_TYPE" v-model="form.suitableLineType" />
<routers-selector v-if="showRouterSelector" v-model="form.lineIds" style="margin-top:5px" />
</el-form-item>
<el-form-item
label="适用商品"
prop="prodIds"
>
<!-- <dict-selector :type="DICT_TYPE.ECW_SUITABLE_PROD_TYPE" v-model="form.suitableProdType" /> -->
<products-selector v-model="form.prodIds" />
</el-form-item>
<el-form-item
label="订单属性"
prop="orderAttr"
>
<dict-selector form-type="checkbox" :type="DICT_TYPE.ECW_ORDER_ATTR" v-model="form.orderAttr" multiple />
</el-form-item>
<el-form-item label="是否发送站内信" prop="isSiteContent">
<dict-selector form-type="radio" :type="DICT_TYPE.ECW_YESNO" v-model="form.isSiteContent" />
</el-form-item>
<el-form-item label="*中文内容" prop="contentZh" :rules='[{required: true, message: "不能为空"}]'>
<editor v-model="form.contentZh" :min-height="192" />
</el-form-item>
<el-form-item label="*英文内容" prop="contentEn" :rules='[{required: true, message: "不能为空"}]'>
<editor v-model="form.contentEn" :min-height="192" />
</el-form-item>
<el-form-item
label="品牌"
prop="brand"
>
<dict-selector form-type="checkbox" :type="DICT_TYPE.BRAND_REG_TYPE" v-model="form.brand" multiple />
</el-form-item>
<el-form-item
label="是否控货"
prop="isCargoControl"
>
<dict-selector form-type="checkbox" :type="DICT_TYPE.ECW_YESNO" v-model="form.isCargoControl" multiple />
</el-form-item>
<el-form-item
label="单证报关"
prop="documentDeclaration"
>
<dict-selector form-type="checkbox" :type="DICT_TYPE.ECW_CUSTOMS_TYPE" v-model="form.documentDeclaration" multiple />
</el-form-item>
<!--el-form-item
label="每个用户领券上限,如不填则默认为1"
prop="limitNum"
>
<el-input
v-model="form.limitNum"
placeholder="请输入每个用户领券上限,如不填则默认为1"
/>
</el-form-item>
<el-form-item
label="优惠券过期状态 0:过期 1:未过期"
prop="overdueStatus"
>
<el-radio-group v-model="form.overdueStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label="优惠券投放状态(-1:取消投放 0:等待投放 1:投放 2:违规下架 3:等待审核)"
prop="putonStatus"
>
<el-radio-group v-model="form.putonStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="获取方式 0=客户领取 1=平台发放" prop="getWay">
<el-input
v-model="form.getWay"
placeholder="请输入获取方式 0=客户领取 1=平台发放"
/>
</el-form-item>
<el-form-item
label="是否控货(可多选) 0否 1是"
prop="isCargoControl"
>
<el-input
v-model="form.isCargoControl"
placeholder="请输入是否控货(可多选) 0否 1是"
/>
</el-form-item>
<el-form-item
label="单证报关(可多选) 1 我司全代 2自单代报 3混合报关"
prop="documentDeclaration"
>
<el-input
v-model="form.documentDeclaration"
placeholder="请输入单证报关(可多选) 1 我司全代 2自单代报 3混合报关"
/>
</el-form-item>
<el-form-item label="优惠券状态(0:草稿 1:发布)" prop="status">
<el-radio-group v-model="form.status">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item-->
<el-form-item>
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="$router.back()">返 回</el-button>
<el-button type="default" @click="reset">重 置</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { getCurrencyList } from '@/api/ecw/currency';
import {
createCoupon,
updateCoupon,
deleteCoupon,
getCoupon,
getCouponPage,
exportCouponExcel,
} from "@/api/ecw/coupon";
import CustomersSelector from '@/components/CustomersSelector'
import {getDictData} from '@/utils/dict'
import RoutersSelector from '@/components/RoutersSelector'
import ProductsSelector from '@/components/ProductsSelector'
import Editor from '@/components/Editor'
import Selector from '@/components/Selector'
export default {
name: "CouponEdit",
components: {CustomersSelector, RoutersSelector, ProductsSelector, Editor, Selector},
data() {
return {
// 遮罩层
loading: true,
// 表单参数
form: {
status: 1,
},
// 表单校验
rules: {},
currencyList:[],
clearanceFeeList:[{},{}],
freightFeeList:[{},{}]
};
},
computed:{
// 是否显示客户选择器
showCustomerSelector(){
let dict = getDictData(this.DICT_TYPE.ECW_SUITABLE_USER_TYPE, this.form.suitableUserType)
return dict && dict.cssClass == 'show-selector'
},
// 是否显示路线选择器
showRouterSelector(){
let dict = getDictData(this.DICT_TYPE.ECW_SUITABLE_LINE_TYPE, this.form.suitableLineType)
return dict && dict.cssClass == 'show-selector'
},
// 显示显示产品选择器
showProductsSelector(){
let dict = getDictData(this.DICT_TYPE.ECW_SUITABLE_PROD_TYPE, this.form.suitableProdType)
return dict && dict.cssClass == 'show-selector'
},
discountDetailedVOs(){
let activeField = null
let fields = ['clearanceFeeList', 'freightFeeList']
fields.forEach(field => {
this[field].forEach(feeItem => {
if(feeItem.reduceAmount){
activeField = field
}
})
})
let discountedList = activeField ? this[activeField] : []
discountedList.forEach(item => {
['endAmount',
'fullAmount',
'fullCurrencyId',
'netReceiptsAmount',
'netReceiptsCurrencyId',
'prodUnit',
'reduceAmount',
'reduceCurrencyId',
'startAmount',
'startAndEndCurrencyId'].forEach(field => {
if(item[field])item[field] = parseFloat(item[field])
})
})
return discountedList
}
},
created() {
getCurrencyList().then(res => this.currencyList = res.data)
if (this.$route.query.id) {
getCoupon(this.$route.query.id).then(
(res) => (this.form = res.data)
);
}
this.reset()
},
methods: {
/** 表单重置 */
reset() {
this.form = {
couponId: undefined,
titleZh: undefined,
titleEn: undefined,
type: undefined,
cashCondition: undefined,
reduceAmount: undefined,
conditionCurrencyId: undefined,
startTime: undefined,
reduceCurrencyId: undefined,
endTime: undefined,
afterReceiveDays: undefined,
validDays: undefined,
costType: undefined,
discountDetailed: undefined,
isSimilarSuperposition: undefined,
couponIds: undefined,
suitableUserType: undefined,
suitableLineType: undefined,
suitableProdType: undefined,
limitNum: undefined,
overdueStatus: undefined,
putonStatus: undefined,
getWay: undefined,
orderAttr: undefined,
isSiteContent: undefined,
isCargoControl: undefined,
documentDeclaration: undefined,
status: undefined,
};
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (!valid) {
return;
}
let data = Object.assign({}, this.form, {discountDetailedVOs: this.discountDetailedVOs})
// 开始时间必填
if(!data.startTime)data.startTime = '2022-01-01 00:00:00'
// status必填
data.status = 0
// 修改的提交
if (data.couponId != null) {
updateCoupon(data).then((response) => {
this.$modal.msgSuccess("修改成功");
this.$router.back();
});
return;
}
// 添加的提交
createCoupon(data).then((response) => {
this.$modal.msgSuccess("新增成功");
this.$router.back();
});
});
},
},
};
</script>
<style scoped lang="scss">
.fee-item{
padding: 5px 0;
>div{
margin-right: 5px;
}
}
</style>
\ No newline at end of file
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="标题" prop="titleZh">
<el-input v-model="queryParams.titleZh" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<!-- <el-form-item label="标题" prop="titleEn">
<el-input v-model="queryParams.titleEn" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> -->
<el-form-item label="类型" prop="type">
<!-- 1:优惠卷 2:金额-满减 3:方数-满减 4 折扣 5优惠 6 特价 7区间价-->
<!-- <el-select v-model="queryParams.type" placeholder="请选择类型 1:优惠卷 2:金额-满减 3:方数-满减 4 折扣 5优惠 6 特价 7区间价" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select> -->
<dict-selector :type='DICT_TYPE.ECW_COUPON_TYPE' v-model="queryParams.type" />
</el-form-item>
<!-- <el-form-item label="使用条件(优惠卷专用)" prop="cashCondition">
<el-input v-model="queryParams.cashCondition" placeholder="请输入使用条件(优惠卷专用)" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="减免金额(优惠卷专用)" prop="reduceAmount">
<el-input v-model="queryParams.reduceAmount" placeholder="请输入减免金额(优惠卷专用)" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="条件货币ID" prop="conditionCurrencyId">
<el-input v-model="queryParams.conditionCurrencyId" placeholder="请输入条件货币ID" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> -->
<el-form-item label="开始时间">
<el-date-picker v-model="dateRangeStartTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
</el-form-item>
<!-- <el-form-item label="减免货币ID" prop="reduceCurrencyId">
<el-input v-model="queryParams.reduceCurrencyId" placeholder="请输入减免货币ID" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> -->
<el-form-item label="结束时间">
<el-date-picker v-model="dateRangeEndTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
</el-form-item>
<!-- <el-form-item label="领券后X天起生效" prop="afterReceiveDays">
<el-input v-model="queryParams.afterReceiveDays" placeholder="请输入领券后X天起生效" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="有效天数" prop="validDays">
<el-input v-model="queryParams.validDays" placeholder="请输入有效天数" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> -->
<el-form-item label="费用类型" prop="costType">
<dict-selector :type="DICT_TYPE.ECW_COUPON_COST_TYPE" v-model="queryParams.costType"/>
</el-form-item>
<!-- <el-form-item label="优惠清单" prop="discountDetailed">
<el-input v-model="queryParams.discountDetailed" placeholder="请输入优惠清单" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="同类优惠劵是否可以叠加 0否 1是" prop="isSimilarSuperposition">
<el-select v-model="queryParams.isSimilarSuperposition" placeholder="请选择同类优惠劵是否可以叠加 0否 1是" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="可叠加优惠劵列表" prop="couponIds">
<el-input v-model="queryParams.couponIds" placeholder="请输入可叠加优惠劵列表" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="适用用户类型 0全部用户 1部分用户 2指定用户不参与" prop="suitableUserType">
<el-select v-model="queryParams.suitableUserType" placeholder="请选择适用用户类型 0全部用户 1部分用户 2指定用户不参与" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="适用线路类型 0全部线路参与 1指定线路参与 2指定线路不参与" prop="suitableLineType">
<el-select v-model="queryParams.suitableLineType" placeholder="请选择适用线路类型 0全部线路参与 1指定线路参与 2指定线路不参与" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="适用产品类型 0全部产品参与 1指定产品参与 2指定产品不参与" prop="suitableProdType">
<el-select v-model="queryParams.suitableProdType" placeholder="请选择适用产品类型 0全部产品参与 1指定产品参与 2指定产品不参与" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="每个用户领券上限,如不填则默认为1" prop="limitNum">
<el-input v-model="queryParams.limitNum" placeholder="请输入每个用户领券上限,如不填则默认为1" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> -->
<el-form-item label="过期状态" prop="overdueStatus">
<dict-selector :type="DICT_TYPE.ECW_COUPON_OVERDUE_STATUS" v-model="queryParams.overdueStatus"/>
</el-form-item>
<el-form-item label="投放状态" prop="putonStatus">
<dict-selector :type="DICT_TYPE.ECW_COUPON_PUTON_STATUS" v-model="queryParams.putonStatus"/>
</el-form-item>
<!-- <el-form-item label="获取方式 0=客户领取 1=平台发放" prop="getWay">
<el-input v-model="queryParams.getWay" placeholder="请输入获取方式 0=客户领取 1=平台发放" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="订单属性(可多选) 1 普货 2重货 3泡货" prop="orderAttr">
<el-input v-model="queryParams.orderAttr" placeholder="请输入订单属性(可多选) 1 普货 2重货 3泡货" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="是否发送站内信 0否 1是" prop="isSiteContent">
<el-select v-model="queryParams.isSiteContent" placeholder="请选择是否发送站内信 0否 1是" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="是否控货(可多选) 0否 1是" prop="isCargoControl">
<el-input v-model="queryParams.isCargoControl" placeholder="请输入是否控货(可多选) 0否 1是" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="单证报关(可多选) 1 我司全代 2自单代报 3混合报关" prop="documentDeclaration">
<el-input v-model="queryParams.documentDeclaration" placeholder="请输入单证报关(可多选) 1 我司全代 2自单代报 3混合报关" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> -->
<el-form-item label="状态" prop="status">
<dict-selector :type="DICT_TYPE.ECW_COUPON_STATUS" v-model="queryParams.status"/>
</el-form-item>
<!-- <el-form-item label="创建时间">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
</el-form-item> -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['ecw:coupon:create']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
v-hasPermi="['ecw:coupon:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="优惠券ID" align="center" prop="couponId" />
<el-table-column label="类型" align="center" prop="type">
<template slot-scope="{row}">
<dict-tag :type="DICT_TYPE.COUPON_TYPE" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="标题" align="center" prop="titleZh" />
<!-- <el-table-column label="标题-英文" align="center" prop="titleEn" /> -->
<el-table-column label="使用条件(优惠卷专用)" align="center" prop="cashCondition" />
<el-table-column label="减免金额(优惠卷专用)" align="center" prop="reduceAmount" />
<el-table-column label="条件货币ID" align="center" prop="conditionCurrencyId" />
<el-table-column label="开始时间" align="center" prop="startTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.startTime) }}</span>
</template>
</el-table-column>
<el-table-column label="减免货币ID" align="center" prop="reduceCurrencyId" />
<el-table-column label="结束时间" align="center" prop="endTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.endTime) }}</span>
</template>
</el-table-column>
<el-table-column label="领券后X天起生效" align="center" prop="afterReceiveDays" />
<el-table-column label="有效天数" align="center" prop="validDays" />
<el-table-column label="费用类型:1 运输费 2 清关费 3 总费用(优惠卷专用)" align="center" prop="costType" />
<el-table-column label="优惠清单" align="center" prop="discountDetailed" />
<el-table-column label="同类优惠劵是否可以叠加 0否 1是" align="center" prop="isSimilarSuperposition" />
<el-table-column label="可叠加优惠劵列表" align="center" prop="couponIds" />
<el-table-column label="适用用户类型 0全部用户 1部分用户 2指定用户不参与" align="center" prop="suitableUserType" />
<el-table-column label="适用线路类型 0全部线路参与 1指定线路参与 2指定线路不参与" align="center" prop="suitableLineType" />
<el-table-column label="适用产品类型 0全部产品参与 1指定产品参与 2指定产品不参与" align="center" prop="suitableProdType" />
<el-table-column label="每个用户领券上限,如不填则默认为1" align="center" prop="limitNum" />
<el-table-column label="优惠券过期状态 0:过期 1:未过期" align="center" prop="overdueStatus" />
<el-table-column label="优惠券投放状态(-1:取消投放 0:等待投放 1:投放 2:违规下架 3:等待审核)" align="center" prop="putonStatus" />
<el-table-column label="获取方式 0=客户领取 1=平台发放" align="center" prop="getWay" />
<el-table-column label="订单属性(可多选) 1 普货 2重货 3泡货" align="center" prop="orderAttr" />
<el-table-column label="是否发送站内信 0否 1是" align="center" prop="isSiteContent" />
<el-table-column label="是否控货(可多选) 0否 1是" align="center" prop="isCargoControl" />
<el-table-column label="单证报关(可多选) 1 我司全代 2自单代报 3混合报关" align="center" prop="documentDeclaration" />
<el-table-column label="优惠券状态(0:草稿 1:发布)" align="center" prop="status" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['ecw:coupon:update']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['ecw:coupon:delete']">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
</div>
</template>
<script>
import { createCoupon, updateCoupon, deleteCoupon, getCoupon, getCouponPage, exportCouponExcel } from "@/api/ecw/coupon";
export default {
name: "Coupon",
components: {
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 优惠券信息列表
list: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
dateRangeStartTime: [],
dateRangeEndTime: [],
dateRangeCreateTime: null,
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
titleZh: null,
titleEn: null,
type: null,
cashCondition: null,
reduceAmount: null,
conditionCurrencyId: null,
reduceCurrencyId: null,
afterReceiveDays: null,
validDays: null,
costType: null,
discountDetailed: null,
isSimilarSuperposition: null,
couponIds: null,
suitableUserType: null,
suitableLineType: null,
suitableProdType: null,
limitNum: null,
overdueStatus: null,
putonStatus: null,
getWay: null,
orderAttr: null,
isSiteContent: null,
isCargoControl: null,
documentDeclaration: null,
status: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
getList() {
this.loading = true;
// 处理查询参数
let params = {...this.queryParams};
this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行查询
getCouponPage(params).then(response => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
couponId: undefined,
titleZh: undefined,
titleEn: undefined,
type: undefined,
cashCondition: undefined,
reduceAmount: undefined,
conditionCurrencyId: undefined,
startTime: undefined,
reduceCurrencyId: undefined,
endTime: undefined,
afterReceiveDays: undefined,
validDays: undefined,
costType: undefined,
discountDetailed: undefined,
isSimilarSuperposition: undefined,
couponIds: undefined,
suitableUserType: undefined,
suitableLineType: undefined,
suitableProdType: undefined,
limitNum: undefined,
overdueStatus: undefined,
putonStatus: undefined,
getWay: undefined,
orderAttr: undefined,
isSiteContent: undefined,
isCargoControl: undefined,
documentDeclaration: undefined,
status: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRangeStartTime = [];
this.dateRangeEndTime = [];
this.dateRangeCreateTime = [];
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
return this.$router.push('edit')
},
/** 修改按钮操作 */
handleUpdate(row) {
const couponId = row.couponId;
return this.$router.push('edit?id=' + couponId)
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) {
return;
}
// 修改的提交
if (this.form.couponId != null) {
updateCoupon(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
return;
}
// 添加的提交
createCoupon(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const couponId = row.couponId;
this.$modal.confirm('是否确认删除优惠券信息编号为"' + couponId + '"的数据项?').then(function() {
return deleteCoupon(couponId);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = {...this.queryParams};
params.pageNo = undefined;
params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeStartTime, 'startTime');
this.addBeginAndEndTime(params, this.dateRangeEndTime, 'endTime');
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行导出
this.$modal.confirm('是否确认导出所有优惠券信息数据项?').then(() => {
this.exportLoading = true;
return exportCouponExcel(params);
}).then(response => {
this.$download.excel(response, '${table.classComment}.xls');
this.exportLoading = false;
}).catch(() => {});
}
}
};
</script>
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<el-form-item label="路线" v-if="form.warehouseLineDO"> <el-form-item label="路线" v-if="form.warehouseLineDO">
<el-input :value="'【' + getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, form.warehouseLineDO.transportType) + '】从【'+form.warehouseLineDO.startTitleZh+'】发往【'+form.warehouseLineDO.destTitleZh+'】'" disabled /> <el-input :value="'【' + getDictDataLabel(DICT_TYPE.ECW_TRANSPORT_TYPE, form.warehouseLineDO.transportType) + '】从【'+form.warehouseLineDO.startTitleZh+'】发往【'+form.warehouseLineDO.destTitleZh+'】'" disabled />
</el-form-item> </el-form-item>
<router-selector v-if="!form.id" v-model="selectedRoutes" /> <routers-selector v-if="!form.id" v-model="selectedRoutes" />
<el-card style="margin-bottom: 10px"> <el-card style="margin-bottom: 10px">
<div slot="header" style="font-size:20px;"> <div slot="header" style="font-size:20px;">
价格设置 价格设置
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
</div> </div>
</template> </template>
<script> <script>
import RouterSelector from '@/components/RouterSelector' import RoutersSelector from '@/components/RoutersSelector'
import { createProductPrice, updateProductPrice, deleteProductPrice, getProductPrice, getProductPricePage, exportProductPriceExcel } from "@/api/ecw/productPrice"; import { createProductPrice, updateProductPrice, deleteProductPrice, getProductPrice, getProductPricePage, exportProductPriceExcel } from "@/api/ecw/productPrice";
import { getProduct } from '@/api/ecw/product' import { getProduct } from '@/api/ecw/product'
import { getProductType, getProductTypeList } from '@/api/ecw/productType' import { getProductType, getProductTypeList } from '@/api/ecw/productType'
...@@ -164,7 +164,7 @@ import { getUnitList } from '@/api/ecw/unit'; ...@@ -164,7 +164,7 @@ import { getUnitList } from '@/api/ecw/unit';
import ProductSelector from '@/components/ProductSelector' import ProductSelector from '@/components/ProductSelector'
import {arrryToKeyedObjectBy} from '@/utils/index' import {arrryToKeyedObjectBy} from '@/utils/index'
export default { export default {
components: {RouterSelector, ProductSelector}, components: {RoutersSelector, ProductSelector},
data(){ data(){
return { return {
selectedRoutes: [], // 勾选的路线渠道 selectedRoutes: [], // 勾选的路线渠道
......
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
<el-option v-for="dict in this.getDictDatas('company_type')" <el-option v-for="dict in this.getDictDatas('company_type')"
:key="dict.value" :label="dict.label" :value="dict.value"/> :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select--> </el-select-->
<dict-selector type="company_type" v-model="queryParams.companyType" /> <dict-selector :type="DICT_TYPE.COMPANY_TYPE" v-model="queryParams.companyType" />
</el-form-item> </el-form-item>
<el-form-item label="合作类型" prop="cooperationType"> <el-form-item label="合作类型" prop="cooperationType">
<dict-selector type="cooperation_type" v-model="queryParams.cooperationType" /> <dict-selector :type="DICT_TYPE.ECW_COOPERATION_TYPE" v-model="queryParams.cooperationType" />
<!--el-select v-model="queryParams.cooperationType" placeholder="请选择合作类型" clearable size="small"> <!--el-select v-model="queryParams.cooperationType" placeholder="请选择合作类型" clearable size="small">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select--> </el-select-->
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
<!-- <el-select v-model="queryParams.status" placeholder="请选择是否展示 默认为展示" clearable size="small"> <!-- <el-select v-model="queryParams.status" placeholder="请选择是否展示 默认为展示" clearable size="small">
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> --> </el-select> -->
<dict-selector type="_yesno" v-model="queryParams.status" /> <dict-selector :type="DICT_TYPE.ECW_YES_NO" v-model="queryParams.status" />
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="创建时间">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd" <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<el-button type="text" size="small" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['infra:codegen:delete']">删除</el-button> <el-button type="text" size="small" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['infra:codegen:delete']">删除</el-button>
<el-button type="text" size="small" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['infra:codegen:update']">同步</el-button> <el-button type="text" size="small" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['infra:codegen:update']">同步</el-button>
<el-button type="text" size="small" icon="el-icon-download" @click="handleGenTable(scope.row)" v-hasPermi="['infra:codegen:download']">生成代码</el-button> <el-button type="text" size="small" icon="el-icon-download" @click="handleGenTable(scope.row)" v-hasPermi="['infra:codegen:download']">生成代码</el-button>
<el-button type="text" size="small" icon="el-icon-download" @click="generateValidateCode(scope.row)">生成验证配置</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -101,7 +102,7 @@ ...@@ -101,7 +102,7 @@
</template> </template>
<script> <script>
import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen, import {getCodegenDetail, getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen,
syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/infra/codegen"; syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/infra/codegen";
import importTable from "./importTable"; import importTable from "./importTable";
...@@ -371,7 +372,35 @@ export default { ...@@ -371,7 +372,35 @@ export default {
this.getList(); this.getList();
}); });
}); });
},
generateValidateCode(row){
let l = this.$loading()
getCodegenDetail(row.id).then(res => {
let rules = {}
res.data.columns.forEach(item => {
let rule = {trigger: 'blur'}
if(!item.nullable){
rule.required = true
rule.message = '不能为空'
}
if(['int', 'tinyint', 'bigint'].indexOf(item.columnType)){
rule.type = 'integer'
}
if(item.columnType.indexOf('decimal') === 0){
rule.type = 'decimal'
}
if(item.columnType == 'datetime'){
rule.type = 'date'
} }
rules[item.javaField] = [rule]
})
console.log(row.tableComment + '校验规则', JSON.stringify(rules))
this.$message('规则已生成,打开控制台查看')
})
.finally(res => {
l.close()
})
},
} }
}; };
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment