产品关联政策

master
lion 3 months ago
parent 1747ab8d84
commit 6e1233cbc2

@ -2,5 +2,5 @@
ENV = 'production' ENV = 'production'
# base api # base api
VUE_APP_BASE_API = VUE_APP_BASE_API = /
#VUE_APP_BASE_DEV_API = https://yybtest.ali251.langye.net/ #VUE_APP_BASE_DEV_API = https://yybtest.ali251.langye.net/

@ -103,7 +103,8 @@ export default {
auto_fee:'自动扣除佣金', auto_fee:'自动扣除佣金',
auto_refund_fee:'自动反佣', auto_refund_fee:'自动反佣',
manually_refund_fee:'手工返佣', manually_refund_fee:'手工返佣',
auto_finish:'自动核销' auto_finish:'自动核销',
auto_return_by_due_date:'超过预产期指定时间自动退单'
}, },
detail:{}, detail:{},

@ -78,62 +78,73 @@
</el-select> </el-select>
</div> </div>
</div> </div>
</template> </template>
<template v-slot:model> <template v-slot:policy_id>
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label"> <div class="xy-table-item-label">关联政策</div>
<span style="color: red;font-weight: 600;padding-right: 4px;"></span>产品类型 <div class="xy-table-item-content">
</div> <el-select clearable placeholder="请选择关联政策" style="width: 300px" v-model="form.policy_id">
<div class="xy-table-item-content"> <el-option v-for="item in policies" :key="item.id" :value="item.id" :label="item.name">
<Button </el-option>
type="primary" </el-select>
icon="md-add" </div>
style="margin-bottom: 10px" </div>
@click="form.model.push({ name:'' })" </template>
>新增</Button <template v-slot:model>
> <div class="xy-table-item">
<div class="xy-table-item-label">
<xy-table <span style="color: red;font-weight: 600;padding-right: 4px;"></span>产品类型
style="width: 620px" </div>
:height="260" <div class="xy-table-item-content">
:is-page="false" <Button
:list="form.model" type="primary"
:table-item="modelTable" icon="md-add"
> style="margin-bottom: 10px"
<template v-slot:btns> @click="form.model.push({ name:'' })"
<el-table-column >新增</Button
label="操作" >
width="90"
header-align="center" <xy-table
align="center" style="width: 620px"
> :height="260"
<template v-slot:default="scope"> :is-page="false"
<Button :list="form.model"
size="small" :table-item="modelTable"
type="primary" >
ghost <template v-slot:btns>
@click="form.model.splice(scope.$index, 1)" <el-table-column
>删除</Button label="操作"
> width="90"
</template> header-align="center"
</el-table-column> align="center"
</template> >
</xy-table> <template v-slot:default="scope">
</div> <Button
</div> size="small"
</template> type="primary"
<template v-slot:can_buy> ghost
<div class="xy-table-item"> @click="form.model.splice(scope.$index, 1)"
<div class="xy-table-item-label"> >删除</Button
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>是否可购买 >
</div> </template>
<div class="xy-table-item-content number-input"> </el-table-column>
<el-select placeholder="请选择是否可购买" style="width: 300px" v-model="form.can_buy"> </template>
<el-option v-for="item in [{id:1,name:'是'},{id:0,name:'否'}]" :key="item.id" :value="item.id" :label="item.name"> </xy-table>
</el-option> </div>
</el-select> </div>
</div> </template>
</div> <template v-slot:can_buy>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>是否可购买
</div>
<div class="xy-table-item-content number-input">
<el-select placeholder="请选择是否可购买" style="width: 300px" v-model="form.can_buy">
<el-option v-for="item in [{id:1,name:'是'},{id:0,name:'否'}]" :key="item.id" :value="item.id" :label="item.name">
</el-option>
</el-select>
</div>
</div>
</template> </template>
<template v-slot:originalPrice> <template v-slot:originalPrice>
<div class="xy-table-item"> <div class="xy-table-item">
@ -241,7 +252,7 @@
<div class="xy-table-item-label"> <div class="xy-table-item-label">
内容: 内容:
</div> </div>
<div class="xy-table-item-content" style="width:680px"> <div class="xy-table-item-content" style="width:680px">
<xyTinymce v-if="isShow" v-model="form.content"></xyTinymce> <xyTinymce v-if="isShow" v-model="form.content"></xyTinymce>
<!-- <tinymce ref="tinymce" :height="200" v-model="form.content" id='tinymce'></tinymce> --> <!-- <tinymce ref="tinymce" :height="200" v-model="form.content" id='tinymce'></tinymce> -->
</div> </div>
@ -249,10 +260,10 @@
</template> </template>
</xy-dialog> </xy-dialog>
<Modal v-model="isShowMerchantSelect" title="所属商户选择"> <Modal v-model="isShowMerchantSelect" title="所属商户选择">
<div class="searchMerchants"> <div class="searchMerchants">
<el-input type="text" @keyup.enter.native="searchMerchants" v-model="merchantKeyword" placeholder="请输入关键词查找商户"></el-input> <el-input type="text" @keyup.enter.native="searchMerchants" v-model="merchantKeyword" placeholder="请输入关键词查找商户"></el-input>
<el-button type="primary" @click="searchMerchants"></el-button> <el-button type="primary" @click="searchMerchants"></el-button>
</div> </div>
<Table size="small" highlight-row ref="currentRowTable" :columns="merchantTable" :data="merchants" <Table size="small" highlight-row ref="currentRowTable" :columns="merchantTable" :data="merchants"
@on-current-change="merchantSelect" /> @on-current-change="merchantSelect" />
@ -273,12 +284,15 @@
import { import {
index as merchantIndex index as merchantIndex
} from '@/api/merchant' } from '@/api/merchant'
import {
index as policyIndex
} from '@/api/policy'
import { import {
Message Message
} from 'element-ui' } from 'element-ui'
// import tinymce from "@/components/Tinymce" // import tinymce from "@/components/Tinymce"
import xyTinymce from "@/components/XyTinymce/index.vue"; import xyTinymce from "@/components/XyTinymce/index.vue";
import {replaceAll} from "@/utils/index" import {replaceAll} from "@/utils/index"
export default { export default {
components: { components: {
@ -291,7 +305,7 @@
return { return {
id: '', id: '',
isShow: false, isShow: false,
type: 'add', type: 'add',
sortnumberNew:'', sortnumberNew:'',
action: `${process.env.VUE_APP_BASE_API}api/admin/upload-file`, action: `${process.env.VUE_APP_BASE_API}api/admin/upload-file`,
pickerOptions: { pickerOptions: {
@ -313,20 +327,21 @@
} }
}] }]
}, },
productTypeName:'', productTypeName:'',
modelTable:[ policies: [],
{ modelTable:[
label: "产品名称", {
customFn: (row, scope) => { label: "产品名称",
return ( <el-input placeholder = "请填写产品名称" customFn: (row, scope) => {
type = "text" return ( <el-input placeholder = "请填写产品名称"
v-model = { type = "text"
row.name v-model = {
} > row.name
</el-input> } >
); </el-input>
}, );
} },
}
], ],
form: { form: {
name: '', name: '',
@ -334,8 +349,9 @@
merchantId: '', merchantId: '',
shopIds: '', shopIds: '',
productTypePid: '', productTypePid: '',
productTypeId: '', productTypeId: '',
model:[], policy_id: '',
model:[],
can_buy:1, can_buy:1,
originalPrice: '', originalPrice: '',
price: '', price: '',
@ -416,31 +432,31 @@
key: 'state', key: 'state',
sortable: true sortable: true
} }
], ],
merchantKeyword:"", merchantKeyword:"",
merchantIndex: 1, merchantIndex: 1,
merchantTotal: 0, merchantTotal: 0,
} }
}, },
methods: { methods: {
changeProductTypeId(e){ changeProductTypeId(e){
if(e){ if(e){
this.products.map(item=>{ this.products.map(item=>{
if(item.id===e){ if(item.id===e){
this.productTypeName = item.name this.productTypeName = item.name
} }
}) })
} }
}, },
async getDetail() { async getDetail() {
const res = await show({ const res = await show({
id: this.id id: this.id
}) })
this.typeChange(res?.product_type_pid) this.typeChange(res?.product_type_pid)
this.products.map(item=>{ this.products.map(item=>{
if(item.id===res.product_type_id){ if(item.id===res.product_type_id){
this.productTypeName = item.name this.productTypeName = item.name
} }
}) })
this.form = { this.form = {
name: res?.name, name: res?.name,
@ -452,10 +468,11 @@
}, },
shopIds: res?.shop_ids, shopIds: res?.shop_ids,
productTypePid: res?.product_type_pid, productTypePid: res?.product_type_pid,
productTypeId: res?.product_type_id, productTypeId: res?.product_type_id,
model:res.model?JSON.parse(res.model):[], policy_id: res?.policy_id || '',
model:res.model?JSON.parse(res.model):[],
can_buy:res?.can_buy, can_buy:res?.can_buy,
originalPrice: res?.original_price, originalPrice: res?.original_price,
price: res?.price, price: res?.price,
fee: res?.fee, fee: res?.fee,
@ -466,7 +483,7 @@
time: [res?.start_time, res?.end_time], time: [res?.start_time, res?.end_time],
sortnumber: res?.sortnumber, sortnumber: res?.sortnumber,
content: res?.content content: res?.content
} }
console.log("form",this.form) console.log("form",this.form)
// this.$refs['tinymce'].setContent(this.form.content || ' ') // this.$refs['tinymce'].setContent(this.form.content || ' ')
}, },
@ -504,14 +521,21 @@
async getMerchants() { async getMerchants() {
const res = await merchantIndex({ const res = await merchantIndex({
page_size: 10, page_size: 10,
page: this.merchantIndex, page: this.merchantIndex,
keyword:this.merchantKeyword keyword:this.merchantKeyword
}) })
this.merchantTotal = res.total this.merchantTotal = res.total
this.merchants = res.data this.merchants = res.data
}, },
searchMerchants(){ async getPolicies() {
this.getMerchants() const res = await policyIndex({
page_size: 999,
page: 1
})
this.policies = res.data || res.rows || []
},
searchMerchants(){
this.getMerchants()
}, },
merchantPageChange(e) { merchantPageChange(e) {
this.merchantIndex = e this.merchantIndex = e
@ -524,19 +548,19 @@
} }
}, },
// replaceAll(str,before,after){ // replaceAll(str,before,after){
// if(str.indexOf(before) != -1){ // if(str.indexOf(before) != -1){
// return str.replace(new RegExp(before, 'g'),after) // return str.replace(new RegExp(before, 'g'),after)
// }else{ // }else{
// return str // return str
// } // }
// }, // },
async updateSortNumber(){ async updateSortNumber(){
await this.getDetail() await this.getDetail()
this.form.sortnumber = this.sortnumberNew this.form.sortnumber = this.sortnumberNew
await this.submit() await this.submit()
}, },
submit() { submit() {
if (this.type === 'add'||this.type === 'copy') { if (this.type === 'add'||this.type === 'copy') {
@ -546,8 +570,9 @@
merchant_id: this.form.merchantId?.value, merchant_id: this.form.merchantId?.value,
shop_ids: this.form.shopIds, shop_ids: this.form.shopIds,
product_type_pid: this.form.productTypePid, product_type_pid: this.form.productTypePid,
product_type_id: this.form.productTypeId, product_type_id: this.form.productTypeId,
model:this.form.model, policy_id: this.form.policy_id,
model:this.form.model,
can_buy:this.form.can_buy, can_buy:this.form.can_buy,
original_price: this.form.originalPrice.toString(), original_price: this.form.originalPrice.toString(),
price: this.form.price.toString(), price: this.form.price.toString(),
@ -570,7 +595,7 @@
}) })
return return
} }
if (this.type === 'editor') { if (this.type === 'editor') {
// return // return
save({ save({
id: this.id, id: this.id,
@ -579,8 +604,9 @@
merchant_id: this.form.merchantId?.value, merchant_id: this.form.merchantId?.value,
shop_ids: this.form.shopIds, shop_ids: this.form.shopIds,
product_type_pid: this.form.productTypePid, product_type_pid: this.form.productTypePid,
product_type_id: this.form.productTypeId, product_type_id: this.form.productTypeId,
model:this.form.model, policy_id: this.form.policy_id,
model:this.form.model,
can_buy:this.form.can_buy, can_buy:this.form.can_buy,
original_price: this.form.originalPrice.toString(), original_price: this.form.originalPrice.toString(),
price: this.form.price.toString(), price: this.form.price.toString(),
@ -597,7 +623,7 @@
Message({ Message({
type: 'success', type: 'success',
message: '编辑商品成功' message: '编辑商品成功'
}) })
this.sortnumberNew = "" this.sortnumberNew = ""
this.isShow = false this.isShow = false
this.$emit('refresh') this.$emit('refresh')
@ -608,12 +634,13 @@
watch: { watch: {
isShow(newVal) { isShow(newVal) {
if (newVal) { if (newVal) {
this.getPolicies()
if (this.type === 'editor'||this.type === 'copy') { if (this.type === 'editor'||this.type === 'copy') {
this.getDetail() this.getDetail()
} }
if(this.type==='add'){ if(this.type==='add'){
this.form.can_buy = 1 this.form.can_buy = 1
} }
} else { } else {
// this.$refs['tinymce'].setContent(' ') // this.$refs['tinymce'].setContent(' ')
@ -636,15 +663,15 @@
::v-deep .el-input-number .el-input__inner { ::v-deep .el-input-number .el-input__inner {
text-align: left !important; text-align: left !important;
} }
} }
.searchMerchants{ .searchMerchants{
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom:16px; margin-bottom:16px;
.el-input{ .el-input{
width:80% width:80%
} }
} }
</style> </style>
@ -688,4 +715,4 @@
top: 1px; top: 1px;
left: 4%; left: 4%;
} }
</style> </style>

Loading…
Cancel
Save