产品 活动自定义上传字段

master
lion 1 year ago
parent efd118eb96
commit 6dd185596b

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

@ -22,7 +22,6 @@
@click="form.company_ids.push({ type_id: '',type_name:'', company_id: '',name:'' })"
>新增</Button
>
<xy-table
style="width: 620px"
:height="260"
@ -52,6 +51,47 @@
</div>
</div>
</template>
<template v-slot:fields>
<div class="xy-table-item">
<div class="xy-table-item-label">活动提交字段</div>
<div class="xy-table-item-content">
<Button
type="primary"
icon="md-add"
style="margin-bottom: 10px"
@click="form.fields.push({ name: '',filed:'', is_reqired: '',data_name:'',data_id:'' })"
>新增</Button
>
<xy-table
style="width: 620px"
:height="260"
:is-page="false"
:list="form.fields"
:table-item="fieldsTable"
>
<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.fields.splice(scope.$index, 1)"
>删除</Button
>
</template>
</el-table-column>
</template>
</xy-table>
</div>
</div>
</template>
<!-- <template v-slot:shopId>
<div class="xy-table-item">
<div class="xy-table-item-label">
@ -419,9 +459,9 @@ import {index as companyIndex} from "@/api/activitycompany"
import {store,show,save} from "@/api/activity"
import {index as indexType} from "@/api/activityType"
import { Message } from 'element-ui'
import { getparameter } from "@/api/system/dictionary";
import { getparameter,listparameter } from "@/api/system/dictionary";
import xyTinymce from "@/components/XyTinymce/index.vue";
import {replaceAll} from "@/utils/index"
import {replaceAll} from "@/utils/index"
export default {
components:{
@ -434,10 +474,12 @@ export default {
type:'add',
id:'',
action:`${process.env.VUE_APP_BASE_API}api/admin/upload-file`,
companykeyword:"",
companykeyword:"",
parameterList:[],
form:{
activeName:"",
company_ids:[],
fields:[],
shopId:0,
sponsor:0,
sponsorLogo:"",
@ -514,6 +556,97 @@ companykeyword:"",
}
],
types:[],
fieldsTable:[
{
label: "字段名",
width: 140,
customFn: (row) => {
return ( <el-input placeholder = "必填(如:姓名)"
type = "text"
v-model = {
row.name
} >
</el-input>
);
},
},
{
label: "字段标识",
width: 140,
customFn: (row) => {
return ( <el-input placeholder = "必填(如name)"
type = "text"
v-model = {
row.filed
} >
</el-input>
);
},
},
{
label: "是否必填",
minWidth: 120,
customFn: (row,scope) => {
return (
<el-select
placeholder="必填"
style="width: 100px"
value={row.is_reqired}
on={{
["change"]: (e) => (row.is_reqired=e),
}}
>
{
['是','否'].map((item,index)=>{
return(
<el-option
// v-for={item in types}
value={item}
key={index}
label={item}
>
</el-option>
)
})
}
</el-select>
);
},
},
{
label: "关联数据",
width: 140,
customFn: (row) => {
return (
<el-select
placeholder="请选择"
style="width: 140px"
value={row.data_name}
clearable
on={{
["change"]: (e) => (row.data_name=e.name,row.data_id = e.id),
}}
>
{
this.parameterList.map((item,index)=>{
return(
<el-option
// v-for={item in types}
value={item}
key={item.id}
label={item.name}
>
</el-option>
)
})
}
</el-select>
);
},
},
],
contentTable: [
{
label: "关联方类型",
@ -577,6 +710,7 @@ companykeyword:"",
},
created(){
this.getLabels()
this.getparameterList()
},
methods: {
@ -607,7 +741,11 @@ companykeyword:"",
}
},
async getparameterList(){
const res = await listparameter()
console.log("listparameter",res)
this.parameterList = res.data
},
async getLabels() {
const res = await getparameter({
number: "activeCompanyType",
@ -643,6 +781,7 @@ companykeyword:"",
// shopId:{value:res.shop_id,label:res.shop.name},
// sponsor:res.sponsor,
company_ids:res.company_ids?JSON.parse(res.company_ids):[],
fields:res.fields?JSON.parse(res.fields):[],
sponsorLogo:res.sponsor_logo,
sponsorAdvertise:res.sponsor_advertise,
recommend:res.recommend,
@ -681,7 +820,22 @@ companykeyword:"",
await this.submit()
},
hasEmptyValue(obj) {
for (let key in obj) {
if (obj.hasOwnProperty(key) && key !== 'data_id' && key !== 'data_name') {
if (obj[key] === null || obj[key] === undefined || obj[key] === '') {
return true;
} else if (typeof obj[key] === 'object') {
if (hasEmptyValue(obj[key]) === true) {
return true;
}
}
}
}
return false;
},
submit(){
let end_date = this.form.date[1]
let apply_end = this.form.applyDate[1]
if(this.compareDate(apply_end,end_date)){
@ -692,12 +846,27 @@ companykeyword:"",
return
}
if(this.form.fields&&this.form.fields.length>0){
this.form.fields.map((item,index)=>{
if(this.hasEmptyValue(item)){
Message({
type:'warning',
message:`活动提交字段第${index+1}必要字段为空`
})
return
}
})
}
// console.log(this.form)
// return
if(this.type === 'add'||this.type === 'copy'){
console.log(this.form)
// return
return
store({
active_name:this.form.activeName,
company_ids:this.form.company_ids,
fields:this.form.fields,
shop_id:0,
sponsor:0,
sponsor_logo:this.form.sponsorLogo,
@ -742,6 +911,7 @@ companykeyword:"",
id:this.id,
active_name:this.form.activeName,
company_ids:this.form.company_ids,
fields:this.form.fields,
shop_id:0,
sponsor:0,
sponsor_logo:this.form.sponsorLogo,

@ -368,7 +368,19 @@
prop: "member.address",
label: "地址",
width: 160,
align:'left'
align:'left',
customFn: (row) => {
return(<div>
{
row.member_address? <div> {
row.member_address
} </div> : <div>{
row.member?row.member.address:''
}</div>
}
</div>)
}
},
{
prop: "member.due_date",
@ -376,10 +388,15 @@
width: 120
},
{
prop: "product_type.name",
label: "产品类型",
width: 100
},
prop: "product_type.name",
label: "产品类型",
width: 100
},
{
prop: "order.model_name",
label: "产品型号",
width: 100
},
{
prop: "merchant.username",
label: "服务商家",

@ -72,12 +72,55 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>产品类别
</div>
<div class="xy-table-item-content">
<el-select clearable placeholder="请选择产品类别" style="width: 300px" v-model="form.productTypeId">
<el-select clearable placeholder="请选择产品类别" @change="changeProductTypeId" style="width: 300px" v-model="form.productTypeId">
<el-option v-for="item in products" :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:originalPrice>
<div class="xy-table-item">
@ -257,14 +300,29 @@
}
}]
},
productTypeName:'',
modelTable:[
{
label: "产品名称",
customFn: (row, scope) => {
return ( <el-input placeholder = "请填写产品名称"
type = "text"
v-model = {
row.name
} >
</el-input>
);
},
}
],
form: {
name: '',
poster: '',
merchantId: '',
shopIds: '',
productTypePid: '',
productTypeId: '',
productTypeId: '',
model:[],
originalPrice: '',
price: '',
fee: '',
@ -350,12 +408,26 @@
merchantTotal: 0,
}
},
methods: {
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.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,
poster: res?.poster,
@ -366,7 +438,8 @@
},
shopIds: res?.shop_ids,
productTypePid: res?.product_type_pid,
productTypeId: res?.product_type_id,
productTypeId: res?.product_type_id,
model:res.model?JSON.parse(res.model):[],
originalPrice: res?.original_price,
price: res?.price,
fee: res?.fee,
@ -457,7 +530,8 @@
merchant_id: this.form.merchantId?.value,
shop_ids: this.form.shopIds,
product_type_pid: this.form.productTypePid,
product_type_id: this.form.productTypeId,
product_type_id: this.form.productTypeId,
model:this.form.model,
original_price: this.form.originalPrice.toString(),
price: this.form.price.toString(),
fee: this.form.fee.toString(),
@ -488,7 +562,8 @@
merchant_id: this.form.merchantId?.value,
shop_ids: this.form.shopIds,
product_type_pid: this.form.productTypePid,
product_type_id: this.form.productTypeId,
product_type_id: this.form.productTypeId,
model:this.form.model,
original_price: this.form.originalPrice.toString(),
price: this.form.price.toString(),
fee: this.form.fee.toString(),

Loading…
Cancel
Save