喻忠伟 5 months ago
commit d426580326
  1. 81
      jeecgboot-vue3-master/src/views/annualcomp/annualcomp/AnnualComp.api.ts
  2. 171
      jeecgboot-vue3-master/src/views/annualcomp/annualcomp/AnnualComp.data.ts
  3. 206
      jeecgboot-vue3-master/src/views/annualcomp/annualcomp/AnnualCompListZJ.vue
  4. 26
      jeecgboot-vue3-master/src/views/annualcomp/annualcomp/AnnualComp_menu_insert.sql
  5. 70
      jeecgboot-vue3-master/src/views/annualcomp/annualcomp/components/AnnualCompForm.vue
  6. 66
      jeecgboot-vue3-master/src/views/annualcomp/annualcomp/components/AnnualCompModal.vue

@ -0,0 +1,81 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
listZJ = '/annualcomp/annualComp/listZJ',
save='/annualcomp/annualComp/add',
edit='/annualcomp/annualComp/edit',
deleteOne = '/annualcomp/annualComp/delete',
deleteBatch = '/annualcomp/annualComp/deleteBatch',
importExcel = '/annualcomp/annualComp/importExcel',
exportXls = '/annualcomp/annualComp/exportXls',
submit = '/annualcomp/annualComp/submit',
enable = '/annualcomp/annualComp/enable',
deactivate = '/annualcomp/annualComp/deactivate',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const listZJ = (params) => defHttp.get({ url: Api.listZJ, params });
export const submit = (params,handleSuccess) => {
return defHttp.get({url: Api.submit, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
export const enable = (params,handleSuccess) => {
return defHttp.get({url: Api.enable, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
export const deactivate = (params,handleSuccess) => {
return defHttp.get({url: Api.deactivate, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
*/
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,171 @@
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '比赛名称',
align: 'center',
dataIndex: 'compname',
},
{
title: '年度名称',
align: 'center',
dataIndex: 'annualname',
},
{
title: '赛次',
align: 'center',
dataIndex: 'games',
},
{
title: '名称',
align: 'center',
dataIndex: 'name',
},
{
title: '年度比赛状态',
align: 'center',
dataIndex: 'state_dictText',
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
{
label: '比赛名称',
field: 'compid',
component: 'JPopup',
componentProps: ({ formActionType }) => {
const { setFieldsValue } = formActionType;
return {
setFieldsValue: setFieldsValue,
code: 'bsmc',
fieldConfig: [{ source: 'comp_name', target: 'compid' }],
multi: false,
};
},
colProps: { span: 6 },
},
{
label: '年度名称',
field: 'annualid',
component: 'JSearchSelect',
componentProps: {
dict: 'annual,annual_name,id',
},
colProps: { span: 6 },
},
{
label: '名称',
field: 'name',
component: 'Input',
colProps: { span: 6 },
},
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '比赛名称',
field: 'compname',
component: 'JPopup',
componentProps: ({ formActionType }) => {
const { setFieldsValue } = formActionType;
return {
setFieldsValue: setFieldsValue,
code: 'bsmc',
fieldConfig: [{ source: 'comp_name', target: 'compname' }],
multi: false,
};
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入比赛名称!' }];
},
},
{
label: '年度名称',
field: 'annualid',
component: 'JSearchSelect',
componentProps: {
dict: 'annual,annual_name,id',
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入年度名称!' }];
},
},
{
label: '赛次',
field: 'games',
component: 'Input',
},
{
label: '名称',
field: 'name',
component: 'Input',
},
{
label: '年度比赛简介',
field: 'introduction',
component: 'InputTextArea',
},
{
label: '年度比赛介绍',
field: 'introduce',
component: 'JEditor',
},
{
label: '比赛图片',
field: 'image',
component: 'JImageUpload',
componentProps: {},
},
{
label: '年度比赛介绍文件',
field: 'compfile',
component: 'JUpload',
componentProps: {},
},
{
label: '开始时间',
field: 'starttime',
component: 'DatePicker',
},
{
label: '结束时间',
field: 'endtime',
component: 'DatePicker',
},
{
label: '主办方',
field: 'organizer',
component: 'Input',
},
{
label: '协办方',
field: 'coorganizer',
component: 'Input',
},
{
label: '驳回信息',
field: 'backinfo',
component: 'InputTextArea',
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
},
];
/**
* formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
return formSchema;
}

@ -0,0 +1,206 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<!-- <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" 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
>批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" />
</template>
<!--字段回显插槽-->
<template #htmlSlot="{ text }">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<template #pcaSlot="{ text }">
{{ getAreaTextByCode(text) }}
</template>
<template #fileSlot="{ text }">
<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>
</BasicTable>
<!-- 表单区域 -->
<AnnualCompModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="annualcomp-annualComp" setup>
import { ref, computed, unref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import AnnualCompModal from './components/AnnualCompModal.vue';
import { columns, searchFormSchema } from './AnnualComp.data';
import { listZJ, submit, enable, deactivate, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AnnualComp.api';
import { downloadFile } from '/@/utils/common/renderUtils';
const checkedKeys = ref<Array<string | number>>([]);
//model
const [registerModal, { openModal }] = useModal();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '年度比赛管理',
api: listZJ,
columns,
canResize: false,
formConfig: {
//labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
fieldMapToNumber: [],
fieldMapToTime: [],
},
actionColumn: {
width: 120,
fixed: 'right',
},
},
exportConfig: {
name: '年度比赛管理',
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
/**
* 新增事件
*/
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 handleSubmit(record) {
await submit({ id: record.id }, handleSuccess);
}
async function handleEnable(record) {
await enable({ id: record.id }, handleSuccess);
}
async function handleDeactivate(record) {
await deactivate({ id: record.id }, handleSuccess);
}
/**
* 删除事件
*/
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) {
if (record.state_dictText == '待提交' || record.state_dictText == '已驳回') {
return [
{
label: '提交',
onClick: handleSubmit.bind(null, record),
},
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
},
},
];
}
if (record.state_dictText == '已提交') {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
];
} else if (record.state_dictText == '已审核' && record.isopen == '0') {
return [
{
label: '启用',
onClick: handleEnable.bind(null, record),
},
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
];
} else
return [
/* {
label: '停用',
onClick: handleDeactivate.bind(null, record),
},*/
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
];
}
</script>
<style scoped></style>

@ -0,0 +1,26 @@
-- 注意:该页面对应的前台目录为views/annualcomp文件夹下
-- 如果你想更改到其他目录,请修改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 ('2023081809206940540', NULL, '年度比赛管理', '/annualcomp/annualCompList', 'annualcomp/AnnualCompList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2023-08-18 09:20:54', 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 ('2023081809206940541', '2023081809206940540', '添加年度比赛管理', NULL, NULL, 0, NULL, NULL, 2, 'annualcomp:annual_comp:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-08-18 09:20:54', 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 ('2023081809206940542', '2023081809206940540', '编辑年度比赛管理', NULL, NULL, 0, NULL, NULL, 2, 'annualcomp:annual_comp:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-08-18 09:20:54', 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 ('2023081809206940543', '2023081809206940540', '删除年度比赛管理', NULL, NULL, 0, NULL, NULL, 2, 'annualcomp:annual_comp:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-08-18 09:20:54', 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 ('2023081809206940544', '2023081809206940540', '批量删除年度比赛管理', NULL, NULL, 0, NULL, NULL, 2, 'annualcomp:annual_comp:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-08-18 09:20:54', 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 ('2023081809206940545', '2023081809206940540', '导出excel_年度比赛管理', NULL, NULL, 0, NULL, NULL, 2, 'annualcomp:annual_comp:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-08-18 09:20:54', 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 ('2023081809206940546', '2023081809206940540', '导入excel_年度比赛管理', NULL, NULL, 0, NULL, NULL, 2, 'annualcomp:annual_comp:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-08-18 09:20:54', NULL, NULL, 0, 0, '1', 0);

@ -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 '../AnnualComp.data';
import { saveOrUpdate } from '../AnnualComp.api';
export default defineComponent({
name: 'AnnualCompForm',
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 = '/annualcomp/annualComp/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,66 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</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 '../AnnualComp.data';
import { saveOrUpdate } from '../AnnualComp.api';
// Emits
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
//
const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = 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;
if (unref(isUpdate)) {
//
await setFieldsValue({
...data.record,
});
}
//
setProps({ disabled: !data?.showFooter });
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
setModalProps({ confirmLoading: true });
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-calendar-picker) {
width: 100%;
}
</style>
Loading…
Cancel
Save