| @ -0,0 +1,63 @@ | |||||
| import { defHttp } from '/@/utils/http/axios'; | |||||
| import { useMessage } from '/@/hooks/web/useMessage'; | |||||
| const { createConfirm } = useMessage(); | |||||
| enum Api { | |||||
| list = '/appbanner/appBanner/list', | |||||
| save = '/appbanner/appBanner/add', | |||||
| edit = '/appbanner/appBanner/edit', | |||||
| deleteOne = '/appbanner/appBanner/delete', | |||||
| deleteBatch = '/appbanner/appBanner/deleteBatch', | |||||
| importExcel = '/appbanner/appBanner/importExcel', | |||||
| exportXls = '/appbanner/appBanner/exportXls', | |||||
| } | |||||
| /** | |||||
| * 导出api | |||||
| * @param params | |||||
| */ | |||||
| export const getExportUrl = Api.exportXls; | |||||
| /** | |||||
| * 导入api | |||||
| */ | |||||
| export const getImportUrl = Api.importExcel; | |||||
| /** | |||||
| * 列表接口 | |||||
| * @param params | |||||
| */ | |||||
| export const list = (params) => defHttp.get({ url: Api.list, params }); | |||||
| /** | |||||
| * 删除单个 | |||||
| */ | |||||
| export const deleteOne = (params, handleSuccess) => { | |||||
| return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 批量删除 | |||||
| * @param params | |||||
| */ | |||||
| export const batchDelete = (params, handleSuccess) => { | |||||
| createConfirm({ | |||||
| iconType: 'warning', | |||||
| title: '确认删除', | |||||
| content: '是否删除选中数据', | |||||
| okText: '确认', | |||||
| cancelText: '取消', | |||||
| onOk: () => { | |||||
| return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }, | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 保存或者更新 | |||||
| * @param params | |||||
| */ | |||||
| export const saveOrUpdate = (params, isUpdate) => { | |||||
| const url = isUpdate ? Api.edit : Api.save; | |||||
| return defHttp.post({ url: url, params }); | |||||
| }; | |||||
| @ -0,0 +1,197 @@ | |||||
| import { BasicColumn } from '/@/components/Table'; | |||||
| import { FormSchema } from '/@/components/Table'; | |||||
| import { rules } from '/@/utils/helper/validator'; | |||||
| import { render } from '/@/utils/common/renderUtils'; | |||||
| import { getWeekMonthQuarterYear } from '/@/utils'; | |||||
| //列表数据 | |||||
| export const columns: BasicColumn[] = [ | |||||
| { | |||||
| title: '图片地址', | |||||
| align: 'center', | |||||
| dataIndex: 'image', | |||||
| customRender: render.renderImage, | |||||
| }, | |||||
| { | |||||
| title: '跳转地址', | |||||
| align: 'center', | |||||
| dataIndex: 'jumpUrl', | |||||
| }, | |||||
| { | |||||
| title: '跳转类型', | |||||
| align: 'center', | |||||
| dataIndex: 'jumpType_dictText', | |||||
| }, | |||||
| { | |||||
| title: '广告位置', | |||||
| align: 'center', | |||||
| dataIndex: 'position_dictText', | |||||
| }, | |||||
| { | |||||
| title: '状态', | |||||
| align: 'center', | |||||
| dataIndex: 'status_dictText', | |||||
| }, | |||||
| { | |||||
| title: '分享名称', | |||||
| align: 'center', | |||||
| dataIndex: 'shareName', | |||||
| }, | |||||
| { | |||||
| title: '分享图', | |||||
| align: 'center', | |||||
| dataIndex: 'shareImage', | |||||
| customRender: render.renderImage, | |||||
| }, | |||||
| { | |||||
| title: '创建日期', | |||||
| align: 'center', | |||||
| dataIndex: 'createTime', | |||||
| }, | |||||
| { | |||||
| title: '更新日期', | |||||
| align: 'center', | |||||
| dataIndex: 'updateTime', | |||||
| }, | |||||
| ]; | |||||
| //查询数据 | |||||
| export const searchFormSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '跳转类型', | |||||
| field: 'jumpType', | |||||
| component: 'JSelectMultiple', | |||||
| componentProps: { | |||||
| dictCode: 'app_banner_jump_type', | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| { | |||||
| label: '广告位置', | |||||
| field: 'position', | |||||
| component: 'JSelectMultiple', | |||||
| componentProps: { | |||||
| dictCode: 'app_banner_position', | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| { | |||||
| label: '状态', | |||||
| field: 'status', | |||||
| component: 'JSelectMultiple', | |||||
| componentProps: { | |||||
| dictCode: 'dict_item_status', | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| { | |||||
| label: '创建日期', | |||||
| field: 'createTime', | |||||
| component: 'RangePicker', | |||||
| componentProps: { | |||||
| valueType: 'Date', | |||||
| showTime: true, | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| ]; | |||||
| //表单数据 | |||||
| export const formSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '图片地址', | |||||
| field: 'image', | |||||
| component: 'JImageUpload', | |||||
| componentProps: { | |||||
| fileMax: 0, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入图片地址!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '跳转地址', | |||||
| field: 'jumpUrl', | |||||
| component: 'Input', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入跳转地址!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '跳转类型', | |||||
| field: 'jumpType', | |||||
| component: 'JDictSelectTag', | |||||
| componentProps: { | |||||
| dictCode: 'app_banner_jump_type', | |||||
| stringToNumber: true, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入跳转类型!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '广告位置', | |||||
| field: 'position', | |||||
| component: 'JDictSelectTag', | |||||
| componentProps: { | |||||
| dictCode: 'app_banner_position', | |||||
| stringToNumber: true, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入广告位置!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '状态', | |||||
| field: 'status', | |||||
| defaultValue: 1, | |||||
| component: 'JDictSelectTag', | |||||
| componentProps: { | |||||
| dictCode: 'dict_item_status', | |||||
| type: 'radio', | |||||
| stringToNumber: true, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入状态!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '分享名称', | |||||
| field: 'shareName', | |||||
| component: 'Input', | |||||
| }, | |||||
| { | |||||
| label: '分享图', | |||||
| field: 'shareImage', | |||||
| component: 'JImageUpload', | |||||
| componentProps: { | |||||
| fileMax: 0, | |||||
| }, | |||||
| }, | |||||
| // TODO 主键隐藏字段,目前写死为ID | |||||
| { | |||||
| label: '', | |||||
| field: 'id', | |||||
| component: 'Input', | |||||
| show: false, | |||||
| }, | |||||
| ]; | |||||
| // 高级查询数据 | |||||
| export const superQuerySchema = { | |||||
| image: { title: '图片地址', order: 0, view: 'image', type: 'string' }, | |||||
| jumpUrl: { title: '跳转地址', order: 1, view: 'text', type: 'string' }, | |||||
| jumpType: { title: '跳转类型', order: 2, view: 'number', type: 'number', dictCode: 'app_banner_jump_type' }, | |||||
| position: { title: '广告位置', order: 3, view: 'number', type: 'number', dictCode: 'app_banner_position' }, | |||||
| status: { title: '状态', order: 4, view: 'number', type: 'number', dictCode: 'dict_item_status' }, | |||||
| shareName: { title: '分享名称', order: 5, view: 'text', type: 'string' }, | |||||
| shareImage: { title: '分享图', order: 6, view: 'image', type: 'string' }, | |||||
| createTime: { title: '创建日期', order: 7, view: 'datetime', type: 'string' }, | |||||
| updateTime: { title: '更新日期', order: 8, view: 'datetime', type: 'string' }, | |||||
| }; | |||||
| /** | |||||
| * 流程表单调用这个方法获取formSchema | |||||
| * @param param | |||||
| */ | |||||
| export function getBpmFormSchema(_formData): FormSchema[] { | |||||
| // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema | |||||
| return formSchema; | |||||
| } | |||||
| @ -0,0 +1,190 @@ | |||||
| <template> | |||||
| <div> | |||||
| <!--引用表格--> | |||||
| <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |||||
| <!--插槽:table标题--> | |||||
| <template #tableTitle> | |||||
| <a-button type="primary" v-auth="'appbanner:app_banner:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |||||
| <a-button type="primary" v-auth="'appbanner:app_banner:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> | |||||
| <j-upload-button type="primary" v-auth="'appbanner:app_banner: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" /> | |||||
| 删除 | |||||
| </a-menu-item> | |||||
| </a-menu> | |||||
| </template> | |||||
| <a-button v-auth="'appbanner:app_banner:deleteBatch'" | |||||
| >批量操作 | |||||
| <Icon icon="mdi:chevron-down" /> | |||||
| </a-button> | |||||
| </a-dropdown> | |||||
| <!-- 高级查询 --> | |||||
| <super-query :config="superQueryConfig" @search="handleSuperQuery" /> | |||||
| </template> | |||||
| <!--操作栏--> | |||||
| <template #action="{ record }"> | |||||
| <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> | |||||
| </template> | |||||
| <!--字段回显插槽--> | |||||
| <template #bodyCell="{ column, record, index, text }"> </template> | |||||
| </BasicTable> | |||||
| <!-- 表单区域 --> | |||||
| <AppBannerModal @register="registerModal" @success="handleSuccess" /> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts" name="appbanner-appBanner" setup> | |||||
| import { ref, reactive, computed, unref } from 'vue'; | |||||
| import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |||||
| import { useModal } from '/@/components/Modal'; | |||||
| import { useListPage } from '/@/hooks/system/useListPage'; | |||||
| import AppBannerModal from './components/AppBannerModal.vue'; | |||||
| import { columns, searchFormSchema, superQuerySchema } from './AppBanner.data'; | |||||
| import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AppBanner.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(); | |||||
| //注册model | |||||
| const [registerModal, { openModal }] = useModal(); | |||||
| //注册table数据 | |||||
| const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ | |||||
| tableProps: { | |||||
| title: '应用广告配置', | |||||
| api: list, | |||||
| columns, | |||||
| canResize: false, | |||||
| formConfig: { | |||||
| //labelWidth: 120, | |||||
| schemas: searchFormSchema, | |||||
| autoSubmitOnEnter: true, | |||||
| showAdvancedButton: true, | |||||
| fieldMapToNumber: [], | |||||
| fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD HH:mm:ss']], | |||||
| }, | |||||
| actionColumn: { | |||||
| width: 120, | |||||
| 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; | |||||
| // 高级查询配置 | |||||
| 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: '编辑', | |||||
| onClick: handleEdit.bind(null, record), | |||||
| auth: 'appbanner:app_banner:edit', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| /** | |||||
| * 下拉操作栏 | |||||
| */ | |||||
| function getDropDownAction(record) { | |||||
| return [ | |||||
| { | |||||
| label: '详情', | |||||
| onClick: handleDetail.bind(null, record), | |||||
| }, | |||||
| { | |||||
| label: '删除', | |||||
| popConfirm: { | |||||
| title: '是否确认删除', | |||||
| confirm: handleDelete.bind(null, record), | |||||
| placement: 'topLeft', | |||||
| }, | |||||
| auth: 'appbanner:app_banner:delete', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| :deep(.ant-picker), | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,70 @@ | |||||
| <template> | |||||
| <div style="min-height: 400px"> | |||||
| <BasicForm @register="registerForm" /> | |||||
| <div style="width: 100%; text-align: center" v-if="!formDisabled"> | |||||
| <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button> | |||||
| </div> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts"> | |||||
| import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
| import { computed, defineComponent } from 'vue'; | |||||
| import { defHttp } from '/@/utils/http/axios'; | |||||
| import { propTypes } from '/@/utils/propTypes'; | |||||
| import { getBpmFormSchema } from '../AppBanner.data'; | |||||
| import { saveOrUpdate } from '../AppBanner.api'; | |||||
| export default defineComponent({ | |||||
| name: 'AppBannerForm', | |||||
| components: { | |||||
| BasicForm, | |||||
| }, | |||||
| props: { | |||||
| formData: propTypes.object.def({}), | |||||
| formBpm: propTypes.bool.def(true), | |||||
| }, | |||||
| setup(props) { | |||||
| const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: getBpmFormSchema(props.formData), | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: { span: 24 }, | |||||
| }); | |||||
| const formDisabled = computed(() => { | |||||
| if (props.formData.disabled === false) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| }); | |||||
| let formData = {}; | |||||
| const queryByIdUrl = '/appbanner/appBanner/queryById'; | |||||
| async function initFormData() { | |||||
| let params = { id: props.formData.dataId }; | |||||
| const data = await defHttp.get({ url: queryByIdUrl, params }); | |||||
| formData = { ...data }; | |||||
| //设置表单的值 | |||||
| await setFieldsValue(formData); | |||||
| //默认是禁用 | |||||
| await setProps({ disabled: formDisabled.value }); | |||||
| } | |||||
| async function submitForm() { | |||||
| let data = getFieldsValue(); | |||||
| let params = Object.assign({}, formData, data); | |||||
| console.log('表单数据', params); | |||||
| await saveOrUpdate(params, true); | |||||
| } | |||||
| initFormData(); | |||||
| return { | |||||
| registerForm, | |||||
| formDisabled, | |||||
| submitForm, | |||||
| }; | |||||
| }, | |||||
| }); | |||||
| </script> | |||||
| @ -0,0 +1,76 @@ | |||||
| <template> | |||||
| <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> | |||||
| <BasicForm @register="registerForm" name="AppBannerForm" /> | |||||
| </BasicModal> | |||||
| </template> | |||||
| <script lang="ts" setup> | |||||
| import { ref, computed, unref } from 'vue'; | |||||
| import { BasicModal, useModalInner } from '/@/components/Modal'; | |||||
| import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
| import { formSchema } from '../AppBanner.data'; | |||||
| import { saveOrUpdate } from '../AppBanner.api'; | |||||
| // Emits声明 | |||||
| const emit = defineEmits(['register', 'success']); | |||||
| const isUpdate = ref(true); | |||||
| const isDetail = ref(false); | |||||
| //表单配置 | |||||
| const [registerForm, { setProps, resetFields, setFieldsValue, validate, scrollToField }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: formSchema, | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: { span: 24 }, | |||||
| }); | |||||
| //表单赋值 | |||||
| const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { | |||||
| //重置表单 | |||||
| await resetFields(); | |||||
| setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter }); | |||||
| isUpdate.value = !!data?.isUpdate; | |||||
| isDetail.value = !!data?.showFooter; | |||||
| if (unref(isUpdate)) { | |||||
| //表单赋值 | |||||
| await setFieldsValue({ | |||||
| ...data.record, | |||||
| }); | |||||
| } | |||||
| // 隐藏底部时禁用整个表单 | |||||
| setProps({ disabled: !data?.showFooter }); | |||||
| }); | |||||
| //设置标题 | |||||
| const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑')); | |||||
| //表单提交事件 | |||||
| async function handleSubmit(v) { | |||||
| try { | |||||
| let values = await validate(); | |||||
| setModalProps({ confirmLoading: true }); | |||||
| //提交表单 | |||||
| await saveOrUpdate(values, isUpdate.value); | |||||
| //关闭弹窗 | |||||
| closeModal(); | |||||
| //刷新列表 | |||||
| emit('success'); | |||||
| } catch ({ errorFields }) { | |||||
| if (errorFields) { | |||||
| const firstField = errorFields[0]; | |||||
| if (firstField) { | |||||
| scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); | |||||
| } | |||||
| } | |||||
| return Promise.reject(errorFields); | |||||
| } finally { | |||||
| setModalProps({ confirmLoading: false }); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| /** 时间和数字输入框样式 */ | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| :deep(.ant-calendar-picker) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -1,26 +0,0 @@ | |||||
| -- 注意:该页面对应的前台目录为views/appuser文件夹下 | |||||
| -- 如果你想更改到其他目录,请修改sql中component字段对应的值 | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external) | |||||
| VALUES ('2025021011269440530', NULL, '应用用户表', '/appuser/appUserList', 'appuser/AppUserList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0); | |||||
| -- 权限控制sql | |||||
| -- 新增 | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) | |||||
| VALUES ('2025021011269440531', '2025021011269440530', '添加应用用户表', NULL, NULL, 0, NULL, NULL, 2, 'appuser:app_user:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0, 0, '1', 0); | |||||
| -- 编辑 | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) | |||||
| VALUES ('2025021011269440532', '2025021011269440530', '编辑应用用户表', NULL, NULL, 0, NULL, NULL, 2, 'appuser:app_user:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0, 0, '1', 0); | |||||
| -- 删除 | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) | |||||
| VALUES ('2025021011269440533', '2025021011269440530', '删除应用用户表', NULL, NULL, 0, NULL, NULL, 2, 'appuser:app_user:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0, 0, '1', 0); | |||||
| -- 批量删除 | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) | |||||
| VALUES ('2025021011269440534', '2025021011269440530', '批量删除应用用户表', NULL, NULL, 0, NULL, NULL, 2, 'appuser:app_user:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0, 0, '1', 0); | |||||
| -- 导出excel | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) | |||||
| VALUES ('2025021011269440535', '2025021011269440530', '导出excel_应用用户表', NULL, NULL, 0, NULL, NULL, 2, 'appuser:app_user:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0, 0, '1', 0); | |||||
| -- 导入excel | |||||
| INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) | |||||
| VALUES ('2025021011269440536', '2025021011269440530', '导入excel_应用用户表', NULL, NULL, 0, NULL, NULL, 2, 'appuser:app_user:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-02-10 11:26:53', NULL, NULL, 0, 0, '1', 0); | |||||
| @ -0,0 +1,63 @@ | |||||
| import { defHttp } from '/src/utils/http/axios'; | |||||
| import { useMessage } from '/src/hooks/web/useMessage'; | |||||
| const { createConfirm } = useMessage(); | |||||
| enum Api { | |||||
| list = '/notice/appNotice/list', | |||||
| save = '/notice/appNotice/add', | |||||
| edit = '/notice/appNotice/edit', | |||||
| deleteOne = '/notice/appNotice/delete', | |||||
| deleteBatch = '/notice/appNotice/deleteBatch', | |||||
| importExcel = '/notice/appNotice/importExcel', | |||||
| exportXls = '/notice/appNotice/exportXls', | |||||
| } | |||||
| /** | |||||
| * 导出api | |||||
| * @param params | |||||
| */ | |||||
| export const getExportUrl = Api.exportXls; | |||||
| /** | |||||
| * 导入api | |||||
| */ | |||||
| export const getImportUrl = Api.importExcel; | |||||
| /** | |||||
| * 列表接口 | |||||
| * @param params | |||||
| */ | |||||
| export const list = (params) => defHttp.get({ url: Api.list, params }); | |||||
| /** | |||||
| * 删除单个 | |||||
| */ | |||||
| export const deleteOne = (params, handleSuccess) => { | |||||
| return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 批量删除 | |||||
| * @param params | |||||
| */ | |||||
| export const batchDelete = (params, handleSuccess) => { | |||||
| createConfirm({ | |||||
| iconType: 'warning', | |||||
| title: '确认删除', | |||||
| content: '是否删除选中数据', | |||||
| okText: '确认', | |||||
| cancelText: '取消', | |||||
| onOk: () => { | |||||
| return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }, | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 保存或者更新 | |||||
| * @param params | |||||
| */ | |||||
| export const saveOrUpdate = (params, isUpdate) => { | |||||
| const url = isUpdate ? Api.edit : Api.save; | |||||
| return defHttp.post({ url: url, params }); | |||||
| }; | |||||
| @ -0,0 +1,122 @@ | |||||
| import { BasicColumn } from '/src/components/Table'; | |||||
| import { FormSchema } from '/src/components/Table'; | |||||
| import { rules } from '/src/utils/helper/validator'; | |||||
| import { render } from '/src/utils/common/renderUtils'; | |||||
| import { getWeekMonthQuarterYear } from '/src/utils'; | |||||
| //列表数据 | |||||
| export const columns: BasicColumn[] = [ | |||||
| { | |||||
| title: '标题', | |||||
| align: 'center', | |||||
| dataIndex: 'title', | |||||
| }, | |||||
| { | |||||
| title: '状态', | |||||
| align: 'center', | |||||
| dataIndex: 'status_dictText', | |||||
| }, | |||||
| { | |||||
| title: '排序', | |||||
| align: 'center', | |||||
| sorter: true, | |||||
| dataIndex: 'sort', | |||||
| }, | |||||
| { | |||||
| title: '创建日期', | |||||
| align: 'center', | |||||
| sorter: true, | |||||
| dataIndex: 'createTime', | |||||
| }, | |||||
| ]; | |||||
| //查询数据 | |||||
| export const searchFormSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '标题', | |||||
| field: 'title', | |||||
| component: 'JInput', | |||||
| }, | |||||
| { | |||||
| label: '状态', | |||||
| field: 'status', | |||||
| component: 'JSelectMultiple', | |||||
| componentProps: { | |||||
| dictCode: 'dict_item_status', | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| { | |||||
| label: '创建日期', | |||||
| field: 'createTime', | |||||
| component: 'RangePicker', | |||||
| componentProps: { | |||||
| valueType: 'Date', | |||||
| showTime: true, | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| ]; | |||||
| //表单数据 | |||||
| export const formSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '标题', | |||||
| field: 'title', | |||||
| component: 'Input', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入标题!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '内容', | |||||
| field: 'content', | |||||
| component: 'JEditor', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入内容!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '状态', | |||||
| field: 'status', | |||||
| defaultValue: 1, | |||||
| component: 'JDictSelectTag', | |||||
| componentProps: { | |||||
| dictCode: 'dict_item_status', | |||||
| type: 'radio', | |||||
| stringToNumber: true, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入状态!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '排序', | |||||
| field: 'sort', | |||||
| component: 'InputNumber', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入排序!' }]; | |||||
| }, | |||||
| }, | |||||
| // TODO 主键隐藏字段,目前写死为ID | |||||
| { | |||||
| label: '', | |||||
| field: 'id', | |||||
| component: 'Input', | |||||
| show: false, | |||||
| }, | |||||
| ]; | |||||
| // 高级查询数据 | |||||
| export const superQuerySchema = { | |||||
| title: { title: '标题', order: 0, view: 'text', type: 'string' }, | |||||
| status: { title: '状态', order: 2, view: 'number', type: 'number', dictCode: 'dict_item_status' }, | |||||
| sort: { title: '排序', order: 3, view: 'number', type: 'number' }, | |||||
| createTime: { title: '创建日期', order: 4, view: 'datetime', type: 'string' }, | |||||
| }; | |||||
| /** | |||||
| * 流程表单调用这个方法获取formSchema | |||||
| * @param param | |||||
| */ | |||||
| export function getBpmFormSchema(_formData): FormSchema[] { | |||||
| // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema | |||||
| return formSchema; | |||||
| } | |||||
| @ -0,0 +1,190 @@ | |||||
| <template> | |||||
| <div> | |||||
| <!--引用表格--> | |||||
| <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |||||
| <!--插槽:table标题--> | |||||
| <template #tableTitle> | |||||
| <a-button type="primary" v-auth="'notice:app_notice:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |||||
| <a-button type="primary" v-auth="'notice:app_notice:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> | |||||
| <j-upload-button type="primary" v-auth="'notice:app_notice: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" /> | |||||
| 删除 | |||||
| </a-menu-item> | |||||
| </a-menu> | |||||
| </template> | |||||
| <a-button v-auth="'notice:app_notice:deleteBatch'" | |||||
| >批量操作 | |||||
| <Icon icon="mdi:chevron-down" /> | |||||
| </a-button> | |||||
| </a-dropdown> | |||||
| <!-- 高级查询 --> | |||||
| <super-query :config="superQueryConfig" @search="handleSuperQuery" /> | |||||
| </template> | |||||
| <!--操作栏--> | |||||
| <template #action="{ record }"> | |||||
| <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> | |||||
| </template> | |||||
| <!--字段回显插槽--> | |||||
| <template #bodyCell="{ column, record, index, text }"> </template> | |||||
| </BasicTable> | |||||
| <!-- 表单区域 --> | |||||
| <AppNoticeModal @register="registerModal" @success="handleSuccess" /> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts" name="notice-appNotice" setup> | |||||
| import { ref, reactive, computed, unref } from 'vue'; | |||||
| import { BasicTable, useTable, TableAction } from '/src/components/Table'; | |||||
| import { useModal } from '/src/components/Modal'; | |||||
| import { useListPage } from '/src/hooks/system/useListPage'; | |||||
| import AppNoticeModal from './components/AppNoticeModal.vue'; | |||||
| import { columns, searchFormSchema, superQuerySchema } from './AppNotice.data'; | |||||
| import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AppNotice.api'; | |||||
| import { downloadFile } from '/src/utils/common/renderUtils'; | |||||
| import { useUserStore } from '/src/store/modules/user'; | |||||
| const queryParam = reactive<any>({}); | |||||
| const checkedKeys = ref<Array<string | number>>([]); | |||||
| const userStore = useUserStore(); | |||||
| //注册model | |||||
| const [registerModal, { openModal }] = useModal(); | |||||
| //注册table数据 | |||||
| const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ | |||||
| tableProps: { | |||||
| title: '公告管理', | |||||
| api: list, | |||||
| columns, | |||||
| canResize: false, | |||||
| formConfig: { | |||||
| //labelWidth: 120, | |||||
| schemas: searchFormSchema, | |||||
| autoSubmitOnEnter: true, | |||||
| showAdvancedButton: true, | |||||
| fieldMapToNumber: [], | |||||
| fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD HH:mm:ss']], | |||||
| }, | |||||
| actionColumn: { | |||||
| width: 120, | |||||
| 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; | |||||
| // 高级查询配置 | |||||
| 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: '编辑', | |||||
| onClick: handleEdit.bind(null, record), | |||||
| auth: 'notice:app_notice:edit', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| /** | |||||
| * 下拉操作栏 | |||||
| */ | |||||
| function getDropDownAction(record) { | |||||
| return [ | |||||
| { | |||||
| label: '详情', | |||||
| onClick: handleDetail.bind(null, record), | |||||
| }, | |||||
| { | |||||
| label: '删除', | |||||
| popConfirm: { | |||||
| title: '是否确认删除', | |||||
| confirm: handleDelete.bind(null, record), | |||||
| placement: 'topLeft', | |||||
| }, | |||||
| auth: 'notice:app_notice:delete', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| :deep(.ant-picker), | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,70 @@ | |||||
| <template> | |||||
| <div style="min-height: 400px"> | |||||
| <BasicForm @register="registerForm"></BasicForm> | |||||
| <div style="width: 100%;text-align: center" v-if="!formDisabled"> | |||||
| <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button> | |||||
| </div> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts"> | |||||
| import {BasicForm, useForm} from '/src/components/Form'; | |||||
| import {computed, defineComponent} from 'vue'; | |||||
| import {defHttp} from '/src/utils/http/axios'; | |||||
| import { propTypes } from '/src/utils/propTypes'; | |||||
| import {getBpmFormSchema} from '../AppNotice.data'; | |||||
| import {saveOrUpdate} from '../AppNotice.api'; | |||||
| export default defineComponent({ | |||||
| name: "AppNoticeForm", | |||||
| components:{ | |||||
| BasicForm | |||||
| }, | |||||
| props:{ | |||||
| formData: propTypes.object.def({}), | |||||
| formBpm: propTypes.bool.def(true), | |||||
| }, | |||||
| setup(props){ | |||||
| const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: getBpmFormSchema(props.formData), | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: {span: 24} | |||||
| }); | |||||
| const formDisabled = computed(()=>{ | |||||
| if(props.formData.disabled === false){ | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| }); | |||||
| let formData = {}; | |||||
| const queryByIdUrl = '/notice/appNotice/queryById'; | |||||
| async function initFormData(){ | |||||
| let params = {id: props.formData.dataId}; | |||||
| const data = await defHttp.get({url: queryByIdUrl, params}); | |||||
| formData = {...data} | |||||
| //设置表单的值 | |||||
| await setFieldsValue(formData); | |||||
| //默认是禁用 | |||||
| await setProps({disabled: formDisabled.value}) | |||||
| } | |||||
| async function submitForm() { | |||||
| let data = getFieldsValue(); | |||||
| let params = Object.assign({}, formData, data); | |||||
| console.log('表单数据', params) | |||||
| await saveOrUpdate(params, true) | |||||
| } | |||||
| initFormData(); | |||||
| return { | |||||
| registerForm, | |||||
| formDisabled, | |||||
| submitForm, | |||||
| } | |||||
| } | |||||
| }); | |||||
| </script> | |||||
| @ -0,0 +1,76 @@ | |||||
| <template> | |||||
| <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> | |||||
| <BasicForm @register="registerForm" name="AppNoticeForm" /> | |||||
| </BasicModal> | |||||
| </template> | |||||
| <script lang="ts" setup> | |||||
| import {ref, computed, unref} from 'vue'; | |||||
| import {BasicModal, useModalInner} from '/src/components/Modal'; | |||||
| import {BasicForm, useForm} from '/src/components/Form'; | |||||
| import {formSchema} from '../AppNotice.data'; | |||||
| import {saveOrUpdate} from '../AppNotice.api'; | |||||
| // Emits声明 | |||||
| const emit = defineEmits(['register','success']); | |||||
| const isUpdate = ref(true); | |||||
| const isDetail = ref(false); | |||||
| //表单配置 | |||||
| const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: formSchema, | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: {span: 24} | |||||
| }); | |||||
| //表单赋值 | |||||
| const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | |||||
| //重置表单 | |||||
| await resetFields(); | |||||
| setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter}); | |||||
| isUpdate.value = !!data?.isUpdate; | |||||
| isDetail.value = !!data?.showFooter; | |||||
| if (unref(isUpdate)) { | |||||
| //表单赋值 | |||||
| await setFieldsValue({ | |||||
| ...data.record, | |||||
| }); | |||||
| } | |||||
| // 隐藏底部时禁用整个表单 | |||||
| setProps({ disabled: !data?.showFooter }) | |||||
| }); | |||||
| //设置标题 | |||||
| const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑')); | |||||
| //表单提交事件 | |||||
| async function handleSubmit(v) { | |||||
| try { | |||||
| let values = await validate(); | |||||
| setModalProps({confirmLoading: true}); | |||||
| //提交表单 | |||||
| await saveOrUpdate(values, isUpdate.value); | |||||
| //关闭弹窗 | |||||
| closeModal(); | |||||
| //刷新列表 | |||||
| emit('success'); | |||||
| } catch ({ errorFields }) { | |||||
| if (errorFields) { | |||||
| const firstField = errorFields[0]; | |||||
| if (firstField) { | |||||
| scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); | |||||
| } | |||||
| } | |||||
| return Promise.reject(errorFields); | |||||
| } finally { | |||||
| setModalProps({confirmLoading: false}); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| /** 时间和数字输入框样式 */ | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| :deep(.ant-calendar-picker) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,63 @@ | |||||
| import { defHttp } from '/@/utils/http/axios'; | |||||
| import { useMessage } from '/@/hooks/web/useMessage'; | |||||
| const { createConfirm } = useMessage(); | |||||
| enum Api { | |||||
| list = '/product/appProduct/list', | |||||
| save = '/product/appProduct/add', | |||||
| edit = '/product/appProduct/edit', | |||||
| deleteOne = '/product/appProduct/delete', | |||||
| deleteBatch = '/product/appProduct/deleteBatch', | |||||
| importExcel = '/product/appProduct/importExcel', | |||||
| exportXls = '/product/appProduct/exportXls', | |||||
| } | |||||
| /** | |||||
| * 导出api | |||||
| * @param params | |||||
| */ | |||||
| export const getExportUrl = Api.exportXls; | |||||
| /** | |||||
| * 导入api | |||||
| */ | |||||
| export const getImportUrl = Api.importExcel; | |||||
| /** | |||||
| * 列表接口 | |||||
| * @param params | |||||
| */ | |||||
| export const list = (params) => defHttp.get({ url: Api.list, params }); | |||||
| /** | |||||
| * 删除单个 | |||||
| */ | |||||
| export const deleteOne = (params, handleSuccess) => { | |||||
| return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 批量删除 | |||||
| * @param params | |||||
| */ | |||||
| export const batchDelete = (params, handleSuccess) => { | |||||
| createConfirm({ | |||||
| iconType: 'warning', | |||||
| title: '确认删除', | |||||
| content: '是否删除选中数据', | |||||
| okText: '确认', | |||||
| cancelText: '取消', | |||||
| onOk: () => { | |||||
| return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }, | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 保存或者更新 | |||||
| * @param params | |||||
| */ | |||||
| export const saveOrUpdate = (params, isUpdate) => { | |||||
| const url = isUpdate ? Api.edit : Api.save; | |||||
| return defHttp.post({ url: url, params }); | |||||
| }; | |||||
| @ -0,0 +1,123 @@ | |||||
| import { BasicColumn } from '/@/components/Table'; | |||||
| import { FormSchema } from '/@/components/Table'; | |||||
| import { rules } from '/@/utils/helper/validator'; | |||||
| import { render } from '/@/utils/common/renderUtils'; | |||||
| import { getWeekMonthQuarterYear } from '/@/utils'; | |||||
| import {getAllTenantList} from "@/views/system/user/user.api"; | |||||
| //列表数据 | |||||
| export const columns: BasicColumn[] = [ | |||||
| { | |||||
| title: '产品名称', | |||||
| align: 'center', | |||||
| dataIndex: 'name', | |||||
| }, | |||||
| { | |||||
| title: '产品分类', | |||||
| align: 'center', | |||||
| dataIndex: 'categoryId_dictText', | |||||
| }, | |||||
| { | |||||
| title: '产品内容', | |||||
| align: 'center', | |||||
| dataIndex: 'content', | |||||
| }, | |||||
| { | |||||
| title: '产品合同模板', | |||||
| align: 'center', | |||||
| dataIndex: 'pdf', | |||||
| }, | |||||
| { | |||||
| title: '创建日期', | |||||
| align: 'center', | |||||
| dataIndex: 'createTime', | |||||
| }, | |||||
| ]; | |||||
| //查询数据 | |||||
| export const searchFormSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '产品名称', | |||||
| field: 'name', | |||||
| component: 'JInput', | |||||
| }, | |||||
| { | |||||
| label: '产品内容', | |||||
| field: 'content', | |||||
| component: 'JInput', | |||||
| }, | |||||
| { | |||||
| label: '创建日期', | |||||
| field: 'createTime', | |||||
| component: 'RangePicker', | |||||
| componentProps: { | |||||
| valueType: 'Date', | |||||
| showTime: true, | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| ]; | |||||
| //表单数据 | |||||
| export const formSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '产品名称', | |||||
| field: 'name', | |||||
| component: 'Input', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入产品名称!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '产品分类', | |||||
| field: 'categoryId', | |||||
| component: 'JDictSelectTag', | |||||
| componentProps: { | |||||
| mode: 'multiple', | |||||
| api: getAllTenantList, | |||||
| numberToString: true, | |||||
| labelField: 'name', | |||||
| valueField: 'id', | |||||
| immediate: false, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入产品分类!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '产品内容', | |||||
| field: 'content', | |||||
| component: 'Input', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入产品内容!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '产品合同模板', | |||||
| field: 'pdf', | |||||
| component: 'JUpload', | |||||
| componentProps: {}, | |||||
| }, | |||||
| // TODO 主键隐藏字段,目前写死为ID | |||||
| { | |||||
| label: '', | |||||
| field: 'id', | |||||
| component: 'Input', | |||||
| show: false, | |||||
| }, | |||||
| ]; | |||||
| // 高级查询数据 | |||||
| export const superQuerySchema = { | |||||
| name: { title: '产品名称', order: 0, view: 'text', type: 'string' }, | |||||
| categoryId: { title: '产品分类', order: 1, view: 'number', type: 'number', dictCode: '' }, | |||||
| content: { title: '产品内容', order: 2, view: 'text', type: 'string' }, | |||||
| pdf: { title: '产品合同模板', order: 3, view: 'file', type: 'string' }, | |||||
| createTime: { title: '创建日期', order: 4, view: 'datetime', type: 'string' }, | |||||
| }; | |||||
| /** | |||||
| * 流程表单调用这个方法获取formSchema | |||||
| * @param param | |||||
| */ | |||||
| export function getBpmFormSchema(_formData): FormSchema[] { | |||||
| // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema | |||||
| return formSchema; | |||||
| } | |||||
| @ -0,0 +1,198 @@ | |||||
| <template> | |||||
| <div> | |||||
| <!--引用表格--> | |||||
| <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |||||
| <!--插槽:table标题--> | |||||
| <template #tableTitle> | |||||
| <a-button type="primary" v-auth="'product:app_product:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |||||
| <a-button type="primary" v-auth="'product:app_product:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> | |||||
| <j-upload-button type="primary" v-auth="'product:app_product: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" /> | |||||
| 删除 | |||||
| </a-menu-item> | |||||
| </a-menu> | |||||
| </template> | |||||
| <a-button v-auth="'product:app_product:deleteBatch'" | |||||
| >批量操作 | |||||
| <Icon icon="mdi:chevron-down" /> | |||||
| </a-button> | |||||
| </a-dropdown> | |||||
| <!-- 高级查询 --> | |||||
| <super-query :config="superQueryConfig" @search="handleSuperQuery" /> | |||||
| </template> | |||||
| <!--操作栏--> | |||||
| <template #action="{ record }"> | |||||
| <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> | |||||
| </template> | |||||
| <!--字段回显插槽--> | |||||
| <template #bodyCell="{ column, record, index, text }"> | |||||
| <template v-if="column.dataIndex === 'pdf'"> | |||||
| <!--文件字段回显插槽--> | |||||
| <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span> | |||||
| <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)" | |||||
| >下载</a-button | |||||
| > | |||||
| </template> | |||||
| </template> | |||||
| </BasicTable> | |||||
| <!-- 表单区域 --> | |||||
| <AppProductModal @register="registerModal" @success="handleSuccess" /> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts" name="product-appProduct" setup> | |||||
| import { ref, reactive, computed, unref } from 'vue'; | |||||
| import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |||||
| import { useModal } from '/@/components/Modal'; | |||||
| import { useListPage } from '/@/hooks/system/useListPage'; | |||||
| import AppProductModal from './components/AppProductModal.vue'; | |||||
| import { columns, searchFormSchema, superQuerySchema } from './AppProduct.data'; | |||||
| import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AppProduct.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(); | |||||
| //注册model | |||||
| const [registerModal, { openModal }] = useModal(); | |||||
| //注册table数据 | |||||
| const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ | |||||
| tableProps: { | |||||
| title: '产品管理', | |||||
| api: list, | |||||
| columns, | |||||
| canResize: false, | |||||
| formConfig: { | |||||
| //labelWidth: 120, | |||||
| schemas: searchFormSchema, | |||||
| autoSubmitOnEnter: true, | |||||
| showAdvancedButton: true, | |||||
| fieldMapToNumber: [], | |||||
| fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD HH:mm:ss']], | |||||
| }, | |||||
| actionColumn: { | |||||
| width: 120, | |||||
| 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; | |||||
| // 高级查询配置 | |||||
| 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: '编辑', | |||||
| onClick: handleEdit.bind(null, record), | |||||
| auth: 'product:app_product:edit', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| /** | |||||
| * 下拉操作栏 | |||||
| */ | |||||
| function getDropDownAction(record) { | |||||
| return [ | |||||
| { | |||||
| label: '详情', | |||||
| onClick: handleDetail.bind(null, record), | |||||
| }, | |||||
| { | |||||
| label: '删除', | |||||
| popConfirm: { | |||||
| title: '是否确认删除', | |||||
| confirm: handleDelete.bind(null, record), | |||||
| placement: 'topLeft', | |||||
| }, | |||||
| auth: 'product:app_product:delete', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| :deep(.ant-picker), | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,70 @@ | |||||
| <template> | |||||
| <div style="min-height: 400px"> | |||||
| <BasicForm @register="registerForm"></BasicForm> | |||||
| <div style="width: 100%;text-align: center" v-if="!formDisabled"> | |||||
| <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button> | |||||
| </div> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts"> | |||||
| import {BasicForm, useForm} from '/@/components/Form/index'; | |||||
| import {computed, defineComponent} from 'vue'; | |||||
| import {defHttp} from '/@/utils/http/axios'; | |||||
| import { propTypes } from '/@/utils/propTypes'; | |||||
| import {getBpmFormSchema} from '../AppProduct.data'; | |||||
| import {saveOrUpdate} from '../AppProduct.api'; | |||||
| export default defineComponent({ | |||||
| name: "AppProductForm", | |||||
| components:{ | |||||
| BasicForm | |||||
| }, | |||||
| props:{ | |||||
| formData: propTypes.object.def({}), | |||||
| formBpm: propTypes.bool.def(true), | |||||
| }, | |||||
| setup(props){ | |||||
| const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: getBpmFormSchema(props.formData), | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: {span: 24} | |||||
| }); | |||||
| const formDisabled = computed(()=>{ | |||||
| if(props.formData.disabled === false){ | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| }); | |||||
| let formData = {}; | |||||
| const queryByIdUrl = '/product/appProduct/queryById'; | |||||
| async function initFormData(){ | |||||
| let params = {id: props.formData.dataId}; | |||||
| const data = await defHttp.get({url: queryByIdUrl, params}); | |||||
| formData = {...data} | |||||
| //设置表单的值 | |||||
| await setFieldsValue(formData); | |||||
| //默认是禁用 | |||||
| await setProps({disabled: formDisabled.value}) | |||||
| } | |||||
| async function submitForm() { | |||||
| let data = getFieldsValue(); | |||||
| let params = Object.assign({}, formData, data); | |||||
| console.log('表单数据', params) | |||||
| await saveOrUpdate(params, true) | |||||
| } | |||||
| initFormData(); | |||||
| return { | |||||
| registerForm, | |||||
| formDisabled, | |||||
| submitForm, | |||||
| } | |||||
| } | |||||
| }); | |||||
| </script> | |||||
| @ -0,0 +1,76 @@ | |||||
| <template> | |||||
| <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> | |||||
| <BasicForm @register="registerForm" name="AppProductForm" /> | |||||
| </BasicModal> | |||||
| </template> | |||||
| <script lang="ts" setup> | |||||
| import {ref, computed, unref} from 'vue'; | |||||
| import {BasicModal, useModalInner} from '/@/components/Modal'; | |||||
| import {BasicForm, useForm} from '/@/components/Form/index'; | |||||
| import {formSchema} from '../AppProduct.data'; | |||||
| import {saveOrUpdate} from '../AppProduct.api'; | |||||
| // Emits声明 | |||||
| const emit = defineEmits(['register','success']); | |||||
| const isUpdate = ref(true); | |||||
| const isDetail = ref(false); | |||||
| //表单配置 | |||||
| const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: formSchema, | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: {span: 24} | |||||
| }); | |||||
| //表单赋值 | |||||
| const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | |||||
| //重置表单 | |||||
| await resetFields(); | |||||
| setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter}); | |||||
| isUpdate.value = !!data?.isUpdate; | |||||
| isDetail.value = !!data?.showFooter; | |||||
| if (unref(isUpdate)) { | |||||
| //表单赋值 | |||||
| await setFieldsValue({ | |||||
| ...data.record, | |||||
| }); | |||||
| } | |||||
| // 隐藏底部时禁用整个表单 | |||||
| setProps({ disabled: !data?.showFooter }) | |||||
| }); | |||||
| //设置标题 | |||||
| const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑')); | |||||
| //表单提交事件 | |||||
| async function handleSubmit(v) { | |||||
| try { | |||||
| let values = await validate(); | |||||
| setModalProps({confirmLoading: true}); | |||||
| //提交表单 | |||||
| await saveOrUpdate(values, isUpdate.value); | |||||
| //关闭弹窗 | |||||
| closeModal(); | |||||
| //刷新列表 | |||||
| emit('success'); | |||||
| } catch ({ errorFields }) { | |||||
| if (errorFields) { | |||||
| const firstField = errorFields[0]; | |||||
| if (firstField) { | |||||
| scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); | |||||
| } | |||||
| } | |||||
| return Promise.reject(errorFields); | |||||
| } finally { | |||||
| setModalProps({confirmLoading: false}); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| /** 时间和数字输入框样式 */ | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| :deep(.ant-calendar-picker) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,64 @@ | |||||
| import {defHttp} from '/@/utils/http/axios'; | |||||
| import { useMessage } from "/@/hooks/web/useMessage"; | |||||
| const { createConfirm } = useMessage(); | |||||
| enum Api { | |||||
| list = '/productCategory/appCategory/list', | |||||
| save='/productCategory/appCategory/add', | |||||
| edit='/productCategory/appCategory/edit', | |||||
| deleteOne = '/productCategory/appCategory/delete', | |||||
| deleteBatch = '/productCategory/appCategory/deleteBatch', | |||||
| importExcel = '/productCategory/appCategory/importExcel', | |||||
| exportXls = '/productCategory/appCategory/exportXls', | |||||
| } | |||||
| /** | |||||
| * 导出api | |||||
| * @param params | |||||
| */ | |||||
| export const getExportUrl = Api.exportXls; | |||||
| /** | |||||
| * 导入api | |||||
| */ | |||||
| export const getImportUrl = Api.importExcel; | |||||
| /** | |||||
| * 列表接口 | |||||
| * @param params | |||||
| */ | |||||
| export const list = (params) => | |||||
| defHttp.get({url: Api.list, params}); | |||||
| /** | |||||
| * 删除单个 | |||||
| */ | |||||
| export const deleteOne = (params,handleSuccess) => { | |||||
| return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| } | |||||
| /** | |||||
| * 批量删除 | |||||
| * @param params | |||||
| */ | |||||
| export const batchDelete = (params, handleSuccess) => { | |||||
| createConfirm({ | |||||
| iconType: 'warning', | |||||
| title: '确认删除', | |||||
| content: '是否删除选中数据', | |||||
| okText: '确认', | |||||
| cancelText: '取消', | |||||
| onOk: () => { | |||||
| return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| } | |||||
| }); | |||||
| } | |||||
| /** | |||||
| * 保存或者更新 | |||||
| * @param params | |||||
| */ | |||||
| export const saveOrUpdate = (params, isUpdate) => { | |||||
| let url = isUpdate ? Api.edit : Api.save; | |||||
| return defHttp.post({url: url, params}); | |||||
| } | |||||
| @ -0,0 +1,71 @@ | |||||
| import {BasicColumn} from '/@/components/Table'; | |||||
| import {FormSchema} from '/@/components/Table'; | |||||
| import { rules} from '/@/utils/helper/validator'; | |||||
| import { render } from '/@/utils/common/renderUtils'; | |||||
| import { getWeekMonthQuarterYear } from '/@/utils'; | |||||
| //列表数据 | |||||
| export const columns: BasicColumn[] = [ | |||||
| { | |||||
| title: '名称', | |||||
| align:"center", | |||||
| dataIndex: 'categoryName' | |||||
| }, | |||||
| { | |||||
| title: '创建日期', | |||||
| align:"center", | |||||
| dataIndex: 'createTime' | |||||
| }, | |||||
| ]; | |||||
| //查询数据 | |||||
| export const searchFormSchema: FormSchema[] = [ | |||||
| { | |||||
| label: "名称", | |||||
| field: "categoryName", | |||||
| component: 'JInput', | |||||
| }, | |||||
| { | |||||
| label: "创建日期", | |||||
| field: "createTime", | |||||
| component: 'RangePicker', | |||||
| componentProps: { | |||||
| valueType: 'Date', | |||||
| showTime:true | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| ]; | |||||
| //表单数据 | |||||
| export const formSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '名称', | |||||
| field: 'categoryName', | |||||
| component: 'Input', | |||||
| dynamicRules: ({model,schema}) => { | |||||
| return [ | |||||
| { required: true, message: '请输入名称!'}, | |||||
| ]; | |||||
| }, | |||||
| }, | |||||
| // TODO 主键隐藏字段,目前写死为ID | |||||
| { | |||||
| label: '', | |||||
| field: 'id', | |||||
| component: 'Input', | |||||
| show: false | |||||
| }, | |||||
| ]; | |||||
| // 高级查询数据 | |||||
| export const superQuerySchema = { | |||||
| categoryName: {title: '名称',order: 0,view: 'text', type: 'string',}, | |||||
| createTime: {title: '创建日期',order: 1,view: 'datetime', type: 'string',}, | |||||
| }; | |||||
| /** | |||||
| * 流程表单调用这个方法获取formSchema | |||||
| * @param param | |||||
| */ | |||||
| export function getBpmFormSchema(_formData): FormSchema[]{ | |||||
| // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema | |||||
| return formSchema; | |||||
| } | |||||
| @ -0,0 +1,191 @@ | |||||
| <template> | |||||
| <div> | |||||
| <!--引用表格--> | |||||
| <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |||||
| <!--插槽:table标题--> | |||||
| <template #tableTitle> | |||||
| <a-button type="primary" v-auth="'productCategory:app_category:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |||||
| <a-button type="primary" v-auth="'productCategory:app_category:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> | |||||
| <j-upload-button type="primary" v-auth="'productCategory:app_category: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="'productCategory:app_category:deleteBatch'">批量操作 | |||||
| <Icon icon="mdi:chevron-down"></Icon> | |||||
| </a-button> | |||||
| </a-dropdown> | |||||
| <!-- 高级查询 --> | |||||
| <super-query :config="superQueryConfig" @search="handleSuperQuery" /> | |||||
| </template> | |||||
| <!--操作栏--> | |||||
| <template #action="{ record }"> | |||||
| <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> | |||||
| </template> | |||||
| <!--字段回显插槽--> | |||||
| <template v-slot:bodyCell="{ column, record, index, text }"> | |||||
| </template> | |||||
| </BasicTable> | |||||
| <!-- 表单区域 --> | |||||
| <AppCategoryModal @register="registerModal" @success="handleSuccess"></AppCategoryModal> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts" name="productCategory-appCategory" setup> | |||||
| import {ref, reactive, computed, unref} from 'vue'; | |||||
| import {BasicTable, useTable, TableAction} from '/@/components/Table'; | |||||
| import {useModal} from '/@/components/Modal'; | |||||
| import { useListPage } from '/@/hooks/system/useListPage' | |||||
| import AppCategoryModal from './components/AppCategoryModal.vue' | |||||
| import {columns, searchFormSchema, superQuerySchema} from './AppCategory.data'; | |||||
| import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './AppCategory.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(); | |||||
| //注册model | |||||
| const [registerModal, {openModal}] = useModal(); | |||||
| //注册table数据 | |||||
| const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ | |||||
| tableProps:{ | |||||
| title: '产品分类管理', | |||||
| api: list, | |||||
| columns, | |||||
| canResize:false, | |||||
| formConfig: { | |||||
| //labelWidth: 120, | |||||
| schemas: searchFormSchema, | |||||
| autoSubmitOnEnter:true, | |||||
| showAdvancedButton:true, | |||||
| fieldMapToNumber: [ | |||||
| ], | |||||
| fieldMapToTime: [ | |||||
| ['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD HH:mm:ss'], | |||||
| ], | |||||
| }, | |||||
| actionColumn: { | |||||
| width: 120, | |||||
| 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 | |||||
| // 高级查询配置 | |||||
| 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: '编辑', | |||||
| onClick: handleEdit.bind(null, record), | |||||
| auth: 'productCategory:app_category:edit' | |||||
| } | |||||
| ] | |||||
| } | |||||
| /** | |||||
| * 下拉操作栏 | |||||
| */ | |||||
| function getDropDownAction(record){ | |||||
| return [ | |||||
| { | |||||
| label: '详情', | |||||
| onClick: handleDetail.bind(null, record), | |||||
| }, { | |||||
| label: '删除', | |||||
| popConfirm: { | |||||
| title: '是否确认删除', | |||||
| confirm: handleDelete.bind(null, record), | |||||
| placement: 'topLeft', | |||||
| }, | |||||
| auth: 'productCategory:app_category:delete' | |||||
| } | |||||
| ] | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| :deep(.ant-picker),:deep(.ant-input-number){ | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,70 @@ | |||||
| <template> | |||||
| <div style="min-height: 400px"> | |||||
| <BasicForm @register="registerForm"></BasicForm> | |||||
| <div style="width: 100%;text-align: center" v-if="!formDisabled"> | |||||
| <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button> | |||||
| </div> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts"> | |||||
| import {BasicForm, useForm} from '/@/components/Form/index'; | |||||
| import {computed, defineComponent} from 'vue'; | |||||
| import {defHttp} from '/@/utils/http/axios'; | |||||
| import { propTypes } from '/@/utils/propTypes'; | |||||
| import {getBpmFormSchema} from '../AppCategory.data'; | |||||
| import {saveOrUpdate} from '../AppCategory.api'; | |||||
| export default defineComponent({ | |||||
| name: "AppCategoryForm", | |||||
| components:{ | |||||
| BasicForm | |||||
| }, | |||||
| props:{ | |||||
| formData: propTypes.object.def({}), | |||||
| formBpm: propTypes.bool.def(true), | |||||
| }, | |||||
| setup(props){ | |||||
| const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: getBpmFormSchema(props.formData), | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: {span: 24} | |||||
| }); | |||||
| const formDisabled = computed(()=>{ | |||||
| if(props.formData.disabled === false){ | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| }); | |||||
| let formData = {}; | |||||
| const queryByIdUrl = '/productCategory/appCategory/queryById'; | |||||
| async function initFormData(){ | |||||
| let params = {id: props.formData.dataId}; | |||||
| const data = await defHttp.get({url: queryByIdUrl, params}); | |||||
| formData = {...data} | |||||
| //设置表单的值 | |||||
| await setFieldsValue(formData); | |||||
| //默认是禁用 | |||||
| await setProps({disabled: formDisabled.value}) | |||||
| } | |||||
| async function submitForm() { | |||||
| let data = getFieldsValue(); | |||||
| let params = Object.assign({}, formData, data); | |||||
| console.log('表单数据', params) | |||||
| await saveOrUpdate(params, true) | |||||
| } | |||||
| initFormData(); | |||||
| return { | |||||
| registerForm, | |||||
| formDisabled, | |||||
| submitForm, | |||||
| } | |||||
| } | |||||
| }); | |||||
| </script> | |||||
| @ -0,0 +1,76 @@ | |||||
| <template> | |||||
| <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> | |||||
| <BasicForm @register="registerForm" name="AppCategoryForm" /> | |||||
| </BasicModal> | |||||
| </template> | |||||
| <script lang="ts" setup> | |||||
| import {ref, computed, unref} from 'vue'; | |||||
| import {BasicModal, useModalInner} from '/@/components/Modal'; | |||||
| import {BasicForm, useForm} from '/@/components/Form/index'; | |||||
| import {formSchema} from '../AppCategory.data'; | |||||
| import {saveOrUpdate} from '../AppCategory.api'; | |||||
| // Emits声明 | |||||
| const emit = defineEmits(['register','success']); | |||||
| const isUpdate = ref(true); | |||||
| const isDetail = ref(false); | |||||
| //表单配置 | |||||
| const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: formSchema, | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: {span: 24} | |||||
| }); | |||||
| //表单赋值 | |||||
| const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | |||||
| //重置表单 | |||||
| await resetFields(); | |||||
| setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter}); | |||||
| isUpdate.value = !!data?.isUpdate; | |||||
| isDetail.value = !!data?.showFooter; | |||||
| if (unref(isUpdate)) { | |||||
| //表单赋值 | |||||
| await setFieldsValue({ | |||||
| ...data.record, | |||||
| }); | |||||
| } | |||||
| // 隐藏底部时禁用整个表单 | |||||
| setProps({ disabled: !data?.showFooter }) | |||||
| }); | |||||
| //设置标题 | |||||
| const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑')); | |||||
| //表单提交事件 | |||||
| async function handleSubmit(v) { | |||||
| try { | |||||
| let values = await validate(); | |||||
| setModalProps({confirmLoading: true}); | |||||
| //提交表单 | |||||
| await saveOrUpdate(values, isUpdate.value); | |||||
| //关闭弹窗 | |||||
| closeModal(); | |||||
| //刷新列表 | |||||
| emit('success'); | |||||
| } catch ({ errorFields }) { | |||||
| if (errorFields) { | |||||
| const firstField = errorFields[0]; | |||||
| if (firstField) { | |||||
| scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); | |||||
| } | |||||
| } | |||||
| return Promise.reject(errorFields); | |||||
| } finally { | |||||
| setModalProps({confirmLoading: false}); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| /** 时间和数字输入框样式 */ | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| :deep(.ant-calendar-picker) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,63 @@ | |||||
| import { defHttp } from '/@/utils/http/axios'; | |||||
| import { useMessage } from '/@/hooks/web/useMessage'; | |||||
| const { createConfirm } = useMessage(); | |||||
| enum Api { | |||||
| list = '/store/appStore/list', | |||||
| save = '/store/appStore/add', | |||||
| edit = '/store/appStore/edit', | |||||
| deleteOne = '/store/appStore/delete', | |||||
| deleteBatch = '/store/appStore/deleteBatch', | |||||
| importExcel = '/store/appStore/importExcel', | |||||
| exportXls = '/store/appStore/exportXls', | |||||
| } | |||||
| /** | |||||
| * 导出api | |||||
| * @param params | |||||
| */ | |||||
| export const getExportUrl = Api.exportXls; | |||||
| /** | |||||
| * 导入api | |||||
| */ | |||||
| export const getImportUrl = Api.importExcel; | |||||
| /** | |||||
| * 列表接口 | |||||
| * @param params | |||||
| */ | |||||
| export const list = (params) => defHttp.get({ url: Api.list, params }); | |||||
| /** | |||||
| * 删除单个 | |||||
| */ | |||||
| export const deleteOne = (params, handleSuccess) => { | |||||
| return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 批量删除 | |||||
| * @param params | |||||
| */ | |||||
| export const batchDelete = (params, handleSuccess) => { | |||||
| createConfirm({ | |||||
| iconType: 'warning', | |||||
| title: '确认删除', | |||||
| content: '是否删除选中数据', | |||||
| okText: '确认', | |||||
| cancelText: '取消', | |||||
| onOk: () => { | |||||
| return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { | |||||
| handleSuccess(); | |||||
| }); | |||||
| }, | |||||
| }); | |||||
| }; | |||||
| /** | |||||
| * 保存或者更新 | |||||
| * @param params | |||||
| */ | |||||
| export const saveOrUpdate = (params, isUpdate) => { | |||||
| const url = isUpdate ? Api.edit : Api.save; | |||||
| return defHttp.post({ url: url, params }); | |||||
| }; | |||||
| @ -0,0 +1,99 @@ | |||||
| import { BasicColumn } from '/@/components/Table'; | |||||
| import { FormSchema } from '/@/components/Table'; | |||||
| import { rules } from '/@/utils/helper/validator'; | |||||
| import { render } from '/@/utils/common/renderUtils'; | |||||
| import { getWeekMonthQuarterYear } from '/@/utils'; | |||||
| //列表数据 | |||||
| export const columns: BasicColumn[] = [ | |||||
| { | |||||
| title: '门店名称', | |||||
| align: 'center', | |||||
| dataIndex: 'storeName', | |||||
| }, | |||||
| { | |||||
| title: '状态', | |||||
| align: 'center', | |||||
| dataIndex: 'status_dictText', | |||||
| }, | |||||
| { | |||||
| title: '备注', | |||||
| align: 'center', | |||||
| dataIndex: 'remark', | |||||
| }, | |||||
| { | |||||
| title: '创建日期', | |||||
| align: 'center', | |||||
| dataIndex: 'createTime', | |||||
| }, | |||||
| ]; | |||||
| //查询数据 | |||||
| export const searchFormSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '门店名称', | |||||
| field: 'storeName', | |||||
| component: 'JInput', | |||||
| }, | |||||
| { | |||||
| label: '状态', | |||||
| field: 'status', | |||||
| component: 'JSelectMultiple', | |||||
| componentProps: { | |||||
| dictCode: 'dict_item_status', | |||||
| }, | |||||
| //colProps: {span: 6}, | |||||
| }, | |||||
| ]; | |||||
| //表单数据 | |||||
| export const formSchema: FormSchema[] = [ | |||||
| { | |||||
| label: '门店名称', | |||||
| field: 'storeName', | |||||
| component: 'Input', | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入门店名称!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '状态', | |||||
| field: 'status', | |||||
| defaultValue: 1, | |||||
| component: 'JDictSelectTag', | |||||
| componentProps: { | |||||
| dictCode: 'dict_item_status', | |||||
| type: 'radio', | |||||
| stringToNumber: true, | |||||
| }, | |||||
| dynamicRules: ({ model, schema }) => { | |||||
| return [{ required: true, message: '请输入状态!' }]; | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: '备注', | |||||
| field: 'remark', | |||||
| component: 'Input', | |||||
| }, | |||||
| // TODO 主键隐藏字段,目前写死为ID | |||||
| { | |||||
| label: '', | |||||
| field: 'id', | |||||
| component: 'Input', | |||||
| show: false, | |||||
| }, | |||||
| ]; | |||||
| // 高级查询数据 | |||||
| export const superQuerySchema = { | |||||
| storeName: { title: '门店名称', order: 0, view: 'text', type: 'string' }, | |||||
| status: { title: '状态', order: 1, view: 'number', type: 'number', dictCode: 'dict_item_status' }, | |||||
| remark: { title: '备注', order: 2, view: 'text', type: 'string' }, | |||||
| createTime: { title: '创建日期', order: 3, view: 'datetime', type: 'string' }, | |||||
| }; | |||||
| /** | |||||
| * 流程表单调用这个方法获取formSchema | |||||
| * @param param | |||||
| */ | |||||
| export function getBpmFormSchema(_formData): FormSchema[] { | |||||
| // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema | |||||
| return formSchema; | |||||
| } | |||||
| @ -0,0 +1,190 @@ | |||||
| <template> | |||||
| <div> | |||||
| <!--引用表格--> | |||||
| <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |||||
| <!--插槽:table标题--> | |||||
| <template #tableTitle> | |||||
| <a-button type="primary" v-auth="'store:app_store:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |||||
| <a-button type="primary" v-auth="'store:app_store:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> | |||||
| <j-upload-button type="primary" v-auth="'store:app_store: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" /> | |||||
| 删除 | |||||
| </a-menu-item> | |||||
| </a-menu> | |||||
| </template> | |||||
| <a-button v-auth="'store:app_store:deleteBatch'" | |||||
| >批量操作 | |||||
| <Icon icon="mdi:chevron-down" /> | |||||
| </a-button> | |||||
| </a-dropdown> | |||||
| <!-- 高级查询 --> | |||||
| <super-query :config="superQueryConfig" @search="handleSuperQuery" /> | |||||
| </template> | |||||
| <!--操作栏--> | |||||
| <template #action="{ record }"> | |||||
| <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> | |||||
| </template> | |||||
| <!--字段回显插槽--> | |||||
| <template #bodyCell="{ column, record, index, text }"> </template> | |||||
| </BasicTable> | |||||
| <!-- 表单区域 --> | |||||
| <AppStoreModal @register="registerModal" @success="handleSuccess" /> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts" name="store-appStore" setup> | |||||
| import { ref, reactive, computed, unref } from 'vue'; | |||||
| import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |||||
| import { useModal } from '/@/components/Modal'; | |||||
| import { useListPage } from '/@/hooks/system/useListPage'; | |||||
| import AppStoreModal from './components/AppStoreModal.vue'; | |||||
| import { columns, searchFormSchema, superQuerySchema } from './AppStore.data'; | |||||
| import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AppStore.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(); | |||||
| //注册model | |||||
| const [registerModal, { openModal }] = useModal(); | |||||
| //注册table数据 | |||||
| const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ | |||||
| tableProps: { | |||||
| title: '门店管理', | |||||
| api: list, | |||||
| columns, | |||||
| canResize: false, | |||||
| formConfig: { | |||||
| //labelWidth: 120, | |||||
| schemas: searchFormSchema, | |||||
| autoSubmitOnEnter: true, | |||||
| showAdvancedButton: true, | |||||
| fieldMapToNumber: [], | |||||
| fieldMapToTime: [], | |||||
| }, | |||||
| actionColumn: { | |||||
| width: 120, | |||||
| 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; | |||||
| // 高级查询配置 | |||||
| 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: '编辑', | |||||
| onClick: handleEdit.bind(null, record), | |||||
| auth: 'store:app_store:edit', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| /** | |||||
| * 下拉操作栏 | |||||
| */ | |||||
| function getDropDownAction(record) { | |||||
| return [ | |||||
| { | |||||
| label: '详情', | |||||
| onClick: handleDetail.bind(null, record), | |||||
| }, | |||||
| { | |||||
| label: '删除', | |||||
| popConfirm: { | |||||
| title: '是否确认删除', | |||||
| confirm: handleDelete.bind(null, record), | |||||
| placement: 'topLeft', | |||||
| }, | |||||
| auth: 'store:app_store:delete', | |||||
| }, | |||||
| ]; | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| :deep(.ant-picker), | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||
| @ -0,0 +1,70 @@ | |||||
| <template> | |||||
| <div style="min-height: 400px"> | |||||
| <BasicForm @register="registerForm" /> | |||||
| <div style="width: 100%; text-align: center" v-if="!formDisabled"> | |||||
| <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button> | |||||
| </div> | |||||
| </div> | |||||
| </template> | |||||
| <script lang="ts"> | |||||
| import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
| import { computed, defineComponent } from 'vue'; | |||||
| import { defHttp } from '/@/utils/http/axios'; | |||||
| import { propTypes } from '/@/utils/propTypes'; | |||||
| import { getBpmFormSchema } from '../AppStore.data'; | |||||
| import { saveOrUpdate } from '../AppStore.api'; | |||||
| export default defineComponent({ | |||||
| name: 'AppStoreForm', | |||||
| components: { | |||||
| BasicForm, | |||||
| }, | |||||
| props: { | |||||
| formData: propTypes.object.def({}), | |||||
| formBpm: propTypes.bool.def(true), | |||||
| }, | |||||
| setup(props) { | |||||
| const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: getBpmFormSchema(props.formData), | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: { span: 24 }, | |||||
| }); | |||||
| const formDisabled = computed(() => { | |||||
| if (props.formData.disabled === false) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| }); | |||||
| let formData = {}; | |||||
| const queryByIdUrl = '/store/appStore/queryById'; | |||||
| async function initFormData() { | |||||
| let params = { id: props.formData.dataId }; | |||||
| const data = await defHttp.get({ url: queryByIdUrl, params }); | |||||
| formData = { ...data }; | |||||
| //设置表单的值 | |||||
| await setFieldsValue(formData); | |||||
| //默认是禁用 | |||||
| await setProps({ disabled: formDisabled.value }); | |||||
| } | |||||
| async function submitForm() { | |||||
| let data = getFieldsValue(); | |||||
| let params = Object.assign({}, formData, data); | |||||
| console.log('表单数据', params); | |||||
| await saveOrUpdate(params, true); | |||||
| } | |||||
| initFormData(); | |||||
| return { | |||||
| registerForm, | |||||
| formDisabled, | |||||
| submitForm, | |||||
| }; | |||||
| }, | |||||
| }); | |||||
| </script> | |||||
| @ -0,0 +1,76 @@ | |||||
| <template> | |||||
| <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> | |||||
| <BasicForm @register="registerForm" name="AppStoreForm" /> | |||||
| </BasicModal> | |||||
| </template> | |||||
| <script lang="ts" setup> | |||||
| import { ref, computed, unref } from 'vue'; | |||||
| import { BasicModal, useModalInner } from '/@/components/Modal'; | |||||
| import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
| import { formSchema } from '../AppStore.data'; | |||||
| import { saveOrUpdate } from '../AppStore.api'; | |||||
| // Emits声明 | |||||
| const emit = defineEmits(['register', 'success']); | |||||
| const isUpdate = ref(true); | |||||
| const isDetail = ref(false); | |||||
| //表单配置 | |||||
| const [registerForm, { setProps, resetFields, setFieldsValue, validate, scrollToField }] = useForm({ | |||||
| labelWidth: 150, | |||||
| schemas: formSchema, | |||||
| showActionButtonGroup: false, | |||||
| baseColProps: { span: 24 }, | |||||
| }); | |||||
| //表单赋值 | |||||
| const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { | |||||
| //重置表单 | |||||
| await resetFields(); | |||||
| setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter }); | |||||
| isUpdate.value = !!data?.isUpdate; | |||||
| isDetail.value = !!data?.showFooter; | |||||
| if (unref(isUpdate)) { | |||||
| //表单赋值 | |||||
| await setFieldsValue({ | |||||
| ...data.record, | |||||
| }); | |||||
| } | |||||
| // 隐藏底部时禁用整个表单 | |||||
| setProps({ disabled: !data?.showFooter }); | |||||
| }); | |||||
| //设置标题 | |||||
| const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑')); | |||||
| //表单提交事件 | |||||
| async function handleSubmit(v) { | |||||
| try { | |||||
| let values = await validate(); | |||||
| setModalProps({ confirmLoading: true }); | |||||
| //提交表单 | |||||
| await saveOrUpdate(values, isUpdate.value); | |||||
| //关闭弹窗 | |||||
| closeModal(); | |||||
| //刷新列表 | |||||
| emit('success'); | |||||
| } catch ({ errorFields }) { | |||||
| if (errorFields) { | |||||
| const firstField = errorFields[0]; | |||||
| if (firstField) { | |||||
| scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); | |||||
| } | |||||
| } | |||||
| return Promise.reject(errorFields); | |||||
| } finally { | |||||
| setModalProps({ confirmLoading: false }); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <style lang="less" scoped> | |||||
| /** 时间和数字输入框样式 */ | |||||
| :deep(.ant-input-number) { | |||||
| width: 100%; | |||||
| } | |||||
| :deep(.ant-calendar-picker) { | |||||
| width: 100%; | |||||
| } | |||||
| </style> | |||||