123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <div>
-
- <BasicTable @register="registerTable" :rowSelection="rowSelection" size="small">
-
- <template #tableTitle>
- <a-button type="primary" v-auth="'cuspCode:cusp_customer_profile:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增(add)</a-button>
- <a-button type="primary" v-auth="'cuspCode:cusp_customer_profile:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出(export)</a-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>
- 删除(delete)
- </a-menu-item>
- </a-menu>
- </template>
- <a-button v-auth="'cuspCode:cusp_customer_profile:deleteBatch'">批量操作(batch operation)
- <Icon icon="mdi:chevron-down"></Icon>
- </a-button>
- </a-dropdown>
-
-
- </template>
-
- <template #action="{ record }">
- <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
- </template>
-
- <template v-slot:bodyCell="{ column, record, index, text }">
- </template>
- </BasicTable>
-
- <CuspCustomerProfileModal @register="registerModal" @success="handleSuccess"></CuspCustomerProfileModal>
- </div>
- </template>
- <script lang="ts" name="cuspCode-cuspCustomerProfile" setup>
- import {ref, reactive, computed, unref,onMounted} from 'vue';
- import {BasicTable, useTable, TableAction} from '/@/components/Table';
- import { useListPage } from '/@/hooks/system/useListPage'
- import {useModal} from '/@/components/Modal';
- import CuspCustomerProfileModal from './components/CuspCustomerProfileModal.vue'
- import {columns, searchFormSchema, superQuerySchema,getIntermediatorOptions} from './CuspCustomerProfile.data';
- import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CuspCustomerProfile.api';
- import {downloadFile} from '/@/utils/common/renderUtils';
- import { useUserStore } from '/@/store/modules/user';
- const queryParam = reactive<any>({});
- const checkedKeys = ref<Array<string | number>>([]);
- const userStore = useUserStore();
-
- const [registerModal, {openModal}] = useModal();
-
- const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
- tableProps:{
- title: '客户档案',
- api: list,
- columns,
- canResize:false,
- formConfig: {
-
- schemas: searchFormSchema,
- autoSubmitOnEnter:true,
- showAdvancedButton:true,
- fieldMapToNumber: [
- ],
- fieldMapToTime: [
- ],
- },
- actionColumn: {
- width: 200,
- fixed:'right'
- },
- beforeFetch: (params) => {
- return Object.assign(params, queryParam);
- },
- },
- exportConfig: {
- name:"客户档案",
- url: getExportUrl,
- params: queryParam,
- },
- importConfig: {
- url: getImportUrl,
- success: handleSuccess
- },
- })
- const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
- onMounted(() => {
- getIntermediatorOptions()
- })
-
- const superQueryConfig = reactive(superQuerySchema);
-
- function handleSuperQuery(params) {
- Object.keys(params).map((k) => {
- queryParam[k] = params[k];
- });
- reload();
- }
-
- function handleAdd() {
- openModal(true, {
- isUpdate: false,
- showFooter: true,
- });
- }
-
- function handleEdit(record: Recordable) {
- openModal(true, {
- record,
- isUpdate: true,
- showFooter: true,
- });
- }
-
- function handleDetail(record: Recordable) {
- openModal(true, {
- record,
- isUpdate: true,
- showFooter: false,
- });
- }
-
- async function handleDelete(record) {
- await deleteOne({id: record.id}, handleSuccess);
- }
-
- async function batchHandleDelete() {
- await batchDelete({ids: selectedRowKeys.value},handleSuccess);
- }
-
- function handleSuccess() {
- (selectedRowKeys.value = []) && reload();
- }
-
- function getTableAction(record){
- return [
- {
- label: '编辑(edit)',
- onClick: handleEdit.bind(null, record),
- auth: 'cuspCode:cusp_customer_profile:edit'
- }
- ]
- }
-
- function getDropDownAction(record){
- return [
- {
- label: '详情(detail)',
- onClick: handleDetail.bind(null, record),
- }, {
- label: '删除(delete)',
- popConfirm: {
- title: '是否确认删除(Are you sure to delete)',
- confirm: handleDelete.bind(null, record),
- placement: 'topLeft'
- },
- auth: 'cuspCode:cusp_customer_profile:delete'
- }
- ]
- }
- </script>
- <style lang="less" scoped>
- :deep(.ant-picker),:deep(.ant-input-number){
- width: 100%;
- }
- </style>
|