lion 8 months ago
parent 7646be348d
commit febd50e4ee

@ -2,6 +2,6 @@
ENV='development'
# base api
VUE_APP_BASE_API=https://yikangyang.ali251.langye.net
VUE_APP_UPLOAD_API=https://yikangyang.ali251.langye.net/api/admin/upload-file
VUE_APP_BASE_API=https://yikangyang-test.ali251.langye.net
VUE_APP_UPLOAD_API=https://yikangyangyikangyang-test.ali251.langye.net/api/admin/upload-file
VUE_APP_PREVIEW_API=http://view.ali251.langye.net:8012/onlinePreview

@ -45,7 +45,19 @@
<vxe-column align="center" field="can_multi_num" width="120" title="数量显示"
:edit-render="{ name: 'VxeSelect', options: [{ label: '不显示', value: 0 },{ label: '显示', value: 1 }] }" />
<vxe-column
<vxe-column field="accompany_product_site" min-width="180" title="站点产品价格" header-align="center" align="left" :edit-render="{}">
<template #default="{ row }">
<div v-for="(item, index) in row['accompany_product_site']" :key="index">
<div v-for="value in siteType" :key="value.id">
<div v-if="value.id === item.site_id">
{{ value.name }}{{ item.price }}
</div>
</div>
</div>
</template>
</vxe-column>
<vxe-column
align="center"
field="site_id"
width="160"
@ -68,7 +80,7 @@
<vxe-column field="images_ids" min-width="180" title="产品图集" header-align="center" align="left" :edit-render="{}">
<template #default="{ row }">
<vxe-upload mode='image' :image-config="{width:40,height:40}" v-model="row['images']" name-field="original_name" readonly progress-text="{percent}%"
:more-config="{ maxCount:1,layout: 'horizontal' }" :show-button-text="false" />
:more-config="{maxCount:1,layout: 'horizontal' }" :show-button-text="false" />
</template>
<template #edit="{ row }">
<vxe-upload multiple mode='image' :image-config="{width:40,height:40}" v-model="row['images']" name-field="original_name" progress-text="{percent}%"
@ -218,7 +230,7 @@
page_size: 20,
keyword: '',
type:1,
show_relation: ['cover']
show_relation: ['cover','accompanyProductSite']
},
total: 0,
allAlign: null,
@ -349,8 +361,17 @@
},
editRowEvent(row) {
if (this.$refs['table']) {
this.$refs['table'].setEditRow(row)
// if (this.$refs['table']) {
// this.$refs['table'].setEditRow(row);
// }
this.isShowAdd = true;
if (row && row.id) {
// Editing existing entry
this.$refs.AddAccompany.setType(this.select.type);
this.$refs.AddAccompany.getDetail(row.id);
} else {
// Adding new entry
this.$refs.AddAccompany.resetForm();
}
},
cancelRowEvent(row) {
@ -377,6 +398,7 @@
try {
const res = await index({
...this.select,
filter:[{
key:'type',
op:'eq',
@ -384,7 +406,7 @@
}]
}, false)
res.data.map(item=>{
item.site_id = item.site_id.split(",")
item.site_id = item.site_id?item.site_id.split(",") : []
})
this.tableData = res.data
this.total = res.total

@ -17,9 +17,19 @@
<el-switch v-model="form['status']" :active-value="1" :inactive-value="0" active-text=""
inactive-text="禁用" />
</el-form-item>
<el-form-item label="站点产品价格" prop="accompany_product_site">
<div v-for="(item, index) in accompany_product_site" :key="index" style="display: flex; align-items: center;">
<vxe-tree-select v-model="item.site_id" placeholder="请选择站点" :options="siteType" clearable
:multiple="false" :option-props="{ value: 'id', label: 'name' }" style="width: 45%;" />
<el-input v-model="item.price" placeholder="请输入价格" style="width: 45%; margin-left: 10px;" />
<el-button type="danger" icon="el-icon-delete" @click="removeProductSite(index)" style="margin-left: 10px;"></el-button>
</div>
<el-button type="primary" @click="addProductSite"></el-button>
</el-form-item>
<el-form-item label="关联站点" prop="site_id">
<vxe-tree-select v-model="form['site_id']" placeholder="请选择关联站点" :options="siteType" clearable
:multiple="true" :option-props="{ value: 'id', label: 'name' }" style="width: 100%;" />
:multiple="true" :option-props="{ value: 'id', label: 'name' }" style="width: 100%;" disabled />
</el-form-item>
<el-form-item label="标题图片" prop="cover_id">
<el-upload :action="action" :file-list="coverList"
@ -78,7 +88,8 @@
<script>
import {
save
save,
show
} from '@/api/accompany/accompany'
import {
getToken
@ -113,7 +124,9 @@
visible: false,
coverList:[],
imageList:[],
accompany_product_site:[],
form: {
id:'',
type: 1,
name: '',
price: '',
@ -126,13 +139,17 @@
flow_content: '',
price_content: '',
appoint_content: '',
accompany_product_site: [],
},
rules: {
name: [{
'required': true,
'message': '产品名称必填'
}],
accompany_product_site: [{
'required': true,
'message': '站点产品价格必填'
}]
}
@ -144,6 +161,7 @@
if(!newVal){
this.coverList = []
this.imageList = []
this.accompany_product_site = []
}
},
visible(newVal) {
@ -213,7 +231,9 @@
reset() {
this.coverList = []
this.imageList = []
this.accompany_product_site = []
this.form = {
id:'',
name: '',
site_id: '',
cover_id: '',
@ -224,48 +244,104 @@
flow_content: '',
price_content: '',
appoint_content: '',
accompany_product_site: [],
price: '',
}
this.$refs['elForm'].resetFields()
},
async getDetail(id) {
try {
const detail = await show({
id,
show_relation: ['cover', 'accompanyProductSite']
});
console.log('Detail fetched:', detail); // Log the response
for (const key in this.form) {
if (detail.hasOwnProperty(key)) {
this.form[key] = detail[key];
}
}
this.form.id = id;
// Handle specific fields like images if necessary
if (detail['images']) {
this.imageList = detail['images'];
}
if(detail['cover']){
this.coverList = [detail['cover']]
}
this.accompany_product_site = detail['accompany_product_site'] || [];
this.form.site_id = this.form.site_id?this.form.site_id.split(",") : [];
} catch (err) {
console.error(err);
}
},
submit() {
if (window.$_uploading) {
this.$message.warning('文件正在上传中')
return
this.$message.warning('文件正在上传中');
return;
}
if (this.accompany_product_site.some(item => !item.site_id || !item.price)) {
this.$message.error('站点和价格不能为空');
return;
}
const siteIds = this.accompany_product_site.map(item => item.site_id);
const hasDuplicateSiteId = siteIds.some((id, index) => siteIds.indexOf(id) !== index);
if (hasDuplicateSiteId) {
this.$message.error('站点ID不能重复');
return;
}
this.form.site_id = siteIds.join(",");
this.form.accompany_product_site = this.accompany_product_site;
// Ensure ID is included
if (this.form.id) {
this.form.id = this.form.id;
}
this.form['cover_id'] = ''
if(this.coverList.length>0){
this.form['cover_id'] = this.coverList[0]?.response?.id ?? ''
if(this.coverList[0]?.response?.id){
this.form['cover_id'] = this.coverList[0]?.response?.id
}else{
this.form['cover_id'] = this.coverList[0].id
}
}else{
this.form['cover_id'] = ''
}
this.form['images_ids'] = []
if(this.imageList.length>0){
this.imageList.map(item=>{
this.form.images_ids.push(item?.response?.id ?? '')
if(item.response?.id){
this.form['images_ids'].push(item.response.id)
}else{
this.form['images_ids'].push(item.id)
}
})
}else{
this.form['images_ids'] = []
}
if(this.form.site_id.length>0){
this.form.site_id = this.form.site_id.join(",")
}
console.log("this.form",this.form)
console.log("this.form", this.form,this.imageList,this.coverList);
// return
this.$refs['elForm'].validate(async valid => {
if (valid) {
this.loading = true
this.loading = true;
try {
await save(this.form)
this.$message.success('新增成功')
this.$emit('refresh')
this.$emit('update:isShow', false)
this.loading = false
this.reset()
await save(this.form);
this.$message.success('新增成功');
this.$emit('refresh');
this.$emit('update:isShow', false);
this.loading = false;
this.reset();
} catch (err) {
this.loading = false
this.loading = false;
}
}
})
});
},
addProductSite() {
const price = this.form['price'] || '';
this.accompany_product_site.push({ site_id: '', price });
},
removeProductSite(index) {
this.accompany_product_site.splice(index, 1);
}
}
}

Loading…
Cancel
Save