更换正式环境,测试修改
This commit is contained in:
@@ -43,9 +43,9 @@
|
||||
<template v-if="pageData.goodsList.length">
|
||||
<view class="u-m-b-32" v-for="(item,index) in pageData.goodsList" :key="index">
|
||||
<my-goods :key="item.id" @update="getGoodsList" @changePrice="changePriceShow"
|
||||
@changeClick="goodsChangeClick" @edit="toGoodsDetail" @editStock="changeStockShow"
|
||||
@guigeClick="editGuigeShow" @baosun="baosunShow" @radioClick="goodsRadioClick" :index="index"
|
||||
:data="item" @del="goodsDel" :showChecked="showChecked"
|
||||
@edit="toGoodsDetail" @editStock="changeStockShow"
|
||||
@guigeClick="editGuigeShow" @baosun="baosunShow" :index="index"
|
||||
:data="item"
|
||||
:showDetail="pageData.showGoodsDetail"></my-goods>
|
||||
</view>
|
||||
</template>
|
||||
@@ -61,39 +61,11 @@
|
||||
</view>
|
||||
|
||||
<my-control ref="control" :categoryShow="pageData.categoryShow" :categoryName="pageData.categoryName"
|
||||
@offShelf="offShelf" @allCheckedChange="allCheckedChange" @controlChange="controlChange"
|
||||
@toggleCategory="toggleCategory" :bottom="pageData.componentBottom"></my-control>
|
||||
<!-- <my-category ref="category" @change="onCategoryShowChange" @cateClick="cateClick"
|
||||
:bottom="pageData.componentBottom+100"></my-category> -->
|
||||
:bottom="pageData.componentBottom"></my-control>
|
||||
|
||||
|
||||
<!-- 下架弹窗 -->
|
||||
<my-model :desc="pageData.modelDesc" ref="model" @confirm="modelConfirm"></my-model>
|
||||
<!-- 商品库存修改弹窗 -->
|
||||
<my-model ref="goodsStockModel" title="商品修改" @close="goodsStockModelClose">
|
||||
<template #desc>
|
||||
<view class="u-p-40 u-text-left">
|
||||
<view>
|
||||
<view class="">排序:</view>
|
||||
<view class="u-m-t-24">
|
||||
<uni-easyinput v-model="goodsStockData.orderBy" placeholder="请输入排序"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32">
|
||||
<view class="">库存开关:</view>
|
||||
<view class="u-m-l-46 ">
|
||||
<my-switch v-model="goodsStockData.isStock"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="stock-btns u-p-b-40">
|
||||
<my-button shape="circle" @tap="goodsStockModelSave">保存</my-button>
|
||||
<my-button shape="circle" type="default" @tap="goodsStockModelCancel">取消</my-button>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
|
||||
<!-- 分类 -->
|
||||
<my-category v-model:isShow="pageData.categoryShow" @confirm="setCategory"></my-category>
|
||||
<!-- 修改价格弹窗 -->
|
||||
@@ -107,7 +79,7 @@
|
||||
:goods="popup.guige.data"></edit-guige>
|
||||
<!-- 报损 -->
|
||||
<baosun-vue :category="pageData.categoryList" v-model:show="popup.baosun.show"
|
||||
:goods="pageData.selGoods"></baosun-vue>
|
||||
:goods="pageData.selGoods" @save="getGoodsList"></baosun-vue>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
@@ -115,34 +87,21 @@
|
||||
<script setup>
|
||||
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 myGoods from './components/goods.vue'
|
||||
import myControl from './components/control.vue'
|
||||
import myCategory from './components/category.vue'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import editPrice from './components/edit-price.vue';
|
||||
import editGuige from './components/edit-guige.vue';
|
||||
import editStock from './components/edit-stock.vue';
|
||||
import baosunVue from './components/baosun.vue';
|
||||
import {
|
||||
$updateProduct,
|
||||
$getProductDetail,
|
||||
$delProduct,
|
||||
$tbShopCategory,
|
||||
$updateProductStatus,
|
||||
$tbProductV2,
|
||||
$updateProductData
|
||||
} from "@/http/yskApi/goods.js"
|
||||
import {
|
||||
getProductPage,
|
||||
getCategoryList,
|
||||
updateProduct
|
||||
} from '@/http/api/product.js'
|
||||
|
||||
import { getProductPage, getCategoryList, updateProduct, productModifyStock } from '@/http/api/product.js'
|
||||
|
||||
import {
|
||||
returnAllCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import { returnAllCategory } from '@/pageProduct/util.js'
|
||||
|
||||
const pageData = reactive({
|
||||
modelDesc: '是否下架',
|
||||
@@ -181,8 +140,6 @@
|
||||
const tabsList = ['简洁', '详情']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const goodsStockModel = ref(null)
|
||||
let reportDamage = ref(null) //报损组件
|
||||
watch(() => pageData.query.categoryId, (newval) => {
|
||||
getGoodsList()
|
||||
})
|
||||
@@ -250,7 +207,10 @@
|
||||
})
|
||||
}
|
||||
|
||||
//报损弹窗展示
|
||||
/**
|
||||
* 报损弹窗展示
|
||||
* @param {Object} index
|
||||
*/
|
||||
function baosunShow(index) {
|
||||
pageData.selGoodsIndex = index
|
||||
const goods = pageData.goodsList[index]
|
||||
@@ -290,7 +250,6 @@
|
||||
* @param {Object} goods
|
||||
*/
|
||||
async function changePriceConfirm(goods) {
|
||||
|
||||
let goodsArr = []
|
||||
if (goods.type == 'sku') {
|
||||
goodsArr = goods.skuList.map(v => {
|
||||
@@ -313,13 +272,15 @@
|
||||
}]
|
||||
}
|
||||
const res = await updateProduct(goodsArr)
|
||||
infoBox.showToast('修改成功')
|
||||
uni.$utils.showToast('修改成功')
|
||||
popup.price.show = false
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
|
||||
// 修改库存弹窗展示
|
||||
/**
|
||||
* 修改库存弹窗展示
|
||||
* @param {Object} index
|
||||
*/
|
||||
async function changeStockShow(index) {
|
||||
const res = await hasPermission('允许修改商品库存')
|
||||
if (!res) {
|
||||
@@ -341,26 +302,29 @@
|
||||
}
|
||||
popup.stock.show = true
|
||||
}
|
||||
async function changeStockConfirm(goods) {
|
||||
let goodsArr = []
|
||||
|
||||
goodsArr = [{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
isSku: false,
|
||||
/**
|
||||
* 库存修改确认
|
||||
* @param {Object} goods
|
||||
*/
|
||||
async function changeStockConfirm(goods) {
|
||||
const res = await productModifyStock({
|
||||
id: goods.id,
|
||||
key: 'stockNumber',
|
||||
value: goods.stockNumber
|
||||
}]
|
||||
const res = await $updateProductData(goodsArr)
|
||||
infoBox.showToast('修改成功')
|
||||
stockNumber: goods.stockNumber,
|
||||
remark: goods.remark
|
||||
})
|
||||
uni.$utils.showToast('修改成功')
|
||||
popup.stock.show = false
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
//修改规格上下架,售罄
|
||||
/**
|
||||
* 修改规格上下架,售罄
|
||||
* @param {Object} goodsIndex
|
||||
* @param {Object} guigeIndex
|
||||
*/
|
||||
function editGuigeShow(goodsIndex, guigeIndex) {
|
||||
const goodsGuige = pageData.goodsList[goodsIndex].skuList[guigeIndex]
|
||||
console.log(goodsIndex, guigeIndex);
|
||||
popup.guige.data = goodsGuige
|
||||
popup.guige.goodsIndex = goodsIndex
|
||||
popup.guige.guigeIndex = guigeIndex
|
||||
@@ -373,7 +337,6 @@
|
||||
*/
|
||||
function isGroundingChange(e) {
|
||||
const { goodsIndex, guigeIndex } = popup.guige
|
||||
console.log(goodsIndex,guigeIndex)
|
||||
pageData.goodsList[goodsIndex].skuList[guigeIndex].isGrounding = e
|
||||
}
|
||||
|
||||
@@ -383,15 +346,21 @@
|
||||
*/
|
||||
function isPauseSaleChange(e) {
|
||||
const { goodsIndex, guigeIndex } = popup.guige
|
||||
console.log(goodsIndex,guigeIndex)
|
||||
pageData.goodsList[goodsIndex].skuList[guigeIndex].isPauseSale = e
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类筛选打开
|
||||
* @param {Object} show
|
||||
*/
|
||||
function onCategoryShowChange(show) {
|
||||
console.log(show);
|
||||
pageData.categoryShow = show
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类筛选确定
|
||||
* @param {Object} category
|
||||
*/
|
||||
function setCategory(category) {
|
||||
pageData.query.categoryId = category.id
|
||||
pageData.categoryName = category.name
|
||||
@@ -413,88 +382,10 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 商品报损
|
||||
function reportDamageClick(index) {
|
||||
pageData.reportData = pageData.goodsList[index]
|
||||
reportDamage.value.open();
|
||||
}
|
||||
|
||||
function returnGoodsStockData() {
|
||||
return reactive({
|
||||
sort: 0,
|
||||
isStock: false,
|
||||
isDistribute: false,
|
||||
isSoldStock: false,
|
||||
isGrounding: false,
|
||||
stockNumber: 0,
|
||||
})
|
||||
}
|
||||
let goodsStockData = returnGoodsStockData()
|
||||
|
||||
function goodsStockModelClose() {
|
||||
console.log('goodsStockModelClose');
|
||||
goodsStockData = returnGoodsStockData()
|
||||
}
|
||||
|
||||
function goodsStockModelCancel() {
|
||||
console.log('goodsStockModelCancel');
|
||||
goodsStockModel.value.close()
|
||||
goodsStockData = returnGoodsStockData()
|
||||
}
|
||||
|
||||
async function goodsStockModelSave() {
|
||||
const item = pageData.goodsList[pageData.selGoodsIndex]
|
||||
const goods = await $getProductDetail(item.id, false)
|
||||
$updateProduct({
|
||||
...goods,
|
||||
sort: goodsStockData.sort,
|
||||
isStock: goodsStockData.isStock
|
||||
}).then(res => {
|
||||
item.sort = goodsStockData.sort
|
||||
item.isStock = goodsStockData.isStock
|
||||
item.stockNumber = goodsStockData.stockNumber
|
||||
goodsStockModelCancel()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
//点击修改按钮弹出修改商品弹窗
|
||||
function goodsChangeClick(index) {
|
||||
pageData.selGoodsIndex = index
|
||||
const goods = pageData.goodsList[index]
|
||||
Object.assign(goodsStockData, goods)
|
||||
goodsStockModel.value.open()
|
||||
}
|
||||
|
||||
//删除商品
|
||||
function goodsDel(index) {
|
||||
const goods = pageData.goodsList[index]
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认删除该商品',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
$delProduct([goods.id]).then(res => {
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
pageData.goodsList.splice(index, 1)
|
||||
})
|
||||
} else if (res.cancel) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetQuery() {
|
||||
pageData.totalElements = 0;
|
||||
pageData.query.page = 1;
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品修改
|
||||
* @param {Object} id
|
||||
*/
|
||||
async function toGoodsDetail(id) {
|
||||
const res = await hasPermission('允许修改商品')
|
||||
if (!res) {
|
||||
@@ -513,109 +404,35 @@
|
||||
function statesTableClick(index) {
|
||||
pageData.stateCurrent = index;
|
||||
pageData.query.status = pageData.statesTabsList[index].value
|
||||
resetQuery()
|
||||
}
|
||||
let test = ref(false)
|
||||
|
||||
function tabsChange(i) {
|
||||
console.log(i);
|
||||
pageData.showGoodsDetail = i ? true : false
|
||||
|
||||
}
|
||||
|
||||
|
||||
//改变商品的选中状态
|
||||
function changeGoodsChecked(checked, index) {
|
||||
if (index !== undefined) {
|
||||
pageData.goodsList[index].checked = checked
|
||||
} else {
|
||||
pageData.goodsList.map(v => {
|
||||
v.checked = checked
|
||||
})
|
||||
}
|
||||
control.value.setisSelectAll(isAllChecked() ? true : false)
|
||||
}
|
||||
|
||||
|
||||
// 获取已经选中的商品
|
||||
function getChechkedGoodsList() {
|
||||
return pageData.goodsList.filter(v => v.checked)
|
||||
}
|
||||
//是否全部选中
|
||||
function isAllChecked() {
|
||||
return getChechkedGoodsList().length === pageData.goodsList.length
|
||||
}
|
||||
// 是否有商品选中
|
||||
function isHasChekdGoods() {
|
||||
return getChechkedGoodsList().length ? true : false
|
||||
searchFunc()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function searchFunc() {
|
||||
console.log('searchFunc');
|
||||
resetQuery()
|
||||
pageData.totalElements = 0;
|
||||
pageData.query.page = 1;
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
let showChecked = ref(false)
|
||||
|
||||
//商品start
|
||||
|
||||
function goodsRadioClick(index) {
|
||||
var checked = !pageData.goodsList[index].checked
|
||||
changeGoodsChecked(checked, index)
|
||||
}
|
||||
|
||||
|
||||
//下架
|
||||
function offShelf() {
|
||||
const hasCheckedArr = getChechkedGoodsList()
|
||||
const hasChecked = isHasChekdGoods()
|
||||
if (!hasChecked) {
|
||||
return infoBox.showToast('您还没有选中商品!')
|
||||
}
|
||||
model.value.open()
|
||||
}
|
||||
//下架确认
|
||||
/**
|
||||
* 下架确认
|
||||
*/
|
||||
function modelConfirm() {
|
||||
console.log('confirm');
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
//商品end
|
||||
|
||||
//控制条
|
||||
function controlChange(bol) {
|
||||
showChecked.value = bol
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 全选
|
||||
function allCheckedChange(checked) {
|
||||
changeGoodsChecked(checked)
|
||||
}
|
||||
|
||||
// 页数改变事件
|
||||
/**
|
||||
* 页数改变事件
|
||||
* @param {Object} page
|
||||
*/
|
||||
function pageChange(page) {
|
||||
console.log(page);
|
||||
pageData.query.page = page
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
//分类
|
||||
const category = ref(null)
|
||||
|
||||
function toggleCategory() {
|
||||
category.value.toggle()
|
||||
}
|
||||
|
||||
function cateClick(cate) {
|
||||
console.log(cate);
|
||||
pageData.query.categoryId = cate.id
|
||||
pageData.categoryName = cate.name
|
||||
pageData.category = cate
|
||||
getGoodsList()
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
|
||||
Reference in New Issue
Block a user