Browse Source

完成表固定字段相关组件

人员选择与行政组织选择

单选、多选、下拉框默认值问题
lwx_v12
超级管理员 1 year ago
parent
commit
41cfb96668
  1. 2
      src/components/DesignForm/app/index.vue
  2. 12
      src/components/DesignForm/assembly/index.ts
  3. 2
      src/components/DesignForm/designLayout/bianXian.vue
  4. 2
      src/components/DesignForm/designLayout/unitBackGround.vue
  5. 24
      src/components/DesignForm/formControlAttr.vue
  6. 93
      src/components/DesignForm/formControlPropertiNew.vue
  7. 110
      src/components/DesignForm/formControlProperties.vue
  8. 53
      src/components/DesignForm/public/form/formGroup.vue
  9. 2
      src/components/DesignForm/tableListPage/index.vue
  10. 7
      src/widget/index.ts
  11. 228
      src/widget/systemunit/deptOrgPage.vue
  12. 205
      src/widget/systemunit/editTime.vue
  13. 17
      src/widget/systemunit/founderTime.vue
  14. 238
      src/widget/systemunit/ownerPage.vue

2
src/components/DesignForm/app/index.vue

@ -584,7 +584,7 @@ const editFormSendFlow = (val:any) => {
<tooltip :content="item.help" />
</template>
</el-table-column>
<el-table-column v-else-if="item.fieldClass=='__control'" :prop="item.field" :label="item.label" config="" width="160">
<el-table-column v-else-if="item.fieldClass=='__control'" :prop="item.field" :label="item.label" config="" width="200" align="center" fixed="right" >
<template #default="scope">
<el-button-group>

12
src/components/DesignForm/assembly/index.ts

@ -1,14 +1,14 @@
import { v4 as uuidv4 } from "uuid";
const selectOption: any = [
/*{
label: '标签1',
value: 'value1'
},
{
label: '标签2',
value: 'value2'
label: '选项1',
value: '1'
},
{
label: '选项2',
value: '2'
},
/*{
label: '标签3',
value: 'value3'
}*/

2
src/components/DesignForm/designLayout/bianXian.vue

@ -117,7 +117,7 @@ const contourProfile = (val:number) => {
@ 功能: 监听颜色
*/
watch(()=>props.dataVal.lineColorVal,(val : any)=>{
console.log("监听颜色-----1--->",val)
// console.log("-----1--->",val)
if(val == null || val.length == 0 || val == ""){
delete props.dataVal.lineColorVal;
}

2
src/components/DesignForm/designLayout/unitBackGround.vue

@ -19,7 +19,7 @@ const props = defineProps({
@ 功能: 监听颜色
*/
watch(()=>props.layouytStyle.backgroundColor,(val : any)=>{
console.log("监听颜色-----1--->",val)
// console.log("-----1--->",val)
if(val == null || val.length == 0 || val == ""){
delete props.layouytStyle.backgroundColor;
}

24
src/components/DesignForm/formControlAttr.vue

@ -1201,9 +1201,12 @@
}
//
const addSelectOption = (type: any) => {
console.log("选择项添加",controlData.value.type)
if (controlData.value.type === 'cascader') {
//
openAttrDialog('cascader')
openAttrDialog('cascader',"级联选择器")
} else if (controlData.value.type === 'treeSelect') {
openAttrDialog('treeSelect', '编辑组件下拉选项数据')
} else {
@ -1213,9 +1216,19 @@
list: []
})
} else {
console.log("选择项添加--->controlData.value.options-->",controlData.value.options)
let maxVal = 1;
if(controlData.value.options && controlData.value.options.length > 0){
controlData.value.options.forEach((item:any)=>{
if(item.value >= maxVal){
maxVal = item.value
}
})
maxVal = maxVal*1 + 1
}
controlData.value.options.push({
label: '',
value: ''
label: '',
value: maxVal.toString()
})
}
}
@ -3154,13 +3167,14 @@ const disabledIstrue = (val:string) => {
v-for="(item, index) in controlData.options"
:key="index"
class="form_cont"
label="选项标签"
>
<el-col :span="10">
<el-input v-model="item.label" placeholder="选项标签" />
</el-col>
<el-col :span="10" :offset="1">
<!-- <el-col :span="10" :offset="1">
<el-input v-model="item.value" placeholder="选项值" />
</el-col>
</el-col> -->
<el-col :span="2" :offset="1">
<i
class="icon-del"

93
src/components/DesignForm/formControlPropertiNew.vue

@ -1055,41 +1055,44 @@ const controlChange = (obj: any, val: any) => {
break
case 'labelNameVal':
if(val != ""){
if(!props.formField.includes(controlData.value.name)){
chineseToPinyin({title:val,types:8,connector:"",formJson:JSON.stringify(props.formInfo)})
.then((data:any)=>{
if(data.code == 0){
if(data.data != ""){
if(!fileSignAry.includes(data.data)){
controlData.value.name = data.data
fileSignAry.push(data.data)
let ary = ["founder","founderTime","editTime","owner","deptOrg"]
if (!ary.includes(controlData.value.type)){
if(!props.formField.includes(controlData.value.name)){
chineseToPinyin({title:val,types:8,connector:"",formJson:JSON.stringify(props.formInfo)})
.then((data:any)=>{
if(data.code == 0){
if(data.data != ""){
if(!fileSignAry.includes(data.data)){
controlData.value.name = data.data
fileSignAry.push(data.data)
}else{
let isEnd = true;
do{
let titleVal = data.data + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
isEnd=false;
}
}while(isEnd);
}
}else{
let isEnd = true;
do{
let titleVal = data.data + Rand(10000000,99999999)
if(!fileSignAry.includes(val)){
controlData.value.name = val
fileSignAry.push(val)
}else{
let titleVal = val + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
isEnd=false;
}
}while(isEnd);
}
}else{
if(!fileSignAry.includes(val)){
controlData.value.name = val
fileSignAry.push(val)
}else{
let titleVal = val + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
}
}
}
}
})
})
}
}
// chineseToPinyin({title:val,types:8,connector:"",formJson:JSON.stringify(props.formInfo)})
// .then((data:any)=>{
@ -1239,9 +1242,11 @@ const delSelectOption = (index: number, type?: string) => {
}
//
const addSelectOption = (type: any) => {
if (controlData.value.type === 'cascader') {
//
openAttrDialog('cascader')
openAttrDialog('cascader',"级联选择器")
} else if (controlData.value.type === 'treeSelect') {
openAttrDialog('treeSelect', '编辑组件下拉选项数据')
} else {
@ -1251,9 +1256,18 @@ const addSelectOption = (type: any) => {
list: []
})
} else {
let maxVal = 1;
if(controlData.value.options && controlData.value.options.length > 0){
controlData.value.options.forEach((item:any)=>{
if(item.value >= maxVal){
maxVal = item.value
}
})
maxVal = maxVal*1 + 1
}
controlData.value.options.push({
label: '',
value: ''
label: '',
value: maxVal.toString()
})
}
}
@ -2649,6 +2663,19 @@ const loadNextPage = () => {
loadingnomore.value = true
}
}
/**
@ 作者: 秦东
@ 时间: 2024-06-22 13:57:55
@ 功能: 判断该输入框是否不可编辑
*/
const disabledIstrue = (val:string) => {
let ary = ["creater","creater_time","edit_time","owner","org"]
if (ary.includes(val)){
return true;
}else{
return false;
}
}
</script>
<template>
<div class="sidebar-tools">
@ -2998,7 +3025,8 @@ const loadNextPage = () => {
v-else
:type="item.inputStyle"
v-model="item.value"
:placeholder="isNotWriteWord(item)"
:placeholder="item.placeholder"
:disabled="isNotWriteWord(item)"
@input="controlChange(item, $event)"
/>
@ -3171,13 +3199,14 @@ const loadNextPage = () => {
v-for="(item, index) in controlData.options"
:key="index"
class="form_cont"
label="选项标签"
>
<el-col :span="10">
<el-input v-model="item.label" placeholder="选项标签" />
</el-col>
<el-col :span="10" :offset="1">
<!-- <el-col :span="10" :offset="1">
<el-input v-model="item.value" placeholder="选项值" />
</el-col>
</el-col> -->
<el-col :span="2" :offset="1">
<i
class="icon-del"

110
src/components/DesignForm/formControlProperties.vue

@ -224,18 +224,24 @@ onMounted(() => {
@ 功能: 判断输入框是否可写
*/
const isNotWrite = (val:any) =>{
// console.log("--->",val,props.customerformid)
if(val.key === "name" && props.customerformid != ""){
return true
}
return false
if(val.key === "name" && props.customerformid != ""){
return true
}
return false
}
const isNotWriteWord = (val:any) =>{
if(val.eventName === "filedNameKey" && props.customerformid != "" && props.formField.includes(val.value)){
return true
}
return false
console.log("判断输入框是否可写--->",val,props.customerformid)
let ary = ["creater","creater_time","edit_time","owner","org"]
if (ary.includes(val)){
return true;
}else{
if(val.eventName === "filedNameKey" && props.customerformid != "" && props.formField.includes(val.value)){
return true
}
return false
}
}
/**
@ 作者: 秦东
@ -1112,41 +1118,45 @@ const controlChange = (obj: any, val: any) => {
// console.log("props.formField",props.formField)
// console.log("props.formField.includes(obj.value)",props.formField.includes(controlData.value.name))
// console.log("obj.value",controlData.value.name)
if(!props.formField.includes(controlData.value.name)){
chineseToPinyin({title:val,types:8,connector:"",formJson:JSON.stringify(props.formInfo)})
.then((data:any)=>{
if(data.code == 0){
if(data.data != ""){
if(!fileSignAry.includes(data.data)){
controlData.value.name = data.data
fileSignAry.push(data.data)
}else{
let isEnd = true;
do{
let titleVal = data.data + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
isEnd=false;
}
}while(isEnd);
}
}else{
if(!fileSignAry.includes(val)){
controlData.value.name = val
fileSignAry.push(val)
}else{
let titleVal = val + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
}
}
let ary = ["founder","founderTime","editTime","owner","deptOrg"]
if (!ary.includes(controlData.value.type)){
}
if(!props.formField.includes(controlData.value.name)){
chineseToPinyin({title:val,types:8,connector:"",formJson:JSON.stringify(props.formInfo)})
.then((data:any)=>{
if(data.code == 0){
if(data.data != ""){
if(!fileSignAry.includes(data.data)){
controlData.value.name = data.data
fileSignAry.push(data.data)
}else{
let isEnd = true;
do{
let titleVal = data.data + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
isEnd=false;
}
}while(isEnd);
}
}else{
if(!fileSignAry.includes(val)){
controlData.value.name = val
fileSignAry.push(val)
}else{
let titleVal = val + Rand(10000000,99999999)
if(!fileSignAry.includes(titleVal)){
controlData.value.name = titleVal;
fileSignAry.push(titleVal);
}
}
}
})
}
}
})
}
}
}
@ -1493,7 +1503,19 @@ const rulesSelectChange = (item: any, val: string) => {
}
/**
@ 作者: 秦东
@ 时间: 2024-06-22 13:57:55
@ 功能: 判断该输入框是否不可编辑
*/
const disabledIstrue = (val:string) => {
let ary = ["creater","creater_time","edit_time","owner","org"]
if (ary.includes(val)){
return true;
}else{
return false;
}
}
</script>
<template>
<div class="sidebar-tools_e">

53
src/components/DesignForm/public/form/formGroup.vue

@ -76,6 +76,41 @@ const notNestedTableFlex = (type: string) => {
return controlType.includes(type)
// return false
}
/**
@ 作者: 秦东
@ 时间: 2024-06-22 15:03:31
@ 功能: 判断不能重复出现的组件
*/
const determineDuplicates = (type: string) => {
const controlType = ["founder","founderTime","editTime","owner","deptOrg"]
// console.log("",dataList);
if(dataList.value.length > 0){
let jibuqi = 0;
dataList.value.forEach((item:any)=>{
// console.log("",item);
if(controlType.includes(type)){
if(type == item.type){
jibuqi++
}
}
})
// console.log("",jibuqi);
if(jibuqi > 1){
ElMessage({
showClose: true,
message: '此类控件在表单中只能出现一次!不可重复添加!',
type: 'error',
})
return true;
}else{
return false
}
}else{
return false
}
// return controlType.includes(type)
}
//
const click = (action: string, index: number, item?: any) => {
if (type.value !== 5) {
@ -109,10 +144,10 @@ const draggableAdd = (evt: any) => {
const isNested = evt.target && evt.target.getAttribute('data-type') //
// console.log("-----1------->",newIndex)
// console.log("-----2------->",key)
// console.log("-----3------->",obj)
console.log("设计拖拽事件-----3------->",obj)
// console.log("-----4------->",isNested)
// console.log("-----4------->",dataList.value)
if ((isNested === 'not-nested' && notNested(obj.type)) || ((isNested === 'not-table' || isNested === 'not-flex') && notNestedTableFlex(obj.type))) {
if ((isNested === 'not-nested' && notNested(obj.type)) || ((isNested === 'not-table' || isNested === 'not-flex') && notNestedTableFlex(obj.type)) || determineDuplicates(obj.type)) {
dataList.value.splice(newIndex, 1)
return
}
@ -342,6 +377,7 @@ const getFormItemLableStyle = (ele: any) => {
return AnalysisCss(ele?.labelStyle)
}
}
</script>
<template>
<draggable
@ -524,17 +560,12 @@ const getFormItemLableStyle = (ele: any) => {
<FounderTime v-else-if="element.type === 'founderTime'" :data="element" :tablekey="props.tableinfo" :numrun="props.numrun" />
<!--修改时间-->
<template v-else-if="element.type === 'editTime'">
{{element}}
</template>
<EditTime v-else-if="element.type === 'editTime'" :data="element" :tablekey="props.tableinfo" :numrun="props.numrun" />
<!--拥有者-->
<template v-else-if="element.type === 'owner'">
{{element}}
</template>
<OwnerPage v-else-if="element.type === 'owner'" :data="element" :tablekey="props.tableinfo" :numrun="props.numrun" />
<!--所属部门-->
<template v-else-if="element.type === 'deptOrg'">
{{element}}
</template>
<DeptOrgPage v-else-if="element.type === 'deptOrg'" :data="element" :tablekey="props.tableinfo" :numrun="props.numrun" />
<DigitPage v-else-if="element.type === 'digitpage'" :data="element" />

2
src/components/DesignForm/tableListPage/index.vue

@ -572,7 +572,7 @@ const editFormSendFlow = (val:any) => {
<tooltip :content="item.help" />
</template>
</el-table-column>
<el-table-column v-else-if="item.fieldClass=='__control'" :prop="item.field" :label="item.label" config="">
<el-table-column v-else-if="item.fieldClass=='__control'" :prop="item.field" :label="item.label" config="" width="200" align="center" fixed="right" >
<template #default="scope">
<el-button-group>
<el-tooltip

7
src/widget/index.ts

@ -18,6 +18,10 @@ import associatedForms from './associatedforms/index.vue'
import FounderForm from './systemunit/founder.vue'
import FounderTime from './systemunit/founderTime.vue'
import EditTime from './systemunit/editTime.vue'
import OwnerPage from './systemunit/ownerPage.vue'
import DeptOrgPage from './systemunit/deptOrgPage.vue'
export default (app: any) => {
app.component('SerialNumber', serialNumber)
@ -37,4 +41,7 @@ export default (app: any) => {
app.component('FounderForm',FounderForm) //创建人组件
app.component('FounderTime',FounderTime) //创建时间主键
app.component('EditTime',EditTime) //创建时间主键
app.component('OwnerPage',OwnerPage) //选择拥有者
app.component('DeptOrgPage',DeptOrgPage) //所属部门
}

228
src/widget/systemunit/deptOrgPage.vue

@ -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-itemprop
}>(),
{}
)
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
})
// customRulesrules
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) {
// 使validatormessage使 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>

205
src/widget/systemunit/editTime.vue

@ -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-itemprop
}>(),
{}
)
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
})
// customRulesrules
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) {
// 使validatormessage使 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>

17
src/widget/systemunit/founderTime.vue

@ -129,7 +129,7 @@ const value = computed({
}
if(zhiVal != null && zhiVal != "") {
return zhiVal
return unixTimeToDayTime(zhiVal)
}else{
return getCurrentTime()
}
@ -146,6 +146,21 @@ const value = computed({
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 getCurrentTime = () => {
const now = new Date();

238
src/widget/systemunit/ownerPage.vue

@ -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-itemprop
}>(),
{}
)
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
})
// customRulesrules
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) {
// 使validatormessage使 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…
Cancel
Save