新增一个渠道管理菜单
This commit is contained in:
parent
552b052ec2
commit
b69a81232f
93
src/api/channel.js
Normal file
93
src/api/channel.js
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
import request from '@/utils/request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除渠道表
|
||||||
|
* @param id
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export function DelChannel(id) {
|
||||||
|
const data = {
|
||||||
|
id: id,
|
||||||
|
};
|
||||||
|
return request({
|
||||||
|
url: '/admin/channel/delete',
|
||||||
|
method: 'GET',
|
||||||
|
params: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道表详情
|
||||||
|
* @param id
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export function InfoChannel(id) {
|
||||||
|
const data = {
|
||||||
|
id: id,
|
||||||
|
};
|
||||||
|
return request({
|
||||||
|
url: '/admin/channel/info',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道表列表
|
||||||
|
* @param pram
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export function ListChannel(pram) {
|
||||||
|
const data = {
|
||||||
|
productName: pram.productName,
|
||||||
|
productId: pram.productId,
|
||||||
|
page: pram.page,
|
||||||
|
limit: pram.limit,
|
||||||
|
};
|
||||||
|
return request({
|
||||||
|
url: '/admin/channel/list',
|
||||||
|
method: 'GET',
|
||||||
|
params: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增渠道表
|
||||||
|
* @param pram
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export function AddChannel(pram) {
|
||||||
|
const data = {
|
||||||
|
name: pram.name,
|
||||||
|
url: pram.url,
|
||||||
|
price: pram.price,
|
||||||
|
status: pram.status,
|
||||||
|
remark: pram.remark,
|
||||||
|
};
|
||||||
|
return request({
|
||||||
|
url: '/admin/channel/save',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新渠道表
|
||||||
|
* @param pram
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export function UpdateChannel(pram) {
|
||||||
|
const data = {
|
||||||
|
name: pram.name,
|
||||||
|
url: pram.url,
|
||||||
|
price: pram.price,
|
||||||
|
status: pram.status,
|
||||||
|
remark: pram.remark,
|
||||||
|
};
|
||||||
|
return request({
|
||||||
|
url: '/admin/channel/update',
|
||||||
|
method: 'post',
|
||||||
|
params: { id: pram.id },
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import Layout from '@/layout';
|
||||||
// import componentsRouter from './modules/components'
|
// import componentsRouter from './modules/components'
|
||||||
import storeRouter from './modules/store';
|
import storeRouter from './modules/store';
|
||||||
import orderRouter from './modules/order';
|
import orderRouter from './modules/order';
|
||||||
|
import channelRouter from './modules/channel';
|
||||||
import userRouter from './modules/user';
|
import userRouter from './modules/user';
|
||||||
import distributionRouter from './modules/distribution';
|
import distributionRouter from './modules/distribution';
|
||||||
import marketingRouter from './modules/marketing';
|
import marketingRouter from './modules/marketing';
|
||||||
|
@ -56,6 +57,8 @@ export const constantRoutes = [
|
||||||
storeRouter,
|
storeRouter,
|
||||||
// 订单
|
// 订单
|
||||||
orderRouter,
|
orderRouter,
|
||||||
|
//渠道
|
||||||
|
channelRouter,
|
||||||
// 会员
|
// 会员
|
||||||
userRouter,
|
userRouter,
|
||||||
// 分销
|
// 分销
|
||||||
|
|
23
src/router/modules/channel.js
Normal file
23
src/router/modules/channel.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import Layout from '@/layout';
|
||||||
|
|
||||||
|
const channelRouter = {
|
||||||
|
path: '/channel',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/channel/index',
|
||||||
|
name: 'Channel',
|
||||||
|
alwaysShow: true,
|
||||||
|
meta: {
|
||||||
|
title: '渠道',
|
||||||
|
icon: 'clipboard',
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
component: () => import('@/views/channel/index'),
|
||||||
|
name: 'ChannelIndex',
|
||||||
|
meta: { title: '渠道' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default channelRouter;
|
167
src/views/channel/creatChannel.vue
Normal file
167
src/views/channel/creatChannel.vue
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-if="dialogVisible"
|
||||||
|
title="添加渠道"
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
width="500px"
|
||||||
|
:before-close="handleClose"
|
||||||
|
>
|
||||||
|
<el-form :model="channelInfo" :rules="rules" ref="channelInfo" label-width="100px" class="demo-ruleForm" v-loading="loading">
|
||||||
|
<el-form-item label="渠道名称" prop="name">
|
||||||
|
<el-input v-model="channelInfo.name" placeholder="请输入渠道名称"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="链接" prop="url">
|
||||||
|
<el-input v-model="channelInfo.url" placeholder="请输入链接"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="单价(元)" >
|
||||||
|
<el-input-number style="width: 60%"
|
||||||
|
v-model="channelInfo.price"
|
||||||
|
:min="0"
|
||||||
|
:step="0.1"
|
||||||
|
step-strictly
|
||||||
|
placeholder="请输入单价"
|
||||||
|
class="selWidthd mr20"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开关">
|
||||||
|
<el-switch
|
||||||
|
v-model="channelInfo.status"
|
||||||
|
active-text="打开"
|
||||||
|
inactive-text="关闭"
|
||||||
|
:active-value="true"
|
||||||
|
:inactive-value="false"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注:" prop="remark">
|
||||||
|
<el-input type="textarea" v-model="channelInfo.remark"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<span slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="resetForm('channelInfo')">取 消</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="submitForm('formValidate')"
|
||||||
|
v-hasPermi="['admin:setting:update', 'admin:setting:save']"
|
||||||
|
>确 定</el-button
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { AddChannel,UpdateChannel} from '@/api/channel';
|
||||||
|
import { Debounce } from '@/utils/validate';
|
||||||
|
const obj = {
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
price: '',
|
||||||
|
status: true,
|
||||||
|
remark: '',
|
||||||
|
id: null,
|
||||||
|
};
|
||||||
|
export default {
|
||||||
|
name: 'CreatChannel',
|
||||||
|
props: {
|
||||||
|
channelInfo: Object,
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// console.log("channelInfo===="+JSON.stringify(this.channelInfo));
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
formValidate: Object.assign({}, obj),
|
||||||
|
loading: false,
|
||||||
|
rules: {
|
||||||
|
name: [{ required: true, message: '请输入渠道名称', trigger: 'blur' }],
|
||||||
|
url: [{ required: true, message: '请输入链接', trigger: 'blur' }],
|
||||||
|
price: [{ type: 'number', message: '单价必须为数字值' }],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formatPercentage(value) {
|
||||||
|
if(value == "0.00" || value == "0.0" || value == "0" || value == 0 || value == null){
|
||||||
|
return "-";
|
||||||
|
}else {
|
||||||
|
return (value * 100).toFixed(2) + '%';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// info(id) {
|
||||||
|
// this.loading = true;
|
||||||
|
// levelInfoApi({ id: id })
|
||||||
|
// .then((res) => {
|
||||||
|
// this.formValidate = res;
|
||||||
|
// this.loading = false;
|
||||||
|
// })
|
||||||
|
// .catch(() => {
|
||||||
|
// this.loading = false;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
handleClose() {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
// this.user = Object.assign({}, '')
|
||||||
|
},
|
||||||
|
submitForm: Debounce(function (formName) {
|
||||||
|
this.$refs.channelInfo.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true;
|
||||||
|
// debugger
|
||||||
|
// this.channelInfo.amountComesUp = (this.channelInfo.amountComesUpStr)/100;
|
||||||
|
// this.channelInfo.downPaymentPercent = (this.channelInfo.downPaymentPercentStr)/100;
|
||||||
|
console.log("----------- "+JSON.stringify(this.channelInfo));
|
||||||
|
let data = {
|
||||||
|
name: this.channelInfo.name,
|
||||||
|
url: this.channelInfo.url,
|
||||||
|
price: this.channelInfo.price,
|
||||||
|
status: this.channelInfo.status,
|
||||||
|
remark: this.channelInfo.remark,
|
||||||
|
id: this.channelInfo.id
|
||||||
|
};
|
||||||
|
this.channelInfo.id
|
||||||
|
? UpdateChannel(data)
|
||||||
|
.then((res) => {
|
||||||
|
this.$message.success('编辑成功');
|
||||||
|
this.loading = false;
|
||||||
|
this.handleClose();
|
||||||
|
this.formValidate = Object.assign({}, obj);
|
||||||
|
this.$parent.getList();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.loading = false;
|
||||||
|
})
|
||||||
|
: AddChannel(this.channelInfo)
|
||||||
|
.then((res) => {
|
||||||
|
this.$message.success('添加成功');
|
||||||
|
this.loading = false;
|
||||||
|
this.handleClose();
|
||||||
|
this.formValidate = Object.assign({}, obj);
|
||||||
|
this.$parent.getList();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.loading = false;
|
||||||
|
this.formValidate = Object.assign({}, obj);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
resetForm(formName) {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this[formName] = {};
|
||||||
|
// this.$nextTick(() => {
|
||||||
|
// this.$refs.formData.resetFields();
|
||||||
|
// })
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.el-input-number .el-input-group__append {
|
||||||
|
padding: 0 12px;
|
||||||
|
line-height: 36px;
|
||||||
|
border-left: 1px solid #dcdfe6;
|
||||||
|
}
|
||||||
|
</style>
|
194
src/views/channel/index.vue
Normal file
194
src/views/channel/index.vue
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
<template>
|
||||||
|
<div class="divBox">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<el-button type="primary" class="mr10" @click="add" size="small" v-hasPermi="['admin:channel:save']"
|
||||||
|
>添加渠道</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table v-loading="listLoading" :data="listData.list" style="width: 100%" size="mini">
|
||||||
|
<el-table-column prop="id" label="ID" min-width="50" />
|
||||||
|
<el-table-column prop="name" label="渠道名称" min-width="100" />
|
||||||
|
<el-table-column prop="url" label="链接" min-width="100" />
|
||||||
|
<el-table-column prop="status" label="开关" min-width="100" >
|
||||||
|
<template slot-scope="scope" v-if="checkPermi(['admin:category:update:status'])">
|
||||||
|
<el-switch
|
||||||
|
v-model="scope.row.status"
|
||||||
|
:active-value="true"
|
||||||
|
:inactive-value="false"
|
||||||
|
active-text="打开"
|
||||||
|
inactive-text="关闭"
|
||||||
|
@change="onchangeIsShow(scope.row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="price" label="单价(元)" min-width="100" />
|
||||||
|
<el-table-column label="操作" min-width="120" fixed="right" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
@click="edit(scope.row)"
|
||||||
|
class="mr10"
|
||||||
|
v-hasPermi="['admin:channel:update']"
|
||||||
|
>编辑</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
@click="handleDelete(scope.row.id, scope.$index)"
|
||||||
|
v-hasPermi="['admin:channel:delete']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="block mb20">
|
||||||
|
<el-pagination
|
||||||
|
:current-page="listPram.page"
|
||||||
|
:page-sizes="constants.page.limit"
|
||||||
|
:layout="constants.page.layout"
|
||||||
|
:total="listData.total"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
<creat-channel ref="grades" :channelInfo="channelInfo"></creat-channel>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ListChannel,AddChannel,UpdateChannel,InfoChannel,DelChannel} from '@/api/channel';
|
||||||
|
import creatChannel from './creatChannel';
|
||||||
|
import { checkPermi } from '@/utils/permission'; // 权限判断函数
|
||||||
|
export default {
|
||||||
|
name: 'Channel',
|
||||||
|
filters: {
|
||||||
|
typeFilter(status) {
|
||||||
|
const statusMap = {
|
||||||
|
wechat: '微信用户',
|
||||||
|
routine: '小程序你用户',
|
||||||
|
h5: 'H5用户',
|
||||||
|
};
|
||||||
|
return statusMap[status];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: { creatChannel },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
listLoading: true,
|
||||||
|
channelInfo: {},
|
||||||
|
constants: this.$constants,
|
||||||
|
listPram: {
|
||||||
|
productId: null,
|
||||||
|
productName: null,
|
||||||
|
page: 1,
|
||||||
|
limit: this.$constants.page.limit[0],
|
||||||
|
},
|
||||||
|
listData: { list: [], total: 0 },
|
||||||
|
tableData: {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formatPercentage(value) {
|
||||||
|
if(value == "0.00" || value == "0.0" || value == "0" || value == 0 || value == null){
|
||||||
|
return "-";
|
||||||
|
}else {
|
||||||
|
return (value * 100).toFixed(2) + '%';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatNumber(value){
|
||||||
|
if(value == 0){
|
||||||
|
return "-";
|
||||||
|
}else {
|
||||||
|
return value + "期";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkPermi,
|
||||||
|
seachList() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
add() {
|
||||||
|
this.$refs.grades.dialogVisible = true;
|
||||||
|
this.channelInfo = {status:true};
|
||||||
|
},
|
||||||
|
edit(channelInfo) {
|
||||||
|
// this.$refs.grades.info(id)
|
||||||
|
// user.amountComesUpStr = user.amountComesUp*100;
|
||||||
|
// user.downPaymentPercentStr = user.downPaymentPercent*100;
|
||||||
|
this.channelInfo = channelInfo;
|
||||||
|
this.$refs.grades.dialogVisible = true;
|
||||||
|
},
|
||||||
|
// 列表
|
||||||
|
getList() {
|
||||||
|
this.listLoading = true;
|
||||||
|
ListChannel(this.listPram)
|
||||||
|
.then((res) => {
|
||||||
|
this.listData = res;
|
||||||
|
this.listLoading = false;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.listLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 删除
|
||||||
|
handleDelete(id, idx) {
|
||||||
|
this.$modalSure('删除吗?删除会导致对应渠道数据清空,请谨慎操作!').then(() => {
|
||||||
|
DelChannel(id).then(() => {
|
||||||
|
this.$message.success('删除成功');
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSizeChange(val) {
|
||||||
|
this.listPram.limit = val;
|
||||||
|
this.handlerGetListData(this.listPram);
|
||||||
|
},
|
||||||
|
handleCurrentChange(val) {
|
||||||
|
this.listPram.page = val;
|
||||||
|
this.handlerGetListData(this.listPram);
|
||||||
|
},
|
||||||
|
onchangeIsShow(row) {
|
||||||
|
if (row.isShow == false) {
|
||||||
|
row.isShow = !row.isShow;
|
||||||
|
UpdateChannel({ id: row.id, isShow: row.isShow })
|
||||||
|
.then(() => {
|
||||||
|
this.$message.success('修改成功');
|
||||||
|
this.getList();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
row.isShow = !row.isShow;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$modalSure('确定修改渠道状态吗?').then(() => {
|
||||||
|
row.isShow = !row.isShow;
|
||||||
|
// console.log("row-----------"+JSON.stringify(row))
|
||||||
|
UpdateChannel(row)
|
||||||
|
.then(() => {
|
||||||
|
this.$message.success('修改成功');
|
||||||
|
this.getList();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
row.isShow = !row.isShow;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.el-switch.is-disabled {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
::v-deep .el-switch__label {
|
||||||
|
cursor: pointer !important;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -719,7 +719,7 @@ export default {
|
||||||
// 发送
|
// 发送
|
||||||
sendOrder(row) {
|
sendOrder(row) {
|
||||||
this.orderDetail = null;
|
this.orderDetail = null;
|
||||||
if (row.type === 0) {
|
if (row.type === 0 || row.type === 2) {
|
||||||
this.$refs.send.modals = true;
|
this.$refs.send.modals = true;
|
||||||
//默认加载Normal物流公司
|
//默认加载Normal物流公司
|
||||||
this.$refs.send.express = this.expressListNormal;
|
this.$refs.send.express = this.expressListNormal;
|
||||||
|
|
|
@ -142,7 +142,7 @@ export default {
|
||||||
},
|
},
|
||||||
// 删除
|
// 删除
|
||||||
handleDelete(id, idx) {
|
handleDelete(id, idx) {
|
||||||
this.$modalSure('删除吗?删除会导致对应用户等级数据清空,请谨慎操作!').then(() => {
|
this.$modalSure('删除吗?删除会导致对应分期套餐配置数据清空,请谨慎操作!').then(() => {
|
||||||
DelInstallments(id).then(() => {
|
DelInstallments(id).then(() => {
|
||||||
this.$message.success('删除成功');
|
this.$message.success('删除成功');
|
||||||
this.getList();
|
this.getList();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user