123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <template>
- <PageWrapper contentBackground>
- <div class="desc-wrap-BasicTable">
- <BasicTable @register="registerTable">
- <template #toolbar>
- <a-button type="primary" @click="openModal(true, {language})" v-if="getCheckPerm('news-add')">
- 新增经销商</a-button
- >
- </template>
- <template #action="{ record }">
- <TableAction
- stopButtonPropagation
- :actions="[
- {
- label: '权益设置',
- //icon: 'icon-park-outline:folder-withdrawal-one',
- ifShow: getCheckPerm('news-withdraw'),
- onClick: handleWithdraw.bind(null, record),
- },
- {
- label: '编辑',
- //icon: 'ep:edit',
- ifShow: getCheckPerm('news-edit'),
- onClick: handleEdit.bind(null, record),
- },
- {
- label: '删除',
- //icon: 'ic:outline-delete-outline',
- ifShow: getCheckPerm('news-delete'),
- onClick: handleDelete.bind(null, record),
- },
- ]"
- />
- </template>
- </BasicTable>
- </div>
- <addNewModal @register="register" @update="reload" />
- <editNewModal @register="registerEdit" @update="reload" />
- <financeModal @register="registerFinance" @update="reload" />
- </PageWrapper>
- </template>
- <script lang="ts">
- import { defineComponent, h, ref } from 'vue';
- import {
- BasicTable,
- useTable,
- TableAction,
- BasicColumn,
- TableImg,
- FormProps,
- } from '/@/components/Table';
- import { PageWrapper } from '/@/components/Page';
- import { Time } from '/@/components/Time';
- import { agentNewList, agentNewDel } from '/@/api/dealer';
- import { Descriptions, Tabs } from 'ant-design-vue';
- import { useModal } from '/@/components/Modal';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { useMessage } from '/@/hooks/web/useMessage';
- import addNewModal from './components/addModal.vue';
- import editNewModal from './components/editModal.vue';
- import financeModal from './components/financeModal.vue';
- import { usePermissionStore } from '/@/store/modules/permission';
- export default defineComponent({
- components: {
- BasicTable,
- TableAction,
- PageWrapper,
- TableImg,
- addNewModal,
- editNewModal,
- financeModal,
- [Descriptions.name]: Descriptions,
- [Descriptions.Item.name]: Descriptions.Item,
- [Tabs.name]: Tabs,
- [Tabs.TabPane.name]: Tabs.TabPane,
- },
- setup() {
- const { t } = useI18n();
- const { createMessage, createConfirm } = useMessage();
- const permissionStore = usePermissionStore();
- const { getCheckPerm } = permissionStore;
- const [register, { openModal }] = useModal();
- const [registerEdit, { openModal:openEditModal }] = useModal();
- const [registerFinance, { openModal:openFinanceModal }] = useModal();
- const language = ref<string>('cn'); //未处理,0已处理(默认1)
- const columns: BasicColumn[] = [
- {
- title: '经销商名称',
- dataIndex: 'name',
- ellipsis: true,
- width: 250,
- },
- {
- title: '联系人',
- dataIndex: 'nickName',
- ellipsis: true,
- width: 250,
- },
- {
- title: '账号',
- ellipsis: true,
- dataIndex: 'userName',
- width: 120,
- },
- {
- title: '创建人',
- ellipsis: true,
- dataIndex: 'sysUserName',
- width: 120,
- },
- {
- title: '创建时间',
- dataIndex: 'createTime',
- width: 150,
- customRender: ({ record }) => {
- return (
- record.createTime &&
- h(Time, {
- value: record.createTime,
- mode: 'datetime',
- })
- );
- },
- },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 100,
- autoSubmitOnEnter: true,
- schemas: [
- {
- field: 'name',
- label: '经销商名称',
- component: 'Input',
- colProps: {
- xl: 7,
- xxl: 7,
- },
- },
- ],
- };
- const [registerTable, { reload }] = useTable({
- api: agentNewList,
- title: '经销商账号列表',
- columns: columns,
- useSearchForm: true,
- formConfig: searchForm,
- showTableSetting: true,
- showIndexColumn: false,
- searchInfo: { language },
- rowKey: 'id',
- fetchSetting: {
- pageField: 'pageNum',
- sizeField: 'pageSize',
- listField: 'list',
- totalField: 'total',
- },
- beforeFetch: (T) => {
- if (T.ctivated) {
- T.publicTimeStart = T.ctivated[0];
- T.publicTimeEnd = T.ctivated[1];
- }
- return T;
- },
- actionColumn: {
- width: 220,
- title: '操作',
- dataIndex: 'action',
- slots: { customRender: 'action' },
- },
- canResize: true,
- });
- async function handleDelete(record: Recordable) {
- createConfirm({
- iconType: 'warning',
- title: () => h('span', '温馨提示'),
- content: () => h('span', '确定要删除吗?'),
- onOk: async () => {
- await agentNewDel({ id: record.id });
- createMessage.success(t('common.optSuccess'));
- reload();
- },
- });
- }
- async function handlePublish(record: Recordable) {
- console.log('点击了发布', record);
- await casePublicApi({ id: record.id, isPublic: 1 });
- createMessage.success(t('common.optSuccess'));
- reload();
- }
- function handleEdit(record: Recordable) {
- console.log('点击了编辑', record);
- openEditModal(true, {...record,language});
- }
- async function handleWithdraw(record: Recordable) {
- openFinanceModal(true, {...record});
- // await casePublicApi({ id: record.id, isPublic: 0 });
- // createMessage.success(t('common.optSuccess'));
- // reload();
- }
- function changeTable(val: string) {
- language.value = val;
- reload();
- }
- function hendleAddNew() {
- console.log('新增新闻');
- }
- return {
- registerTable,
- handleDelete,
- handleEdit,
- handleWithdraw,
- handlePublish,
- hendleAddNew,
- changeTable,
- reload,
- language,
- register,
- registerFinance,
- registerEdit,
- openModal,
- getCheckPerm,
- };
- },
- });
- </script>
|