详情表单

szh-new
lijingjia 2 months ago
parent fcdaa2976c
commit a8466778c2

@ -12,7 +12,7 @@
<slot name="formHeader"></slot> <slot name="formHeader"></slot>
<template v-for="schema in getSchema" :key="schema.field"> <template v-for="schema in getSchema" :key="schema.field">
<FormItem <FormItem
v-if="schema.isEdit != 1 || schema.component == 'Divider' || schema.component == 'InputTextArea'" v-show="schema.isEdit == 2 || schema.component == 'Divider' || schema.component == 'InputTextArea'"
:is-advanced="fieldsIsAdvancedMap[schema.field]" :is-advanced="fieldsIsAdvancedMap[schema.field]"
:table-action="tableAction" :table-action="tableAction"
:form-action-type="formActionType" :form-action-type="formActionType"
@ -27,7 +27,7 @@
</template> </template>
</FormItem> </FormItem>
<!-- 只读 --> <!-- 只读 -->
<a-col :span="schema?.colProps?.span || 24" v-if="schema.show !== false && schema.isEdit == 1 && schema.component != 'Divider' && schema.component != 'InputTextArea'"> <a-col :span="schema?.colProps?.span || 24" v-show="schema.show !== false && schema.isEdit == 1 && schema.component != 'Divider' && schema.component != 'InputTextArea'">
<div class="ds-form-onlyread"> <div class="ds-form-onlyread">
<span class="label">{{ schema.label }}</span> {{ formModel[schema.field] || '-' }} <span class="label">{{ schema.label }}</span> {{ formModel[schema.field] || '-' }}
<span v-if="!schema.dynamicDisabled" class="iconfont icon-bianji1" @click="editFormItem(schema)"></span> <span v-if="!schema.dynamicDisabled" class="iconfont icon-bianji1" @click="editFormItem(schema)"></span>
@ -125,17 +125,23 @@
...rowProps, ...rowProps,
} }
}) })
const getBindValue = computed( const getBindValue = computed(
() => ({ ...attrs, ...props, ...unref(getProps) } as Recordable), () => ({ ...attrs, ...props, ...unref(getProps) } as Recordable),
) )
// isEdit
let editFlag = false
const getSchema = computed((): FormSchema[] => { const getSchema = computed((): FormSchema[] => {
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any) const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any)
const isReadonly = unref(propsRef).readonly const isReadonly = unref(propsRef).readonly
for (const schema of schemas) { for (const schema of schemas) {
// item if (!editFlag) {
if (isReadonly && !schema.isEdit) schema['isEdit'] = 1 // item 1(2)
if (isReadonly) {
schema['isEdit'] = 1
} else {
schema['isEdit'] = 2
}
}
const { defaultValue, component, isHandleDateDefaultValue = true } = schema const { defaultValue, component, isHandleDateDefaultValue = true } = schema
// handle date type // handle date type
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) { if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) {
@ -150,6 +156,9 @@
} }
} }
} }
if (schemas.length) {
editFlag = true
}
if (unref(getProps).showAdvancedButton) { if (unref(getProps).showAdvancedButton) {
return cloneDeep( return cloneDeep(
schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[], schemas.filter((schema) => schema.component !== 'Divider') as FormSchema[],

@ -71,6 +71,7 @@
v-if="visible" v-if="visible"
ref="busTable" ref="busTable"
:formData="getFieldsValue()" :formData="getFieldsValue()"
:setFieldsValue="setFieldsValue"
@save="save" @save="save"
@refresh="refresh" @refresh="refresh"
></BusinessTable> ></BusinessTable>

@ -77,7 +77,6 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue' import { onMounted, ref } from 'vue'
import { BasicTable, useTable } from '/@/components/Table'
import { useMessage } from '/@/hooks/web/useMessage' import { useMessage } from '/@/hooks/web/useMessage'
import { closePage } from '/@/hooks/web/common' import { closePage } from '/@/hooks/web/common'
import { Divider } from 'ant-design-vue' import { Divider } from 'ant-design-vue'
@ -91,11 +90,11 @@
const visible = ref(false) const visible = ref(false)
import { formSchema } from './columns' import { formSchema } from './columns'
import { Save, Get, Delete, ApplyAudit } from '../api' import { Save, Get, Delete, ApplyAudit } from '../api'
console.log(route) console.log(route.path)
const [registerForm, { validate, getFieldsValue, setFieldsValue }] = useForm({ const [registerForm, { validate, getFieldsValue, setFieldsValue }] = useForm({
labelWidth: 150, labelWidth: 150,
schemas: formSchema, schemas: formSchema,
// readonly: route.path != '/paid-apply/create', readonly: route.path != '/paid-apply/create',
showActionButtonGroup: false showActionButtonGroup: false
}) })
// loading // loading
@ -127,6 +126,8 @@
// //
const save = async (feeInfo) => { const save = async (feeInfo) => {
const postData = await validate() const postData = await validate()
console.log(postData)
return
if (feeInfo && feeInfo.length) { if (feeInfo && feeInfo.length) {
postData['details'] = [...feeData.value, ...feeInfo] postData['details'] = [...feeData.value, ...feeInfo]
} else { } else {
@ -203,12 +204,8 @@
} }
onMounted(() => { onMounted(() => {
// //
// reload()
init() init()
}) })
function handleSuccess() {
// reload()
}
</script> </script>
<style lang="less"> <style lang="less">

Loading…
Cancel
Save