|
@@ -3,66 +3,138 @@
|
|
|
<!-- 搜索 -->
|
|
|
<el-form inline label-width="100px" size="mini">
|
|
|
<el-form-item label="推荐位置:">
|
|
|
- <el-select>
|
|
|
- <el-option />
|
|
|
+ <el-select v-model="form.position" placeholder="请选择推荐位置" clearable>
|
|
|
+ <el-option v-for="item in dict.type.goods_location" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="当前状态:">
|
|
|
- <el-select>
|
|
|
- <el-option />
|
|
|
+ <el-select v-model="form.status" placeholder="请选择当前状态" clearable>
|
|
|
+ <el-option v-for="item in dict.type.on_off_out" :key="item.value" :label="item.label"
|
|
|
+ :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="商品名称:">
|
|
|
- <el-input />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="商品简介:">
|
|
|
- <el-input />
|
|
|
+ <el-input v-model="form.name" placeholder="请输入商品名称" clearable />
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
|
|
|
<el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-plus" plain @click="getDetail">新增</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" plain @click="getDetail()">新增</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<!-- 列表 -->
|
|
|
- <el-table>
|
|
|
- <el-table-column label="推荐位置"></el-table-column>
|
|
|
- <el-table-column label="商品名称"></el-table-column>
|
|
|
- <el-table-column label="商品简介"></el-table-column>
|
|
|
- <el-table-column label="商品价格"></el-table-column>
|
|
|
- <el-table-column label="商品图片"></el-table-column>
|
|
|
- <el-table-column label="当前状态"></el-table-column>
|
|
|
- <el-table-column label="权重"></el-table-column>
|
|
|
- <el-table-column label="有效期"></el-table-column>
|
|
|
- <el-table-column label="操作">
|
|
|
- <el-button>编辑</el-button>
|
|
|
+ <el-table :data="tableData" v-loading="loading">
|
|
|
+ <el-table-column label="推荐位置" prop="position" align="center" :formatter="positionFormatter" />
|
|
|
+ <el-table-column label="商品名称" prop="name" align="center" show-overflow-tooltip />
|
|
|
+ <el-table-column label="商品简介" prop="description" align="center" show-overflow-tooltip />
|
|
|
+ <el-table-column label="商品价格/元" prop="price" align="center" />
|
|
|
+ <el-table-column label="商品图片" align="center" width="100px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-image :src="scope.row.pic" :previewSrcList="[scope.row.pic]" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="当前状态" prop="status" align="center" :formatter="statusFormatter" />
|
|
|
+ <el-table-column label="权重" prop="sort" align="center" />
|
|
|
+ <el-table-column label="有效期" align="center" show-overflow-tooltip>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.startTime }} 至 {{ scope.row.endTime }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="text" @click="getDetail(scope.row.id)">编辑</el-button>
|
|
|
+ <el-button type="delete" @click="getDelete(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ <pagination v-show="total>0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
|
|
|
+ @pagination="getList" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { list, remove } from '@/api/goods/list'
|
|
|
export default {
|
|
|
+ dicts: ['goods_location', 'on_off_out'],
|
|
|
data() {
|
|
|
return {
|
|
|
-
|
|
|
+ // 遮罩层
|
|
|
+ loading: false,
|
|
|
+ // 表单
|
|
|
+ form: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10
|
|
|
+ },
|
|
|
+ // 列表
|
|
|
+ tableData: [],
|
|
|
+ total: 0
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ // 列表
|
|
|
+ getList() {
|
|
|
+ this.loading = true
|
|
|
+ list(this.form).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.tableData = res.data.records
|
|
|
+ this.total = res.data.total
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
// 搜索
|
|
|
getSearch() {
|
|
|
-
|
|
|
+ this.form.pageNum = 1
|
|
|
+ this.getList()
|
|
|
},
|
|
|
// 重置
|
|
|
getRefresh() {
|
|
|
-
|
|
|
+ this.form = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
},
|
|
|
// 新增 编辑
|
|
|
- getDetail() {
|
|
|
+ getDetail(id) {
|
|
|
this.$router.push({
|
|
|
- path: `/goods/goodsList/detail`
|
|
|
+ path: `/goods/goodsList/detail`,
|
|
|
+ query: {
|
|
|
+ id: id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除
|
|
|
+ getDelete(row) {
|
|
|
+ this.$confirm(`是否删除${row.name}商品?`, '提醒', {
|
|
|
+ 'confirmButtonText': '确定',
|
|
|
+ 'cancelButtonText': '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ remove({
|
|
|
+ id: row.id
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('删除成功!')
|
|
|
+ this.getList()
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ // 字典翻译
|
|
|
+ positionFormatter(row) {
|
|
|
+ return this.selectDictLabel(this.dict.type.goods_location, row.position)
|
|
|
+ },
|
|
|
+
|
|
|
+ statusFormatter(row) {
|
|
|
+ return this.selectDictLabel(this.dict.type.on_off_out, row.status)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|