diff --git a/src/api/baseData/unit/unitApi.js b/src/api/baseData/unit/unitApi.js
new file mode 100644
index 0000000..9275952
--- /dev/null
+++ b/src/api/baseData/unit/unitApi.js
@@ -0,0 +1,28 @@
+import { baseRequest } from '@/utils/request'
+
+const request = (url, ...arg) => baseRequest(`/base/sysunit/` + url, ...arg)
+
+/**
+ * 单位Api接口管理器
+ *
+ * @author Luck
+ * @date 2024/07/23 11:36
+ **/
+export default {
+ // 获取单位分页
+ sysUnitPage(data) {
+ return request('page', data, 'get')
+ },
+ // 提交单位表单 edit为true时为编辑,默认为新增
+ sysUnitSubmitForm(data, edit = false) {
+ return request(edit ? 'edit' : 'add', data)
+ },
+ // 删除单位
+ sysUnitDelete(data) {
+ return request('delete', data)
+ },
+ // 获取单位详情
+ sysUnitDetail(data) {
+ return request('detail', data, 'get')
+ }
+}
diff --git a/src/components/DrawerForm/index.vue b/src/components/DrawerForm/index.vue
new file mode 100644
index 0000000..6dc7cb6
--- /dev/null
+++ b/src/components/DrawerForm/index.vue
@@ -0,0 +1,49 @@
+
+
+
+
+ 关闭
+ 保存
+
+
+
+
+
+
+
diff --git a/src/components/DynamicForm/index.vue b/src/components/DynamicForm/index.vue
new file mode 100644
index 0000000..974350a
--- /dev/null
+++ b/src/components/DynamicForm/index.vue
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/SearchForm/index.vue b/src/components/SearchForm/index.vue
new file mode 100644
index 0000000..a047c8a
--- /dev/null
+++ b/src/components/SearchForm/index.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+ 查询
+ 重置
+
+ {{ advanced ? '收起' : '展开' }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/Table/index.vue b/src/components/Table/index.vue
index aa481fb..522ebc0 100644
--- a/src/components/Table/index.vue
+++ b/src/components/Table/index.vue
@@ -11,6 +11,45 @@
斑马纹
+
+ {
+ emit('plusRowData')
+ }
+ "
+ >
+
+
+
+ {
+ emit('editRowData')
+ }
+ "
+ >
+
+
+
+ {
+ emit('deleteRowData')
+ }
+ "
+ >
+
+
({
+ plus: false,
+ edit: false,
+ delete: false,
refresh: false,
height: false,
columnSetting: false,
@@ -245,6 +287,21 @@
const renderTableProps = ref([])
// 右上角工具数组
const tool = [
+ {
+ name: 'plus',
+ icon: 'plus-outlined',
+ title: '新增'
+ },
+ {
+ name: 'edit',
+ icon: 'edit-outlined',
+ title: '编辑'
+ },
+ {
+ name: 'delete',
+ icon: 'delete-outlined',
+ title: '删除'
+ },
{
name: 'refresh',
icon: 'sync-outlined',
@@ -365,62 +422,71 @@
}
)
// 用请求数据请求该列表的返回数据
- const result = props.data(parameter)
- if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
- result.then((r) => {
- if (r == null) {
- data.localLoading = false
- return
- }
- // 获取分页数据及分页的显示内容
- data.localPagination =
- (props.showPagination &&
- Object.assign({}, data.localPagination, {
- current: r.current, // pageNo, // 返回结果中的当前分页数
- total: r.total, // totalRows, // 返回结果中的总记录数
- showSizeChanger: props.showSizeChanger,
- pageSizeOptions: props.pageSizeOptions,
- showTotal: (total, range) => {
- return `${range[0]}-${range[1]} 共 ${total} 条 `
- },
- pageSize: (pagination && pagination.pageSize) || data.localPagination.pageSize
- })) ||
- false
- // 后端数据records为null保存修复
- if (r.records == null) {
- r.records = []
- }
- // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
- if (r.records.length === 0 && props.showPagination && data.localPagination.current > 1) {
- data.localPagination.current--
- loadData()
- return
- }
- try {
- // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
- // 没有数据或只有一页数据时隐藏分页栏
- // if ((['auto', true].includes(props.showPagination) && r.total <= (r.pages * data.localPagination.pageSize))) {
- // data.localPagination.hideOnSinglePage = true
- // }
- if (!props.showPagination) {
- data.localPagination.hideOnSinglePage = true
- }
- } catch (e) {
- data.localPagination = false
- }
+ console.log(typeof props.data, 'typeof props.data')
+ if (typeof props.data !== 'function') {
+ data.localLoading = false
+ data.localDataSource = props.data
- // 返回结果中的数组数据
- if (props.showPagination === false) {
- data.localDataSource = r instanceof Array ? r : r.records
- } else {
- data.localDataSource = r.records
- }
- getTableProps()
- })
- .catch(() => {})
- .finally(() => {
- data.localLoading = false
- })
+ getTableProps()
+ } else {
+ const result = props.data(parameter)
+ if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
+ result
+ .then((r) => {
+ if (r == null) {
+ data.localLoading = false
+ return
+ }
+ // 获取分页数据及分页的显示内容
+ data.localPagination =
+ (props.showPagination &&
+ Object.assign({}, data.localPagination, {
+ current: r.current, // pageNo, // 返回结果中的当前分页数
+ total: r.total, // totalRows, // 返回结果中的总记录数
+ showSizeChanger: props.showSizeChanger,
+ pageSizeOptions: props.pageSizeOptions,
+ showTotal: (total, range) => {
+ return `${range[0]}-${range[1]} 共 ${total} 条 `
+ },
+ pageSize: (pagination && pagination.pageSize) || data.localPagination.pageSize
+ })) ||
+ false
+ // 后端数据records为null保存修复
+ if (r.records == null) {
+ r.records = []
+ }
+ // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
+ if (r.records.length === 0 && props.showPagination && data.localPagination.current > 1) {
+ data.localPagination.current--
+ loadData()
+ return
+ }
+ try {
+ // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
+ // 没有数据或只有一页数据时隐藏分页栏
+ // if ((['auto', true].includes(props.showPagination) && r.total <= (r.pages * data.localPagination.pageSize))) {
+ // data.localPagination.hideOnSinglePage = true
+ // }
+ if (!props.showPagination) {
+ data.localPagination.hideOnSinglePage = true
+ }
+ } catch (e) {
+ data.localPagination = false
+ }
+
+ // 返回结果中的数组数据
+ if (props.showPagination === false) {
+ data.localDataSource = r instanceof Array ? r : r.records
+ } else {
+ data.localDataSource = r.records
+ }
+ getTableProps()
+ })
+ .catch(() => {})
+ .finally(() => {
+ data.localLoading = false
+ })
+ }
}
}
@@ -502,7 +568,8 @@
...renderProps,
size: data.customSize, // 注意这个size是a-table组件需要的,这里不能跟别的地方成为compSize
columns: data.columnsSetting.filter((value) => value.checked === undefined || value.checked),
- ...data.localSettings
+ ...data.localSettings,
+ scroll: {x: 100, y: 1000}
}
// 将值为 undefined 或者 null 的 table里props属性进行一个过滤
renderTableProps.value = Object.entries(renderProps).reduce((x, [y, z]) => (z == null ? x : ((x[y] = z), x)), {})
@@ -571,7 +638,20 @@
})
onMounted(() => {
init()
+
+ window.addEventListener('resize', () => {
+ console.log('屏幕发生变换')
+ })
})
+
+
+
+ onBeforeUnmount(() => {
+ window.removeEventListener('resize', () => {
+ console.log('屏幕发生变换')
+
+ });
+ });
diff --git a/src/views/basicData/unit/formData/SearchForm.js b/src/views/basicData/unit/formData/SearchForm.js
new file mode 100644
index 0000000..fc11a9e
--- /dev/null
+++ b/src/views/basicData/unit/formData/SearchForm.js
@@ -0,0 +1,26 @@
+export const SearchFields = [
+ { label: '名称', name: 'name', type: 'input', placeholder: '请输入名称' },
+ {
+ label: '状态',
+ name: 'state',
+ type: 'select',
+ placeholder: '请选择状态',
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Inactive', value: 'inactive' }
+ ]
+ },
+ { label: '编码', name: 'number', type: 'input', placeholder: '请输入编码' },
+ {
+ label: '是否基本单位',
+ name: 'isBase',
+ type: 'select',
+ placeholder: '请选择是否基本单位',
+ options: [
+ { label: '是', value: true },
+ { label: '否', value: false }
+ ],
+ advanced: true
+ },
+ { label: '单位组id', name: 'unitGroupId', type: 'input', placeholder: '请输入单位组id', advanced: true }
+]
diff --git a/src/views/basicData/unit/index.vue b/src/views/basicData/unit/index.vue
new file mode 100644
index 0000000..e2b8eaa
--- /dev/null
+++ b/src/views/basicData/unit/index.vue
@@ -0,0 +1,202 @@
+
+
+
+
+
+
+
+
+
+ 单位组
+
+
+
+
+
+
+
+
+
+
+ 新增
+
+
+
+
+
+
+ {{ $TOOL.dictTypeData('COMMON_STATUS', record.state) }}
+
+
+ {{ $TOOL.dictTypeData('YES_NO', record.isBase) }}
+
+
+
+ 编辑
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+