134 lines
3.9 KiB
Vue
134 lines
3.9 KiB
Vue
<template>
|
|
<div>
|
|
<div class="n-layout-page-header">
|
|
<n-card :bordered="false" title="IM外部服务配置" />
|
|
</div>
|
|
<n-card :bordered="false" class="proCard">
|
|
<BasicForm
|
|
ref="searchFormRef"
|
|
@register="register"
|
|
@submit="reloadTable"
|
|
@reset="handleReset"
|
|
@keyup.enter="reloadTable"
|
|
/>
|
|
<BasicTable
|
|
ref="actionRef"
|
|
:columns="columns"
|
|
:request="loadDataTable"
|
|
:row-key="(row) => row.tenantId + '-' + row.service"
|
|
:actionColumn="actionColumn"
|
|
:scroll-x="scrollX"
|
|
:resizeHeightOffset="-10000"
|
|
/>
|
|
</n-card>
|
|
<EditModal ref="editRef" @reload-table="reloadTable" />
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, h, onMounted, reactive, ref } from 'vue';
|
|
import { useDialog, useMessage } from 'naive-ui';
|
|
import { BasicForm, useForm } from '@/components/Form/index';
|
|
import { BasicTable, TableAction } from '@/components/Table';
|
|
import { usePermission } from '@/hooks/web/usePermission';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { Check, List } from '@/api/imExternalConfig';
|
|
import { columns, loadOptions, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
|
import { adaTableScrollX } from '@/utils/hotgo';
|
|
import EditModal from './edit.vue';
|
|
|
|
const message = useMessage();
|
|
const dialog = useDialog();
|
|
const { hasPermission } = usePermission();
|
|
const userStore = useUserStore();
|
|
const isPlatformAdmin = computed(() => userStore.isCompanyDept);
|
|
const actionRef = ref();
|
|
const searchFormRef = ref<any>({});
|
|
const editRef = ref();
|
|
|
|
const tenantSchema = schemas.value.find((item) => item.field === 'tenantId');
|
|
if (tenantSchema) {
|
|
tenantSchema.ifShow = () => isPlatformAdmin.value;
|
|
}
|
|
|
|
const actionColumn = reactive({
|
|
width: 170,
|
|
title: '操作',
|
|
key: 'action',
|
|
fixed: 'right',
|
|
render(record: State) {
|
|
return h(TableAction as any, {
|
|
style: 'button',
|
|
actions: [
|
|
{
|
|
label: '编辑',
|
|
auth: ['/imExternalConfig/update'],
|
|
onClick: () => editRef.value.openModal(record),
|
|
},
|
|
{
|
|
label: '检查',
|
|
type: 'warning',
|
|
auth: ['/imExternalConfig/check'],
|
|
onClick: () => handleCheck(record),
|
|
},
|
|
],
|
|
});
|
|
},
|
|
});
|
|
const scrollX = computed(() => adaTableScrollX(columns, actionColumn.width));
|
|
|
|
const [register, { setFieldsValue }] = useForm({
|
|
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
|
labelWidth: 90,
|
|
schemas,
|
|
});
|
|
|
|
const loadDataTable = async (res) => {
|
|
const params = { ...searchFormRef.value?.formModel, ...res };
|
|
if (isPlatformAdmin.value && !params.tenantId)
|
|
return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
|
return await List(params);
|
|
};
|
|
|
|
function reloadTable() {
|
|
actionRef.value?.reload();
|
|
}
|
|
|
|
async function handleReset() {
|
|
const defaults: Recordable = {};
|
|
if (isPlatformAdmin.value && tenantOptions.value.length > 0)
|
|
defaults.tenantId = tenantOptions.value[0].value;
|
|
await setFieldsValue(defaults);
|
|
reloadTable();
|
|
}
|
|
|
|
function handleCheck(record: State) {
|
|
dialog.warning({
|
|
title: '检查配置',
|
|
content: '将执行基础配置完整性检查,是否确认?',
|
|
positiveText: '确认',
|
|
negativeText: '取消',
|
|
onPositiveClick: async () => {
|
|
await Check({ tenantId: record.tenantId, service: record.service });
|
|
message.success('操作成功');
|
|
reloadTable();
|
|
},
|
|
});
|
|
}
|
|
|
|
onMounted(async () => {
|
|
loadOptions();
|
|
if (isPlatformAdmin.value) {
|
|
await loadTenantOptions();
|
|
if (tenantOptions.value.length > 0) {
|
|
await setFieldsValue({ tenantId: tenantOptions.value[0].value });
|
|
} else {
|
|
message.warning('暂无可用租户');
|
|
}
|
|
}
|
|
reloadTable();
|
|
});
|
|
</script>
|
|
|
|
<style lang="less" scoped></style>
|