Compare commits
8 Commits
4324e5a688
...
c414efc7a4
| Author | SHA1 | Date | |
|---|---|---|---|
| c414efc7a4 | |||
| 09a2af0b55 | |||
| 89620b2445 | |||
| a1df62238e | |||
| 3a056335bb | |||
| fbff519ac9 | |||
| 657c916703 | |||
| 3c1c822f88 |
@ -23,10 +23,9 @@ def get_current_user_permissions():
|
|||||||
user_role = claims.get('role')
|
user_role = claims.get('role')
|
||||||
if not user_role:
|
if not user_role:
|
||||||
return []
|
return []
|
||||||
# 超级管理员返回所有字段权限
|
# 超级管理员返回所有字段权限 (忽略大小写)
|
||||||
if user_role == 'super_admin':
|
if user_role.upper() == 'SUPER_ADMIN':
|
||||||
return ['material_list:id', 'material_list:companyName', 'material_list:name', 'material_list:commonName', 'material_list:category', 'material_list:type',
|
return ['material_list:*']
|
||||||
'material_list:spec', 'material_list:unit', 'material_list:inventoryCount', 'material_list:availableCount', 'material_list:files', 'material_list:isEnabled']
|
|
||||||
perm_dict = AuthService.get_user_permissions(user_role)
|
perm_dict = AuthService.get_user_permissions(user_role)
|
||||||
# 合并菜单和元素权限
|
# 合并菜单和元素权限
|
||||||
perms = perm_dict.get('menus', []) + perm_dict.get('elements', [])
|
perms = perm_dict.get('menus', []) + perm_dict.get('elements', [])
|
||||||
@ -37,6 +36,9 @@ def filter_item_by_permissions(item_dict, user_permissions):
|
|||||||
"""
|
"""
|
||||||
根据用户权限过滤 item 字典,无权限的字段值置为 None
|
根据用户权限过滤 item 字典,无权限的字段值置为 None
|
||||||
"""
|
"""
|
||||||
|
# 如果用户拥有通配符权限,则不过滤
|
||||||
|
if 'material_list:*' in user_permissions:
|
||||||
|
return item_dict
|
||||||
# 字段名到权限码的映射(与前端 permissionMap 保持一致)
|
# 字段名到权限码的映射(与前端 permissionMap 保持一致)
|
||||||
field_to_perm = {
|
field_to_perm = {
|
||||||
'id': 'material_list:id',
|
'id': 'material_list:id',
|
||||||
@ -190,15 +192,19 @@ def create():
|
|||||||
}
|
}
|
||||||
# 过滤用户没有权限的字段
|
# 过滤用户没有权限的字段
|
||||||
filtered_data = {}
|
filtered_data = {}
|
||||||
for key, value in data.items():
|
# 如果拥有通配符权限,则不过滤
|
||||||
if key in field_to_perm:
|
if 'material_list:*' in user_permissions:
|
||||||
perm_code = field_to_perm[key]
|
filtered_data = data
|
||||||
if perm_code in user_permissions:
|
else:
|
||||||
|
for key, value in data.items():
|
||||||
|
if key in field_to_perm:
|
||||||
|
perm_code = field_to_perm[key]
|
||||||
|
if perm_code in user_permissions:
|
||||||
|
filtered_data[key] = value
|
||||||
|
# 没有权限则跳过,不包含在 filtered_data 中
|
||||||
|
else:
|
||||||
|
# 不在映射中的字段,默认允许(例如 visibilityLevel)
|
||||||
filtered_data[key] = value
|
filtered_data[key] = value
|
||||||
# 没有权限则跳过,不包含在 filtered_data 中
|
|
||||||
else:
|
|
||||||
# 不在映射中的字段,默认允许(例如 visibilityLevel)
|
|
||||||
filtered_data[key] = value
|
|
||||||
|
|
||||||
MaterialBaseService.create_material(filtered_data)
|
MaterialBaseService.create_material(filtered_data)
|
||||||
return jsonify({"code": 200, "msg": "新增成功"})
|
return jsonify({"code": 200, "msg": "新增成功"})
|
||||||
@ -239,15 +245,19 @@ def update(id):
|
|||||||
}
|
}
|
||||||
# 过滤用户没有权限的字段
|
# 过滤用户没有权限的字段
|
||||||
filtered_data = {}
|
filtered_data = {}
|
||||||
for key, value in data.items():
|
# 如果拥有通配符权限,则不过滤
|
||||||
if key in field_to_perm:
|
if 'material_list:*' in user_permissions:
|
||||||
perm_code = field_to_perm[key]
|
filtered_data = data
|
||||||
if perm_code in user_permissions:
|
else:
|
||||||
|
for key, value in data.items():
|
||||||
|
if key in field_to_perm:
|
||||||
|
perm_code = field_to_perm[key]
|
||||||
|
if perm_code in user_permissions:
|
||||||
|
filtered_data[key] = value
|
||||||
|
# 没有权限则跳过,不包含在 filtered_data 中
|
||||||
|
else:
|
||||||
|
# 不在映射中的字段,默认允许(例如 visibilityLevel)
|
||||||
filtered_data[key] = value
|
filtered_data[key] = value
|
||||||
# 没有权限则跳过,不包含在 filtered_data 中
|
|
||||||
else:
|
|
||||||
# 不在映射中的字段,默认允许(例如 visibilityLevel)
|
|
||||||
filtered_data[key] = value
|
|
||||||
# 使用过滤后的数据调用服务
|
# 使用过滤后的数据调用服务
|
||||||
MaterialBaseService.update_material(id, filtered_data)
|
MaterialBaseService.update_material(id, filtered_data)
|
||||||
return jsonify({"code": 200, "msg": "修改成功"})
|
return jsonify({"code": 200, "msg": "修改成功"})
|
||||||
|
|||||||
@ -52,6 +52,7 @@ def filter_item_by_permissions(item_dict, user_permissions):
|
|||||||
'inspection_status': 'inbound_buy:inspection_status',
|
'inspection_status': 'inbound_buy:inspection_status',
|
||||||
'warehouse_location': 'inbound_buy:warehouse_location',
|
'warehouse_location': 'inbound_buy:warehouse_location',
|
||||||
'unit_price': 'inbound_buy:unit_price',
|
'unit_price': 'inbound_buy:unit_price',
|
||||||
|
'post_tax_unit_price': 'inbound_buy:post_tax_unit_price',
|
||||||
'tax_rate': 'inbound_buy:tax_rate',
|
'tax_rate': 'inbound_buy:tax_rate',
|
||||||
'total_price': 'inbound_buy:total_price',
|
'total_price': 'inbound_buy:total_price',
|
||||||
'currency': 'inbound_buy:currency',
|
'currency': 'inbound_buy:currency',
|
||||||
@ -118,12 +119,13 @@ def get_list():
|
|||||||
# 新增筛选参数
|
# 新增筛选参数
|
||||||
category = request.args.get('category', '')
|
category = request.args.get('category', '')
|
||||||
material_type = request.args.get('material_type', '')
|
material_type = request.args.get('material_type', '')
|
||||||
|
company = request.args.get('company', '')
|
||||||
|
|
||||||
# 状态参数处理
|
# 状态参数处理
|
||||||
statuses_str = request.args.get('statuses', '')
|
statuses_str = request.args.get('statuses', '')
|
||||||
statuses = statuses_str.split(',') if statuses_str else []
|
statuses = statuses_str.split(',') if statuses_str else []
|
||||||
|
|
||||||
result = BuyInboundService.get_list(page, limit, keyword, statuses, category, material_type)
|
result = BuyInboundService.get_list(page, limit, keyword, statuses, category, material_type, company)
|
||||||
# 字段级脱敏
|
# 字段级脱敏
|
||||||
user_permissions = get_current_user_permissions()
|
user_permissions = get_current_user_permissions()
|
||||||
if result.get('items'):
|
if result.get('items'):
|
||||||
@ -166,6 +168,7 @@ def submit():
|
|||||||
'inspection_status': 'inbound_buy:inspection_status',
|
'inspection_status': 'inbound_buy:inspection_status',
|
||||||
'warehouse_location': 'inbound_buy:warehouse_location',
|
'warehouse_location': 'inbound_buy:warehouse_location',
|
||||||
'unit_price': 'inbound_buy:unit_price',
|
'unit_price': 'inbound_buy:unit_price',
|
||||||
|
'post_tax_unit_price': 'inbound_buy:post_tax_unit_price',
|
||||||
'tax_rate': 'inbound_buy:tax_rate',
|
'tax_rate': 'inbound_buy:tax_rate',
|
||||||
'total_price': 'inbound_buy:total_price',
|
'total_price': 'inbound_buy:total_price',
|
||||||
'currency': 'inbound_buy:currency',
|
'currency': 'inbound_buy:currency',
|
||||||
@ -230,6 +233,7 @@ def update_buy(id):
|
|||||||
'inspection_status': 'inbound_buy:inspection_status',
|
'inspection_status': 'inbound_buy:inspection_status',
|
||||||
'warehouse_location': 'inbound_buy:warehouse_location',
|
'warehouse_location': 'inbound_buy:warehouse_location',
|
||||||
'unit_price': 'inbound_buy:unit_price',
|
'unit_price': 'inbound_buy:unit_price',
|
||||||
|
'post_tax_unit_price': 'inbound_buy:post_tax_unit_price',
|
||||||
'tax_rate': 'inbound_buy:tax_rate',
|
'tax_rate': 'inbound_buy:tax_rate',
|
||||||
'total_price': 'inbound_buy:total_price',
|
'total_price': 'inbound_buy:total_price',
|
||||||
'currency': 'inbound_buy:currency',
|
'currency': 'inbound_buy:currency',
|
||||||
|
|||||||
@ -33,7 +33,8 @@ class StockBuy(db.Model):
|
|||||||
available_quantity = db.Column(db.Numeric(19, 4), default=0)
|
available_quantity = db.Column(db.Numeric(19, 4), default=0)
|
||||||
|
|
||||||
# 财务与商务
|
# 财务与商务
|
||||||
unit_price = db.Column(db.Numeric(19, 4), default=0) # 现意为:不含税单价
|
pre_tax_unit_price = db.Column(db.Numeric(19, 4), default=0) # 现意为:不含税单价
|
||||||
|
post_tax_unit_price = db.Column(db.Numeric(19, 4), default=0) # 税后单价
|
||||||
total_price = db.Column(db.Numeric(19, 4), default=0) # 总价
|
total_price = db.Column(db.Numeric(19, 4), default=0) # 总价
|
||||||
# [新增] 税率
|
# [新增] 税率
|
||||||
tax_rate = db.Column(db.Numeric(5, 2), default=0)
|
tax_rate = db.Column(db.Numeric(5, 2), default=0)
|
||||||
@ -97,7 +98,8 @@ class StockBuy(db.Model):
|
|||||||
'available_quantity': float(self.available_quantity or 0),
|
'available_quantity': float(self.available_quantity or 0),
|
||||||
'qty_available': float(self.available_quantity or 0),
|
'qty_available': float(self.available_quantity or 0),
|
||||||
|
|
||||||
'unit_price': float(self.unit_price or 0),
|
'unit_price': float(self.pre_tax_unit_price or 0),
|
||||||
|
'post_tax_unit_price': float(self.post_tax_unit_price or 0),
|
||||||
'total_price': float(self.total_price or 0),
|
'total_price': float(self.total_price or 0),
|
||||||
# [新增] 税率
|
# [新增] 税率
|
||||||
'tax_rate': float(self.tax_rate or 0),
|
'tax_rate': float(self.tax_rate or 0),
|
||||||
@ -116,4 +118,4 @@ class StockBuy(db.Model):
|
|||||||
|
|
||||||
'global_print_id': self.global_print_id,
|
'global_print_id': self.global_print_id,
|
||||||
'global_print_id_str': f"{self.global_print_id:010d}" if self.global_print_id else ""
|
'global_print_id_str': f"{self.global_print_id:010d}" if self.global_print_id else ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -368,9 +368,9 @@ class MaterialBaseService:
|
|||||||
# 处理采购件
|
# 处理采购件
|
||||||
for stock, base in list_buy:
|
for stock, base in list_buy:
|
||||||
# 价格计算
|
# 价格计算
|
||||||
unit_price = float(stock.unit_price or 0)
|
unit_price = float(stock.pre_tax_unit_price or 0)
|
||||||
tax_rate = float(stock.tax_rate or 0)
|
tax_rate = float(stock.tax_rate or 0)
|
||||||
price_incl = unit_price * (1 + tax_rate / 100.0)
|
price_incl = float(stock.post_tax_unit_price or (unit_price * (1 + tax_rate / 100.0)))
|
||||||
qty = float(stock.stock_quantity or 0)
|
qty = float(stock.stock_quantity or 0)
|
||||||
|
|
||||||
# 计算不含税总价 = 数量 * 不含税单价
|
# 计算不含税总价 = 数量 * 不含税单价
|
||||||
@ -535,4 +535,4 @@ class MaterialBaseService:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
raise e
|
raise e
|
||||||
|
|||||||
@ -117,7 +117,13 @@ class BuyInboundService:
|
|||||||
|
|
||||||
in_qty = float(data.get('in_quantity') or 0)
|
in_qty = float(data.get('in_quantity') or 0)
|
||||||
u_price = float(data.get('unit_price') or 0)
|
u_price = float(data.get('unit_price') or 0)
|
||||||
tax_rate = float(data.get('tax_rate') or 0) # [新增]
|
tax_rate = float(data.get('tax_rate') or 0)
|
||||||
|
|
||||||
|
# 计算税后单价
|
||||||
|
post_tax_price = float(data.get('post_tax_unit_price') or 0)
|
||||||
|
if post_tax_price == 0 and u_price > 0:
|
||||||
|
tax_multiplier = 1 + (tax_rate / 100)
|
||||||
|
post_tax_price = u_price * tax_multiplier
|
||||||
|
|
||||||
try:
|
try:
|
||||||
seq_sql = text("SELECT nextval('global_print_seq')")
|
seq_sql = text("SELECT nextval('global_print_seq')")
|
||||||
@ -137,8 +143,9 @@ class BuyInboundService:
|
|||||||
warehouse_location=data.get('warehouse_location'),
|
warehouse_location=data.get('warehouse_location'),
|
||||||
|
|
||||||
# 价格信息
|
# 价格信息
|
||||||
unit_price=u_price,
|
pre_tax_unit_price=u_price,
|
||||||
tax_rate=tax_rate, # [新增]
|
post_tax_unit_price=post_tax_price,
|
||||||
|
tax_rate=tax_rate,
|
||||||
total_price=in_qty * u_price,
|
total_price=in_qty * u_price,
|
||||||
currency=data.get('currency', 'CNY'),
|
currency=data.get('currency', 'CNY'),
|
||||||
exchange_rate=data.get('exchange_rate', 1.0),
|
exchange_rate=data.get('exchange_rate', 1.0),
|
||||||
@ -182,8 +189,22 @@ class BuyInboundService:
|
|||||||
if 'arrival_photo' in data: stock.arrival_photo = json.dumps(data['arrival_photo'])
|
if 'arrival_photo' in data: stock.arrival_photo = json.dumps(data['arrival_photo'])
|
||||||
if 'inspection_report' in data: stock.inspection_report = json.dumps(data['inspection_report'])
|
if 'inspection_report' in data: stock.inspection_report = json.dumps(data['inspection_report'])
|
||||||
|
|
||||||
# [新增] 更新税率
|
# 更新税率
|
||||||
if 'tax_rate' in data: stock.tax_rate = float(data['tax_rate'])
|
if 'tax_rate' in data:
|
||||||
|
stock.tax_rate = float(data['tax_rate'])
|
||||||
|
|
||||||
|
# 更新税前单价
|
||||||
|
if 'unit_price' in data:
|
||||||
|
stock.pre_tax_unit_price = float(data['unit_price'])
|
||||||
|
|
||||||
|
# 更新税后单价
|
||||||
|
if 'post_tax_unit_price' in data:
|
||||||
|
stock.post_tax_unit_price = float(data['post_tax_unit_price'])
|
||||||
|
else:
|
||||||
|
# 如果税后单价没有提供,根据税前单价和税率计算
|
||||||
|
if 'unit_price' in data or 'tax_rate' in data:
|
||||||
|
tax_multiplier = 1 + (float(data.get('tax_rate', stock.tax_rate or 0)) / 100)
|
||||||
|
stock.post_tax_unit_price = float(stock.pre_tax_unit_price) * tax_multiplier
|
||||||
|
|
||||||
if 'in_quantity' in data:
|
if 'in_quantity' in data:
|
||||||
diff = float(data['in_quantity']) - float(stock.in_quantity)
|
diff = float(data['in_quantity']) - float(stock.in_quantity)
|
||||||
@ -192,9 +213,8 @@ class BuyInboundService:
|
|||||||
stock.stock_quantity = float(stock.stock_quantity) + diff
|
stock.stock_quantity = float(stock.stock_quantity) + diff
|
||||||
stock.available_quantity = float(stock.available_quantity) + diff
|
stock.available_quantity = float(stock.available_quantity) + diff
|
||||||
|
|
||||||
if 'unit_price' in data: stock.unit_price = float(data['unit_price'])
|
# 重新计算总价
|
||||||
|
stock.total_price = float(stock.in_quantity) * float(stock.pre_tax_unit_price)
|
||||||
stock.total_price = float(stock.in_quantity) * float(stock.unit_price)
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return stock
|
return stock
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -322,4 +342,4 @@ class BuyInboundService:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_history_locations(base_id):
|
def get_history_locations(base_id):
|
||||||
return [r[0] for r in
|
return [r[0] for r in
|
||||||
db.session.query(StockBuy.warehouse_location).filter(StockBuy.base_id == base_id).distinct().all()]
|
db.session.query(StockBuy.warehouse_location).filter(StockBuy.base_id == base_id).distinct().all()]
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class OutboundService:
|
|||||||
if table_type == 'stock_product':
|
if table_type == 'stock_product':
|
||||||
return float(item.sale_price) if item.sale_price else 0
|
return float(item.sale_price) if item.sale_price else 0
|
||||||
elif table_type == 'stock_buy':
|
elif table_type == 'stock_buy':
|
||||||
return float(item.unit_price) if item.unit_price else 0
|
return float(item.pre_tax_unit_price) if item.pre_tax_unit_price else 0
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
prod = StockProduct.query.filter(
|
prod = StockProduct.query.filter(
|
||||||
|
|||||||
@ -89,7 +89,7 @@ const handleLogout = () => {
|
|||||||
<footer v-if="!isLoginPage" class="app-footer">
|
<footer v-if="!isLoginPage" class="app-footer">
|
||||||
<span class="version-tag">
|
<span class="version-tag">
|
||||||
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
||||||
当前版本: 1.4 Beta (2.27权限管理版)
|
当前版本: 1.5 Beta (2.27权限管理完成版)
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="buy-module">
|
<div class="buy-module">
|
||||||
<div class="header-container">
|
<div class="header-container" style="flex-wrap: wrap;">
|
||||||
<div class="search-form-area">
|
<div class="search-form-area" style="flex-wrap: wrap;">
|
||||||
|
|
||||||
<el-select
|
<el-select
|
||||||
v-model="queryParams.company"
|
v-model="queryParams.company"
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<el-button class="reset-btn" @click="resetQuery">重置</el-button>
|
<el-button class="reset-btn" @click="resetQuery">重置</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right-actions">
|
<div class="right-actions" style="flex-wrap: wrap;">
|
||||||
<el-button v-if="userStore.hasPermission('inbound_buy:operation')" type="primary" :icon="Plus" @click="handleCreate" class="add-btn">新增</el-button>
|
<el-button v-if="userStore.hasPermission('inbound_buy:operation')" type="primary" :icon="Plus" @click="handleCreate" class="add-btn">新增</el-button>
|
||||||
<el-button :icon="Refresh" circle @click="fetchData" class="circle-btn" />
|
<el-button :icon="Refresh" circle @click="fetchData" class="circle-btn" />
|
||||||
|
|
||||||
@ -197,7 +197,7 @@
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="visible"
|
v-model="visible"
|
||||||
:title="dialogStatus === 'create' ? '新增采购入库' : '编辑入库信息'"
|
:title="dialogStatus === 'create' ? '新增采购入库' : '编辑入库信息'"
|
||||||
width="1000px"
|
:width="'min(1000px, 95vw)'"
|
||||||
top="4vh"
|
top="4vh"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
@ -296,9 +296,6 @@
|
|||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="入库日期" prop="in_date"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled/></el-form-item>
|
<el-form-item label="入库日期" prop="in_date"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled/></el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
|
||||||
<el-form-item label="条码" prop="barcode"><el-input v-model="form.barcode" placeholder="扫描条码" clearable/></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="库位" prop="warehouse_location">
|
<el-form-item label="库位" prop="warehouse_location">
|
||||||
<el-autocomplete
|
<el-autocomplete
|
||||||
@ -346,7 +343,7 @@
|
|||||||
<el-row :gutter="20" style="margin-top: 10px;">
|
<el-row :gutter="20" style="margin-top: 10px;">
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="入库数量" prop="in_quantity">
|
<el-form-item label="入库数量" prop="in_quantity">
|
||||||
<el-input-number v-model="form.in_quantity" :min="1" controls-position="right" style="width:100%" class="strong-input"/>
|
<el-input-number v-model="form.in_quantity" :min="1" controls-position="right" style="width:100%" class="strong-input" @change="updatePrices('qty')"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
@ -435,7 +432,7 @@
|
|||||||
|
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="税率">
|
<el-form-item label="税率">
|
||||||
<el-select v-model="form.tax_rate" style="width:100%">
|
<el-select v-model="form.tax_rate" style="width:100%" @change="updatePrices('tax')">
|
||||||
<el-option label="0%" :value="0" />
|
<el-option label="0%" :value="0" />
|
||||||
<el-option label="1%" :value="1" />
|
<el-option label="1%" :value="1" />
|
||||||
<el-option label="13%" :value="13" />
|
<el-option label="13%" :value="13" />
|
||||||
@ -443,7 +440,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="6"><el-form-item label="不含税单价" prop="unit_price"><el-input-number v-model="form.unit_price" :precision="4" controls-position="right" style="width:100%"/></el-form-item></el-col>
|
<el-col :span="6"><el-form-item label="税前单价" prop="unit_price"><el-input-number v-model="form.unit_price" :precision="4" controls-position="right" style="width:100%" @change="updatePrices('pre')"/></el-form-item></el-col>
|
||||||
|
<el-col :span="6"><el-form-item label="税后单价"><el-input-number v-model="form.post_tax_unit_price" :precision="4" controls-position="right" style="width:100%" @change="updatePrices('post')"/></el-form-item></el-col>
|
||||||
|
|
||||||
<el-col :span="6"><el-form-item label="总价"><el-input-number v-model="form.total_price" :precision="2" disabled :controls="false" style="width:100%" class="total-price-input"/></el-form-item></el-col>
|
<el-col :span="6"><el-form-item label="总价"><el-input-number v-model="form.total_price" :precision="2" disabled :controls="false" style="width:100%" class="total-price-input"/></el-form-item></el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -842,7 +840,7 @@ const form = reactive({
|
|||||||
material_name: '', spec_model: '', category: '', unit: '', material_type: '',
|
material_name: '', spec_model: '', category: '', unit: '', material_type: '',
|
||||||
sku: '', barcode: '', in_date: '', serial_number: '', batch_number: '', status: '在库', inspection_status: '未检',
|
sku: '', barcode: '', in_date: '', serial_number: '', batch_number: '', status: '在库', inspection_status: '未检',
|
||||||
in_quantity: 1, stock_quantity: 1, available_quantity: 1, warehouse_location: '',
|
in_quantity: 1, stock_quantity: 1, available_quantity: 1, warehouse_location: '',
|
||||||
unit_price: 0, total_price: 0,
|
unit_price: 0, post_tax_unit_price: 0, total_price: 0,
|
||||||
tax_rate: 0,
|
tax_rate: 0,
|
||||||
currency: 'CNY', exchange_rate: 1.00,
|
currency: 'CNY', exchange_rate: 1.00,
|
||||||
supplier_name: '', purchaser: '', purchaser_email: '', source_link: '', detail_link: '',
|
supplier_name: '', purchaser: '', purchaser_email: '', source_link: '', detail_link: '',
|
||||||
@ -1039,7 +1037,25 @@ const handleEntryModeChange = (val: string) => {
|
|||||||
if(formRef.value) formRef.value.clearValidate('batch_number')
|
if(formRef.value) formRef.value.clearValidate('batch_number')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(() => [form.in_quantity, form.unit_price], () => { form.total_price = Number((form.in_quantity * form.unit_price).toFixed(4)) })
|
// 价格联动计算
|
||||||
|
const updatePrices = (source: string) => {
|
||||||
|
const taxMultiplier = 1 + (form.tax_rate || 0) / 100;
|
||||||
|
if (source === 'pre') {
|
||||||
|
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
|
||||||
|
} else if (source === 'post') {
|
||||||
|
form.unit_price = Number((form.post_tax_unit_price / taxMultiplier).toFixed(4));
|
||||||
|
} else if (source === 'tax') {
|
||||||
|
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
|
||||||
|
}
|
||||||
|
form.total_price = Number((form.in_quantity * form.unit_price).toFixed(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => [form.in_quantity, form.unit_price], () => {
|
||||||
|
form.total_price = Number((form.in_quantity * form.unit_price).toFixed(4));
|
||||||
|
// 同时更新税后单价
|
||||||
|
const taxMultiplier = 1 + (form.tax_rate || 0) / 100;
|
||||||
|
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
|
||||||
|
})
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@ -1105,6 +1121,10 @@ const handleUpdate = (row: any) => {
|
|||||||
source_link: row.source_link, detail_link: row.detail_link,
|
source_link: row.source_link, detail_link: row.detail_link,
|
||||||
arrival_photo: row.arrival_photo || [], inspection_report: row.inspection_report || []
|
arrival_photo: row.arrival_photo || [], inspection_report: row.inspection_report || []
|
||||||
})
|
})
|
||||||
|
// 计算税后单价
|
||||||
|
const taxMultiplier = 1 + (form.tax_rate || 0) / 100;
|
||||||
|
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
|
||||||
|
|
||||||
arrivalFileList.value = form.arrival_photo.map(url => ({ name: url.split('/').pop(), url: getImageUrl(url) }))
|
arrivalFileList.value = form.arrival_photo.map(url => ({ name: url.split('/').pop(), url: getImageUrl(url) }))
|
||||||
const reports = form.inspection_report || []
|
const reports = form.inspection_report || []
|
||||||
const reportImgs = reports.filter(r => !isExternalLink(r))
|
const reportImgs = reports.filter(r => !isExternalLink(r))
|
||||||
@ -1127,7 +1147,13 @@ const submitForm = async () => {
|
|||||||
const onlyImages = finalReportList.filter(item => !isExternalLink(item))
|
const onlyImages = finalReportList.filter(item => !isExternalLink(item))
|
||||||
if (inspection_report_url.value) onlyImages.push(inspection_report_url.value)
|
if (inspection_report_url.value) onlyImages.push(inspection_report_url.value)
|
||||||
|
|
||||||
const payload = { ...form, inspection_report: onlyImages, in_quantity: Number(form.in_quantity), unit_price: Number(form.unit_price) }
|
const payload = {
|
||||||
|
...form,
|
||||||
|
inspection_report: onlyImages,
|
||||||
|
in_quantity: Number(form.in_quantity),
|
||||||
|
unit_price: Number(form.unit_price),
|
||||||
|
post_tax_unit_price: Number(form.post_tax_unit_price)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (dialogStatus.value === 'create') {
|
if (dialogStatus.value === 'create') {
|
||||||
const res: any = await createBuyInbound(payload)
|
const res: any = await createBuyInbound(payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user