Commit a9e00cd1 authored by YIyiyi's avatar YIyiyi

feat:添加应用分类管理,修改token,userInfo信息储存方式

parent 2fabc80c
#开发环境
NODE_ENV = "development"
VUE_APP_API_BASE_URL=http://192.168.0.98:11078
VUE_APP_API_IMG_URL=http://192.168.0.98:11078/
VUE_APP_API_BASE_URL=http://8.136.255.30:11078
VUE_APP_API_IMG_URL=http://8.136.255.30:11078/
#VUE_APP_API_BASE_URL=http://10.12.185.213:11071
\ No newline at end of file
import local from "@/utils/local";
// import local from "@/utils/local";
import store from "@/store/index";
// 皮肤模板页面权限
export const permission = {
inserted: function(el, binding) {
const { value } = binding;
const roles = local.getLocal("baseUserInfo").id;
// const roles = local.getLocal("baseUserInfo").id;
const roles = store.getters["site/userInfo"].id;
if (value) {
const permissionRoles = value;
const hasPermission = permissionRoles.includes(roles);
......
......@@ -12,6 +12,7 @@
<a-tab-pane key="/appmarket/terminalapp" tab="终端应用"> </a-tab-pane>
<a-tab-pane key="/appmarket/moveapp" tab="移动端应用"> </a-tab-pane>
<a-tab-pane key="/appmarket/blackapp" tab="应用黑名单"> </a-tab-pane>
<a-tab-pane key="/appmarket/category" tab="应用分类"> </a-tab-pane>
</a-tabs>
<div class="app-out-box flex1">
<router-view></router-view>
......@@ -147,4 +148,4 @@ export default {
/deep/.ant-tabs-tabpane {
padding: 0px 20px;
}
</style>
\ No newline at end of file
</style>
<template>
<div class="app-category">
<div class="header flex aic jcb mb20 pdr6">
<a-space>
<a-button type="primary" @click="handleAdd"> 新增分类 </a-button>
</a-space>
<a-input-search
style="width: 300px"
placeholder="请输入分类名称搜索"
enter-button="搜索"
v-model="searchVal"
allowClear
@search="onSearch"
/>
</div>
<!-- 表格 -->
<div class="table-content">
<a-table
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: onSelectChange,
}"
:loading="loading"
bordered
:scroll="{ y: 580 }"
:columns="columns"
:pagination="{
showTotal: (total) => `共 ${total} 条`,
current: current,
total: total,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: pageSizeOptions,
onChange: handleChange,
onShowSizeChange: showSizeChange,
}"
:data-source="tableData"
:rowKey="(record) => record.id"
>
<!-- 序号 -->
<span slot="num" slot-scope="text, record, index">{{
(current - 1) * size + index + 1
}}</span>
<!-- 操作 -->
<template slot="action" slot-scope="text">
<a-space size="middle">
<span class="primary pointer" @click="handleEdit(text)">编辑</span>
<span class="delete pointer" @click="handleDel(text.id)">删除</span>
</a-space>
</template>
</a-table>
</div>
<!-- 新增、编辑分类 -->
<AddCategory
ref="AddCategory"
:title="title"
:addVisile.sync="addVisile"
@addSuccess="getCategoryList"
></AddCategory>
</div>
</template>
<script>
import { getCategoryList, deleteCategory } from "@/services/market";
import AddCategory from "../modal/AddCategory";
import local from "@/utils/local";
import { pageSizeOptions } from "@/config/pageConfig.js";
const columns = [
{
title: "序号",
dataIndex: "num",
width: "65px",
scopedSlots: {
customRender: "num",
},
},
{
title: "站点名称",
dataIndex: "siteName",
},
{
title: "分类名称",
dataIndex: "categoryName",
},
{
title: "排序",
dataIndex: "sort",
},
{
title: "创建时间",
dataIndex: "createTime",
},
{
title: "操作",
width: "150px",
scopedSlots: { customRender: "action" },
},
];
export default {
components: {
AddCategory,
},
data() {
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
columns,
siteId: local.getLocal("siteId"),
tableData: [], // 表格数据
loading: false,
searchVal: "", // 搜索
current: 1,
size: 10,
total: 0,
pageSizeOptions,
selectedRowKeys: [], // 表格勾选数据
AddVisible: false,
title: "新增分类",
addVisile: false,
};
},
created() {
this.getCategoryList();
},
methods: {
// 获取分类列表
async getCategoryList() {
this.loading = true;
let res = await getCategoryList({
page: this.current,
size: this.size,
siteId: this.siteId,
categoryName: `%${this.searchVal}%`,
});
this.loading = false;
let { data, total } = res.data.data;
if (res.data.code === 1) {
if (!data.length && this.current > 1) {
this.current -= 1;
this.getCategoryList();
}
this.tableData = data;
this.total = total;
}
},
// 新增
handleAdd() {
this.title = "新增分类";
this.$refs.AddCategory.onAdd();
this.addVisile = true;
},
// 搜索
onSearch() {
this.current = 1;
this.getCategoryList();
},
// 翻页
handleChange(cur) {
this.current = cur;
this.getCategoryList();
},
// 改变每页显示数量
showSizeChange(current, size) {
this.current = current;
this.size = size;
this.getCategoryList();
},
// 勾选表格
onSelectChange(keys) {
this.selectedRowKeys = keys;
},
// 编辑
handleEdit(row) {
this.title = "编辑分类";
this.$refs.AddCategory.onEdit(row);
this.addVisile = true;
},
// 删除
handleDel(id) {
let _this = this;
_this.$confirm({
title: "系统提示",
content: "删除不可恢复,确定要删除吗?",
okText: "确定",
okType: "danger",
cancelText: "取消",
centered: true,
icon: "exclamation-circle",
maskClosable: true,
async onOk() {
let res = await deleteCategory({ id });
let { code, msg } = res.data;
if (code === 1) {
_this.$message.success(msg);
_this.getCategoryList();
}
},
onCancel() {
console.log("Cancel");
},
});
},
},
};
</script>
<style lang="less" scoped></style>
......@@ -168,8 +168,8 @@
></DevToBlack>
</div>
</template>
<script>
<script>
import {
getDeviceList,
getBlackAppList,
......@@ -330,7 +330,6 @@ export default {
let { data, total } = res.data.data;
this.deviceList = data;
this.rightTotal = total;
console.log(data);
}
this.rightLoading = false;
},
......@@ -443,8 +442,8 @@ export default {
},
};
</script>
<style lang="less" scoped>
<style lang="less" scoped>
.black-app {
width: 100%;
height: 100%;
......@@ -482,4 +481,4 @@ export default {
justify-content: space-between;
}
}
</style>
\ No newline at end of file
</style>
<template>
<div>
<a-modal
v-model="Visible"
:maskClosable="false"
:title="title"
@cancel="handleClose"
destroyOnClose
centered
>
<template slot="footer">
<a-button @click="handleReset">重置</a-button>
<a-button type="primary" @click="handleOk">确定</a-button>
</template>
<a-form-model
ref="form"
:model="form"
:rules="rules"
:label-col="{ span: 4 }"
:wrapper-col="{ span: 20 }"
>
<a-form-model-item label="分类名称" prop="categoryName">
<a-input v-model="form.categoryName" placeholder="请输入分类名称" />
</a-form-model-item>
<a-form-model-item label="分类编码" prop="categoryCode">
<a-input v-model="form.categoryCode" placeholder="请输入分类编码" />
</a-form-model-item>
<a-form-model-item label="排序" prop="sort">
<a-input-number v-model="form.sort" :min="1" />
</a-form-model-item>
</a-form-model>
</a-modal>
</div>
</template>
<script>
import { saveCategory } from "@/services/market";
import local from "@/utils/local";
export default {
props: {
addVisile: {
type: Boolean,
require: true,
default: false,
},
title: {
require: true,
default: "新增分类",
},
},
components: {},
data() {
return {
form: {
siteId: local.getLocal("siteId"), // 站点id
siteName: local.getLocal("siteName"), // 站点名称
categoryName: "", // 分类名称
categoryCode: "", // 分类编码
sort: 99, // 排序
},
rules: {
categoryName: [
{ required: true, message: "请输入分类名称", trigger: "blur" },
],
categoryCode: [
{ required: true, message: "请输入分类编码", trigger: "blur" },
],
},
};
},
computed: {
Visible: {
get() {
return this.addVisile;
},
set(val) {
this.$emit("update:addVisile", val);
},
},
},
created() {},
methods: {
// 新增
onAdd() {
Object.assign(this.form, this.$options.data().form);
this.form.id && this.$delete(this.form, "id");
},
// 编辑
onEdit(data) {
this.form = { ...data };
},
// 关闭弹窗
handleClose() {
this.$refs.form.resetFields();
this.Visible = false;
},
// 保存
handleOk() {
this.$refs.form.validate(async (valid) => {
if (valid) {
let res = await saveCategory(this.form);
let { code, msg } = res.data;
if (code == 1) {
this.$message.success(msg);
this.$emit("addSuccess");
this.handleClose();
}
}
});
},
// 重置
handleReset() {
this.$refs.form.resetFields();
},
},
};
</script>
<style lang="less" scoped></style>
......@@ -6,6 +6,7 @@
<script>
import local from "@/utils/local";
import { mapMutations } from "vuex";
export default {
data() {
return {};
......@@ -14,6 +15,12 @@ export default {
this.getToken();
},
methods: {
...mapMutations("site", [
"SET_userInfo",
"SET_token",
"SET_SITE_ID",
"SET_siteName",
]),
// 获取token
getToken() {
let token = this.$route.query.token;
......@@ -22,8 +29,12 @@ export default {
let siteName = this.$route.query.siteName;
if (token && userInfo) {
userInfo = JSON.parse(userInfo);
local.setLocal("token", token);
local.setLocal("baseUserInfo", userInfo);
this.SET_userInfo(userInfo);
this.SET_token(token);
this.SET_SITE_ID(siteId);
this.SET_siteName(siteName);
// local.setLocal("token", token);
// local.setLocal("baseUserInfo", userInfo);
local.setLocal("siteId", siteId);
local.setLocal("siteName", siteName);
this.$router.push("/website");
......@@ -38,5 +49,4 @@ export default {
};
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
<style lang="less" scoped></style>
......@@ -264,6 +264,14 @@ const options = {
invisible: true,
},
},
{
path: "category",
component: () =>
import("@/pages/basicset/appmarket/components/AppCategory"),
meta: {
invisible: true,
},
},
],
},
{
......
......@@ -317,6 +317,13 @@ module.exports = {
used: `${BASE_URL}/base/app/version/used`,
preview: `${BASE_URL}/base/app/version/preview`,
},
// 应用分类
Appcategory: {
list: `${BASE_URL}/base/app/category/list`,
info: `${BASE_URL}/base/app/category/info`,
save: `${BASE_URL}/base/app/category/save`,
delete: `${BASE_URL}/base/app/category/delete`,
},
// 系统设置
system: {
// 系统日志
......
......@@ -6,6 +6,7 @@ import {
version,
device,
blackapp,
Appcategory,
} from "@/services/basicsetApi";
import { request, METHOD } from "@/utils/request";
......@@ -164,3 +165,22 @@ export async function saveBlackApp(data) {
export async function deleteBlackapp(data) {
return request(blackapp.delete, METHOD.GET, data);
}
/**
* 应用分类
*/
// 获取分类列表
export async function getCategoryList(data) {
return request(Appcategory.list, METHOD.POST, data);
}
// 保存分类列表
export async function saveCategory(data) {
return request(Appcategory.save, METHOD.POST, data);
}
// 删除分类列表
export async function deleteCategory(data) {
return request(Appcategory.delete, METHOD.GET, data);
}
......@@ -2,6 +2,7 @@ export default {
namespaced: true,
state: {
siteId: "", // 站点id
siteName: "", // 站点名称
imageResolution: [], // 皮肤设置分辨率
SiteTree: [], // 站点树
appTemplate: [], // 应用模板属性
......@@ -32,8 +33,20 @@ export default {
appDict(state) {
return state.appDict;
},
siteId(state) {
return state.siteId;
},
},
mutations: {
SET_siteName(state, siteName) {
state.siteName = siteName;
},
SET_userInfo(state, userInfo) {
state.userInfo = userInfo;
},
SET_token(state, token) {
state.token = token;
},
SET_curProduct(state, curProduct) {
state.curProduct = curProduct;
},
......
// import Cookie from 'js-cookie'
import local from "@/utils/local";
// import local from "@/utils/local";
import { message } from "ant-design-vue";
import store from "@/store/index";
// 401拦截
// const resp401 = {
// /**
......@@ -71,7 +71,8 @@ const reqCommon = {
*/
onFulfilled(config) {
// 携带token
let token = local.getLocal("token");
// let token = local.getLocal("token");
let token = store.getters["site/token"];
if (token) {
config.headers.Authorization = token;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment