退货原因管理完善
This commit is contained in:
parent
76529b209f
commit
c4870aac99
47
src/api/returnReason.js
Normal file
47
src/api/returnReason.js
Normal file
@ -0,0 +1,47 @@
|
||||
import request from '@/utils/request'
|
||||
export function fetchList(params) {
|
||||
return request({
|
||||
url:'/returnReason/list',
|
||||
method:'get',
|
||||
params:params
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteReason(params) {
|
||||
return request({
|
||||
url:'/returnReason/delete',
|
||||
method:'post',
|
||||
params:params
|
||||
})
|
||||
}
|
||||
|
||||
export function updateStatus(params) {
|
||||
return request({
|
||||
url:'/returnReason/update/status',
|
||||
method:'post',
|
||||
params:params
|
||||
})
|
||||
}
|
||||
|
||||
export function addReason(data) {
|
||||
return request({
|
||||
url:'/returnReason/create',
|
||||
method:'post',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
|
||||
export function getReasonDetail(id) {
|
||||
return request({
|
||||
url:'/returnReason/'+id,
|
||||
method:'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function updateReason(id,data) {
|
||||
return request({
|
||||
url:'/returnReason/update/'+id,
|
||||
method:'post',
|
||||
data:data
|
||||
})
|
||||
}
|
@ -1,13 +1,273 @@
|
||||
<template>
|
||||
<div> {{msg}}</div>
|
||||
<div class="app-container">
|
||||
<el-card class="operate-container" shadow="never">
|
||||
<i class="el-icon-tickets"></i>
|
||||
<span>数据列表</span>
|
||||
<el-button
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
class="btn-add">添加
|
||||
</el-button>
|
||||
</el-card>
|
||||
<div class="table-container">
|
||||
<el-table ref="returnReasonTable"
|
||||
:data="list"
|
||||
style="width: 100%;"
|
||||
@selection-change="handleSelectionChange"
|
||||
v-loading="listLoading" border>
|
||||
<el-table-column type="selection" width="60" align="center"></el-table-column>
|
||||
<el-table-column label="编号" width="80" align="center">
|
||||
<template slot-scope="scope">{{scope.row.id}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="原因类型" align="center">
|
||||
<template slot-scope="scope">{{scope.row.name}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排序" width="100" align="center">
|
||||
<template slot-scope="scope">{{scope.row.sort }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否可用" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.status"
|
||||
@change="handleStatusChange(scope.$index,scope.row)"
|
||||
:active-value="1"
|
||||
:inactive-value="0">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="添加时间" width="180" align="center">
|
||||
<template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
@click="handleUpdate(scope.$index, scope.row)">编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="batch-operate-container">
|
||||
<el-select
|
||||
size="small"
|
||||
v-model="operateType" placeholder="批量操作">
|
||||
<el-option
|
||||
v-for="item in operateOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button
|
||||
style="margin-left: 20px"
|
||||
class="search-button"
|
||||
@click="handleBatchOperate"
|
||||
type="primary"
|
||||
size="small">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
background
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
layout="total, sizes,prev, pager, next,jumper"
|
||||
:current-page.sync="listQuery.pageNum"
|
||||
:page-size="listQuery.pageSize"
|
||||
:page-sizes="[5,10,15]"
|
||||
:total="total">
|
||||
</el-pagination>
|
||||
</div>
|
||||
<el-dialog
|
||||
title="添加退货原因"
|
||||
:visible.sync="dialogVisible" width="30%">
|
||||
<el-form :model="returnReason"
|
||||
ref="reasonForm" label-width="150px">
|
||||
<el-form-item label="原因类型:">
|
||||
<el-input v-model="returnReason.name" class="input-width"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序:">
|
||||
<el-input v-model="returnReason.sort" class="input-width"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否启用:">
|
||||
<el-switch v-model="returnReason.status" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleConfirm">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {formatDate} from '@/utils/date';
|
||||
import {fetchList,deleteReason,updateStatus,addReason,getReasonDetail,updateReason} from '@/api/returnReason';
|
||||
const defaultListQuery = {
|
||||
pageNum: 1,
|
||||
pageSize: 5
|
||||
};
|
||||
const defaultReturnReason = {
|
||||
name:null,
|
||||
sort:0,
|
||||
status:1,
|
||||
createTime:null
|
||||
};
|
||||
export default {
|
||||
name: 'returnReasonList',
|
||||
data() {
|
||||
return {msg: '退货原因列表'}
|
||||
return {
|
||||
list: null,
|
||||
total: null,
|
||||
multipleSelection: [],
|
||||
listLoading:true,
|
||||
listQuery:Object.assign({}, defaultListQuery),
|
||||
operateType:null,
|
||||
operateOptions: [
|
||||
{
|
||||
label: "删除",
|
||||
value: 1
|
||||
}
|
||||
],
|
||||
dialogVisible:false,
|
||||
returnReason:Object.assign({},defaultReturnReason),
|
||||
operateReasonId:null
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.getList();
|
||||
},
|
||||
filters:{
|
||||
formatCreateTime(time) {
|
||||
let date = new Date(time);
|
||||
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleAdd() {
|
||||
this.dialogVisible=true;
|
||||
this.operateReasonId=null;
|
||||
this.returnReason=Object.assign({},defaultReturnReason);
|
||||
},
|
||||
handleConfirm(){
|
||||
if(this.operateReasonId==null){
|
||||
//添加操作
|
||||
addReason(this.returnReason).then(response=>{
|
||||
this.dialogVisible=false;
|
||||
this.operateReasonId=null;
|
||||
this.$message({
|
||||
message: '添加成功!',
|
||||
type: 'success',
|
||||
duration:1000
|
||||
});
|
||||
this.getList();
|
||||
});
|
||||
}else{
|
||||
//编辑操作
|
||||
updateReason(this.operateReasonId,this.returnReason).then(response=>{
|
||||
this.dialogVisible=false;
|
||||
this.operateReasonId=null;
|
||||
this.$message({
|
||||
message: '修改成功!',
|
||||
type: 'success',
|
||||
duration:1000
|
||||
});
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
},
|
||||
handleUpdate(index, row){
|
||||
this.dialogVisible=true;
|
||||
this.operateReasonId=row.id;
|
||||
getReasonDetail(row.id).then(response=>{
|
||||
this.returnReason=response.data;
|
||||
});
|
||||
},
|
||||
handleDelete(index, row){
|
||||
let ids=[];
|
||||
ids.push(row.id);
|
||||
this.deleteReason(ids);
|
||||
},
|
||||
handleSelectionChange(val){
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
handleStatusChange(index,row){
|
||||
let ids=[];
|
||||
ids.push(row.id);
|
||||
let param = new URLSearchParams();
|
||||
param.append("status",row.status);
|
||||
param.append("ids",ids);
|
||||
updateStatus(param).then(response=>{
|
||||
this.$message({
|
||||
message: '状态修改成功',
|
||||
type: 'success'
|
||||
});
|
||||
});
|
||||
},
|
||||
handleBatchOperate(){
|
||||
if(this.multipleSelection==null||this.multipleSelection.length<1){
|
||||
this.$message({
|
||||
message: '请选择要操作的条目',
|
||||
type: 'warning',
|
||||
duration: 1000
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(this.operateType===1){
|
||||
let ids=[];
|
||||
for(let i=0;i<this.multipleSelection.length;i++){
|
||||
ids.push(this.multipleSelection[i].id);
|
||||
}
|
||||
this.deleteReason(ids);
|
||||
}
|
||||
},
|
||||
handleSizeChange(val){
|
||||
this.listQuery.pageNum = 1;
|
||||
this.listQuery.pageSize = val;
|
||||
this.getList();
|
||||
},
|
||||
handleCurrentChange(val){
|
||||
this.listQuery.pageNum = val;
|
||||
this.getList();
|
||||
},
|
||||
getList(){
|
||||
this.listLoading = true;
|
||||
fetchList(this.listQuery).then(response => {
|
||||
this.listLoading = false;
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
});
|
||||
},
|
||||
deleteReason(ids){
|
||||
this.$confirm('是否要进行该删除操作?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let params = new URLSearchParams();
|
||||
params.append("ids",ids);
|
||||
deleteReason(params).then(response=>{
|
||||
this.$message({
|
||||
message: '删除成功!',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
this.listQuery.pageNum=1;
|
||||
this.getList();
|
||||
});
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
<style scoped>
|
||||
.input-width {
|
||||
width: 80%;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
@ -182,7 +182,7 @@
|
||||
|
||||
const defaultListQuery = {
|
||||
pageNum: 1,
|
||||
pageSize: 5,
|
||||
pageSize: 10,
|
||||
orderSn: null,
|
||||
receiverKeyword: null,
|
||||
status: null,
|
||||
@ -420,6 +420,11 @@
|
||||
let params = new URLSearchParams();
|
||||
params.append("ids",ids);
|
||||
deleteOrder(params).then(response=>{
|
||||
this.$message({
|
||||
message: '删除成功!',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
this.getList();
|
||||
});
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user