This commit is contained in:
mkm 2024-08-27 12:29:58 +08:00
parent 6627995f3f
commit bc1aa23f17
8 changed files with 197 additions and 119 deletions

View File

@ -0,0 +1,48 @@
import request from '@/utils/request'
// 门店商品属性值辅助表列表
export function apiStoreBranchProductAttrValueLists(params: any) {
return request.get({
url: '/store_branch_product_attr_value/storebranchproductattrvalue/lists',
params
})
}
// 添加门店商品属性值辅助表
export function apiStoreBranchProductAttrValueAdd(params: any) {
return request.post({
url: '/store_branch_product_attr_value/storebranchproductattrvalue/add',
params
})
}
// 编辑门店商品属性值辅助表
export function apiStoreBranchProductAttrValueEdit(params: any) {
return request.post({
url: '/store_branch_product_attr_value/storebranchproductattrvalue/edit',
params
})
}
//更新状态
export function apiStoreBranchProductAttrValueStatus(params: any) {
return request.post({
url: '/store_branch_product_attr_value/storebranchproductattrvalue/status',
params
})
}
// 删除门店商品属性值辅助表
export function apiStoreBranchProductAttrValueDelete(params: any) {
return request.post({
url: '/store_branch_product_attr_value/storebranchproductattrvalue/delete',
params
})
}
// 门店商品属性值辅助表详情
export function apiStoreBranchProductAttrValueDetail(params: any) {
return request.get({
url: '/store_branch_product_attr_value/storebranchproductattrvalue/detail',
params
})
}

View File

@ -0,0 +1,26 @@
import request from '@/utils/request'
// 商品属性值表列表
export function apiStoreProductAttrValueLists(params: any) {
return request.get({ url: '/store_product_attr_value/storeproductattrvalue/lists', params })
}
// 添加商品属性值表
export function apiStoreProductAttrValueAdd(params: any) {
return request.post({ url: '/store_product_attr_value/storeproductattrvalue/add', params })
}
// 编辑商品属性值表
export function apiStoreProductAttrValueEdit(params: any) {
return request.post({ url: '/store_product_attr_value/storeproductattrvalue/edit', params })
}
// 删除商品属性值表
export function apiStoreProductAttrValueDelete(params: any) {
return request.post({ url: '/store_product_attr_value/storeproductattrvalue/delete', params })
}
// 商品属性值表详情
export function apiStoreProductAttrValueDetail(params: any) {
return request.get({ url: '/store_product_attr_value/storeproductattrvalue/detail', params })
}

View File

@ -30,11 +30,6 @@ export function apiSourceProductStoreLists(params: any) {
return request.get({ url: '/system_store/systemstore/source_product_store_lists', params }) return request.get({ url: '/system_store/systemstore/source_product_store_lists', params })
} }
// 根据商品来源更新门店
export function apiSourceProductUpdateStore(params: any) {
return request.post({ url: '/system_store/systemstore/source_product_update_store', params })
}
// 根据商品编辑门店库存 // 根据商品编辑门店库存
export function apiStoreBranchProductEdit(params: any) { export function apiStoreBranchProductEdit(params: any) {
return request.post({ url: '/store_branch_product/StoreBranchProduct/edit', params }) return request.post({ url: '/store_branch_product/StoreBranchProduct/edit', params })

View File

@ -1,26 +1,65 @@
<template> <template>
<div class="edit-popup"> <div class="edit-popup">
<popup <el-drawer title="商品详情" :size="1200" v-model="isOpen">
ref="popupRef" <el-tabs v-model="activeName" class="demo-tabs">
title="详情" <el-tab-pane label="基础信息" name="first">
:async="true" <el-descriptions class="margin-top" :column="2" border>
width="550px" <el-descriptions-item label="商品名称">
:cancelButtonText="false" {{ formData.store_name }}
:confirmButtonText="false" </el-descriptions-item>
> <el-descriptions-item label="商品分类">{{
<el-form ref="formRef" :model="formData" label-width="90px"> formData.cate_name
}}</el-descriptions-item>
</el-form> <el-descriptions-item label="商品图片" :span="2">
</popup> <el-image
:src="formData.image"
class="w-20 h-20"
:preview-teleported="true"
/>
</el-descriptions-item>
<el-descriptions-item label="厂家备注" :span="2">
<div style="white-space: pre">
{{ formData.manufacturer_information }}
</div>
</el-descriptions-item>
</el-descriptions>
<el-table :data="sku_lists" border class="mt-4">
<el-table-column label="规格名称" prop="sku_name" min-width="150" />
<el-table-column label="单位" prop="unit_name" />
<el-table-column label="供货价" prop="purchase" show-overflow-tooltip />
<el-table-column label="商户价" prop="cost" show-overflow-tooltip />
<el-table-column label="零售价" prop="price" show-overflow-tooltip />
<el-table-column label="商品销量" prop="sales" show-overflow-tooltip />
<el-table-column label="商品库存" prop="stock" show-overflow-tooltip />
<el-table-column label="条码" prop="bar_code" show-overflow-tooltip />
<el-table-column label="状态" show-overflow-tooltip>
<template #default="{ row }">
<el-switch
size="large"
@change="statusChange(row)"
v-model="row.status"
:active-value="1"
:inactive-value="0"
active-text="上架"
inactive-text="下架"
inline-prompt
/>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</el-drawer>
</div> </div>
</template> </template>
<script lang="ts" setup name="storeBranchProductDETAILS"> <script lang="ts" setup name="storeProductDETAILS">
import type { FormInstance } from 'element-plus' import {
import Popup from '@/components/popup/index.vue' apiStoreBranchProductAttrValueLists,
import { apiStoreBranchProductAdd, apiStoreBranchProductEdit, apiStoreBranchProductDetail } from '@/api/store_branch_product' apiStoreBranchProductAttrValueStatus
import { timeFormat } from '@/utils/util' } from '@/api/store_branch_product_attr_value'
import type { PropType } from 'vue' import type { PropType } from 'vue'
import feedback from '@/utils/feedback'
defineProps({ defineProps({
dictData: { dictData: {
type: Object as PropType<Record<string, any[]>>, type: Object as PropType<Record<string, any[]>>,
@ -28,20 +67,29 @@ defineProps({
} }
}) })
const emit = defineEmits(['success', 'close']) const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
const sku_lists = ref([])
const isOpen = ref(false)
const activeName = ref('first')
// //
const formData = reactive({ const formData = reactive({
id: '', id: '',
image: '',
store_name: '',
bar_code: '',
cate_id: '',
cate_name: '',
price: '',
unit: '',
unit_name: '',
stock: '',
cost: '',
purchase: '',
rose: '0',
manufacturer_information: ''
}) })
// //
const setFormData = async (data: Record<any, any>) => { const setFormData = async (data: Record<any, any>) => {
for (const key in formData) { for (const key in formData) {
@ -50,20 +98,23 @@ const setFormData = async (data: Record<any, any>) => {
formData[key] = data[key] formData[key] = data[key]
} }
} }
apiStoreBranchProductAttrValueLists({
product_id: data.product_id,
} store_id: data.store_id
}).then((res) => {
const getDetail = async (row: Record<string, any>) => { sku_lists.value = res.lists
const data = await apiStoreBranchProductDetail({
id: row.id
}) })
setFormData(data)
} }
const statusChange = (row: any) => {
apiStoreBranchProductAttrValueStatus({
id: row.id,
status: row.status
})
}
// //
const open = () => { const open = () => {
popupRef.value?.open() isOpen.value = true
} }
// //
@ -71,11 +122,13 @@ const handleClose = () => {
emit('close') emit('close')
} }
//
const queryParams = reactive({
product_id: ''
})
defineExpose({ defineExpose({
open, open,
setFormData, setFormData
getDetail
}) })
</script> </script>

View File

@ -197,6 +197,14 @@
show-overflow-tooltip show-overflow-tooltip
> >
<template #default="{ row }"> <template #default="{ row }">
<!-- <el-button
v-perms="['store_branch_product.store_branch_product/details']"
type="primary"
link
@click="handleDetail(row)"
>
详情
</el-button> -->
<el-button <el-button
type="primary" type="primary"
v-prems="['store_branch_product.store_branch_product/deit']" v-prems="['store_branch_product.store_branch_product/deit']"
@ -226,6 +234,7 @@
@success="getLists" @success="getLists"
@close="showEdit = false" @close="showEdit = false"
/> />
<Details ref="detailsRef"></Details>
</div> </div>
</template> </template>
@ -239,10 +248,12 @@ import { apiSystemStoreLists } from '@/api/system_store'
import feedback from '@/utils/feedback' import feedback from '@/utils/feedback'
import EditPopup from './edit.vue' import EditPopup from './edit.vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import Details from './details.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>() const editRef = shallowRef<InstanceType<typeof EditPopup>>()
// //
const showEdit = ref(false) const showEdit = ref(false)
const detailsRef = ref(null)
// //
const queryParams = reactive({ const queryParams = reactive({
@ -279,6 +290,11 @@ const handleAdd = async () => {
editRef.value?.open('add') editRef.value?.open('add')
} }
//
const handleDetail = async (data: any) => {
detailsRef.value?.open()
detailsRef.value?.setFormData(data)
}
// //
const handleEdit = async (data: any) => { const handleEdit = async (data: any) => {
showEdit.value = true showEdit.value = true

View File

@ -164,7 +164,6 @@ import { apiStoreProductAdd, apiStoreProductEdit, apiStoreProductDetail } from '
import { timeFormat } from '@/utils/util' import { timeFormat } from '@/utils/util'
import { import {
apiSourceProductStoreLists, apiSourceProductStoreLists,
apiSourceProductUpdateStore,
apiStoreBranchProductEdit, apiStoreBranchProductEdit,
apiStoreBranchProductEditPrice apiStoreBranchProductEditPrice
} from '@/api/system_store' } from '@/api/system_store'
@ -292,35 +291,6 @@ const handleDelete = (store_id: number) => {
addList.set(store_id, (addList.get(store_id) || 0) - 1) addList.set(store_id, (addList.get(store_id) || 0) - 1)
removeList.set(store_id, (removeList.get(store_id) || 0) + 1) removeList.set(store_id, (removeList.get(store_id) || 0) + 1)
} }
//
const submitStore = () => {
feedback
.confirm('确定修改适用门店吗?')
.then(async () => {
const add = Array.from(addList.entries())
.filter(([k, v]) => v == 1)
.map(([key]) => key)
const remove = Array.from(removeList.entries())
.filter(([k, v]) => v == 1)
.map(([key]) => key)
console.log(add, remove)
if (add.length == 0 && remove.length == 0) return ElMessage.warning('没有更改门店')
apiSourceProductUpdateStore({
addList: add,
removeList: remove,
product_id: queryParams.product_id
}).then((res) => {
isEidt.value = false
addList.clear()
removeList.clear()
})
})
.catch(() => {
// on cancel
})
}
// //
const isEidtStock = ref(false) const isEidtStock = ref(false)
const stockList = ref(new Map()) const stockList = ref(new Map())

View File

@ -25,6 +25,7 @@
</el-descriptions> </el-descriptions>
<el-table :data="sku_lists" border class="mt-4"> <el-table :data="sku_lists" border class="mt-4">
<el-table-column label="规格名称" prop="sku_name" min-width="150" /> <el-table-column label="规格名称" prop="sku_name" min-width="150" />
<el-table-column label="单位" prop="unit_name" />
<el-table-column label="供货价" prop="purchase" show-overflow-tooltip /> <el-table-column label="供货价" prop="purchase" show-overflow-tooltip />
<el-table-column label="商户价" prop="cost" show-overflow-tooltip /> <el-table-column label="商户价" prop="cost" show-overflow-tooltip />
<el-table-column label="零售价" prop="price" show-overflow-tooltip /> <el-table-column label="零售价" prop="price" show-overflow-tooltip />
@ -93,7 +94,7 @@
import { usePaging } from '@/hooks/usePaging' import { usePaging } from '@/hooks/usePaging'
import { ElMessage, type FormInstance } from 'element-plus' import { ElMessage, type FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue' import Popup from '@/components/popup/index.vue'
import { apiStoreProductAdd, apiStoreProductEdit, apiStoreProductDetail } from '@/api/store_product' import { apiStoreProductAttrValueLists } from '@/api/store_product_attr_value'
import { timeFormat } from '@/utils/util' import { timeFormat } from '@/utils/util'
import { apiSourceProductStoreLists } from '@/api/system_store' import { apiSourceProductStoreLists } from '@/api/system_store'
import { apiWarehouseProductStoregeLists } from '@/api/warehouse_product_storege' import { apiWarehouseProductStoregeLists } from '@/api/warehouse_product_storege'
@ -144,6 +145,9 @@ const setFormData = async (data: Record<any, any>) => {
formData[key] = data[key] formData[key] = data[key]
} }
} }
apiStoreProductAttrValueLists({ product_id: data.id }).then((res) => {
sku_lists.value = res.lists
})
} }
// //

View File

@ -19,16 +19,6 @@
:readonly="false" :readonly="false"
/> />
</el-form-item> </el-form-item>
<el-form-item label="商品条码" prop="bar_code">
<el-input
v-model="formData.bar_code"
class="w-[500px]"
@input="validateInput"
clearable
placeholder="请输入商品条码"
:readonly="false"
/>
</el-form-item>
<el-form-item label="商品类型" prop="product_type"> <el-form-item label="商品类型" prop="product_type">
<el-radio-group <el-radio-group
v-model="formData.product_type" v-model="formData.product_type"
@ -332,11 +322,19 @@ const columns = ref([
{ label: '规格名称', prop: 'sku_name', width: '180' }, { label: '规格名称', prop: 'sku_name', width: '180' },
{ label: '供货价', prop: 'purchase', width: '180' }, { label: '供货价', prop: 'purchase', width: '180' },
{ label: '商户价', prop: 'cost', width: '180' }, { label: '商户价', prop: 'cost', width: '180' },
{ label: '零售价', prop: 'price', width: '180' } { label: '零售价', prop: 'price', width: '180' },
{ label: '条码', prop: 'bar_code', width: '180' }
]) ])
const addRow = () => { const addRow = () => {
tableData.value.push({ sku_name: '', purchase: 0, cost: 0, price: 0, editable: true }) tableData.value.push({
sku_name: '',
purchase: 0,
cost: 0,
price: 0,
bar_code: '',
editable: true
})
} }
const deleteRow = (index) => { const deleteRow = (index) => {
@ -347,18 +345,11 @@ const formData = reactive({
id: '', id: '',
image: '', image: '',
store_name: '', store_name: '',
bar_code: '',
store_info: '', store_info: '',
product_type: 0, product_type: 0,
cate_arr: [], cate_arr: [],
cate_id: '', cate_id: '',
price: '',
vip_price: '',
unit: '',
stock: '',
swap: '', swap: '',
cost: '',
purchase: '',
batch: 1, batch: 1,
store_batch: 1, store_batch: 1,
manufacturer_information: '', manufacturer_information: '',
@ -368,18 +359,6 @@ const formData = reactive({
spec_type: 0 spec_type: 0
}) })
//
const validateInput = () => {
//
const inputValue = formData.bar_code
// 使
const filteredValue = inputValue.replace(/[^a-zA-Z0-9]/g, '')
//
formData.bar_code = filteredValue
}
const showStore = ref(false) // const showStore = ref(false) //
// //
const storeList = ref([]) const storeList = ref([])
@ -471,13 +450,6 @@ const formRules = reactive<any>({
trigger: ['blur'] trigger: ['blur']
} }
], ],
bar_code: [
{
required: true,
message: '请输入商品条码',
trigger: ['blur']
}
],
store_info: [ store_info: [
{ {
required: true, required: true,
@ -499,13 +471,6 @@ const formRules = reactive<any>({
trigger: ['blur', 'change'] trigger: ['blur', 'change']
} }
], ],
swap: [
{
required: true,
message: '请输入兑换库存',
trigger: ['blur']
}
],
image: [ image: [
{ {
required: true, required: true,
@ -558,7 +523,8 @@ const handleSubmit = async () => {
unit: item.unit, unit: item.unit,
purchase: item.purchase, purchase: item.purchase,
cost: item.cost, cost: item.cost,
price: item.price price: item.price,
bar_code: item.bar_code
} }
}) })
} }