重构小程序端管理模块
This commit is contained in:
@@ -59,10 +59,10 @@
|
||||
<div
|
||||
v-any-role="['merchant', 'superAdmin']"
|
||||
class="ele-text-secondary"
|
||||
>{{ record.phone }}
|
||||
>{{ record.phone }}
|
||||
</div>
|
||||
<div v-role="'guest'" class="ele-text-secondary"
|
||||
>{{ record.mobile }}
|
||||
>{{ record.mobile }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
@@ -70,17 +70,20 @@
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<template v-if="record.status == 0">
|
||||
<a-tag>已下架</a-tag>
|
||||
<a-tag>待审核</a-tag>
|
||||
</template>
|
||||
<template v-if="record.status == 1">
|
||||
<a-tag color="green">已上架</a-tag>
|
||||
<a-tag color="green">已通过</a-tag>
|
||||
</template>
|
||||
<template v-if="record.status == 2">
|
||||
<a-tag color="red">已驳回</a-tag>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'expirationTime'">
|
||||
<template v-if="record.version == 30"> -</template>
|
||||
<template v-else>
|
||||
<div>{{ toDateString(record.createTime, 'yyyy-MM-dd') }}</div>
|
||||
<div>{{ toDateString(record.expirationTime, 'yyyy-MM-dd') }}</div>
|
||||
<div>{{ toDateString(record.createTime, "yyyy-MM-dd") }}</div>
|
||||
<div>{{ toDateString(record.expirationTime, "yyyy-MM-dd") }}</div>
|
||||
<div
|
||||
v-if="expirationTime(record.expirationTime) < 0"
|
||||
class="ele-text-placeholder"
|
||||
@@ -99,9 +102,15 @@
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'version'">
|
||||
<span v-if="record.version == 10"> 免费版 </span>
|
||||
<span v-if="record.version == 20"> 商业版 </span>
|
||||
<span v-if="record.version == 30"> 永久授权 </span>
|
||||
<span class="text-gray-400" v-if="record.version == 10">
|
||||
免费版
|
||||
</span>
|
||||
<span class="text-blue-500" v-if="record.version == 20">
|
||||
商业版
|
||||
</span>
|
||||
<span class="text-green-500" v-if="record.version == 30">
|
||||
永久授权
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'appUrl'">
|
||||
<DesktopOutlined
|
||||
@@ -159,14 +168,13 @@
|
||||
支付宝扫一扫
|
||||
</div>
|
||||
</template>
|
||||
<a-button :size="`small`">
|
||||
<AlipayOutlined class="ele-text-primary" />
|
||||
支付宝
|
||||
</a-button>
|
||||
<AlipayOutlined />
|
||||
</a-popover>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a class="font-bold" @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<template v-if="record.deleted == 1">
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
@@ -205,292 +213,300 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, watch } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
IdcardOutlined,
|
||||
TabletOutlined,
|
||||
DesktopOutlined,
|
||||
GlobalOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import CompanyEdit from './components/company-edit.vue';
|
||||
import {
|
||||
destructionCompany,
|
||||
removeBatchCompany,
|
||||
removeCompany,
|
||||
undeleteCompany
|
||||
} from '@/api/oa/company';
|
||||
import { Company, CompanyParam } from '@/api/system/company/model';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { createVNode, ref, watch } from "vue";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
IdcardOutlined,
|
||||
TabletOutlined,
|
||||
DesktopOutlined,
|
||||
GlobalOutlined
|
||||
} from "@ant-design/icons-vue";
|
||||
import type { EleProTable } from "ele-admin-pro";
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from "ele-admin-pro/es/ele-pro-table/types";
|
||||
import Search from "./components/search.vue";
|
||||
import CompanyEdit from "./components/company-edit.vue";
|
||||
import {
|
||||
destructionCompany,
|
||||
removeBatchCompany,
|
||||
removeCompany,
|
||||
undeleteCompany
|
||||
} from "@/api/oa/company";
|
||||
import { Company, CompanyParam } from "@/api/system/company/model";
|
||||
import { toDateString } from "ele-admin-pro";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const { currentRoute } = useRouter();
|
||||
import { pageCompanyAll } from '@/api/system/company';
|
||||
import {
|
||||
copyText,
|
||||
getMerchantId,
|
||||
getPageTitle,
|
||||
getUserId,
|
||||
openNew
|
||||
} from '@/utils/common';
|
||||
import { addUserCollection } from '@/api/system/user-collection';
|
||||
const { currentRoute } = useRouter();
|
||||
import { pageCompanyAll } from "@/api/system/company";
|
||||
import {
|
||||
copyText,
|
||||
getMerchantId,
|
||||
getPageTitle,
|
||||
getUserId,
|
||||
openNew
|
||||
} from "@/utils/common";
|
||||
import { addUserCollection } from "@/api/system/user-collection";
|
||||
import { getTenantId } from "@/utils/domain";
|
||||
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '租户ID',
|
||||
fixed: 'left',
|
||||
dataIndex: 'tenantId',
|
||||
align: 'center',
|
||||
width: 90
|
||||
},
|
||||
{
|
||||
title: 'Logo',
|
||||
dataIndex: 'companyLogo',
|
||||
key: 'companyLogo',
|
||||
align: 'center',
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '租户名称',
|
||||
dataIndex: 'shortName',
|
||||
key: 'shortName'
|
||||
},
|
||||
{
|
||||
title: '版本',
|
||||
dataIndex: 'version',
|
||||
align: 'center',
|
||||
key: 'version'
|
||||
},
|
||||
{
|
||||
title: '到期时间',
|
||||
dataIndex: 'expirationTime',
|
||||
key: 'expirationTime',
|
||||
align: 'center',
|
||||
width: 160,
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
key: 'appUrl',
|
||||
width: 180
|
||||
},
|
||||
// {
|
||||
// title: '状态',
|
||||
// dataIndex: 'status',
|
||||
// align: 'center',
|
||||
// width: 120,
|
||||
// key: 'status',
|
||||
// customRender: ({ text }) => ['已上线', '开发中'][text]
|
||||
// }
|
||||
]);
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: "租户ID",
|
||||
fixed: "left",
|
||||
dataIndex: "tenantId",
|
||||
align: "center",
|
||||
width: 90
|
||||
},
|
||||
{
|
||||
title: "Logo",
|
||||
dataIndex: "companyLogo",
|
||||
key: "companyLogo",
|
||||
align: "center",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: "租户名称",
|
||||
dataIndex: "shortName",
|
||||
key: "shortName"
|
||||
},
|
||||
{
|
||||
title: "版本",
|
||||
dataIndex: "version",
|
||||
align: "center",
|
||||
key: "version",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: "到期时间",
|
||||
dataIndex: "expirationTime",
|
||||
key: "expirationTime",
|
||||
align: "center",
|
||||
width: 160,
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text, "yyyy-MM-dd")
|
||||
},
|
||||
{
|
||||
title: "应用终端",
|
||||
align: "center",
|
||||
key: "appUrl",
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
key: 'status'
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
align: "center",
|
||||
dataIndex: "action",
|
||||
width: 180
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Company[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Company | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
// 页面标题
|
||||
const title = getPageTitle();
|
||||
// 表格选中数据
|
||||
const selection = ref<Company[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Company | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
// 页面标题
|
||||
const title = getPageTitle();
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where.merchantId = getMerchantId();
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where.merchantId = getMerchantId();
|
||||
|
||||
// 默认显示我的收藏
|
||||
if (where.version == undefined) {
|
||||
where.version = 99;
|
||||
}
|
||||
// 回收站
|
||||
if (where.version == 88) {
|
||||
where.version = undefined;
|
||||
where.deleted = 1;
|
||||
}
|
||||
// 查询全部
|
||||
if (where.version == 100) {
|
||||
where.version = undefined;
|
||||
}
|
||||
return pageCompanyAll({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
// 默认显示我的收藏
|
||||
if (where.version == undefined) {
|
||||
where.version = 99;
|
||||
}
|
||||
// 回收站
|
||||
if (where.version == 88) {
|
||||
where.version = undefined;
|
||||
where.deleted = 1;
|
||||
}
|
||||
// 查询全部
|
||||
if (where.version == 100) {
|
||||
where.version = undefined;
|
||||
}
|
||||
return pageCompanyAll({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: CompanyParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
/* 搜索 */
|
||||
const reload = (where?: CompanyParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Company) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Company) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const expirationTime = (dateTime) => {
|
||||
const now = new Date().getTime();
|
||||
const expiration = new Date(dateTime).getTime();
|
||||
const mss = expiration - now;
|
||||
let days = Math.floor(mss / (1000 * 60 * 60 * 24));
|
||||
let hours = Math.floor((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
let minutes = Math.floor((mss % (1000 * 60 * 60)) / (1000 * 60));
|
||||
let seconds = Math.round((mss % (1000 * 60)) / 1000);
|
||||
return days;
|
||||
};
|
||||
const expirationTime = (dateTime) => {
|
||||
const now = new Date().getTime();
|
||||
const expiration = new Date(dateTime).getTime();
|
||||
const mss = expiration - now;
|
||||
let days = Math.floor(mss / (1000 * 60 * 60 * 24));
|
||||
let hours = Math.floor((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
let minutes = Math.floor((mss % (1000 * 60 * 60)) / (1000 * 60));
|
||||
let seconds = Math.round((mss % (1000 * 60)) / 1000);
|
||||
return days;
|
||||
};
|
||||
|
||||
const expirationTimeText = (item: any) => {
|
||||
const now = new Date().getTime();
|
||||
const expiration = new Date(item.expirationTime).getTime();
|
||||
const mss = expiration - now;
|
||||
let days = Math.floor(mss / (1000 * 60 * 60 * 24));
|
||||
let hours = Math.floor((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
let minutes = Math.floor((mss % (1000 * 60 * 60)) / (1000 * 60));
|
||||
let seconds = Math.round((mss % (1000 * 60)) / 1000);
|
||||
if (item.version == 30) {
|
||||
return `永久授权`;
|
||||
}
|
||||
if (days < 0) {
|
||||
// item.status = 1;
|
||||
// updateCompany(item);
|
||||
return `(已过期${Math.abs(days)}天)`;
|
||||
}
|
||||
if (days < 30) {
|
||||
return `(剩余${days}天)`;
|
||||
}
|
||||
};
|
||||
const expirationTimeText = (item: any) => {
|
||||
const now = new Date().getTime();
|
||||
const expiration = new Date(item.expirationTime).getTime();
|
||||
const mss = expiration - now;
|
||||
let days = Math.floor(mss / (1000 * 60 * 60 * 24));
|
||||
let hours = Math.floor((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
let minutes = Math.floor((mss % (1000 * 60 * 60)) / (1000 * 60));
|
||||
let seconds = Math.round((mss % (1000 * 60)) / 1000);
|
||||
if (item.version == 30) {
|
||||
return `永久授权`;
|
||||
}
|
||||
if (days < 0) {
|
||||
// item.status = 1;
|
||||
// updateCompany(item);
|
||||
return `(已过期${Math.abs(days)}天)`;
|
||||
}
|
||||
if (days < 30) {
|
||||
return `(剩余${days}天)`;
|
||||
}
|
||||
};
|
||||
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
|
||||
const onCode = (text: string) => {
|
||||
console.log(text);
|
||||
};
|
||||
const onCode = (text: string) => {
|
||||
console.log(text);
|
||||
};
|
||||
|
||||
const onCollection = (item: Company) => {
|
||||
addUserCollection({ tid: item.companyId }).then((msg) => {
|
||||
const onCollection = (item: Company) => {
|
||||
addUserCollection({ tid: item.companyId }).then((msg) => {
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Company) => {
|
||||
const hide = message.loading("请求中..", 0);
|
||||
removeCompany(row.companyId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Company) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeCompany(row.companyId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error("请至少选择一条数据");
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: "提示",
|
||||
content: "确定要删除选中的记录吗?",
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading("请求中..", 0);
|
||||
removeBatchCompany(selection.value.map((d) => d.companyId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchCompany(selection.value.map((d) => d.companyId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// 从回收站放回原处
|
||||
const recovery = (row: Company) => {
|
||||
undeleteCompany(row.companyId)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 销毁租户
|
||||
const destruction = (row: Company) => {
|
||||
destructionCompany(row.tenantId)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
() => {
|
||||
// 从回收站放回原处
|
||||
const recovery = (row: Company) => {
|
||||
undeleteCompany(row.companyId)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 销毁租户
|
||||
const destruction = (row: Company) => {
|
||||
destructionCompany(row.tenantId)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
() => {
|
||||
reload();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import * as MenuIcons from '@/layout/menu-icons';
|
||||
import * as MenuIcons from "@/layout/menu-icons";
|
||||
|
||||
export default {
|
||||
name: 'CompanyIndex',
|
||||
components: MenuIcons
|
||||
};
|
||||
export default {
|
||||
name: "CompanyIndex",
|
||||
components: MenuIcons
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.tag-icon {
|
||||
padding-right: 6px;
|
||||
}
|
||||
.tag-icon {
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.qrcode {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.qrcode {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user