hldy_vue/src/components/dataAsync/AsyncMainList.vue

178 lines
4.6 KiB
Vue

<template>
<div class="p-2">
<!--引用表格-->
<BasicTable @register="registerTable" :expandRowByClick="true" class="darkened-table">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'asyncmain:nu_async_main:add'" @click="handleAdd"
preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" v-auth="'asyncmain:nu_async_main:exportXls'" preIcon="ant-design:export-outlined"
@click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" v-auth="'asyncmain:nu_async_main:importExcel'"
preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'asyncmain:nu_async_main:deleteBatch'">批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template v-slot:bodyCell="{ column, record, index, text }">
<template v-if="column.dataIndex === 'asyncStatusList'">
<span style="color: #008DFF;">点击此行展开/收起同步详情</span>
</template>
</template>
<template #expandedRowRender="{ record, index, indent, expanded }">
<a-table :columns="asyncStatusColumns" :data-source="record.asyncStatusList" :pagination="false" bordered
class="z-table-class" size="small">
<template #bodyCell="{ column }">
</template>
</a-table>
</template>
</BasicTable>
<!-- 表单区域 -->
<AsyncMainModal ref="registerModal" @success="handleSuccess"></AsyncMainModal>
</div>
</template>
<script lang="ts" name="asyncmain-asyncMain" setup>
import { ref, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { asyncMaincolumns, asyncStatusColumns } from './AsyncMain.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AsyncMain.api';
import AsyncMainModal from './components/AsyncMainModal.vue'
const props = defineProps({
orgCode: 'orgCode',
type:'',
});
const queryParam = reactive<any>({});
const registerModal = ref();
//注册table数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '数据同步主表',
api: list,
columns: asyncMaincolumns,
canResize: false,
useSearchForm: false,
showTableSetting: false,
showActionColumn: false,
beforeFetch: async (params) => {
queryParam.type = props.type
queryParam.orgCode = props.orgCode
return Object.assign(params, queryParam);
},
},
exportConfig: {
name: "数据同步主表",
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
/**
* 新增事件
*/
function handleAdd() {
registerModal.value.disableSubmit = false;
registerModal.value.add();
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 查询
*/
function searchQuery() {
reload();
}
defineExpose({
searchQuery
});
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
padding: 0;
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust {
min-width: 100px !important;
}
.query-group-split-cust {
width: 30px;
display: inline-block;
text-align: center
}
.ant-form-item:not(.ant-form-item-with-help) {
margin-bottom: 16px;
height: 32px;
}
:deep(.ant-picker),
:deep(.ant-input-number) {
width: 100%;
}
}
:deep(.ant-table-title) {
display: none !important;
}
:deep(.darkened-table) {
.ant-table-thead>tr>th {
background-color: #dadadaee;
}
.ant-table-tbody>tr>td {
background-color: #f3f3f3f5;
}
}
:deep(.z-table-class) {
.ant-table-thead>tr>th {
background-color: #e6f0fd;
}
.ant-table-tbody>tr>td {
background-color: #FBFBFB;
}
}
</style>