mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 10:36:31 +08:00
1、修复在线表单初始化表单组件信息错误。
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { getCurrentInstance } from 'vue';
|
||||
import { Delete, Search, Edit, Plus, Refresh, Picture } from '@element-plus/icons-vue';
|
||||
import { EpPropMergeType } from 'element-plus/es/utils';
|
||||
import { useDate } from '@/common/hooks/useDate';
|
||||
import { usePermissions } from '@/common/hooks/usePermission';
|
||||
import { Dialog } from '@/components/Dialog';
|
||||
|
||||
@@ -43,43 +43,24 @@ export const useDate = () => {
|
||||
* @param {String} statsType 转换类型(day, month, year)
|
||||
* @param {String} format 输出格式
|
||||
*/
|
||||
const getDateRangeFilter = (date: string, statsType = 'day', format = 'YYYY-MM-dd HH:mm:ss') => {
|
||||
const getDateRangeFilter = (date: string, statsType = 'day', format = 'YYYY-MM-DD HH:mm:ss') => {
|
||||
if (date == null) return [];
|
||||
|
||||
statsType = allowStatsType.indexOf(statsType) === -1 ? 'day' : statsType;
|
||||
date = date.substring(0, date.indexOf(' '));
|
||||
const tempList = date.split('-');
|
||||
const year = Number.parseInt(tempList[0]);
|
||||
const month = Number.parseInt(tempList[1]);
|
||||
const day = Number.parseInt(tempList[2]);
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
||||
const tempDate = parseDate(date, format);
|
||||
console.log('tempDate', tempDate);
|
||||
if (tempDate && tempDate.isValid()) {
|
||||
switch (statsType) {
|
||||
case 'day':
|
||||
return [tempDate.startOf('d').format(format), tempDate.endOf('d').format(format)];
|
||||
case 'month':
|
||||
return [tempDate.startOf('M').format(format), tempDate.endOf('M').format(format)];
|
||||
case 'year':
|
||||
return [tempDate.startOf('y').format(format), tempDate.endOf('y').format(format)];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
const tempDate = new Date(year, month - 1, day);
|
||||
// 判断是否正确的日期
|
||||
if (isNaN(tempDate.getTime())) return [];
|
||||
|
||||
tempDate.setHours(0, 0, 0, 0);
|
||||
let retDate: Date[] = [];
|
||||
// TODO 如果类型为'time', 'datetime'会出错
|
||||
switch (statsType) {
|
||||
case 'day':
|
||||
retDate = [new Date(tempDate), new Date(tempDate.setDate(tempDate.getDate() + 1))];
|
||||
break;
|
||||
case 'month':
|
||||
tempDate.setDate(1);
|
||||
retDate = [new Date(tempDate), new Date(tempDate.setMonth(tempDate.getMonth() + 1))];
|
||||
break;
|
||||
case 'year':
|
||||
tempDate.setDate(1);
|
||||
tempDate.setMonth(0);
|
||||
retDate = [new Date(tempDate), new Date(tempDate.setFullYear(tempDate.getFullYear() + 1))];
|
||||
break;
|
||||
}
|
||||
|
||||
retDate[1] = new Date(retDate[1].getTime() - 1);
|
||||
|
||||
return [formatDate(retDate[0], format), formatDate(retDate[1], format)];
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="dept-select">
|
||||
<el-select
|
||||
:model-value="value"
|
||||
:model-value="modelValue"
|
||||
style="width: 100%"
|
||||
:multiple="multiple"
|
||||
:disabled="disabled"
|
||||
@@ -32,11 +32,14 @@ import { SysCommonBizController } from '@/api/system';
|
||||
import { Dialog } from '@/components/Dialog';
|
||||
import DeptSelectDlg from './DeptSelectDlg.vue';
|
||||
|
||||
const emit = defineEmits<{ input: [ANY_OBJECT]; change: [ANY_OBJECT] }>();
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [string | number | ANY_OBJECT[]];
|
||||
change: [string | number | ANY_OBJECT[], string | number | ANY_OBJECT[]];
|
||||
}>();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: string | number | Array<ANY_OBJECT>;
|
||||
modelValue: string | number | Array<ANY_OBJECT> | undefined;
|
||||
size?: '' | 'default' | 'small' | 'large';
|
||||
placeholder?: string;
|
||||
props?: ANY_OBJECT;
|
||||
@@ -69,12 +72,11 @@ const refreshData = (data: ANY_OBJECT) => {
|
||||
}
|
||||
};
|
||||
const handlerEditOperate = (items: Ref<ANY_OBJECT>) => {
|
||||
console.log('DeptSelect > handlerEditOperate', items);
|
||||
selectedItems.value = [];
|
||||
if (props.multiple) {
|
||||
if (Array.isArray(items.value)) selectedItems.value = items.value;
|
||||
if (Array.isArray(items)) selectedItems.value = items;
|
||||
} else {
|
||||
if (items.value != null) selectedItems.value.push(items.value);
|
||||
if (items != null) selectedItems.value.push(items);
|
||||
}
|
||||
if (!checkSelectChange()) return;
|
||||
emitChange();
|
||||
@@ -115,7 +117,7 @@ const onClear = () => {
|
||||
emitChange();
|
||||
};
|
||||
const emitChange = () => {
|
||||
let tempValue;
|
||||
let tempValue: string | number | ANY_OBJECT[];
|
||||
if (props.multiple) {
|
||||
tempValue = selectedItems.value.map(item => {
|
||||
return item[props.props.value];
|
||||
@@ -123,19 +125,19 @@ const emitChange = () => {
|
||||
} else {
|
||||
tempValue = (selectedItems.value[0] || {})[props.props.value];
|
||||
}
|
||||
emit('input', tempValue);
|
||||
emit('change', tempValue);
|
||||
emit('update:modelValue', tempValue);
|
||||
emit('change', tempValue, selectedItems.value);
|
||||
};
|
||||
const checkSelectChange = () => {
|
||||
let valueIdString =
|
||||
props.multiple && Array.isArray(props.value)
|
||||
? (props.value || [])
|
||||
props.multiple && Array.isArray(props.modelValue)
|
||||
? (props.modelValue || [])
|
||||
.sort((val1: ANY_OBJECT, val2: ANY_OBJECT) => {
|
||||
if (val1 === val2) return 0;
|
||||
return val1 < val2 ? -1 : 1;
|
||||
})
|
||||
.join(',')
|
||||
: props.value || '';
|
||||
: props.modelValue || '';
|
||||
let selectedItemsString = selectedItems.value
|
||||
.sort((item1, item2) => {
|
||||
if (item1[props.props.value] === item2[props.props.value]) return 0;
|
||||
@@ -149,12 +151,16 @@ const getSelectDeptList = () => {
|
||||
let params: ANY_OBJECT = {
|
||||
widgetType: 'upms_dept',
|
||||
};
|
||||
if (props.value == null || props.value === '' || props.value.length <= 0)
|
||||
if (
|
||||
props.modelValue == null ||
|
||||
props.modelValue === '' ||
|
||||
(props.modelValue as ANY_OBJECT[]).length <= 0
|
||||
)
|
||||
selectedItems.value = [];
|
||||
if (props.multiple) {
|
||||
params.fieldValues = Array.isArray(props.value) ? props.value : [];
|
||||
params.fieldValues = Array.isArray(props.modelValue) ? props.modelValue : [];
|
||||
} else {
|
||||
params.fieldValues = Array.isArray(props.value) ? props.value[0] : props.value;
|
||||
params.fieldValues = Array.isArray(props.modelValue) ? props.modelValue[0] : props.modelValue;
|
||||
params.fieldValues = params.fieldValues == null ? [] : [params.fieldValues];
|
||||
}
|
||||
if (Array.isArray(params.fieldValues) && params.fieldValues.length > 0) {
|
||||
@@ -173,9 +179,9 @@ const getSelectDeptList = () => {
|
||||
}
|
||||
};
|
||||
watch(
|
||||
() => props.value,
|
||||
() => props.modelValue,
|
||||
() => {
|
||||
if (props.value) getSelectDeptList();
|
||||
if (props.modelValue) getSelectDeptList();
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="user-select">
|
||||
<el-select
|
||||
:model-value="value"
|
||||
:model-value="modelValue"
|
||||
style="width: 100%"
|
||||
:multiple="multiple"
|
||||
:disabled="disabled"
|
||||
@@ -32,11 +32,14 @@ import { SysCommonBizController } from '@/api/system';
|
||||
import { Dialog } from '@/components/Dialog';
|
||||
import UserSelectDlg from './UserSelectDlg.vue';
|
||||
|
||||
const emit = defineEmits<{ input: [ANY_OBJECT]; change: [ANY_OBJECT, ANY_OBJECT[]] }>();
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [string | number | ANY_OBJECT[]];
|
||||
change: [string | number | ANY_OBJECT[], string | number | ANY_OBJECT[]];
|
||||
}>();
|
||||
|
||||
const pps = withDefaults(
|
||||
defineProps<{
|
||||
value: string | number;
|
||||
modelValue: string | number | Array<ANY_OBJECT> | undefined;
|
||||
size?: '' | 'default' | 'small' | 'large';
|
||||
placeholder?: string;
|
||||
props?: ANY_OBJECT;
|
||||
@@ -68,13 +71,15 @@ const refreshData = (data: ANY_OBJECT) => {
|
||||
}
|
||||
};
|
||||
const handlerEditOperate = (items: Ref<ANY_OBJECT>) => {
|
||||
console.log('handlerEditOperate', items);
|
||||
selectedItems.value = [];
|
||||
if (pps.multiple) {
|
||||
if (Array.isArray(items.value)) selectedItems.value = items.value;
|
||||
if (Array.isArray(items)) selectedItems.value = items;
|
||||
} else {
|
||||
if (items.value != null) selectedItems.value.push(items.value);
|
||||
if (items != null) selectedItems.value.push(items);
|
||||
}
|
||||
if (!checkSelectChange()) return;
|
||||
console.log('1111', selectedItems.value);
|
||||
emitChange();
|
||||
};
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
@@ -119,7 +124,7 @@ const emitChange = () => {
|
||||
return item;
|
||||
});
|
||||
emit(
|
||||
'input',
|
||||
'update:modelValue',
|
||||
tempValue.map(item => item[pps.props.value]),
|
||||
);
|
||||
emit(
|
||||
@@ -129,19 +134,19 @@ const emitChange = () => {
|
||||
);
|
||||
} else {
|
||||
tempValue = selectedItems.value[0] || {};
|
||||
emit('input', tempValue[pps.props.value]);
|
||||
emit('update:modelValue', tempValue[pps.props.value]);
|
||||
emit('change', tempValue[pps.props.value], selectedItems.value);
|
||||
}
|
||||
};
|
||||
const checkSelectChange = () => {
|
||||
let valueIdString = pps.multiple
|
||||
? (pps.value || [])
|
||||
.sort((val1, val2) => {
|
||||
? ((pps.modelValue || []) as ANY_OBJECT[])
|
||||
.sort((val1: ANY_OBJECT, val2: ANY_OBJECT) => {
|
||||
if (val1 === val2) return 0;
|
||||
return val1 < val2 ? -1 : 1;
|
||||
})
|
||||
.join(',')
|
||||
: pps.value || '';
|
||||
: pps.modelValue || '';
|
||||
let selectedItemsString = selectedItems.value
|
||||
.sort((item1, item2) => {
|
||||
if (item1[pps.props.value] === item2[pps.props.value]) return 0;
|
||||
@@ -155,12 +160,16 @@ const getSelectUserList = () => {
|
||||
let params: ANY_OBJECT = {
|
||||
widgetType: 'upms_user',
|
||||
};
|
||||
if (pps.value == null || pps.value === '' || (Array.isArray(pps.value) && pps.value.length <= 0))
|
||||
if (
|
||||
pps.modelValue == null ||
|
||||
pps.modelValue === '' ||
|
||||
(Array.isArray(pps.modelValue) && pps.modelValue.length <= 0)
|
||||
)
|
||||
selectedItems.value = [];
|
||||
if (pps.multiple) {
|
||||
params.fieldValues = Array.isArray(pps.value) ? pps.value : [];
|
||||
params.fieldValues = Array.isArray(pps.modelValue) ? pps.modelValue : [];
|
||||
} else {
|
||||
params.fieldValues = Array.isArray(pps.value) ? pps.value[0] : pps.value;
|
||||
params.fieldValues = Array.isArray(pps.modelValue) ? pps.modelValue[0] : pps.modelValue;
|
||||
params.fieldValues = params.fieldValues == null ? [] : [params.fieldValues];
|
||||
}
|
||||
if (Array.isArray(params.fieldValues) && params.fieldValues.length > 0) {
|
||||
@@ -179,9 +188,9 @@ const getSelectUserList = () => {
|
||||
}
|
||||
};
|
||||
watch(
|
||||
() => pps.value,
|
||||
() => pps.modelValue,
|
||||
() => {
|
||||
if (pps.value) getSelectUserList();
|
||||
if (pps.modelValue) getSelectUserList();
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { createApp } from 'vue';
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
|
||||
import '@/common/http/request';
|
||||
// eslint-disable-next-line import/named
|
||||
import { debounce } from 'lodash';
|
||||
import { VxeTable, VxeColumn, Edit } from 'vxe-table';
|
||||
import App from '@/App.vue';
|
||||
import { router } from '@/router/index';
|
||||
import pinia from '@/store';
|
||||
import useStaticDictStore from '@/store/staticDict';
|
||||
|
||||
// 表格样式
|
||||
import 'vxe-table/lib/style.css';
|
||||
@@ -31,17 +34,20 @@ import * as olineDicgt from '@/common/staticDict/online';
|
||||
import * as flowDict from '@/common/staticDict/flow';
|
||||
|
||||
import { ANY_OBJECT } from '@/types/generic';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
// vxe-table设置
|
||||
function useTable(app: ANY_OBJECT) {
|
||||
app.use(VxeTable).use(VxeColumn).use(Edit);
|
||||
}
|
||||
// 静态字典设置
|
||||
function useStaticDict(app: ANY_OBJECT, staticDict: ANY_OBJECT) {
|
||||
if (app.config.globalProperties.StaticDict == null) {
|
||||
app.config.globalProperties.StaticDict = {};
|
||||
}
|
||||
Object.keys(staticDict).forEach(key => {
|
||||
app.config.globalProperties[key] = staticDict[key];
|
||||
app.config.globalProperties.StaticDict[key] = staticDict[key];
|
||||
});
|
||||
}
|
||||
|
||||
// webpack需要重写ResizeObserver,否则会报错
|
||||
const resizeObserver = window.ResizeObserver;
|
||||
window.ResizeObserver = class ResizeObserver extends resizeObserver {
|
||||
@@ -60,3 +66,6 @@ useStaticDict(app, olineDicgt);
|
||||
useStaticDict(app, flowDict);
|
||||
app.use(pinia).use(router).use(useTable);
|
||||
app.mount('#app');
|
||||
// 设置静态字典
|
||||
const staticDictStore = useStaticDictStore();
|
||||
staticDictStore.setStaticDict(app.config.globalProperties.StaticDict);
|
||||
|
||||
@@ -150,7 +150,6 @@ const isMobileFilter = computed(() => {
|
||||
);
|
||||
});
|
||||
const getAllDropdownData = computed(() => {
|
||||
console.log('widget getAllDropdownData', pps.widget.props.supportAll, dictDataList);
|
||||
if (pps.widget.props.supportAll) {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -156,7 +156,9 @@ import { downloadBlob, post } from '@/common/http/request';
|
||||
import { useDownload } from '@/common/hooks/useDownload';
|
||||
import { useUpload } from '@/common/hooks/useUpload';
|
||||
import { API_CONTEXT } from '@/api/config';
|
||||
import { useLayoutStore } from '@/store';
|
||||
|
||||
const layoutStore = useLayoutStore();
|
||||
const emit = defineEmits<{
|
||||
viewWorkOrder: [ANY_OBJECT, ANY_OBJECT | null];
|
||||
handlerWorkOrder: [ANY_OBJECT, ANY_OBJECT | null];
|
||||
@@ -194,8 +196,6 @@ const props = withDefaults(defineProps<IProps>(), {
|
||||
operationList: () => [],
|
||||
});
|
||||
|
||||
import { useLayoutStore } from '@/store';
|
||||
const layoutStore = useLayoutStore();
|
||||
const form = inject('form', () => {
|
||||
console.error('OnlineCustomWorkFlowTable: form not injected');
|
||||
return { isEdit: false } as ANY_OBJECT;
|
||||
@@ -210,6 +210,11 @@ const tableColumnList = computed(() => {
|
||||
props.widget && props.widget.props && Array.isArray(props.widget.props.tableColumnList)
|
||||
? props.widget.props.tableColumnList
|
||||
: [];
|
||||
tempList = tempList.map(item => {
|
||||
return {
|
||||
...item,
|
||||
};
|
||||
});
|
||||
tempList.forEach((item: ANY_OBJECT) => {
|
||||
if (item.fieldType === 0 || item.fieldType == null) {
|
||||
// 绑定表字段
|
||||
|
||||
@@ -51,8 +51,8 @@ export const useForm = (props: ANY_OBJECT, formRef: Ref<FormInstance> | null = n
|
||||
});
|
||||
|
||||
const form = computed(() => {
|
||||
const temp: ANY_OBJECT = buildFormConfig(dialogParams.value.formConfig) || {};
|
||||
return temp;
|
||||
buildFormConfig(dialogParams.value.formConfig);
|
||||
return dialogParams.value.formConfig;
|
||||
});
|
||||
|
||||
const loginStore = useLoginStore();
|
||||
|
||||
@@ -245,7 +245,8 @@ export const useFormConfig = () => {
|
||||
};
|
||||
|
||||
const buildFormConfig = (formData: ANY_OBJECT) => {
|
||||
if (formData == null) return;
|
||||
if (formData == null || formData.rawData == null || formData.rawData.onlineTableList == null)
|
||||
return;
|
||||
const formConfig = formData;
|
||||
formConfig.datasourceMap = new Map();
|
||||
formConfig.relationMap = new Map();
|
||||
|
||||
@@ -4,7 +4,9 @@ import useLoginStore from './login';
|
||||
import useLayoutStore from './layout';
|
||||
import useOtherStore from './other';
|
||||
import useMessage from './message';
|
||||
import useStaticDictStore from './staticDict';
|
||||
|
||||
const pinia = createPinia();
|
||||
pinia?.use(piniaPersist);
|
||||
export { useLoginStore, useLayoutStore, useMessage, useOtherStore };
|
||||
export { useLoginStore, useLayoutStore, useMessage, useOtherStore, useStaticDictStore };
|
||||
export default pinia;
|
||||
|
||||
15
OrangeFormsOpen-VUE3/src/store/staticDict.ts
Normal file
15
OrangeFormsOpen-VUE3/src/store/staticDict.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ANY_OBJECT } from '@/types/generic';
|
||||
|
||||
export default defineStore('staticDict', {
|
||||
state: () => {
|
||||
return {
|
||||
staticDict: {} as ANY_OBJECT,
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
setStaticDict(dict: ANY_OBJECT) {
|
||||
this.staticDict = dict;
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user