新增添加商品

This commit is contained in:
gyq
2024-05-16 10:09:31 +08:00
parent 055b0a068b
commit 8135d4616b
3 changed files with 117 additions and 48 deletions

View File

@@ -1,8 +1,8 @@
<template>
<el-dialog title="选择商品" :visible.sync="dialogVisible" @open="resetHandle()">
<el-dialog title="选择团购券分类" :visible.sync="dialogVisible" @open="resetHandle()">
<el-form :model="searhForm" inline>
<el-form-item>
<el-input v-model="searhForm.name" placeholder="商品名称"></el-input>
<el-input v-model="searhForm.name" placeholder="分类名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">查询</el-button>
@@ -11,6 +11,7 @@
</el-form>
<div class="head-container">
<el-table ref="table" :data="tableData.list" v-loading="tableData.loading">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column label="名称" prop="name"></el-table-column>
<el-table-column label="状态" prop="status">
<template v-slot="scope">
@@ -18,16 +19,15 @@
disabled></el-switch>
</template>
</el-table-column>
<el-table-column label="操作">
<template v-slot="scope">
<el-button type="primary" size="mini" @click="confirmHandle(scope.row)">选择</el-button>
</template>
</el-table-column>
</el-table>
</div>
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" @size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="confirmHandle"> </el-button>
</span>
</el-dialog>
</template>
@@ -46,13 +46,15 @@ export default {
total: 0,
loading: false,
list: []
}
},
goods: []
}
},
methods: {
// 确定选商品
confirmHandle(row) {
this.$emit('success', row)
let res = this.$refs.table.selection
this.$emit('success', res)
this.close()
},
// 重置查询
@@ -83,19 +85,42 @@ export default {
name: this.searhForm.name,
sort: 'id',
})
this.tableData.loading = false
this.tableData.list = res.content
this.tableData.total = res.totalElements
if (this.goods.length) {
this.$nextTick(() => {
this.selection()
})
}
setTimeout(() => {
this.tableData.loading = false
}, 500);
} catch (error) {
console.log(error)
}
},
show() {
show(goods) {
this.dialogVisible = true
if (goods && goods.length) {
this.goods = [...goods]
} else {
this.goods = []
}
this.resetHandle()
this.getTableData()
},
close() {
this.dialogVisible = false
},
selection() {
this.goods.forEach(row => {
this.tableData.list.forEach((item, index) => {
if (row.id == item.id) {
this.$refs.table.toggleRowSelection(this.tableData.list[index]);
}
})
});
}
}
}

View File

@@ -112,7 +112,6 @@ export default {
shopId: localStorage.getItem('shopId'),
sort: 'id',
})
this.tableData.loading = false
this.tableData.list = res.content
this.tableData.total = res.totalElements
@@ -121,6 +120,9 @@ export default {
this.selection()
})
}
setTimeout(() => {
this.tableData.loading = false
}, 500);
} catch (error) {
console.log(error)
}