修改后台创建产品

This commit is contained in:
lcc
2025-05-22 09:28:32 +08:00
parent 76d36cf0e1
commit a10f5a0f64
4 changed files with 236 additions and 7 deletions
+8
View File
@@ -0,0 +1,8 @@
import request from '@/utils/request';
export async function pageBiz(params) {
const res = await request.get('/common/allBiz', {
params
});
return res.data;
}
+173
View File
@@ -0,0 +1,173 @@
<template>
<ele-modal
width="40%"
:visible="visible"
:append-to-body="true"
:close-on-click-modal="true"
custom-class="ele-dialog-form"
title="选择门店"
@update:visible="updateVisible"
>
<el-card shadow="never">
<!-- 未选择的班级数据表格 -->
<ele-pro-table
:datasource="allBiz"
:columns="columns"
height="535px"
:toolkit="[]"
layout="total, prev, pager, next, jumper"
>
<template v-slot:toolkit>
<el-button size="mini" class="ele-btn-icon" @click="removeAll">
移除所有
</el-button>
<el-button size="mini" class="ele-btn-icon" @click="addAll">
全部添加
</el-button>
</template>
<template v-slot:action="{ row }">
<el-button
size="mini"
type="info"
@click="remove(row)"
v-if="selectBiz.includes(row.id)"
>移除</el-button
>
<el-button size="mini" type="primary" @click="add(row)" v-else
>添加</el-button
>
</template>
</ele-pro-table>
</el-card>
</ele-modal>
</template>
<script>
import { pageBiz } from '@/api/biz';
export default {
components: {},
props: {
// 弹窗是否打开
visible: Boolean,
value: {
type: Array,
default: () => []
},
showBiz: {
type: [Object, Array],
default: () => {}
}
},
data() {
return {
// 加载状态
loading: false,
allBiz: [],
selectBiz: Object.values(this.value),
showSelectBiz: { ...this.showBiz },
columns: [
{
prop: 'id',
label: 'ID',
width: 80,
align: 'center'
},
{
prop: 'name',
label: '门店',
showOverflowTooltip: true,
minWidth: 110,
sortable: 'custom'
},
{
columnKey: 'action',
label: '操作',
width: 150,
align: 'center',
slot: 'action'
}
]
};
},
computed: {
// /* 未选择的班级数据 */
unChooseClass() {
return this.allBiz.filter((d) => this.selectBiz.indexOf(d.id) === -1);
}
// // 是否开启响应式布局
// styleResponsive() {
// return this.$store.state.theme.styleResponsive;
// }
},
created() {},
methods: {
/* 获取全部实训班级 */
query() {
pageBiz()
.then((data) => {
this.allBiz = data;
})
.catch((e) => {
this.$message.error(e.message);
});
},
/* 添加 */
add(row) {
this.selectBiz.push(row.id);
this.showSelectBiz[row.id] = row.name;
},
/* 移除 */
remove(row) {
this.selectBiz.splice(this.selectBiz.indexOf(row.id), 1);
this.$delete(this.showSelectBiz, row.id);
},
/* 添加全部 */
addAll() {
this.unChooseClass.forEach((d) => {
this.selectBiz.push(d.id);
this.showSelectBiz[d.id] = d.name;
});
},
/* 移除所有 */
removeAll() {
this.selectBiz.splice(0, this.selectBiz.length);
this.showSelectBiz = {};
},
/* 搜索事件 */
onSearch(where) {
this.lastWhere = where;
this.doReload();
},
/* 更新visible */
updateVisible(value) {
this.$emit('update:visible', value);
}
},
watch: {
visible(visible) {
if (visible && !this.allBiz.length) {
this.query();
}
},
value(newVal) {
this.selectBiz = newVal;
},
showBiz(newVal) {
this.showSelectBiz = newVal;
},
selectBiz(value) {
this.$emit('input', value);
this.$emit('update:showBiz', this.showSelectBiz);
}
}
};
</script>
<style lang="scss" scoped>
:deep(.el-dialog__body) {
padding: 0;
}
:deep(.el-card__body) {
padding: 0;
}
</style>
@@ -31,6 +31,14 @@
</div>
-->
</el-form-item>
<el-form-item label="海报背景图:" prop="posterBg">
<upload-img
v-model="form.posterBg"
:images="form.posterBg"
:limit="1"
:multiple="true"
/>
</el-form-item>
<el-form-item label="优惠券金额:">
<el-input
clearable
@@ -175,6 +183,32 @@
v-model="form.rule"
/>
</el-form-item>
<el-form-item label="可用门店:">
<el-radio-group v-model="form.userType">
<el-radio :label="0">指定门店</el-radio>
<el-radio :label="1">所有门店</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="指定使用门店:" v-if="form.userType === 0">
<el-row>
<el-button @click="showSetBiz = true">选择门店</el-button
><span style="margin-left: 10px"
>已选择
<span class="ele-text-danger">{{ form.bizs.length }}</span></span
>个门店
</el-row>
<el-row>
<el-tag
type="info"
closable
@close="removeBiz(index)"
v-for="(item, index) in form.selectBiz"
:key="index"
>{{ item }}</el-tag
>
</el-row>
<el-row></el-row>
</el-form-item>
<el-form-item label="推广文案:">
<div
style="margin: 8px 0"
@@ -199,6 +233,12 @@
</el-button>
</el-form-item>
</el-form>
<!-- 编辑弹窗 -->
<select-biz
:visible.sync="showSetBiz"
v-model="form.bizs"
:show-biz.sync="form.selectBiz"
/>
<template v-slot:footer>
<el-button @click="updateVisible(false)">取消</el-button>
<el-button type="primary" :loading="loading" @click="save">
@@ -214,12 +254,14 @@
import UploadImg from '@/components/UploadImg/index.vue';
import RegionsSelect from '@/components/RegionsSelect/index.vue';
import CarModelSelector from '@/components/CarSelector/index.vue';
import SelectBiz from '@/components/SelectBiz/index.vue';
export default {
components: {
UploadImg,
RegionsSelect,
CarModelSelector
CarModelSelector,
SelectBiz
},
props: {
// 弹窗是否打开
@@ -256,9 +298,14 @@
age_between: '',
rule: '',
promotion_text: [],
carProductLabel: []
carProductLabel: [],
userType: 0,
bizs: [],
selectBiz: {},
posterBg: []
};
return {
showSetBiz: false,
editVersion: false,
defaultForm,
// 表单数据
@@ -346,6 +393,10 @@
/* 添加海报描述 */
addShareTitle() {
this.form.promotion_text.push('');
},
removeBiz(bizId) {
this.form.bizs.splice(this.form.bizs.indexOf(bizId), 1);
this.$delete(this.form.selectBiz, bizId);
}
},
watch: {
+2 -5
View File
@@ -81,9 +81,6 @@
</template>
<!-- 操作列 -->
<template v-slot:action="{ row }">
<el-link type="primary" :underline="false" @click="edit(row)">
适用门店
</el-link>
<el-link
type="primary"
:underline="false"
@@ -162,7 +159,7 @@
label: '产品信息',
slot: 'title',
showOverflowTooltip: true,
minWidth: 200
minWidth: 150
},
{
prop: 'cityName',
@@ -189,7 +186,7 @@
{
columnKey: 'action',
label: '操作',
width: 150,
width: 200,
align: 'center',
resizable: false,
slot: 'action'