From 587965020b6de3314343fc90c556da5b0bd66896 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Sat, 28 Sep 2024 15:07:09 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pageProduct/add-Product/add-Product.vue | 534 +++++-------------
.../add-Product/components/choose-haocai.vue | 4 +-
.../add-Product/components/edit-haocai.vue | 147 +++--
.../choose-specifications.vue | 84 ++-
.../components/fast-edit.vue | 157 +++++
pageProduct/index/components/baosun.vue | 38 +-
pageProduct/index/components/control.vue | 6 +-
pageProduct/index/components/edit-guige.vue | 33 +-
pageProduct/index/components/edit-stock.vue | 52 +-
pageProduct/index/components/goods.vue | 78 ++-
pageProduct/index/index.vue | 41 +-
11 files changed, 642 insertions(+), 532 deletions(-)
create mode 100644 pageProduct/add-specifications/components/fast-edit.vue
diff --git a/pageProduct/add-Product/add-Product.vue b/pageProduct/add-Product/add-Product.vue
index 5f5aa16..b86622e 100644
--- a/pageProduct/add-Product/add-Product.vue
+++ b/pageProduct/add-Product/add-Product.vue
@@ -1,9 +1,8 @@
-
+
-
@@ -11,20 +10,13 @@
err-show-type="toast" validateTrigger="submit" label-width="350" ref="Forms">
-
-
-
-
+
+
+
+
-
+
注:第一张图为商品封面图,图片尺寸为750x750
@@ -63,17 +55,6 @@
-
-
-
@@ -84,7 +65,7 @@
-
+
@@ -118,179 +99,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
- 选择规格
+ 选择规格
编辑规格
-
+
组合名称
售价
库存数量
-
{{item.specSnap}}
- {{item.salePrice}}
+ ¥{{item.salePrice}}
{{item.stockNumber}}
@@ -374,9 +205,9 @@
-
+
规格属性
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
删除该商品
@@ -737,18 +441,13 @@
保存
-
-
+
-
+
@@ -762,15 +461,16 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -798,7 +498,7 @@
import myButton from '@/components/my-components/my-button'
import mySwitch from '@/components/my-components/my-switch.vue'
import infoBox from "@/commons/utils/infoBox.js"
-
+
import {
$types,
$defaultSku
@@ -1146,11 +846,12 @@
const tabsList = ['基础设置', '耗材绑定']
let tabsCurrent = ref(0)
- function changeTabsCurrent(newval){
- tabsCurrent.value=newval
+
+ function changeTabsCurrent(newval) {
+ tabsCurrent.value = newval
}
-
-
+
+
const Forms = ref(null)
@@ -1253,10 +954,15 @@
usageRules: ""
}
})
- const skuList = reactive([{
- ...$defaultSku,
- barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
- }])
+ const skuList = reactive({
+ list: [{
+ ...$defaultSku,
+ barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
+ }]
+ })
+ watch(() => skuList.list, (newval) => {
+ console.log(newval);
+ })
//库存表单数据
const stockData = reactive({
inventoryMode: 0,
@@ -1294,13 +1000,21 @@
url: v
}
})
- $goodsData = res
- Object.assign(FormData, res)
- if (res.skuList.length) {
- for (let i in res.skuList) {
- skuList[i] = res.skuList[i]
+ for(let i in res.conInfos){
+ const con=res.conInfos[i]
+ const item=res.skuList.find(v=>v.id==con.productSkuId)
+ if(item){
+ if(item.hasOwnProperty('haoCaiList')){
+ item.haoCaiList.push(con)
+ }else{
+ item.haoCaiList=[con]
+ }
}
}
+ $goodsData = res
+ console.log(res);
+ Object.assign(FormData, res)
+ skuList.list = res.skuList || []
//多规格
if (res.typeEnum === 'sku') {
const selectSpec = JSON.parse(res.selectSpec)
@@ -1319,13 +1033,12 @@
selectSpec: selectSpec.map(s => {
return {
...s,
- // value: s.value.map(v => {
- // return {
- // text: v,
- // value: v
- // }
- // })
-
+ value: s.value.map(v => {
+ return typeof v === 'string' ? {
+ text: v,
+ value: v
+ } : v
+ })
}
}),
result: res.skuList.map(v => {
@@ -1339,7 +1052,8 @@
...v
},
names,
- specSnap: v.specSnap
+ specSnap: v.specSnap,
+ coverImg:v.coverImg
}
}),
specList: [],
@@ -1422,9 +1136,14 @@
const pageData = reactive({
// 商品类型
// types: $types,
- types: [
- {name:'单规格',value:'normal'},
- {name:'多规格',value:'sku'}
+ types: [{
+ name: '单规格',
+ value: 'normal'
+ },
+ {
+ name: '多规格',
+ value: 'sku'
+ }
],
// 单位
units: [],
@@ -1441,6 +1160,10 @@
pageData.skuList = res
})
}
+ function updateGoodsDetail(){
+ getGoodsDetail()
+ getProductSku()
+ }
onLoad((params) => {
if (isEmpty(params)) {
option.type = params.type ? params.type : 'add'
@@ -1454,6 +1177,10 @@
uni.setNavigationBarTitle({
title: option.type === 'add' ? '添加商品' : '编辑商品'
})
+ if (option.type === 'edit') {
+ getGoodsDetail()
+ getProductSku()
+ }
defaultValueInit()
getCategory()
getTbShopUnit()
@@ -1461,10 +1188,10 @@
})
onShow(() => {
- if (option.type === 'edit') {
- getGoodsDetail()
- getProductSku()
- }
+ // if (option.type === 'edit') {
+ // getGoodsDetail()
+ // getProductSku()
+ // }
})
@@ -1498,15 +1225,23 @@
if (typeEnum === 'group' && !groupCategoryId.length) {
return infoBox.showToast('请选择团购券分类')
}
+
// if(typeEnum==='sku'){
// return infoBox.showErrorToast('请选择规格')
// }
const images = refFile.value.getFileList()
+ if(images.length<=0){
+ return infoBox.showToast('请上传商品图片')
+ }
const skuSnap = []
- const submitSkuList = FormData.specificationsGroup ? skuList : [{
+ let submitSkuList = FormData.specificationsGroup ? skuList.list : [{
...$defaultSku,
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
- }]
+ }];
+ if(typeEnum=='normal'){
+ submitSkuList=skuList.list ;
+ }
+ console.log(submitSkuList);
if (FormData.specificationsGroup) {
for (let i of FormData.specificationsGroup.selectSpec) {
if (i.selectSpecResult.length) {
@@ -1517,7 +1252,6 @@
}
}
}
-
const submitData = {
...FormData,
images: images,
@@ -1526,7 +1260,13 @@
specInfo: JSON.stringify(submitSkuList),
lowPrice: submitSkuList[0].salePrice,
specificationsGroup: undefined,
- selectSpec: JSON.stringify(FormData.specificationsGroup.selectSpec),
+ selectSpec: JSON.stringify(FormData.specificationsGroup.selectSpec.map(spe=>{
+ return {
+ ...spe,value:spe.value.map(v=>{
+ return typeof v==='string'?v:v.text||v.value
+ })
+ }
+ })),
skuSnap: JSON.stringify(skuSnap)
}
//编辑
@@ -1562,29 +1302,33 @@
/**
* 监听规格保存,拿到数据
- * @param {Boolean} open //控制开启或关闭监听
*/
- function watchSpecificationsSave(open = true) {
- if (open) {
- uni.$on('emitspecificationsSave', function(data) {
- FormData.specificationsGroup = data
- skuList.length = data.result.length
- for (let i in data.result) {
- const v = data.result[i]
- skuList[i] = {
- ...v.skus,
- ...v.names,
- specSnap: v.specSnap,
- }
- }
- console.log(skuList);
- })
- } else {
- uni.$off('emitspecificationsSave', function(data) {
- console.log('emitspecificationsSave remove');
- })
- }
+ const newSkuList = reactive({
+ list: []
+ })
+ function watchSpecificationsSave() {
+ uni.$off('emitspecificationsSave')
+ uni.$on('emitspecificationsSave', function(data) {
+ FormData.specificationsGroup = data
+ skuList.list = data.result.map(v => {
+ return {
+ ...v.skus,
+ ...v.names,
+ specSnap: v.specSnap,
+ coverImg: v.coverImg || ''
+ }
+ })
+ newSkuList.list = data.result.map(v => {
+ return {
+ ...v.skus,
+ ...v.names,
+ specSnap: v.specSnap,
+ coverImg: v.coverImg || ''
+ }
+ })
+ console.log(skuList.list);
+ })
}
function toGroup() {
@@ -1666,23 +1410,20 @@
watch(() => FormData.typeEnum, (newval) => {
if (option.type === 'add') {
if (newval === 'sku') {
- skuList.length = 0
+ skuList.list = []
} else {
- skuList[0] = {
+ skuList.list[0] = {
...$defaultSku,
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
}
}
}
})
- watchSpecificationsSave()
- watchTimerSave()
- onBeforeUnmount(() => {
- watchSpecificationsSave(false)
- watchTimerSave(false)
+ onShow(() => {
+ watchSpecificationsSave()
})
onReady(() => {
- Forms.value&&Forms.value.setRules(rules)
+ Forms.value && Forms.value.setRules(rules)
})
watch(() => pageData.types, (newval) => {
Forms.value.setRules(rules)
@@ -1764,6 +1505,7 @@
.box {
margin-top: 36rpx;
font-size: 28rpx;
+
.block {
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
diff --git a/pageProduct/add-Product/components/choose-haocai.vue b/pageProduct/add-Product/components/choose-haocai.vue
index 0b5cf16..df10e21 100644
--- a/pageProduct/add-Product/components/choose-haocai.vue
+++ b/pageProduct/add-Product/components/choose-haocai.vue
@@ -91,8 +91,8 @@
function haocaiClick(item, index) {
console.log(item);
- if (item.consId != props.modelValue) {
- emits('update:modelValue', item.consId)
+ if (item.id != props.modelValue) {
+ emits('update:modelValue', item.id)
emits('change', item)
}
popShow.value = false
diff --git a/pageProduct/add-Product/components/edit-haocai.vue b/pageProduct/add-Product/components/edit-haocai.vue
index e27798d..b5746b2 100644
--- a/pageProduct/add-Product/components/edit-haocai.vue
+++ b/pageProduct/add-Product/components/edit-haocai.vue
@@ -14,9 +14,9 @@
-
+
规格名称
- {{item.specSnap}}
+ {{sku.specSnap}}
序号
@@ -26,29 +26,24 @@
-
{{haocaiIndex+1}}
-
- {{item.name}}
-
-
+
-
- {{item.unit}}
-
-
+
-
-
-
-
-
+
+
+
@@ -173,16 +168,20 @@
deletetbProskuCon,
} from "@/http/yskApi/consumable.js";
import {
- tbShopCurrencyGet,$hasPermission
+ tbShopCurrencyGet,
+ $hasPermission
} from '@/http/yskApi/shop.js'
+ import infoBox from '@/commons/utils/infoBox.js'
import chooseHaocai from './choose-haocai.vue';
import chooseDanwei from './choose-danwei.vue';
import {
$tbProskuConV2
} from '@/http/yskApi/goods.js'
- const emits=defineEmits(['cancel'])
- function cancel(){
+import { cloneWith } from 'lodash';
+ const emits = defineEmits(['cancel', 'updateGoods'])
+
+ function cancel() {
emits('cancel')
}
const props = defineProps({
@@ -203,27 +202,29 @@
console.log(newval);
conInfos.value = newval
})
+
function conInfosChange(newval, item) {
console.log(newval);
item.stockNumber = newval.balance
item.conUnit = newval.conUnit
}
-
+
const skuList = ref(props.goods.skuList)
watch(() => props.goods.skuList, (newval) => {
console.log(newval);
skuList.value = newval
})
-
-
-
+ const $baseicHaocaiData = {
+ conInfoId: '',
+ conUnit: '',
+ surplusStock: ''
+ }
+
function addHaocai() {
conInfos.value.push({
- conInfoId: '',
- conUnit: '',
- surplusStock: ''
+ ...$baseicHaocaiData
})
}
const popup = reactive({
@@ -233,11 +234,21 @@
})
function addGuigeHaocai(index) {
- console.log(index);
+ if (skuList.value[index].haoCaiList) {
+ skuList.value[index].haoCaiList.push({
+ ...$baseicHaocaiData
+ })
+ } else {
+ skuList.value[index].haoCaiList = [{
+ ...$baseicHaocaiData
+ }]
+ }
+ console.log(skuList.value[index]);
}
function delHaocai(index) {
const item = conInfos.value[index]
+ console.log(item);
uni.showModal({
title: '提示',
content: '是否删除该耗材',
@@ -258,7 +269,24 @@
}
function delGuigeHaocao(guigeIndex, haocaiIndex) {
- skuList.value[guigeIndex].haoaiList.splice(haocaiIndex, 1)
+ const item = skuList.value[guigeIndex].haoCaiList[haocaiIndex]
+ console.log(item);
+ uni.showModal({
+ title: '提示',
+ content: '是否删除该耗材',
+ success(res) {
+ if (res.confirm) {
+ if (item&&item.id) {
+ deletetbProskuCon([item.id]).then(res1 => {
+ skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
+ })
+ } else {
+ skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
+ }
+
+ }
+ }
+ })
}
// 是否是多规格商品
@@ -270,30 +298,66 @@
isBindGuige.value = isSku.value
})
- function save() {
+ async function save() {
console.log('save');
- const isPas= conInfos.value.every(v=>{
- return v.conInfoId&&v.conUnit&&v.surplusStock>0
- })
- console.log(isPas);
- return
- let ajaxData = ''
+ let isPas=false
+ if(!isBindGuige.value){
+ //绑定至商品
+ isPas = conInfos.value.every(v => {
+ return v.conInfoId && v.conUnit && v.surplusStock > 0
+ })
+ }else{
+ //绑定至规格
+ isPas = skuList.value.filter(v=>v.haoCaiList&&v.haoCaiList.length).every(sku => {
+ console.log(sku.haoCaiList);
+ return sku.haoCaiList.every(v=>{
+ return v.conInfoId && v.conUnit && v.surplusStock > 0
+ })
+ })
+ }
+
+ if (!isPas) {
+ return infoBox.showToast('请填写全部耗材选项值')
+ }
+ let ajaxData = {
+ productId: props.goods.id,
+ cons: []
+ }
if (!isBindGuige.value) {
//绑定至商品
- ajaxData = conInfos.value.map(v => {
+ ajaxData.cons = conInfos.value.map(v => {
return {
+ id: v.id || '',
conInfoId: v.conInfoId,
productId: props.goods.id,
shopId: uni.getStorageSync('shopId'),
productSkuId: 0,
- surplusStock: v.surplusStock
+ surplusStock: v.surplusStock * 1,
+ status: 1
}
})
} else {
+ for(let i in skuList.value){
+ const haocaiList=skuList.value[i].haoCaiList||[]
+ for(let k in haocaiList){
+ const v=haocaiList[k]
+ ajaxData.cons.push({
+ id: v.id || '',
+ conInfoId: v.conInfoId,
+ productId: props.goods.id,
+ shopId: uni.getStorageSync('shopId'),
+ productSkuId: skuList.value[i].id,
+ surplusStock: v.surplusStock * 1,
+ status: 1
+ })
+ }
+ }
}
console.log(ajaxData);
- $tbProskuConV2(ajaxData)
+ await $tbProskuConV2(ajaxData)
+ emits('updateGoods')
+ infoBox.showToast('修改成功')
}
let haoCaiList = ref([])
@@ -303,12 +367,11 @@
function init() {
gettbConsInfo({
- page: 0,
- size: 200
+ "status": 1,
}).then(res => {
for (let i in res.content) {
const item = res.content[i]
- $haocaiMap[item.consId] = item
+ $haocaiMap[item.id] = item
}
haoCaiList.value = res.content
diff --git a/pageProduct/add-specifications/choose-specifications.vue b/pageProduct/add-specifications/choose-specifications.vue
index 3e85444..d972ef9 100644
--- a/pageProduct/add-specifications/choose-specifications.vue
+++ b/pageProduct/add-specifications/choose-specifications.vue
@@ -21,7 +21,6 @@
- {{item.selectSpecResult}}
@@ -30,6 +29,19 @@
+
+
@@ -97,12 +109,12 @@
+ placeholder="请输入分销金额" />
+ v-model="item.skus.barCode" placeholder="请输入商品条码" />
@@ -112,18 +124,25 @@
+
+
+
-
+
+
\ No newline at end of file
diff --git a/pageProduct/index/components/baosun.vue b/pageProduct/index/components/baosun.vue
index b84c66e..827ee9a 100644
--- a/pageProduct/index/components/baosun.vue
+++ b/pageProduct/index/components/baosun.vue
@@ -16,10 +16,10 @@
报损数量
-
-
+
+
@@ -28,7 +28,7 @@
备注
-
+
@@ -36,9 +36,7 @@
上传图片
-
-
-
+
@@ -67,8 +65,9 @@
returnCategory
} from '@/pageProduct/util.js'
import {
- $tbShopUnit
+ $frmLoss
} from '@/http/yskApi/goods.js'
+ import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
show: {
type: Boolean,
@@ -88,9 +87,9 @@
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
- note: '',
- number: 1,
- images: []
+ remark: '',
+ stockNumber: 1,
+ coverImg: []
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
@@ -111,8 +110,21 @@
}
- function save() {
- console.log(form.images);
+ async function save() {
+ if (form.stockNumber <= 0) {
+ return infoBox.showToast('请输入正确的报损数量')
+ }
+ if (!form.remark) {
+ return infoBox.showToast('请输入备注')
+ }
+ console.log(form);
+ const res= await $frmLoss({
+ ...form,
+ productId:props.goods.id,
+ coverImg:form.coverImg[0]?form.coverImg[0].serveUrl:''
+ })
+ infoBox.showToast('提交成功!')
+ popShow.value=false
}
diff --git a/pageProduct/index/components/control.vue b/pageProduct/index/components/control.vue
index a51e690..0e6d621 100644
--- a/pageProduct/index/components/control.vue
+++ b/pageProduct/index/components/control.vue
@@ -1,7 +1,7 @@
- 批量管理
+
商品添加
+
+ 全部记录
+
@@ -117,7 +118,7 @@
returnCategory
} from '@/pageProduct/util.js'
import {
- $tbShopUnit
+ $tbShopUnit,$getProductStockDetail
} from '@/http/yskApi/goods.js'
const props = defineProps({
show: {
@@ -135,29 +136,15 @@
}
}
})
-
+
+ function toRecodes(){
+ }
function changeShowRecoders(show) {
recoders.show = show
}
const recoders = reactive({
- list: [{
- title: '2024-09-15 11:20:30',
- content: '开启了库存,库存由0件修改为5件'
- },
- {
- title: '2024-09-15 ',
- content: '开启了库存,库存由0件修改为4件'
- },
- {
- title: '2024-09-15 ',
- content: '开启了库存,库存由0件修改为3件'
- },
- {
- title: '2024-09-15 ',
- content: '开启了库存,库存由0件修改为2件'
- },
- ],
- show: false,
+ list: [],
+ show: true,
active: 0
})
@@ -171,8 +158,27 @@
popShow.value = newval
if (newval) {
data.value = props.goods
+ getProductStockDetail()
}
})
+ async function getProductStockDetail(){
+ const {content}=await $getProductStockDetail({
+ page:0,
+ size:2,
+ productId:props.goods.id,
+ column:'/api/tbProductStockDetail/stock/count',
+ shopId:uni.getStorageSync('shopId'),
+ createdAt:[]
+ })
+ console.log(content);
+ recoders.list=content.map(v=>{
+ return {
+ ...v,
+ title:v.createdAt,
+ content:v.type+':'+Math.abs(v.stockNumber)
+ }
+ })
+ }
const isSku = computed(() => {
// return data.value.typeEnum == '多规格'
return false
diff --git a/pageProduct/index/components/goods.vue b/pageProduct/index/components/goods.vue
index 65359d6..c00bb8d 100644
--- a/pageProduct/index/components/goods.vue
+++ b/pageProduct/index/components/goods.vue
@@ -33,17 +33,18 @@
{{data.name}}
-
+ ¥
{{data.lowPrice}}
-
+
规格:
@@ -64,7 +65,7 @@
-
+
@@ -86,11 +87,11 @@
售罄
-
+
- 下架产品
-
+ {{data.isGrounding?'下架产品':'上架产品' }}
+
@@ -109,17 +110,21 @@