更新商品管理模块

This commit is contained in:
2024-09-28 15:07:09 +08:00
parent 3c7918211e
commit 587965020b
11 changed files with 642 additions and 532 deletions

View File

@@ -21,7 +21,6 @@
</view>
<view class="u-m-t-24">
{{item.selectSpecResult}}
<uni-data-checkbox @change="createResult" multiple :selectedColor="color.ColorMain"
v-model="item.selectSpecResult" :localdata="item.value"></uni-data-checkbox>
@@ -30,6 +29,19 @@
</view>
</view>
</view>
<!-- <view class="block u-m-b-32 u-p-30">
<view class="font-bold">批量修改</view>
<view class="u-flex fast-edit u-flex-wrap gap-20 u-m-t-12">
<view class="color-main item u-flex u-row-center u-col-center" v-for="(item,index) in fastEdit.list" :key="index">
<view class="u-flex u-col-center">
<view class="u-m-r-12">{{item.text}}</view>
<up-icon size="16" :color="color.ColorMain" name="edit-pen"></up-icon>
</view>
</view>
</view>
</view> -->
<view>
<view class="block u-m-b-32" v-for="(item,index) in FormData.result" :key="index">
@@ -97,12 +109,12 @@
<uni-easyinput @blur="priceFormat(item.skus,'firstShared')"
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
:inputBorder="inputBorder" v-model="item.skus.firstShared" type="digit"
placeholder="请输入起售数量" />
placeholder="请输入分销金额" />
</uni-forms-item>
<uni-forms-item label="商品条码" required>
<uni-easyinput disabled :paddingNone="inputPaddingNone"
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.skus.barCode" placeholder="请输入起售数量" />
v-model="item.skus.barCode" placeholder="请输入商品条码" />
</uni-forms-item>
</view>
</view>
@@ -112,18 +124,25 @@
<view class="save-btn-box">
<button class="save-btn" hover-class="btn-hover-class" @click="save">保存</button>
<button class="save-btn edit-btn" hover-class="btn-hover-class" @click="fastEditShow">
<view class="u-flex u-row-center">
<view class="u-m-r-6">批量修改</view>
<up-icon name="edit-pen" :color="color.ColorMain"></up-icon>
</view>
</button>
</view>
</view>
<view class="bottom" ref="bottom"></view>
<pop-fast-edit @update="updateSkuKey" v-model:show="fastEdit.show"></pop-fast-edit>
</view>
</template>
<script setup>
import myUploadFile from '@/components/my-components/my-upload-file'
import {
formatPrice
} from "@/commons/utils/format.js";
import popFastEdit from "./components/fast-edit.vue"
const refFiles = ref([]);
//绑定文件上传元素
function setRefFile(index) {
@@ -135,10 +154,26 @@
};
}
const fastEdit=reactive({
show:false,
list:[
{text:'会员价',key:'memberPrice',value:''},
{text:'成本价',key:'costPrice',value:''},
{text:'原价',key:'originPrice',value:''},
{text:'起售数量',key:'suit',value:''},
{text:'库存数量',key:'stockNumber',value:''},
{text:'分销金额',key:'firstShared',value:''}
],
sel:''
})
function fastEditShow(){
fastEdit.show=true
}
//上个页面传来的参数
let option={}
//number类型数据限制
function priceFormat(item, key) {
nextTick(() => {
@@ -180,7 +215,19 @@
watch
} from 'vue';
function updateSkuKey(arr){
for(let i in FormData.result){
const sku=FormData.result[i].skus
for(let k in arr){
const item=arr[k]
if(sku.hasOwnProperty(item.key)){
sku[item.key]=item.value
}
}
}
}
const inputPaddingNone = ref(true)
const form = ref(null)
const originSpecMap={}
@@ -353,15 +400,16 @@
getTbProductSpec()
const obj = uni.getStorageSync('guige')
if (obj&&JSON.stringify(obj) !== '{}') {
console.log(obj.selectSpec);
option.productId=opt.productId
Object.assign(FormData, obj)
for(let i of obj.result){
const key=returnSpecSnap(i.names)
originSpecMap[key]=i
}
console.log(FormData);
nextTick(() => {
FormData.result = obj.result
console.log(FormData.result);
})
}
console.log(opt);
@@ -516,7 +564,7 @@
left: 30rpx;
right: 30rpx;
bottom: 60rpx;
z-index: 100;
}
::v-deep.uni-forms-item {
@@ -540,7 +588,12 @@
border-radius: 12rpx;
font-size: 28rpx;
}
.edit-btn{
background-color: #fff;
color: #333;
border-radius: 12rpx;
font-size: 28rpx;
}
.btn-hover-class {
opacity: .6;
}
@@ -551,7 +604,18 @@
padding-left: 42rpx;
border-radius: 14rpx 14rpx 14rpx 14rpx;
}
.fast-edit{
.item{
color: #333;
border: 1px solid #bbb;
padding: 4rpx 10rpx 8rpx 10rpx;
border-radius: 10rpx;
min-width: 186rpx;
&.active{
color: $my-main-color;
}
}
}
::v-deep .uni-input-placeholder {
font-size: 28rpx;
}

View File

@@ -0,0 +1,157 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
<view class="u-p-32 box u-font-28">
<view class="u-flex u-relative u-row-center">
<view class="u-font-32">快速修改</view>
<view class="u-absolute close">
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
</view>
</view>
<view class="u-m-t-36">
<view class="u-m-b-24" v-for="(item,index) in list" :key="index">
<view>{{item.text}}</view>
<view class="u-m-t-24">
<up-input v-model="item.value">
<template #suffix>
<up-button @click="itemClick(item)" type="primary" text="修改" size="mini"></up-button>
</template>
</up-input>
</view>
</view>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
修改
</view>
</my-button>
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted,
computed
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$tbShopUnit
} from '@/http/yskApi/goods.js'
const props = defineProps({
show: {
type: Boolean,
default: false
}
})
const arr = [
{
text: '售价',
key: 'salePrice',
value: ''
},
{
text: '会员价',
key: 'memberPrice',
value: ''
},
{
text: '成本价',
key: 'costPrice',
value: ''
},
{
text: '原价',
key: 'originPrice',
value: ''
},
{
text: '起售数量',
key: 'suit',
value: ''
},
{
text: '库存数量',
key: 'stockNumber',
value: ''
},
{
text: '分销金额',
key: 'firstShared',
value: ''
}
]
const list = ref([...arr])
function changeShowRecoders(show) {
recoders.show = show
}
const data = ref(props.item)
const emits = defineEmits(['update:show', 'update','itemClick'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
function itemClick(item){
console.log(item);
emits('update',[item])
}
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = props.item
}
})
const isSku = computed(() => {
// return data.value.typeEnum == '多规格'
return false
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
list.value=[...arr]
}
function open() {
}
function save() {
emits('update',list.value)
popShow.value = false
}
</script>
<style lang="scss" scoped>
.box {
width: 556rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>