商品标签功能
This commit is contained in:
140
src/views/modules/shop/shoptag-add-or-update.vue
Normal file
140
src/views/modules/shop/shoptag-add-or-update.vue
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:title="!dataForm.splId ? '新增' : '修改'"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:visible.sync="visible" append-to-body>
|
||||||
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||||
|
<el-form-item label="标签名称" prop="labelName">
|
||||||
|
<el-input v-model="dataForm.labelName" placeholder="标签名称"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<span slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="visible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
restaurants: [],
|
||||||
|
state: '',
|
||||||
|
timeout: null,
|
||||||
|
dataForm: {
|
||||||
|
splId: 0,
|
||||||
|
labelName: '',
|
||||||
|
},
|
||||||
|
dataRule: {
|
||||||
|
labelName: [
|
||||||
|
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
init (row) {
|
||||||
|
this.visible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['dataForm'].resetFields()
|
||||||
|
if (row) {
|
||||||
|
this.dataForm.splId = row.splId
|
||||||
|
this.dataForm.labelName = row.labelName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 表单提交
|
||||||
|
dataFormSubmit () {
|
||||||
|
this.$refs['dataForm'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if(this.dataForm.splId){
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl(`/book/label/updateLabel?splId=`+this.dataForm.splId+`&labelName=`+ this.dataForm.labelName),
|
||||||
|
method: 'post',
|
||||||
|
// data: this.$http.adornData({
|
||||||
|
// 'splId': this.dataForm.splId,
|
||||||
|
// 'labelName': this.dataForm.labelName
|
||||||
|
// })
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data && data.code === 0) {
|
||||||
|
this.$message({
|
||||||
|
message: '操作成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.visible = false
|
||||||
|
this.$emit('refreshDataList')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl(`/book/label/addLabel?labelName=`+ this.dataForm.labelName),
|
||||||
|
method: 'post',
|
||||||
|
// data: this.$http.adornData({
|
||||||
|
// 'splId': this.dataForm.splId,
|
||||||
|
// 'labelName': this.dataForm.labelName
|
||||||
|
// })
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data && data.code === 0) {
|
||||||
|
this.$message({
|
||||||
|
message: '操作成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.visible = false
|
||||||
|
this.$emit('refreshDataList')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadAll() {
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl(`/book/shopproduct/prodSearch`),
|
||||||
|
method: 'get'
|
||||||
|
}).then(({data}) => {
|
||||||
|
this.restaurants = data.list
|
||||||
|
console.log(this.restaurants)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
querySearchAsync(queryString, cb) {
|
||||||
|
console.log('数据'+this.restaurants)
|
||||||
|
var restaurants = this.restaurants;
|
||||||
|
var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
|
||||||
|
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
cb(results);
|
||||||
|
}, 3000 * Math.random());
|
||||||
|
},
|
||||||
|
createStateFilter(queryString) {
|
||||||
|
return (state) => {
|
||||||
|
return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
handleSelect(item) {
|
||||||
|
console.log(item);
|
||||||
|
this.dataForm.prodId = item.productId,
|
||||||
|
this.dataForm.promotionId = item.value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.loadAll();
|
||||||
|
// this.restaurants = this.loadAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
153
src/views/modules/shop/shoptag.vue
Normal file
153
src/views/modules/shop/shoptag.vue
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mod-config">
|
||||||
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||||
|
<!-- <el-form-item>
|
||||||
|
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item>
|
||||||
|
<!-- <el-button @click="getDataList()">查询</el-button> -->
|
||||||
|
<el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||||
|
<!-- <el-button v-if="isAuth('book:shopseckill:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> -->
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<el-table
|
||||||
|
:data="dataList"
|
||||||
|
border
|
||||||
|
v-loading="dataListLoading"
|
||||||
|
style="width: 100%;">
|
||||||
|
<el-table-column label="序号" width="70" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ (pageIndex - 1) * pageSize + scope.$index + 1 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="labelName"
|
||||||
|
header-align="center"
|
||||||
|
align="center"
|
||||||
|
label="标签名称">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
fixed="right"
|
||||||
|
header-align="center"
|
||||||
|
align="center"
|
||||||
|
width="150"
|
||||||
|
label="操作">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row)">修改</el-button>
|
||||||
|
<el-button type="text" size="small" @click="deleteHandle(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- <el-pagination
|
||||||
|
@size-change="sizeChangeHandle"
|
||||||
|
@current-change="currentChangeHandle"
|
||||||
|
:current-page="pageIndex"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
:page-size="pageSize"
|
||||||
|
:total="totalPage"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper">
|
||||||
|
</el-pagination> -->
|
||||||
|
<!-- 弹窗, 新增 / 修改 -->
|
||||||
|
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import AddOrUpdate from './shoptag-add-or-update'
|
||||||
|
// import dialogComponent from './seckillprodrelation'
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
dataForm: {
|
||||||
|
key: ''
|
||||||
|
},
|
||||||
|
dataList: [],
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
totalPage: 0,
|
||||||
|
dataListLoading: false,
|
||||||
|
dataListSelections: [],
|
||||||
|
addOrUpdateVisible: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
AddOrUpdate
|
||||||
|
},
|
||||||
|
activated () {
|
||||||
|
this.getDataList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 获取数据列表
|
||||||
|
getDataList () {
|
||||||
|
this.dataListLoading = true
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl('/book/label/getLabels'),
|
||||||
|
method: 'post',
|
||||||
|
// params: this.$http.adornParams({
|
||||||
|
// 'page': this.pageIndex,
|
||||||
|
// 'limit': this.pageSize,
|
||||||
|
// 'key': this.dataForm.key
|
||||||
|
// })
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data && data.code === 0) {
|
||||||
|
this.dataList = data.result.labels
|
||||||
|
// this.totalPage = data.page.totalCount
|
||||||
|
} else {
|
||||||
|
this.dataList = []
|
||||||
|
// this.totalPage = 0
|
||||||
|
}
|
||||||
|
this.dataListLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 每页数
|
||||||
|
sizeChangeHandle (val) {
|
||||||
|
this.pageSize = val
|
||||||
|
this.pageIndex = 1
|
||||||
|
this.getDataList()
|
||||||
|
},
|
||||||
|
// 当前页
|
||||||
|
currentChangeHandle (val) {
|
||||||
|
this.pageIndex = val
|
||||||
|
this.getDataList()
|
||||||
|
},
|
||||||
|
// 多选
|
||||||
|
selectionChangeHandle (val) {
|
||||||
|
this.dataListSelections = val
|
||||||
|
},
|
||||||
|
// 新增 / 修改
|
||||||
|
addOrUpdateHandle (row) {
|
||||||
|
this.addOrUpdateVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.addOrUpdate.init(row)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 删除
|
||||||
|
deleteHandle (row) {
|
||||||
|
this.$confirm(`确定删除[${row.labelName}]标签?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl('/book/label/delLabel?splId='+row.splId),
|
||||||
|
method: 'post',
|
||||||
|
// data: this.$http.adornData(ids, false)
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data && data.code === 0) {
|
||||||
|
this.$message({
|
||||||
|
message: '操作成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.getDataList()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user