Compare commits
2 Commits
b86c0fd1af
...
4cd27f33cc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cd27f33cc | ||
|
|
7e0b130457 |
@@ -9,6 +9,14 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</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-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>
|
||||
@@ -56,16 +64,9 @@
|
||||
<el-table-column label="商品ID" align="center" prop="id" />
|
||||
<el-table-column label="商品名称" align="center" prop="name" />
|
||||
<el-table-column label="商品描述" align="center" prop="description" />
|
||||
<el-table-column label="原价(元)" align="center" prop="originalPrice">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ (scope.row.originalPrice / 100).toFixed(2) }}</span>
|
||||
</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" prop="typeName" />
|
||||
<el-table-column label="原价(元)" align="center" prop="originalPrice" />
|
||||
<el-table-column label="现价(元)" align="center" prop="currentPrice" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -86,13 +87,13 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
<!-- <pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
/> -->
|
||||
|
||||
<!-- 添加或修改商品对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
@@ -103,6 +104,9 @@
|
||||
<el-form-item label="商品描述" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
|
||||
</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-input v-model="form.originalPrice" placeholder="请输入原价" />
|
||||
</el-form-item>
|
||||
@@ -147,7 +151,8 @@ export default {
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null
|
||||
name: null,
|
||||
typeName: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
@@ -183,6 +188,7 @@ export default {
|
||||
id: null,
|
||||
name: null,
|
||||
description: null,
|
||||
typeName: null,
|
||||
originalPrice: null,
|
||||
currentPrice: null
|
||||
}
|
||||
@@ -216,13 +222,6 @@ export default {
|
||||
const id = row.id || this.ids
|
||||
getProduct(id).then(response => {
|
||||
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.title = "修改商品"
|
||||
})
|
||||
@@ -231,25 +230,14 @@ export default {
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(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) {
|
||||
updateProduct(submitData).then(response => {
|
||||
updateProduct(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addProduct(submitData).then(response => {
|
||||
addProduct(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
|
||||
Reference in New Issue
Block a user