代码更新
This commit is contained in:
@@ -466,7 +466,8 @@
|
||||
getProductDetail,
|
||||
addProduct,
|
||||
updateProduct,
|
||||
delProduct
|
||||
delProduct,
|
||||
productBindCons
|
||||
} from '@/api/product.js'
|
||||
import {
|
||||
uploadFile
|
||||
@@ -575,6 +576,7 @@
|
||||
watch(() => FormData.type, (newval) => {
|
||||
if (option.type == 'edit') {
|
||||
FormData.specId = newval != 'sku' ? '' : ($goodsData.specId || '')
|
||||
console.log($goodsData)
|
||||
if (newval == $goodsData.type) {
|
||||
skuList.list = $goodsData.skuList
|
||||
if ($goodsData.groupSnap) {
|
||||
@@ -665,17 +667,17 @@
|
||||
url: v
|
||||
}
|
||||
})
|
||||
for (let i in res.conInfos) {
|
||||
const con = res.conInfos[i]
|
||||
const item = res.skuList.find(v => v.id == con.productSkuId)
|
||||
res.consList.map(v=>{
|
||||
const item = res.skuList.find(v => v.productId == v.productId)
|
||||
if (item) {
|
||||
if (item.hasOwnProperty('haoCaiList')) {
|
||||
item.haoCaiList.push(con)
|
||||
item.haoCaiList.push(v)
|
||||
} else {
|
||||
item.haoCaiList = [con]
|
||||
item.haoCaiList = [v]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
res.skuList = (res.skuList.length ? res.skuList : [])
|
||||
|
||||
$goodsData = res
|
||||
@@ -758,6 +760,7 @@
|
||||
}else{
|
||||
FormData.groupType = null
|
||||
}
|
||||
console.log(FormData)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1074,7 +1077,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 'single') {
|
||||
if (type != 'sku') {
|
||||
let lowPrice = skuList.list[0] ? skuList.list[0].salePrice : FormData.salePrice
|
||||
let suitNum = skuList.list[0] ? skuList.list[0].suitNum : 0
|
||||
if (lowPrice === '') {
|
||||
@@ -1088,7 +1091,9 @@
|
||||
}
|
||||
}
|
||||
if (type == 'sku') {
|
||||
|
||||
if ( selectSpecInfo.length ==0 || JSON.stringify(selectSpecInfo) == '{}') {
|
||||
return infoBox.showToast('请选择规格!')
|
||||
}
|
||||
}
|
||||
if (type == 'package') {
|
||||
if (groupType == 0 && FormData.proGroupVo[0].goods.length <= 0) {
|
||||
@@ -1218,6 +1223,9 @@
|
||||
*/
|
||||
function toTimerPage() {
|
||||
go.to('PAGES_PRODUCT_TIMER', {
|
||||
days: FormData.days,
|
||||
startTime: FormData.startTime,
|
||||
endTime: FormData.endTime
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,131 +3,63 @@
|
||||
<view class="default-box-padding bg-fff border-r-18">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>商品名称</view>
|
||||
<view class="u-flex u-font-24 color-666">
|
||||
<view class="u-m-r-20">绑定至规格</view>
|
||||
<view class="u-flex u-relative">
|
||||
<up-switch :size="18" v-model="pageData.isBindGuige" :disabled="!isSku">绑定至规格</up-switch>
|
||||
<view class="u-absolute position-all" style="z-index: 1;" v-if="!isSku"
|
||||
@click="infoBox.showToast('只有单规格或者多规格商品可绑定至规格',3)"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="border-bottom u-m-t-16 u-p-b-32">{{skuList.length}}{{goods.name}}</view>
|
||||
<view class="">
|
||||
<template v-if="pageData.isBindGuige&&isSku">
|
||||
<view class="list">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(sku,index) in skuList" :key="index">
|
||||
<view>规格名称</view>
|
||||
<view class="u-m-t-16">{{sku.specInfo}}</view>
|
||||
<view class="color-666 u-m-t-24 u-flex">
|
||||
<view class="xuhao">序号</view>
|
||||
<view class="list">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(item,index) in consList" :key="index">
|
||||
<view class="color-666 u-flex">
|
||||
<view class="xuhao">序号</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1">耗材名称</view>
|
||||
<view class="u-flex-1">单位</view>
|
||||
<view class="u-flex-1">用量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 color-666">
|
||||
<view class=" u-m-t-24 u-flex">
|
||||
<view class="xuhao">{{index+1}}</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1">耗材名称</view>
|
||||
<view class="u-flex-1">单位</view>
|
||||
<view class="u-flex-1">用量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 color-666">
|
||||
<view class="u-m-t-24" v-for="(item,haocaiIndex) in sku.haoCaiList" :key="haocaiIndex">
|
||||
<view class=" u-flex">
|
||||
<view class="xuhao">{{haocaiIndex+1}}</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1 ">
|
||||
<choose-haocai @change="conInfosChange($event,item)"
|
||||
:listMap="$haocaiMap" :list="haoCaiList"
|
||||
v-model="item.consInfoId"></choose-haocai>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<choose-danwei :listMap="$danweiMap" :list="danweiList"
|
||||
v-model="item.conUnit"></choose-danwei>
|
||||
</view>
|
||||
<view class="u-flex input">
|
||||
<up-input border="none" v-model="item.surplusStock"></up-input>
|
||||
<up-icon @click="delGuigeHaocao(index,haocaiIndex)" color="#EA4025"
|
||||
:size="16" name="minus-circle-fill"></up-icon>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<choose-haocai @change="conInfosChange($event,item)" :listMap="$haocaiMap"
|
||||
:list="haoCaiList" v-model="item.consInfoId"></choose-haocai>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<choose-danwei v-model="item.conUnit"></choose-danwei>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<view class="u-flex input">
|
||||
<up-input border="none" v-model="item.surplusStock"></up-input>
|
||||
<up-icon @click="delHaocai(index)" color="#EA4025" :size="16"
|
||||
name="minus-circle-fill"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-16 color-666 u-font-24">
|
||||
<view class="xuhao">
|
||||
</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存:{{item.stockNumber}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class=" u-p-t-32 u-flex" @click="addGuigeHaocai(index)">
|
||||
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
|
||||
<view class="u-m-l-16">添加耗材</view>
|
||||
<view class="u-flex u-m-t-16 u-font-24" v-if="item.stockNumber">
|
||||
<view class="xuhao">
|
||||
|
||||
</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存:{{item.stockNumber}}
|
||||
{{item.conUnit}}
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="list">
|
||||
<view class="u-p-b-32 u-p-t-32 border-bottom" v-for="(item,index) in conInfos" :key="index">
|
||||
<view class="color-666 u-flex">
|
||||
<view class="xuhao">序号</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1">耗材名称</view>
|
||||
<view class="u-flex-1">单位</view>
|
||||
<view class="u-flex-1">用量</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 color-666">
|
||||
<view class=" u-m-t-24 u-flex">
|
||||
<view class="xuhao">{{index+1}}</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||
<view class="u-flex-1 ">
|
||||
<choose-haocai @change="conInfosChange($event,item)" :listMap="$haocaiMap"
|
||||
:list="haoCaiList" v-model="item.consInfoId"></choose-haocai>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<choose-danwei v-model="item.conUnit"></choose-danwei>
|
||||
</view>
|
||||
<view class="u-flex-1 ">
|
||||
<view class="u-flex input">
|
||||
<up-input border="none" v-model="item.surplusStock"></up-input>
|
||||
<up-icon @click="delHaocai(index)" color="#EA4025" :size="16"
|
||||
name="minus-circle-fill"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-16 u-font-24" v-if="item.stockNumber">
|
||||
<view class="xuhao">
|
||||
|
||||
</view>
|
||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存:{{item.stockNumber}}
|
||||
{{item.conUnit}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class=" u-p-t-32 u-flex" @click="addHaocai">
|
||||
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
|
||||
<view class="u-m-l-16">添加耗材</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="!pageData.isBindGuige">
|
||||
<view class="u-flex">
|
||||
<view class=" u-p-t-32 u-flex" @click="addHaocai">
|
||||
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
|
||||
<view class="u-m-l-16">添加耗材</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="default-box-padding bg-fff border-r-18 u-flex u-row-between u-m-t-32">
|
||||
<view>当某个耗材的使用库存不足时,商品自动
|
||||
售罄。</view>
|
||||
<view>当某个耗材的使用库存不足时,商品自动售罄。</view>
|
||||
|
||||
</view>
|
||||
<view class="bottom">
|
||||
@@ -146,10 +78,10 @@
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import chooseHaocai from './choose-haocai.vue';
|
||||
import chooseDanwei from './choose-danwei.vue';
|
||||
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js';
|
||||
|
||||
import { getConsList } from '@/api/cons.js';
|
||||
import { productBind } from '@/api/product.js';
|
||||
import { productBindCons } from '@/api/product.js';
|
||||
|
||||
const emits = defineEmits(['cancel', 'updateGoods'])
|
||||
|
||||
@@ -158,9 +90,9 @@
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
conInfos: [],
|
||||
consList: [],
|
||||
skuList: [],
|
||||
typeEnum: ''
|
||||
type: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,30 +105,19 @@
|
||||
let haoCaiList = ref([])
|
||||
let $haocaiMap = reactive({})
|
||||
const skuList = ref(props.goods.skuList)
|
||||
const conInfos = ref(props.goods.conInfos||[])
|
||||
watch(() => props.goods.conInfos, (newval) => {
|
||||
conInfos.value = newval
|
||||
const consList = ref(props.goods.consList||[])
|
||||
watch(() => props.goods.consList, (newval) => {
|
||||
consList.value = newval
|
||||
})
|
||||
watch(() => props.goods.skuList, (newval) => {
|
||||
skuList.value = newval
|
||||
})
|
||||
watch(() => props.goods.type, (newval) => {
|
||||
if(!newval){
|
||||
pageData.isBindGuige = false
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
if(props.goods.conInfos){
|
||||
const firstItem= props.goods.conInfos[0]
|
||||
pageData.isBindGuige = firstItem?(firstItem.productSkuId==0?false:true):false
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
function init() {
|
||||
console.log(skuList)
|
||||
getConsList({
|
||||
"status": 1,
|
||||
}).then(res => {
|
||||
@@ -227,101 +148,35 @@
|
||||
item.conUnit = newval.conUnit
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const $baseicHaocaiData = {
|
||||
consInfoId: '',
|
||||
conUnit: '',
|
||||
surplusStock: ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品耗材
|
||||
*/
|
||||
function addHaocai() {
|
||||
conInfos.value.push({
|
||||
...$baseicHaocaiData
|
||||
consList.value.push({
|
||||
consInfoId: '',
|
||||
conUnit: '',
|
||||
surplusStock: ''
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规格耗材
|
||||
* @param {Object} index
|
||||
*/
|
||||
function addGuigeHaocai(index) {
|
||||
console.log(skuList.value[index])
|
||||
if (skuList.value[index].haoCaiList) {
|
||||
skuList.value[index].haoCaiList.push({
|
||||
...$baseicHaocaiData
|
||||
})
|
||||
} else {
|
||||
skuList.value[index]['haoCaiList'] = [{
|
||||
...$baseicHaocaiData
|
||||
}]
|
||||
}
|
||||
console.log(skuList.value[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品耗材
|
||||
* @param {Object} index
|
||||
*/
|
||||
function delHaocai(index) {
|
||||
const item = conInfos.value[index]
|
||||
console.log(item);
|
||||
const item = consList.value[index]
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除该耗材',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
if (item.id) {
|
||||
deletetbProskuCon([item.id]).then(res1 => {
|
||||
conInfos.value.splice(index, 1)
|
||||
})
|
||||
} else {
|
||||
conInfos.value.splice(index, 1)
|
||||
}
|
||||
|
||||
consList.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规格耗材
|
||||
* @param {Object} guigeIndex
|
||||
* @param {Object} haocaiIndex
|
||||
*/
|
||||
function delGuigeHaocao(guigeIndex, haocaiIndex) {
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是多规格商品
|
||||
*/
|
||||
const isSku = computed(() => {
|
||||
return props.goods.type == 'sku'||props.goods.type == 'single'
|
||||
})
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@@ -330,21 +185,9 @@
|
||||
if (!bol) {
|
||||
return
|
||||
}
|
||||
console.log('save');
|
||||
let isPas = false
|
||||
if (!pageData.isBindGuige) {
|
||||
//绑定至商品
|
||||
isPas = conInfos.value.every(v => {
|
||||
return v.consInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
} else {
|
||||
//绑定至规格
|
||||
isPas = skuList.value.filter(v => v.haoCaiList && v.haoCaiList.length).every(sku => {
|
||||
return sku.haoCaiList.every(v => {
|
||||
return v.consInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
})
|
||||
}
|
||||
let isPas = consList.value.every(v => {
|
||||
return v.consInfoId && v.conUnit && v.surplusStock > 0
|
||||
})
|
||||
|
||||
if (!isPas) {
|
||||
return infoBox.showToast('请填写全部耗材选项值')
|
||||
@@ -353,33 +196,15 @@
|
||||
id: props.goods.id,
|
||||
consList: []
|
||||
}
|
||||
if (!pageData.isBindGuige) {
|
||||
//绑定至商品
|
||||
ajaxData.consList = conInfos.value.map(v => {
|
||||
return {
|
||||
id: v.id || '',
|
||||
consInfoId: v.consInfoId,
|
||||
productId: props.goods.id,
|
||||
surplusStock: v.surplusStock * 1,
|
||||
}
|
||||
})
|
||||
} else {
|
||||
for (let i in skuList.value) {
|
||||
const haocaiList = skuList.value[i].haoCaiList || []
|
||||
for (let k in haocaiList) {
|
||||
const v = haocaiList[k]
|
||||
ajaxData.consList.push({
|
||||
id: v.id || '',
|
||||
consInfoId: v.consInfoId,
|
||||
productId: props.goods.id,
|
||||
surplusStock: v.surplusStock * 1,
|
||||
})
|
||||
}
|
||||
ajaxData.consList = consList.value.map(v => {
|
||||
return {
|
||||
id: v.id || '',
|
||||
consInfoId: v.consInfoId,
|
||||
productId: props.goods.id,
|
||||
surplusStock: v.surplusStock * 1,
|
||||
}
|
||||
|
||||
}
|
||||
console.log(ajaxData);
|
||||
await productBind(ajaxData)
|
||||
})
|
||||
await productBindCons(ajaxData)
|
||||
emits('updateGoods')
|
||||
infoBox.showToast('修改成功')
|
||||
}
|
||||
|
||||
@@ -40,74 +40,20 @@
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-center u-m-t-60">
|
||||
<my-button width="580" shape="circle" @click="save">保存</my-button>
|
||||
<my-button width="580" shape="circle" @click="emitTimerSave">保存</my-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
computed,
|
||||
ref
|
||||
} from 'vue';
|
||||
import { onLoad, onReady } from '@dcloudio/uni-app';
|
||||
import { computed, ref } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import color from '@/commons/color.js'
|
||||
import {
|
||||
$getProductDetail,
|
||||
} from '@/http/yskApi/goods.js'
|
||||
//返回一天的时间 时分格式
|
||||
function returnDayTime() {
|
||||
return new Array(3).fill(1).map((v, index) => {
|
||||
if (index === 0) {
|
||||
return new Array(24).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
if (index === 1 || index === 2) {
|
||||
return new Array(60).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const times = ref(returnDayTime())
|
||||
let defaultTimeIndex = ref(0)
|
||||
|
||||
function getTime(indexArr) {
|
||||
const hour = times.value[0][indexArr[0]]
|
||||
const month = times.value[1][indexArr[1]]
|
||||
const s = times.value[2][indexArr[2]]
|
||||
// return `${hour}:${month}:${s}`
|
||||
return `${hour}:${month}`
|
||||
}
|
||||
//获取$event.detail.value
|
||||
function getEnentDetailValue(e) {
|
||||
return e.detail.value
|
||||
}
|
||||
|
||||
function setListTimeValue(index, key, time) {
|
||||
list.value[index][key].value = time
|
||||
}
|
||||
|
||||
function startTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'startTime', time)
|
||||
}
|
||||
|
||||
function endTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'endTime', time)
|
||||
}
|
||||
|
||||
|
||||
|
||||
import { getProductDetail } from '@/api/product.js'
|
||||
|
||||
|
||||
const cycle = [{
|
||||
value: 'Monday',
|
||||
text: '星期一'
|
||||
@@ -140,15 +86,89 @@
|
||||
const ListDataconstructor = {
|
||||
cycleChecked: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
||||
}
|
||||
let goodsDetail = ref({})
|
||||
onLoad(async (opt) => {
|
||||
console.log(opt)
|
||||
const arr = opt ? returnTimer(opt) : [];
|
||||
console.log(arr);
|
||||
if (arr.length) {
|
||||
list.value = arr
|
||||
}
|
||||
})
|
||||
|
||||
function returnTimer(res) {
|
||||
return [{
|
||||
cycleChecked: res.days ? res.days.split(',').filter(v => v) : [],
|
||||
startTime: res.startTime ? {
|
||||
value: res.startTime,
|
||||
index: returnTimeIndex(res.startTime)
|
||||
} : returnBasicTimeConstructor.startTime,
|
||||
endTime: res.endTime ? {
|
||||
value: res.endTime,
|
||||
index: returnTimeIndex(res.endTime)
|
||||
} : returnBasicTimeConstructor.endTime
|
||||
}]
|
||||
}
|
||||
|
||||
function returnTimeIndex(time) {
|
||||
return time.split(':').map(v => {
|
||||
return v * 1
|
||||
})
|
||||
}
|
||||
const times = ref(returnDayTime())
|
||||
//返回一天的时间 时分格式
|
||||
function returnDayTime() {
|
||||
return new Array(3).fill(1).map((v, index) => {
|
||||
if (index === 0) {
|
||||
return new Array(24).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
if (index === 1 || index === 2) {
|
||||
return new Array(60).fill(1).map((hour, index) => {
|
||||
return `0${index}`.slice(-2)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
let defaultTimeIndex = ref(0)
|
||||
function getTime(indexArr) {
|
||||
const hour = times.value[0][indexArr[0]]
|
||||
const month = times.value[1][indexArr[1]]
|
||||
const s = times.value[2][indexArr[2]]
|
||||
// return `${hour}:${month}:${s}`
|
||||
return `${hour}:${month}:${s}`
|
||||
}
|
||||
|
||||
//获取$event.detail.value
|
||||
function getEnentDetailValue(e) {
|
||||
return e.detail.value
|
||||
}
|
||||
|
||||
function setListTimeValue(index, key, time) {
|
||||
list.value[index][key].value = time
|
||||
}
|
||||
|
||||
function startTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'startTime', time)
|
||||
}
|
||||
|
||||
function endTimeChange(e, index) {
|
||||
const indexArr = getEnentDetailValue(e)
|
||||
const time = getTime(indexArr)
|
||||
setListTimeValue(index, 'endTime', time)
|
||||
}
|
||||
|
||||
function returnBasicTimeConstructor() {
|
||||
return {
|
||||
startTime: {
|
||||
value: '00:00',
|
||||
value: '00:00:00',
|
||||
index: [0, 0, 0]
|
||||
},
|
||||
endTime: {
|
||||
value: '23:59',
|
||||
value: '23:59:59',
|
||||
index: [0, 0, 0]
|
||||
}
|
||||
}
|
||||
@@ -184,51 +204,17 @@
|
||||
function emitTimerSave() {
|
||||
const par = {
|
||||
days: list.value[0].cycleChecked.join(','),
|
||||
startTime: list.value[0].startTime.value+':00',
|
||||
endTime: list.value[0].endTime.value+':00'
|
||||
startTime: list.value[0].startTime.value,
|
||||
endTime: list.value[0].endTime.value
|
||||
}
|
||||
console.log(par);
|
||||
uni.$emit('timerSave', par)
|
||||
go.back()
|
||||
}
|
||||
|
||||
function save() {
|
||||
emitTimerSave()
|
||||
}
|
||||
let goodsDetail = ref({})
|
||||
|
||||
function returnTimeIndex(time) {
|
||||
console.log(time);
|
||||
return time.split(':').map(v => {
|
||||
return v * 1
|
||||
})
|
||||
}
|
||||
|
||||
function returnTimer(res) {
|
||||
return [{
|
||||
cycleChecked: res.days ? res.days.split(',').filter(v => v) : [],
|
||||
startTime: res.startTime ? {
|
||||
value: res.startTime,
|
||||
index: returnTimeIndex(res.startTime)
|
||||
} : returnBasicTimeConstructor.startTime,
|
||||
endTime: res.endTime ? {
|
||||
value: res.endTime,
|
||||
index: returnTimeIndex(res.endTime)
|
||||
} : returnBasicTimeConstructor.endTime
|
||||
}]
|
||||
}
|
||||
onLoad(async (opt) => {
|
||||
let res = null
|
||||
if (opt.productId) {
|
||||
res = await $getProductDetail(opt.productId)
|
||||
goodsDetail.value = res
|
||||
}
|
||||
const arr = res ? returnTimer(res) : [];
|
||||
console.log(arr);
|
||||
if (arr.length) {
|
||||
list.value = arr
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -2,173 +2,304 @@
|
||||
<view class="page min-page">
|
||||
<view class="box">
|
||||
<view class="block border-top-0 u-p-t-32 u-p-b-32">
|
||||
|
||||
<!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
|
||||
<up-form ref="formRef" labelPosition="top" :model="vdata.formData" :rules="vdata.rules" labelWidth="80" :labelStyle="{fontWeight:'bold'}">
|
||||
<up-form-item label="规格名称" prop="name" borderBottom >
|
||||
<up-input v-model="vdata.formData.name" border="none" placeholder="规格名称,如:衣服" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="规格级别" prop="level" borderBottom @click="vdata.showLevel = true;">
|
||||
<up-input v-model="vdata.levelName" readonly border="none" placeholder="请选择规格级别" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="排序" prop="sort" borderBottom >
|
||||
<up-input v-model="vdata.formData.sort" border="none" placeholder="请输入排序" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="上级规格" prop="pid" borderBottom @click="vdata.showSpec = true;">
|
||||
<up-input v-model="vdata.pidName" readonly border="none" placeholder="请选择上级规格" ></up-input>
|
||||
</up-form-item>
|
||||
</up-form>
|
||||
<uni-forms ref="nameFormRef" :model="specifications" :rules="rules" :label-width="350"
|
||||
label-position="top" validateTrigger="blur">
|
||||
<uni-forms-item label="模版名称" required name="name">
|
||||
<uni-easyinput padding-none :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="specifications.name" placeholder="模版名称,如:衣服" />
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
</view>
|
||||
<view v-for="(item,index) in specifications.children" :key="index">
|
||||
<uni-forms :model="item" :rules="rules" err-show-type="undertext" validateTrigger="blur"
|
||||
:ref="setFormRef(index)" :border="true" label-position="top" label-width="350">
|
||||
<view class="block">
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="规格组名" required name="name">
|
||||
<uni-easyinput padding-none :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
v-model="item.name" placeholder="规格组名,如:尺码" />
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class="u-p-b-8">
|
||||
<uni-forms-item label="规格值">
|
||||
<view class="option ">
|
||||
<view class="">
|
||||
<view class="u-flex option-item u-m-t-8" v-for="(option,optionIndex) in item.children"
|
||||
:key="optionIndex">
|
||||
<view class="u-flex-1">
|
||||
<uni-forms-item :key="optionIndex" :name="['children',optionIndex,'name']"
|
||||
:ref="setFormInputRef(index,optionIndex)"
|
||||
:rules="[{'required': true,errorMessage: '必填'}]" label-width="0"
|
||||
label="" required :showRequired="false">
|
||||
<view class="bg-fff u-p-t-12 u-p-b-12" style="border-radius: 8rpx;">
|
||||
<uni-easyinput
|
||||
v-model="specifications.children[index].children[optionIndex].name"
|
||||
@input="inpuChange(index,optionIndex)"
|
||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||
placeholder="请输入规格值,如:S、M" />
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<view class=" u-flex" v-if="item.children.length>1">
|
||||
<uni-forms-item :key="optionIndex" label-width="0" label=""
|
||||
:showRequired="false">
|
||||
<view class="u-flex">
|
||||
<view class="icon icon-reduce u-m-l-38"
|
||||
@click="delOption(index,optionIndex)">
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24 " @click="addOptions(index)">
|
||||
<view class="icon icon-add u-m-r-22 "></view>
|
||||
<view class="color-main">添加规格</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<template v-if="specifications.children.length>1">
|
||||
<view class="u-p-b-32">
|
||||
<view class="u-flex " @click="delSpecificationsGroup(index)">
|
||||
<view class="icon icon-reduce u-m-r-22 "></view>
|
||||
<view class="color-red">删除规格组</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</uni-forms>
|
||||
</view>
|
||||
|
||||
<view class="u-flex block u-p-l-20 u-p-r-20 u-p-t-28 u-p-b-28" @click="addSpecificationsGroup">
|
||||
<view class="icon icon-add u-m-r-22 "></view>
|
||||
<view class="color-main">添加规格组</view>
|
||||
</view>
|
||||
|
||||
<view class="save-btn-box">
|
||||
<button class="save-btn " hover-class="btn-hover-class" @click="save">保存</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<up-action-sheet
|
||||
:show="vdata.showLevel"
|
||||
:actions="vdata.levelList"
|
||||
title="请选择规格级别"
|
||||
@close="vdata.showLevel = false"
|
||||
@select="levelSelect"
|
||||
></up-action-sheet>
|
||||
<up-action-sheet
|
||||
:show="vdata.showSpec"
|
||||
:actions="vdata.specList"
|
||||
title="请选择规格级别"
|
||||
@close="vdata.showSpec = false"
|
||||
@select="specSelect"
|
||||
></up-action-sheet>
|
||||
<view class="bottom" ref="bottom"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, nextTick, ref } from 'vue';
|
||||
import { onLoad, onReady, } from '@dcloudio/uni-app';
|
||||
|
||||
import {
|
||||
$productSpec
|
||||
} from '@/http/yskApi/goods.js'
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import { getSpecList, addSpec, updateSpec } from '@/api/product.js'
|
||||
import { reactive, nextTick, ref, } from 'vue';
|
||||
import { addSpecQuic } from '@/api/product.js'
|
||||
|
||||
const nameFormRef = ref(null)
|
||||
// 表单样式
|
||||
const placeholderStyle = ref('font-size:28rpx;')
|
||||
//表单边框
|
||||
const inputBorder = ref(false)
|
||||
const form = ref(null)
|
||||
const bottom = ref(null)
|
||||
//表单验证
|
||||
const rules = {
|
||||
name: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
},
|
||||
MinOptional: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
},
|
||||
MaxOptional: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
},
|
||||
optionPrice: {
|
||||
rules: [{
|
||||
required: true,
|
||||
errorMessage: '必填'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
const option = {
|
||||
type: 'add',
|
||||
id: undefined
|
||||
}
|
||||
const formRef = ref(null)
|
||||
const vdata = reactive({
|
||||
showLevel: false,
|
||||
showSpec: false,
|
||||
levelList: [
|
||||
{ name: "一级", value: 1},
|
||||
{ name: "二级", value: 2},
|
||||
{ name: "三级", value: 3}
|
||||
],
|
||||
levelName: "",
|
||||
pidName: "",
|
||||
formData: {
|
||||
id: null,
|
||||
name: "",
|
||||
level: "",
|
||||
sort: "",
|
||||
pid: "",
|
||||
},
|
||||
rules: {
|
||||
"name": {
|
||||
required: true,
|
||||
message: '请输入规格名称',
|
||||
trigger: ['blur', 'change'],
|
||||
// 规格列表
|
||||
const specifications = reactive({
|
||||
name: '',
|
||||
children: [
|
||||
{
|
||||
name: '',
|
||||
children: []
|
||||
},
|
||||
"level": {
|
||||
required: true,
|
||||
message: '请选择规格级别',
|
||||
trigger: ['blur', 'input'],
|
||||
},
|
||||
"sort": {
|
||||
required: true,
|
||||
message: '请输入排序',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
"pid": {
|
||||
required: true,
|
||||
message: '请选择上级规格',
|
||||
trigger: ['blur', 'input'],
|
||||
},
|
||||
},
|
||||
specList: []
|
||||
]
|
||||
})
|
||||
|
||||
onReady(()=>{
|
||||
})
|
||||
//表单验证
|
||||
onLoad(opt => {
|
||||
console.log(opt);
|
||||
if (opt && JSON.stringify(opt) !== '{}' && opt.type) {
|
||||
option.type = opt.type
|
||||
const data = uni.getStorageSync('spec')
|
||||
uni.removeStorageSync('spec')
|
||||
if(data){
|
||||
vdata.formData.id = data.id
|
||||
vdata.formData.name = data.name
|
||||
vdata.formData.level = data.level
|
||||
vdata.formData.sort = data.sort
|
||||
vdata.formData.pid = data.pid
|
||||
vdata.levelName = vdata.levelList.filter(item => item.value == vdata.formData.level)[0].name
|
||||
}
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: option.type === 'edit' ? '编辑规格模版' : '添加规格模版'
|
||||
title: '添加规格模版'
|
||||
})
|
||||
getSpecData()
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加规格组
|
||||
*/
|
||||
function addSpecificationsGroup() {
|
||||
specifications.children.push({
|
||||
name: '',
|
||||
children: []
|
||||
})
|
||||
scrollPageBottom()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规格列表
|
||||
* 删除规格组
|
||||
* @param {Object} index
|
||||
*/
|
||||
function getSpecData(){
|
||||
getSpecList({page: 0, size:10}).then(res=>{
|
||||
vdata.specList = [{name: '顶级',id: 0},...res]
|
||||
if(vdata.formData.id){
|
||||
vdata.pidName = vdata.specList.filter(item => item.id == vdata.formData.pid)[0].name
|
||||
}
|
||||
function delSpecificationsGroup(index) {
|
||||
if(specifications.children.length<=1) return;
|
||||
specifications.children.splice(index, 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定索引的规格组添加规格项
|
||||
* @param {Object} index
|
||||
*/
|
||||
function addOptions(index) {
|
||||
specifications.children[index].children.push({
|
||||
name: '',
|
||||
children: []
|
||||
})
|
||||
}
|
||||
|
||||
function levelSelect (e) {
|
||||
console.log(e)
|
||||
vdata.levelName = e.name;
|
||||
vdata.formData.level = e.value;
|
||||
/**
|
||||
* 删除指定索引的规格组添加规格项
|
||||
* @param {Object} index
|
||||
* @param {Object} optionIndex
|
||||
*/
|
||||
function delOption(index, optionIndex) {
|
||||
if(specifications.children[index].children.length<=1){
|
||||
return
|
||||
}
|
||||
specifications.children[index].children.splice(optionIndex, 1)
|
||||
}
|
||||
|
||||
function specSelect (e) {
|
||||
console.log(e)
|
||||
vdata.pidName = e.name;
|
||||
vdata.formData.pid = e.id;
|
||||
//页面滚动到最底部
|
||||
function scrollPageBottom() {
|
||||
nextTick(() => {
|
||||
uni.pageScrollTo({
|
||||
duration: 100, // 过渡时间
|
||||
scrollTop: 100000, // 滚动的实际距离
|
||||
})
|
||||
})
|
||||
}
|
||||
//设置表单验证规则
|
||||
function setFormRules() {
|
||||
form.value.setRules(rules)
|
||||
}
|
||||
const formRefs = ref([]);
|
||||
/**
|
||||
* 绑定表单元素
|
||||
* @param {Object} index
|
||||
*/
|
||||
function setFormRef(index) {
|
||||
formRefs.value[index] = null;
|
||||
return (el) => {
|
||||
if (el) {
|
||||
formRefs.value[index] = el;
|
||||
}
|
||||
};
|
||||
}
|
||||
// 绑定option input元素
|
||||
const refFormInput = ref([])
|
||||
function setFormInputRef(index, index1) {
|
||||
const newIndex = index * 10000 + index1
|
||||
return (el) => {
|
||||
if (el) {
|
||||
if (!refFormInput.value[newIndex]) {
|
||||
refFormInput.value[newIndex] = el;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当表单内容输入变化根据配置的rules进行验证
|
||||
* @param {Object} index
|
||||
* @param {Object} index1
|
||||
*/
|
||||
function inpuChange(index, index1) {
|
||||
const newIndex = index * 10000 + index1
|
||||
refFormInput.value[newIndex].onFieldChange()
|
||||
}
|
||||
|
||||
function onFieldChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
|
||||
function returnPromise(prosise, index) {
|
||||
return new Promise((resolve, reject) => {
|
||||
prosise.then(res => {
|
||||
console.log(res);
|
||||
resolve({
|
||||
sucees: true
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
resolve({
|
||||
sucees: false
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
async function save() {
|
||||
|
||||
if (option.type === 'add') {
|
||||
return addSpec(vdata.formData).then(res => {
|
||||
infoBox.showToast('添加成功')
|
||||
settimeoutBack(1500)
|
||||
})
|
||||
let isAllPassForm = 0
|
||||
const nameFormRes = await returnPromise(nameFormRef.value.validate())
|
||||
if (!nameFormRes.sucees) {
|
||||
isAllPassForm -= 1
|
||||
}
|
||||
updateSpec(vdata.formData).then(res => {
|
||||
infoBox.showToast('修改成功')
|
||||
settimeoutBack(1500)
|
||||
})
|
||||
for (let i in specifications.children) {
|
||||
const res = await returnPromise(formRefs.value[i].validate(), i)
|
||||
isAllPassForm += res.sucees ? 1 : 0
|
||||
}
|
||||
//判断验证是否通过
|
||||
if (isAllPassForm === specifications.children.length) {
|
||||
console.log('pass');
|
||||
const data = {
|
||||
name: specifications.name,
|
||||
children: specifications.children.map(v => {
|
||||
return {
|
||||
...v
|
||||
}
|
||||
})
|
||||
}
|
||||
addSpecQuic(data).then(res => {
|
||||
infoBox.showSuccessToast('添加成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
let timer = null
|
||||
function settimeoutBack(time) {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, time)
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<view class="u-m-b-32" v-for="(item,index) in list" :key="index">
|
||||
<view>{{item.text}}:</view>
|
||||
<view class="u-m-t-16">
|
||||
<up-input v-model="item.value">
|
||||
<up-input type="number" v-model="item.value">
|
||||
<template #suffix>
|
||||
<up-button @click="itemClick(item)" type="primary" text="修改" size="mini"></up-button>
|
||||
</template>
|
||||
@@ -116,7 +116,7 @@
|
||||
}
|
||||
})
|
||||
const isSku = computed(() => {
|
||||
// return data.value.typeEnum == '多规格'
|
||||
// return data.value.type == 'sku'
|
||||
return false
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
|
||||
179
pageProduct/add-specifications/edit-specifications.vue
Normal file
179
pageProduct/add-specifications/edit-specifications.vue
Normal file
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<view class="page min-page">
|
||||
<view class="box">
|
||||
<view class="block border-top-0 u-p-t-32 u-p-b-32">
|
||||
<up-form ref="formRef" labelPosition="top" :model="vdata.formData" :rules="vdata.rules" labelWidth="80" :labelStyle="{fontWeight:'bold'}">
|
||||
<up-form-item label="规格名称" prop="name" borderBottom >
|
||||
<up-input v-model="vdata.formData.name" border="none" placeholder="规格名称,如:衣服" ></up-input>
|
||||
</up-form-item>
|
||||
<up-form-item label="排序" prop="sort" borderBottom >
|
||||
<up-input v-model="vdata.formData.sort" border="none" placeholder="请输入排序" ></up-input>
|
||||
</up-form-item>
|
||||
</up-form>
|
||||
</view>
|
||||
<view class="save-btn-box">
|
||||
<button class="save-btn " hover-class="btn-hover-class" @click="save">保存</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import { updateSpec } from '@/api/product.js'
|
||||
|
||||
const option = {
|
||||
type: 'add',
|
||||
id: undefined
|
||||
}
|
||||
const formRef = ref(null)
|
||||
const vdata = reactive({
|
||||
formData: {
|
||||
id: null,
|
||||
name: "",
|
||||
level: "",
|
||||
sort: "",
|
||||
pid: "",
|
||||
},
|
||||
rules: {
|
||||
"name": {
|
||||
required: true,
|
||||
message: '请输入规格名称',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
"sort": {
|
||||
required: true,
|
||||
message: '请输入排序',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
onLoad(opt => {
|
||||
if (opt && JSON.stringify(opt) !== '{}' && opt.type) {
|
||||
const data = uni.getStorageSync('spec')
|
||||
uni.removeStorageSync('spec')
|
||||
if(data){
|
||||
vdata.formData.id = data.id
|
||||
vdata.formData.name = data.name
|
||||
vdata.formData.sort = data.sort
|
||||
vdata.formData.level = data.level
|
||||
vdata.formData.pid = data.pid
|
||||
}
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑规格模版'
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
async function save() {
|
||||
updateSpec(vdata.formData).then(res => {
|
||||
infoBox.showToast('修改成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.page {
|
||||
background: #F9F9F9;
|
||||
padding: 32rpx 30rpx 0 30rpx;
|
||||
padding-bottom: 200rpx;
|
||||
}
|
||||
::v-deep .uni-forms-item--border {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
::v-deep .uni-forms-item.is-direction-top .uni-forms-item__label{
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
::v-deep .uni-easyinput__content-input{
|
||||
height: inherit;
|
||||
}
|
||||
::v-deep.uni-forms-item {
|
||||
min-height: inherit;
|
||||
}
|
||||
::v-deep .uni-forms-item__error {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
::v-deep .option .uni-forms-item {
|
||||
padding: 0;
|
||||
min-height: inherit;
|
||||
background-color: transparent;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
|
||||
.box {
|
||||
font-size: 28rpx;
|
||||
.block {
|
||||
background: #FFFFFF;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
padding: 0 24rpx;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.save-btn-box {
|
||||
position: fixed;
|
||||
left: 30rpx;
|
||||
right: 30rpx;
|
||||
bottom: 60rpx;
|
||||
|
||||
}
|
||||
|
||||
::v-deep.uni-forms-item {
|
||||
align-items: inherit;
|
||||
}
|
||||
|
||||
::v-deep .uni-forms-item .uni-forms-item__label {
|
||||
text-indent: 0;
|
||||
font-size: 28rpx !important;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
::v-deep .border-top-0 .uni-forms-item.is-direction-top {
|
||||
border-color: transparent !important;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
background-color: $my-main-color;
|
||||
color: #fff;
|
||||
border-radius: 12rpx;
|
||||
font-size: 28rpx;
|
||||
border-radius: 100rpx;
|
||||
}
|
||||
|
||||
.btn-hover-class {
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
::v-deep .uni-input-placeholder {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.option {
|
||||
padding: 8rpx 24rpx 32rpx 24rpx;
|
||||
background: #F9F9F9;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -10,9 +10,9 @@
|
||||
<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-16" v-if="data.type == 'sku'">{{data.name}}</view>
|
||||
<view class="u-m-t-38">
|
||||
<template v-if="!isSku">
|
||||
<template v-if="data.type != 'sku'">
|
||||
<view class="u-m-b-32">
|
||||
<view class="u-flex u-row-between">
|
||||
<view>{{data.name}}</view>
|
||||
@@ -84,41 +84,11 @@
|
||||
</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)
|
||||
|
||||
|
||||
import { computed, reactive, ref, watch, onMounted } from 'vue';
|
||||
import { returnSkuSnap, returnTypeEnum, returnCategory } from '@/pageProduct/util.js'
|
||||
import { formatPrice } from "@/commons/utils/format.js";
|
||||
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const props = defineProps({
|
||||
show: {
|
||||
type: Boolean,
|
||||
@@ -135,10 +105,11 @@
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
let popShow = ref(props.show)
|
||||
let data = ref({
|
||||
lowPrice: 0,
|
||||
skuList: []
|
||||
@@ -159,37 +130,57 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
const emits = defineEmits(['update:show', 'save'])
|
||||
const refForm = ref(null)
|
||||
onMounted(()=>{
|
||||
// #ifndef H5
|
||||
refForm.value.setRules(rules)
|
||||
// #endif
|
||||
})
|
||||
watch(() => popShow.value, (newval) => {
|
||||
emits('update:show', newval)
|
||||
})
|
||||
|
||||
/**
|
||||
* 金额处理
|
||||
* @param {Object} item
|
||||
* @param {Object} key
|
||||
* @param {Object} val
|
||||
*/
|
||||
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 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) {
|
||||
console.log(data)
|
||||
emits('save', {
|
||||
...data.value,
|
||||
})
|
||||
@@ -200,37 +191,16 @@
|
||||
// 处理验证错误
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function close() {
|
||||
popShow.value = false
|
||||
}
|
||||
|
||||
function open() {
|
||||
|
||||
}
|
||||
|
||||
// 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>
|
||||
|
||||
@@ -32,15 +32,11 @@
|
||||
<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.type=='single'">¥</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">
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
<view class="u-flex">
|
||||
<view class="u-p-l-16 item u-p-r-16 u-p-t-6 u-p-b-6 tranistion u-text-center color-333"
|
||||
:class="{'active':pageData.stateCurrent==index}" @tap="statesTableClick(index)"
|
||||
v-for="(item,index) in statesTabsList" :key="index">
|
||||
{{item}}
|
||||
v-for="(item,index) in pageData.statesTabsList" :key="index">
|
||||
{{item.laber}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-col-center" @click="go.to('PAGES_PRODUCT_SPECIF_TEMPLATE')">
|
||||
@@ -83,31 +83,6 @@
|
||||
<my-switch v-model="goodsStockData.isStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-flex u-m-t-32">
|
||||
<view class="">共享库存:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isDistribute"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">售罄:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isSoldStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">上架:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isSale"></my-switch>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- <view class="u-m-t-24 u-m-t-32" v-if="goodsStockData.isStock">
|
||||
<view class="">数量:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="goodsStockData.stockNumber" placeholder="请输入库存数量"></uni-easyinput>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
</template>
|
||||
@@ -138,22 +113,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onPageScroll,
|
||||
onPullDownRefresh
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js';
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js';
|
||||
import myGoods from './components/goods.vue'
|
||||
import myControl from './components/control.vue'
|
||||
import myCategory from './components/category.vue'
|
||||
@@ -163,8 +126,6 @@
|
||||
import editStock from './components/edit-stock.vue';
|
||||
import baosunVue from './components/baosun.vue';
|
||||
import {
|
||||
$tbProduct,
|
||||
$upProSort,
|
||||
$updateProduct,
|
||||
$getProductDetail,
|
||||
$delProduct,
|
||||
@@ -175,7 +136,8 @@
|
||||
} from "@/http/yskApi/goods.js"
|
||||
import {
|
||||
getProductList,
|
||||
getCategoryList
|
||||
getCategoryList,
|
||||
updateProduct
|
||||
} from '@/api/product.js'
|
||||
|
||||
import {
|
||||
@@ -190,6 +152,12 @@
|
||||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
statesTabsList: [
|
||||
{ laber: '全部', value: ''},
|
||||
{ laber: '已售罄', value: 'sold_out'},
|
||||
{ laber: '在售中', value: 'on_sale'},
|
||||
{ laber: '已下架', value: 'off_sale'},
|
||||
],
|
||||
showGoodsDetail: false,
|
||||
selGoodsIndex: '',
|
||||
selGoods: {},
|
||||
@@ -202,8 +170,7 @@
|
||||
categoryId: '',
|
||||
name: '',
|
||||
orderBy: "create_time desc",
|
||||
isSoldStock: '',
|
||||
isSale: ''
|
||||
status: '',
|
||||
},
|
||||
category: '',
|
||||
categoryList: [], //分类列表
|
||||
@@ -211,6 +178,11 @@
|
||||
categoryName: '',
|
||||
hasAjax: false
|
||||
})
|
||||
const tabsList = ['简洁', '详情']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
watch(() => pageData.query.categoryId, (newval) => {
|
||||
getGoodsList()
|
||||
})
|
||||
@@ -292,16 +264,19 @@
|
||||
*/
|
||||
function changePriceShow(index) {
|
||||
pageData.selGoodsIndex = index
|
||||
const goods = pageData.goodsList[index]
|
||||
let goods = pageData.goodsList[index]
|
||||
console.log(goods)
|
||||
if(goods.type != 'sku') {
|
||||
goods.lowPrice = goods.skuList[0].salePrice
|
||||
}
|
||||
goods.skuList = goods.skuList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
_lowPrice: v.lowPrice
|
||||
_lowPrice: v.salePrice
|
||||
}
|
||||
})
|
||||
console.log(goods)
|
||||
const lowPrice = goods.lowPrice.toString().replace('¥', '') * 1
|
||||
let lowPrice = goods.lowPrice.toString().replace('¥', '') * 1
|
||||
pageData.selGoods = {
|
||||
...goods,
|
||||
lowPrice,
|
||||
@@ -310,20 +285,14 @@
|
||||
popup.price.show = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改价格确认
|
||||
* @param {Object} goods
|
||||
*/
|
||||
async function changePriceConfirm(goods) {
|
||||
|
||||
let goodsArr = []
|
||||
if (goods.typeEnum == '单规格') {
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
id: goods.id,
|
||||
key: 'salePrice',
|
||||
value: goods.lowPrice
|
||||
}]
|
||||
} else {
|
||||
if (goods.type == 'sku') {
|
||||
goodsArr = goods.skuList.map(v => {
|
||||
return {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
@@ -333,8 +302,17 @@
|
||||
value: v.lowPrice
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
id: goods.id,
|
||||
key: 'salePrice',
|
||||
value: goods.lowPrice
|
||||
}]
|
||||
}
|
||||
const res = await $updateProductData(goodsArr)
|
||||
const res = await updateProduct(goodsArr)
|
||||
infoBox.showToast('修改成功')
|
||||
popup.price.show = false
|
||||
getGoodsList()
|
||||
@@ -365,25 +343,7 @@
|
||||
}
|
||||
async function changeStockConfirm(goods) {
|
||||
let goodsArr = []
|
||||
// if (goods.typeEnum == '单规格') {
|
||||
// goodsArr = [{
|
||||
// shopId: uni.getStorageSync('shopId'),
|
||||
// isSku: false,
|
||||
// id: goods.id,
|
||||
// key: 'stockNumber',
|
||||
// value: goods.stockNumber
|
||||
// }]
|
||||
// } else {
|
||||
// goodsArr = goods.skuList.map(v => {
|
||||
// return {
|
||||
// shopId: uni.getStorageSync('shopId'),
|
||||
// isSku: true,
|
||||
// id: v.id,
|
||||
// key: 'stockNumber',
|
||||
// value: v.stockNumber
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
@@ -454,12 +414,7 @@
|
||||
}
|
||||
|
||||
|
||||
const tabsList = ['简洁', '详情']
|
||||
const statesTabsList = ['全部', '已售罄', '在售中', '已下架']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
|
||||
// 商品报损
|
||||
function reportDamageClick(index) {
|
||||
pageData.reportData = pageData.goodsList[index]
|
||||
@@ -537,6 +492,7 @@
|
||||
function resetQuery() {
|
||||
pageData.totalElements = 0;
|
||||
pageData.query.page = 1;
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
async function toGoodsDetail(id) {
|
||||
@@ -549,31 +505,15 @@
|
||||
productId: id
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品类型切换
|
||||
* @param {Object} index
|
||||
*/
|
||||
function statesTableClick(index) {
|
||||
pageData.stateCurrent = index;
|
||||
pageData.query.status = pageData.statesTabsList[index].value
|
||||
resetQuery()
|
||||
console.log(index);
|
||||
if (index == 0) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = ''
|
||||
return
|
||||
}
|
||||
if (index == 1) {
|
||||
pageData.query.isSoldStock = 1
|
||||
pageData.query.isSale = ''
|
||||
return
|
||||
}
|
||||
if (index == 2) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = 1
|
||||
return
|
||||
}
|
||||
if (index == 3) {
|
||||
pageData.query.isSoldStock = ''
|
||||
pageData.query.isSale = 0
|
||||
return
|
||||
}
|
||||
}
|
||||
let test = ref(false)
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import { reactive, ref } from 'vue';
|
||||
}
|
||||
function edit(){
|
||||
uni.setStorageSync('spec',props.data)
|
||||
go.to('PAGES_PRODUCT_GUIGE_ADD', {
|
||||
go.to('PAGES_PRODUCT_GUIGE_EDIT', {
|
||||
type: 'edit'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
$types
|
||||
} from '@/commons/goodsData.js'
|
||||
import { $types } from '@/commons/goodsData.js'
|
||||
export function returnSkuSnap(goods) {
|
||||
const selectSpec = typeof goods.selectSpec === 'string' ? JSON.parse(goods.selectSpec) : goods.selectSpec
|
||||
let result = selectSpec.map(v => {
|
||||
@@ -11,8 +9,8 @@ export function returnSkuSnap(goods) {
|
||||
})
|
||||
return result
|
||||
}
|
||||
export function returnTypeEnum(typeEnum) {
|
||||
const item = $types.find(v => v.title == typeEnum)
|
||||
export function returnTypeEnum(type) {
|
||||
const item = $types.find(v => v.title == type)
|
||||
let result = item ? item.value : undefined
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user