feat: 同步规格优化

This commit is contained in:
GaoHao 2025-04-11 15:50:15 +08:00
parent 8fd3565bac
commit 331f438f99
8 changed files with 95 additions and 39 deletions

View File

@ -71,6 +71,7 @@ import contentConfig from "./config/content";
import editModalConfig from "./config/edit";
import searchConfig from "./config/search";
import { returnOptionsLabel } from "./config/config";
import { isSyncStatus } from "@/utils/index";
const {
searchRef,
@ -87,6 +88,14 @@ const {
handleFilterChange,
} = usePage();
if (isSyncStatus()) {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){
contentConfig.toolbar?.splice(0, 1)
}
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("edit") != -1){
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(0, 1)
}
}
//
async function handleAddClick() {
addModalRef.value?.setModalVisible();

View File

@ -29,6 +29,13 @@ const contentConfig: IContentConfig = {
pk: "id",
toolbar: [
"add",
{
icon: "refresh",
text: "同步",
type: "danger",
name: "sync",
auth: "import",
},
{
text: "入库",
name: "ruku",

View File

@ -64,7 +64,7 @@
justify-content: center;
align-items: center;
">
<el-button type="primary" link @click="refAddHaocaiOpen(scope.row)">编辑</el-button>
<el-button type="primary" link @click="refAddHaocaiOpen(scope.row)" v-if="!isSyncStatus()">编辑</el-button>
<el-button link type="primary" @click="refAddHaocaiTakinShow(scope.row, 'consumables')">
耗材盘点
</el-button>
@ -89,12 +89,16 @@ import addHaocai from "./components/add-haocai.vue";
import dataTongji from "./components/DataStatistics.vue";
import addConsTakin from "./components/addConsTakin.vue";
import consApi from "@/api/product/cons";
import UserAPI from "@/api/product/index";
import type { IObject, IOperatData } from "@/components/CURD/types";
import usePage from "@/components/CURD/usePage";
import contentConfig from "./config/content";
import editModalConfig from "./config/edit";
import searchConfig from "./config/search";
import { returnOptionsLabel } from "./config/config";
import { isSyncStatus } from "@/utils/index";
const router = useRouter();
const {
searchRef,
@ -121,7 +125,20 @@ if (conName) {
searchConfig.formItems[1].initialValue = conName;
}
}
console.log(isSyncStatus())
console.log(contentConfig)
if (isSyncStatus()) {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){
contentConfig.toolbar?.splice(0, 1)
}
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("delete") != -1){
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(2, 1)
}
}else {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("sync") != -1){
contentConfig.toolbar?.splice(1, 1)
}
}
//
const gongjiData = reactive({ totalRow: 0 });
function getTongji(params: IObject | undefined) {
@ -189,8 +206,13 @@ async function handleEditClick(row: IObject) {
editModalRef.value?.setFormData({ ...row, url: [row.url] });
}
//
function handleToolbarClick(name: string) {
async function handleToolbarClick(name: string) {
console.log(name);
if( name === 'sync' ){
let res = await UserAPI.sync()
ElMessage.success('操作成功,数据正在后台同步中...')
return;
}
if (name === "category") {
router.push({ path: "/inventory/classification" });
return;

View File

@ -71,6 +71,7 @@ import contentConfig from "./config/content";
import editModalConfig from "./config/edit";
import searchConfig from "./config/search";
import { returnOptionsLabel } from "./config/config";
import { isSyncStatus } from "@/utils/index";
const {
searchRef,
@ -86,7 +87,14 @@ const {
handleSearchClick,
handleFilterChange,
} = usePage();
if (isSyncStatus()) {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){
contentConfig.toolbar?.splice(0, 1)
}
if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("edit") != -1){
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(0, 1)
}
}
//
async function handleAddClick() {
addModalRef.value?.setModalVisible();

View File

@ -208,7 +208,7 @@ if (isSyncStatus()) {
contentConfig.cols[contentConfig.cols.length-1].operat?.splice(2, 1)
}
}else {
if( JSON.stringify(contentConfig.toolbar)?.indexOf("custom2") != -1){
if( JSON.stringify(contentConfig.toolbar)?.indexOf("sync") != -1){
contentConfig.toolbar?.splice(1, 1)
}
}
@ -328,10 +328,9 @@ async function handleToolbarClick(name: string) {
// ElMessage.success("1");
myDialogRef.value.open();
}
if ( name === "custom2" ) { //
if ( name === "sync" ) { //
let res = await UserAPI.sync()
ElMessage.success('操作成功,数据正在后台同步中...')
console.log(res)
}
}
async function confirm() {

View File

@ -14,7 +14,7 @@
</template>
<template v-slot="scope">
<el-input-number size="default" v-model="scope.row.salePrice" @change="priceFormat(scope.row, 'salePrice')"
@blur="priceFormat(scope.row, 'salePrice')" controls-position="right"></el-input-number>
@blur="priceFormat(scope.row, 'salePrice')" controls-position="right" :disabled="isSyncStatus()"></el-input-number>
</template>
</el-table-column>
<el-table-column prop="originPrice">
@ -26,7 +26,7 @@
</template>
<template v-slot="scope">
<el-input-number @change="priceFormat(scope.row, 'originPrice')" v-model="scope.row.originPrice"
@blur="priceFormat(scope.row, 'originPrice')" controls-position="right"></el-input-number>
@blur="priceFormat(scope.row, 'originPrice')" controls-position="right" :disabled="isSyncStatus()"></el-input-number>
</template>
</el-table-column>
<el-table-column prop="costPrice">
@ -38,7 +38,7 @@
</template>
<template v-slot="scope">
<el-input-number @change="priceFormat(scope.row, 'costPrice')" v-model="scope.row.costPrice"
@blur="priceFormat(scope.row, 'costPrice')" controls-position="right"></el-input-number>
@blur="priceFormat(scope.row, 'costPrice')" controls-position="right" :disabled="isSyncStatus()"></el-input-number>
</template>
</el-table-column>
@ -51,7 +51,7 @@
</template>
<template v-slot="scope">
<el-input-number @change="priceFormat(scope.row, 'memberPrice')" v-model="scope.row.memberPrice"
@blur="priceFormat(scope.row, 'memberPrice')" controls-position="right"></el-input-number>
@blur="priceFormat(scope.row, 'memberPrice')" controls-position="right" :disabled="isSyncStatus()"></el-input-number>
</template>
</el-table-column>
<el-table-column label="起售数量" prop="suitNum">
@ -64,9 +64,9 @@
<template v-slot="scope">
<el-input-number @change="priceFormat(scope.row, 'suitNum')" v-model="scope.row.suitNum"
@blur="priceFormat(scope.row, 'suitNum')" :min="0" controls-position="right"
v-if="props.info.type == 'weigh'"></el-input-number>
v-if="props.info.type == 'weigh'" :disabled="isSyncStatus()"></el-input-number>
<el-input-number @change="priceFormat(scope.row, 'suitNum')" v-model="scope.row.suitNum"
@blur="priceFormat(scope.row, 'suitNum')" :min="1" controls-position="right" v-else></el-input-number>
@blur="priceFormat(scope.row, 'suitNum')" :min="1" controls-position="right" :disabled="isSyncStatus()" v-else></el-input-number>
</template>
</el-table-column>
</el-table>
@ -77,7 +77,7 @@
<el-form-item>
<el-input-number @change="priceFormat(batchNumberForm, 'batchNumber')"
@blur="priceFormat(batchNumberForm, 'batchNumber')" v-model="batchNumberForm.batchNumber"
controls-position="right" style="width: 100%"></el-input-number>
controls-position="right" style="width: 100%" :disabled="isSyncStatus()"></el-input-number>
</el-form-item>
</el-form>
<template #footer>
@ -93,6 +93,8 @@
</template>
<script setup>
import { ref } from 'vue'
import { isSyncStatus } from "@/utils/index";
const ruleFormRef = ref(null)
let batchNumberKey = ref(null)
let batchNumberForm = reactive({
@ -193,4 +195,4 @@ const formatPrice = (price, min = -Infinity, max = 100000000, returnIsArea = fal
return newval
}
defineExpose({ getdata })
</script>
</script>

View File

@ -4,21 +4,21 @@
<el-form-item label="商品名称" required>
<el-col :span="12">
<el-form-item prop="name">
<el-input v-model="ruleForm.name" placeholder="请输入商品名称" />
<el-input v-model="ruleForm.name" placeholder="请输入商品名称" :disabled="isSyncStatus()"/>
</el-form-item>
</el-col>
</el-form-item>
<el-form-item label="商品介绍">
<el-col :span="12">
<el-form-item>
<el-input v-model="ruleForm.shortTitle" type="textarea" placeholder="请输入商品介绍" />
<el-input v-model="ruleForm.shortTitle" type="textarea" placeholder="请输入商品介绍" :disabled="isSyncStatus()"/>
</el-form-item>
</el-col>
</el-form-item>
<el-form-item label="单位" required>
<el-col :span="12">
<el-form-item prop="unitId">
<el-select v-model="ruleForm.unitId" placeholder="请选择单位">
<el-select v-model="ruleForm.unitId" placeholder="请选择单位" :disabled="isSyncStatus()">
<el-option :label="item.name" :value="item.id" v-for="item in datas.Company" :key="item.id" />
</el-select>
</el-form-item>
@ -27,7 +27,7 @@
<el-form-item label="商品分类" required>
<el-col :span="12">
<el-form-item prop="region">
<el-select v-model="ruleForm.categoryId" placeholder="请选择商品分类">
<el-select v-model="ruleForm.categoryId" placeholder="请选择商品分类" :disabled="isSyncStatus()">
<el-option :label="item.name" :value="item.id" v-for="item in datas.classification" :key="item.id" />
</el-select>
</el-form-item>
@ -54,7 +54,7 @@
<AddImg ref="addImg" @successEvent="successEvent"></AddImg>
<el-form-item label="商品类型">
<el-radio-group v-model="ruleForm.type" @change="changeTypeEnum(ruleForm.type)">
<el-radio-group v-model="ruleForm.type" @change="changeTypeEnum(ruleForm.type)" :disabled="isSyncStatus()">
<el-radio value="single">单规格商品</el-radio>
<el-radio value="sku">多规格商品</el-radio>
<el-radio value="package">套餐商品</el-radio>
@ -65,7 +65,7 @@
<el-form-item label="套餐商品" v-if="ruleForm.type == 'package'">
<div style="display: block;width: 100%;">
<div class="head-container">
<el-radio-group v-model="ruleForm.groupType" @change="typeChange">
<el-radio-group v-model="ruleForm.groupType" @change="typeChange" :disabled="isSyncStatus()">
<el-radio-button label="0">固定套餐</el-radio-button>
<el-radio-button label="1">可选套餐</el-radio-button>
</el-radio-group>
@ -82,13 +82,13 @@
</el-table-column>
<el-table-column width="150">
<template #header>
<el-button type="primary" @click="addgoods(-1)">添加商品</el-button>
<el-button type="primary" @click="addgoods(-1)" :disabled="isSyncStatus()">添加商品</el-button>
</template>
<template v-slot="scope">
<el-button type="text" :disabled="scope.row.type != 'sku'"
<el-button type="text" :disabled="scope.row.type != 'sku'&&isSyncStatus()"
@click="showSelectSkuHandle(scope.row, scope.$index, index)">设置规格</el-button>
<el-button type="text"
@click="ruleForm.proGroupVo[index].goods.splice(scope.$index, 1)">删除</el-button>
@click="ruleForm.proGroupVo[index].goods.splice(scope.$index, 1)" >删除</el-button>
</template>
</el-table-column>
</el-table>
@ -97,13 +97,13 @@
<div class="group_wrap" v-for="(item, index) in ruleForm.proGroupVo" :key="index">
<el-form inline :model="item">
<el-form-item label="规格组名">
<el-input v-model="item.title" />
<el-input v-model="item.title" :disabled="isSyncStatus()"/>
</el-form-item>
<el-form-item :label="`本组菜品${item.goods.length}选`">
<el-input v-model="item.number" />
<el-input v-model="item.number" :disabled="isSyncStatus()"/>
</el-form-item>
<el-form-item>
<el-button @click="ruleForm.proGroupVo.splice(index, 1)">删除</el-button>
<el-button @click="ruleForm.proGroupVo.splice(index, 1)" :disabled="isSyncStatus()">删除</el-button>
</el-form-item>
</el-form>
<div style="margin-top: 20px;">
@ -113,29 +113,29 @@
<el-table-column label="价格" prop="price"></el-table-column>
<el-table-column label="数量" prop="number">
<template v-slot="scope">
<el-input-number v-model="scope.row.number" :min="0" />
<el-input-number v-model="scope.row.number" :min="0" :disabled="isSyncStatus()"/>
</template>
</el-table-column>
<el-table-column width="150">
<template #header>
<el-button type="primary" @click="addgoods(index);">添加商品</el-button>
<el-button type="primary" @click="addgoods(index);" :disabled="isSyncStatus()">添加商品</el-button>
</template>
<template v-slot="scope">
<el-button type="text" :disabled="scope.row.type != 'sku'"
<el-button type="text" :disabled="scope.row.type != 'sku'&&isSyncStatus()"
@click="showSelectSkuHandle(scope.row, scope.$index, index)">设置规格</el-button>
<el-button type="text"
@click="ruleForm.proGroupVo[index].goods.splice(scope.$index, 1)">删除</el-button>
@click="ruleForm.proGroupVo[index].goods.splice(scope.$index, 1)" :disabled="isSyncStatus()">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<el-button type="primary" @click="addtaocan">添加套餐组</el-button>
<el-button type="primary" @click="addtaocan" :disabled="isSyncStatus()">添加套餐组</el-button>
</div>
</div>
</el-form-item>
<el-form-item label="选择规格" v-if="ruleForm.type == 'sku'">
<el-select v-model="ruleForm.specId" placeholder="请选择规格" style="width: 500px" @change="selectSpecHandle">
<el-select v-model="ruleForm.specId" placeholder="请选择规格" style="width: 500px" @change="selectSpecHandle" :disabled="isSyncStatus()">
<el-option :label="item.name" :value="item.id" v-for="item in datas.specificationsconfig"
:key="item.id"></el-option>
</el-select>
@ -157,7 +157,7 @@
<el-form-item label="重量">
<el-col :span="12">
<div style="display: block;">
<el-input v-model="ruleForm.weight" placeholder="">
<el-input v-model="ruleForm.weight" placeholder="" :disabled="isSyncStatus()">
<template #append>千克</template>
</el-input>
<!-- <div style="color: #999;">用于快递或配送运费计重</div> -->
@ -165,7 +165,7 @@
</el-col>
</el-form-item>
<el-form-item label="是否允许临时改价">
<el-radio-group v-model="ruleForm.isAllowTempModifyPrice">
<el-radio-group v-model="ruleForm.isAllowTempModifyPrice" :disabled="isSyncStatus()">
<el-radio :value="1">允许</el-radio>
<el-radio :value="0">不允许</el-radio>
</el-radio-group>
@ -198,7 +198,7 @@
</el-form-item>
<el-form-item label="库存开关">
<div style="display: block;">
<el-switch v-model="ruleForm.isStock" :active-value="1" :inactive-value="0" />
<el-switch v-model="ruleForm.isStock" :active-value="1" :inactive-value="0" :disabled="isSyncStatus()"/>
<div style="color: #999;">关闭则不计算出入库数据</div>
</div>
</el-form-item>
@ -211,7 +211,7 @@
<el-form-item label="打包费" prop="delivery">
<div style="display: block;">
<el-input-number v-model="ruleForm.packFee" controls-position="right"></el-input-number>
<el-input-number v-model="ruleForm.packFee" controls-position="right" :disabled="isSyncStatus()"></el-input-number>
<div style="color: #999;">单份商品打包费店铺开启外卖模式下该数据才生效</div>
</div>
</el-form-item>
@ -251,6 +251,7 @@ import { reactive, ref } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
//
import SpecificationAttribute from './SpecificationAttribute.vue'
import { isSyncStatus } from "@/utils/index";
import UserAPI from "@/api/product/productclassification";
import UserAPI2 from "@/api/product/commonUnits";
import UserAPI3 from "@/api/product/index";
@ -492,6 +493,10 @@ function selectSkuHandle(item: any, index: number) {
// }
}
function addimgEvent() {
if( isSyncStatus() ){
ElMessage.error('当前同步启用状态下不可修改')
return
}
(addImg.value as any)?.show()
}
//
@ -521,6 +526,10 @@ function addgoods(index: number = -1) {
(shopListRef.value as any)?.opens()
}
function deleteEvent(d: any) {
if( isSyncStatus() ){
ElMessage.error('当前同步启用状态下不可修改')
return
}
let index = ruleForm.images.findIndex((ele) => ele == d);
ruleForm.images.splice(index, 1);
}
@ -915,4 +924,4 @@ const resetForm = (formEl: FormInstance | undefined) => {
top: -10px;
z-index: 10;
}
</style>
</style>

View File

@ -63,7 +63,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
icon: "refresh",
text: "同步",
type: "danger",
name: "custom2",
name: "sync",
auth: "import",
},
{