同步代码

This commit is contained in:
GaoHao
2025-02-07 14:49:20 +08:00
commit 0740c3f349
1141 changed files with 167372 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9" :zIndex="999">
<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-48">
<view>商品名称</view>
<view class="u-m-t-16 color-999" style="">{{data.name}}</view>
<view class="u-m-t-38">
<view class="u-m-b-32">
<view class="u-flex ">
报损数量
</view>
<view class="u-m-t-16">
<up-input v-model="form.stockNumber" type="number">
<!-- <template #suffix>
<view>{{data.unitName}}</view>
</template> -->
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.remark" placeholder="请输入备注"></up-textarea>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>上传图片</view>
</view>
<view class="u-m-t-16">
<my-up-upload :maxCount="1" :multiple="false" v-model="form.coverImg"></my-up-upload>
</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>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$frmLoss
} from '@/http/yskApi/goods.js'
import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
skuList: []
}
}
})
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
remark: '',
stockNumber: 1,
coverImg: []
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = props.goods
}
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
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
}
</script>
<style lang="scss" scoped>
::v-deep .u-m-t-16 .u-textarea{
border-width: 1px!important;
}
.box {
width: 556rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>

View File

@@ -0,0 +1,120 @@
<template>
<view>
<view class="category " :style="getCompouteStyle()">
<scroll-view scroll-y="true" :style="{height:props.height+'rpx'}">
<view class="list">
<view v-if="showAllText" class="font-bold item border-bottom u-font-28" @tap="cateClick({id:'',name:'全部分类'})">全部分类</view>
<view v-for="(item,index) in category.list" :key="index">
<view class="item font-bold border-bottom" @tap="cateClick(item)">
{{item.name}}
</view>
<view class="item border-bottom" @tap="cateClick(child)"
v-for="(child,childIndex) in item.childrenList"
:key="childIndex" >
<text>&nbsp;&nbsp;</text>
{{child.name}}
</view>
</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import {
ref, warn, watch, watchEffect,
onMounted,reactive
} from 'vue';
import {$tbShopCategory} from '@/http/yskApi/goods.js'
const emite=defineEmits(['cateClick','change'])
const props = defineProps({
showAllText:{
type:Boolean,
default:true
},
width: {
type: [Number, String],
default: 264
},
height: {
type: [Number, String],
default: 420
},
right: {
type: [Number, String],
default: 30
},
bottom: {
type: [Number, String],
default: 0
}
})
let show = ref(false)
watch(()=>show.value,(newval)=>{
emite('change',newval)
})
function open() {
show.value = true
}
function close() {
show.value = false
}
function toggle() {
show.value = !show.value
}
function cateClick(item){
emite('cateClick',item)
close()
}
function getCompouteStyle() {
return {
width: props.width + 'rpx',
height: props.height + 'rpx',
right: props.right + 'rpx',
bottom: props.bottom + 'rpx',
transform:`scaleY(${show.value?1:0})`
}
}
const category=reactive({
list:[],
categoryId:'',
categoryName:'',
})
onMounted(()=>{
$tbShopCategory({
page:0,size:200
}).then(res=>{
category.list=res.content
})
})
defineExpose({
open,
close,toggle
})
</script>
<style lang="scss" scoped>
.category {
background: #FFFFFF;
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
border-radius: 14rpx 14rpx 14rpx 14rpx;
position: fixed;
font-size: 24rpx;
color: #333;
.list{
box-sizing: border-box;
.item{
padding: 24rpx 24rpx 24rpx 48rpx;
}
}
}
</style>

View File

@@ -0,0 +1,93 @@
<template>
<view>
<view class="category " :style="getCompouteStyle()">
<scroll-view scroll-y="true" :style="{height:props.height+'rpx'}">
<view class="list">
<view class="item" @tap="cateClick(item)" v-for="(item,index) in 20" :key="index">
分类
</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import {
ref, warn, watch, watchEffect,
onMounted
} from 'vue';
import {$tbShopCategory} from '@/http/yskApi/goods.js'
const emite=defineEmits(['cateClick'])
const props = defineProps({
width: {
type: [Number, String],
default: 264
},
height: {
type: [Number, String],
default: 420
},
right: {
type: [Number, String],
default: 30
},
bottom: {
type: [Number, String],
default: 0
}
})
let show = ref(false)
function open() {
show.value = true
}
function close() {
show.value = false
}
function toggle() {
show.value = !show.value
}
function cateClick(item){
emite('cateClick',item)
}
function getCompouteStyle() {
return {
width: props.width + 'rpx',
height: props.height + 'rpx',
right: props.right + 'rpx',
bottom: props.bottom + 'rpx',
transform:`scaleY(${show.value?1:0})`
}
}
onMounted(()=>{
$tbShopCategory({
page:0,size:200
})
})
defineExpose({
open,
close,toggle
})
</script>
<style lang="scss" scoped>
.category {
background: #FFFFFF;
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
border-radius: 14rpx 14rpx 14rpx 14rpx;
position: fixed;
font-size: 24rpx;
color: #333;
.list{
box-sizing: border-box;
.item{
padding: 24rpx 24rpx 24rpx 48rpx;
}
}
}
</style>

View File

@@ -0,0 +1,106 @@
<template>
<up-picker :show="show" keyName="name" @confirm="confirm" :columns="category.list" @close="close" @cancel="close" :closeOnClickOverlay="true"></up-picker>
</template>
<script setup>
import {
ref, warn, watch, watchEffect,
onMounted,reactive
} from 'vue';
import {$tbShopCategory} from '@/http/yskApi/goods.js'
const emite=defineEmits(['change','update:isShow','confirm'])
const props = defineProps({
showAllText:{
type:Boolean,
default:true
},
width: {
type: [Number, String],
default: 264
},
height: {
type: [Number, String],
default: 420
},
right: {
type: [Number, String],
default: 30
},
bottom: {
type: [Number, String],
default: 0
},
isShow:{
type:Boolean,
default:false
}
})
let show = ref(props.isShow)
watch(()=>show.value,(newval)=>{
emite('change',newval)
emite('update:isShow',newval)
})
watch(()=>props.isShow,(newval)=>{
console.log(newval);
show.value=newval
})
function confirm(e){
console.log(e.value[0]);
show.value = false
emite('confirm',e.value[0])
}
function close() {
console.log('close');
show.value = false
}
const category=reactive({
list:[],
})
onMounted(()=>{
$tbShopCategory({
page:0,size:200
}).then(res=>{
res.content.unshift({
name:'全部',
id:'',
childrenList:[]
})
category.list=[res.content.reduce((prve, cur) => {
prve.push(...[{
...cur,
name: '' + cur.name,
childrenList:undefined
}, ...cur.childrenList.map(v => {
return {
...v,
name: '' + v.name
}
})])
return prve
}, [])]
console.log(category.list);
})
})
</script>
<style lang="scss" scoped>
.category {
background: #FFFFFF;
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
border-radius: 14rpx 14rpx 14rpx 14rpx;
position: fixed;
font-size: 24rpx;
color: #333;
.list{
box-sizing: border-box;
.item{
padding: 24rpx 24rpx 24rpx 48rpx;
}
}
}
</style>

View File

@@ -0,0 +1,166 @@
<template>
<view class="control" :style="getComputedStyle()">
<view class="u-flex control1" v-if="showControl1">
<!-- <view class="btn" @click="changeShowControl1">批量管理</view> -->
<view class="btn add font-bold u-font-28 color-fff" @tap="go.to('PAGES_PRODUCT_ADD')">商品添加</view>
<!-- <view class="color-999 btn u-flex u-row-center" @click="emitToggleCategory">
<text class="u-m-r-10">{{categoryName||'选择分类'}}</text>
<view class="arrow-down" :class="{'up':categoryShow}">
<uni-icons type="right" size="16" color="#999"></uni-icons>
</view>
</view> -->
</view>
<view class="u-flex control2 u-row-between" v-else>
<view class="u-flex btn">
<view class="u-m-r-58">
<label class="radio" @click="changeIsSelectAll">
<radio class="scale7" @tap.stop="changeIsSelectAll" :color="ColorMain" value="" :checked="isSelectAll" />
<text>全选</text>
</label>
</view>
<view class="u-p-l-30 u-p-r-30 my-bg-main" @click="changeShowControl1">取消</view>
<view class="u-p-l-60 u-p-r-60 borde-r" @click="offShelf">下架</view>
</view>
<view class=" u-flex u-row-center btn" @click="emitToggleCategory">
<text class="u-m-r-10">分类至</text>
<uni-icons type="right" size="16" color="#fff"></uni-icons>
</view>
</view>
</view>
</template>
<script setup>
import {$tbShopCategory} from '@/http/yskApi/goods.js'
import go from '@/commons/utils/go.js';
import {ColorMain} from '@/commons/color.js'
import {
onMounted,
reactive,
ref
} from 'vue';
const props = defineProps({
bottom: {
type: [Number, String],
default: 30
},
categoryName:{
type:String,
default:''
},
categoryShow:{
type:Boolean,
default:false
}
})
let showControl1 = ref(true)
const emits = defineEmits(['toggleCategory','controlChange','allCheckedChange','offShelf','categoryChange'])
function emitToggleCategory() {
emits('toggleCategory')
}
function changeShowControl1() {
showControl1.value = !showControl1.value
emits('controlChange',!showControl1.value)
}
let isSelectAll = ref(false)
function changeIsSelectAll() {
isSelectAll.value = !isSelectAll.value
emits('allCheckedChange',isSelectAll.value)
}
function getComputedStyle() {
return {
bottom: props.bottom + 'rpx'
}
}
//设置是否全选
function setisSelectAll(checked){
isSelectAll.value =checked
}
defineExpose({
setisSelectAll
})
//下架
function offShelf(){
emits('offShelf')
}
</script>
<style lang="scss" scoped>
.scale7 {
transform: scale(0.7);
}
.add{
background-color: $my-main-color;
border-radius: 100rpx;
overflow: hidden;
}
.borde-r {
position: relative;
&::after {
display: block;
content: '';
position: absolute;
top: 20rpx;
bottom: 20rpx;
width: 2px;
background-color: #fff;
right: 0;
}
}
.control {
position: fixed;
left: 110rpx;
right: 110rpx;
z-index: 100;
background: #3E3A3A;
border-radius: 100rpx;
overflow: hidden;
.btn{
color: #fff;
}
.control1 {
.arrow-down {
transform: rotate(90deg);
transition: all .2s ease-in-out;
&.up{
transform: rotate(-90deg);
}
}
}
.control1 .btn:not(:last-child)::after {
display: block;
content: '';
position: absolute;
top: 20rpx;
bottom: 20rpx;
width: 2px;
background-color: #fff;
right: 0;
}
.control1 .btn {
flex: 1;
}
.control1 .btn,
.control2 .btn{
position: relative;
line-height: 76rpx;
text-align: center;
}
.control2 {
padding: 0 28rpx;
}
}
</style>

View File

@@ -0,0 +1,171 @@
<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">{{data.specSnap}}</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-48">
<view class="u-flex u-row-between border-bottom u-p-b-30">
<view>当前状态</view>
<view class="u-flex u-relative">
<up-radio-group v-model="isGrounding" placement="row" @change="isGroundingChange">
<up-radio :customStyle="{marginRight: '10px'}" v-for="(item, index) in status.list"
:key="index" :label="item.label" :name="item.name">
</up-radio>
</up-radio-group>
<view class="u-absolute position-all" @click="hasShangXiajia(true)" v-if="!canShangXiaJia"></view>
</view>
</view>
<view class=" u-flex u-row-between u-m-t-30 u-relative">
<view>售罄</view>
<up-switch :activeValue="1" :inactiveValue="0" :size="20" @change="isPauseSaleChange" v-model="isPauseSale"></up-switch>
<view class="u-absolute position-all" @click="hasShouQing(true)" v-if="!canShouQing"></view>
</view>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$updateGrounding,
$updateProductStatus,$updateProductData,
$tbProskuConV2
} from '@/http/yskApi/goods.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
skuList: []
}
}
})
const status = reactive({
list: [{
name: 1,
label: '上架中'
}, {
name: 0,
label: '已下架'
}],
})
// 是否售罄
const isPauseSale = ref(0)
// 是否上架
const isGrounding = ref(1)
const data = ref(props.goods)
const emits = defineEmits(['update:show', 'save', 'isGroundingChange', 'isPauseSaleChange'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
console.log(props.goods);
data.value = props.goods
isPauseSale.value = props.goods.isPauseSale
isGrounding.value = props.goods.isGrounding
}
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
hasShangXiajia()
hasShouQing()
}
function save() {
emits('save')
}
function upDateGoods(par) {
return $updateProductData([{
id: data.value.id,
isSku: 1,
shopId: uni.getStorageSync('shopId'),
...par
}])
}
let canShangXiaJia=ref(false)
async function hasShangXiajia(tips=false){
canShangXiaJia.value=await hasPermission({text:'允许上下架商品',tips})
}
let canShouQing=ref(false)
async function hasShouQing(tips=false){
canShouQing.value=await hasPermission({text:'允许售罄商品',tips})
}
async function isGroundingChange(e) {
if(!canShangXiaJia.value){
return
}
await upDateGoods({
key:'grounding',
value: e
})
emits('isGroundingChange', e)
infoBox.showToast('更新成功')
}
async function isPauseSaleChange(e) {
if(!canShouQing.value){
return
}
console.log(e);
await upDateGoods({
key:'pauseSale',
value: e
})
emits('isPauseSaleChange', e)
infoBox.showToast('更新成功')
}
</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>

View File

@@ -0,0 +1,251 @@
<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-48">
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm">
<view>商品名称</view>
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
<view class="u-m-t-38">
<template v-if="!isSku">
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>{{data.name}}</view>
<view class="u-font-24">
<text>变动金额</text>
<text class="number">{{data.lowPrice*1-data._lowPrice*1}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input v-model="data.lowPrice" type="number"
@change="priceFormat(data,'lowPrice',$event)">
<template #suffix>
<view></view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</template>
<template v-else>
<scroll-view scroll-y="true" style="max-height: 50vh;">
<view class="u-m-b-32" v-for="(item,index) in data.skuList" :key="index">
<view class="u-flex u-row-between">
<view>{{item.name}}</view>
<view class="u-font-24">
<text>变动金额</text>
<text class="number">{{item.lowPrice-item._lowPrice}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input @change="priceFormat(item,'lowPrice',$event)" v-model="item.lowPrice"
type="number">
<template #suffix>
<view></view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</scroll-view>
</template>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
保存
</view>
</my-button>
</view>
</view>
</up-form>
</view>
</view>
</up-popup>
</template>
<script setup>
import {
computed,
reactive,
ref,
watch,
nextTick,
onMounted
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
formatPrice
} from "@/commons/utils/format.js";
function priceFormat(item, key, val) {
let min = 0;
let max = 100000000;
const returnNewVal = formatPrice(val, min, max, true)
const newval = typeof returnNewVal !== 'number' ? returnNewVal.value : returnNewVal
if (typeof returnNewVal !== 'number') {
uni.showToast({
title: `请输入${min}${max}范围内的数字`,
icon: 'none'
})
}
setTimeout(() => {
item[key] = newval
}, 100)
}
const refForm = ref(null)
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
return {
lowPrice: 0,
skuList: []
}
}
}
})
let data = ref({
lowPrice: 0,
skuList: []
})
const rules = {
'lowPrice': [{
type: 'Number',
min: 0,
required: true,
message: '价格不能小于0',
trigger: ['blur', 'change']
},
{
validator: (rule, value, callback) => {
return true
},
message: ''
}
]
}
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = {
...props.goods
}
}
})
const isSku = computed(() => {
return data.value.typeEnum == '多规格'
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
function save() {
refForm.value.validate().then(valid => {
if (valid) {
emits('save', {
...data.value,
})
} else {
console.log(err);
}
}).catch(() => {
// 处理验证错误
});
}
// function save() {
// const skuSnap = returnSkuSnap(data.value)
// let typeEnum = returnTypeEnum(data.value.typeEnum)
// let lowPrice = undefined
// typeEnum = typeEnum ? typeEnum : 'normal'
// const findCategory = returnCategory(data.value.categoryName, props.category)
// console.log(typeEnum);
// console.log(findCategory);
// const categoryId = findCategory ? findCategory.id : ''
// if (typeEnum == 'normal') {
// // 单规格
// lowPrice = data.value.skuList[0].salePrice
// }
// emits('save', {
// ...data.value,
// lowPrice,
// typeEnum,
// images: data.value.images ? data.value.images : [data.value.coverImg],
// categoryId,
// skuSnap: JSON.stringify(skuSnap)
// })
// }
onMounted(()=>{
// #ifndef H5
refForm.value.setRules(rules)
// #endif
})
</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>

View File

@@ -0,0 +1,280 @@
<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-48">
<up-form labelPosition="left" :model="data" :rules="rules" ref="refForm" errorType="toast">
<view>商品名称</view>
<view class="u-m-t-16" v-if="isSku">{{data.name}}</view>
<view class="u-m-t-38">
<template v-if="!isSku">
<view class="u-m-b-32" >
<view class="u-flex u-row-between">
<view>{{data.name}}</view>
<view class="u-font-24">
<text>变动数量</text>
<text class="number">{{data.stockNumber-data._stockNumber}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-form-item prop="stockNumber">
<up-input v-model="data.stockNumber" type="number">
<template #suffix>
<view>{{data.unitName||''}}</view>
</template>
</up-input>
</up-form-item>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</template>
<template v-else>
<scroll-view scroll-y="true" style="max-height: 30vh;">
<view class="u-m-b-32" v-for="(item,index) in data.skuList" :key="index">
<view class="u-flex u-row-between">
<view>{{item.name}}</view>
<view class="u-font-24">
<text>变动数量</text>
<text class="number">{{item.stockNumber-item._stockNumber}}</text>
</view>
</view>
<view class="u-m-t-16">
<up-input v-model="item.stockNumber">
<template #suffix>
<view>{{data.unitName||''}}</view>
</template>
</up-input>
</view>
</view>
<view class="u-m-b-32">
<view class="u-flex u-row-between">
<view>备注</view>
</view>
<view class="u-m-t-16">
<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
</view>
</view>
</scroll-view>
</template>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
保存
</view>
</my-button>
<view class="u-m-t-30">
<template v-if="!recoders.show">
<view class="color-999 u-font-24 u-flex u-row-center u-col-center">
<view class="u-flex" @click="changeShowRecoders(true)">
<view class="u-m-r-6">查看记录</view>
<up-icon name="arrow-down" :size="12"></up-icon>
</view>
</view>
</template>
<template v-else>
<scroll-view scroll-y="true" style="max-height: 30vh;">
<my-step :list="recoders.list"></my-step>
</scroll-view>
<view class="color-999 u-font-24 u-flex u-row-center u-col-center">
<!-- <view class="u-flex" @click="changeShowRecoders(false)"> -->
<view class="u-flex" @click="toRecodes">
<view class="u-m-r-6">全部记录</view>
<up-icon name="arrow-right" :size="12"></up-icon>
</view>
</view>
</template>
</view>
</view>
</view>
</up-form>
</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,$getProductStockDetail
} from '@/http/yskApi/goods.js'
import go from '@/commons/utils/go.js'
const refForm = ref(null)
const props = defineProps({
show: {
type: Boolean,
default: false
},
category: {
type: Array,
default: () => []
},
goods: {
type: Object,
default: () => {
return{
id:'',
skuList: []
}
}
}
})
const rules =reactive({
'stockNumber': [{
type: 'number',
required: true,
message: '请填写库存',
trigger: ['blur', 'change']
}
]
})
function toRecodes(){
console.log(props.goods.id);
go.to('PAGES_PRODUCT_INVOICING_LIST',{
productId:props.goods.id
})
}
function changeShowRecoders(show) {
recoders.show = show
}
const recoders = reactive({
list: [],
show: true,
active: 0
})
const data = ref({
name:''
})
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
watch(() => props.show, (newval) => {
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
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
form.note=''
}
function open() {
}
function save() {
refForm.value.validate().then(valid => {
if (valid) {
emits('save', {
...data.value,
})
} else {
console.log(err);
}
}).catch(() => {
// 处理验证错误
});
}
// function save() {
// const skuSnap = returnSkuSnap(data.value)
// let typeEnum = returnTypeEnum(data.value.typeEnum)
// let lowPrice = undefined
// typeEnum = typeEnum ? typeEnum : 'normal'
// const findCategory = returnCategory(data.value.categoryName, props.category)
// console.log(typeEnum);
// console.log(findCategory);
// const categoryId = findCategory ? findCategory.id : ''
// if (typeEnum == 'normal') {
// // 单规格
// lowPrice = data.value.skuList[0].salePrice
// }
// emits('save', {
// ...data.value,
// lowPrice,
// typeEnum,
// images: data.value.images ? data.value.images : [data.value.coverImg],
// categoryId,
// skuSnap: JSON.stringify(skuSnap)
// })
// }
onMounted(()=>{
// #ifndef H5
refForm.value.setRules(rules)
// #endif
})
</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: #F0465B;
}
</style>

View File

@@ -0,0 +1,410 @@
<template>
<view class=" goods">
<view class="u-flex u-row-between">
<view class="u-flex">
<view class="color-333">
<text class="">排序</text>
<text class="u-m-l-20">{{data.sort}}</text>
</view>
<view class="color-333 u-m-l-42 u-flex">
<up-icon @click="editStock" name="edit-pen" :size="16" :color="ColorMain"></up-icon>
<text class="stock u-m-l-4">库存:{{data.stockNumber}}</text>
</view>
</view>
<view>
<!-- <text class="u-font-28 color-666" @click="changeClick">修改</text> -->
<text class="u-font-28 color-666" @click="changePrice">改价</text>
<text class="u-font-28 color-red u-m-l-24" @click="baosun">报损</text>
</view>
</view>
<view class="u-m-t-48 u-flex u-col-top u-relative">
<view v-if="props.showChecked">
<label class="radio">
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
:checked="props.data.checked" /><text></text>
</label>
</view>
<view class="img">
<up--image :width="63" :height="63" :radius="3" :src="data.coverImg"></up--image>
</view>
<view class="w-full info">
<view class="info-p-l color-333 u-flex u-row-between">
<view class="u-flex">
<text class="u-m-r-24">{{data.name}}</text>
<!-- <uni-tag size="small" type="primary"
custom-style="background-color: #318AFE;" :text="data.typeEnum"></uni-tag> -->
</view>
<view class="u-font-32">
<text v-if="data.typeEnum=='单规格'">¥</text>
<text>{{data.lowPrice}}</text>
<!-- <text>¥</text>
<text>{{data.lowPrice}}</text>
<text v-if="data.typeEnum == '多规格'">~{{data.maxPrice }}</text> -->
</view>
</view>
<view class="u-m-t-24">
<template v-if="data.skuList.length>=2">
<view class="u-flex u-flex-wrap w-full gap-10 u-col-top" :style="skuStyle">
<view class="u-font-24 info-p-l u-m-t-6">规格</view>
<view class="skd" v-for="(item,index) in data.skuList" :key="index"
@click="guigeClick(index)">
<text>{{item.specSnap||item.name}}</text>
<view class="tag-primary tag" v-if="item.isGrounding">上架中</view>
<view class="tag-gray tag" v-if="item.isPauseSale">已售罄</view>
<view class="tag-gray tag" v-if="!item.isGrounding">已下架</view>
<!-- <template v-if="item.isPauseSale">
<view class="tag-gray tag" >已售罄</view>
</template>
<template v-else>
<view class="tag-primary tag" v-if="item.isGrounding">上架中</view>
<view class="tag-gray tag" v-else>已下架</view>
</template> -->
</view>
</view>
<template v-if="skuIsNotOne">
<view class="u-flex u-row-center">
<view class="u-flex u-flex-y-center" @click="toggleIsShowSkuAll" >
<view class="u-font-28 u-m-r-10 u-m-t-10 color-666">{{isShowSkuAll?'收起':'展开'}}</view>
<view class="u-flex u-flex-y-center">
<up-icon :size="14" name="arrow-down" v-if="!isShowSkuAll"></up-icon>
<up-icon :size="14" name="arrow-up" v-else></up-icon>
</view>
</view>
</view>
</template>
</template>
<template v-else>
<view style="height: 44rpx;">
</view>
</template>
</view>
</view>
</view>
<!-- <view class="u-m-t-16 skus u-text-center" v-if="data.skuList.length>=2">
<view class="u-flex u-flex-wrap skds">
<view class="skd" v-for="(item,index) in data.skuList" :key="index"><text>{{item.specSnap}}</text>
<view class="tag-primary tag">上架中</view>
</view>
</view>
</view> -->
<view class="u-m-t-24 u-flex u-row-between">
<view class="u-flex">
<view class="u-flex">
<view class="u-m-r-18 color-999">售罄</view>
<my-switch disabled v-model="isPauseSale" :openDisabledClass="false" @click="isPauseSaleChange"></my-switch>
</view>
<view class="u-flex u-m-l-30">
<view class="u-m-r-18 color-999">上架产品</view>
<my-switch disabled v-model="isGrounding" :openDisabledClass="false" @click="isGroundingChange"></my-switch>
</view>
</view>
<view class="u-flex">
<!-- <view class="btn-default btn" @tap="xiajia">下架商品</view> -->
<!-- <view class="btn-default btn" @tap="del">删除</view> -->
<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
</view>
</view>
</view>
</template>
<script setup>
import {
computed,
ref,
watch,
watchEffect
} from 'vue';
import {
$goodsIsHot,
$tbProskuConV2,$updateProductData
} from '@/http/yskApi/goods.js'
import go from '@/commons/utils/go.js';
import {hasPermission} from '@/commons/utils/hasPermission.js';
import {
ColorMain
} from '@/commons/color.js'
const emits = defineEmits(['radioClick', 'changeClick', 'xiajia', 'del', 'changePrice', 'baosun', 'guigeClick','update',
'editStock'
])
const props = defineProps({
index: {
type: Number
},
data: {
type: Object,
default: () => {
return {
}
}
},
showChecked: {
type: Boolean,
default: false
},
showDetail: {
type: Boolean,
default: false
}
})
let isShowSkuAll=ref(false)
const skuStyle=computed(()=>{
if(isShowSkuAll.value){
return ''
}else{
return 'height: 30px;overflow: hidden'
}
})
const skuIsNotOne=computed(()=>{
let isOne=true;
let width=0;
const fontSize=12;
const gap=5;
const boxWith=40;
const max=247;
for(let i in props.data.skuList){
const sku=props.data.skuList[i]
width+=(fontSize*sku.name.length+boxWith+gap)
if(width>max){
isOne=false
break;
}
}
return !isOne
})
function toggleIsShowSkuAll(){
isShowSkuAll.value=!isShowSkuAll.value
}
async function upDateGoods(par) {
const res = await $updateProductData([{
id: props.data.id,
isSku: 0,
shopId: uni.getStorageSync('shopId'),
...par
}])
uni.showToast({
title: '修改成功',
icon: 'none'
})
emits('update')
}
let isPauseSale=ref(props.data.isPauseSale)
let isGrounding=ref(props.data.isGrounding)
watch(() => props.data.isPauseSale, (newval) => {
isPauseSale.value=newval
})
watch(() => props.data.isGrounding, (newval) => {
isGrounding.value=newval
})
async function isPauseSaleChange(e) {
const res=await hasPermission('允许售罄商品')
if(!res){
return
}
upDateGoods({
key: 'pauseSale',
value: isPauseSale.value?0:1
})
}
async function isGroundingChange(e) {
const res=await hasPermission('允许上下架商品')
if(!res){
return
}
upDateGoods({
key: 'grounding',
value: isGrounding.value?0:1
})
}
let checked = ref(false)
function radioClick() {
console.log(props.index);
emits('radioClick', props.index)
}
function changeClick() {
emits('changeClick', props.index)
}
function reportDamage () {
emits('reportDamage', props.index)
}
function xiajia() {
emits('xiajia', props.index)
}
function del() {
emits('del', props.index)
}
async function changePrice() {
const res=await hasPermission('允许修改商品')
if(!res){
return
}
emits('changePrice', props.index)
}
function baosun() {
emits('baosun', props.index)
}
function guigeClick(guigeIndex) {
emits('guigeClick', props.index, guigeIndex)
}
function editStock() {
emits('editStock', props.index)
}
//携带参数type edit跳转到商品添加页面编辑与添加同一页面根据type值来判断
function toEdit() {
emits('edit', props.data.id)
// go.to('PAGES_PRODUCT_ADD', {
// type: 'edit',
// productId: props.data.id
// })
}
</script>
<style lang="scss" scoped>
$imgSize: 126rpx;
$price-color: #F02C45;
.btn {
padding: 6rpx 28rpx;
border-radius: 100rpx;
border: 2rpx solid transparent;
}
.gap-10 {
gap: 10rpx;
}
.btn-primary {
border-color: $my-main-color;
color: $my-main-color;
}
.btn-default {
border-color: #F4F4F4;
color: #999;
}
.price {
color: $price-color;
}
.h-100 {
height: $imgSize;
}
.img {
position: absolute;
left: 0;
top: 0;
// width: $imgSize;
// height: $imgSize;
}
.info-p-l {
padding-left: 71px;
}
.icon-arrow-right {
width: 32rpx;
height: 32rpx;
}
.stock {
// padding-right: 46rpx;
position: relative;
}
.stock::after {
// content: '';
// position: absolute;
// right: 10rpx;
// top: 50%;
// transform: translateY(-50%);
// display: block;
// width: 16rpx;
// border: 2rpx solid #333333;
}
.color-red {
color: #F0465B;
}
.goods {
border-radius: 10rpx 10rpx 10rpx 10rpx;
background-color: #fff;
padding: 24rpx 28rpx 16rpx 28rpx;
font-size: 28rpx;
.skus {
background: #F9F9F9;
border-radius: 14rpx 14rpx 14rpx 14rpx;
padding: 20rpx;
.sku {
color: #000;
font-weight: 700;
padding: 6rpx 40rpx;
}
.skds {
gap: 10rpx 50rpx;
}
}
}
.skd {
padding: 10rpx 38rpx 8rpx 40rpx;
background: #F0F2F5;
border-radius: 4rpx;
position: relative;
color: #666;
overflow: hidden;
margin-bottom: 10rpx;
font-size: 24rpx;
.tag {
position: absolute;
right: 0;
top: 0;
font-size: 12rpx;
height: 18rpx;
line-height: 18rpx;
right: 0;
border-radius: 0rpx 2rpx 2rpx 8rpx;
}
.tag-primary {
background-color: $my-main-color;
color: #fff;
}
.tag-gray {
background-color: rgb(144, 147, 153);
color: #fff;
}
}
</style>