逻辑优化

This commit is contained in:
zzyuan 2025-07-31 09:02:26 +08:00
parent 937fdf799a
commit 8383351d8e
4 changed files with 143 additions and 212 deletions

View File

@ -51,19 +51,19 @@
<el-button
size="mini"
type="text"
v-if="scope.row.cardStatus==1"
:disabled="scope.row.cardStatus!=1"
@click="handleChangeCard(scope.row)"
>换卡</el-button>
<el-button
size="mini"
type="text"
v-if="scope.row.cardStatus==1"
:disabled="scope.row.cardStatus!=1"
@click="handleReturn(scope.row)"
>退卡</el-button>
<el-button
size="mini"
type="text"
v-if="scope.row.cardStatus==1"
:disabled="scope.row.cardStatus!=1"
@click="handleLoss(scope.row)"
>挂失</el-button>
<el-button

View File

@ -37,7 +37,7 @@
<span v-else></span>
</template>
</el-table-column>
<el-table-column label="图片地址" align="center" prop="imgUrl" :show-overflow-tooltip="true"/>
<!-- <el-table-column label="图片地址" align="center" prop="imgUrl" :show-overflow-tooltip="true"/> -->
<el-table-column label="用途类型" align="center" prop="usageType" :show-overflow-tooltip="true">
<template scope="scope">
<span v-if="scope.row.usageType==1">后台</span>
@ -110,13 +110,13 @@
</el-form-item>
</el-col>
</el-row>
<el-row>
<!-- <el-row>
<el-col :span="24">
<el-form-item label="图片地址">
<el-input v-model="form.imgUrl" placeholder="图片地址" disabled clearable/>
</el-form-item>
</el-col>
</el-row>
</el-row> -->
<el-row>
<el-col :span="24">
<el-form-item label="图片" prop="imgUrl">

View File

@ -238,11 +238,13 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 图片查看 -->
<el-dialog :visible.sync="dialogVisible" width="700px">
<img style="width: 100%;height: 100%;" :src="dialogImageUrl" alt="">
</el-dialog>
<el-dialog :title="titleProduct" :visible.sync="openProduct" width="1200px" append-to-body>
<div class="app-container" id="toolsType">
<div>
<el-row>
<el-form
:model="queryShopParams"
@ -258,7 +260,6 @@
placeholder="请输入商品名称"
clearable maxlength="30"
style="width: 240px"
@keyup.enter.native="handleShopQuery"
/>
</el-form-item>
<el-form-item label="上架状态" prop="putawayState">
@ -276,7 +277,6 @@
placeholder="请输入条码"
clearable maxlength="30"
style="width: 240px"
@keyup.enter.native="handleShopQuery"
/>
</el-form-item>
<el-form-item>
@ -310,51 +310,24 @@
</div>
<div class="head-container">
<el-tree
style="height: 700px; overflow: scroll"
style="height: 500px; overflow: scroll"
:data="treeShopOptions"
:props="defaultProps"
:show-checkbox="true"
:default-expand-all="true"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="typeTree"
node-key="materialTypeId"
ref="typeTree"
node-key="id"
highlight-current
@node-click="handleNodeClick"
@check-change="handleCheckChange"
>
<span class="custom-tree-node" slot-scope="{ node, data }" @mousemove="onMousemove(data)" @mouseleave="onMouseleave()">
<span v-if="isMousemoveId === data.id && node.label.length > 5">{{
<span class="custom-tree-node" slot-scope="{ node, data }">
<span v-if="node.label.length > 5">{{
node.label.slice(0, 5) + "..."
}}</span>
<span v-else>{{ node.label }}</span>
<span class="btn-items" v-if="isMousemoveId === data.id">
<el-button
type="text"
size="mini"
icon="el-icon-plus" v-if="data.level<1"
@click.stop="() => appendTreeNode(data)"
>
</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-edit-outline"
style="color: #67c23a"
v-if="data.id !== 0"
@click.stop="() => editTreeNode(data)"
>
</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
style="color: #f56c6c"
v-if="data.parentId != '0'"
@click.stop="() => removeTreeNode(data)"
>
</el-button>
</span>
<span v-else>{{ node.label }}</span>
</span>
</el-tree>
</div>
@ -458,106 +431,88 @@
</el-dialog>
<!-- 商品编辑对话框 -->
<el-dialog :title="titleProductEitd" :visible.sync="openProductEitd" width="980px" append-to-body>
<el-form ref="form" :model="productFrom" label-width="90px">
<el-row justify="center">
<table align="center" width="80%" cellspacing="0">
<tr >
<td colspan="4" class="table-title">商品</td>
</tr>
<tr >
<td class="table-label"><span >名称</span></td>
<td class="table-content">
<el-input
v-model="productFrom.materialName"
disabled
/>
</td>
<td class="table-label"><span >单位</span></td>
<td class="table-content">
<el-input
v-model="productFrom.unitName"
disabled
/>
</td>
</tr>
<tr >
<td class="table-label"><span >条码</span></td>
<td class="table-content">
<el-input
v-model="productFrom.barCode"
disabled
/>
</td>
<td class="table-label"><span >零售价</span></td>
<td class="table-content">
<el-input
<el-form ref="form" :model="productFrom" label-width="110px">
<el-row>
<el-col :span="12">
<el-form-item label="商品名称" prop="materialName">
<el-input v-model="productFrom.materialName" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="商品单位" prop="unitName">
<el-input v-model="productFrom.unitName" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="商品条码" prop="barCode">
<el-input v-model="productFrom.barCode" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="零售价" prop="salePrice">
<el-input
v-model="productFrom.salePrice"
placeholder="请输入"
@input="handleNumberInput"
/>
</td>
</tr>
<tr >
<td class="table-label"><span >会员价</span></td>
<td class="table-content">
<el-input
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="会员价" prop="prefPrice">
<el-input
v-model="productFrom.prefPrice"
placeholder="请输入"
@input="handleNumberInput"
/>
</td>
<td class="table-label"><span >个人限购数量</span></td>
<td class="table-content">
<el-input
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="个人限购数量" prop="personLimit">
<el-input
v-model="productFrom.personLimit"
placeholder="请输入"
@input="handleNumberInput"
/>
</td>
</tr>
<tr >
<td class="table-label"><span >每日限购数量</span></td>
<td class="table-content">
<el-input
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="每日限购数量" prop="oneDayLimit">
<el-input
v-model="productFrom.oneDayLimit"
placeholder="请输入"
@input="handleNumberInput"
/>
</td>
<td class="table-label"><span >库存</span></td>
<td class="table-content">
<el-input
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="库存" prop="inventoryNum">
<el-input
v-model="productFrom.inventoryNum"
placeholder="请输入"
@input="handleNumberInput"
@input="handleNumberInput"
/>
</td>
</tr>
<tr >
<td class="table-label"><span >上架状态</span></td>
<td class="table-content">
<template>
<span>{{ '下架' }}</span>
<el-switch
v-model="productFrom.putawayStatef"
@change="handlePutawayStateEitdChange(productFrom)">
</el-switch>
<span>{{'上架' }}</span>
</template>
</td>
<td class="table-label"><span >线上销售</span></td>
<td class="table-content">
<template >
<span>{{'否'}}</span>
<el-switch
v-model="productFrom.ifOnlinef"
@change="handleIfOnlineEitdChange(productFrom)">
</el-switch>
<span>{{'是' }}</span>
</template>
</td>
</tr>
</table>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="上架状态" prop="putawayState">
<el-switch
v-model="productFrom.putawayState"
active-value="1" active-text="上架"
inactive-value="2" inactive-text="下架">
</el-switch>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="线上销售" prop="ifOnline">
<el-switch
v-model="productFrom.ifOnline"
active-value="1" active-text="是"
inactive-value="2" inactive-text="否">
</el-switch>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
@ -567,7 +522,7 @@
</el-dialog>
<!-- 商品添加对话框 -->
<el-dialog :title="titleAddProduct" :visible.sync="openAddProduct" width="1200px" append-to-body>
<div class="app-container" id="toolsType">
<div>
<el-row>
<el-form
:model="queryAddShopParams"
@ -613,8 +568,7 @@
<template slot-scope="scope">
<span>{{'下架' }}</span>
<el-switch
v-model="scope.row.putawayState"
@change="handlePutawayStateChanges(scope.row)">
v-model="scope.row.putawayState">
</el-switch>
<span>{{ '上架' }}</span>
</template>
@ -623,8 +577,7 @@
<template slot-scope="scope">
<span>{{ '否'}}</span>
<el-switch
v-model="scope.row.ifOnline"
@change="handleIfOnlineChanges(scope.row)">
v-model="scope.row.ifOnline">
</el-switch>
<span>{{ '是' }}</span>
</template>
@ -724,7 +677,7 @@
isMousemoveId: null,
defaultProps: {
children: "children",
label: "materialTypeName",
label: "categoryName",
},
keyShopWord:"",//-
putawayStates:[{"putawayState":"1","putawayStateName":"上架"},{"putawayState":"2","putawayStateName":"下架"}],
@ -895,6 +848,12 @@
return this.checkUrlList.length > 0
},
},
watch: {
//
keyShopWord(val) {
this.$refs.typeTree.filter(val);
},
},
methods: {
handleNumberInput(value){
this.inputValue = value.replace(/[^\d.]/g, '');
@ -1110,13 +1069,14 @@
console.log(file)
this.dialogImageUrl = file.url
this.dialogVisible = true
},
},
//
getShopTreeData() {
shopMaterialTreeApi().then((response) => {
this.treeShopOptions = this.handleTree(response.rows,'materialTypeId');
let param = {
goodsType:2
}
shopMaterialTreeApi(param).then((response) => {
this.treeShopOptions = response.data
this.addLevel(this.treeShopOptions)
console.log("this.treeOptions",this.treeShopOptions)
if(this.treeShopOptions && this.treeShopOptions.length > 0){
@ -1129,34 +1089,8 @@
// -
filterNode(value, data) {
if (!value) return true;
return data.materialTypeName.indexOf(value) !== -1;
},
handleTree(data, idKey, parentIdKey = 'parentId', childrenKey = 'children') {
// MapidKey
const nodeMap = new Map();
//
const rootNodes = [];
// nodeMap
data.forEach(node => {
// nodeMapchildren
nodeMap.set(node[idKey], { ...node, [childrenKey]: [] });
// parentIdnullnodeMap
if (node[parentIdKey] === null || !nodeMap.has(node[parentIdKey])) {
// rootNodes
rootNodes.push(nodeMap.get(node[idKey]));
} else {
// children
//
const parentNode = nodeMap.get(node[parentIdKey]);
// children
parentNode[childrenKey].push(nodeMap.get(node[idKey]));
}
});
//
return rootNodes;
},
return data.categoryName.indexOf(value) !== -1;
},
addLevel(nodes, level = 0) {
nodes.forEach(node => {
node.level = level; //
@ -1214,9 +1148,6 @@
this.resetForm("queryShopForm");
this.handleShopQuery();
},
/** 商品列表 */
getShopList() {
this.loading = true;
@ -1226,7 +1157,8 @@
"putawayState": this.queryShopParams.putawayState,
"materialName":this.queryShopParams.materialName,
"barCode":this.queryShopParams.barCode,
"supermarketId":this.selectSupermarketId
"supermarketId":this.selectSupermarketId,
"materialTypeIds": this.$refs.typeTree.getCheckedKeys(),
}
console.log("this.queryShopParams",param)
shopPageListApi(param).then(response => {
@ -1245,30 +1177,12 @@
}
getShopProductApi(param).then(response => {
console.log("response.data",response.data)
this.productFrom=response.data;
this.productFrom.putawayStatef=this.productFrom.putawayState=="1"?true:false;
this.productFrom.ifOnlinef=this.productFrom.ifOnline=="2"?true:false;
this.productFrom=response.data;
});
},
cancelShopEitd(){
this.openProductEitd=false;
},
handlePutawayStateEitdChange(from){
let pws=from.putawayState;
if(pws=="1"){
this.productFrom.putawayState="2";
}else if(pws=="2"){
this.productFrom.putawayState="1";
}
},
handleIfOnlineEitdChange(from){
let pws=from.ifOnline;
if(pws=="1"){
this.productFrom.ifOnline="2";
}else if(pws=="2"){
this.productFrom.ifOnline="1";
}
},
},
handlePutawayStateChange(row){
let pws=row.putawayState;
let param={}
@ -1304,12 +1218,6 @@
eitdShopProductApi(param).then(response => {
this.getShopList();
});
},
handlePutawayStateChanges(row){
},
handleIfOnlineChanges(row){
},
submitShopEitd(){
console.log("this.productFrom",this.productFrom)

View File

@ -85,7 +85,6 @@
</el-table-column>
<el-table-column label="中标供应商" align="center" prop="supplierName" :show-overflow-tooltip="true"/>
<el-table-column label="最近一次供货" align="center">
<!-- <el-table-column label="供应商名称" align="center" prop="lastOrderGoodsSupplierName" width="120" :show-overflow-tooltip="true" /> -->
<el-table-column label="时间" align="center" prop="lastOrderGoodsDate" width="160" :show-overflow-tooltip="true" />
<el-table-column label="价格" align="center" prop="lastOrderGoodsPrice" width="120" :show-overflow-tooltip="true" >
<template slot-scope="scope">
@ -389,22 +388,39 @@ export default {
},
changSupplier(row){
console.log(row)
let param = [
{
"id":row.id,
"canteenId": row.canteenId,
"supplierId": row.supplierId,
"materialId": row.materialId,
"alternativeSuppliers": row.alternativeSuppliers,
"ifSupply": row.ifSupply
}
]
editSupplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功");
this.getList();
});
if(row.ifSupply){
let param = [
{
"id":row.id,
"canteenId": row.canteenId,
"supplierId": row.supplierId,
"materialId": row.materialId,
"alternativeSuppliers": row.alternativeSuppliers,
"ifSupply": row.ifSupply
}
]
editSupplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功");
});
}else{
let param = [
{
"id":row.id,
"canteenId": row.canteenId,
"supplierId": row.supplierId,
"materialId": row.materialId,
"alternativeSuppliers": row.alternativeSuppliers,
"ifSupply": row.ifSupply
}
]
addSupplierBindMaterialApi(param).then(response => {
this.getList();
});
}
},
changSupplierList(row){
console.log(row)
let param = [
{
"id":row.id,
@ -422,10 +438,17 @@ export default {
}else{
param[0].alternativeSuppliers=[]
}
editSupplierBindMaterialApi(param).then(response => {
// this.$modal.msgSuccess("");
// this.getList();
});
if(row.ifSupply){
editSupplierBindMaterialApi(param).then(response => {
// this.$modal.msgSuccess("");
// this.getList();
});
}else{
addSupplierBindMaterialApi(param).then(response => {
// this.$modal.msgSuccess("");
this.getList();
});
}
},
//
handleSelectionChange(selection) {