产品关联政策

master
lion 3 months ago
parent 1747ab8d84
commit 6e1233cbc2

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

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

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

Loading…
Cancel
Save