commit message

This commit is contained in:
Chopper
2021-05-13 10:56:04 +08:00
commit ec3e958037
728 changed files with 132685 additions and 0 deletions

View File

@@ -0,0 +1,465 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Row @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
<Form-item label="系统类型" prop="orderSn">
<Select
v-model="searchForm.type"
placeholder="请选择系统类型"
clearable
style="width: 200px"
>
<Option value="IOS">苹果</Option>
<Option value="ANDROID">安卓</Option>
</Select>
</Form-item>
<Form-item style="margin-left:-35px;" class="br">
<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
</Form-item>
</Form>
</Row>
<Row class="operation" style="margin-top: 20px">
<Button @click="addAppVersion" type="primary">添加</Button>
</Row>
<Row class="padding-row">
<Table
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
></Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</Card>
</Col>
</Row>
<Modal
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="1000"
>
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="版本名称" prop="versionName">
<Input v-model="form.versionName" maxlength="15" clearable style="width: 40%"/>
</FormItem>
<FormItem label="版本号" prop="version">
<Input v-model="form.version" maxlength="15" clearable style="width: 40%"/>
</FormItem>
<FormItem label="更新时间" prop="versionUpdateDate">
<DatePicker
v-model="form.versionUpdateDate"
type="datetime"
format="yyyy-MM-dd HH:mm:ss"
clearable
placeholder="请选择"
style="width: 200px"
></DatePicker>
</FormItem>
<FormItem label="强制更新">
<RadioGroup v-model="form.forceUpdate">
<Radio label="1">强制更新</Radio>
<Radio label="0">非强制更新</Radio>
</RadioGroup>
</FormItem>
<FormItem label="类型">
<RadioGroup v-model="form.type">
<Radio label="IOS">苹果</Radio>
<Radio label="ANDROID">安卓</Radio>
</RadioGroup>
</FormItem>
<FormItem label="下载地址" prop="downloadUrl">
<Input v-model="form.downloadUrl" maxlength="100" clearable style="width: 40%"/>
</FormItem>
<FormItem class="form-item-view-el" label="更新内容" prop="content">
<editor v-model="form.content"></editor>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="saveAppVersion">保存</Button>
</div>
</Modal>
<div>
<!-- 查看版本信息 -->
<Modal
:title="queryModalTitle"
v-model="queryModalVisible"
:width="700"
>
<Form>
<div class="div-version">
<FormItem label="版本名称:">
{{form.versionName}}
</FormItem>
</div>
<div class="div-version">
<FormItem label="版本号:">
{{form.version}}
</FormItem>
</div>
<FormItem label="更新时间:">
<div>
{{versionUpdateDate}}
</div>
</FormItem>
<FormItem label="强制更新:">
<span v-if="form.forceUpdate == 1">强制更新</span>
<span v-else>非强制更新</span>
</FormItem>
<FormItem label="类型">
<span v-if="form.type == 'IOS'">IOS</span>
<span v-else>安卓</span>
</FormItem>
<FormItem label="下载地址:">
{{form.downloadUrl}}
</FormItem>
<FormItem label="更新内容:">
<div v-html="form.content">
</div>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="queryModalVisible = false">取消</Button>
</div>
</Modal>
</div>
</div>
</template>
<script>
import * as API_Setting from "@/api/setting";
import editor from "@/views/my-components/lili/editor";
export default {
name: "orderList",
components: {
editor
},
data() {
return {
queryModalVisible: false,
queryModalTitle: "查看更新信息",
loading: true, // 表单加载状态
modalVisible: false, // 添加app版本模态框
modalTitle: "", // 添加app版本标题
modalType: 0,
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
type: ""
},
selectDate: null,
form: {
// 添加或编辑表单对象初始化数据
versionName: "",
version: "",
forceUpdate: 1,
type: "IOS",
downloadUrl: "",
content: "",
versionUpdateDate: ""
},
versionUpdateDate: "",
// 表单验证规则
formValidate: {
version: [
{required: true, message: '版本号不能为空', trigger: 'blur'},
],
versionName: [
{required: true, message: '版本名称不能为空', trigger: 'blur'},
],
downloadUrl: [
{required: true, message: '下载地址不能为空', trigger: 'blur'},
],
versionUpdateDate: [{required: true, message: "更新时间不能为空"}],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
{
title: "版本名称",
key: "versionName",
minWidth: 100,
},
{
title: "版本号",
key: "version",
minWidth: 120,
},
{
title: "强制更新",
key: "forceUpdate",
width: 100,
render: (h, params) => {
return h(
"div",
{
props: {
color: params.row.forceUpdate ? "primary" : "default",
},
},
params.row.forceUpdate == 0 ? "非强制" : "强制"
);
}
},
{
title: "类型",
key: "type",
minWidth: 80,
render: (h, params) => {
if (params.row.type == "IOS") {
return h('div', [h('span', {}, '苹果'),]);
} else {
return h('div', [h('span', {}, '安卓'),]);
}
}
},
{
title: "更新时间",
key: "versionUpdateDate",
minWidth: 120,
sortable: true,
},
{
title: "操作",
key: "action",
align: "center",
width: 230,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "info",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.detail(params.row);
},
},
},
"查看"
),
h(
"Button",
{
props: {
type: "info",
size: "small",
ghost:true
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.editAppVersion(params.row);
},
},
},
"修改"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.remove(params.row);
},
},
},
"删除"
),
]);
},
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
};
},
methods: {
init() {
this.getData();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getData();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getData();
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getData();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getData();
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
getData() {
this.loading = true;
API_Setting.appVersionPage(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
this.total = this.data.length;
this.loading = false;
},
//添加app版本信息
addAppVersion() {
this.modalVisible = true;
this.modalTitle = "添加APP版本信息"
const versionUpdateDate = this.$options.filters.unixToDate(
new Date() / 1000
);
this.form = {
forceUpdate: 0,
type: "IOS",
versionUpdateDate: versionUpdateDate,
content: " "
}
},
//添加app版本信息
editAppVersion(v) {
this.modalVisible = true;
this.modalTitle = "修改APP版本信息"
this.modalType = 1
this.form = v
},
//保存app版本信息
saveAppVersion() {
this.$refs.form.validate((valid) => {
if (valid) {
this.submitLoading = true;
const versionUpdateDate = this.$options.filters.unixToDate(
this.form.versionUpdateDate / 1000
);
this.form.versionUpdateDate = versionUpdateDate
this.form.updateTime = versionUpdateDate
if (this.modalType == 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.form.id;
API_Setting.addVersion(this.form).then((res) => {
this.submitLoading = false;
if (res && res.success) {
this.$Message.success("添加成功");
this.modalVisible = false
this.getData();
}
});
} else {
API_Setting.editVersion(this.form, this.form.id).then((res) => {
this.submitLoading = false;
if (res && res.success) {
this.$Message.success("修改成功");
this.modalVisible = false
this.getData();
}
});
}
}
})
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除么?",
loading: true,
onOk: () => {
// 删除
API_Setting.deleteVersion(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getData();
}
});
}
});
},
detail(v) {
this.queryModalVisible = true
this.form = JSON.parse(JSON.stringify(v))
//时间格式化有问题,所以另外单独给时间赋值
this.versionUpdateDate = this.form.versionUpdateDate
},
},
mounted() {
this.init();
},
};
</script>
<style lang="scss" scoped>
.ivu-form-item {
margin-bottom: 14px;
vertical-align: top;
zoom: 1;
}
.search-form{
width: 100%;
}
// 建议引入通用样式 可删除下面样式代码
@import "@/styles/table-common.scss";
</style>

View File

@@ -0,0 +1,474 @@
<template>
<div class="search">
<Card>
<Row class="operation">
<i-switch v-model="strict" size="large" style="margin-right: 5px">
<span slot="open">级联</span>
<span slot="close">单选</span>
</i-switch>
<Button @click="addRoot">添加部门</Button>
<Button @click="add" type="primary">添加子部门</Button>
<Button @click="delAll">批量删除</Button>
<Button @click="getParentList">刷新</Button>
</Row>
<Row type="flex" justify="start">
<Col :md="8" :lg="8" :xl="6">
<Alert show-icon>
当前选择编辑
<span class="select-title">{{ editTitle }}</span>
<a class="select-clear" v-if="form.id" @click="cancelEdit"
>取消选择</a
>
</Alert>
<!-- <Input
v-model="searchKey"
suffix="ios-search"
@on-change="search"
placeholder="输入部门名搜索"
clearable
/> -->
<div class="tree-bar" :style="{ maxHeight: maxHeight }">
<Tree
ref="tree"
:data="data"
:load-data="loadData"
show-checkbox
@on-check-change="changeSelect"
@on-select-change="selectTree"
:check-strictly="!strict"
></Tree>
<Spin size="large" fix v-if="loading"></Spin>
</div>
</Col>
<Col :md="15" :lg="13" :xl="9" style="margin-left: 10px">
<Form
ref="form"
:model="form"
:label-width="100"
:rules="formValidate"
>
<FormItem label="上级部门" prop="parentTitle">
<div style="display: flex">
<Input
v-model="form.parentTitle"
readonly
style="margin-right: 10px"
/>
<Poptip
transfer
trigger="click"
placement="right-start"
title="选择上级部门"
width="250"
>
<Button icon="md-list">选择部门</Button>
<div
slot="content"
style="position: relative; min-height: 5vh"
>
<Tree
:data="dataEdit"
:load-data="loadData"
@on-select-change="selectTreeEdit"
></Tree>
<Spin size="large" fix v-if="loadingEdit"></Spin>
</div>
</Poptip>
</div>
</FormItem>
<FormItem label="部门名称" prop="title">
<Input v-model="form.title" />
</FormItem>
<FormItem label="选择角色">
<Select
:loading="userLoading"
not-found-text="暂无角色"
v-model="selectedRole"
multiple
>
<Option v-for="item in users" :value="item.id" :key="item.id">{{
item.name
}}</Option>
</Select>
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="form.sortOrder"
></InputNumber>
</Tooltip>
</FormItem>
<!-- <FormItem label="是否启用" prop="status">
<i-switch size="large" v-model="form.status" :true-value="0" :false-value="-1">
<span slot="open">启用</span>
<span slot="close">禁用</span>
</i-switch>
</FormItem> -->
<Form-item>
<Button
style="margin-right: 5px"
@click="submitEdit"
:loading="submitLoading"
type="primary"
>修改并保存</Button
>
<Button @click="handleReset">重置</Button>
</Form-item>
</Form>
</Col>
</Row>
</Card>
<Modal
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="500"
>
<Form
ref="formAdd"
:model="formAdd"
:label-width="85"
:rules="formValidate"
>
<div v-if="showParent">
<FormItem label="上级部门:">{{ form.title }}</FormItem>
</div>
<FormItem label="部门名称" prop="title">
<Input v-model="formAdd.title" />
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="formAdd.sortOrder"
></InputNumber>
</Tooltip>
</FormItem>
<!-- <FormItem label="是否启用" prop="status">
<i-switch size="large" v-model="formAdd.status" :true-value="0" :false-value="-1">
<span slot="open">启用</span>
<span slot="close">禁用</span>
</i-switch>
</FormItem> -->
</Form>
<div slot="footer">
<Button type="text" @click="cancelAdd">取消</Button>
<Button type="primary" :loading="submitLoading" @click="submitAdd"
>提交</Button
>
</div>
</Modal>
</div>
</template>
<script>
import {
initDepartment,
loadDepartment,
addDepartment,
editDepartment,
deleteDepartment,
searchDepartment,
getUserByDepartmentId,
getRoleList,
updateDepartmentRole,
} from "@/api/index";
export default {
name: "department-manage",
data() {
return {
loading: true,
maxHeight: "500px",
strict: true,
userLoading: false,
loadingEdit: true,
modalVisible: false,
selectList: [],
selectCount: 0,
showParent: false,
modalTitle: "",
editTitle: "",
selectedRole: [], //选择的角色
searchKey: "",
form: {
id: "",
title: "",
parentId: "",
parentTitle: "",
sortOrder: 0,
status: 0,
},
formAdd: {},
formValidate: {
title: [{ required: true, message: "名称不能为空", trigger: "blur" }],
sortOrder: [
{
required: true,
type: "number",
message: "排序值不能为空",
trigger: "blur",
},
],
},
submitLoading: false,
data: [],
dataEdit: [],
users: [],
};
},
methods: {
init() {
this.getParentList();
},
getParentList() {
this.loading = true;
initDepartment().then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result;
}
});
},
loadData(item, callback) {
loadDepartment(item.id).then((res) => {
if (res.success) {
/* res.result.forEach(function(e) {
if (e.isParent) {
e.loading = false;
e.children = [];
}
}); */
callback(res.result);
}
});
},
search() {
if (this.searchKey) {
this.loading = true;
searchDepartment({ title: this.searchKey }).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result;
}
});
} else {
this.getParentList();
}
},
// 点击树
selectTree(v) {
if (v.length > 0) {
// 转换null为""
for (let attr in v[0]) {
if (v[0][attr] == null) {
v[0][attr] = "";
}
}
let str = JSON.stringify(v[0]);
let data = JSON.parse(str);
this.editTitle = data.title;
// 加载部门用户数据
this.userLoading = true;
getUserByDepartmentId(data.id).then((res) => {
let way =[]
res.result && res.result.forEach((item) => {
way.push(item.roleId)
})
this.$set(this,'selectedRole',way)
console.warn( this.selectedRole);
});
getRoleList({
pageNumber: 1,
pageSize: 10000,
}).then((res) => {
this.userLoading = false;
console.log(res);
if (res.success) {
this.users = res.result.records;
// 回显
this.form = data;
}
});
} else {
this.cancelEdit();
}
},
cancelEdit() {
let data = this.$refs.tree.getSelectedNodes()[0];
if (data) {
data.selected = false;
}
this.$refs.form.resetFields();
delete this.form.id;
this.editTitle = "";
},
selectTreeEdit(v) {
if (v.length > 0) {
// 转换null为""
for (let attr in v[0]) {
if (v[0][attr] == null) {
v[0][attr] = "";
}
}
let str = JSON.stringify(v[0]);
let data = JSON.parse(str);
this.form.parentId = data.id;
this.form.parentTitle = data.title;
}
},
cancelAdd() {
this.modalVisible = false;
},
handleReset() {
this.$refs.form.resetFields();
this.form.status = 0;
},
submitEdit() {
this.$refs.form.validate((valid) => {
if (valid) {
if (!this.form.id) {
this.$Message.warning("请先点击选择要修改的部门");
return;
}
console.log(this.selectedRole);
let roleWay = [];
this.selectedRole.forEach((item) => {
let role = {
departmentId: this.form.id,
roleId: item,
};
roleWay.push(role);
});
Promise.all([
editDepartment(this.form.id, this.form),
updateDepartmentRole(
this.form.id,
roleWay
),
]).then((res) => {
this.submitLoading = false;
if (res[0].success) {
this.$Message.success("编辑成功");
this.init();
this.modalVisible = false;
}
console.log(res[1]);
});
}
});
},
submitAdd() {
this.$refs.formAdd.validate((valid) => {
if (valid) {
this.submitLoading = true;
addDepartment(this.formAdd).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("添加成功");
this.init();
this.modalVisible = false;
}
});
}
});
},
add() {
if (this.form.id == "" || this.form.id == null) {
this.$Message.warning("请先点击选择一个部门");
return;
}
this.modalTitle = "添加子部门";
this.showParent = true;
this.formAdd = {
parentId: this.form.id,
sortOrder: 0,
status: 0,
};
this.modalVisible = true;
},
addRoot() {
this.modalTitle = "添加一级部门";
this.showParent = false;
this.formAdd = {
parentId: 0,
sortOrder: 0,
status: 0,
};
this.modalVisible = true;
},
changeSelect(v) {
console.log(v);
this.selectCount = v.length;
this.selectList = v;
},
delAll() {
if (this.selectCount <= 0) {
this.$Message.warning("您还未勾选要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content:
"您确认要删除所选的 " + this.selectCount + " 条数据及其下级所有数据?",
loading: true,
onOk: () => {
let ids = "";
this.selectList.forEach(function (e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
deleteDepartment(ids).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.selectList = [];
this.selectCount = 0;
this.cancelEdit();
this.init();
}
});
},
});
},
},
mounted() {
// 计算高度
let height = document.documentElement.clientHeight;
this.maxHeight = Number(height - 287) + "px";
this.init();
},
};
</script>
<style lang="scss" scoped>
@import "@/styles/tree-common.scss";
</style>

View File

@@ -0,0 +1,231 @@
<template>
<Card class="card">
<div v-for="(item,index) in instantDelivery" :key="index">
<div class="cardBox">
<div class="methodItem">
<span v-if="item.image = ''">暂无封面</span>
<img v-else :src=item.images height="172" width="440"/>
<h4>{{item.deliveryName}}</h4></div>
<div class="bar">
<div v-if="item.deliveryOpen==1" class="status" style="color: rgb(53, 189, 129);">已启用</div>
<div v-else class="status" style="color: rgb(53, 189, 129);">
<a class="links" style="color: rgb(53, 189, 129);" @click="openDelivery(item)">启用</a>&nbsp;<span
style="color: red;">(未启用)</span>
</div>
<div class="div-edit">
<Upload
multiple
:action=action
:show-upload-list="false"
:format="['jpg', 'jpeg', 'png', 'gif']"
:on-success="uploadSuccess"
>
<a class="links" @click="deliveryBean = item.deliveryBean">更换封面</a>
</Upload>
</div>
<div>
<a class="links" @click="edit">编辑</a>
</div>
</div>
</div>
<Modal
:title="modalTitle"
v-model="modalVisible"
:width="500"
>
<Form ref="form" :model="form" :label-width="90">
<Form-item :label="config.name" v-for="(config,q) in item.configItems" :key="config">
<div>
<Input
type="text"
v-model="config.value"
clearable
placeholder="请输入您的请求参数,均不能为空"
style="width: 300px"
v-if="config.type == 'text'"
/>
</div>
</Form-item>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="saveDeliverySubmit(item)">保存</Button>
</div>
</Modal>
</div>
</Card>
</template>
<script>
import * as API_Setting from "@/api/setting";
import editor from "@/views/my-components/lili/editor";
import {commonUrl} from '@/libs/axios'
export default {
name: "instantDelivery",
components: {
editor
},
data() {
return {
deliveryBean: "",
action: commonUrl + '/common/upload/file',
loading: true, // 表单加载状态
modalVisible: false, // 修改同城配送模态框
modalTitle: "", // 修改同城配送标题
instantDelivery: [{
configItems: []
}
], //同城配送数据
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
selectDate: null,
form: {},
// 表单验证规则
formValidate: {},
submitLoading: false, // 添加或编辑提交状态
};
},
methods: {
init() {
this.getData();
},
//修改同城配送方案
edit() {
this.modalVisible = true
this.modalTitle = "编辑同城配送"
},
saveDeliverySubmit(item) {
const headers = {
"Content-Type": "application/json;charset=utf-8"
}
this.loading = true
API_Setting.editInstantDelivery(item.deliveryBean, item.configItems, headers).then((res) => {
this.loading = false;
if (res.success) {
this.instantDelivery = (res.result.records);
this.modalVisible = false
this.$Message.success("保存成功");
this.getData()
}
});
},
//开启某个同城配送
openDelivery(item) {
this.$Modal.confirm({
title: "确定开启?",
content: "确认开启当前同城配送方案",
onOk: () => {
API_Setting.openInstantDelivery(item.deliveryBean).then((res) => {
if (res.success) {
this.$Message.success("开启成功");
this.getData();
}
});
},
});
},
//封面上传成功方法
uploadSuccess(res) {
const params = {
images: res.result
}
this.loading = true
API_Setting.editInstantDeliveryImage(this.deliveryBean, params).then((res) => {
this.loading = false;
if (res.success) {
this.$Message.success("更换成功");
this.getData()
}
});
},
getData() {
this.loading = true;
API_Setting.getInstantDelivery(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.instantDelivery = res.result.records;
}
});
this.loading = false;
},
},
mounted() {
this.init();
},
};
</script>
<style lang="scss" scoped>
.cardBox {
display: inline-block;
border-radius: 2px;
line-height: 1.5;
margin-right: 20px;
width: 300px;
border: 1px solid #eee;
padding: 10px;
}
.methodItem {
width: 100%;
border: 1px solid #f5f5f5;
text-align: center;
padding: 20px 0;
}
methodItem img {
width: 220px;
height: 86px;
}
methodItem h4 {
font-size: 14px;
color: #333;
margin-top: 5px;
}
.methodItem img {
width: 220px;
height: 86px;
}
.div-edit {
margin-left: 50px
}
.bar {
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 10px 8px 0;
}
.ivu-upload {
height: 21px;
margin-left: 15px;
}
</style>

View File

@@ -0,0 +1,330 @@
<style lang="scss">
@import "@/styles/table-common.scss";
</style>
<template>
<div class="search">
<Card>
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
<Form-item label="搜索日志" prop="searchKey">
<Input
type="text"
v-model="searchForm.searchKey"
placeholder="请输入搜索日志内容"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="操作人" prop="operatorName">
<Input
type="text"
v-model="searchForm.operatorName"
placeholder="请输入操作人"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="创建时间">
<DatePicker
type="daterange"
v-model="selectDate"
format="yyyy-MM-dd"
clearable
@on-change="selectDateRange"
placeholder="选择起始时间"
style="width: 200px"
></DatePicker>
</Form-item>
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
</Form>
</Row>
<Row class="operation padding-row">
<Button @click="getLogList" icon="md-refresh">刷新</Button>
<Button type="dashed" @click="openTip=!openTip">{{openTip ? "关闭提示" : "开启提示"}}</Button>
</Row>
<Row v-show="openTip">
<Alert show-icon>
<span>展示详细内容</span>
<Icon type="ios-bulb-outline" slot="icon"></Icon>
<i-switch
size="large"
v-model="showDev"
>
<span slot="open">开发</span>
<span slot="close">普通</span>
</i-switch>
</Alert>
</Row>
<Row>
<Table
v-if="showDev"
:loading="loading"
border
:columns="columns_dev"
:data="data"
ref="table"
sortable="custom"
>
</Table>
<Table
v-else
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
>
</Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10,20,50]"
size="small"
show-totalzx
show-elevator
show-sizer
></Page>
</Row>
</Card>
</div>
</template>
<script>
import {getLogListData} from "@/api/index";
export default {
name: "log-manage",
data() {
return {
openSearch: true,
openTip: false,
loading: true,
selectList: [],
selectCount: 0,
selectDate: null,
searchKey: "",
operatorName: "",
showDev: false,//展示进阶日志
searchForm: {
type: 1,
pageNumber: 1,
pageSize: 10,
startDate: "",
endDate: "",
sort: "createTime",
order: "desc"
},
columns: [
{
title: "操作名称",
key: "name",
width: 150,
fixed: "left",
ellipsis: false,
tooltip: true
},
{
title: "日志内容",
key: "customerLog",
minWidth: 200,
fixed: "left",
ellipsis: false,
tooltip: true
},
{
title: "操作用户",
minWidth: 115,
key: "username",
width: 120,
tooltip: true
},
{
title: "操作时间",
key: "createTime",
align: "center",
width: 170
}
],
columns_dev: [
{
title: "操作名称",
key: "name",
minWidth: 100,
fixed: "left",
ellipsis: false,
tooltip: true
},
{
title: "日志内容",
key: "customerLog",
minWidth: 120,
fixed: "left",
ellipsis: false,
tooltip: true,
},
{
title: "操作用户",
key: "username",
width: 115,
},
{
title: "IP",
key: "ip",
width: 150
},
{
title: "IP信息",
key: "ipInfo",
width: 150,
ellipsis: false,
tooltip: true,
},
{
title: "请求路径",
width: 150,
ellipsis: false,
tooltip: true,
key: "requestUrl"
},
{
title: "请求类型",
key: "requestType",
width: 130,
align: "center",
filters: [
{
label: "GET",
value: "GET"
},
{
label: "POST",
value: "POST"
},
{
label: "PUT",
value: "PUT"
},
{
label: "DELETE",
value: "DELETE"
}
],
filterMultiple: false,
filterMethod(value, row) {
if (value == "GET") {
return row.requestType == "GET";
} else if (value == "POST") {
return row.requestType == "POST";
} else if (value == "PUT") {
return row.requestType == "PUT";
} else if (value == "DELETE") {
return row.requestType == "DELETE";
}
}
},
{
title: "请求参数",
minWidth: 100,
key: "requestParam",
ellipsis: false,
tooltip: true
},
{
title: "耗时-毫秒",
key: "costTime",
width: 140,
align: "center",
filters: [
{
label: "≤300毫秒",
value: 0
},
{
label: "300毫秒<x<1000毫秒",
value: 0.3
},
{
label: ">1000毫秒",
value: 1
}
],
filterMultiple: false,
filterMethod(value, row) {
if (value == 0) {
return row.costTime <= 300;
} else if (value == 0.3) {
return row.costTime > 300 && row.costTime < 1000;
} else {
return row.costTime > 1000;
}
}
},
{
title: "操作时间",
key: "createTime",
align: "center",
width: 170,
sortType: "desc"
}
],
data: [],
total: 0
};
},
methods: {
init() {
this.getLogList();
},
changeTab(v) {
this.searchForm.type = v;
this.getLogList();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getLogList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getLogList();
},
selectDateRange(v) {
if (v) {
this.searchForm.startDate = v[0];
this.searchForm.endDate = v[1];
}
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getLogList();
},
getLogList() {
this.loading = true;
this.searchForm.key = this.searchKey;
this.searchForm.operatorName = this.operatorName;
getLogListData(this.searchForm).then(res => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
}
},
mounted() {
this.init();
}
};
</script>

View File

@@ -0,0 +1,681 @@
<style lang="scss" scoped>
@import "@/styles/tree-common.scss";
</style>
<template>
<div class="search">
<Card>
<Row class="operation">
<i-switch v-model="strict" class="selectModel" size="large" style="margin-right: 5px">
<span slot="open">级联</span>
<span slot="close">单选</span>
</i-switch>
<Button @click="addRootMenu" >添加顶级菜单</Button>
<Button @click="addMenu" type="primary" >添加子菜单</Button>
<Button @click="delAll">批量删除</Button>
<Dropdown @on-click="handleDropdown">
<Button>
更多操作
<Icon type="md-arrow-dropdown"></Icon>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="refresh">刷新</DropdownItem>
<DropdownItem name="expandOne">收合所有</DropdownItem>
<DropdownItem name="expandTwo">展开一级</DropdownItem>
<DropdownItem name="expandThree">展开两级</DropdownItem>
<DropdownItem name="expandAll">展开所有</DropdownItem>
</DropdownMenu>
</Dropdown>
</Row>
<Row type="flex" justify="start">
<Col :md="8" :lg="8" :xl="6">
<Alert show-icon>
当前选择编辑
<span class="select-title">{{ editTitle }}</span>
<a class="select-clear" v-if="form.id" @click="cancelEdit"
>取消选择</a
>
</Alert>
<Input
v-model="searchKey"
suffix="ios-search"
@on-change="search"
placeholder="输入菜单名搜索"
clearable
/>
<div class="tree-bar" :style="{ maxHeight: maxHeight }">
<Tree
ref="tree"
:data="data"
show-checkbox
:render="renderContent"
@on-select-change="selectTree"
@on-check-change="changeSelect"
:check-strictly="!strict"
></Tree>
<Spin size="large" fix v-if="loading"></Spin>
</div>
</Col>
<Col :md="15" :lg="13" :xl="9" style="margin-left: 10px">
<Form
ref="form"
:model="form"
:label-width="110"
:rules="formValidate"
>
<FormItem label="类型" prop="type">
<div v-show="form.level == 0">
<Icon
type="ios-navigate-outline"
size="16"
style="margin-right: 5px"
></Icon>
<span>顶部菜单</span>
</div>
<div v-show="form.level == 1 || form.level == 2">
<Icon
type="ios-list-box-outline"
size="16"
style="margin-right: 5px"
></Icon>
<span>页面菜单</span>
</div>
</FormItem>
<FormItem
label="名称"
prop="title"
>
<Input v-model="form.title"/>
</FormItem>
<FormItem label="路径" prop="path" v-if="form.level != 0">
<Input v-model="form.path"/>
</FormItem>
<FormItem
label="英文名"
prop="name"
v-if="form.level == 0"
class="block-tool"
>
<Tooltip placement="right" content="需唯一">
<Input v-model="form.name"/>
</Tooltip>
</FormItem>
<FormItem
label="路由英文名"
prop="name"
v-if="form.level != 0"
class="block-tool"
>
<Tooltip placement="right" content="需唯一" transfer>
<Input v-model="form.name"/>
</Tooltip>
</FormItem>
<FormItem
label="图标"
prop="icon"
>
<icon-choose v-model="form.icon"></icon-choose>
</FormItem>
<FormItem label="前端组件" prop="frontRoute" v-if="form.level != 0">
<Input v-model="form.frontRoute"/>
</FormItem>
<FormItem
label="第三方链接"
v-if="form.level == 2"
class="block-tool"
>
<Tooltip
placement="right"
content="前端组件需为 sys/monitor/monitor 时生效"
max-width="300"
transfer
>
<Input
v-model="form.url"
placeholder="http://"
@on-change="changeEditUrl"
/>
</Tooltip>
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="form.sortOrder"
></InputNumber>
</Tooltip>
</FormItem>
<Form-item>
<Button
style="margin-right: 5px"
@click="submitEdit"
:loading="submitLoading"
type="primary"
icon="ios-create-outline"
>保存
</Button
>
<Button @click="handleReset">重置</Button>
</Form-item>
</Form>
</Col>
</Row>
</Card>
<Modal
draggable
:title="modalTitle"
v-model="menuModalVisible"
:mask-closable="false"
:width="500"
:styles="{ top: '30px' }"
>
<Form
ref="formAdd"
:model="formAdd"
:label-width="100"
:rules="formValidate"
>
<div v-if="showParent">
<FormItem label="上级节点:">{{ parentTitle }}</FormItem>
</div>
<FormItem label="类型" prop="type">
<div v-show="formAdd.level == 0">
<Icon
type="ios-navigate-outline"
size="16"
style="margin-right: 5px"
></Icon>
<span>顶部菜单</span>
</div>
<div v-show="formAdd.level != 0">
<Icon
type="ios-list-box-outline"
size="16"
style="margin-right: 5px"
></Icon>
<span>页面菜单</span>
</div>
</FormItem>
<FormItem
label="名称"
prop="title"
>
<Input v-model="formAdd.title"/>
</FormItem>
<FormItem label="路径" prop="path" v-if="formAdd.level != 0">
<Input v-model="formAdd.path"/>
</FormItem>
<FormItem
label="英文名"
prop="name"
v-if="formAdd.level == 0"
class="block-tool"
>
<Tooltip placement="right" content="需唯一">
<Input v-model="formAdd.name"/>
</Tooltip>
</FormItem>
<FormItem
label="路由英文名"
prop="name"
v-if="formAdd.level != 0"
class="block-tool"
>
<Tooltip placement="right" content="需唯一">
<Input v-model="formAdd.name"/>
</Tooltip>
</FormItem>
<FormItem
label="图标"
prop="icon"
>
<icon-choose v-model="formAdd.icon"></icon-choose>
</FormItem>
<FormItem label="前端组件" prop="frontRoute" v-if="formAdd.level != 0">
<Input v-model="formAdd.frontRoute"/>
</FormItem>
<FormItem
label="第三方链接"
prop="url"
v-if="formAdd.level == 2"
class="block-tool"
>
<Tooltip
placement="right"
content="前端组件需为 sys/monitor/monitor 时生效"
max-width="300"
transfer
>
<Input
v-model="formAdd.url"
placeholder="http://"
@on-change="changeAddUrl"
/>
</Tooltip>
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="formAdd.sortOrder"
></InputNumber>
</Tooltip>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="menuModalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="submitAdd"
>提交
</Button
>
</div>
</Modal>
</div>
</template>
<script>
import {
getAllPermissionList,
addPermission,
editPermission,
deletePermission,
searchPermission,
} from "@/api/index";
import IconChoose from "@/views/my-components/lili/icon-choose";
import util from "@/libs/util.js";
export default {
name: "menu-manage",
components: {
IconChoose,
},
data() {
return {
loading: true,
strict: true,
maxHeight: "500px",
expandLevel: 1,
menuModalVisible: false,
iconModalVisible: false,
selectList: [],
selectCount: 0,
showParent: false,
searchKey: "",
parentTitle: "",
editTitle: "",
modalTitle: "",
form: {
id: "",
title: "",
name: "",
icon: "",
path: "",
frontRoute: "",
parentId: "",
buttonType: "",
sortOrder: 0,
level: 0,
url: "",
showAlways: true,
},
formAdd: {
buttonType: "",
},
formValidate: {
title: [{required: true, message: "名称不能为空", trigger: "blur"}],
name: [
{required: true, message: "路由英文名不能为空", trigger: "blur"},
],
icon: [{required: true, message: "图标不能为空", trigger: "click"}],
path: [{required: true, message: "路径不能为空", trigger: "blur"}],
frontRoute: [
{required: true, message: "前端组件不能为空", trigger: "blur"},
],
sortOrder: [
{
required: true,
type: "number",
message: "排序值不能为空",
trigger: "blur",
},
],
},
submitLoading: false,
data: [],
};
},
methods: {
init() {
this.getAllList();
},
renderContent(h, {root, node, data}) {
let icon = "";
if (data.level == 0) {
icon = "ios-navigate";
} else if (data.level == 1) {
icon = "md-list-box";
} else if (data.level == 2) {
icon = "md-list";
}
return h("span", [
h("span", [
h("Icon", {
props: {
type: icon,
size: "16",
},
style: {
"margin-right": "8px",
"margin-bottom": "3px",
},
}),
h("span", data.title),
]),
]);
},
handleDropdown(name) {
console.log(name)
if (name == "expandOne") {
this.expandLevel = 1;
this.getAllList();
} else if (name == "expandTwo") {
this.expandLevel = 2;
this.getAllList();
} else if (name == "expandThree") {
this.expandLevel = 3;
this.getAllList();
}
if (name == "expandAll") {
this.expandLevel = 4;
this.getAllList();
} else if (name == "refresh") {
this.getAllList();
}
},
getAllList() {
this.loading = true;
getAllPermissionList().then((res) => {
this.loading = false;
if (res.success) {
// 仅展开指定级数 默认后台已展开所有
let expandLevel = this.expandLevel;
res.result.forEach(function (e) {
if (expandLevel == 1) {
if (e.level == 0) {
e.expand = false;
}
if (e.children && e.children.length > 0) {
e.children.forEach(function (c) {
if (c.level == 1) {
c.expand = false;
}
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
if (b.level == 2) {
b.expand = false;
}
});
}
});
}
} else if (expandLevel == 2) {
if (e.level == 0) {
e.expand = true;
}
if (e.children && e.children.length > 0) {
e.children.forEach(function (c) {
if (c.level == 1) {
c.expand = false;
}
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
if (b.level == 2) {
b.expand = false;
}
});
}
});
}
} else if (expandLevel == 3) {
if (e.level == 0) {
e.expand = true;
}
if (e.children && e.children.length > 0) {
e.children.forEach(function (c) {
if (c.level == 1) {
c.expand = true;
}
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
if (b.level == 2) {
b.expand = false;
}
});
}
});
}
} else if (expandLevel == 4) {
if (e.level == 0) {
e.expand = true;
}
if (e.children && e.children.length > 0) {
e.children.forEach(function (c) {
if (c.level == 1) {
c.expand = true;
}
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
if (b.level == 2) {
b.expand = true;
}
});
}
});
}
}
});
this.data = res.result;
}
});
},
search() {
if (this.searchKey) {
this.loading = true;
searchPermission({title: this.searchKey}).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result;
}
});
} else {
this.getAllList();
}
},
selectTree(v) {
if (v.length > 0) {
// 转换null为""
let str = JSON.stringify(v);
let menu = JSON.parse(str);
this.form = menu[0];
this.editTitle = menu[0].title;
} else {
this.cancelEdit();
}
},
cancelEdit() {
let data = this.$refs.tree.getSelectedNodes()[0];
if (data) {
data.selected = false;
}
this.$refs.form.resetFields();
this.form.id = "";
this.editTitle = "";
},
handleReset() {
this.$refs.form.resetFields();
this.form.icon = "";
this.form.frontRoute = "";
},
submitEdit() {
this.$refs.form.validate((valid) => {
if (valid) {
if (!this.form.id) {
this.$Message.warning("请先点击选择要修改的菜单节点");
return;
}
this.submitLoading = true;
if (this.form.sortOrder == null) {
this.form.sortOrder = "";
}
if (this.form.buttonType == null) {
this.form.buttonType = "";
}
delete this.form.updateTime;
editPermission(this.form).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("编辑成功");
// 标记重新获取菜单数据
this.$store.commit("setAdded", false);
util.initRouter(this);
this.init();
this.menuModalVisible = false;
}
});
}
});
},
submitAdd() {
this.$refs.formAdd.validate((valid) => {
if (valid) {
this.submitLoading = true;
addPermission(this.formAdd).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("添加成功");
// 标记重新获取菜单数据
this.$store.commit("setAdded", false);
util.initRouter(this);
this.init();
this.menuModalVisible = false;
}
});
}
});
},
changeEditUrl(e) {
let v = e.target.value;
if (v.indexOf("http") > -1) {
this.form.frontRoute = "sys/monitor/monitor";
}
},
changeAddUrl(e) {
let v = e.target.value;
if (v.indexOf("http") > -1) {
this.formAdd.frontRoute = "sys/monitor/monitor";
}
},
addMenu() {
if (!this.form.id) {
this.$Message.warning("请先点击选择一个菜单权限节点");
return;
}
this.parentTitle = this.form.title;
this.modalTitle = "添加子节点(可拖动)";
this.showParent = true;
if (this.form.level == 2) {
this.$Modal.warning({
title: "抱歉,不能添加啦",
content: "仅支持2级菜单目录",
});
return;
}
let frontRoute = "";
this.formAdd = {
icon: "",
parentId: this.form.id,
level: Number(this.form.level) + 1,
sortOrder: 0,
buttonType: "",
status: 0,
showAlways: true,
};
if (this.form.level == 0) {
this.formAdd.path = "/";
this.formAdd.frontRoute = "Main";
}
this.menuModalVisible = true;
},
addRootMenu() {
this.modalTitle = "添加顶部菜单(可拖动)";
this.showParent = false;
this.formAdd = {
level: 0,
sortOrder: 0,
status: 0,
};
this.menuModalVisible = true;
},
changeSelect(v) {
this.selectCount = v.length;
this.selectList = v;
},
delAll() {
if (this.selectCount <= 0) {
this.$Message.warning("您还未勾选要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
loading: true,
onOk: () => {
let ids = "";
this.selectList.forEach(function (e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
deletePermission(ids).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
// 标记重新获取菜单数据
this.$store.commit("setAdded", false);
util.initRouter(this);
this.selectList = [];
this.selectCount = 0;
this.cancelEdit();
this.init();
}
});
},
});
},
},
mounted() {
// 计算高度
let height = document.documentElement.clientHeight;
this.maxHeight = Number(height - 287) + "px";
this.init();
},
};
</script>

View File

@@ -0,0 +1,792 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Tabs value="MESSAGE" @on-click="paneChange">
<TabPane label="站内信列表" name="MESSAGE">
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchMessageForm" inline :label-width="70" class="search-form">
<Form-item label="消息标题" prop="title">
<Input
type="text"
v-model="searchMessageForm.title"
placeholder="请输入消息标题"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="消息内容" prop="content">
<Input
type="text"
v-model="searchMessageForm.content"
placeholder="请输入消息内容"
clearable
style="width: 200px"
/>
</Form-item>
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
</Form>
</Row>
<Row class="operation" style="margin-top: 20px">
<Button @click="sendMessage" type="primary">发送消息</Button>
</Row>
<Row>
<Table
:loading="loading"
border
:columns="messageColumns"
:data="messageData"
ref="table"
sortable="custom"
@on-sort-change="messageChangeSort"
@on-selection-change="messageChangeSelect"
></Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchMessageForm.pageNumber"
:total="messageDataTotal"
:page-size="searchMessageForm.pageSize"
@on-change="messageChangePage"
@on-page-size-change="messageChangePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</TabPane>
<TabPane label="通知类站内信" name="SETTING">
<Row>
<Table
:loading="loading"
border
:columns="noticeColumns"
:data="noticeData"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
></Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="noticeDataTotal"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</TabPane>
</Tabs>
</Card>
</Col>
</Row>
<!-- 站内信模板编辑 -->
<Modal
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="800"
>
<div class="message-title">
<p>1左侧#{xxx}为消息变量</p>
<p>2如果要发送的消息包含消息变量则将消息变量复制到消息内容中即可注意格式</p>
<p>3比如消息变量为#{订单号}发送的内容为订单号为xxx的订单已经发货注意查收完整的消息内容应该为订单号为#{订单号}的订单已经发货注意查收</p>
</div>
<div class="send-setting">
<div class="left-show">
<div v-for="(item, index) in form.variables" >
#{<span>{{item}}</span>}
</div>
</div>
<div class="send-form">
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="通知节点" prop="noticeNode">
<Input v-model="form.noticeNode" clearable type="text" style="width: 90%" maxlength="20" disabled />
</FormItem>
<FormItem label="消息标题" prop="noticeTitle">
<Input v-model="form.noticeTitle" clearable type="text" style="width: 90%" maxlength="20"/>
</FormItem>
<FormItem label="消息内容" prop="noticeContent">
<Input v-model="form.noticeContent" clearable type="textarea" style="width: 90%" maxlength="50" :autosize="{maxRows:4,minRows: 4}" show-word-limit />
</FormItem>
</Form>
</div>
</div>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit">保存</Button>
</div>
</Modal>
<!-- 站内信发送 -->
<Modal
:title="messageModalTitle"
v-model="messageModalVisible"
:mask-closable="false"
:width="500"
>
<Form ref="messageSendForm" :model="messageSendForm" :label-width="100" :rules="messageFormValidate">
<FormItem label="消息标题" prop="title">
<Input v-model="messageSendForm.title" maxlength="15" clearable style="width: 90%"/>
</FormItem>
<FormItem label="消息内容" prop="content">
<Input
v-model="messageSendForm.content"
:rows="4"
type="textarea"
style="max-height:60vh;overflow:auto;width: 90%"
/>
</FormItem>
<FormItem label="发送范围">
<RadioGroup v-model="messageSendForm.messageRange" @on-change="selectShop">
<Radio label="ALL">全站</Radio>
<Radio label="APPOINT">指定商家</Radio>
</RadioGroup>
</FormItem>
<FormItem label="指定商家" v-if="shopShow">
<Select v-model="messageSendForm.userIds" filterable multiple style="width: 90%;"
label-in-value @on-change="getName">
<Option v-for="item in shopList" :value="item.id" :key="item.id" :lable="item.storeName">{{ item.storeName
}}
</Option>
</Select>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="messageModalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="sendMessageSubmit"
>发送
</Button
>
</div>
</Modal>
<!-- 站内信发送 -->
<Modal
:title="modalTitle"
v-model="messageDetailModalVisible"
:mask-closable="false"
:width="700"
>
<Form ref="messageSendForm" :model="messageSendForm" :label-width="100" :rules="messageFormValidate">
<FormItem label="消息标题" prop="title">
<Input v-model="messageSendForm.title" maxlength="15" clearable style="width: 50%" disabled/>
</FormItem>
<FormItem label="消息内容" prop="content">
<Input
disabled
v-model="messageSendForm.content"
:rows="4"
type="textarea"
style="max-height:60vh;overflow:auto;width: 50%"
/>
</FormItem>
<FormItem label="发送范围">
<RadioGroup v-model="messageSendForm.messageRange">
<Radio disabled label="ALL">全站</Radio>
<Radio disabled label="APPOINT">指定商家</Radio>
</RadioGroup>
</FormItem>
<FormItem label="指定商家">
<Row>
<Table
:loading="loading"
border
:columns="messageDetailColumns"
:data="shopMessageData"
ref="table"
sortable="custom"
@on-sort-change="messageChangeSort"
@on-selection-change="messageChangeSelect"
></Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchShopMessageForm.pageNumber"
:total="shopMessageDataTotal"
:page-size="searchShopMessageForm.pageSize"
@on-change="messageChangePage"
@on-page-size-change="messageChangePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="messageDetailModalVisible = false">取消</Button>
</div>
</Modal>
</div>
</template>
<script>
import * as API_Setting from "@/api/setting.js";
import * as API_Other from "@/api/other.js";
import * as API_Shop from "@/api/shops.js";
export default {
name: "bill",
components: {},
data() {
return {
openSearch: true, // 显示搜索
openTip: true, // 显示提示
loading: true, // 表单加载状态
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
messageModalVisible: false, // 发送站内信模态框
messageModalTitle: "", // 发送站内信标题
messageDetailModalVisible: false, // 添加或编辑显示
shopShow: false, //指定商家是否出现
shopList: [],//店铺列表
drop: false,
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
},
messageFormValidate: {
title: [
{required: true, message: '请输入消息标题', trigger: 'blur'},
],
content: [
{required: true, message: '请输入消息内容', trigger: 'blur'},
],
},
//管理端消息汇总
searchMessageForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
//发送给店铺的消息
searchShopMessageForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
selectDate: null,
form: {
noticeNode: "",
noticeTitle: ""
},
//消息发送表单
messageSendForm: {
messageRange: "ALL",
userIds: [],
userNames: [],
},
// 表单验证规则
formValidate: {
noticeNode: [
{required: true, message: '请输入通知节点', trigger: 'blur'},
],
noticeTitle: [
{required: true, message: '请输入通知标题', trigger: 'blur'},
],
noticeContent: [
{required: true, message: '请输通知内容', trigger: 'blur'},
],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
messageSelectList: [], // 消息多选数据
messageSelectCount: 0, // 多选计数
selectCount: 0, // 多选计数
noticeColumns: [
{
title: "通知节点",
key: "noticeNode",
maxWidth: 270,
sortable: false,
},
{
title: "通知标题",
key: "noticeTitle",
minWidth: 200,
sortable: false,
},
{
title: "通知内容",
key: "noticeContent",
minWidth: 300,
sortable: false,
},
{
title: "状态",
key: "noticeStatus",
maxWidth: 100,
sortType: "desc",
render: (h, params) => {
if (params.row.noticeStatus == "OPEN") {
return h("Badge", {props: {status: "success", text: "开启"}})
} else if (params.row.noticeStatus == "CLOSE") {
return h("Badge", {props: {status: "processing", text: "关闭"}})
}
}
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 140,
render: (h, params) => {
let enableOrDisable = "";
if (params.row.noticeStatus == "OPEN") {
enableOrDisable = h(
"Button",
{
props: {
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.disable(params.row);
}
}
},
"关闭"
);
} else {
enableOrDisable = h(
"Button",
{
props: {
type: "success",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.enable(params.row);
}
}
},
"开启"
);
}
return h("div", [
enableOrDisable,
h(
"Button",
{
props: {
type: "primary",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
]);
}
},
],
noticeData: [], // 表单数据
noticeDataTotal: 0, // 表单数据总数
messageColumns: [
{
title: "消息标题",
key: "title",
minWidth: 150,
},
{
title: "消息内容",
key: "content",
minWidth: 350,
tooltip: true
},
{
title: "发送类型",
key: "messageRange",
width: 100,
render: (h, params) => {
if (params.row.messageRange == "ALL") {
return h('div', [
h('span', {}, '全站'),
]);
} else if (params.row.messageRange == "APPOINT") {
return h('div', [
h('span', {}, '指定用户'),
]);
}
}
},
{
title: "发送时间",
key: "createTime",
sortable: true,
width: 180,
sortable: false,
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 140,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "info",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.detail(params.row);
}
}
},
"详细"
),
h(
"Button",
{
props: {
type: "error",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.delete(params.row.id);
}
}
},
"删除"
),
]);
}
},
],
messageData: [], // 表单数据
messageDataTotal: 0, // 表单数据总数
messageDetailColumns: [
{
title: "店铺ID",
key: "storeId",
maxWidth: 300,
sortable: false,
},
{
title: "店铺名称",
key: "storeName",
sortable: false,
},
{
title: "是否已读",
key: "status",
render: (h, params) => {
if (params.row.status == "ALREADY_READY") {
return h( "Badge", {props: { status: "success",text: "已读" } })
} else if (params.row.status == "UN_READY") {
return h( "Badge", {props: { status: "processing",text: "未读" } })
}else{
return h( "Badge", {props: { status: "processing",text: "回收站" } })
}
}
},
],
shopMessageData: [], // 发送给店铺的消息数据
shopMessageDataTotal: 0, // 发送给店铺的消息数据总数
};
},
methods: {
init() {
this.getMessage();
},
//获取全部商家
getShopList() {
this.loading = true;
API_Shop.getShopList().then((res) => {
this.loading = false;
if (res.success) {
this.shopList = res.result;
}
});
this.loading = false;
},
paneChange(v) {
if (v == "SETTING") {
this.getNoticeMessage()
}
if (v == "MESSAGE") {
this.getMessage()
}
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getNoticeMessage();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getNoticeMessage();
},
handleSearch() {
this.searchMessageForm.pageNumber = 1;
this.searchMessageForm.pageSize = 10;
this.getMessage();
},
//消息每页条数发生变化
messageChangePageSize(v) {
this.searchMessageForm.pageSize = v;
this.getMessage();
},
//消息页数变化
messageChangePage(v) {
this.searchMessageForm.pageNumber = v;
this.getMessage();
this.clearSelectAll();
},
//消息
messageChangeSort(e) {
this.searchMessageForm.sort = e.key;
this.searchMessageForm.order = e.order;
this.getMessage();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getNoticeMessage();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
//消息
messageChangeSelect(e) {
this.messageSelectList = e;
this.messageSelectCount = e.length;
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
selectDateRange(v) {
if (v) {
this.searchForm.startDate = v[0];
this.searchForm.endDate = v[1];
}
},
//获取发送段铺的名称
getName(value) {
this.messageSendForm.userNames = new Array()
value.forEach((item) => {
this.messageSendForm.userNames.push(item.label)
})
},
//删除站内信
delete(id){
console.warn(id)
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认删除此站内信 ?",
loading: true,
onOk: () => {
API_Setting.deleteMessage(id).then((res) => {
if (res.success) {
this.$Message.success("删除成功");
}
this.$Modal.remove();
this.getMessage();
});
}
});
},
//管理员发送消息
sendMessage() {
this.messageModalVisible = true
this.messageModalTitle = "发送站内信"
this.shopShow = false
this.messageSendForm =
{
messageRange: "ALL",
content: "",
title: "",
userIds: [],
userNames: [],
}
},
//管理员发送站内信提交
sendMessageSubmit() {
if (this.messageSendForm.userIds.length <= 0 && this.messageSendForm.messageRange == "APPOINT") {
this.$Message.error("请选择发送对象");
return
}
this.$refs["messageSendForm"].validate(valid => {
if (valid) {
API_Other.sendMessage(this.messageSendForm).then((res) => {
this.loading = false;
if (res.success) {
this.$Message.success("发送成功");
this.messageModalVisible = false
this.getMessage();
}
});
this.loading = false;
}
})
},
//弹出选择商家的框
selectShop(v) {
if (v == "APPOINT") {
this.getShopList()
this.shopShow = true
}
if (v == "ALL") {
this.shopShow = false
}
},
//获取管理员发送列表
getMessage() {
this.loading = true;
API_Other.getMessagePage(this.searchMessageForm).then((res) => {
this.loading = false;
if (res.success) {
this.messageData = res.result.records;
this.messageDataTotal = res.result.total;
}
});
this.loading = false;
},
getNoticeMessage() {
this.loading = true;
API_Setting.getNoticeMessageData(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.noticeData = res.result.records;
this.noticeDataTotal = res.result.total;
}
});
this.loading = false;
},
//保存通知类站内信
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
let params ={
noticeContent:this.form.noticeContent,
noticeTitle:this.form.noticeTitle
}
API_Setting.editNoticeMessage(this.form.id, params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("修改成功");
this.modalVisible = false;
this.getNoticeMessage();
}
});
}
});
},
//消息详情
detail(v) {
this.searchShopMessageForm.messageId = v.id
API_Other.getShopMessage(this.searchShopMessageForm).then((res) => {
if (res.success) {
this.messageDetailModalVisible = true;
this.modalTitle = "消息详情"
this.messageSendForm = v
this.shopMessageData = res.result.records;
this.shopMessageDataTotal = res.result.total;
}
});
},
edit(v) {
API_Setting.getNoticeMessageDetail(v.id).then((res) => {
if (res.success) {
this.modalTitle = "编辑通知类推送"
this.modalVisible = true
this.form = res.result
}
});
},
//禁用站内信模板
disable(v) {
API_Setting.updateMessageStatus(v.id,"CLOSE").then((res) => {
if (res.success) {
this.$Message.success("禁用成功");
this.getNoticeMessage();
}
});
},
//启用站内信模板
enable(v) {
API_Setting.updateMessageStatus(v.id,"OPEN").then((res) => {
if (res.success) {
this.$Message.success("启用成功");
this.getNoticeMessage();
}
});
},
},
mounted() {
this.init();
},
};
</script>
<style lang="scss">
@import "@/styles/table-common.scss";
@import "sms.scss";
</style>

View File

@@ -0,0 +1,151 @@
.card {
width: 100%;
height: 100%;
position: fixed;
}
.cardBox {
display: inline-block;
border-radius: 2px;
line-height: 1.5;
margin-right: 20px;
width: 300px;
border: 1px solid #eee;
padding: 10px;
}
.methodItem {
width: 100%;
border: 1px solid #f5f5f5;
text-align: center;
padding: 20px 0;
}
methodItem img {
width: 220px;
height: 86px;
}
methodItem h4 {
font-size: 14px;
color: #333;
margin-top: 5px;
}
.methodItem img {
width: 220px;
height: 86px;
}
.bar {
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 10px 8px 0;
}
.send-setting .left-show {
width: 230px;
padding: 20px 30px 20px 10px;
border: 1px solid #eee;
background-color: #fafafa;
}
.send-form {
flex: 1;
padding: 10px;
border: 1px solid #eee;
margin-left: 24px;
background-color: #fafafa;
}
.send-setting {
display: flex;
margin: 20px 0 0 0;
.sms {
word-break: break-all;
display: inline-block;
background-color: #eee;
max-width: 220px;
padding: 10px;
margin-bottom: 10px;
border-radius: 6px;
}
}
.choose-member {
display: flex;
height: 400px;
border: 1px solid #eee;
margin-bottom: 20px;
}
.source-member {
width: 50%;
border-right: 1px solid #eee;
padding: 10px;
}
.btns {
> span {
display: flex;
align-items: center;
justify-content: space-between;
}
}
.mobile {
margin-right: 20px;
}
.nickname {
font-size: 12px;
color: #999;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.traget-member {
width: 50%;
padding: 10px;
}
.scroll-card {
margin: 5px 0;
}
.ivu-card-body {
padding: 1px;
margin-left: 7px;
}
.checkbox-tag {
height: 35px;
width: 100%;
}
.ivu-tag-border.ivu-tag-closable .ivu-icon-ios-close {
margin-right: 68px !important;
left: 7px;
top: 0px;
}
.ivu-tag-text {
line-height: 35px;
font-size: 14px;
}
.message-title{
background-color: #fff5eb;
border: 1px solid #ffc999;
box-sizing: border-box;
color: rgba(0, 0, 0, 0.85);
font-size: 14px;
padding: 8px 15px;
border-radius: 2px;
}

View File

@@ -0,0 +1,928 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Tabs value="LIST" @on-click="paneChange">
<TabPane label="发送任务列表" name="LIST">
<Row class="operation" style="margin-bottom: 10px">
<Button @click="sendBatchSmsModal" type="primary">发送短信</Button>
</Row>
<Row>
<Table :loading="loading" border :columns="smsColumns" :data="smsData" ref="table" sortable="custom" @on-sort-change="templateChangeSort">
</Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page :current="smsSearchForm.pageNumber" :total="smsTotal" :page-size="smsSearchForm.pageSize" @on-change="smsChangePage" @on-page-size-change="smsChangePageSize"
:page-size-opts="[10, 20, 50]" size="small" show-total show-elevator show-sizer></Page>
</Row>
</TabPane>
<TabPane label="短信模板" name="TEMPLATE">
<Row class="operation" style="margin-bottom: 10px">
<Button @click="addTemplate" type="primary">添加短信模板</Button>
<Button @click="syncTemplate" type="info">同步</Button>
</Row>
<Row>
<Table :loading="loading" border :columns="templateColumns" :data="templateData" ref="table" sortable="custom" @on-sort-change="smsChangeSort">
</Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page :current="templateSearchForm.pageNumber" :total="templateTotal" :page-size="templateSearchForm.pageSize" @on-change="templateChangePage"
@on-page-size-change="templateChangePageSize" :page-size-opts="[10, 20, 50]" size="small" show-total show-elevator show-sizer></Page>
</Row>
</TabPane>
<TabPane label="短信签名" name="SIGN">
<Row class="operation" style="margin-bottom: 10px">
<Button @click="addSign" type="primary">添加短信签名</Button>
<Button @click="syncSign" type="info">同步</Button>
</Row>
<Row>
<Table :loading="loading" border :columns="signColumns" :data="signData" ref="table" sortable="custom" @on-sort-change="signChangeSort">
<template slot="signStatus" slot-scope="scope">
<div v-if="scope.row.signStatus ==2 ">
审核拒绝
<Poptip trigger="hover" :content=scope.row.reason placement="top-start" transfer>
<span style="color: #ed3f14">原因</span>
</Poptip>
</div>
<div v-if="scope.row.signStatus ==0 ">
审核中
</div>
<div v-if="scope.row.signStatus ==1 ">
审核通过
</div>
</template>
</Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page :current="signSearchForm.pageNumber" :total="signTotal" :page-size="signSearchForm.pageSize" @on-change="signChangePage" @on-page-size-change="signChangePageSize"
:page-size-opts="[10, 20, 50]" size="small" show-total show-elevator show-sizer></Page>
</Row>
</TabPane>
</Tabs>
</Card>
</Col>
</Row>
<Modal :title="templateModalTitle" v-model="templateModalVisible" :mask-closable="false" :width="500">
<Form ref="templateForm" :model="templateForm" :label-width="100" :rules="templateFormValidate">
<FormItem label="模板名称" prop="templateName">
<Input v-model="templateForm.templateName" maxlength="30" clearable style="width: 90%" placeholder="请输入模板名称不超过30字符" />
</FormItem>
<FormItem label="模板内容" prop="templateContent">
<Input v-model="templateForm.templateContent" clearable type="textarea" style="width: 90%" maxlength="200" :autosize="{maxRows:5,minRows: 5}" show-word-limit
placeholder="请输入短信内容不超过500字符不支持【】、★、 ※、 →、 ●等特殊符号;" />
</FormItem>
<FormItem label="申请说明" prop="remark">
<Input v-model="templateForm.remark" clearable type="textarea" style="width: 90%" maxlength="150" :autosize="{maxRows:4,minRows: 4}" show-word-limit
placeholder="请描述您的业务使用场景不超过100字符用于春节集五福" />
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="templateModalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="templateSubmit">提交
</Button>
</div>
</Modal>
<Modal :title="sendSmsModalTitle" v-model="sendSmsModal" :mask-closable="false" :width="900">
<div class="send-setting">
<div class="left-show" v-html="smsContent">
<div class="sms">效果预览</div>
</div>
<div class="send-form">
<Form ref="smsForm" :model="smsForm" :label-width="100" :rules="smsFormValidate">
<FormItem label="短信签名" prop="signName">
<Select @on-change="selectSmsSign" v-model="smsForm.signName" style="width: 35%;">
<Option v-for="item in smsSigns" :value="item.signName" :key="item.signName">{{ item.signName }}
</Option>
</Select>
</FormItem>
<FormItem label="短信模板" prop="messageCode">
<Select @on-change="selectSmsTemplate" v-model="smsForm.messageCode" style="width: 35%;">
<Option v-for="(item,index) in smsTemplates" :key="index" :value="item.templateCode">{{
item.templateName }}
<input type="hidden"></input>
</Option>
</Select>
</FormItem>
<FormItem label="短信内容" prop="context">
<Input v-model="smsForm.context" clearable type="textarea" style="width: 90%" maxlength="50" :autosize="{maxRows:4,minRows: 4}" show-word-limit disabled />
</FormItem>
<FormItem label="接收人" prop="smsRange">
<p>
已选<span style="color: #f56c1d"> {{memberNum}}</span>预计耗费条数<span style="color: #f56c1d">{{this.smsForm.num}}</span>
</p>
<RadioGroup @on-change="smsRangeChange" v-model="smsForm.smsRange">
<Radio label="1">全部会员</Radio>
<Radio label="2">自定义选择</Radio>
</RadioGroup>
</FormItem>
<FormItem>
<div class="choose-member" v-if="customSms">
<div class="source-member">
<Input suffix="ios-search" @on-enter="memberSearch" v-model="memberSearchParam.mobile" @on-blur="memberSearch" placeholder="请输入手机号码" style="width: 92%" />
<div style="margin-top: 5px">
<Scroll :on-reach-bottom="memberSearchEdge">
<div dis-hover v-for="(item, index) in members" :key="index" class="scroll-card">
<Button class="btns" :class="{'active':item.___selected}" @click="moveMember(index,item)" style="width: 100%;text-align: left">
<span v-if="item.mobile" class="mobile">
{{item.mobile}}
</span>
<span class="nickname">
{{ item.nickName}}
</span>
</Button>
</div>
</Scroll>
</div>
</div>
<div class="traget-member" style="overflow:auto">
<div v-for="(item, index) in alreadyCheckShow" :key="index" >
<Tag class="checkbox-tag" closable @on-close="alreadyCheckClose(item,index)">{{item.mobile ||
item.nickName}}
</Tag>
</div>
</div>
</div>
</FormItem>
</Form>
</div>
</div>
<div slot="footer">
<Button type="text" @click="sendSmsModal = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="sendSms">发送</Button>
</div>
</Modal>
</div>
</template>
<script>
import * as API_Setting from "@/api/setting.js";
import * as API_Member from "@/api/member.js";
export default {
name: "sms",
components: {},
data() {
return {
customSms: false, //当选择自动发送对象 展示
isActive: false,
alreadyCheck: [], //已经选中的数据
alreadyCheckShow: [], //已经选择的值负责显示
memberPage: 0,
members: [], //所有会员
smsTemplateContent: "", //短信模板内容
memberNum: 0, //会员总数
smsNum: 0, //预计发送短信条数
smsContent: "<div class='sms'>效果预览</div>", //短信内容
smsTemplates: [], //短信模板
smsSigns: [], //短信签名
sendSmsModal: false, //弹出发送短信模态框
sendSmsModalTitle: "短信发送", //发送短信模态框标题
modalType: 0, // 添加或编辑标识
templateModalVisible: false, //添加短信模板弹出框
templateModalTitle: "", //添加短信模板弹出框标题
templateForm: {}, //短信模板添加form
submitLoading: false,
selected: "",
settingData: "",
modalTitle: "设置",
modalVisible: false,
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
signSearchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
//短信模板查询form
templateSearchForm: {
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
//会员条数查询form
memberSearchFrom: {
disabled: "OPEN", // 会员状态
},
//会员查询条件
memberSearchParam: {
pageNumber: 1, // 当前页数
pageSize: 8, // 页面大小
disabled: "OPEN", // 会员状态
},
//短信记录查询form
smsSearchForm: {
sort: "createTime",
order: "desc",
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
},
smsForm: {
smsName: "",
signName: "",
context: "",
smsRange: "1",
num: 0,
messageCode: "",
}, //短信发送form
//短信发送参数校验
smsFormValidate: {
signName: [
{
required: true,
message: "请选择短信签名",
trigger: "blur",
},
],
messageCode: [
{
required: true,
message: "请选择短信模板",
trigger: "blur",
},
],
},
templateFormValidate: {
templateName: [
{
required: true,
message: "请输入短信模板名称",
trigger: "blur",
},
],
templateContent: [
{
required: true,
message: "请输入短信模板内容",
trigger: "blur",
},
],
remark: [
{
required: true,
message: "请输入短信模板申请说明",
trigger: "blur",
},
],
},
smsColumns: [
{
title: "模板名称",
key: "smsName",
width: 250,
},
{
title: "签名",
width: 150,
key: "signName",
},
{
title: "短信内容",
minWidth: 300,
key: "context",
tooltip: true,
},
{
title: "预计发送条数",
key: "num",
width: 140,
},
{
title: "操作",
key: "action",
align: "center",
width: 150,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "primary",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.detail(params.row);
},
},
},
"详细"
),
]);
},
},
],
smsData: [], // 表单数据
smsTotal: 0, // 表单数据总数
templateColumns: [
{
title: "模板code",
key: "templateCode",
},
{
title: "模板名称",
key: "templateName",
},
{
title: "模板内容",
key: "templateContent",
},
{
title: "状态",
key: "templateStatus",
headerAlign: "center",
Width: "100px",
render: (h, params) => {
if (params.row.templateStatus == 0) {
return h("div", {}, "审核中");
} else if(params.row.templateStatus == 1){
return h("div", {}, "审核通过");
} else {
return h("div", {}, "审核失败");
}
},
},
{
title: "操作",
key: "action",
fixed: "right",
width: 200,
align: "center",
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "info",
size: "small",
icon: "ios-create-outline",
},
style: {
marginRight: "5px",
},
attrs: {
disabled: params.row.templateStatus == 2 ? false : true,
},
on: {
click: () => {
this.editTemplate(params.row);
},
},
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px",
},
attrs: {
disabled: params.row.templateStatus == 0 ? true : false,
},
on: {
click: () => {
this.deleteSmsTemplate(params.row);
},
},
},
"删除"
),
]);
},
},
],
templateData: [], // 表单数据
templateTotal: 0, // 表单数据总数
signColumns: [
{
title: "签名名称",
key: "signName",
},
{
title: "申请说明",
key: "remark",
},
{
title: "状态",
key: "signStatus",
headerAlign: "center",
Width: "100px",
slot: "signStatus",
},
{
title: "操作",
key: "action",
fixed: "right",
width: 200,
align: "center",
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "info",
size: "small",
icon: "ios-create-outline",
},
attrs: {
disabled: params.row.signStatus == 2 ? false : true,
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.editSign(params.row);
},
},
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
icon: "ios-create-outline",
},
attrs: {
disabled: params.row.signStatus == 0 ? true : false,
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.deleteSmsSign(params.row);
},
},
},
"删除"
),
]);
},
},
],
signData: [], // 表单数据
signTotal: 0, // 表单数据总数
};
},
filters: {},
methods: {
init() {
this.getSms();
//查询会员总数
this.getMemberNum();
},
//查询会员条数
getMemberNum() {
API_Member.getMemberNum(this.memberSearchFrom).then((res) => {
this.loading = false;
if (res.success) {
this.memberNum = res.result;
this.smsForm.num = this.memberNum; //全部会员则会员数就等于条数
}
});
},
//已经选择的人取消选中
alreadyCheckClose(val,index) {
this.alreadyCheck.splice(index, 1);
this.alreadyCheckShow.splice(index, 1);
this.members.forEach((item,index)=>{
if(item.___selected && item.mobile == val.mobile){
item.___selected = false
}
})
this.smsForm.num--;
this.memberNum--;
},
//发送短信详细
detail(){
},
//选择接收人事件
smsRangeChange(v) {
this.memberNum = 0;
this.smsForm.num = 0;
if (v == 1) {
this.alreadyCheck = [];
this.alreadyCheckShow = [];
this.customSms = false;
this.getMemberNum();
}
if (v == 2) {
this.customSms = true;
this.getMembers();
}
},
//搜索会员
memberSearch() {
this.memberSearchParam.pageNumber = 1;
this.members = [];
this.getMembers();
},
//移动会员
moveMember(index, item) {
if (!item.mobile) {
this.$Message.error("当前用户暂无手机号绑定");
return false;
}
item.___selected = true;
if (this.alreadyCheck.length == 0) {
this.alreadyCheck.push(item.mobile);
this.alreadyCheckShow.push(item);
this.smsForm.num++;
this.memberNum++;
} else {
//如果已选择数组内存在此用户则不在进行选择
let result = this.alreadyCheck.indexOf(item.mobile);
if (result < 0) {
this.smsForm.num++;
this.memberNum++;
this.alreadyCheck.push(item.mobile);
this.alreadyCheckShow.push(item);
}
}
},
//底部滑动查询会员
memberSearchEdge() {
return new Promise((resolve) => {
setTimeout(() => {
if (this.memberPage != this.memberSearchParam.pageNumber) {
this.memberSearchParam.pageNumber++;
this.getMembers();
resolve();
} else {
resolve();
return false;
}
}, 1000);
});
},
//分页查询会员信息
getMembers() {
API_Member.getMemberListData(this.memberSearchParam).then((res) => {
this.loading = false;
if (res.success) {
res.result.records.forEach((item) => {
item.___selected = false;
this.members.push(item);
});
this.memberPage = res.result.pages;
}
});
},
//弹出发送短信模态框
sendBatchSmsModal() {
this.templateSearchForm.templateStatus = 1;
API_Setting.getSmsTemplatePage(this.templateSearchForm).then((res) => {
if (res.success) {
this.smsTemplates = res.result.records;
}
});
this.signSearchForm.signStatus = 1;
API_Setting.getSmsSignPage(this.signSearchForm).then((res) => {
if (res.success) {
this.smsSigns = res.result.records;
}
});
this.smsContent = "<div class='sms'>效果预览</div>";
//添加的时候将已经选过的手机号码置为空
this.alreadyCheck = [];
this.alreadyCheckShow = [];
this.smsTemplateContent = "效果预览";
// this.smsTemplateContent = "";
this.smsForm = {
smsName: "",
signName: "",
context: "",
smsRange: "1",
num: 0,
messageCode: "",
};
this.getMemberNum();
this.loading = false;
this.sendSmsModal = true;
},
setting() {
this.modalVisible = true;
},
//pane切换事件
paneChange(v) {
if (v == "TEMPLATE") {
this.getSmsTemplate();
}
if (v == "SIGN") {
this.getSmsSign();
}
},
//短信签名变化方法
selectSmsSign(v) {
if (v != void 0) {
//给预览赋值
this.smsContent =
"<div class='sms'>【" +
v +
"】" +
" " +
this.smsTemplateContent +
"</div>";
} else {
this.smsContent =
"<div class='sms'>效果预览" + this.smsTemplateContent + "</div>";
}
},
//短信模板变化方法
selectSmsTemplate(v) {
//循环短信模板 如果选择短信模板匹配则查询出当前模板的内容
this.smsTemplates.forEach((e) => {
if (this.smsForm.messageCode == e.templateCode) {
this.smsTemplateContent = e.templateContent;
this.smsForm.smsName = e.templateName;
}
});
if (this.smsForm.signName != "" && this.smsForm.signName != void 0) {
this.smsContent =
"<div class='sms'>【" +
this.smsForm.signName +
"】" +
this.smsTemplateContent +
"</div>";
} else {
this.smsContent =
"<div class='sms'>" + this.smsTemplateContent + "</div>";
}
this.smsForm.context = this.smsTemplateContent;
},
//查询方法
handleSearch() {},
//删除短信模板
deleteSmsTemplate(v) {
let params = {
templateCode: v.templateCode,
};
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除此短信模板?",
loading: true,
onOk: () => {
API_Setting.deleteSmsTemplatePage(params).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getSmsTemplate();
}
});
},
});
},
//发送短信
sendSms() {
this.$refs.smsForm.validate((valid) => {
const mobile = JSON.stringify(this.alreadyCheck);
this.smsForm.mobile = mobile;
if (valid) {
API_Setting.sendSms(this.smsForm).then((res) => {
if (res.success) {
this.$Message.success("发送成功");
this.getSms();
this.sendSmsModal = false;
}
});
}
});
},
//添加短信签名
addSign() {
this.$router.push({ name: "add-sms-sign" });
},
//新增短信模板
addTemplate() {
this.templateModalVisible = true;
this.templateModalTitle = "添加短信模板";
this.templateForm = {};
},
//新增短信模板
editTemplate(v) {
this.templateModalVisible = true;
this.templateModalTitle = "修改短信模板";
this.templateForm = v;
this.modalType = 1;
},
//同步签名
syncSign() {
this.loading = true;
API_Setting.syncSign().then((res) => {
this.loading = false;
if (res.success) {
this.$Message.success("同步成功");
this.getSmsSign();
}
});
this.loading = false;
},
//短信模板添加提交
templateSubmit() {
this.$refs.templateForm.validate((valid) => {
if (valid) {
this.loading = true;
if (this.modalType == 0) {
API_Setting.addSmsTemplatePage(this.templateForm)
.then((res) => {
this.loading = false;
if (res.code === 200) {
this.$Message.success("添加成功");
this.loading = false;
this.templateModalVisible = false;
this.getSmsTemplate();
}
})
.catch(() => {
this.loading = false;
});
} else {
API_Setting.editSmsTemplatePage(this.templateForm)
.then((res) => {
this.loading = false;
if (res.code === 200) {
this.$Message.success("修改成功");
this.loading = false;
this.templateModalVisible = false;
this.getSmsTemplate();
}
})
.catch(() => {
this.loading = false;
});
}
}
});
},
//删除短信签名
deleteSmsSign(v) {
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除此短信签名?",
loading: true,
onOk: () => {
API_Setting.deleteSign(v.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getSmsTemplate();
}
});
},
});
},
//短信模板同步
syncTemplate() {
this.loading = true;
API_Setting.syncTemplate().then((res) => {
this.loading = false;
if (res.success) {
this.$Message.success("同步成功");
this.getSmsTemplate();
}
});
this.loading = false;
},
//短信记录页数变化
smsChangePage(v) {
this.smsSearchForm.pageNumber = v;
this.getSms();
},
//短信记录页数变化
smsChangePageSize(v) {
this.smsSearchForm.pageSize = v;
this.getSms();
},
//短信模板页数变化
templateChangePage(v) {
this.templateSearchForm.pageNumber = v;
this.getSmsTemplate();
},
//短信模板页数变化
templateChangePageSize(v) {
this.templateSearchForm.pageSize = v;
this.getSmsTemplate();
},
templateChangeSort(e) {
this.templateSearchForm.sort = e.key;
this.templateSearchForm.order = e.order;
this.getSmsTemplate();
},
smsChangeSort(e) {
this.smsSearchForm.sort = e.key;
this.smsSearchForm.order = e.order;
this.getSms();
},
//分页获取短信模板数据
getSmsTemplate() {
this.loading = true;
API_Setting.getSmsTemplatePage(this.templateSearchForm).then((res) => {
this.loading = false;
if (res.success) {
this.templateData = res.result.records;
this.templateTotal = res.result.total;
}
});
this.loading = false;
},
//分页获取短信记录数据
getSms() {
this.loading = true;
API_Setting.getSmsPage(this.smsSearchForm).then((res) => {
this.loading = false;
if (res.success) {
this.smsData = res.result.records;
this.smsTotal = res.result.total;
}
});
this.loading = false;
},
//短信模板页数变化
signChangePage(v) {
this.signSearchForm.pageNumber = v;
this.getSmsSign();
},
//短信模板页数变化
signChangePageSize(v) {
this.signSearchForm.pageSize = v;
this.getSmsSign();
},
signChangeSort(e) {
this.signSearchForm.sort = e.key;
this.signSearchForm.order = e.order;
this.getSmsSign();
},
//修改短信签名
editSign(v) {
this.$router.push({ name: "add-sms-sign", query: { id: v.id } });
},
//分页获取短信签名数据
getSmsSign() {
this.loading = true;
API_Setting.getSmsSignPage(this.signSearchForm).then((res) => {
this.loading = false;
if (res.success) {
this.signData = res.result.records;
this.signTotal = res.result.total;
}
});
this.loading = false;
},
},
mounted() {
this.init();
},
watch: {},
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
@import "@/styles/table-common.scss";
@import "sms.scss";
.split {
height: 200px;
border: 1px solid #dcdee2;
}
.split-pane {
padding: 10px;
}
</style>

View File

@@ -0,0 +1,195 @@
<template>
<Card>
<div style="margin-top: 0px">
<div class="sign-name" v-if="id == undefined">
新增签名
</div>
<div class="sign-name" v-else>
修改签名
</div>
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="签名" prop="signName">
<Input v-model="form.signName" maxlength="12" clearable style="width: 28%"
placeholder="仅限2-12个字符建议使用App应用名称或是网站名/公司名"/>
</FormItem>
<FormItem label="签名来源" prop="signSource">
<Select v-model="form.signSource" placeholder="请选择签名来源" style="width: 28%">
<Option :value="0">企事业单位的全称或简称</Option>
<Option :value="1">工信部备案网站的全称或简称</Option>
<Option :value="2">App应用的全称或简称</Option>
<Option :value="3">公众号或小程序的全称或简称</Option>
<Option :value="4">电商平台店铺名的全称或简称</Option>
<Option :value="5">商标名的全称或简称</Option>
</Select>
</FormItem>
<div class="div-remark div-remark-first">
签名来源选择工信部备案网站的全称或简称时请在说明中添加网站域名加快审核速度
</div>
<div class="div-remark div-remark-bottom">
如果选择APP应用的全称或简称或公众号或小程序的全称或简称则网站APP小程序或公众号必须已上线
</div>
<FormItem label="证明文件">
<div style="float: left">
<upload-pic-thumb
v-model="form.businessLicense"
:multiple="false"
:max-size="2048"
>
</upload-pic-thumb>
</div>
<div style="float: left;margin-left: 20px">
<upload-pic-thumb
v-model="form.license"
:max-size="2048"
:multiple="false"
></upload-pic-thumb>
</div>
</FormItem>
<div class="div-remark div-remark-first">
第一张为营业执照第二张为授权委托书请上传签名归属方的企事业单位的企业营业执照组织机构代码证税务登记证三证合一的证件及授权委托书
</div>
<div class="div-remark div-remark-bottom">
支持jpgpnggifjpeg格式的图片每张图片不大于2MB
</div>
<FormItem label="申请说明" prop="remark">
<Input v-model="form.remark" clearable type="textarea" style="width: 50%" maxlength="100"
:autosize="{maxRows:4,minRows: 4}" show-word-limit
placeholder="请描述您的业务使用场景不超过100字符验证码、双十一大促营销"/>
</FormItem>
</Form>
<div class="footer">
<Button type="primary" :loading="submitLoading" @click="addSignSubmit">提交
</Button
>
</div>
</div>
</Card>
</template>
<script>
import * as API_Setting from "@/api/setting.js";
import uploadPicThumb from "@/views/my-components/lili/upload-pic-thumb";
export default {
name: "smsSign",
components: {
uploadPicThumb
},
data() {
return {
id: 0,
form: {
signName: "",
businessLicense: "",
license: "",
},
loading: false,
formValidate: {
signName: [{required: true, message: "签名名称不能为空", trigger: "blur"}],
remark: [{required: true, message: "申请说明不能为空", trigger: "blur"}],
businessLicense: [{required: true, message: " ", trigger: "blur"}],
},
submitLoading: false
}
},
filters: {},
methods: {
init() {
this.id = this.$route.query.id;
if (this.id != undefined) {
this.getSmsSignDetail();
}
},
//添加短信模板
addSignSubmit() {
//校验证件信息
if (this.form.businessLicense == "" || this.form.license == "") {
this.$Message.error("请完善证件信息");
return
}
//校验签名来源
if (this.form.signSource == "") {
this.$Message.error("请选择签名来源");
return
}
this.$refs.form.validate((valid) => {
if (valid) {
this.loading = true;
//新增
if (this.id == undefined) {
API_Setting.addSmsSign(this.form).then(res => {
this.loading = false;
if (res.code === 200) {
this.$Message.success('添加成功');
this.$router.back()
}
}).catch(() => {
this.loading = false;
});
} else {
API_Setting.editSmsSign(this.form).then(res => {
this.loading = false;
if (res.code === 200) {
this.$Message.success('修改成功');
this.$router.back()
}
}).catch(() => {
this.loading = false;
});
}
}
})
},
//查询短信签名详细
getSmsSignDetail() {
API_Setting.smsSignDetail(this.id).then(res => {
this.loading = false;
if (res.code === 200) {
this.form = res.result
}
})
}
},
mounted() {
this.init();
},
};
</script>
<style lang="scss">
.sign-name {
margin-top: 5px;
margin-left: 20px;
font-size: 16px;
margin-bottom: 30px;
color: #333;
}
.div-remark {
margin-left: 100px;
margin-bottom: 2px;
color: #999;
}
.div-remark-first {
margin-top: -17px;
}
.div-remark-bottom {
margin-bottom: 8px;
}
.footer {
margin-left: 100px;
}
</style>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
@import "@/styles/table-common.scss";
</style>

View File

@@ -0,0 +1,98 @@
<template>
<div>
<Card>
<Row>
<Form
ref="searchForm"
inline
:label-width="70"
@keydown.enter.native="handleGo"
>
<Form-item label="链接地址" prop="url">
<Input type="text" v-model="url" placeholder="http://" clearable style="width: 350px" />
</Form-item>
<Form-item style="margin-left:-50px;">
<Button @click="handleGo" type="primary" icon="ios-send" style="margin-right:5px">前往</Button>
<Button @click="handleOpen" icon="md-open">新窗口中打开</Button>
</Form-item>
</Form>
</Row>
<Divider style="margin-top:-10px;margin-bottom:0px;" />
<Row>
<div style="position:relative;">
<iframe
id="iframe"
:src="go"
frameborder="0"
width="100%"
:height="height"
scrolling="auto"
></iframe>
<Spin fix size="large" v-if="loading"></Spin>
</div>
</Row>
</Card>
</div>
</template>
<script>
export default {
name: "monitor",
data() {
return {
loading: false,
go: "",
url: "",
html: "",
height: "525px"
};
},
computed: {},
methods: {
initUrl() {
let url = this.$route.meta.url;
if (url !== null && url !== undefined) {
this.url = url;
this.go = url;
// window.open(this.go);
this.loading = true;
let that = this;
// 判断iframe是否加载完毕
let iframe = document.getElementById("iframe");
if (iframe.attachEvent) {
iframe.attachEvent("onload", function() {
//iframe加载完成后你需要进行的操作
that.loading = false;
});
} else {
iframe.onload = function() {
//iframe加载完成后你需要进行的操作
that.loading = false;
};
}
}
},
handleGo() {
let url = this.url;
this.go = this.url;
},
handleOpen() {
window.open(this.url);
}
},
watch: {
$route(to, from) {
this.initUrl();
}
},
mounted() {
// 计算高度
let height = document.documentElement.clientHeight;
this.height = Number(height - 217) + "px";
this.initUrl();
}
};
</script>

View File

@@ -0,0 +1,135 @@
.search {
.oss-operation {
margin-bottom: 2vh;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
button {
margin-right: 5px;
}
}
}
.none{
display: none;
}
.oss-wrapper {
display: flex;
flex-wrap: wrap;
position: relative;
}
.oss-card {
margin: 10px 20px 10px 0;
width: 290px;
:hover {
.content .other .name {
color: #1890ff;
transition: color .3s;
}
}
cursor: pointer;
.ivu-card-body {
padding: 0;
}
.content {
display: flex;
flex-direction: column;
:hover {
.play {
transition: opacity .3s;
opacity: 1 !important;
}
}
.img {
height: 135px;
object-fit: cover;
}
.video {
height: 135px;
position: relative;
.cover {
height: 100%;
width: 100%;
object-fit: fill;
}
.play {
position: absolute;
top: 43px;
left: 117px;
height: 50px;
width: 50px;
opacity: 0.8;
}
}
.other {
padding: 16px;
height: 135px;
.name {
font-size: 16px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: rgba(0, 0, 0, .85);
font-weight: 500;
margin-bottom: 4px;
}
.key {
overflow: hidden;
text-overflow: ellipsis;
height: 45px;
word-break: break-all;
color: rgba(0, 0, 0, .45);
}
.info {
font-size: 12px;
color: rgba(0, 0, 0, .45);
overflow: hidden;
text-overflow: ellipsis;
height: 36px;
word-break: break-all;
}
}
.actions {
display: flex;
align-items: center;
height: 50px;
background: #f7f9fa;
border-top: 1px solid #e8e8e8;
i:hover {
color: #1890ff;
}
.btn {
display: flex;
justify-content: center;
width: 33.33%;
border-right: 1px solid #e8e8e8;
}
.btn-no {
display: flex;
justify-content: center;
width: 33.33%;
}
}
}
}

View File

@@ -0,0 +1,816 @@
<style lang="scss">
@import "@/styles/table-common.scss";
@import "./ossManage.scss";
</style>
<template>
<div class="search">
<Card>
<div class="operation">
<Row @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="85" class="search-form"
>
<Form-item label="原文件名" prop="name">
<Input
type="text"
v-model="searchForm.name"
placeholder="请输入原文件名"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="存储文件名" prop="fileKey">
<Input
type="text"
v-model="searchForm.fileKey"
placeholder="请输入存储文件名"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="上传时间">
<DatePicker
v-model="selectDate"
type="daterange"
format="yyyy-MM-dd"
clearable
@on-change="selectDateRange"
placeholder="选择起始时间"
style="width: 200px"
></DatePicker>
</Form-item>
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn"
>搜索
</Button
>
</Form>
</Row>
<div class="oss-operation padding-row">
<div>
<Button
@click="uploadVisible = true"
type="primary"
>上传文件
</Button
>
<Dropdown @on-click="handleDropdown">
<Button>
更多操作
<Icon type="md-arrow-dropdown"/>
</Button>
<DropdownMenu slot="list">
<DropdownItem name="refresh">刷新</DropdownItem>
<DropdownItem v-show="showType == 'list'" name="removeAll">批量删除
</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
<div>
<RadioGroup
v-model="fileType"
@on-change="changeFileType"
type="button"
style="margin-right: 25px"
>
<Radio label="all">所有类型</Radio>
<Radio label="pic">图片</Radio>
<Radio label="video">视频</Radio>
</RadioGroup>
<RadioGroup
v-model="showType"
type="button"
@on-change="changeShowType"
>
<Radio title="列表" label="list">
<Icon type="md-list"></Icon>
</Radio>
<Radio title="缩略图" label="thumb">
<Icon type="ios-apps"></Icon>
</Radio>
</RadioGroup>
</div>
</div>
</div>
<div v-show="showType == 'list'">
<Row v-show="openTip">
<Alert show-icon>
已选择
<span class="select-count">{{ selectCount }}</span>
<a class="select-clear" @click="clearSelectAll">清空</a>
<span v-if="selectCount > 0" style="margin-left: 15px"
>共计 {{ totalSize }} 存储量</span
>
</Alert>
</Row>
<Row>
<Table
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
></Table>
</Row>
</div>
<div v-show="showType == 'thumb'">
<div class="oss-wrapper">
<Card v-for="(item, i) in data" :key="i" class="oss-card">
<div class="content">
<img
@click="showPic(item)"
v-if="item.fileType.indexOf('image') >= 0"
class="img"
:src="item.url"
/>
<div
v-else-if="item.fileType.indexOf('video') >= 0"
class="video"
@click="showVideo(item)"
>
<!-- 文件小于5MB显示video -->
<video class="cover" v-if="item.fileSize < 1024 * 1024 * 5">
<source :src="item.url"/>
</video>
<img class="play" src="@/assets/play.png"/>
</div>
<div v-else class="other">
<div class="name">{{ item.name }}</div>
<div class="key">{{ item.fileKey }}</div>
<div class="info">
文件类型{{ item.fileType }} 文件大小{{
((item.fileSize * 1.0) / (1024 * 1024)).toFixed(2)
}}
MB 创建时间{{ item.createTime }}
</div>
</div>
<div class="actions">
<div class="btn">
<Tooltip content="下载" placement="top">
<Icon @click="download(item)" type="md-download" size="16"/>
</Tooltip>
</div>
<div class="btn">
<Tooltip content="重命名" placement="top">
<Icon @click="rename(item)" type="md-create" size="16"/>
</Tooltip>
</div>
<div class="btn-no">
<Tooltip content="删除" placement="top">
<Icon @click="remove(item)" type="md-trash" size="16"/>
</Tooltip>
</div>
</div>
</div>
</Card>
</div>
</div>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="pageSizeOpts"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</Card>
<Drawer title="文件上传" class="drawer" styles="z-index:2000;" closable v-model="uploadVisible" width="500">
<Upload
:action="baseUrl + '/common/upload/file'"
:headers="accessToken"
:on-success="handleSuccess"
:on-error="handleError"
:max-size="5120"
:on-exceeded-size="handleMaxSize"
multiple
type="drag"
ref="up"
>
<div style="padding: 20px 0">
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
<p>点击这里或将文件拖拽到这里上传</p>
</div>
</Upload>
<div class="drawer-footer">
<Button @click="clearFiles">清空上传列表</Button>
</div>
</Drawer>
<Modal
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="500"
>
<Form ref="form" :model="form" :label-width="95" :rules="formValidate">
<FormItem label="原文件名" prop="name">
<Input v-model="form.name"/>
</FormItem>
<FormItem label="存储文件名" prop="fileKey">
<Input v-model="form.fileKey" disabled/>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="handleCancel">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit"
>提交
</Button
>
</div>
</Modal>
<Modal v-model="picVisible" :title="picTitle" draggable>
<img
:src="file.url"
alt="无效的图片链接"
style="width: 100%; margin: 0 auto; display: block"
/>
<div slot="footer">
<span
>文件类型{{ file.fileType }} 文件大小{{ file.msize }} 创建时间{{
file.createTime
}}</span
>
</div>
</Modal>
<Modal
v-model="videoVisible"
:title="videoTitle"
:width="800"
@on-cancel="closeVideo"
draggable
>
<div id="dplayer"></div>
<div slot="footer">
<span
>文件类型{{ file.fileType }} 文件大小{{ file.msize }} 创建时间{{
file.createTime
}}</span
>
</div>
</Modal>
</div>
</template>
<script>
import {
getFileListData,
renameFile,
deleteFile,
} from "@/api/index";
import DPlayer from "dplayer";
import config from "@/config";
var dp;
export default {
name: "oss-manage",
data() {
return {
config,
baseUrl: "",
selectImage: false, //是否是选择
accessToken: {}, // 上传token鉴权
loading: false, // 表单加载状态
fileType: "all",
showType: "list",
modalVisible: false, // 添加或编辑显示
uploadVisible: false,
videoVisible: false,
picVisible: false,
picTitle: "",
videoTitle: "",
modalTitle: "", // 添加或编辑标题
searchForm: {
// 搜索框对应data对象
name: "",
fileKey: "",
fileType: "",
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
startDate: "", // 起始时间
endDate: "", // 终止时间
},
selectDate: null, // 选择日期绑定modal
oldKey: "",
form: {
name: "",
fileKey: "",
},
file: {},
// 表单验证规则
formValidate: {
name: [{required: true, message: "不能为空", trigger: "blur"}],
fileKey: [{required: true, message: "不能为空", trigger: "blur"}],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
totalSize: "", // 文件大小统计
columns: [
// 表头
{
type: "selection",
width: 60,
align: "center",
},
{
title: "原文件名",
key: "name",
minWidth: 130,
sortable: true,
ellipsis: false,
tooltip: true,
},
{
title: "存储文件名",
key: "fileKey",
width: 165,
sortable: true,
ellipsis: false,
tooltip: true,
},
{
title: "缩略图(点击预览)",
key: "url",
width: 150,
align: "center",
render: (h, params) => {
if (params.row.fileType.includes("image") > 0) {
return h("img", {
attrs: {
src: params.row.url,
alt: "加载图片失败",
},
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain",
},
on: {
click: () => {
this.showPic(params.row);
},
},
});
} else if (params.row.fileType.includes("video") > 0) {
// 如果视频文件大小超过5MB不予加载video
if (params.row.fileSize < 1024 * 1024 * 5) {
return h(
"video",
{
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain",
},
on: {
click: () => {
this.showVideo(params.row);
},
},
},
[
h("source", {
attrs: {
src: params.row.url,
},
}),
]
);
} else {
return h("img", {
attrs: {
src: require("@/assets/play.png"),
},
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain",
},
on: {
click: () => {
this.showVideo(params.row);
},
},
});
}
} else {
return h("span", "非多媒体类型");
}
},
},
{
title: "文件类型",
key: "fileType",
width: 115,
sortable: true,
className: this.selectImage == true ? "none" : "",
},
{
title: "文件大小",
key: "fileSize",
width: 115,
sortable: true,
className: this.selectImage == true ? "none" : "",
render: (h, params) => {
let m =
((params.row.fileSize * 1.0) / (1024 * 1024)).toFixed(2) + " MB";
return h("span", m);
},
},
{
title: "上传者",
key: "createBy",
width: 120,
sortable: true,
render: (h, params) => {
let m = "";
if(params.row.userEnums=="MANAGER"){
m="[管理员]"
}else if(params.row.userEnums=="STORE"){
m="[店铺]"
}else{
m="[会员]"
}
m += params.row.createBy
return h("span", m);
},
},
{
title: "上传时间",
key: "createTime",
width: 180,
sortable: true,
sortType: "desc",
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 200,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "primary",
size: "small",
},
style: {
marginRight: "5px",
display: this.selectImage == true ? "inline-block" : "none",
},
on: {
click: () => {
this.selectedParams(params.row);
},
},
},
"选择"
),
h(
"Button",
{
props: {
type: "primary",
size: "small",
},
style: {
marginRight: "5px",
display: this.selectImage == true ? "none" : "inline-block",
},
on: {
click: () => {
this.download(params.row);
},
},
},
"下载"
),
h(
"Button",
{
props: {
size: "small",
},
style: {
marginRight: "5px",
display: this.selectImage == true ? "none" : "inline-block",
},
on: {
click: () => {
this.rename(params.row);
},
},
},
"重命名"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
display: this.selectImage == true ? "none" : "inline-block",
},
on: {
click: () => {
this.remove(params.row);
},
},
},
"删除"
),
]);
},
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
pageSizeOpts: [5, 10, 20],
};
},
methods: {
/**
* 选择
*/
selectedParams(val) {
this.$emit("callback", val);
},
handleDropdown(name) {
if (name == "refresh") {
this.getDataList();
} else if (name == "removeAll") {
this.removeAll();
}
},
init() {
this.accessToken = {
accessToken: this.getStore("accessToken"),
};
this.getDataList();
},
showPic(v) {
this.file = v;
this.file.msize = ((v.fileSize * 1.0) / (1024 * 1024)).toFixed(2) + " MB";
this.picTitle = v.name + "(" + v.fileKey + ")";
this.picVisible = true;
},
showVideo(v) {
dp = new DPlayer({
container: document.getElementById("dplayer"),
screenshot: true,
video: {
url: v.url,
},
danmaku: {
id: v.fileKey,
api: "https://api.prprpr.me/dplayer/",
},
});
this.file = v;
this.file.msize = ((v.fileSize * 1.0) / (1024 * 1024)).toFixed(2) + " MB";
this.videoTitle = v.name + "(" + v.fileKey + ")";
this.videoVisible = true;
},
closeVideo() {
dp.destroy();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order == "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
selectDateRange(v) {
if (v) {
this.searchForm.startDate = v[0];
this.searchForm.endDate = v[1];
}
},
changeShowType() {
this.searchForm.pageNumber = 1;
if (this.showType == "list") {
this.searchForm.pageSize = 10;
} else {
this.searchForm.pageSize = 12;
}
this.getDataList();
},
getDataList() {
if (this.showType == "list") {
this.pageSizeOpts = [10, 20, 50];
} else {
this.pageSizeOpts = [12, 24, 48];
}
this.loading = true;
getFileListData(this.searchForm).then((res) => {
this.loading = false;
this.data = res.result.records;
this.total = res.result.total;
});
},
handleSearch() {
this.searchForm.title = this.searchForm.name;
this.searchForm.pageNumber = 1;
if (this.showType == "list") {
this.searchForm.pageSize = 5;
} else {
this.searchForm.pageSize = 12;
}
this.getDataList();
},
changeFileType() {
let name = this.fileType;
if (name == "all") {
this.searchForm.fileType = "";
} else if (name == "pic") {
this.searchForm.fileType = "image";
} else if (name == "video") {
this.searchForm.fileType = "video";
}
this.handleSearch();
},
handleReset() {
this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1;
if (this.showType == "list") {
this.searchForm.pageSize = 5;
} else {
this.searchForm.pageSize = 12;
}
this.selectDate = null;
this.searchForm.startDate = "";
this.searchForm.endDate = "";
this.searchForm.fileKey = "";
// 重新加载数据
this.getDataList();
},
handleMaxSize(file) {
this.$Notice.warning({
title: "文件大小过大",
desc: "所选文件‘ " + file.name + " ’大小过大, 不得超过 5M.",
});
},
handleSuccess(res, file) {
if (res.success) {
this.$Message.success("上传文件 " + file.name + " 成功");
this.getDataList();
} else {
this.$Message.error(res.message);
}
},
handleError(error, file, fileList) {
this.$Message.error(error.toString());
},
clearFiles() {
this.$refs.up.clearFiles();
},
handleCancel() {
this.modalVisible = false;
},
download(v) {
window.open(
v.url + "?attname=&response-content-type=application/octet-stream"
);
},
removeAll() {
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选的 " + this.selectCount + " 个文件?",
loading: true,
onOk: () => {
let ids = "";
this.selectList.forEach(function (e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
deleteFile(ids).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("批量删除文件成功");
this.clearSelectAll();
this.getDataList();
}
});
},
});
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除文件 " + v.name + " ?",
loading: true,
onOk: () => {
deleteFile(v.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除文件 " + v.name + " 成功");
this.getDataList();
}
});
},
});
},
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
this.submitLoading = true;
let params = {
id: this.form.id,
key: this.oldKey,
newKey: this.form.fileKey,
newName: this.form.name,
};
renameFile(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
}
});
},
rename(v) {
this.modalTitle = "编辑文件名";
// 转换null为""
for (let attr in v) {
if (v[attr] == null) {
v[attr] = "";
}
}
let str = JSON.stringify(v);
let data = JSON.parse(str);
this.form = data;
this.oldKey = data.fileKey;
this.modalVisible = true;
},
clearSelectAll() {
this.$refs.table.selectAll(false);
this.totalSize = "";
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
let size = 0;
e.forEach((item) => {
size += item.fileSize * 1.0;
});
this.totalSize = ((size * 1.0) / (1024 * 1024)).toFixed(2) + " MB";
},
},
mounted() {
this.init();
this.baseUrl =
process.env.NODE_ENV === "development"
? this.config.api_dev.common
: this.config.api_prod.common;
},
};
</script>

View File

@@ -0,0 +1,23 @@
.permModal {
.ivu-modal-body {
max-height: 560px;
overflow: auto;
}
}
.depModal {
.ivu-modal-body {
max-height: 500px;
overflow: auto;
}
}
.tips{
font-size: 12px;
color: #999;
margin-left: 8px;
}
.title{
font-weight: bold;
margin-right: 20px;
}

View File

@@ -0,0 +1,782 @@
<style lang="scss">
@import "@/styles/table-common.scss";
@import "./roleManage.scss";
</style>
<template>
<div class="search">
<Card>
<Row class="operation">
<Button @click="addRole" type="primary">添加角色</Button>
<Button @click="delAll">批量删除</Button>
</Row>
<Row>
<Table
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
></Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="pageNumber"
:total="total"
:page-size="pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</Card>
<!-- 编辑 -->
<Modal
:title="modalTitle"
v-model="roleModalVisible"
:mask-closable="false"
:width="500"
>
<Form
ref="roleForm"
:model="roleForm"
:label-width="80"
:rules="roleFormValidate"
>
<FormItem label="角色名称" prop="name">
<Input v-model="roleForm.name"/>
</FormItem>
<FormItem label="备注" prop="description">
<Input v-model="roleForm.description"/>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="cancelRole">取消</Button>
<Button type="primary" :loading="submitLoading" @click="submitRole"
>提交
</Button
>
</div>
</Modal>
<!-- 菜单权限 -->
<Modal
:title="modalTitle"
v-model="permModalVisible"
:mask-closable="false"
:width="500"
:styles="{ top: '30px' }"
class="permModal"
>
<div style="position: relative">
<Tree
ref="tree"
:data="permData"
show-checkbox
:render="renderContent"
:check-strictly="true"
>
</Tree>
<Spin size="large" fix v-if="treeLoading"></Spin>
</div>
<div slot="footer">
<Button type="text" @click="cancelPermEdit">取消</Button>
<Select
v-model="openLevel"
@on-change="changeOpen"
style="width: 110px; text-align: left; margin-right: 10px"
>
<Option value="0">展开所有</Option>
<Option value="1">收合所有</Option>
<Option value="2">仅展开一级</Option>
<Option value="3">仅展开两级</Option>
</Select>
<Button
type="primary"
:loading="submitPermLoading"
@click="submitPermEdit(true)"
>编辑
</Button
>
</div>
</Modal>
<!-- 数据权限 -->
<Modal
:title="modalTitle"
v-model="depModalVisible"
:mask-closable="false"
:width="500"
class="depModal"
>
<Alert show-icon
>默认可查看全部数据自定义数据范围时请勾选下方数据
</Alert
>
<Form :label-width="85">
<FormItem label="数据范围">
<Select v-model="dataType" transfer>
<Option :value="0">全部数据权限</Option>
<Option :value="1">自定义数据权限</Option>
<Option :value="2">本部门及以下数据权限</Option>
<Option :value="3">本部门数据权限</Option>
</Select>
</FormItem>
</Form>
<div v-show="dataType == 1" style="margin-top: 15px">
<div style="position: relative">
<Tree
ref="depTree"
:data="depData"
:load-data="loadData"
@on-toggle-expand="expandCheckDep"
multiple
style="margin-top: 15px"
></Tree>
<Spin size="large" fix v-if="depTreeLoading"></Spin>
</div>
</div>
<div slot="footer">
<Button type="text" @click="depModalVisible = false">取消</Button>
<Button
type="primary"
:loading="submitDepLoading"
@click="submitDepEdit"
>提交
</Button
>
</div>
</Modal>
<!-- 保存权限弹出选择权限 -->
<Modal
v-model="selectIsSuperModel"
title="选择菜单权限"
:loading="superModelLoading"
@on-ok="saveRole"
>
<div v-for="(item, index) in saveRoleWay" :key="index">
<span class="title">{{ item.title }}</span>
<RadioGroup v-model="item.isSuper">
<Radio :label="true">
<span>操作数据权限</span>
</Radio>
<Radio :label="false">
<span>查看权限</span>
</Radio>
</RadioGroup>
</div>
</Modal>
</div>
</template>
<script>
import {
getRoleList,
getAllPermissionList,
addRole,
editRole,
deleteRole,
loadDepartment,
editRoleDep,
selectRoleMenu,
saveRoleMenu,
} from "@/api/index";
import util from "@/libs/util.js";
export default {
name: "role-manage",
data() {
return {
superModelLoading: false, //保存权限弹出选择权限保存
selectIsSuperModel: false, //保存权限弹出选择权限
rolePermsWay: [], //查询角色权限集合
openLevel: "0",
loading: true,
treeLoading: true,
depTreeLoading: true,
submitPermLoading: false,
submitDepLoading: false,
searchKey: "",
sortColumn: "",
sortType: "desc",
modalType: 0, // 0 添加 1 编辑
roleModalVisible: false,
permModalVisible: false,
depModalVisible: false,
modalTitle: "",
roleForm: {
name: "",
description: "",
},
roleFormValidate: {
name: [
{required: true, message: "角色名称不能为空", trigger: "blur"},
],
},
submitLoading: false,
selectList: [],
selectCount: 0,
columns: [
{
type: "selection",
width: 60,
align: "center",
},
{
title: "角色名称",
key: "name",
minWidth: 150,
},
{
title: "备注",
key: "description",
minWidth: 150,
tooltip: true
},
{
title: "创建时间",
key: "createTime",
width: 170,
sortable: true,
sortType: "desc",
},
{
title: "更新时间",
key: "updateTime",
width: 170,
sortable: true,
},
{
title: "最后操作人",
key: "createBy",
width: 150,
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 230,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "warning",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.editPerm(params.row);
},
},
},
"菜单权限"
),
h(
"Button",
{
props: {
size: "small",
type: "info"
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.edit(params.row);
},
},
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
on: {
click: () => {
this.remove(params.row);
},
},
},
"删除"
),
]);
},
},
],
data: [],
pageNumber: 1,
pageSize: 10,
total: 0,
permData: [],
editRolePermId: "",
selectAllFlag: false,
depData: [],
dataType: 0,
editDepartments: [],
saveRoleWay: [], //用户保存用户点击的菜单
};
},
methods: {
init() {
this.getRoleList();
// 获取所有菜单权限树
this.getPermList();
},
handleContextMenu(val) {
console.log(val);
},
renderContent(h, {root, node, data}) {
let icon = "";
if (data.level == 0) {
icon = "ios-navigate";
} else if (data.level == 1) {
icon = "md-list-box";
} else if (data.level == 2) {
icon = "md-list";
} else if (data.level == 3) {
icon = "md-radio-button-on";
} else {
icon = "md-radio-button-off";
}
return h(
"span",
{
style: {
display: "inline-block",
cursor: "pointer",
},
on: {
click: () => {
data.checked = !data.checked;
},
},
},
[
h("span", [
h("Icon", {
props: {
type: icon,
size: "16",
},
style: {
"margin-right": "8px",
"margin-bottom": "3px",
},
}),
h("span", data.title),
h(
"span",
{class: {tips: true}},
data.isSuper ? "操作权限" : "查看权限"
),
]),
]
);
},
changePage(v) {
this.pageNumber = v;
this.getRoleList();
this.clearSelectAll();
},
changePageSize(v) {
this.pageSize = v;
this.getRoleList();
},
changeSort(e) {
this.sortColumn = e.key;
this.sortType = e.order;
if (e.order == "normal") {
this.sortType = "";
}
this.getRoleList();
},
/**
* 查询所有角色
*/
getRoleList() {
this.loading = true;
let params = {
pageNumber: this.pageNumber,
pageSize: this.pageSize,
sort: this.sortColumn,
order: this.sort,
};
getRoleList(params).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
},
/**
* 查询菜单
*/
getPermList() {
this.treeLoading = true;
getAllPermissionList().then((res) => {
if (res.success) {
this.deleteDisableNode(res.result);
this.permData = res.result;
this.treeLoading = false;
}
this.treeLoading = false;
});
},
// 递归标记禁用节点
deleteDisableNode(permData) {
let that = this;
permData.forEach(function (e) {
if (e.status == -1) {
e.title = "[已禁用] " + e.title;
e.disabled = true;
}
if (e.children && e.children.length > 0) {
that.deleteDisableNode(e.children);
}
});
},
cancelRole() {
this.roleModalVisible = false;
},
submitRole() {
this.$refs.roleForm.validate((valid) => {
if (valid) {
if (this.modalType == 0) {
// 添加
this.submitLoading = true;
addRole(this.roleForm).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getRoleList();
this.roleModalVisible = false;
}
});
} else {
this.submitLoading = true;
this.roleForm.roleId = this.roleForm.id;
editRole(this.roleForm).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getRoleList();
this.roleModalVisible = false;
}
});
}
}
});
},
/**
* 点击添加按钮
*/
addRole() {
this.modalType = 0;
this.modalTitle = "添加角色";
this.$refs.roleForm.resetFields();
delete this.roleForm.id;
this.roleModalVisible = true;
},
edit(v) {
this.modalType = 1;
this.modalTitle = "编辑角色";
this.$refs.roleForm.resetFields();
// 转换null为""
for (let attr in v) {
if (v[attr] == null) {
v[attr] = "";
}
}
let str = JSON.stringify(v);
let roleInfo = JSON.parse(str);
this.roleForm = roleInfo;
this.roleModalVisible = true;
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除角色 " + v.name + " ?",
loading: true,
onOk: () => {
deleteRole(v.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getRoleList();
}
});
},
});
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
delAll() {
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
loading: true,
onOk: () => {
let ids = "";
this.selectList.forEach(function (e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
deleteRole(ids).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.clearSelectAll();
this.getRoleList();
}
});
},
});
},
// 菜单权限
async editPerm(v) {
if (this.treeLoading) {
this.$Message.warning("菜单权限数据加载中,请稍后点击查看");
return;
}
this.editRolePermId = v.id;
this.modalTitle = "分配 " + v.name + " 的菜单权限";
// 匹配勾选
let rolePerms;
// 当前角色的菜单权限
let res = await selectRoleMenu(v.id);
if (res.result) {
rolePerms = res.result;
this.rolePermsWay = res.result;
}
// 递归判断子节点
this.checkPermTree(this.permData, rolePerms);
console.warn(this.permData);
this.permModalVisible = true;
},
// 递归判断子节点
checkPermTree(permData, rolePerms) {
let that = this;
permData.forEach((p) => {
if (that.hasPerm(p, rolePerms) && p.status != -1) {
this.$set(p, "checked", true);
} else {
this.$set(p, "checked", false);
}
if (p.children && p.children.length > 0) {
that.checkPermTree(p.children, rolePerms);
}
});
},
// 判断角色拥有的权限节点勾选
hasPerm(p, rolePerms) {
console.log(p, rolePerms);
if (!rolePerms) return false;
let flag = false;
for (let i = 0; i < rolePerms.length; i++) {
if (p.id == rolePerms[i].menuId) {
this.$set(p, "isSuper", rolePerms[i].isSuper);
flag = true;
break;
}
}
if (flag) {
return true;
}
return false;
},
// 递归全选节点
selectedTreeAll(permData, select) {
let that = this;
permData.forEach(function (e) {
e.checked = select;
if (e.children && e.children.length > 0) {
that.selectedTreeAll(e.children, select);
}
});
},
/**分配菜单权限 */
submitPermEdit() {
this.saveRoleWay = [];
this.selectIsSuperModel = true; //打开选择权限
let selectedNodes = this.$refs.tree.getCheckedNodes();
let way = [];
selectedNodes.forEach((e) => {
console.log(e);
let perm = {
title: e.title,
isSuper: e.isSuper,
menuId: e.id,
roleId: this.editRolePermId,
};
way.push(perm);
this.saveRoleWay = way;
});
},
/**保存权限 */
saveRole() {
this.superModelLoading = true;
saveRoleMenu(this.editRolePermId, this.saveRoleWay).then((res) => {
this.superModelLoading = false;
if (res.success) {
this.$Message.success("操作成功");
// 标记重新获取菜单数据
this.$store.commit("setAdded", false);
util.initRouter(this);
this.getRoleList();
this.permModalVisible = false;
}
});
},
cancelPermEdit() {
this.permModalVisible = false;
},
loadData(item, callback) {
loadDepartment(item.id, {openDataFilter: false}).then((res) => {
if (res.success) {
res.result.forEach(function (e) {
e.selected = false;
if (e.isParent) {
e.loading = false;
e.children = [];
}
if (e.status == -1) {
e.title = "[已禁用] " + e.title;
e.disabled = true;
}
});
callback(res.result);
}
});
},
expandCheckDep(v) {
// 判断展开子节点
this.checkDepTree(v.children, this.editDepartments);
},
// 判断子节点
checkDepTree(depData, roleDepIds) {
let that = this;
depData.forEach(function (p) {
if (that.hasDepPerm(p, roleDepIds)) {
p.selected = true;
} else {
p.selected = false;
}
});
},
changeOpen(v) {
if (v == "0") {
this.permData.forEach((e) => {
e.expand = true;
if (e.children && e.children.length > 0) {
e.children.forEach((c) => {
c.expand = true;
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
b.expand = true;
});
}
});
}
});
} else if (v == "1") {
this.permData.forEach((e) => {
e.expand = false;
if (e.children && e.children.length > 0) {
e.children.forEach((c) => {
c.expand = false;
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
b.expand = false;
});
}
});
}
});
} else if (v == "2") {
this.permData.forEach((e) => {
e.expand = true;
if (e.children && e.children.length > 0) {
e.children.forEach((c) => {
c.expand = false;
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
b.expand = false;
});
}
});
}
});
} else if (v == "3") {
this.permData.forEach((e) => {
e.expand = true;
if (e.children && e.children.length > 0) {
e.children.forEach((c) => {
c.expand = true;
if (c.children && c.children.length > 0) {
c.children.forEach(function (b) {
b.expand = false;
});
}
});
}
});
}
},
},
mounted() {
this.init();
},
};
</script>

View File

@@ -0,0 +1,180 @@
<template>
<div class="layout">
<div class="row" v-if="client ==item.client" v-for="(item,index) in formValidate" :key="index">
<div class="col">
<Card :padding="0">
<!-- app -->
<div class="icon-item" v-if="item.clientType== 'APP'">
<img class="icon" src="../../../../assets/setting/app.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if="item.clientType== 'PC'">
<!-- pc -->
<img class="icon" src="../../../../assets/setting/pc.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if="item.clientType== 'WECHAT_MP'">
<!-- 小程序 -->
<img class="icon" src="../../../../assets/setting/wechat_mp.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if=" item.clientType== 'H5'">
<!-- h5 -->
<img class="icon" src="../../../../assets/setting/h5.svg" alt="" srcset="">
</div>
<div class='pay-title'> {{way[item.clientType]}}</div>
<div>
<Divider orientation="left">登录设置</Divider>
<div class="pay-list">
<Form style="width:100%;" ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
<FormItem label="appId" prop="appId">
<Input @on-enter="setupSetting" class="label-appkey" v-model="item.appId" />
</FormItem>
<FormItem label="appKey" prop="appKey">
<Input @on-enter="setupSetting" v-model="item.appKey" />
</FormItem>
</Form>
<Button @click="setupSetting">保存设置</Button>
</div>
</div>
</Card>
</div>
</div>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "../setting/validate";
import { getPaymentSupportForm } from "@/api/setting";
export default {
data() {
return {
ruleValidate: {},
way: {
APP: "移动应用端",
H5: "移动端",
WECHAT_MP: "小程序端",
PC: "PC端",
},
formValidate: {},
pay: "",
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
setupSetting() {
this.$Spin.show();
setTimeout(() => {
this.$Spin.hide();
setSetting(this.type, {
qqConnectSettingItemList: this.formValidate,
}).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
this.$Modal.remove();
} else {
this.$Message.error("保存失败!");
this.$Modal.remove();
}
});
}, 3000);
},
// 实例化数据
async init() {
this.formValidate = JSON.parse(this.res).qqConnectSettingItemList;
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "../setting/style.scss";
.pay-title {
text-align: center;
margin: 10px 0;
}
.col {
width: 100%;
}
.layout {
padding: 20px;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
}
.row {
width: 350px;
margin-right: 20px;
display: flex;
margin-bottom: 20px;
/deep/ .ivu-card-body {
padding: 0 16px !important;
}
}
.label-item {
display: flex;
}
.label-item {
display: flex;
align-items: center;
}
.pay-list {
display: flex;
justify-content: center;
padding-bottom: 10px;
flex-direction: column;
align-items: center;
/deep/ .ivu-btn {
width: 100px;
}
}
.icon-item {
width: 100%;
padding: 30px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.ivu-form-item {
display: flex;
align-items: center;
}
.ivu-row {
width: 100%;
}
.icon {
width: 100px;
height: 100px;
}
</style>

View File

@@ -0,0 +1,178 @@
<template>
<div class="layout">
<div class="row" v-if="client ==item.client" v-for="(item,index) in formValidate" :key="index">
<div class="col">
<Card :padding="0">
<!-- app -->
<div class="icon-item" v-if="item.clientType== 'APP'">
<img class="icon" src="../../../../assets/setting/app.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if="item.clientType== 'PC'">
<!-- pc -->
<img class="icon" src="../../../../assets/setting/pc.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if="item.clientType== 'WECHAT_MP'">
<!-- 小程序 -->
<img class="icon" src="../../../../assets/setting/wechat_mp.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if=" item.clientType== 'H5'">
<!-- h5 -->
<img class="icon" src="../../../../assets/setting/h5.svg" alt="" srcset="">
</div>
<div class='pay-title'> {{way[item.clientType]}}</div>
<div>
<Divider orientation="left">登录设置</Divider>
<div class="pay-list">
<Form style="width:100%;" ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
<FormItem label="appId" prop="appId">
<Input @on-enter="setupSetting" class="label-appkey" v-model="item.appId" />
</FormItem>
<FormItem label="appSecret" prop="appSecret">
<Input @on-enter="setupSetting" v-model="item.appSecret" />
</FormItem>
</Form>
<Button @click="setupSetting">保存设置</Button>
</div>
</div>
</Card>
</div>
</div>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "../setting/validate";
import { getPaymentSupportForm } from "@/api/setting";
export default {
data() {
return {
ruleValidate: {},
way: {
APP: "移动应用端",
H5: "移动端",
WECHAT_MP: "小程序端",
PC: "PC端",
},
formValidate: {},
pay: "",
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
setupSetting() {
this.$Spin.show();
setTimeout(() => {
this.$Spin.hide();
setSetting(this.type, {
wechatConnectSettingItems: this.formValidate,
}).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
this.$Modal.remove();
} else {
this.$Message.error("保存失败!");
this.$Modal.remove();
}
});
}, 3000);
},
// 实例化数据
async init() {
this.formValidate = JSON.parse(this.res).wechatConnectSettingItems;
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "../setting/style.scss";
.pay-title {
text-align: center;
margin: 10px 0;
}
.col {
width: 100%;
}
.layout {
padding: 20px;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
}
.row {
width: 350px;
margin-right: 20px;
display: flex;
margin-bottom: 20px;
/deep/ .ivu-card-body {
padding: 0 16px !important;
}
}
.label-item {
display: flex;
}
.label-item {
display: flex;
align-items: center;
}
.pay-list {
display: flex;
justify-content: center;
padding-bottom: 10px;
flex-direction: column;
align-items: center;
/deep/ .ivu-btn {
width: 100px;
}
}
.icon-item {
width: 100%;
padding: 30px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.ivu-form-item {
display: flex;
align-items: center;
}
.ivu-row {
width: 100%;
}
.icon {
width: 100px;
height: 100px;
}
</style>

View File

@@ -0,0 +1,103 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="160" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="appId" prop="appId">
<Input class="w200" v-model="formValidate.appId" />
</FormItem>
<FormItem label="certPath" prop="certPath">
<Input v-model="formValidate.certPath" />
</FormItem>
<FormItem label="alipayPublicCertPath" prop="alipayPublicCertPath">
<Input v-model="formValidate.alipayPublicCertPath" />
</FormItem>
<FormItem label="privateKey" class="label-item" prop="privateKey">
<Input v-model="formValidate.privateKey" />
</FormItem>
<FormItem label="rootCertPath" prop="rootCertPath">
<Input v-model="formValidate.rootCertPath" />
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "../setting/validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: {
accessKeyId: "",
accessKeySecret: "",
bucketName: "",
picLocation: "",
endPoint: "",
},
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "../setting/style.scss";
.label-item {
display: flex;
}
.w200 {
/deep/ .ivu-input {
width: 250px !important;
margin: 0 10px;
}
}
/deep/ .ivu-input {
width: 450px !important;
margin: 0 10px;
}
.ivu-input-wrapper {
width: 450px;
margin-right: 10px;
}
</style>

View File

@@ -0,0 +1,189 @@
<template>
<div class="layout">
<div class="row" v-for="(client,clientIndex) in supportForm.clients" :key="clientIndex">
<div class="col" v-if="client ==item.client" v-for="(item,index) in formValidate" :key="index">
<Card :padding="0">
<div>
<!-- app -->
<div class="icon-item" v-if="client ==item.client &&item.client== 'APP'">
<img class="icon" src="../../../../assets/setting/app.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if=" client ==item.client && item.client== 'PC'">
<!-- pc -->
<img class="icon" src="../../../../assets/setting/pc.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if=" client ==item.client && item.client== 'WECHAT_MP'">
<!-- 小程序 -->
<img class="icon" src="../../../../assets/setting/wechat_mp.svg" alt="" srcset="">
</div>
<div class="icon-item" v-if=" client ==item.client && item.client== 'H5'">
<!-- h5 -->
<img class="icon" src="../../../../assets/setting/h5.svg" alt="" srcset="">
</div>
<div class='pay-title' v-if=" client ==item.client "> {{way[item.client]}}</div>
<div v-if=" client ==item.client ">
<Divider orientation="left">支付设置</Divider>
<div class="pay-list">
<CheckboxGroup @on-change="handleChangePayType" v-model="item.supports">
<Checkbox v-for="(support,i) in supportForm.payments" :key="i" :label="support">
{{payWay[support] || support}}
</Checkbox>
</CheckboxGroup>
</div>
</div>
</div>
</Card>
</div>
</div>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "../setting/validate";
import { getPaymentSupportForm } from "@/api/setting";
export default {
data() {
return {
ruleValidate: {},
way: {
APP: "移动应用端",
H5: "移动端",
WECHAT_MP: "小程序端",
PC: "PC端",
},
formValidate: {},
pay: "",
// key obj
payWay: {
ALIPAY: "支付宝支付",
WECHAT: "微信支付",
WALLET: "余额支付",
},
supportForm: "",
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
handleChangePayType(val) {
this.$Modal.confirm({
title: "修改支付设置",
content: "您是否修改此项?",
loading: true,
onOk: () => {
this.setupSetting();
},
onCancel: () => {
val.splice(val.length - 1, 1);
},
});
},
setupSetting() {
setSetting(this.type, { paymentSupportItems: this.formValidate }).then(
(res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
this.$Modal.remove();
} else {
this.$Message.error("保存失败!");
this.$Modal.remove();
}
}
);
},
// 实例化数据
async init() {
this.formValidate = JSON.parse(this.res).paymentSupportItems;
console.log(this.formValidate);
await getPaymentSupportForm().then((res) => {
// res.result.payments = ["H5", "PC"];
this.supportForm = res.result;
});
},
},
};
</script>
<style lang="scss" scoped>
@import "../setting/style.scss";
.pay-title {
text-align: center;
margin: 10px 0;
}
.layout {
padding: 20px;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-start;
}
.row {
width: 300px;
margin-right: 20px;
display: flex;
margin-bottom: 20px;
/deep/ .ivu-card-body {
padding: 0 16px !important;
}
}
.label-item {
display: flex;
}
.label-item {
display: flex;
align-items: center;
}
.pay-list {
display: flex;
justify-content: center;
padding-bottom: 10px;
}
.icon-item {
width: 100%;
padding: 30px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.ivu-form-item {
display: flex;
align-items: center;
}
.ivu-row {
width: 100%;
}
.icon {
width: 100px;
height: 100px;
}
</style>

View File

@@ -0,0 +1,109 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="appId" prop="appId">
<Input class="w200" v-model="formValidate.appId" />
</FormItem>
<FormItem label="mchId" prop="mchId">
<Input class="w200" v-model="formValidate.mchId" />
</FormItem>
<FormItem label="apiKey3" prop="apiKey3">
<Input v-model="formValidate.apiKey3" />
</FormItem>
<FormItem label="apiclient_cert_p12" class="label-item" prop="apiclient_cert_p12">
<Input v-model="formValidate.apiclient_cert_p12" />
</FormItem>
<FormItem label="apiclient_cert_pem" prop="apiclient_cert_pem">
<Input v-model="formValidate.apiclient_cert_pem" />
</FormItem>
<FormItem label="apiclient_key" prop="apiclient_key">
<Input v-model="formValidate.apiclient_key" />
</FormItem>
<FormItem label="serialNumber" prop="serialNumber">
<Input v-model="formValidate.serialNumber" />
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "../setting/validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: {
accessKeyId: "",
accessKeySecret: "",
bucketName: "",
picLocation: "",
endPoint: "",
},
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "../setting/style.scss";
.label-item {
display: flex;
}
.w200 {
/deep/ .ivu-input {
width: 250px !important;
margin: 0 10px;
}
}
/deep/ .ivu-input {
width: 450px !important;
margin: 0 10px;
}
.ivu-input-wrapper {
width: 450px;
margin-right: 10px;
}
</style>

View File

@@ -0,0 +1,766 @@
<template>
<div>
<Card>
<Tabs v-model="tabName" :animated="false" style="overflow: visible">
<TabPane label="基础设置" name="base">
<div style="display:flex;position:relative">
<Form
ref="baseForm"
:model="base"
:label-width="140"
label-position="right"
:rules="baseValidate"
>
<FormItem label="网站名称" prop="siteName">
<Input type="text" v-model="base.siteName" placeholder="请输入网站名称" style="width: 350px"/>
</FormItem>
<FormItem label="ICP证书号" prop="icp">
<Input type="text" v-model="base.icp" placeholder="请输入ICP证书号"
style="width: 350px"/>
</FormItem>
<FormItem label="Logo" prop="logo">
<upload-pic-input v-model="base.logo" style="width: 350px"></upload-pic-input>
</FormItem>
<FormItem label="商家中心Logo" prop="sellerLogo">
<upload-pic-input v-model="base.sellerLogo" style="width: 350px"></upload-pic-input>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px" :loading="saveLoading"
@click="saveBase">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</div>
</TabPane>
<TabPane label="积分设置" name="point">
<div style="display:flex;position:relative">
<Form
ref="pointForm"
:model="point"
:label-width="140"
label-position="right"
:rules="pointValidate"
>
<FormItem label="注册" prop="register">
<Input type="text" v-model="point.register" placeholder="请输入注册赠送积分"
style="width: 350px"/>
</FormItem>
<FormItem label="登陆" prop="login">
<Input type="text" v-model="point.login" placeholder="请输入登陆赠送积分"
style="width: 350px"/>
</FormItem>
<FormItem label="消费一元" prop="money">
<Input type="text" v-model="point.money" placeholder="请输入积分"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px" :loading="saveLoading"
@click="savePoint">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</div>
</TabPane>
<TabPane label="订单设置" name="order">
<div style="display:flex;position:relative">
<Form
ref="orderForm"
:model="order"
:label-width="140"
label-position="right"
:rules="orderValidate"
>
<FormItem label="自动取消 分钟" prop="autoCancel">
<Input type="text" v-model="order.autoCancel" placeholder="请输入自动取消分钟"
style="width: 350px"/>
</FormItem>
<FormItem label="自动收货 天" prop="autoReceive">
<Input type="text" v-model="order.autoReceive" placeholder="请输入自动收货天数"
style="width: 350px"/>
</FormItem>
<FormItem label="自动收货 天" prop="autoComplete">
<Input type="text" v-model="order.autoComplete" placeholder="请输入自动完成天数"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px" :loading="saveLoading"
@click="saveOrder">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</div>
</TabPane>
<TabPane label="商品设置" name="goods">
<div style="display:flex;position:relative">
<Form
ref="goodsForm"
:model="goods"
:label-width="140"
label-position="right"
:rules="goodsValidate"
>
<FormItem label="是否开启商品审核" prop="goodsCheck">
<RadioGroup v-model="goods.goodsCheck">
<Radio label="OPEN">开启</Radio>
<Radio label="CLOSE">关闭</Radio>
</RadioGroup>
</FormItem>
<FormItem label="商品页面小图宽度" prop="smallPictureWidth">
<Input type="text" v-model="goods.smallPictureWidth" placeholder="商品页面小图宽度"
style="width: 350px"/>
</FormItem>
<FormItem label="商品页面小图高度" prop="smallPictureHeight">
<Input type="text" v-model="goods.smallPictureHeight" placeholder="商品页面小图高度"
style="width: 350px"/>
</FormItem>
<FormItem label="缩略图宽度" prop="abbreviationPictureWidth">
<Input type="text" v-model="goods.abbreviationPictureWidth" placeholder="缩略图宽度"
style="width: 350px"/>
</FormItem>
<FormItem label="缩略图高度" prop="abbreviationPictureHeight">
<Input type="text" v-model="goods.abbreviationPictureHeight" placeholder="缩略图高度"
style="width: 350px"/>
</FormItem>
<FormItem label="原图宽" prop="originalPictureWidth">
<Input type="text" v-model="goods.originalPictureWidth" placeholder="原图宽"
style="width: 350px"/>
</FormItem>
<FormItem label="原图高" prop="originalPictureHeight">
<Input type="text" v-model="goods.originalPictureHeight" placeholder="原图高"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px" :loading="saveLoading"
@click="saveGoods">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</div>
</TabPane>
<TabPane label="信任登陆" name="trust">
<div>
<Row style="background:#eee;padding:10px;" :gutter="16">
<Col span="12">
<Card>
<p slot="title">微信信任登陆</p>
<Form
ref="wechatForm"
:model="wechat"
:label-width="140"
label-position="right"
>
<FormItem label="appId" prop="appId">
<Input type="text" v-model="wechat.appId" placeholder="appId"
style="width: 350px"/>
</FormItem>
<FormItem label="appSecret" prop="appSecret">
<Input type="text" v-model="wechat.appSecret" placeholder="appSecret"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackUrl" prop="callbackUrl">
<Input type="text" v-model="wechat.callbackUrl" placeholder="callbackUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackLoginUrl" prop="callbackLoginUrl">
<Input type="text" v-model="wechat.callbackLoginUrl"
placeholder="callbackLoginUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackBindUrl" prop="callbackBindUrl">
<Input type="text" v-model="wechat.callbackBindUrl"
placeholder="callbackBindUrl"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px"
:loading="saveLoading"
@click="saveWechat">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</Card>
</Col>
<Col span="12">
<Card>
<p slot="title">QQ信任登陆</p>
<Form
ref="qqForm"
:model="qq"
:label-width="140"
label-position="right"
>
<FormItem label="appId" prop="appId">
<Input type="text" v-model="qq.appId" placeholder="appId"
style="width: 350px"/>
</FormItem>
<FormItem label="appKey" prop="appKey">
<Input type="text" v-model="qq.appKey" placeholder="appKey"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackUrl" prop="callbackUrl">
<Input type="text" v-model="qq.callbackUrl" placeholder="callbackUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackLoginUrl" prop="callbackLoginUrl">
<Input type="text" v-model="qq.callbackLoginUrl"
placeholder="callbackLoginUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackBindUrl" prop="callbackBindUrl">
<Input type="text" v-model="qq.callbackBindUrl"
placeholder="callbackBindUrl"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px"
:loading="saveLoading"
@click="saveQQ">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</Card>
</Col>
</Row>
<Row style="background:#eee;padding:10px;" :gutter="16">
<Col span="12">
<Card>
<p slot="title">微博信任登陆</p>
<Form
ref="weiboForm"
:model="weibo"
:label-width="140"
label-position="right"
>
<FormItem label="appKey" prop="appKey">
<Input type="text" v-model="weibo.appKey" placeholder="appKey"
style="width: 350px"/>
</FormItem>
<FormItem label="appSecret" prop="appSecret">
<Input type="text" v-model="weibo.appSecret" placeholder="appSecret"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackUrl" prop="callbackUrl">
<Input type="text" v-model="weibo.callbackUrl" placeholder="callbackUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackLoginUrl" prop="callbackLoginUrl">
<Input type="text" v-model="weibo.callbackLoginUrl"
placeholder="callbackLoginUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackBindUrl" prop="callbackBindUrl">
<Input type="text" v-model="weibo.callbackBindUrl"
placeholder="callbackBindUrl"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px"
:loading="saveLoading"
@click="saveWeibo">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</Card>
</Col>
<Col span="12">
<Card>
<p slot="title">支付宝信任登陆</p>
<Form
ref="alipayForm"
:model="alipay"
:label-width="140"
label-position="right"
>
<FormItem label="appId" prop="appId">
<Input type="text" v-model="alipay.appId" placeholder="appId"
style="width: 350px"/>
</FormItem>
<FormItem label="appSecret" prop="appSecret">
<Input type="text" v-model="alipay.appSecret" placeholder="appSecret"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackUrl" prop="callbackUrl">
<Input type="text" v-model="alipay.callbackUrl" placeholder="callbackUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackLoginUrl" prop="callbackLoginUrl">
<Input type="text" v-model="alipay.callbackLoginUrl"
placeholder="callbackLoginUrl"
style="width: 350px"/>
</FormItem>
<FormItem label="callbackBindUrl" prop="callbackBindUrl">
<Input type="text" v-model="alipay.callbackBindUrl"
placeholder="callbackBindUrl"
style="width: 350px"/>
</FormItem>
<FormItem>
<Button type="primary" style="width: 100px;margin-right:5px"
:loading="saveLoading"
@click="saveAlipay">保存
</Button>
</FormItem>
</Form>
<Spin fix v-if="loading"></Spin>
</Card>
</Col>
</Row>
<Spin fix v-if="loading"></Spin>
</div>
</TabPane>
</Tabs>
</Card>
</div>
</template>
<script>
import {
getParams,
editParams
} from "@/api/platform.js";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
import {regular} from '@/utils'
export default {
name: "setting-manage",
components: {
uploadPicInput
},
data() {
return {
tabName: "base",
loading: false, // 表单加载状态
saveLoading: false,
base: {
siteName: "",
icp: "",
logo: "",
sellerLogo: "",
},
point: {
register: "",
login: "",
money: ""
},
order: {
autoCancel: "",
autoReceive: "",
autoComplete: ""
},
goods: {
goodsCheck: "OPEN",
smallPictureWidth: "",
smallPictureHeight: "",
abbreviationPictureWidth: "",
abbreviationPictureHeight: "",
originalPictureWidth: "",
originalPictureHeight: ""
},
wechat: {
appId: "",
appSecret: "",
callbackUrl: "",
callbackLoginUrl: "",
callbackBindUrl: ""
},
qq: {
appId: "",
appKey: "",
callbackUrl: "",
callbackLoginUrl: "",
callbackBindUrl: ""
},
weibo: {
appKey: "",
appSecret: "",
callbackUrl: "",
callbackLoginUrl: "",
callbackBindUrl: ""
},
alipay: {
appId: "",
appSecret: "",
callbackUrl: "",
callbackLoginUrl: "",
callbackBindUrl: ""
},
baseValidate: {
// 表单验证规则
siteName: [{required: true, message: "不能为空", trigger: "blur"}],
icp: [{required: true, message: "不能为空", trigger: "blur"}],
logo: [{required: true, message: "不能为空", trigger: "blur"}],
sellerLogo: [{required: true, message: "不能为空", trigger: "blur"}]
},
pointValidate: {
// 表单验证规则
register: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
login: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
money: [
{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}]
},
orderValidate: {
// 表单验证规则
autoCancel: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
autoReceive: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
autoComplete: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}]
},
goodsValidate: {
smallPictureWidth: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
smallPictureHeight: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
abbreviationPictureWidth: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
abbreviationPictureHeight: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
originalPictureWidth: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}],
originalPictureHeight: [{
required: true,
validator: (rule, value, callback) => {
if (!regular.integer.test(value)) {
callback(new Error('请输入正整数,且不为零!'))
} else {
callback()
}
},
trigger: 'blur'
}]
}
};
},
methods: {
init() {
this.initBase();
this.initPoint();
this.initOrder();
this.initGoods();
this.initWechat();
this.initQQ();
this.initWeibo();
this.initAlipay();
},
initBase() {
this.loading = true;
getParams('base').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.base = res.result
}
}
});
},
initPoint() {
this.loading = true;
getParams('point').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.point = res.result
}
}
});
},
initOrder() {
this.loading = true;
getParams('order').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.order = res.result
}
}
});
},
initGoods() {
this.loading = true;
getParams('goods').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.goods = res.result
}
}
});
},
initWeibo() {
this.loading = true;
getParams('weibo').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.weibo = res.result
}
}
});
},
initWechat() {
this.loading = true;
getParams('wechat').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.wechat = res.result
}
}
});
},
initQQ() {
this.loading = true;
getParams('qq').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.qq = res.result
}
}
});
},
initAlipay() {
this.loading = true;
getParams('alipay').then(res => {
if (res.success) {
this.loading = false;
if (res.result) {
this.alipay = res.result
}
}
});
},
saveBase() {
this.$refs.baseForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.base.id = 'base'
editParams(this.base, 'base').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
savePoint() {
this.$refs.pointForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.point.id = 'point'
editParams(this.point, 'point').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
saveOrder() {
this.$refs.orderForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.order.id = 'order'
editParams(this.order, 'order').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
saveGoods() {
this.$refs.goodsForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.goods.id = 'goods'
editParams(this.goods, 'goods').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
saveWechat() {
this.$refs.wechatForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.wechat.id = 'wechat'
editParams(this.wechat, 'wechat').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
saveQQ() {
this.$refs.qqForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.qq.id = 'qq'
editParams(this.qq, 'qq').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
saveWeibo() {
this.$refs.wechatForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.weibo.id = 'weibo'
editParams(this.weibo, 'weibo').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
},
saveAlipay() {
this.$refs.alipayForm.validate(valid => {
if (valid) {
this.saveLoading = true;
this.alipay.id = 'alipay'
editParams(this.alipay, 'alipay').then(res => {
this.saveLoading = false;
if (res.success) {
this.$Message.success("保存成功");
}
});
}
});
}
},
mounted() {
let name = this.$route.query.name;
if (name) {
this.tabName = name;
}
this.init();
}
};
</script>

View File

@@ -0,0 +1,151 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="站点名称" prop="siteName">
<Input v-model="formValidate.siteName" />
</FormItem>
<FormItem label="icp" prop="icp">
<Input v-model="formValidate.icp" />
</FormItem>
<FormItem label="后台Logo" prop="domainLogo">
<div class="label-item-upload">
<img v-if="formValidate.domainLogo" class="img" :src="formValidate.domainLogo" />
<img v-else class="img" src="../../../../assets/emptyImg.png" alt="">
<Button @click="onClickImg('domainLogo')">选择图片</Button>
</div>
</FormItem>
<FormItem label="买家端Logo" prop="buyerSideLogo">
<div class="label-item-upload">
<img v-if="formValidate.buyerSideLogo" class="img" :src="formValidate.buyerSideLogo" />
<img v-else class="img" src="../../../../assets/emptyImg.png" alt="">
<Button @click="onClickImg('buyerSideLogo')">选择图片</Button>
</div>
</FormItem>
<FormItem label="商家端Logo" prop="sellerSideLogo">
<div class="label-item-upload">
<img v-if="formValidate.sellerSideLogo" class="img" :src="formValidate.sellerSideLogo" />
<img v-else class="img" src="../../../../assets/emptyImg.png" alt="">
<Button @click="onClickImg('sellerSideLogo')">选择图片</Button>
</div>
</FormItem>
<FormItem label="站点地址" prop="staticPageAddress">
<Input v-model="formValidate.staticPageAddress" />
</FormItem>
<FormItem label="wap站点地址" prop="staticPageWapAddress">
<Input v-model="formValidate.staticPageWapAddress" />
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
<Modal width="1200px" v-model="picModelFlag">
<ossManage @callback="callbackSelected" ref="ossManage" />
</Modal>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
import ossManage from "@/views/sys/oss-manage/ossManage";
export default {
title: "基础设置",
props: ["res", "type"],
components: {
ossManage,
},
data() {
return {
handleSubmit,
picModelFlag: false,
formValidate: {
buyerSideLogo: "",
domainLogo: "",
icp: "",
sellerSideLogo: "",
siteName: "",
staticPageAddress: "",
staticPageWapAddress: "",
},
selected: "",
ruleValidate: {},
};
},
created() {
console.log(this.type);
this.init();
},
methods: {
// 点击图片
onClickImg(item) {
this.selected = item;
this.$refs.ossManage.selectImage = true;
this.picModelFlag = true;
},
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
callbackSelected(val) {
this.picModelFlag = false;
this.formValidate[this.selected] = val.url;
console.log(val);
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
/**添加必填项 */
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.res).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style scoped lang="scss">
@import "./style.scss";
.label-item {
display: flex;
> .ivu-input {
width: 200px;
margin: 0 10px;
}
}
.label-item-upload {
display: flex;
align-items: flex-end;
img {
margin-right: 10px;
width: 100px;
height: 100px;
}
}
</style>

View File

@@ -0,0 +1,151 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="商品审核" prop="goodsCheck">
<RadioGroup v-model="formValidate.goodsCheck">
<Radio label="true">开启</Radio>
<Radio label="false">关闭</Radio>
</RadioGroup>
</FormItem>
<div class="label-item">
<FormItem label="小图宽" prop="smallPictureWidth">
<Input type="number" v-model="formValidate.smallPictureWidth">
<span slot="prepend"></span>
<span slot="append">px</span>
</Input>
</FormItem>
<FormItem label="小图高" class="label-item" prop="smallPictureHeight">
<Input type="number" v-model="formValidate.smallPictureHeight">
<span slot="prepend"></span>
<span slot="append">px</span>
</Input>
</FormItem>
</div>
<div class="label-item">
<FormItem class="label-item" label="缩略图宽" prop="abbreviationPictureWidth">
<Input type="number" v-model="formValidate.abbreviationPictureWidth">
<span slot="prepend"></span>
<span slot="append">px</span>
</Input>
</FormItem>
<FormItem class="label-item" label="缩略图高" prop="abbreviationPictureHeight">
<Input type="number" v-model="formValidate.abbreviationPictureHeight">
<span slot="prepend"></span>
<span slot="append">px</span>
</Input>
</FormItem>
</div>
<div class="label-item">
<FormItem class="label-item" label="原图宽高" prop="originalPictureWidth">
<Input type="number" v-model="formValidate.originalPictureWidth">
<span slot="prepend"></span>
<span slot="append">px</span>
</Input>
</FormItem>
<FormItem class="label-item" label="原图宽高" prop="originalPictureHeight">
<Input type="number" v-model="formValidate.originalPictureHeight">
<span slot="prepend"></span>
<span slot="append">px</span>
</Input>
</FormItem>
</div>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
props: ["res", "type"],
data() {
return {
formValidate: {
goodsCheck: 1,
smallPictureHeight: "0",
smallPictureWidth: "0",
abbreviationPictureWidth: "0",
abbreviationPictureHeight: "0",
originalPictureWidth: "0",
originalPictureHeight: "0",
},
ruleValidate: {},
};
},
watch: {
res: {
handler() {},
immediate: true,
},
},
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if( handleSubmit(that, name )){
this.setupSetting()
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
Object.keys(this.res).map((item) => {
this.res[item] += "";
});
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
{
validator: (rule, value, callback) => {
if (value < 0) {
callback(new Error("不能输入负数!"));
} else {
callback();
}
},
trigger: "change",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.label-item {
display: flex;
}
/deep/ .ivu-input {
width: 100px !important;
}
</style>

View File

@@ -0,0 +1,92 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="企业id" prop="ebusinessID">
<Input v-model="formValidate.ebusinessID" />
</FormItem>
<FormItem label="密钥" prop="appKey">
<Input class="label-appkey" v-model="formValidate.appKey" />
</FormItem>
<FormItem label="api地址" prop="reqURL">
<Input v-model="formValidate.reqURL" />
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: { ebusinessID: "", reqURL: "", appKey: "" },
};
},
props: ["res",'type'],
watch: {
res: {
handler() {},
immediate: true,
},
},
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if( handleSubmit(that, name )){
this.setupSetting()
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.label-item {
display: flex;
> .ivu-input {
width: 200px;
margin: 0 10px;
}
}
.label-appkey {
width: 300px !important;
/deep/ input {
width: 300px !important;
}
}
</style>

View File

@@ -0,0 +1,124 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="订单自动取消" prop="autoCancel">
<Input type='number' v-model="formValidate.autoCancel">
<span slot="append"></span>
</Input>
</FormItem>
<FormItem label="订单自动收货" class="label-item" prop="autoReceive">
<Input type='number' v-model="formValidate.autoReceive">
<span slot="append"></span>
</Input>
</FormItem>
<FormItem label="订单自动完成" prop="autoComplete">
<Input type='number' v-model="formValidate.autoComplete">
<span slot="append"></span>
</Input>
</FormItem>
<FormItem label="自动评价" prop="autoEvaluation">
<Input type='number' v-model="formValidate.autoEvaluation">
<span slot="append"></span>
</Input>
</FormItem>
<FormItem label="售后自动取消" prop="autoCancelAfterSale">
<Input type='number' v-model="formValidate.autoCancelAfterSale">
<span slot="append"></span>
</Input>
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: {
autoCancel: "",
autoComplete: "",
autoEvaluation: "",
autoReceive: "",
autoCancelAfterSale: "",
},
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
Object.keys(this.res).map((item) => {
this.res[item] += "";
});
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
{
validator: (rule, value, callback) => {
if (value < 0) {
callback(new Error("不能输入负数!"));
} else {
callback();
}
},
trigger: "change",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.label-item {
display: flex;
}
.ivu-input-wrapper {
width: 100px;
margin-right: 10px;
}
/deep/ .ivu-input {
width: 100px !important;
}
</style>

View File

@@ -0,0 +1,95 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="endPoint" prop="endPoint">
<Input v-model="formValidate.endPoint" />
</FormItem>
<FormItem label="bucketName" class="label-item" prop="bucketName">
<Input v-model="formValidate.bucketName" />
</FormItem>
<FormItem label="picLocation" prop="bucketName">
<Input v-model="formValidate.picLocation" />
</FormItem>
<FormItem label="accessKeyId" prop="accessKeyId">
<Input v-model="formValidate.accessKeyId" />
</FormItem>
<FormItem label="accessKeySecret" prop="accessKeySecret">
<Input v-model="formValidate.accessKeySecret" />
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: {
accessKeyId: "",
accessKeySecret: "",
bucketName: "",
picLocation: "",
endPoint: "",
},
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if( handleSubmit(that, name )){
this.setupSetting()
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.label-item {
display: flex;
}
/deep/ .ivu-input {
width: 300px !important;
margin: 0 10px;
}
.ivu-input-wrapper {
width: 300px;
margin-right: 10px;
}
</style>

View File

@@ -0,0 +1,175 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="积分比例" prop="money">
<Input type="number" v-model="formValidate.money">
<span slot="prepend">1积分=</span>
<span slot="append">人民币</span>
</Input>
</FormItem>
<FormItem label="注册账号" prop="register">
<Input type="number" v-model="formValidate.register">
<span slot="append">积分</span>
</Input>
</FormItem>
<FormItem label="登录" class="label-item" prop="login">
<Input type="number" v-model="formValidate.login">
<span slot="append">积分</span>
</Input>
</FormItem>
<FormItem label="每日签到积分" prop="signIn">
<Input type="number" v-model="formValidate.signIn">
<span slot="append">积分</span>
</Input>
</FormItem>
<FormItem label="订单评价赠送积分" prop="comment">
<Input type="number" v-model="formValidate.comment">
<span slot="append">积分</span>
</Input>
</FormItem>
<FormItem class="label-item" v-for="(point,index) in formValidate.pointSettingItems" :key="index" :label="'签到设置'+(index+1)">
<div class="label-item">
<InputNumber :min="1" v-model="point.day" :formatter="value => `签到${value}天`" :parser="value => value.replace('天', '') && value.replace('签到', '')"></InputNumber>
<InputNumber :min="0" :formatter="value => `赠送${value}积分`" :parser="value => value.replace('积分', '') && value.replace('赠送', '')" v-model="point.point"></InputNumber>
<Button ghost type="error" @click="delSign(point,index)">删除</Button>
</div>
</FormItem>
<FormItem label="操作:">
<Button @click="addSign">新增签到</Button>
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: {},
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if (handleSubmit(that, name)) {
this.setupSetting();
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
delSign(item, index) {
this.formValidate.pointSettingItems.splice(index, 1);
},
addSign() {
if (this.formValidate.pointSettingItems.length >= 4) {
this.$Message.error({
content: "最多设置4项签到设置",
});
return false;
}
this.formValidate.pointSettingItems.push({
point: "0",
day:
this.formValidate.pointSettingItems[
this.formValidate.pointSettingItems.length - 1
].day + 1,
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
Object.keys(this.res).map((item) => {
if (item == "pointSettingItems") {
return false;
}
this.res[item] += "";
});
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
{
validator: (rule, value, callback) => {
if (value < 0) {
callback(new Error("不能输入负数!"));
} else {
callback();
}
},
trigger: "change",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.label-item {
display: flex;
> .ivu-input-number {
width: 100px;
margin-right: 5px;
}
> .ivu-input-number:nth-last-of-type(1) {
width: 150px;
margin-right: 5px;
}
> .ivu-input {
width: 100px;
margin: 0 10px;
}
}
/deep/ .ivu-input {
width: 70px !important;
}
.ivu-input-wrapper {
width: 70px;
margin-right: 10px;
}
.label-btns {
/deep/ .ivu-btn {
margin-right: 10px;
}
}
</style>

View File

@@ -0,0 +1,92 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="accessKeyId" prop="accessKeyId">
<Input v-model="formValidate.accessKeyId" />
</FormItem>
<FormItem label="accessSecret" prop="accessSecret">
<Input v-model="formValidate.accessSecret" />
</FormItem>
<FormItem label="regionId" prop="regionId">
<Input v-model="formValidate.regionId" />
</FormItem>
<FormItem label="signName" prop="signName">
<Input v-model="formValidate.signName" />
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
data() {
return {
ruleValidate: {},
formValidate: {
accessKeyId: "",
regionId: "",
picLocation: "",
accessSecret: "",
},
};
},
props: ["res", "type"],
created() {
this.init();
},
methods: {
submit(name) {
let that = this;
if( handleSubmit(that, name )){
this.setupSetting()
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
Object.keys(this.formValidate).forEach((item) => {
this.ruleValidate[item] = [
{
required: true,
message: "请填写必填项",
trigger: "blur",
},
];
});
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.label-item {
display: flex;
}
/deep/ .ivu-input {
width: 300px !important;
margin: 0 10px;
}
.ivu-input-wrapper {
width: 300px;
margin-right: 10px;
}
</style>

View File

@@ -0,0 +1,67 @@
<template>
<div class="layout">
<Form ref="formValidate" :label-width="150" label-position="right" :model="formValidate" :rules="ruleValidate">
<FormItem label="提现审核是否开启">
<i-switch v-model="formValidate.apply" style="margin-top:7px;"><span slot="open"></span>
<span slot="close"></span>
</i-switch>
</FormItem>
<div class="label-btns">
<Button type="primary" @click="submit('formValidate')">保存</Button>
</div>
</Form>
</div>
</template>
<script>
import { setSetting } from "@/api/index";
import { handleSubmit } from "./validate";
export default {
data() {
return {
formValidate: {
apply: true,
},
switchTitle: "提现审核是否开启",
};
},
created() {
this.init();
},
props: ["res", "type"],
methods: {
submit(name) {
let that = this;
if( handleSubmit(that, name )){
this.setupSetting()
}
},
setupSetting() {
setSetting(this.type, this.formValidate).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
});
},
// 实例化数据
init() {
this.res = JSON.parse(this.res);
this.$set(this, "formValidate", { ...this.res });
},
},
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
/deep/ .ivu-form-item-content{
align-items: center;
paddinig-bottom: 5px;
}
</style>

View File

@@ -0,0 +1,22 @@
/deep/ .ivu-input{
width: 200px !important;
}
.label-btns{
margin-left: 150px;
}
.ivu-form-item{
padding: 10px 0;
}
.ivu-input-wrapper {
width: 150px;
margin-right: 10px;
}
/deep/ .ivu-form-item-content {
margin-left: 0 !important;
display: flex;
}

View File

@@ -0,0 +1,23 @@
//表单中必填
export function validateRequired(rule, value, callback) {
if (value != void 0 || value != null) {
callback();
} else {
return callback(new Error("必填项不能为空"));
}
}
// 验证必填项
export function handleSubmit(that, name) {
let flag = false;
that.$refs[name].validate(valid => {
if (valid) {
flag = true;
return flag;
} else {
that.$Message.error("请正确填写内容!");
return flag;
}
});
return flag
}

View File

@@ -0,0 +1,126 @@
<template>
<Card v-if="show">
<Tabs v-model="selected" @on-click="clickTab">
<TabPane :label="tabItem.name" :name="tabItem.type" v-for="(tabItem, tabIndex) in tabWay" :key="tabIndex">
<component v-if="settingData" :res="settingData" :type="selected"
:is="templateSetting[tabItem.type]"></component>
</TabPane>
</Tabs>
</Card>
</template>
<script>
import {getSetting} from "@/api/index.js";
import templateSetting from "./template";
export default {
data() {
return {
templateSetting,
selected: "",
settingData: "",
show: true,
setting: [
//基础配置
{
type: "BASE_SETTING",
name: "基础配置",
},
//商品设置
{
type: "GOODS_SETTING",
name: "商品设置",
},
// 快递鸟设置
{
type: "KUAIDI_SETTING",
name: "快递鸟设置",
},
//订单配置
{
type: "ORDER_SETTING",
name: "订单配置",
},
//阿里OSS配置
{
type: "OSS_SETTING",
name: "阿里OSS配置",
},
//阿里短信配置
{
type: "SMS_SETTING",
name: "阿里短信配置",
},
//积分设置
{type: "POINT_SETTING", name: "积分设置"},
{
type: "WITHDRAWAL_SETTING",
name: "提现设置",
},
],
authLogin: [
// 微信设置
{type: "WECHAT_CONNECT", name: "微信设置"},
// QQ设置
{type: "QQ_CONNECT", name: "QQ设置"},
//微博联合登陆
// {type: "WEIBO_CONNECT", name: "微博联合登陆"},
// //支付宝配置
// {type: "ALIPAY_CONNECT", name: "支付宝配置"},
],
pay: [
//支付宝支付设置
{type: "PAYMENT_SUPPORT", name: "支付开启/关闭"},
//支付宝支付设置
{type: "ALIPAY_PAYMENT", name: "支付宝支付设置"},
//微信支付设置
{type: "WECHAT_PAYMENT", name: "微信支付设置"},
],
tabWay: [],
};
},
watch: {
$route(to, from) {
this.selected = "";
this.show = false;
this.getSettingData(this.selected);
this.$nextTick(() => {
this.show = true;
});
// this.$router.go(0)
},
},
mounted() {
this.clickTab(this.selected);
},
methods: {
clickTab(name) {
this.selected = name;
this.getSettingData(name);
},
/**
* 进入页面请求第一个配置
*/
getSettingData(name) {
this.settingData = "";
Object.keys(this).forEach((item) => {
if (this.$route.name == item) {
this.tabWay = this[item];
}
});
// 点击页面给每项第一个数据赋值
if (!name) {
name = this.tabWay[0].type;
this.selected = name;
}
getSetting(name).then((res) => {
if (res.result) {
this.settingData = JSON.stringify(res.result);
}
});
},
},
};
</script>

View File

@@ -0,0 +1,160 @@
<template>
<Card class="card">
<div class="cardBox">
<div class="methodItem">
<img src="../../../assets/aliyun.png" height="172" width="440"/>
<h4>阿里云短信</h4></div>
<div class="bar">
<div class="status" style="color: rgb(53, 189, 129);">已启用</div>
<div><a class="links">编辑</a></div>
</div>
</div>
<!-- 阿里云的短信参数 -->
<Modal
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="500"
>
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="accessKeyId" prop="addressName">
<Input v-model="form.accessKeyId" clearable style="width: 100%"/>
</FormItem>
<FormItem label="accessSecret" prop="accessSecret">
<Input v-model="form.accessSecret" clearable style="width: 100%"/>
</FormItem>
<FormItem label="regionId" prop="regionId">
<Input v-model="form.regionId" clearable style="width: 100%"/>
</FormItem>
<FormItem label="signName" prop="signName">
<Input v-model="form.signName" clearable style="width: 100%"/>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="saveSetting"
>提交
</Button
>
</div>
</Modal>
</Card>
</template>
<script>
import {getSetting, setSetting} from "@/api/index.js";
import template from "./template";
export default {
name: "smsSettingManage",
components: {
template
},
data() {
return {
submitLoading: false,
template,
selected: "",
settingData: "",
modalTitle: '设置',
modalVisible: false,
form: {},
}
},
filters: {},
methods: {
init() {
settingInfo("SMS_SETTING")
},
setting() {
this.modalVisible = true
},
saveSetting() {
setSetting("SMS_SETTING", this.form).then((res) => {
if (res.code == 200) {
this.$Message.success("保存成功!");
} else {
this.$Message.error("保存失败!");
}
this.modalVisible = false
});
},
settingInfo(v) {
alert()
this.selected = v
getSetting(v).then((res) => {
if (res.result) {
console.log(res)
this.modalVisible = true
this.form = res
}
});
}
},
mounted() {
this.init();
},
};
</script>
<style lang="scss">
.card {
width: 100%;
height: 100%;
position: fixed;
}
.cardBox {
display: inline-block;
border-radius: 2px;
line-height: 1.5;
margin-right: 20px;
width: 300px;
border: 1px solid #eee;
padding: 10px;
}
.methodItem {
width: 100%;
border: 1px solid #f5f5f5;
text-align: center;
padding: 20px 0;
}
methodItem img {
width: 220px;
height: 86px;
}
methodItem h4 {
font-size: 14px;
color: #333;
margin-top: 5px;
}
.methodItem img {
width: 220px;
height: 86px;
}
.bar {
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 10px 8px 0;
}
</style>

View File

@@ -0,0 +1,29 @@
import BASE_SETTING from "./setting/BASE_SETTING";
import GOODS_SETTING from "./setting/GOODS_SETTING";
import ORDER_SETTING from "./setting/ORDER_SETTING";
import POINT_SETTING from "./setting/POINT_SETTING";
import KUAIDI_SETTING from "./setting/KUAIDI_SETTING";
import OSS_SETTING from "./setting/OSS_SETTING";
import SMS_SETTING from "./setting/SMS_SETTING";
import WITHDRAWAL_SETTING from "./setting/WITHDRAWAL_SETTING";
import ALIPAY_PAYMENT from "./pay/ALIPAY_PAYMENT";
import WECHAT_PAYMENT from "./pay/WECHAT_PAYMENT";
import PAYMENT_SUPPORT from "./pay/PAYMENT_SUPPORT";
import WECHAT_CONNECT from "./authLogin/WECHAT_CONNECT";
import QQ_CONNECT from "./authLogin/QQ_CONNECT";
export default {
BASE_SETTING,
GOODS_SETTING,
ORDER_SETTING,
POINT_SETTING,
KUAIDI_SETTING,
OSS_SETTING,
SMS_SETTING,
WITHDRAWAL_SETTING,
PAYMENT_SUPPORT,
WECHAT_PAYMENT,
ALIPAY_PAYMENT,
WECHAT_CONNECT,
QQ_CONNECT
};

View File

@@ -0,0 +1,369 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Tabs value="RESOURCE" @on-click="handleClickType">
<TabPane label="图片源" name="RESOURCE">
<Row>
<Col>
<Row class="operation" style="margin-bottom: 10px">
<Button @click="add" type="primary">添加</Button>
</Row>
<Row>
<Table
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
>
<!-- 商品栏目格式化 -->
<template slot="imageSlot" slot-scope="scope">
<div style="">
<img :src="scope.row.resource" style="height: 60px;margin-top: 1px;width: 90px">
</div>
</template>
</Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
>
</Page>
</Row>
</Col>
</Row>
</TabPane>
<TabPane label="滑块源" name="SLIDER">
<Row>
<Col>
<Row class="operation" style="margin-bottom: 10px">
<Button @click="add" type="primary" icon="md-add">添加</Button>
</Row>
<Row>
<Table
:loading="loading"
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
>
<!-- 商品栏目格式化 -->
<template slot="imageSlot" slot-scope="scope">
<div style="">
<img :src="scope.row.resource" style="height: 60px;margin-top: 1px;width: 60px">
</div>
</template>
</Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10, 20, 50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</Col>
</Row>
</TabPane>
</Tabs>
</Card>
</Col>
</Row>
<Modal
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="500"
>
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="名称" prop="name">
<Input v-model="form.name" maxlength="20" clearable style="width: 100%"/>
</FormItem>
<FormItem label="图片" prop="resource">
<Input v-model="form.resource" clearable style="width: 100%"/>
</FormItem>
<FormItem label="类型" prop="type">
<radio-group v-model="form.type" type="button">
<radio label="RESOURCE">图片源</radio>
<radio label="SLIDER">滑块源</radio>
</radio-group>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit"
>提交
</Button
>
</div>
</Modal>
</div>
</template>
<script>
import * as API_Setting from "@/api/setting";
export default {
data() {
return {
modalVisible: false,//添加验证码源弹出框
modalTitle: "", //添加验证码源弹出框标题
loading: true, // 表单加载状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
modalType: 0, // 添加或编辑标识
submitLoading: false, // 添加或编辑提交状态
form: {
name: "",
resource: "",
type: "RESOURCE",
},//添加编辑表单
formValidate: {
name: [
{
required: true,
message: "请输入名称",
trigger: "blur",
},
],
resource: [
{
required: true,
message: "请上传图片",
trigger: "blur",
},
],
},
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
type: "RESOURCE"
},
columns: [
{
title: "名称",
key: "name",
minWidth: 80,
},{
title: "图片",
key: "resource",
width: 150,
slot: "imageSlot"
},
{
title: "创建人",
key: "createBy",
minWidth: 80,
},
{
title: "创建时间",
key: "createTime",
minWidth: 120,
},
{
title: "最后修改人",
key: "updateBy",
minWidth: 80,
},
{
title: "更新时间",
key: "updateTime",
minWidth: 120,
},
{
title: "操作",
key: "action",
align: "center",
width: 200,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "info",
size: "small",
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
on: {
click: () => {
this.remove(params.row);
}
}
},
"删除"
)
]);
},
},
],
data: [], // 表单数据
total: 0,//条数
};
},
methods: {
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
this.getDataList();
},
//切换tab
handleClickType(v) {
this.searchForm.pageNumber = 1 // 当前页数
this.searchForm.pageSize = 10 // 页面大小
//图片源
if (v == "RESOURCE") {
this.searchForm.type = "RESOURCE"
}
//滑块源
if (v == "SLIDER") {
this.searchForm.type = "SLIDER"
}
this.getDataList();
},
//获取验证码源数据
getDataList() {
this.loading = true;
API_Setting.verificationPage(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total
}
});
this.loading = false;
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
//添加验证码源
add() {
this.form.type = this.searchForm.type
this.modalVisible = true
this.modalType = 0
this.modalTitle = "添加验证码源"
},
//修改验证码源
edit(v) {
this.form.name = v.name
this.form.id = v.id
this.form.resource = v.resource
this.form.type = v.type
this.modalType = 1
this.modalVisible = true
this.modalTitle = "修改验证码源"
},
//提交表单
handleSubmit() {
this.form.type = this.searchForm.type
this.$refs.form.validate((valid) => {
if (valid) {
this.submitLoading = true;
if (this.modalType == 0) {
// 添加
delete this.form.id;
API_Setting.addVerification(this.form).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("添加成功");
this.getDataList();
this.modalVisible = false;
}
});
} else {
// 编辑
API_Setting.editVerification(this.form.id, this.form).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("修改成功");
this.getDataList();
this.modalVisible = false;
}
});
}
}
});
},
//删除验证码源
remove(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "确认要删除此验证码源?",
loading: true,
onOk: () => {
// 删除
API_Setting.delVerification(v.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("验证码源已删除");
this.getDataList();
}
});
},
});
}
},
mounted() {
this.getDataList();
},
};
</script>

View File

@@ -0,0 +1,642 @@
<style lang="scss">
@import "@/styles/table-common.scss";
</style>
<template>
<div class="search">
<Card>
<Row @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
<Form-item label="用户名" prop="username">
<Input
type="text"
v-model="searchForm.username"
placeholder="请输入用户名"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="联系方式" prop="mobile">
<Input
type="text"
v-model="searchForm.mobile"
placeholder="请输入联系方式"
clearable
style="width: 200px"
/>
</Form-item>
<Form-item label="部门" prop="department" >
<department-choose @on-change="handleSelectDep" style="width: 150px;" ref="dep"></department-choose>
</Form-item>
<Form-item label="用户状态" prop="status">
<Select v-model="searchForm.status" placeholder="请选择" clearable style="width: 150px">
<Option value="true">启用</Option>
<Option value="false">禁用</Option>
</Select>
</Form-item>
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
</Form>
</Row>
<Row class="operation padding-row">
<Button @click="add" type="primary">添加</Button>
<Button @click="delAll">批量删除</Button>
<Button @click="resetPass">重置密码</Button>
</Row>
<Row>
<Table
:loading="loading"
border
:columns="columns"
:data="data"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="showSelect"
ref="table"
></Table>
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="[10,20,50]"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row>
</Card>
<Modal
:title="modalTitle"
v-model="userModalVisible"
:mask-closable="false"
:width="500"
:styles="{top: '30px'}"
>
<Form ref="form" :model="form" :label-width="70" :rules="formValidate">
<FormItem label="用户名" prop="username">
<Input v-model="form.username" autocomplete="off"/>
</FormItem>
<FormItem label="昵称" prop="username">
<Input v-model="form.nickName" autocomplete="off"/>
</FormItem>
<FormItem label="密码" prop="password" v-if="modalType==0" :error="errorPass">
<Input type="password" password v-model="form.password" autocomplete="off"/>
</FormItem>
<FormItem label="邮箱" prop="email">
<Input v-model="form.email"/>
</FormItem>
<FormItem label="手机号" prop="mobile">
<Input v-model="form.mobile"/>
</FormItem>
<Form-item label="头像" prop="avatar">
<upload-pic-input v-model="form.avatar"></upload-pic-input>
</Form-item>
<Form-item label="所属部门">
<department-tree-choose @on-change="handleSelectDepTree" ref="depTree"></department-tree-choose>
</Form-item>
<FormItem label="角色" prop="roles">
<Select v-model="form.roles" multiple>
<Option v-for="item in roleList" :value="item.id" :key="item.id" :label="item.name">
</Option>
</Select>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="cancelUser">取消</Button>
<Button type="primary" :loading="submitLoading" @click="submitUser">提交</Button>
</div>
</Modal>
<check-password ref="checkPass" @on-success="resetPass"/>
</div>
</template>
<script>
import {
getUserListData,
getAllRoleList,
addUser,
editOtherUser,
enableUser,
deleteUser,
resetPassword
} from "@/api/index";
import {validateMobile} from "@/libs/validate";
import departmentChoose from "@/views/my-components/lili/department-choose";
import departmentTreeChoose from "@/views/my-components/lili/department-tree-choose";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
export default {
name: "user-manage",
components: {
departmentChoose,
departmentTreeChoose,
uploadPicInput,
},
data() {
return {
height: 510,
openTip: false,
loading: true,
dropDownIcon: "ios-arrow-down",
selectCount: 0,
selectList: [],
searchForm: {
username: "",
departmentId: "",
mobile: "",
type: "",
status: "",
pageNumber: 1,
pageSize: 10,
sort: "createTime",
order: "desc"
},
selectDate: null,
modalType: 0,
userModalVisible: false,
modalTitle: "",
form: {
username: "",
mobile: "",
email: "",
sex: "",
type: 0,
roles: [],
departmentId: "",
departmentTitle: ""
},
userRoles: [],
roleList: [],
errorPass: "",
formValidate: {
username: [
{required: true, message: "用户名不能为空", trigger: "blur"}
],
mobile: [
{required: true, message: "手机号不能为空", trigger: "blur"},
{validator: validateMobile, trigger: "blur"}
],
email: [
{required: true, message: "请输入邮箱地址"},
{type: "email", message: "邮箱格式不正确"}
]
},
submitLoading: false,
columns: [
{
type: "selection",
width: 60,
align: "center",
fixed: "left"
},
{
title: "用户名",
key: "username",
minWidth: 120,
sortable: true,
fixed: "left"
},
{
title: "头像",
key: "avatar",
width: 80,
align: "center",
render: (h, params) => {
return h("Avatar", {
props: {
src: params.row.avatar
}
});
}
},
{
title: "手机",
key: "mobile",
width: 125
},
{
title: "邮箱",
key: "email",
minWidth: 180,
sortable: true
},
{
title: "状态",
key: "status",
align: "center",
width: 110,
render: (h, params) => {
if (params.row.status == true) {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "启用"
}
})
]);
} else if (params.row.status == false) {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "禁用"
}
})
]);
}
},
filters: [
{
label: "启用",
value: true
},
{
label: "禁用",
value: false
}
],
filterMultiple: false,
filterMethod(value, row) {
return row.status == value;
}
},
{
title: "创建时间",
key: "createTime",
sortable: true,
sortType: "desc",
width: 180
},
{
title: "操作",
key: "action",
width: 200,
align: "center",
fixed: "right",
render: (h, params) => {
let enableOrDisable = "";
if (params.row.status == true) {
enableOrDisable = h(
"Button",
{
props: {
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.disable(params.row);
}
}
},
"禁用"
);
} else {
enableOrDisable = h(
"Button",
{
props: {
type: "success",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.enable(params.row);
}
}
},
"启用"
);
}
return h("div", [
h(
"Button",
{
props: {
type: "info",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
enableOrDisable,
h(
"Button",
{
props: {
type: "error",
size: "small"
},
on: {
click: () => {
this.remove(params.row);
}
}
},
"删除"
)
]);
}
}
],
data: [],
total: 0,
departments: []
};
},
methods: {
init() {
this.getUserList();
},
handleSelectDepTree(v) {
if (v) {
this.form.departmentId = v.departmentId;
this.form.departmentTitle = v.departmentTitle;
} else {
this.form.departmentId = "";
this.form.departmentTitle = "";
}
},
handleSelectDep(v) {
this.searchForm.departmentId = v;
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getUserList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getUserList();
},
selectDateRange(v) {
if (v) {
this.searchForm.startDate = v[0];
this.searchForm.endDate = v[1];
}
},
getUserList() {
// 多条件搜索用户列表
this.loading = true;
// 避免后台默认值
if (!this.searchForm.type) {
this.searchForm.type = "";
}
if (!this.searchForm.status) {
this.searchForm.status = "";
}
getUserListData(this.searchForm).then(res => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getUserList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order == "normal") {
this.searchForm.order = "";
}
this.getUserList();
},
getRoleList() {
let params = {
pageSize: 100
}
getAllRoleList(params).then(res => {
if (res.success) {
this.roleList = res.result.records;
}
});
},
resetPass() {
this.$Modal.confirm({
title: "确认重置",
content:
"您确认要重置所选的 " +
this.selectCount +
" 条用户数据密码为【123456】?",
loading: true,
onOk: () => {
let ids = "";
this.selectList.forEach(function (e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
resetPassword(ids).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.clearSelectAll();
this.getUserList();
}
});
}
});
},
cancelUser() {
this.userModalVisible = false;
},
submitUser() {
this.$refs.form.validate(valid => {
if (valid) {
if (this.modalType == 0) {
// 添加用户 避免编辑后传入id
delete this.form.id;
delete this.form.status;
if (this.form.password == "" || this.form.password == undefined) {
this.errorPass = "密码不能为空";
return;
}
if (this.form.password.length < 6) {
this.errorPass = "密码长度不得少于6位";
return;
}
//todo
this.form.password = this.md5(this.form.password)
this.submitLoading = true;
addUser(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getUserList();
this.userModalVisible = false;
}
});
} else {
// 编辑
this.submitLoading = true;
editOtherUser(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getUserList();
this.userModalVisible = false;
}
});
}
}
});
},
add() {
this.modalType = 0;
this.modalTitle = "添加用户";
this.$refs.form.resetFields();
this.$refs.depTree.setData("", "");
this.userModalVisible = true;
},
edit(v) {
this.form = JSON.parse(JSON.stringify(v));
this.modalType = 1;
this.modalTitle = "编辑用户";
this.$refs.form.resetFields();
// 转换null为""
for (let attr in this.form) {
if (this.form[attr] == null) {
this.form[attr] = "";
}
}
this.$refs.depTree.setData(this.form.departmentId, this.form.departmentTitle);
let selectRolesId = [];
if (this.form.roles) {
this.form.roles.forEach(function (e) {
selectRolesId.push(e.id);
});
}
this.form.roles = selectRolesId;
this.userModalVisible = true;
},
enable(v) {
let params = {
status: true
}
this.$Modal.confirm({
title: "确认启用",
content: "您确认要启用用户 " + v.username + " ?",
loading: true,
onOk: () => {
enableUser(v.id, params).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getUserList();
}
});
}
});
},
disable(v) {
let params = {
status: false
}
this.$Modal.confirm({
title: "确认禁用",
content: "您确认要禁用用户 " + v.username + " ?",
loading: true,
onOk: () => {
enableUser(v.id, params).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getUserList();
}
});
}
});
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除用户 " + v.username + " ?",
loading: true,
onOk: () => {
deleteUser(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getUserList();
}
});
}
});
},
showSelect(e) {
this.exportData = e;
this.selectList = e;
this.selectCount = e.length;
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
delAll() {
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
loading: true,
onOk: () => {
let ids = "";
this.selectList.forEach(function (e) {
ids += e.id + ",";
});
ids = ids.substring(0, ids.length - 1);
deleteUser(ids).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.clearSelectAll();
this.getUserList();
}
});
}
});
}
},
mounted() {
// 计算高度
this.height = Number(document.documentElement.clientHeight - 230);
this.init();
this.getRoleList();
}
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
@import "@/styles/table-common.scss";
</style>