| @ -0,0 +1,253 @@ | |||
| <template> | |||
| <a-card :bordered="false"> | |||
| <!-- 查询区域 --> | |||
| <div class="table-page-search-wrapper"> | |||
| <a-form layout="inline" @keyup.enter.native="searchQuery"> | |||
| <a-row :gutter="24"> | |||
| <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |||
| <a-form-item label="商品分类"> | |||
| <j-multi-select-tag placeholder="请选择商品分类" dictCode="common_shop_class,title,id" v-model="queryParam.shopClass"/> | |||
| </a-form-item> | |||
| </a-col> | |||
| <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |||
| <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> | |||
| <a-button type="primary" @click="searchQuery" icon="search">查询</a-button> | |||
| <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> | |||
| <a @click="handleToggleSearch" style="margin-left: 8px"> | |||
| {{ toggleSearchStatus ? '收起' : '展开' }} | |||
| <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/> | |||
| </a> | |||
| </span> | |||
| </a-col> | |||
| </a-row> | |||
| </a-form> | |||
| </div> | |||
| <!-- 查询区域-END --> | |||
| <!-- 操作按钮区域 --> | |||
| <div class="table-operator"> | |||
| <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> | |||
| <!-- <a-button type="primary" icon="download" @click="handleExportXls('商品信息表')">导出</a-button>--> | |||
| <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">--> | |||
| <!-- <a-button type="primary" icon="import">导入</a-button>--> | |||
| <!-- </a-upload>--> | |||
| <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>--> | |||
| <a-dropdown v-if="selectedRowKeys.length > 0"> | |||
| <a-menu slot="overlay"> | |||
| <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item> | |||
| </a-menu> | |||
| <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button> | |||
| </a-dropdown> | |||
| </div> | |||
| <!-- table区域-begin --> | |||
| <div> | |||
| <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;"> | |||
| <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项 | |||
| <a style="margin-left: 24px" @click="onClearSelected">清空</a> | |||
| </div> | |||
| <a-table | |||
| ref="table" | |||
| size="middle" | |||
| :scroll="{x:true}" | |||
| bordered | |||
| rowKey="id" | |||
| :columns="columns" | |||
| :dataSource="dataSource" | |||
| :pagination="ipagination" | |||
| :loading="loading" | |||
| :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" | |||
| class="j-table-force-nowrap" | |||
| @change="handleTableChange"> | |||
| <template slot="htmlSlot" slot-scope="text"> | |||
| <div v-html="text"></div> | |||
| </template> | |||
| <template slot="imgSlot" slot-scope="text,record"> | |||
| <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span> | |||
| <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/> | |||
| </template> | |||
| <template slot="fileSlot" slot-scope="text"> | |||
| <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span> | |||
| <a-button | |||
| v-else | |||
| :ghost="true" | |||
| type="primary" | |||
| icon="download" | |||
| size="small" | |||
| @click="downloadFile(text)"> | |||
| 下载 | |||
| </a-button> | |||
| </template> | |||
| <span slot="action" slot-scope="text, record"> | |||
| <a @click="handleEdit(record)">编辑</a> | |||
| <a-divider type="vertical" /> | |||
| <a-dropdown> | |||
| <a class="ant-dropdown-link">更多 <a-icon type="down" /></a> | |||
| <a-menu slot="overlay"> | |||
| <a-menu-item> | |||
| <a @click="handleDetail(record)">详情</a> | |||
| </a-menu-item> | |||
| <a-menu-item> | |||
| <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)"> | |||
| <a>删除</a> | |||
| </a-popconfirm> | |||
| </a-menu-item> | |||
| </a-menu> | |||
| </a-dropdown> | |||
| </span> | |||
| </a-table> | |||
| </div> | |||
| <common-shop-modal ref="modalForm" @ok="modalFormOk"></common-shop-modal> | |||
| </a-card> | |||
| </template> | |||
| <script> | |||
| import '@/assets/less/TableExpand.less' | |||
| import { mixinDevice } from '@/utils/mixin' | |||
| import { JeecgListMixin } from '@/mixins/JeecgListMixin' | |||
| import CommonShopModal from './modules/CommonShopModal' | |||
| import {filterMultiDictText} from '@/components/dict/JDictSelectUtil' | |||
| export default { | |||
| name: 'CommonShopList', | |||
| mixins:[JeecgListMixin, mixinDevice], | |||
| components: { | |||
| CommonShopModal | |||
| }, | |||
| data () { | |||
| return { | |||
| description: '商品信息表管理页面', | |||
| // 表头 | |||
| columns: [ | |||
| { | |||
| title: '#', | |||
| dataIndex: '', | |||
| key:'rowIndex', | |||
| width:60, | |||
| align:"center", | |||
| customRender:function (t,r,index) { | |||
| return parseInt(index)+1; | |||
| } | |||
| }, | |||
| { | |||
| title:'创建日期', | |||
| align:"center", | |||
| dataIndex: 'createTime' | |||
| }, | |||
| { | |||
| title:'商品分类', | |||
| align:"center", | |||
| dataIndex: 'shopClass_dictText' | |||
| }, | |||
| { | |||
| title:'商品标题', | |||
| align:"center", | |||
| dataIndex: 'name' | |||
| }, | |||
| { | |||
| title:'商品图片', | |||
| align:"center", | |||
| dataIndex: 'image', | |||
| scopedSlots: {customRender: 'imgSlot'} | |||
| }, | |||
| { | |||
| title:'是否上架', | |||
| align:"center", | |||
| dataIndex: 'status_dictText' | |||
| }, | |||
| { | |||
| title:'商品说明', | |||
| align:"center", | |||
| dataIndex: 'service' | |||
| }, | |||
| { | |||
| title:'最低价格', | |||
| align:"center", | |||
| dataIndex: 'price' | |||
| }, | |||
| { | |||
| title:'最高价格', | |||
| align:"center", | |||
| dataIndex: 'maxPrice' | |||
| }, | |||
| { | |||
| title:'单位', | |||
| align:"center", | |||
| dataIndex: 'unit' | |||
| }, | |||
| { | |||
| title:'是否品牌', | |||
| align:"center", | |||
| dataIndex: 'isPin', | |||
| customRender: (text) => (text ? filterMultiDictText(this.dictOptions['isPin'], text) : ''), | |||
| }, | |||
| { | |||
| title:'显示回收规则', | |||
| align:"center", | |||
| dataIndex: 'isRecycleRules', | |||
| customRender: (text) => (text ? filterMultiDictText(this.dictOptions['isRecycleRules'], text) : ''), | |||
| }, | |||
| { | |||
| title: '操作', | |||
| dataIndex: 'action', | |||
| align:"center", | |||
| fixed:"right", | |||
| width:147, | |||
| scopedSlots: { customRender: 'action' } | |||
| } | |||
| ], | |||
| url: { | |||
| list: "/commonShop/commonShop/list", | |||
| delete: "/commonShop/commonShop/delete", | |||
| deleteBatch: "/commonShop/commonShop/deleteBatch", | |||
| exportXlsUrl: "/commonShop/commonShop/exportXls", | |||
| importExcelUrl: "commonShop/commonShop/importExcel", | |||
| }, | |||
| dictOptions:{}, | |||
| superFieldList:[], | |||
| } | |||
| }, | |||
| created() { | |||
| this.$set(this.dictOptions, 'isPin', [{text:'是',value:'Y'},{text:'否',value:'N'}]) | |||
| this.$set(this.dictOptions, 'isRecycleRules', [{text:'是',value:'Y'},{text:'否',value:'N'}]) | |||
| this.getSuperFieldList(); | |||
| }, | |||
| computed: { | |||
| importExcelUrl: function(){ | |||
| return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; | |||
| }, | |||
| }, | |||
| methods: { | |||
| initDictConfig(){ | |||
| }, | |||
| getSuperFieldList(){ | |||
| let fieldList=[]; | |||
| fieldList.push({type:'datetime',value:'createTime',text:'创建日期'}) | |||
| fieldList.push({type:'Text',value:'shopCion',text:'关联品牌',dictCode:"common_vip,name,id"}) | |||
| fieldList.push({type:'list_multi',value:'shopClass',text:'商品分类',dictTable:"common_shop_class", dictText:'title', dictCode:'id'}) | |||
| fieldList.push({type:'string',value:'name',text:'商品标题',dictCode:''}) | |||
| fieldList.push({type:'Text',value:'image',text:'商品图片',dictCode:''}) | |||
| fieldList.push({type:'int',value:'status',text:'是否上架',dictCode:'book_my_status'}) | |||
| fieldList.push({type:'string',value:'service',text:'商品说明',dictCode:''}) | |||
| fieldList.push({type:'Text',value:'details',text:'回收规则',dictCode:''}) | |||
| fieldList.push({type:'BigDecimal',value:'price',text:'最低价格',dictCode:''}) | |||
| fieldList.push({type:'BigDecimal',value:'maxPrice',text:'最高价格',dictCode:''}) | |||
| fieldList.push({type:'string',value:'unit',text:'单位',dictCode:''}) | |||
| fieldList.push({type:'switch',value:'isPin',text:'是否品牌'}) | |||
| fieldList.push({type:'switch',value:'isRecycleRules',text:'显示回收规则'}) | |||
| this.superFieldList = fieldList | |||
| } | |||
| } | |||
| } | |||
| </script> | |||
| <style scoped> | |||
| @import '~@assets/less/common.less'; | |||
| </style> | |||
| @ -0,0 +1,495 @@ | |||
| <template> | |||
| <a-modal | |||
| :title="title" | |||
| :width="'80%'" | |||
| :height="'80%'" | |||
| :visible="visible" | |||
| :confirmLoading="confirmLoading" | |||
| @ok="handleOk" | |||
| @cancel="handleCancel" | |||
| cancelText="取消" | |||
| okText="确定" | |||
| :bodyStyle="{ height: '80vh', overflow: 'hidden' }" | |||
| > | |||
| <div class="brand-select-container"> | |||
| <!-- 操作按钮区域 --> | |||
| <div class="operation-bar"> | |||
| <a-space> | |||
| <a-button type="primary" size="small" @click="selectAll">全选</a-button> | |||
| <a-button size="small" @click="unselectAll">全不选</a-button> | |||
| <a-button size="small" @click="reverseSelect">反选</a-button> | |||
| <span class="selected-count">已选择: {{ selectedBrands.length }} 个品牌</span> | |||
| </a-space> | |||
| </div> | |||
| <!-- 品牌分类和品牌列表 --> | |||
| <a-spin :spinning="loading"> | |||
| <div class="brand-categories"> | |||
| <div | |||
| v-for="category in brandCategories" | |||
| :key="category.id" | |||
| class="category-section" | |||
| > | |||
| <div class="category-header" @click="toggleCategoryExpand(category.id)"> | |||
| <div class="category-left"> | |||
| <a-icon | |||
| :type="isCategoryExpanded(category.id) ? 'down' : 'right'" | |||
| class="expand-icon" | |||
| /> | |||
| <a-checkbox | |||
| :checked="isCategoryAllSelected(category.id)" | |||
| :indeterminate="isCategoryIndeterminate(category.id)" | |||
| @change="onCategorySelectChange(category.id, $event)" | |||
| @click.stop | |||
| > | |||
| <span class="category-name">{{ category.name }}</span> | |||
| <span class="category-count">({{ getCategoryBrandCount(category.id) }})</span> | |||
| </a-checkbox> | |||
| </div> | |||
| <a-space size="small" @click.stop> | |||
| <a-button | |||
| type="link" | |||
| size="small" | |||
| @click="selectCategoryAll(category.id)" | |||
| > | |||
| 全选 | |||
| </a-button> | |||
| <a-button | |||
| type="link" | |||
| size="small" | |||
| @click="unselectCategoryAll(category.id)" | |||
| > | |||
| 全不选 | |||
| </a-button> | |||
| <a-button | |||
| type="link" | |||
| size="small" | |||
| @click="reverseCategorySelect(category.id)" | |||
| > | |||
| 反选 | |||
| </a-button> | |||
| </a-space> | |||
| </div> | |||
| <div v-if="isCategoryExpanded(category.id)" class="brands-grid"> | |||
| <div | |||
| v-for="brand in getCategoryBrands(category.id)" | |||
| :key="brand.id" | |||
| class="brand-item" | |||
| :class="{ 'selected': selectedBrands.includes(String(brand.id)) }" | |||
| @click="toggleBrandSelect(brand.id)" | |||
| > | |||
| <a-checkbox | |||
| :checked="selectedBrands.includes(String(brand.id))" | |||
| @click.stop | |||
| @change="onBrandSelectChange(brand.id, $event)" | |||
| > | |||
| </a-checkbox> | |||
| <div class="brand-content"> | |||
| <img | |||
| v-if="brand.image" | |||
| :src="getImageUrl(brand.image)" | |||
| :alt="brand.name" | |||
| class="brand-image" | |||
| @error="onImageError" | |||
| /> | |||
| <div v-else class="brand-image-placeholder"> | |||
| <a-icon type="picture" /> | |||
| </div> | |||
| <div class="brand-name" :title="brand.name">{{ brand.name }}</div> | |||
| <div v-if="brand.hot === '1'" class="hot-tag">热门</div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <!-- 空状态 --> | |||
| <div v-if="!loading && brandCategories.length === 0" class="empty-state"> | |||
| <a-empty description="暂无品牌数据" /> | |||
| </div> | |||
| </a-spin> | |||
| </div> | |||
| </a-modal> | |||
| </template> | |||
| <script> | |||
| import { getAction } from '@/api/manage' | |||
| export default { | |||
| name: 'BrandSelectModal', | |||
| components: { | |||
| }, | |||
| props: { | |||
| visible: { | |||
| type: Boolean, | |||
| default: false | |||
| }, | |||
| value: { | |||
| type: [String, Array], | |||
| default: () => [] | |||
| }, | |||
| title: { | |||
| type: String, | |||
| default: '选择品牌' | |||
| } | |||
| }, | |||
| data() { | |||
| return { | |||
| confirmLoading: false, | |||
| loading: false, | |||
| brandCategories: [], | |||
| allBrands: [], | |||
| selectedBrands: [], | |||
| expandedCategories: [] // 展开的分类ID列表 | |||
| } | |||
| }, | |||
| watch: { | |||
| visible(val) { | |||
| if (val) { | |||
| this.initData() | |||
| } | |||
| } | |||
| }, | |||
| methods: { | |||
| // 初始化选中的品牌(不依赖watch) | |||
| initSelectedBrands() { | |||
| if (Array.isArray(this.value)) { | |||
| // 确保数组中的ID都是字符串类型,保持一致性 | |||
| this.selectedBrands = this.value.map(id => String(id)) | |||
| } else if (typeof this.value === 'string' && this.value) { | |||
| this.selectedBrands = this.value.split(',').map(id => id.trim()) | |||
| } else { | |||
| this.selectedBrands = [] | |||
| } | |||
| }, | |||
| async initData() { | |||
| this.loading = true | |||
| try { | |||
| // 并行获取品牌分类和品牌数据 | |||
| const [categoryRes, brandRes] = await Promise.all([ | |||
| getAction('/commonBrandCategory/commonBrandCategory/list', { pageNo: 1, pageSize: 99999 }), | |||
| getAction('/commonVip/commonVip/list', { pageNo: 1, pageSize: 99999 }) | |||
| ]) | |||
| if (categoryRes.success) { | |||
| this.brandCategories = categoryRes.result.records || [] | |||
| } | |||
| if (brandRes.success) { | |||
| this.allBrands = brandRes.result.records || [] | |||
| } | |||
| // 数据加载完成后,直接根据value设置选中状态 | |||
| this.initSelectedBrands() | |||
| } catch (error) { | |||
| console.error('获取品牌数据失败:', error) | |||
| this.$message.error('获取品牌数据失败') | |||
| } finally { | |||
| this.loading = false | |||
| } | |||
| }, | |||
| // 获取指定分类下的品牌 | |||
| getCategoryBrands(categoryId) { | |||
| return this.allBrands.filter(brand => brand.brandCategory === categoryId) | |||
| }, | |||
| // 获取分类下品牌数量 | |||
| getCategoryBrandCount(categoryId) { | |||
| return this.getCategoryBrands(categoryId).length | |||
| }, | |||
| // 判断分类是否展开 | |||
| isCategoryExpanded(categoryId) { | |||
| return this.expandedCategories.includes(categoryId) | |||
| }, | |||
| // 切换分类展开状态 | |||
| toggleCategoryExpand(categoryId) { | |||
| const index = this.expandedCategories.indexOf(categoryId) | |||
| if (index > -1) { | |||
| this.expandedCategories.splice(index, 1) | |||
| } else { | |||
| this.expandedCategories.push(categoryId) | |||
| } | |||
| }, | |||
| // 判断分类是否全选 | |||
| isCategoryAllSelected(categoryId) { | |||
| const categoryBrands = this.getCategoryBrands(categoryId) | |||
| return categoryBrands.length > 0 && categoryBrands.every(brand => this.selectedBrands.includes(String(brand.id))) | |||
| }, | |||
| // 判断分类是否部分选中 | |||
| isCategoryIndeterminate(categoryId) { | |||
| const categoryBrands = this.getCategoryBrands(categoryId) | |||
| const selectedCount = categoryBrands.filter(brand => this.selectedBrands.includes(String(brand.id))).length | |||
| return selectedCount > 0 && selectedCount < categoryBrands.length | |||
| }, | |||
| // 分类选择变化 | |||
| onCategorySelectChange(categoryId, event) { | |||
| const checked = event.target.checked | |||
| if (checked) { | |||
| this.selectCategoryAll(categoryId) | |||
| } else { | |||
| this.unselectCategoryAll(categoryId) | |||
| } | |||
| }, | |||
| // 品牌选择变化 | |||
| onBrandSelectChange(brandId, event) { | |||
| const checked = event.target.checked | |||
| const brandIdStr = String(brandId) | |||
| if (checked) { | |||
| if (!this.selectedBrands.includes(brandIdStr)) { | |||
| this.selectedBrands.push(brandIdStr) | |||
| } | |||
| } else { | |||
| const index = this.selectedBrands.indexOf(brandIdStr) | |||
| if (index > -1) { | |||
| this.selectedBrands.splice(index, 1) | |||
| } | |||
| } | |||
| }, | |||
| // 切换品牌选择状态 | |||
| toggleBrandSelect(brandId) { | |||
| const brandIdStr = String(brandId) | |||
| const index = this.selectedBrands.indexOf(brandIdStr) | |||
| if (index > -1) { | |||
| this.selectedBrands.splice(index, 1) | |||
| } else { | |||
| this.selectedBrands.push(brandIdStr) | |||
| } | |||
| }, | |||
| // 全选 | |||
| selectAll() { | |||
| this.selectedBrands = this.allBrands.map(brand => String(brand.id)) | |||
| }, | |||
| // 全不选 | |||
| unselectAll() { | |||
| this.selectedBrands = [] | |||
| }, | |||
| // 反选 | |||
| reverseSelect() { | |||
| const allBrandIds = this.allBrands.map(brand => String(brand.id)) | |||
| this.selectedBrands = allBrandIds.filter(id => !this.selectedBrands.includes(id)) | |||
| }, | |||
| // 分类全选 | |||
| selectCategoryAll(categoryId) { | |||
| const categoryBrands = this.getCategoryBrands(categoryId) | |||
| categoryBrands.forEach(brand => { | |||
| const brandIdStr = String(brand.id) | |||
| if (!this.selectedBrands.includes(brandIdStr)) { | |||
| this.selectedBrands.push(brandIdStr) | |||
| } | |||
| }) | |||
| }, | |||
| // 分类全不选 | |||
| unselectCategoryAll(categoryId) { | |||
| const categoryBrands = this.getCategoryBrands(categoryId) | |||
| categoryBrands.forEach(brand => { | |||
| const brandIdStr = String(brand.id) | |||
| const index = this.selectedBrands.indexOf(brandIdStr) | |||
| if (index > -1) { | |||
| this.selectedBrands.splice(index, 1) | |||
| } | |||
| }) | |||
| }, | |||
| // 分类反选 | |||
| reverseCategorySelect(categoryId) { | |||
| const categoryBrands = this.getCategoryBrands(categoryId) | |||
| categoryBrands.forEach(brand => { | |||
| const brandIdStr = String(brand.id) | |||
| const index = this.selectedBrands.indexOf(brandIdStr) | |||
| if (index > -1) { | |||
| this.selectedBrands.splice(index, 1) | |||
| } else { | |||
| this.selectedBrands.push(brandIdStr) | |||
| } | |||
| }) | |||
| }, | |||
| // 获取图片URL | |||
| getImageUrl(image) { | |||
| if (!image) return '' | |||
| if (image.startsWith('http')) return image | |||
| return `${process.env.VUE_APP_API_BASE_URL}/sys/common/static/${image}` | |||
| }, | |||
| // 图片加载错误处理 | |||
| onImageError(event) { | |||
| event.target.style.display = 'none' | |||
| event.target.nextElementSibling.style.display = 'flex' | |||
| }, | |||
| // 确定 | |||
| handleOk() { | |||
| this.$emit('input', this.selectedBrands) | |||
| this.$emit('ok', this.selectedBrands) | |||
| this.handleCancel() | |||
| }, | |||
| // 取消 | |||
| handleCancel() { | |||
| this.$emit('cancel') | |||
| } | |||
| } | |||
| } | |||
| </script> | |||
| <style lang="less" scoped> | |||
| .brand-select-container { | |||
| height: 100%; | |||
| display: flex; | |||
| flex-direction: column; | |||
| .operation-bar { | |||
| padding: 16px 0; | |||
| border-bottom: 1px solid #f0f0f0; | |||
| margin-bottom: 16px; | |||
| flex-shrink: 0; | |||
| .selected-count { | |||
| color: #666; | |||
| font-size: 14px; | |||
| } | |||
| } | |||
| .brand-categories { | |||
| flex: 1; | |||
| overflow-y: auto; | |||
| max-height: calc(80vh - 120px); /* 减去操作栏和弹窗头部的高度 */ | |||
| .category-section { | |||
| margin-bottom: 24px; | |||
| .category-header { | |||
| display: flex; | |||
| justify-content: space-between; | |||
| align-items: center; | |||
| padding: 12px 16px; | |||
| background: #fafafa; | |||
| border-radius: 6px; | |||
| margin-bottom: 12px; | |||
| cursor: pointer; | |||
| transition: background-color 0.3s; | |||
| &:hover { | |||
| background: #f0f0f0; | |||
| } | |||
| .category-left { | |||
| display: flex; | |||
| align-items: center; | |||
| .expand-icon { | |||
| margin-right: 8px; | |||
| color: #666; | |||
| transition: transform 0.3s; | |||
| } | |||
| } | |||
| .category-name { | |||
| font-weight: 500; | |||
| font-size: 16px; | |||
| } | |||
| .category-count { | |||
| color: #999; | |||
| font-size: 14px; | |||
| } | |||
| } | |||
| .brands-grid { | |||
| display: grid; | |||
| grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); | |||
| gap: 12px; | |||
| padding: 0 8px; | |||
| .brand-item { | |||
| display: flex; | |||
| align-items: center; | |||
| padding: 12px; | |||
| border: 1px solid #e8e8e8; | |||
| border-radius: 6px; | |||
| cursor: pointer; | |||
| transition: all 0.3s; | |||
| &:hover { | |||
| border-color: #1890ff; | |||
| box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2); | |||
| } | |||
| &.selected { | |||
| border-color: #1890ff; | |||
| background: #f6ffed; | |||
| } | |||
| .brand-content { | |||
| display: flex; | |||
| align-items: center; | |||
| flex: 1; | |||
| margin-left: 8px; | |||
| position: relative; | |||
| .brand-image { | |||
| width: 32px; | |||
| height: 32px; | |||
| border-radius: 4px; | |||
| object-fit: cover; | |||
| margin-right: 8px; | |||
| } | |||
| .brand-image-placeholder { | |||
| width: 32px; | |||
| height: 32px; | |||
| border-radius: 4px; | |||
| background: #f5f5f5; | |||
| display: flex; | |||
| align-items: center; | |||
| justify-content: center; | |||
| margin-right: 8px; | |||
| color: #ccc; | |||
| } | |||
| .brand-name { | |||
| flex: 1; | |||
| font-size: 14px; | |||
| overflow: hidden; | |||
| text-overflow: ellipsis; | |||
| white-space: nowrap; | |||
| } | |||
| .hot-tag { | |||
| position: absolute; | |||
| top: -6px; | |||
| right: -6px; | |||
| background: #ff4d4f; | |||
| color: white; | |||
| font-size: 10px; | |||
| padding: 2px 4px; | |||
| border-radius: 2px; | |||
| transform: scale(0.8); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| .empty-state { | |||
| text-align: center; | |||
| padding: 40px 0; | |||
| } | |||
| } | |||
| </style> | |||
| @ -0,0 +1,286 @@ | |||
| <template> | |||
| <a-spin :spinning="confirmLoading"> | |||
| <j-form-container :disabled="formDisabled"> | |||
| <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail"> | |||
| <a-row> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="关联品牌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shopCion"> | |||
| <div class="brand-select-wrapper"> | |||
| <a-input | |||
| v-model="brandDisplayText" | |||
| placeholder="请选择关联品牌" | |||
| readonly | |||
| @click="showBrandSelectModal" | |||
| style="cursor: pointer;" | |||
| > | |||
| <a-icon slot="suffix" type="down" /> | |||
| </a-input> | |||
| <a-button | |||
| type="link" | |||
| size="small" | |||
| @click="showBrandSelectModal" | |||
| style="margin-left: 8px;" | |||
| > | |||
| 选择品牌 | |||
| </a-button> | |||
| </div> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="商品分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shopClass"> | |||
| <j-multi-select-tag type="list_multi" v-model="model.shopClass" dictCode="common_shop_class,title,id" placeholder="请选择商品分类" /> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="商品标题" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name"> | |||
| <a-input v-model="model.name" placeholder="请输入商品标题" ></a-input> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="商品图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="image"> | |||
| <j-image-upload isMultiple v-model="model.image" ></j-image-upload> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="是否上架" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status"> | |||
| <j-dict-select-tag type="list" v-model="model.status" dictCode="book_my_status" placeholder="请选择是否上架" /> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="商品说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="service"> | |||
| <a-input v-model="model.service" placeholder="请输入商品说明" ></a-input> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="回收规则" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="details"> | |||
| <j-editor v-model="model.details" /> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="最低价格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="price"> | |||
| <a-input-number v-model="model.price" placeholder="请输入最低价格" style="width: 100%" /> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="最高价格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maxPrice"> | |||
| <a-input-number v-model="model.maxPrice" placeholder="请输入最高价格" style="width: 100%" /> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unit"> | |||
| <a-input v-model="model.unit" placeholder="请输入单位" ></a-input> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="是否品牌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isPin"> | |||
| <j-switch v-model="model.isPin" ></j-switch> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| <a-col :span="24"> | |||
| <a-form-model-item label="显示回收规则" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isRecycleRules"> | |||
| <j-switch v-model="model.isRecycleRules" ></j-switch> | |||
| </a-form-model-item> | |||
| </a-col> | |||
| </a-row> | |||
| </a-form-model> | |||
| </j-form-container> | |||
| <!-- 品牌选择弹窗 --> | |||
| <BrandSelectModal | |||
| :visible="brandSelectVisible" | |||
| v-model="selectedBrandIds" | |||
| @ok="onBrandSelectOk" | |||
| @cancel="onBrandSelectCancel" | |||
| /> | |||
| </a-spin> | |||
| </template> | |||
| <script> | |||
| import { httpAction, getAction } from '@/api/manage' | |||
| import { validateDuplicateValue } from '@/utils/util' | |||
| import BrandSelectModal from './BrandSelectModal.vue' | |||
| export default { | |||
| name: 'CommonShopForm', | |||
| components: { | |||
| BrandSelectModal | |||
| }, | |||
| props: { | |||
| //表单禁用 | |||
| disabled: { | |||
| type: Boolean, | |||
| default: false, | |||
| required: false | |||
| } | |||
| }, | |||
| data () { | |||
| return { | |||
| model:{ | |||
| }, | |||
| labelCol: { | |||
| xs: { span: 24 }, | |||
| sm: { span: 5 }, | |||
| }, | |||
| wrapperCol: { | |||
| xs: { span: 24 }, | |||
| sm: { span: 16 }, | |||
| }, | |||
| confirmLoading: false, | |||
| validatorRules: { | |||
| }, | |||
| url: { | |||
| add: "/commonShop/commonShop/add", | |||
| edit: "/commonShop/commonShop/edit", | |||
| queryById: "/commonShop/commonShop/queryById" | |||
| }, | |||
| // 品牌选择相关 | |||
| brandSelectVisible: false, | |||
| selectedBrandIds: [], | |||
| brandDisplayText: '', | |||
| allBrands: [] // 存储所有品牌数据用于显示 | |||
| } | |||
| }, | |||
| computed: { | |||
| formDisabled(){ | |||
| return this.disabled | |||
| }, | |||
| }, | |||
| watch: { | |||
| // 监听model.shopCion变化,更新品牌显示 | |||
| 'model.shopCion': { | |||
| handler(val) { | |||
| if (val) { | |||
| this.selectedBrandIds = val.split(',').map(id => id.trim()) | |||
| this.updateBrandDisplayText() | |||
| } else { | |||
| this.selectedBrandIds = [] | |||
| this.brandDisplayText = '' | |||
| } | |||
| }, | |||
| immediate: true | |||
| }, | |||
| // 监听选中的品牌ID变化 | |||
| selectedBrandIds: { | |||
| handler(val) { | |||
| this.model.shopCion = val.join(',') | |||
| this.updateBrandDisplayText() | |||
| }, | |||
| deep: true | |||
| } | |||
| }, | |||
| created () { | |||
| //备份model原始值 | |||
| this.modelDefault = JSON.parse(JSON.stringify(this.model)); | |||
| // 初始化品牌数据 | |||
| this.loadBrandData(); | |||
| }, | |||
| methods: { | |||
| add () { | |||
| this.edit(this.modelDefault); | |||
| }, | |||
| async edit (record) { | |||
| if (record.id) { | |||
| // 调用查询详情接口获取完整数据 | |||
| try { | |||
| this.confirmLoading = true; | |||
| const res = await getAction(this.url.queryById, { id: record.id }); | |||
| if (res.success) { | |||
| this.model = Object.assign({}, res.result); | |||
| } else { | |||
| this.$message.error('获取商品详情失败'); | |||
| this.model = Object.assign({}, record); | |||
| } | |||
| } catch (error) { | |||
| console.error('查询商品详情失败:', error); | |||
| this.$message.error('获取商品详情失败'); | |||
| this.model = Object.assign({}, record); | |||
| } finally { | |||
| this.confirmLoading = false; | |||
| } | |||
| } else { | |||
| this.model = Object.assign({}, record); | |||
| } | |||
| this.visible = true; | |||
| }, | |||
| submitForm () { | |||
| const that = this; | |||
| // 触发表单验证 | |||
| this.$refs.form.validate(valid => { | |||
| if (valid) { | |||
| that.confirmLoading = true; | |||
| let httpurl = ''; | |||
| let method = ''; | |||
| if(!this.model.id){ | |||
| httpurl+=this.url.add; | |||
| method = 'post'; | |||
| }else{ | |||
| httpurl+=this.url.edit; | |||
| method = 'put'; | |||
| } | |||
| httpAction(httpurl,this.model,method).then((res)=>{ | |||
| if(res.success){ | |||
| that.$message.success(res.message); | |||
| that.$emit('ok'); | |||
| }else{ | |||
| that.$message.warning(res.message); | |||
| } | |||
| }).finally(() => { | |||
| that.confirmLoading = false; | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| // 加载品牌数据 | |||
| async loadBrandData() { | |||
| try { | |||
| const res = await getAction('/commonVip/commonVip/list', { pageNo: 1, pageSize: 999 }) | |||
| if (res.success) { | |||
| this.allBrands = res.result.records || [] | |||
| } | |||
| } catch (error) { | |||
| console.error('加载品牌数据失败:', error) | |||
| } | |||
| }, | |||
| // 显示品牌选择弹窗 | |||
| showBrandSelectModal() { | |||
| this.brandSelectVisible = true | |||
| }, | |||
| // 品牌选择确定 | |||
| onBrandSelectOk(selectedIds) { | |||
| this.selectedBrandIds = [...selectedIds] | |||
| this.brandSelectVisible = false | |||
| }, | |||
| // 品牌选择取消 | |||
| onBrandSelectCancel() { | |||
| this.brandSelectVisible = false | |||
| }, | |||
| // 更新品牌显示文本 | |||
| updateBrandDisplayText() { | |||
| if (this.selectedBrandIds.length === 0) { | |||
| this.brandDisplayText = '' | |||
| return | |||
| } | |||
| const selectedBrands = this.allBrands.filter(brand => | |||
| this.selectedBrandIds.includes(brand.id) | |||
| ) | |||
| if (selectedBrands.length === 0) { | |||
| this.brandDisplayText = `已选择 ${this.selectedBrandIds.length} 个品牌` | |||
| } else if (selectedBrands.length <= 3) { | |||
| this.brandDisplayText = selectedBrands.map(brand => brand.name).join('、') | |||
| } else { | |||
| const firstThree = selectedBrands.slice(0, 3).map(brand => brand.name).join('、') | |||
| this.brandDisplayText = `${firstThree} 等${selectedBrands.length}个品牌` | |||
| } | |||
| } | |||
| } | |||
| } | |||
| </script> | |||
| @ -0,0 +1,84 @@ | |||
| <template> | |||
| <a-drawer | |||
| :title="title" | |||
| :width="width" | |||
| placement="right" | |||
| :closable="false" | |||
| @close="close" | |||
| destroyOnClose | |||
| :visible="visible"> | |||
| <common-shop-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" normal></common-shop-form> | |||
| <div class="drawer-footer"> | |||
| <a-button @click="handleCancel" style="margin-bottom: 0;">关闭</a-button> | |||
| <a-button v-if="!disableSubmit" @click="handleOk" type="primary" style="margin-bottom: 0;">提交</a-button> | |||
| </div> | |||
| </a-drawer> | |||
| </template> | |||
| <script> | |||
| import CommonShopForm from './CommonShopForm' | |||
| export default { | |||
| name: 'CommonShopModal', | |||
| components: { | |||
| CommonShopForm | |||
| }, | |||
| data () { | |||
| return { | |||
| title:"操作", | |||
| width:800, | |||
| visible: false, | |||
| disableSubmit: false | |||
| } | |||
| }, | |||
| methods: { | |||
| add () { | |||
| this.visible=true | |||
| this.$nextTick(()=>{ | |||
| this.$refs.realForm.add(); | |||
| }) | |||
| }, | |||
| edit (record) { | |||
| this.visible=true | |||
| this.$nextTick(()=>{ | |||
| this.$refs.realForm.edit(record); | |||
| }); | |||
| }, | |||
| close () { | |||
| this.$emit('close'); | |||
| this.visible = false; | |||
| }, | |||
| submitCallback(){ | |||
| this.$emit('ok'); | |||
| this.visible = false; | |||
| }, | |||
| handleOk () { | |||
| this.$refs.realForm.submitForm(); | |||
| }, | |||
| handleCancel () { | |||
| this.close() | |||
| } | |||
| } | |||
| } | |||
| </script> | |||
| <style lang="less" scoped> | |||
| /** Button按钮间距 */ | |||
| .ant-btn { | |||
| margin-left: 30px; | |||
| margin-bottom: 30px; | |||
| float: right; | |||
| } | |||
| .drawer-footer{ | |||
| position: absolute; | |||
| bottom: -8px; | |||
| width: 100%; | |||
| border-top: 1px solid #e8e8e8; | |||
| padding: 10px 16px; | |||
| text-align: right; | |||
| left: 0; | |||
| background: #fff; | |||
| border-radius: 0 0 2px 2px; | |||
| } | |||
| </style> | |||
| @ -0,0 +1,60 @@ | |||
| <template> | |||
| <j-modal | |||
| :title="title" | |||
| :width="width" | |||
| :visible="visible" | |||
| switchFullscreen | |||
| @ok="handleOk" | |||
| :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" | |||
| @cancel="handleCancel" | |||
| cancelText="关闭"> | |||
| <common-shop-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></common-shop-form> | |||
| </j-modal> | |||
| </template> | |||
| <script> | |||
| import CommonShopForm from './CommonShopForm' | |||
| export default { | |||
| name: 'CommonShopModal', | |||
| components: { | |||
| CommonShopForm | |||
| }, | |||
| data () { | |||
| return { | |||
| title:'', | |||
| width:800, | |||
| visible: false, | |||
| disableSubmit: false | |||
| } | |||
| }, | |||
| methods: { | |||
| add () { | |||
| this.visible=true | |||
| this.$nextTick(()=>{ | |||
| this.$refs.realForm.add(); | |||
| }) | |||
| }, | |||
| edit (record) { | |||
| this.visible=true | |||
| this.$nextTick(()=>{ | |||
| this.$refs.realForm.edit(record); | |||
| }) | |||
| }, | |||
| close () { | |||
| this.$emit('close'); | |||
| this.visible = false; | |||
| }, | |||
| handleOk () { | |||
| this.$refs.realForm.submitForm(); | |||
| }, | |||
| submitCallback(){ | |||
| this.$emit('ok'); | |||
| this.visible = false; | |||
| }, | |||
| handleCancel () { | |||
| this.close() | |||
| } | |||
| } | |||
| } | |||
| </script> | |||
| @ -0,0 +1,62 @@ | |||
| package org.jeecg.modules.commonBrandProduct.entity; | |||
| import java.io.Serializable; | |||
| import com.baomidou.mybatisplus.annotation.IdType; | |||
| import com.baomidou.mybatisplus.annotation.TableId; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||
| import org.springframework.format.annotation.DateTimeFormat; | |||
| import org.jeecgframework.poi.excel.annotation.Excel; | |||
| import java.util.Date; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import java.io.UnsupportedEncodingException; | |||
| /** | |||
| * @Description: 款式价格配置 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| @ApiModel(value="common_brand_product_price对象", description="款式价格配置") | |||
| @Data | |||
| @TableName("common_brand_product_price") | |||
| public class CommonBrandProductPrice implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| /**主键*/ | |||
| @TableId(type = IdType.ASSIGN_ID) | |||
| @ApiModelProperty(value = "主键") | |||
| private java.lang.String id; | |||
| /**创建人*/ | |||
| @ApiModelProperty(value = "创建人") | |||
| private java.lang.String createBy; | |||
| /**创建日期*/ | |||
| @ApiModelProperty(value = "创建日期") | |||
| private java.util.Date createTime; | |||
| /**更新人*/ | |||
| @ApiModelProperty(value = "更新人") | |||
| private java.lang.String updateBy; | |||
| /**更新日期*/ | |||
| @ApiModelProperty(value = "更新日期") | |||
| private java.util.Date updateTime; | |||
| /**所属部门*/ | |||
| @ApiModelProperty(value = "所属部门") | |||
| private java.lang.String sysOrgCode; | |||
| /**最低价格*/ | |||
| @Excel(name = "最低价格", width = 15) | |||
| @ApiModelProperty(value = "最低价格") | |||
| private java.math.BigDecimal minPrice; | |||
| /**最高价格*/ | |||
| @Excel(name = "最高价格", width = 15) | |||
| @ApiModelProperty(value = "最高价格") | |||
| private java.math.BigDecimal maxPrice; | |||
| /**款式*/ | |||
| @ApiModelProperty(value = "款式") | |||
| private java.lang.String styleId; | |||
| /**品牌分类*/ | |||
| @Excel(name = "品牌分类", width = 15, dictTable = "common_brand_category", dicText = "name", dicCode = "id") | |||
| @ApiModelProperty(value = "品牌分类") | |||
| private java.lang.String brandCategoryId; | |||
| } | |||
| @ -0,0 +1,19 @@ | |||
| package org.jeecg.modules.commonBrandProduct.mapper; | |||
| import java.util.List; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| /** | |||
| * @Description: 款式价格配置 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| public interface CommonBrandProductPriceMapper extends BaseMapper<CommonBrandProductPrice> { | |||
| public boolean deleteByMainId(@Param("mainId") String mainId); | |||
| public List<CommonBrandProductPrice> selectByMainId(@Param("mainId") String mainId); | |||
| } | |||
| @ -0,0 +1,16 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="org.jeecg.modules.commonBrandProduct.mapper.CommonBrandProductPriceMapper"> | |||
| <delete id="deleteByMainId" parameterType="java.lang.String"> | |||
| DELETE | |||
| FROM common_brand_product_price | |||
| WHERE | |||
| style_id = #{mainId} </delete> | |||
| <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice"> | |||
| SELECT * | |||
| FROM common_brand_product_price | |||
| WHERE | |||
| style_id = #{mainId} </select> | |||
| </mapper> | |||
| @ -0,0 +1,19 @@ | |||
| package org.jeecg.modules.commonBrandProduct.service; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProduct; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice; | |||
| import com.baomidou.mybatisplus.extension.service.IService; | |||
| import java.util.List; | |||
| /** | |||
| * @Description: 款式价格配置 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| public interface ICommonBrandProductPriceService extends IService<CommonBrandProductPrice> { | |||
| public List<CommonBrandProductPrice> selectByMainId(String mainId); | |||
| public void buildBrandProductPrice(CommonBrandProduct brandProduct, String brandCategory); | |||
| } | |||
| @ -1,14 +1,40 @@ | |||
| package org.jeecg.modules.commonBrandProduct.service; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProduct; | |||
| import com.baomidou.mybatisplus.extension.service.IService; | |||
| import java.io.Serializable; | |||
| import java.util.Collection; | |||
| import java.util.List; | |||
| /** | |||
| * @Description: 品牌款式 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-25 | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| public interface ICommonBrandProductService extends IService<CommonBrandProduct> { | |||
| /** | |||
| * 添加一对多 | |||
| * | |||
| */ | |||
| public void saveMain(CommonBrandProduct commonBrandProduct,List<CommonBrandProductPrice> commonBrandProductPriceList) ; | |||
| /** | |||
| * 修改一对多 | |||
| * | |||
| */ | |||
| public void updateMain(CommonBrandProduct commonBrandProduct,List<CommonBrandProductPrice> commonBrandProductPriceList); | |||
| /** | |||
| * 删除一对多 | |||
| */ | |||
| public void delMain (String id); | |||
| /** | |||
| * 批量删除一对多 | |||
| */ | |||
| public void delBatchMain (Collection<? extends Serializable> idList); | |||
| } | |||
| @ -0,0 +1,60 @@ | |||
| package org.jeecg.modules.commonBrandProduct.service.impl; | |||
| import lombok.extern.log4j.Log4j2; | |||
| import org.apache.commons.lang.StringUtils; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProduct; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice; | |||
| import org.jeecg.modules.commonBrandProduct.mapper.CommonBrandProductPriceMapper; | |||
| import org.jeecg.modules.commonBrandProduct.service.ICommonBrandProductPriceService; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.List; | |||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| /** | |||
| * @Description: 款式价格配置 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| @Log4j2 | |||
| @Service | |||
| public class CommonBrandProductPriceServiceImpl extends ServiceImpl<CommonBrandProductPriceMapper, CommonBrandProductPrice> implements ICommonBrandProductPriceService { | |||
| @Autowired | |||
| private CommonBrandProductPriceMapper commonBrandProductPriceMapper; | |||
| @Override | |||
| public List<CommonBrandProductPrice> selectByMainId(String mainId) { | |||
| return commonBrandProductPriceMapper.selectByMainId(mainId); | |||
| } | |||
| @Override | |||
| public void buildBrandProductPrice(CommonBrandProduct brandProduct, String brandCategory){ | |||
| if (brandProduct == null || StringUtils.isBlank(brandCategory)){ | |||
| log.warn("品牌款式的价格配置失败 款式:{} 品牌分类: {}", brandProduct, brandCategory); | |||
| return; | |||
| } | |||
| log.info("使用品牌款式下的价格配置 款式ID:{} 品牌分类: {}", brandProduct.getId(), brandCategory); | |||
| List<CommonBrandProductPrice> prices = lambdaQuery() | |||
| .eq(CommonBrandProductPrice::getBrandCategoryId, brandCategory) | |||
| .eq(CommonBrandProductPrice::getStyleId, brandProduct.getId()) | |||
| .list(); | |||
| brandProduct.setBrandId(brandCategory); | |||
| if (prices.size() > 0){ | |||
| CommonBrandProductPrice price = prices.get(0); | |||
| if (price.getMinPrice() != null){ | |||
| log.info("设置最低价格: {}", price.getMinPrice()); | |||
| brandProduct.setMinPrice(price.getMinPrice()); | |||
| } | |||
| if (price.getMaxPrice() != null){ | |||
| log.info("设置最高价格: {}", price.getMaxPrice()); | |||
| brandProduct.setMaxPrice(price.getMaxPrice()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -1,19 +1,77 @@ | |||
| package org.jeecg.modules.commonBrandProduct.service.impl; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProduct; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice; | |||
| import org.jeecg.modules.commonBrandProduct.mapper.CommonBrandProductPriceMapper; | |||
| import org.jeecg.modules.commonBrandProduct.mapper.CommonBrandProductMapper; | |||
| import org.jeecg.modules.commonBrandProduct.service.ICommonBrandProductService; | |||
| import org.springframework.stereotype.Service; | |||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.io.Serializable; | |||
| import java.util.List; | |||
| import java.util.Collection; | |||
| /** | |||
| * @Description: 品牌款式 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-25 | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| @Service | |||
| public class CommonBrandProductServiceImpl extends ServiceImpl<CommonBrandProductMapper, CommonBrandProduct> implements ICommonBrandProductService { | |||
| @Autowired | |||
| private CommonBrandProductMapper commonBrandProductMapper; | |||
| @Autowired | |||
| private CommonBrandProductPriceMapper commonBrandProductPriceMapper; | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| public void saveMain(CommonBrandProduct commonBrandProduct, List<CommonBrandProductPrice> commonBrandProductPriceList) { | |||
| commonBrandProductMapper.insert(commonBrandProduct); | |||
| if(commonBrandProductPriceList!=null && commonBrandProductPriceList.size()>0) { | |||
| for(CommonBrandProductPrice entity:commonBrandProductPriceList) { | |||
| //外键设置 | |||
| entity.setStyleId(commonBrandProduct.getId()); | |||
| commonBrandProductPriceMapper.insert(entity); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| public void updateMain(CommonBrandProduct commonBrandProduct,List<CommonBrandProductPrice> commonBrandProductPriceList) { | |||
| commonBrandProductMapper.updateById(commonBrandProduct); | |||
| //1.先删除子表数据 | |||
| commonBrandProductPriceMapper.deleteByMainId(commonBrandProduct.getId()); | |||
| //2.子表数据重新插入 | |||
| if(commonBrandProductPriceList!=null && commonBrandProductPriceList.size()>0) { | |||
| for(CommonBrandProductPrice entity:commonBrandProductPriceList) { | |||
| //外键设置 | |||
| entity.setStyleId(commonBrandProduct.getId()); | |||
| commonBrandProductPriceMapper.insert(entity); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| public void delMain(String id) { | |||
| commonBrandProductPriceMapper.deleteByMainId(id); | |||
| commonBrandProductMapper.deleteById(id); | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| public void delBatchMain(Collection<? extends Serializable> idList) { | |||
| for(Serializable id:idList) { | |||
| commonBrandProductPriceMapper.deleteByMainId(id.toString()); | |||
| commonBrandProductMapper.deleteById(id); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,76 @@ | |||
| package org.jeecg.modules.commonBrandProduct.vo; | |||
| import java.util.List; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProduct; | |||
| import org.jeecg.modules.commonBrandProduct.entity.CommonBrandProductPrice; | |||
| import lombok.Data; | |||
| import org.jeecgframework.poi.excel.annotation.Excel; | |||
| import org.jeecgframework.poi.excel.annotation.ExcelEntity; | |||
| import org.jeecgframework.poi.excel.annotation.ExcelCollection; | |||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||
| import org.springframework.format.annotation.DateTimeFormat; | |||
| import java.util.Date; | |||
| import org.jeecg.common.aspect.annotation.Dict; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| /** | |||
| * @Description: 品牌款式 | |||
| * @Author: jeecg-boot | |||
| * @Date: 2025-08-28 | |||
| * @Version: V1.0 | |||
| */ | |||
| @Data | |||
| @ApiModel(value="common_brand_productPage对象", description="品牌款式") | |||
| public class CommonBrandProductPage { | |||
| /**主键*/ | |||
| @ApiModelProperty(value = "主键") | |||
| private java.lang.String id; | |||
| /**创建人*/ | |||
| @ApiModelProperty(value = "创建人") | |||
| private java.lang.String createBy; | |||
| /**创建日期*/ | |||
| @ApiModelProperty(value = "创建日期") | |||
| private java.util.Date createTime; | |||
| /**更新人*/ | |||
| @ApiModelProperty(value = "更新人") | |||
| private java.lang.String updateBy; | |||
| /**更新日期*/ | |||
| @ApiModelProperty(value = "更新日期") | |||
| private java.util.Date updateTime; | |||
| /**所属部门*/ | |||
| @ApiModelProperty(value = "所属部门") | |||
| private java.lang.String sysOrgCode; | |||
| /**款式名称*/ | |||
| @Excel(name = "款式名称", width = 15) | |||
| @ApiModelProperty(value = "款式名称") | |||
| private java.lang.String name; | |||
| /**款式图片*/ | |||
| @Excel(name = "款式图片", width = 15) | |||
| @ApiModelProperty(value = "款式图片") | |||
| private java.lang.String image; | |||
| /**默认最低价格*/ | |||
| @Excel(name = "默认最低价格", width = 15) | |||
| @ApiModelProperty(value = "默认最低价格") | |||
| private java.math.BigDecimal minPrice; | |||
| /**默认最高价格*/ | |||
| @Excel(name = "默认最高价格", width = 15) | |||
| @ApiModelProperty(value = "默认最高价格") | |||
| private java.math.BigDecimal maxPrice; | |||
| /**品牌分类*/ | |||
| @Excel(name = "品牌分类", width = 15, dictTable = "common_brand_category", dicText = "name", dicCode = "id") | |||
| @Dict(dictTable = "common_brand_category", dicText = "name", dicCode = "id") | |||
| @ApiModelProperty(value = "品牌分类") | |||
| private java.lang.String brandId; | |||
| /**商品*/ | |||
| @Excel(name = "商品", width = 15, dictTable = "common_shop", dicText = "name", dicCode = "id") | |||
| @Dict(dictTable = "common_shop", dicText = "name", dicCode = "id") | |||
| @ApiModelProperty(value = "商品") | |||
| private java.lang.String shopId; | |||
| @ExcelCollection(name="款式价格配置") | |||
| @ApiModelProperty(value = "款式价格配置") | |||
| private List<CommonBrandProductPrice> commonBrandProductPriceList; | |||
| } | |||