14 changed files with 894 additions and 105 deletions
@ -0,0 +1,228 @@ |
|||
<!-- |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-22 16:40:53 |
|||
@ 备注: 所属部门 |
|||
--> |
|||
<script lang='ts' setup> |
|||
import { AnalysisCss,AnalysisInputCss } from '@/components/DesignForm/public/form/calculate/cssInfo' |
|||
import { constControlChange,constFormProps } from '@/api/DesignForm/utils' |
|||
import { FormItem, FormList } from '@/api/DesignForm/types' |
|||
import validate from '@/api/DesignForm/validate' |
|||
import { getPeopleKey,getUserCont } from '@/api/hr/people/index' |
|||
|
|||
import { orgAndPeople } from '@/api/displayboardapi/types' |
|||
import { getOrgEveryonePeople } from '@/api/displayboardapi/indexapi' |
|||
|
|||
import { govthree } from '@/api/opk/opk/api' |
|||
import Tooltips from '@/components/DesignForm/tooltip.vue' |
|||
|
|||
const props = withDefaults( |
|||
defineProps<{ |
|||
data: FormList |
|||
tablekey: any |
|||
numrun?: number |
|||
modelValue?: any // 子表和弹性布局时时有传 |
|||
tProp?: string // 子表时的form-item的prop值,用于子表校验用 |
|||
}>(), |
|||
{} |
|||
) |
|||
const orgList = ref<orgAndPeople[]>() |
|||
const formProps = inject(constFormProps, {}) as any |
|||
const config = computed(() => { |
|||
return props.data.config || {} |
|||
}) |
|||
const type = computed(() => { |
|||
return formProps.value.type |
|||
}) |
|||
// 返回当前item项的校验规则 |
|||
const itemRules = computed(() => { |
|||
let temp |
|||
const itemR: any = props.data.item?.rules || [] |
|||
const customR = formatCustomRules() |
|||
// 如果三个都没有设置,则返回undefined |
|||
if (itemR?.length || customR?.length) { |
|||
temp = [...customR, ...itemR] |
|||
} |
|||
return temp |
|||
}) |
|||
// 处理自定义校验规则,将customRules转换后追加到rules里 |
|||
const formatCustomRules = () => { |
|||
const rulesReg: any = {} |
|||
validate && |
|||
validate.forEach(item => { |
|||
rulesReg[item.type] = item.regExp |
|||
}) |
|||
|
|||
// 获取校验方法 父级使用provide方法注入 |
|||
const temp: any = [] |
|||
props.data.customRules?.forEach((item: any) => { |
|||
if (!item.message && item.type !== 'methods') { |
|||
return // 方法时允许提示信息为空 |
|||
} |
|||
let obj = {} |
|||
if (item.type === 'required') { |
|||
obj = { required: true } |
|||
} else if (item.type === 'rules') { |
|||
// 自定义表达式 |
|||
obj = { pattern: item.rules } |
|||
} else if (item.type === 'methods') { |
|||
// 方法时 |
|||
const methods: any = item.methods |
|||
if (methods) { |
|||
obj = { validator: inject(methods, {}) } |
|||
} |
|||
} else if (item.type) { |
|||
obj = { pattern: rulesReg[item.type as string] } |
|||
} |
|||
// 这里判断下防某些条件下重复push的可能或存重复校验类型 |
|||
let message: any = { message: item.message } |
|||
if (!item.message) { |
|||
// 当使用validator校验时,如果存在message字段则不能使用 callback(new Error('x'));的提示 |
|||
message = {} |
|||
} |
|||
temp.push( |
|||
Object.assign( |
|||
{ |
|||
trigger: item.trigger || 'blur' |
|||
}, |
|||
obj, |
|||
message |
|||
) |
|||
) |
|||
}) |
|||
return temp |
|||
} |
|||
const getLabel = (ele: FormItem) => { |
|||
const showColon = formProps.value.showColon ? ':' : '' |
|||
if (ele) { |
|||
return ele.showLabel ? '' : ele.label + showColon |
|||
} else { |
|||
return '' |
|||
} |
|||
} |
|||
//组件css部分 |
|||
const configStyle = computed(() => { |
|||
return props.data.styles || {} |
|||
}) |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-03-01 09:07:11 |
|||
@ 功能: 布局处理 |
|||
*/ |
|||
const getFormItemLableStyle = (ele: any) => { |
|||
if(ele?.labelStyle){ |
|||
// console.log("返回栅格宽度3",AnalysisCss(ele?.labelStyle)) |
|||
return AnalysisCss(ele?.labelStyle) |
|||
} |
|||
} |
|||
const getFormItemInputStyle = (ele: any,sty:number) => { |
|||
if(ele?.inputStyle){ |
|||
// console.log("返回栅格宽度4",AnalysisInputCss(ele?.inputStyle,sty)) |
|||
return AnalysisInputCss(ele?.inputStyle,sty) |
|||
} |
|||
} |
|||
|
|||
const value = computed({ |
|||
get() { |
|||
if (props.tProp) { |
|||
// 表格和弹性布局 |
|||
return props.modelValue*1 |
|||
} else { |
|||
return formProps.value.model[props.data.name]*1 |
|||
} |
|||
// return 107 |
|||
}, |
|||
set(newVal: any) { |
|||
if (props.tProp) { |
|||
emits('update:modelValue', newVal) |
|||
} |
|||
updateModel(newVal) |
|||
} |
|||
}) |
|||
const changeEvent = inject(constControlChange, '') as any |
|||
const updateModel = (val: any) => { |
|||
let controlAttribute = "" |
|||
if(props.data.control){ |
|||
if(props.data.control.type){ |
|||
controlAttribute = props.data.control.type |
|||
} |
|||
} |
|||
changeEvent && |
|||
changeEvent({ |
|||
key: props.data.name, |
|||
value: val, |
|||
data: props.data, |
|||
tProp: props.tProp, |
|||
type: props.data.type, |
|||
attribute: controlAttribute |
|||
}) |
|||
} |
|||
const orgTree ={ |
|||
label: 'name', |
|||
children:'child', |
|||
} |
|||
const orgLoading = ref(false) |
|||
onMounted(()=>{ |
|||
orgLoading.value = true |
|||
getUserCont() |
|||
.then((data:any)=>{ |
|||
console.log("获取中午",data) |
|||
let orgId = data.data.organization*1 |
|||
let companyId = data.data.company*1 |
|||
if(companyId == null || orgId == ""){ |
|||
companyId = 309 |
|||
} |
|||
nextTick(()=>{ |
|||
govthree({id:companyId,all:1}) |
|||
.then(({data})=>{ |
|||
console.log("获取行政组织",data,value.value) |
|||
orgList.value = data |
|||
if(value.value == null || value.value == "" || value.value == undefined){ |
|||
nextTick(()=>{ |
|||
value.value = orgId |
|||
}) |
|||
} |
|||
|
|||
}) |
|||
.finally(()=>{ |
|||
orgLoading.value = false |
|||
}) |
|||
}) |
|||
}) |
|||
}) |
|||
</script> |
|||
<template> |
|||
<el-form-item |
|||
v-bind="data.item" |
|||
:prop="tProp || data.name" |
|||
:class="config.className" |
|||
:label="getLabel(data.item as FormItem)" |
|||
:rules="itemRules as any" |
|||
> |
|||
<template v-if="config.help" #label > |
|||
<span :style="getFormItemLableStyle(configStyle)">{{ getLabel(data.item) }}</span> |
|||
<Tooltips :content="config.help" /> |
|||
</template> |
|||
<template #label v-else> |
|||
<span :style="getFormItemLableStyle(configStyle)" >{{ getLabel(data.item) }}</span> |
|||
</template> |
|||
<div> |
|||
<el-tree-select |
|||
v-loading="orgLoading" |
|||
element-loading-text="Loading..." |
|||
v-model="value" |
|||
:data="orgList" |
|||
:props="orgTree" |
|||
:render-after-expand="false" |
|||
:filterable="true" |
|||
node-key="id" |
|||
clearable |
|||
check-strictly |
|||
style="width: 240px" |
|||
/> |
|||
</div> |
|||
</el-form-item> |
|||
</template> |
|||
<style lang='scss' scoped> |
|||
|
|||
</style> |
|||
@ -0,0 +1,205 @@ |
|||
<!-- |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-22 15:35:14 |
|||
@ 备注: 编辑时间组件 |
|||
--> |
|||
<script lang='ts' setup> |
|||
import { AnalysisCss,AnalysisInputCss } from '@/components/DesignForm/public/form/calculate/cssInfo' |
|||
import { constControlChange,constFormProps } from '@/api/DesignForm/utils' |
|||
import { FormItem, FormList } from '@/api/DesignForm/types' |
|||
import validate from '@/api/DesignForm/validate' |
|||
import { getPeopleKey,getUserCont } from '@/api/hr/people/index' |
|||
|
|||
import Tooltips from '@/components/DesignForm/tooltip.vue' |
|||
|
|||
const props = withDefaults( |
|||
defineProps<{ |
|||
data: FormList |
|||
tablekey: any |
|||
numrun?: number |
|||
modelValue?: any // 子表和弹性布局时时有传 |
|||
tProp?: string // 子表时的form-item的prop值,用于子表校验用 |
|||
}>(), |
|||
{} |
|||
) |
|||
const changeEvent = inject(constControlChange, '') as any |
|||
const formProps = inject(constFormProps, {}) as any |
|||
const config = computed(() => { |
|||
return props.data.config || {} |
|||
}) |
|||
const type = computed(() => { |
|||
return formProps.value.type |
|||
}) |
|||
// 返回当前item项的校验规则 |
|||
const itemRules = computed(() => { |
|||
let temp |
|||
const itemR: any = props.data.item?.rules || [] |
|||
const customR = formatCustomRules() |
|||
// 如果三个都没有设置,则返回undefined |
|||
if (itemR?.length || customR?.length) { |
|||
temp = [...customR, ...itemR] |
|||
} |
|||
return temp |
|||
}) |
|||
// 处理自定义校验规则,将customRules转换后追加到rules里 |
|||
const formatCustomRules = () => { |
|||
const rulesReg: any = {} |
|||
validate && |
|||
validate.forEach(item => { |
|||
rulesReg[item.type] = item.regExp |
|||
}) |
|||
|
|||
// 获取校验方法 父级使用provide方法注入 |
|||
const temp: any = [] |
|||
props.data.customRules?.forEach((item: any) => { |
|||
if (!item.message && item.type !== 'methods') { |
|||
return // 方法时允许提示信息为空 |
|||
} |
|||
let obj = {} |
|||
if (item.type === 'required') { |
|||
obj = { required: true } |
|||
} else if (item.type === 'rules') { |
|||
// 自定义表达式 |
|||
obj = { pattern: item.rules } |
|||
} else if (item.type === 'methods') { |
|||
// 方法时 |
|||
const methods: any = item.methods |
|||
if (methods) { |
|||
obj = { validator: inject(methods, {}) } |
|||
} |
|||
} else if (item.type) { |
|||
obj = { pattern: rulesReg[item.type as string] } |
|||
} |
|||
// 这里判断下防某些条件下重复push的可能或存重复校验类型 |
|||
let message: any = { message: item.message } |
|||
if (!item.message) { |
|||
// 当使用validator校验时,如果存在message字段则不能使用 callback(new Error('x'));的提示 |
|||
message = {} |
|||
} |
|||
temp.push( |
|||
Object.assign( |
|||
{ |
|||
trigger: item.trigger || 'blur' |
|||
}, |
|||
obj, |
|||
message |
|||
) |
|||
) |
|||
}) |
|||
return temp |
|||
} |
|||
const getLabel = (ele: FormItem) => { |
|||
const showColon = formProps.value.showColon ? ':' : '' |
|||
if (ele) { |
|||
return ele.showLabel ? '' : ele.label + showColon |
|||
} else { |
|||
return '' |
|||
} |
|||
} |
|||
//组件css部分 |
|||
const configStyle = computed(() => { |
|||
return props.data.styles || {} |
|||
}) |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-03-01 09:07:11 |
|||
@ 功能: 布局处理 |
|||
*/ |
|||
const getFormItemLableStyle = (ele: any) => { |
|||
if(ele?.labelStyle){ |
|||
// console.log("返回栅格宽度3",AnalysisCss(ele?.labelStyle)) |
|||
return AnalysisCss(ele?.labelStyle) |
|||
} |
|||
} |
|||
const getFormItemInputStyle = (ele: any,sty:number) => { |
|||
if(ele?.inputStyle){ |
|||
// console.log("返回栅格宽度4",AnalysisInputCss(ele?.inputStyle,sty)) |
|||
return AnalysisInputCss(ele?.inputStyle,sty) |
|||
} |
|||
} |
|||
|
|||
const value = computed({ |
|||
get() { |
|||
if (props.tProp) { |
|||
// 表格和弹性布局 |
|||
let zhiVal = props.modelValue |
|||
if(zhiVal != null && zhiVal != "") { |
|||
zhiVal=zhiVal*1 |
|||
} |
|||
return zhiVal |
|||
} else { |
|||
let zhiVal = formProps.value.model[props.data.name] |
|||
if(zhiVal != null && zhiVal != "") { |
|||
zhiVal=zhiVal*1 |
|||
} |
|||
return unixTimeToDayTime(zhiVal) |
|||
} |
|||
}, |
|||
set(newVal: any) { |
|||
if(newVal != null && newVal != "") { |
|||
newVal=newVal*1 |
|||
} |
|||
if (props.tProp) { |
|||
|
|||
emits('update:modelValue', newVal) |
|||
} |
|||
updateModel(newVal*1) |
|||
} |
|||
}) |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-24 11:13:44 |
|||
@ 功能: 时间戳转日期 |
|||
*/ |
|||
const unixTimeToDayTime = (val:string) => { |
|||
let date = new Date(val * 1000); |
|||
let Y = date.getFullYear() + "-"; |
|||
let M =(date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-"; |
|||
let D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "; |
|||
let h = date.getHours() + ":"; |
|||
let m = date.getMinutes() + ":"; |
|||
let s = date.getSeconds(); |
|||
return Y + M + D + h + m + s; |
|||
} |
|||
const updateModel = (val: any) => { |
|||
let controlAttribute = "" |
|||
if(props.data.control){ |
|||
if(props.data.control.type){ |
|||
controlAttribute = props.data.control.type |
|||
} |
|||
} |
|||
changeEvent && |
|||
changeEvent({ |
|||
key: props.data.name, |
|||
value: val, |
|||
data: props.data, |
|||
tProp: props.tProp, |
|||
type: props.data.type, |
|||
attribute: controlAttribute |
|||
}) |
|||
} |
|||
</script> |
|||
<template> |
|||
<el-form-item |
|||
v-bind="data.item" |
|||
:prop="tProp || data.name" |
|||
:class="config.className" |
|||
:label="getLabel(data.item as FormItem)" |
|||
:rules="itemRules as any" |
|||
> |
|||
<template v-if="config.help" #label > |
|||
<span :style="getFormItemLableStyle(configStyle)">{{ getLabel(data.item) }}</span> |
|||
<Tooltips :content="config.help" /> |
|||
</template> |
|||
<template #label v-else> |
|||
<span :style="getFormItemLableStyle(configStyle)" >{{ getLabel(data.item) }}</span> |
|||
</template> |
|||
<div v-if="type === 4" class="form-value" v-html="value"></div> |
|||
<template v-else> |
|||
<el-input v-model="value" :style="getFormItemInputStyle(configStyle,2)" :input-style="getFormItemInputStyle(configStyle,3)" placeholder="系统自动生成" disabled></el-input> |
|||
</template> |
|||
</el-form-item> |
|||
</template> |
|||
<style lang='scss' scoped> |
|||
|
|||
</style> |
|||
@ -0,0 +1,238 @@ |
|||
<!-- |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-06-22 16:30:39 |
|||
@ 备注: 拥有者组件 |
|||
--> |
|||
<script lang='ts' setup> |
|||
import { AnalysisCss,AnalysisInputCss } from '@/components/DesignForm/public/form/calculate/cssInfo' |
|||
import { constControlChange,constFormProps } from '@/api/DesignForm/utils' |
|||
import { FormItem, FormList } from '@/api/DesignForm/types' |
|||
import validate from '@/api/DesignForm/validate' |
|||
import { getPeopleKey,getUserCont } from '@/api/hr/people/index' |
|||
|
|||
import { orgAndPeople } from '@/api/displayboardapi/types' |
|||
import { getOrgEveryonePeople } from '@/api/displayboardapi/indexapi' |
|||
|
|||
import Tooltips from '@/components/DesignForm/tooltip.vue' |
|||
|
|||
const props = withDefaults( |
|||
defineProps<{ |
|||
data: FormList |
|||
tablekey: any |
|||
numrun?: number |
|||
modelValue?: any // 子表和弹性布局时时有传 |
|||
tProp?: string // 子表时的form-item的prop值,用于子表校验用 |
|||
}>(), |
|||
{} |
|||
) |
|||
const orgPeople = ref<orgAndPeople[]>() |
|||
const formProps = inject(constFormProps, {}) as any |
|||
const config = computed(() => { |
|||
return props.data.config || {} |
|||
}) |
|||
const type = computed(() => { |
|||
return formProps.value.type |
|||
}) |
|||
// 返回当前item项的校验规则 |
|||
const itemRules = computed(() => { |
|||
let temp |
|||
const itemR: any = props.data.item?.rules || [] |
|||
const customR = formatCustomRules() |
|||
// 如果三个都没有设置,则返回undefined |
|||
if (itemR?.length || customR?.length) { |
|||
temp = [...customR, ...itemR] |
|||
} |
|||
return temp |
|||
}) |
|||
// 处理自定义校验规则,将customRules转换后追加到rules里 |
|||
const formatCustomRules = () => { |
|||
const rulesReg: any = {} |
|||
validate && |
|||
validate.forEach(item => { |
|||
rulesReg[item.type] = item.regExp |
|||
}) |
|||
|
|||
// 获取校验方法 父级使用provide方法注入 |
|||
const temp: any = [] |
|||
props.data.customRules?.forEach((item: any) => { |
|||
if (!item.message && item.type !== 'methods') { |
|||
return // 方法时允许提示信息为空 |
|||
} |
|||
let obj = {} |
|||
if (item.type === 'required') { |
|||
obj = { required: true } |
|||
} else if (item.type === 'rules') { |
|||
// 自定义表达式 |
|||
obj = { pattern: item.rules } |
|||
} else if (item.type === 'methods') { |
|||
// 方法时 |
|||
const methods: any = item.methods |
|||
if (methods) { |
|||
obj = { validator: inject(methods, {}) } |
|||
} |
|||
} else if (item.type) { |
|||
obj = { pattern: rulesReg[item.type as string] } |
|||
} |
|||
// 这里判断下防某些条件下重复push的可能或存重复校验类型 |
|||
let message: any = { message: item.message } |
|||
if (!item.message) { |
|||
// 当使用validator校验时,如果存在message字段则不能使用 callback(new Error('x'));的提示 |
|||
message = {} |
|||
} |
|||
temp.push( |
|||
Object.assign( |
|||
{ |
|||
trigger: item.trigger || 'blur' |
|||
}, |
|||
obj, |
|||
message |
|||
) |
|||
) |
|||
}) |
|||
return temp |
|||
} |
|||
const getLabel = (ele: FormItem) => { |
|||
const showColon = formProps.value.showColon ? ':' : '' |
|||
if (ele) { |
|||
return ele.showLabel ? '' : ele.label + showColon |
|||
} else { |
|||
return '' |
|||
} |
|||
} |
|||
//组件css部分 |
|||
const configStyle = computed(() => { |
|||
return props.data.styles || {} |
|||
}) |
|||
/** |
|||
@ 作者: 秦东 |
|||
@ 时间: 2024-03-01 09:07:11 |
|||
@ 功能: 布局处理 |
|||
*/ |
|||
const getFormItemLableStyle = (ele: any) => { |
|||
if(ele?.labelStyle){ |
|||
// console.log("返回栅格宽度3",AnalysisCss(ele?.labelStyle)) |
|||
return AnalysisCss(ele?.labelStyle) |
|||
} |
|||
} |
|||
const getFormItemInputStyle = (ele: any,sty:number) => { |
|||
if(ele?.inputStyle){ |
|||
// console.log("返回栅格宽度4",AnalysisInputCss(ele?.inputStyle,sty)) |
|||
return AnalysisInputCss(ele?.inputStyle,sty) |
|||
} |
|||
} |
|||
|
|||
const value = computed({ |
|||
get() { |
|||
if (props.tProp) { |
|||
// 表格和弹性布局 |
|||
return props.modelValue |
|||
} else { |
|||
return formProps.value.model[props.data.name] |
|||
} |
|||
}, |
|||
set(newVal: any) { |
|||
if (props.tProp) { |
|||
emits('update:modelValue', newVal) |
|||
} |
|||
updateModel(newVal) |
|||
} |
|||
}) |
|||
const changeEvent = inject(constControlChange, '') as any |
|||
const updateModel = (val: any) => { |
|||
let controlAttribute = "" |
|||
if(props.data.control){ |
|||
if(props.data.control.type){ |
|||
controlAttribute = props.data.control.type |
|||
} |
|||
} |
|||
changeEvent && |
|||
changeEvent({ |
|||
key: props.data.name, |
|||
value: val, |
|||
data: props.data, |
|||
tProp: props.tProp, |
|||
type: props.data.type, |
|||
attribute: controlAttribute |
|||
}) |
|||
} |
|||
const peopleLoading = ref(false) |
|||
onMounted(()=>{ |
|||
peopleLoading.value = true |
|||
getUserCont() |
|||
.then((data:any)=>{ |
|||
let orgId = data.data.company |
|||
let userId = data.data.userId |
|||
if(orgId == null || orgId == ""){ |
|||
orgId = "309" |
|||
} |
|||
nextTick(()=>{ |
|||
getOrgEveryonePeople({"id":orgId.toString()}) |
|||
.then(({data})=>{ |
|||
orgPeople.value = data |
|||
if(value.value == null || value.value == "" || value.value == undefined){ |
|||
nextTick(()=>{ |
|||
value.value = userId |
|||
}) |
|||
} |
|||
}) |
|||
.finally(()=>{ |
|||
peopleLoading.value = false |
|||
}) |
|||
}); |
|||
}) |
|||
|
|||
|
|||
// getOrgEveryonePeople({"id":"309"}) |
|||
// .then(({data})=>{ |
|||
|
|||
// console.log("拥有者组件---->",data); |
|||
// orgPeople.value = data |
|||
// console.log("拥有者组件-1123123--->",orgPeople.value); |
|||
// nextTick(()=>{ |
|||
// getUserCont() |
|||
// .then((data:any)=>{ |
|||
// console.log("获取人员信息",data) |
|||
// value.value = data.data.userId |
|||
// }) |
|||
// }) |
|||
// }) |
|||
}); |
|||
const orgTreeProps ={ |
|||
label: 'name', |
|||
children:'child', |
|||
} |
|||
</script> |
|||
<template> |
|||
<el-form-item |
|||
v-bind="data.item" |
|||
:prop="tProp || data.name" |
|||
:class="config.className" |
|||
:label="getLabel(data.item as FormItem)" |
|||
:rules="itemRules as any" |
|||
> |
|||
<template v-if="config.help" #label > |
|||
<span :style="getFormItemLableStyle(configStyle)">{{ getLabel(data.item) }}</span> |
|||
<Tooltips :content="config.help" /> |
|||
</template> |
|||
<template #label v-else> |
|||
<span :style="getFormItemLableStyle(configStyle)" >{{ getLabel(data.item) }}</span> |
|||
</template> |
|||
<div> |
|||
<el-tree-select |
|||
v-loading="peopleLoading" |
|||
element-loading-text="Loading..." |
|||
v-model="value" |
|||
:data="orgPeople" |
|||
:props="orgTreeProps" |
|||
:render-after-expand="false" |
|||
:filterable="true" |
|||
node-key="id" |
|||
clearable |
|||
style="width: 240px" |
|||
/> |
|||
</div> |
|||
</el-form-item> |
|||
</template> |
|||
<style lang='scss' scoped> |
|||
|
|||
</style> |
|||
Loading…
Reference in new issue