This commit is contained in:
menxipeng
2025-11-16 19:18:28 +08:00
parent 9f87272433
commit 7e0b130457

View File

@@ -9,6 +9,14 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="类型说明" prop="typeName">
<el-input
v-model="queryParams.typeName"
placeholder="请输入类型说明"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -56,16 +64,9 @@
<el-table-column label="商品ID" align="center" prop="id" /> <el-table-column label="商品ID" align="center" prop="id" />
<el-table-column label="商品名称" align="center" prop="name" /> <el-table-column label="商品名称" align="center" prop="name" />
<el-table-column label="商品描述" align="center" prop="description" /> <el-table-column label="商品描述" align="center" prop="description" />
<el-table-column label="原价(元)" align="center" prop="originalPrice"> <el-table-column label="类型说明" align="center" prop="typeName" />
<template slot-scope="scope"> <el-table-column label="原价(元)" align="center" prop="originalPrice" />
<span>{{ (scope.row.originalPrice / 100).toFixed(2) }}</span> <el-table-column label="现价(元)" align="center" prop="currentPrice" />
</template>
</el-table-column>
<el-table-column label="现价(元)" align="center" prop="currentPrice">
<template slot-scope="scope">
<span>{{ (scope.row.currentPrice / 100).toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@@ -86,13 +87,13 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <!-- <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> /> -->
<!-- 添加或修改商品对话框 --> <!-- 添加或修改商品对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -103,6 +104,9 @@
<el-form-item label="商品描述" prop="description"> <el-form-item label="商品描述" prop="description">
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
<el-form-item label="类型说明" prop="typeName">
<el-input v-model="form.typeName" placeholder="请输入类型说明" />
</el-form-item>
<el-form-item label="原价(元)" prop="originalPrice"> <el-form-item label="原价(元)" prop="originalPrice">
<el-input v-model="form.originalPrice" placeholder="请输入原价" /> <el-input v-model="form.originalPrice" placeholder="请输入原价" />
</el-form-item> </el-form-item>
@@ -147,7 +151,8 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: null name: null,
typeName: null
}, },
// 表单参数 // 表单参数
form: {}, form: {},
@@ -183,6 +188,7 @@ export default {
id: null, id: null,
name: null, name: null,
description: null, description: null,
typeName: null,
originalPrice: null, originalPrice: null,
currentPrice: null currentPrice: null
} }
@@ -216,13 +222,6 @@ export default {
const id = row.id || this.ids const id = row.id || this.ids
getProduct(id).then(response => { getProduct(id).then(response => {
this.form = response.data this.form = response.data
// 将分转换为元显示
if (this.form.originalPrice) {
this.form.originalPrice = (this.form.originalPrice / 100).toFixed(2)
}
if (this.form.currentPrice) {
this.form.currentPrice = (this.form.currentPrice / 100).toFixed(2)
}
this.open = true this.open = true
this.title = "修改商品" this.title = "修改商品"
}) })
@@ -231,25 +230,14 @@ export default {
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
// 创建提交数据的副本
const submitData = { ...this.form }
// 将元转换为分发送到接口
if (submitData.originalPrice) {
submitData.originalPrice = Math.round(parseFloat(submitData.originalPrice) * 100)
}
if (submitData.currentPrice) {
submitData.currentPrice = Math.round(parseFloat(submitData.currentPrice) * 100)
}
if (this.form.id != null) { if (this.form.id != null) {
updateProduct(submitData).then(response => { updateProduct(this.form).then(response => {
this.$modal.msgSuccess("修改成功") this.$modal.msgSuccess("修改成功")
this.open = false this.open = false
this.getList() this.getList()
}) })
} else { } else {
addProduct(submitData).then(response => { addProduct(this.form).then(response => {
this.$modal.msgSuccess("新增成功") this.$modal.msgSuccess("新增成功")
this.open = false this.open = false
this.getList() this.getList()