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,315 @@
<template>
<div>
<div class="operation">
<Button @click="addParent" icon="md-add">添加一级分类</Button>
</div>
<tree-table
ref="treeTable"
size="default"
:loading="loading"
:data="tableData"
:columns="columns"
:border="true"
:show-index="false"
:is-fold="true"
:expand-type="false"
primary-key="id">
<template slot="action" slot-scope="scope">
<Button
type="primary"
@click="edit(scope.row)"
size="small"
icon="md-add"
style="margin-right:5px"
>编辑
</Button>
<Button
type="error"
@click="remove(scope.row)"
size="small"
icon="md-add"
style="margin-right:5px"
>删除
</Button>
&nbsp;
<Button
v-show="scope.row.level != 2 "
type="primary"
@click="addChildren(scope.row)"
size="small"
icon="md-add"
style="margin-right:5px"
>添加子分类
</Button>
</template>
</tree-table>
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable='false' :width="500">
<Form ref="form" :model="formAdd" :label-width="100" :rules="formValidate">
<div v-if="showParent">
<FormItem label="上级分类" prop="parentId">
{{parentTitle}}
<Input v-model="formAdd.parentId" clearable style="width:100%;display:none"/>
</FormItem>
</div>
<FormItem label="分类名称" prop="name">
<Input v-model="formAdd.articleCategoryName" clearable style="width:100%"/>
</FormItem>
<FormItem label="排序值" prop="sort" style="width:345px">
<InputNumber v-model="formAdd.sort"></InputNumber>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible=false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="Submit">提交</Button>
</div>
</Modal>
</div>
</template>
<script>
import {
saveArticleCategory,
getArticleCategory,
delArticleCategory,
updateArticleCategory
} from "@/api/pages";
import TreeTable from "@/views/my-components/tree-table/Table/Table";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
export default {
name: "lili-components",
components: {
TreeTable,
uploadPicInput
},
data() {
return {
currView: "index",
loading: false,
brands: [], //品牌集合
Specifications: [], //规格集合
categoryId: "",
expandLevel: 1,
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
showParent: false, // 是否展示上级菜单
parentTitle: "", // 父级菜单名称
modalBrandTitle: "",
modalSpecTitle: "",
formAdd: { // 添加或编辑表单对象初始化数据
parentId: "",
name: "",
sort: 1,
level: 0,
},
enabledParam: {
type: 0
},
brandForm: {},
specForm: {},
// 表单验证规则
formValidate: {},
columns: [
{
title: "分类名称",
key: "articleCategoryName",
witt: "100px",
},
{
title: "排序",
key: "sort",
width: "100px",
},
{
title: "操作",
key: "action",
align: "center",
headerAlign: "center",
width: "400px",
type: "template",
template: "action",
}
],
tableData: []
};
},
methods: {
init() {
this.getAllList();
// this.getBrandList();
// this.getSpecList()
},
addChildren(v) {
this.modalType = 0;
this.modalTitle = "添加子分类";
this.formAdd.articleCategoryName = "";
this.parentTitle = v.articleCategoryName;
this.formAdd.level = eval(v.level + "+1");
this.showParent = true;
delete this.formAdd.id;
this.formAdd.parentId = v.id;
this.modalVisible = true;
},
edit(v) {
this.modalType = 1;
this.modalTitle = "编辑";
this.formAdd.id = v.id;
this.formAdd.articleCategoryName = v.articleCategoryName;
this.formAdd.level = v.level;
this.formAdd.parentId = v.parentId;
this.showParent = false;
this.modalVisible = true;
},
addParent() {
this.modalType = 0;
this.modalTitle = "添加一级分类";
this.parentTitle = "顶级分类";
this.showParent = true;
this.$refs.form.resetFields();
delete this.formAdd.id;
this.formAdd.parentId = 0;
this.modalVisible = true;
},
Submit() {
this.$refs.form.validate(valid => {
if (valid) {
this.submitLoading = true;
if (this.modalType === 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.formAdd.id;
saveArticleCategory(this.formAdd).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("添加成功");
this.formAdd={}
} else {
this.$Message.error(res.message);
}
this.getAllList();
this.modalVisible = false;
});
} else {
// 编辑
updateArticleCategory(this.formAdd, this.formAdd.id).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("修改成功");
} else {
this.$Message.error(res.message);
}
this.getAllList();
this.modalVisible = false;
this.$refs.form.resetFields();
});
}
}
});
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认要删除 " + v.articleCategoryName + " ?",
loading: true,
onOk: () => {
// 删除
delArticleCategory(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getAllList();
}
});
}
});
},
getAllList() {
this.loading = true;
getArticleCategory().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;
}
});
}
});
}
}
});
this.tableData = res.result;
}
});
},
},
mounted() {
this.init();
}
};
</script>
<style lang="scss" scoped>
.article {
font-size: 16px;
font-weight: 400;
margin: 12px 0;
}
</style>

View File

@@ -0,0 +1,490 @@
<template>
<div class="wrapper">
<Row>
<Col style=" height: 100%;" span="4">
<Card class="article-category">
<Tree :data="treeData" @on-select-change="handleSearchChange"></Tree>
</Card>
</Col>
<Col span="20">
<Card class="article-detail">
<Row @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="70" style="width:100%;" class="search-form">
<Form-item label="文章标题" prop="title">
<Input type="text" v-model="searchForm.title" placeholder="请输入文章标题" clearable style="width: 200px" />
</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" style="">添加</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="openStatusSlot" slot-scope="scope">
<div>
</div>
<i-switch size="large" v-model="scope.row.openStatus" @on-change="changeSwitch(scope.row)">
<span slot="open">展示</span>
<span slot="close">隐藏</span>
</i-switch>
</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>
</Page>
</Row>
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="1100">
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="文章标题" prop="title">
<Input v-model="form.title" clearable style="width: 40%" />
</FormItem>
<FormItem label="文章分类" prop="categoryId">
<Select v-model="treeValue" placeholder="请选择" clearable style="width: 180px">
<Option :value="treeValue" style="display: none">{{
treeValue
}}
</Option>
<Tree :data="treeData" @on-select-change="handleCheckChange"></Tree>
</Select>
</FormItem>
<FormItem label="文章排序" prop="sort">
<Input type="number" v-model="form.sort" clearable style="width: 10%" />
</FormItem>
<FormItem class="form-item-view-el" label="文章内容" prop="content">
<editor v-model="form.content"></editor>
</FormItem>
<FormItem label="是否展示" prop="openStatus">
<i-switch size="large" v-model="form.openStatus" :true-value="open" :false-value="close">
<span slot="open">展示</span>
<span slot="close">隐藏</span>
</i-switch>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit">提交</Button>
</div>
</Modal>
</Card>
</Col>
</Row>
</div>
</template>
<script>
import {
getArticleCategory,
saveArticle,
getArticle,
delArticle,
updateArticle,
seeArticle,
updateArticleStatus,
} from "@/api/pages";
import editor from "@/views/my-components/lili/editor";
export default {
name: "article",
components: {
editor,
},
props: {
selected: {
type: Boolean,
default: false,
},
},
data() {
return {
selectedIndex: 99999,
loading: true, // 表单加载状态
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
categoryId: "",
},
searchTreeValue: "",
form: {
// 添加或编辑表单对象初始化数据
title: "",
categoryId: "",
sort: 1,
content: "",
id: "",
},
// 表单验证规则
formValidate: {},
list: [],
treeValue: "",
//树结构
treeData: [],
model2: "",
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
// 表头
{
title: "分类名称",
key: "articleCategoryName",
width: 150,
},
{
title: "文章标题",
key: "title",
minWidth: 200,
tooltip: true,
},
{
title: "是否显示",
key: "openStatus",
width: 100,
slot: "openStatusSlot",
/*render: (h, params) => {
if (params.row.openStatus == "CLOSE") {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "隐藏",
},
}),
]);
} else if (params.row.openStatus == "OPEN") {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "展示",
},
}),
]);
}
},*/
},
{
title: "排序",
key: "sort",
width: 100,
},
{
title: "操作",
key: "action",
align: "center",
width: 230,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
size: "small",
type: this.selectedIndex == params.index ? "primary" : "",
},
style: {
marginRight: "5px",
display: this.selected ? "" : "none",
},
on: {
click: () => {
this.selectedIndex = params.index;
this.$emit("callbacked", params.row);
},
},
},
this.selectedIndex == params.index ? "已选" : "选择"
),
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: [], // 表单数据
total: 0, // 表单数据总数
};
},
watch: {
"searchForm.categoryId": {
handler() {
this.handleSearch();
},
deep: true,
},
"searchForm.title": {
handler() {
this.handleSearch();
},
deep: true,
},
},
methods: {
init() {
this.getDataList();
this.getAllList(0);
},
handleSearchChange(data) {
let { value, title } = data[0];
this.list.push({
value,
title,
});
this.searchForm.categoryId = value;
this.searchTreeValue = title;
},
//是否展示事件
changeSwitch(v) {
let params = {
status: v.openStatus,
};
updateArticleStatus(v.id, params).then((res) => {
this.submitLoading = false;
if (res.success) {
}
});
},
handleCheckChange(data) {
let value = "";
let title = "";
this.list = [];
this.model2 = "";
data.forEach((item, index) => {
value += `${item.value},`;
title += `${item.title},`;
});
value = value.substring(0, value.length - 1);
title = title.substring(0, title.length - 1);
this.list.push({
value,
title,
});
this.form.categoryId = value;
this.treeValue = title;
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
getAllList(parent_id) {
this.loading = true;
getArticleCategory(parent_id).then((res) => {
this.loading = false;
if (res.success) {
this.treeData = this.getTree(res.result);
this.treeData.unshift({
title: "全部",
level: 0,
children: [],
id: "0",
categoryId: 0
});
}
});
},
getTree(tree = []) {
let arr = [];
if (!!tree && tree.length !== 0) {
tree.forEach((item) => {
let obj = {};
obj.title = item.articleCategoryName;
obj.value = item.id;
obj.attr = item.articleCategoryName; // 其他你想要添加的属性
obj.expand = false;
obj.selected = false;
obj.children = this.getTree(item.children); // 递归调用
arr.push(obj);
});
}
return arr;
},
getDataList(val) {
if (val) this.form = {};
this.loading = true;
// 带多条件搜索参数获取表单数据 请自行修改接口
getArticle(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.total = res.result.total;
//为了在是否展示一列展示开关 需要改一下数据类型,最终提交再次更改
this.data = [];
if (res.result.records.length > 0) {
res.result.records.forEach((item) => {
if (item.openStatus == "OPEN") {
item.openStatus = true;
} else {
item.openStatus = false;
}
})
this.data = res.result.records;
}
}
});
this.total = this.data.length;
this.loading = false;
},
handleSubmit() {
if (this.form.openStatus) {
this.form.openStatus = "OPEN";
} else {
this.form.openStatus = "CLOSE";
}
this.$refs.form.validate((valid) => {
if (valid) {
this.submitLoading = true;
if (this.modalType === 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.form.id;
saveArticle(this.form).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
} else {
// 编辑
updateArticle(this.form).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
}
}
});
},
add() {
this.modalType = 0;
this.modalTitle = "添加文章";
this.$refs.form.resetFields();
delete this.form.id;
this.modalVisible = true;
},
edit(data) {
this.modalType = 1;
this.modalTitle = "编辑文章";
this.$refs.form.resetFields();
seeArticle(data.id).then((res) => {
if (res.result) {
this.modalVisible = true;
this.form.categoryId = res.result.categoryId;
this.treeValue = data.articleCategoryName;
this.form.id = data.id;
this.form.content = res.result.content;
this.form.title = res.result.title;
this.form.sort = res.result.sort;
if (res.result.openStatus == "OPEN") {
this.form.openStatus = true;
} else {
this.form.openStatus = false;
}
}
});
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认要删除么?",
loading: true,
onOk: () => {
// 删除
delArticle(v.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
},
});
},
},
mounted() {
this.init();
},
};
</script>
<style lang="scss" scoped>
@import "@/styles/table-common.scss";
</style>

View File

@@ -0,0 +1,244 @@
<style lang="scss">
@import "@/styles/table-common.scss";
</style>
<template>
<div class="search">
<Card>
<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 v-model="formValidate" :title="modalTitle" @on-ok="" width="500">
<Form
ref="formValidate"
:model="form"
:label-width="80"
>
<FormItem label="用户名" prop="userName">
<span> {{form.userName}}</span>
</FormItem>
<FormItem label="手机号码" prop="mobile">
<span> {{form.mobile}}</span>
</FormItem>
<FormItem label="类型" prop="type">
<span v-if="form.type == 'FUNCTION'">功能建议</span>
<span v-if="form.type == 'OPTIMIZE'">优化反馈</span>
<span v-if="form.type == 'OTHER'">其他意见</span>
</FormItem>
<FormItem label="反馈内容" prop="context">
<Input style="width: 85%" v-model="form.context" type="textarea" disabled :autosize="{minRows: 3,maxRows: 5}"
></Input>
</FormItem>
<FormItem label="相关材料" prop="images">
<div v-if="form.images == null">
暂无
</div>
<div v-else>
<span v-for="(item, index) in this.form.images.split(',')">
<Avatar shape="square" icon="ios-person" size="large" style="width: 80px;height: 90px;margin-right: 5px" :src="item"
/>
</span>
</div>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="formValidate = false">取消</Button>
</div>
</Modal>
</div>
</template>
<script>
import {
getMemberFeedback,
getMemberFeedbackDetail
} from "@/api/other";
export default {
name: "role-manage",
data() {
return {
loading: true,
modalType: 0, // 0 添加 1 编辑
form: {},
searchForm: {
pageNumber: 1,
pageSize: 10,
},
modalTitle: "详细",
formValidate: false,
roleForm: {
name: "",
description: "",
},
images: [],
columns: [
{
type: "selection",
width: 60,
align: "center",
},
{
title: "会员名称",
key: "userName",
minWidth: 120,
tooltip: true
},
{
title: "手机号码",
key: "mobile",
minWidth: 120,
tooltip: true
},
{
title: "反馈内容",
key: "context",
minWidth: 380,
tooltip: true
},
{
title: "类型",
key: "type",
minWidth: 120,
render: (h, params) => {
if (params.row.type == "FUNCTION") {
return h('div', [h('span', {}, "功能建议")]);
} else if (params.row.type == "OPTIMIZE") {
return h('div', [h('span', {}, "优化反馈")]);
} else if (params.row.type == "OTHER") {
return h('div', [h('span', {}, "其他意见")]);
} else {
return h('div', [h('span', {}, "未知意见")]);
}
}
},
{
title: "创建时间",
key: "createTime",
width: 170,
sortable: true,
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 130,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
size: "small",
type: "info"
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.detail(params.row);
},
},
},
"查看"
)
]);
},
},
],
data: [],
pageNumber: 1,
pageSize: 10,
total: 0,
permData: [],
editRolePermId: "",
selectAllFlag: false,
depData: [],
dataType: 0,
editDepartments: [],
saveRoleWay: [], //用户保存用户点击的菜单
};
},
methods: {
init() {
this.getFeedback();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getFeedback();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getFeedback();
},
changeSort(e) {
this.sortColumn = e.key;
this.sortType = e.order;
if (e.order == "normal") {
this.sortType = "";
}
this.getFeedback();
},
/**
* 查询意见反馈
*/
getFeedback() {
this.loading = true;
getMemberFeedback(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
},
/**
* 投诉建议详细
*/
detail(v) {
getMemberFeedbackDetail(v.id).then((res) => {
this.loading = false;
if (res.success) {
this.$set(this, "form", res.result);
this.formValidate = true
}
});
}
},
mounted() {
this.init();
},
};
</script>

View File

@@ -0,0 +1,477 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Row class="operation">
<Button @click="add" type="primary" icon="md-add">添加</Button>
<Button @click="disableAll" icon="md-trash">批量禁用</Button>
<Button @click="getDataList" icon="md-refresh">刷新</Button>
<Button type="dashed" @click="openTip=!openTip">{{openTip ? "关闭提示" : "开启提示"}}</Button>
</Row>
<Row v-show="openTip">
<Alert show-icon>
已选择 <span class="select-count">{{selectCount}}</span>
<a class="select-clear" @click="clearSelectAll">清空</a>
</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>
<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="500">
<Form ref="form" :model="form" :label-width="100" :rules="formValidate" > <FormItem label="名称" prop="name" >
<Input v-model="form.name" clearable style="width:100%"/>
</FormItem>
<FormItem label="图片" prop="url">
<upload-pic-input v-model="form.url" style="width:100%"></upload-pic-input>
</FormItem>
<FormItem label="操作类型" prop="operationType" >
<Select v-model="form.operationType" placeholder="请选择" clearable style="width: 200px">
<Option value="NONE">无操作</Option>
<Option value="URL">链接地址</Option>
<Option value="GOODS">商品序号</Option>
<Option value="SHOP">店铺编号</Option>
<Option value="KEYWORD">关键字</Option>
<Option value="CATEGORY">商品分类</Option>
</Select>
</FormItem>
<FormItem label="链接值" prop="sort" >
<Input v-model="form.operationUrl" clearable style="width:100%"/>
</FormItem>
<FormItem label="排序" prop="sort" >
<InputNumber :max="999" :min="0" v-model="form.sort"></InputNumber>
</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 {
getFocusData,
saveFocusData,
disableFocus,
enableFocus,
delFocus
} from "@/api/pages";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
export default {
name: "mobileFocus",
components: {
uploadPicInput
},
data() {
return {
openTip: true, // 显示提示
loading: true, // 表单加载状态
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: { // 搜索框初始化对象
clientType: "MOBILE", //客户端类型
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
},
form: { // 添加或编辑表单对象初始化数据
name: "",
operationType: "",
operationUrl: "",
url: "",
sort: 0,
},
// 表单验证规则
formValidate: {
name: [{ required: true, message: "不能为空", trigger: "blur" }],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
// 表头
{
type: "selection",
width: 60,
align: "center"
},
{
title: "名称",
key: "name",
minWidth: 120,
sortable: false,
},
{
title: "状态",
key: "status",
minWidth: 100,
sortable: false,
render: (h, params) => {
if (params.row.status == 'CLOSE') {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "禁用"
}
})
]);
} else if (params.row.status == 'OPEN') {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "启用"
}
})
]);
}
}
},
{
title: "图片",
key: "url",
minWidth: 120,
sortable: false,
render: (h, params) => {
return h("img", {
attrs: {
src: params.row.url,
alt: "加载图片失败"
},
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain"
}
});
}
},
{
title: "排序",
key: "sort",
minWidth: 120,
sortable: false,
},
{
title: "操作",
key: "action",
align: "center",
width: 200,
render: (h, params) => {
let enableOrDisable = "";
if (params.row.status == "CLOSE") {
enableOrDisable = h(
"Button",
{
props: {
type: "success",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.enable(params.row);
}
}
},
"启用"
);
} else {
enableOrDisable = h(
"Button",
{
props: {
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.disable(params.row);
}
}
},
"禁用"
);
}
return h("div", [
h(
"Button",
{
props: {
type: "primary",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.remove(params.row);
}
}
},
"删除"
),
enableOrDisable,
]);
}
}
],
data: [], // 表单数据
total: 0 // 表单数据总数
};
},
methods: {
init() {
this.getDataList();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
handleReset() {
this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
// 重新加载数据
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
getDataList() {
this.loading = true;
// 带多条件搜索参数获取表单数据 请自行修改接口
getFocusData(this.searchForm).then(res => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
// 以下为模拟数据
//this.data = [
//];
this.total = this.data.length;
this.loading = false;
},
enable(v){
this.$Modal.confirm({
title: "确认启用",
// 记得确认修改此处
content: "您确认要确认启用 " + v.name + " ?",
loading: true,
onOk: () => {
// 删除
enableFocus(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disable(v) {
this.$Modal.confirm({
title: "确认禁用",
// 记得确认修改此处
content: "您确认要禁用 " + v.name + " ?",
loading: true,
onOk: () => {
// 删除
disableFocus(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
this.form.ClientType = "MOBILE"
this.submitLoading = true;
if (this.modalType === 0) {
this.form.status = "OPEN"
// 添加 避免编辑后传入id等数据 记得删除
delete this.form.id;
saveFocusData(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
} else {
// 编辑
saveFocusData(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
}
}
});
},
add() {
this.modalType = 0;
this.modalTitle = "添加";
this.$refs.form.resetFields();
delete this.form.id;
this.modalVisible = true;
},
edit(v) {
this.modalType = 1;
this.modalTitle = "编辑";
this.$refs.form.resetFields();
// 转换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.modalVisible = true;
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认要删除么?",
loading: true,
onOk: () => {
// 删除
delFocus(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disableAll() {
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);
// 批量删除
disableFocus(ids).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("禁用成功");
this.clearSelectAll();
this.getDataList();
}
});
}
});
}
},
mounted() {
this.init();
}
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
// @import "@/styles/table-common.scss";
.search {
.operation {
margin-bottom: 2vh;
}
.select-count {
font-weight: 600;
color: #40a9ff;
}
.select-clear {
margin-left: 10px;
}
.page {
margin-top: 2vh;
}
.drop-down {
margin-left: 5px;
}
}
</style>

View File

@@ -0,0 +1,477 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Row class="operation">
<Button @click="add" type="primary" icon="md-add">添加</Button>
<Button @click="disableAll" icon="md-trash">批量禁用</Button>
<Button @click="getDataList" icon="md-refresh">刷新</Button>
<Button type="dashed" @click="openTip=!openTip">{{openTip ? "关闭提示" : "开启提示"}}</Button>
</Row>
<Row v-show="openTip">
<Alert show-icon>
已选择 <span class="select-count">{{selectCount}}</span>
<a class="select-clear" @click="clearSelectAll">清空</a>
</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>
<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="500">
<Form ref="form" :model="form" :label-width="100" :rules="formValidate" > <FormItem label="名称" prop="name" >
<Input v-model="form.name" clearable style="width:100%"/>
</FormItem>
<FormItem label="图片" prop="url">
<upload-pic-input v-model="form.url" style="width:100%"></upload-pic-input>
</FormItem>
<FormItem label="操作类型" prop="operationType" >
<Select v-model="form.operationType" placeholder="请选择" clearable style="width: 200px">
<Option value="NONE">无操作</Option>
<Option value="URL">链接地址</Option>
<Option value="GOODS">商品序号</Option>
<Option value="SHOP">店铺编号</Option>
<Option value="KEYWORD">关键字</Option>
<Option value="CATEGORY">商品分类</Option>
</Select>
</FormItem>
<FormItem label="链接值" prop="sort" >
<Input v-model="form.operationUrl" clearable style="width:100%"/>
</FormItem>
<FormItem label="排序" prop="sort" >
<InputNumber :max="999" :min="0" v-model="form.sort"></InputNumber>
</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 {
getFocusData,
saveFocusData,
disableFocus,
enableFocus,
delFocus
} from "@/api/pages";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
export default {
name: "pcFocus",
components: {
uploadPicInput
},
data() {
return {
openTip: true, // 显示提示
loading: true, // 表单加载状态
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: { // 搜索框初始化对象
clientType: "PC", //客户端类型
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
},
form: { // 添加或编辑表单对象初始化数据
name: "",
operationType: "",
operationUrl: "",
url: "",
sort: 0,
},
// 表单验证规则
formValidate: {
name: [{ required: true, message: "不能为空", trigger: "blur" }],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
// 表头
{
type: "selection",
width: 60,
align: "center"
},
{
title: "名称",
key: "name",
minWidth: 120,
sortable: false,
},
{
title: "状态",
key: "status",
minWidth: 100,
sortable: false,
render: (h, params) => {
if (params.row.status == 'CLOSE') {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "禁用"
}
})
]);
} else if (params.row.status == 'OPEN') {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "启用"
}
})
]);
}
}
},
{
title: "图片",
key: "url",
minWidth: 120,
sortable: false,
render: (h, params) => {
return h("img", {
attrs: {
src: params.row.url,
alt: "加载图片失败"
},
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain"
}
});
}
},
{
title: "排序",
key: "sort",
minWidth: 120,
sortable: false,
},
{
title: "操作",
key: "action",
align: "center",
width: 200,
render: (h, params) => {
let enableOrDisable = "";
if (params.row.status == "CLOSE") {
enableOrDisable = h(
"Button",
{
props: {
type: "success",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.enable(params.row);
}
}
},
"启用"
);
} else {
enableOrDisable = h(
"Button",
{
props: {
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.disable(params.row);
}
}
},
"禁用"
);
}
return h("div", [
h(
"Button",
{
props: {
type: "primary",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.remove(params.row);
}
}
},
"删除"
),
enableOrDisable,
]);
}
}
],
data: [], // 表单数据
total: 0 // 表单数据总数
};
},
methods: {
init() {
this.getDataList();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
handleReset() {
this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
// 重新加载数据
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
getDataList() {
this.loading = true;
// 带多条件搜索参数获取表单数据 请自行修改接口
getFocusData(this.searchForm).then(res => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
// 以下为模拟数据
//this.data = [
//];
this.total = this.data.length;
this.loading = false;
},
enable(v){
this.$Modal.confirm({
title: "确认启用",
// 记得确认修改此处
content: "您确认要确认启用 " + v.name + " ?",
loading: true,
onOk: () => {
// 删除
enableFocus(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disable(v) {
this.$Modal.confirm({
title: "确认禁用",
// 记得确认修改此处
content: "您确认要禁用 " + v.name + " ?",
loading: true,
onOk: () => {
// 删除
disableFocus(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
this.form.ClientType = "PC"
this.submitLoading = true;
if (this.modalType === 0) {
this.form.status = "OPEN"
// 添加 避免编辑后传入id等数据 记得删除
delete this.form.id;
saveFocusData(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
} else {
// 编辑
saveFocusData(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
}
}
});
},
add() {
this.modalType = 0;
this.modalTitle = "添加";
this.$refs.form.resetFields();
delete this.form.id;
this.modalVisible = true;
},
edit(v) {
this.modalType = 1;
this.modalTitle = "编辑";
this.$refs.form.resetFields();
// 转换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.modalVisible = true;
},
remove(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认要删除么?",
loading: true,
onOk: () => {
// 删除
delFocus(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disableAll() {
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);
// 批量删除
disableFocus(ids).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("禁用成功");
this.clearSelectAll();
this.getDataList();
}
});
}
});
}
},
mounted() {
this.init();
}
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
// @import "@/styles/table-common.scss";
.search {
.operation {
margin-bottom: 2vh;
}
.select-count {
font-weight: 600;
color: #40a9ff;
}
.select-clear {
margin-left: 10px;
}
.page {
margin-top: 2vh;
}
.drop-down {
margin-left: 5px;
}
}
</style>

View File

@@ -0,0 +1,467 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Row class="operation">
<Button @click="add" type="primary" icon="md-add">添加</Button>
<Button @click="disableAll" icon="md-trash">批量禁用</Button>
<Button @click="getDataList" icon="md-refresh">刷新</Button>
<Button type="dashed" @click="openTip=!openTip">{{openTip ? "关闭提示" : "开启提示"}}</Button>
</Row>
<Row v-show="openTip">
<Alert show-icon>
已选择 <span class="select-count">{{selectCount}}</span>
<a class="select-clear" @click="clearSelectAll">清空</a>
</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>
<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="500">
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="导航栏名称" prop="navigationName">
<Input v-model="form.navigationName" clearable style="width:100%"/>
</FormItem>
<FormItem label="导航栏链接" prop="url">
<Input v-model="form.url" clearable style="width:100%"/>
</FormItem>
<FormItem label="品牌图标" prop="image">
<upload-pic-input v-model="form.image" style="width:100%"></upload-pic-input>
</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 {
save,
getNavigationData,
disableNavigation,
enableNavigation,
delNavigation,
update
} from "@/api/pages";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
export default {
name: "mobileNavigation",
components: {
uploadPicInput
},
data() {
return {
openTip: true, // 显示提示
loading: true, // 表单加载状态
type: "MOBILE",
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: { // 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
},
form: { // 添加或编辑表单对象初始化数据
navigationName: "",
image: "",
url: "",
},
// 表单验证规则
formValidate: {
url: [{required: true, message: "导航栏url不能为空", trigger: "blur"}],
navigationName: [{required: true, message: "导航栏不能为空", trigger: "blur"}],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
// 表头
{
type: "selection",
width: 60,
align: "center"
},
{
title: "导航名称",
key: "navigationName",
minWidth: 120,
sortable: false,
},
{
title: "状态",
key: "status",
minWidth: 100,
sortable: false,
render: (h, params) => {
if (params.row.status == 'CLOSE') {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "禁用"
}
})
]);
} else if (params.row.status == 'OPEN') {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "启用"
}
})
]);
}
}
},
{
title: "图片",
key: "image",
minWidth: 120,
sortable: false,
render: (h, params) => {
return h("img", {
attrs: {
src: params.row.image,
alt: "加载图片失败"
},
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain"
}
});
}
},
{
title: "排序",
key: "sort",
minWidth: 120,
sortable: false,
},
{
title: "操作",
key: "action",
align: "center",
width: 250,
render: (h, params) => {
console.warn(params.status)
let enableOrDisable = "";
if (params.row.status == "CLOSE") {
enableOrDisable = h(
"Button",
{
props: {
type: "success",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.enable(params.row);
}
}
},
"启用"
);
} else {
enableOrDisable = h(
"Button",
{
props: {
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.disable(params.row);
}
}
},
"禁用"
);
}
return h("div", [
h(
"Button",
{
props: {
type: "primary",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.del(params.row);
}
}
},
"删除"
),
enableOrDisable,
]);
}
}
],
data: [], // 表单数据
total: 0 // 表单数据总数
};
},
methods: {
init() {
this.getDataList();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
handleReset() {
this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
// 重新加载数据
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
getDataList() {
this.searchForm.clientType = this.type
this.loading = true;
// 带多条件搜索参数获取表单数据 请自行修改接口
getNavigationData(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;
},
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
this.submitLoading = true;
this.form.clientType = this.type
if (this.modalType === 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.form.id;
save(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
} else {
// 编辑
update(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
}
}
});
},
add() {
this.modalType = 0;
this.modalTitle = "添加";
this.$refs.form.resetFields();
delete this.form.id;
this.modalVisible = true;
},
edit(v) {
this.modalType = 1;
this.modalTitle = "编辑";
this.$refs.form.resetFields();
// 转换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.modalVisible = true;
},
enable(v){
this.$Modal.confirm({
title: "确认启用",
// 记得确认修改此处
content: "您确认要确认启用 " + v.navigationName + " ?",
loading: true,
onOk: () => {
// 删除
enableNavigation(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disable(v) {
this.$Modal.confirm({
title: "确认禁用",
// 记得确认修改此处
content: "您确认要禁用 " + v.navigationName + " ?",
loading: true,
onOk: () => {
// 删除
disableNavigation(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disableAll() {
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);
// 批量禁用
disableNavigation(ids).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.clearSelectAll();
this.getDataList();
}
});
}
});
},
del(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认要永久性删除 " + v.navigationName + " ?",
loading: true,
onOk: () => {
// 删除
delNavigation(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
}
},
mounted() {
this.init();
}
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
// @import "@/styles/table-common.scss";
.search {
.operation {
margin-bottom: 2vh;
}
.select-count {
font-weight: 600;
color: #40a9ff;
}
.select-clear {
margin-left: 10px;
}
.page {
margin-top: 2vh;
}
.drop-down {
margin-left: 5px;
}
}
</style>

View File

@@ -0,0 +1,467 @@
<template>
<div class="search">
<Row>
<Col>
<Card>
<Row class="operation">
<Button @click="add" type="primary" icon="md-add">添加</Button>
<Button @click="disableAll" icon="md-trash">批量禁用</Button>
<Button @click="getDataList" icon="md-refresh">刷新</Button>
<Button type="dashed" @click="openTip=!openTip">{{openTip ? "关闭提示" : "开启提示"}}</Button>
</Row>
<Row v-show="openTip">
<Alert show-icon>
已选择 <span class="select-count">{{selectCount}}</span>
<a class="select-clear" @click="clearSelectAll">清空</a>
</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>
<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="500">
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="导航栏名称" prop="navigationName">
<Input v-model="form.navigationName" clearable style="width:100%"/>
</FormItem>
<FormItem label="导航栏链接" prop="url">
<Input v-model="form.url" clearable style="width:100%"/>
</FormItem>
<FormItem label="品牌图标" prop="image">
<upload-pic-input v-model="form.image" style="width:100%"></upload-pic-input>
</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 {
save,
getNavigationData,
disableNavigation,
enableNavigation,
delNavigation,
update
} from "@/api/pages";
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
export default {
name: "pcNavigation",
components: {
uploadPicInput
},
data() {
return {
openTip: true, // 显示提示
loading: true, // 表单加载状态
type: "PC",
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: { // 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "createTime", // 默认排序字段
order: "desc", // 默认排序方式
},
form: { // 添加或编辑表单对象初始化数据
navigationName: "",
image: "",
url: "",
},
// 表单验证规则
formValidate: {
url: [{required: true, message: "导航栏url不能为空", trigger: "blur"}],
navigationName: [{required: true, message: "导航栏不能为空", trigger: "blur"}],
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
// 表头
{
type: "selection",
width: 60,
align: "center"
},
{
title: "导航名称",
key: "navigationName",
minWidth: 120,
sortable: false,
},
{
title: "状态",
key: "status",
minWidth: 100,
sortable: false,
render: (h, params) => {
if (params.row.status == 'CLOSE') {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "禁用"
}
})
]);
} else if (params.row.status == 'OPEN') {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "启用"
}
})
]);
}
}
},
{
title: "图片",
key: "image",
minWidth: 120,
sortable: false,
render: (h, params) => {
return h("img", {
attrs: {
src: params.row.image,
alt: "加载图片失败"
},
style: {
cursor: "pointer",
width: "80px",
height: "60px",
margin: "10px 0",
"object-fit": "contain"
}
});
}
},
{
title: "排序",
key: "sort",
minWidth: 120,
sortable: false,
},
{
title: "操作",
key: "action",
align: "center",
width: 250,
render: (h, params) => {
console.warn(params.status)
let enableOrDisable = "";
if (params.row.status == "CLOSE") {
enableOrDisable = h(
"Button",
{
props: {
type: "success",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.enable(params.row);
}
}
},
"启用"
);
} else {
enableOrDisable = h(
"Button",
{
props: {
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.disable(params.row);
}
}
},
"禁用"
);
}
return h("div", [
h(
"Button",
{
props: {
type: "primary",
size: "small"
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.edit(params.row);
}
}
},
"编辑"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px"
},
on: {
click: () => {
this.del(params.row);
}
}
},
"删除"
),
enableOrDisable,
]);
}
}
],
data: [], // 表单数据
total: 0 // 表单数据总数
};
},
methods: {
init() {
this.getDataList();
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
handleReset() {
this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
// 重新加载数据
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
changeSelect(e) {
this.selectList = e;
this.selectCount = e.length;
},
getDataList() {
this.searchForm.clientType = this.type
this.loading = true;
// 带多条件搜索参数获取表单数据 请自行修改接口
getNavigationData(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;
},
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
this.submitLoading = true;
this.form.clientType = this.type
if (this.modalType === 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.form.id;
save(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
} else {
// 编辑
update(this.form).then(res => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false;
}
});
}
}
});
},
add() {
this.modalType = 0;
this.modalTitle = "添加";
this.$refs.form.resetFields();
delete this.form.id;
this.modalVisible = true;
},
edit(v) {
this.modalType = 1;
this.modalTitle = "编辑";
this.$refs.form.resetFields();
// 转换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.modalVisible = true;
},
enable(v){
this.$Modal.confirm({
title: "确认启用",
// 记得确认修改此处
content: "您确认要确认启用 " + v.navigationName + " ?",
loading: true,
onOk: () => {
// 删除
enableNavigation(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disable(v) {
this.$Modal.confirm({
title: "确认禁用",
// 记得确认修改此处
content: "您确认要禁用 " + v.navigationName + " ?",
loading: true,
onOk: () => {
// 删除
disableNavigation(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
},
disableAll() {
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);
// 批量禁用
disableNavigation(ids).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.clearSelectAll();
this.getDataList();
}
});
}
});
},
del(v) {
this.$Modal.confirm({
title: "确认删除",
// 记得确认修改此处
content: "您确认要永久性删除 " + v.navigationName + " ?",
loading: true,
onOk: () => {
// 删除
delNavigation(v.id).then(res => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("操作成功");
this.getDataList();
}
});
}
});
}
},
mounted() {
this.init();
}
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
// @import "@/styles/table-common.scss";
.search {
.operation {
margin-bottom: 2vh;
}
.select-count {
font-weight: 600;
color: #40a9ff;
}
.select-clear {
margin-left: 10px;
}
.page {
margin-top: 2vh;
}
.drop-down {
margin-left: 5px;
}
}
</style>