主子表:暂时存储,样式跑通

This commit is contained in:
YunaiV 2023-11-10 00:20:00 +08:00
parent 4e413a10e6
commit d45ebd4fcf
2 changed files with 49 additions and 31 deletions

View File

@ -1,22 +1,15 @@
<template> <template>
<!-- <el-row :gutter="10" class="mb2">-->
<!-- <el-col :span="1.5">-->
<!-- <el-button type="primary" @click="handleAdd">添加</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button type="danger">删除</el-button>-->
<!-- </el-col>-->
<!-- </el-row>-->
<el-table <el-table
:data="formData" :data="formData"
@selection-change="handleDemoStudentContactSelectionChange" @selection-change="handleDemoStudentContactSelectionChange"
ref="demoStudentContactRef" ref="demoStudentContactRef"
:stripe="true" :stripe="true"
class="-mt-10px"
> >
<el-table-column label="序号" type="index" width="100" /> <el-table-column label="序号" type="index" width="100" />
<el-table-column label="名字" prop="name" width="300"> <el-table-column label="名字" prop="name" width="300">
<template #default="scope"> <template #default="scope">
<el-form-item label-width="0px" :inline-message="true"> <el-form-item label-width="0px" :inline-message="true" class="mb-0px!">
<el-input v-model="scope.row.name" placeholder="请输入名字" /> <el-input v-model="scope.row.name" placeholder="请输入名字" />
</el-form-item> </el-form-item>
</template> </template>
@ -25,26 +18,37 @@
<template #default="{ row, $index }"> <template #default="{ row, $index }">
<el-form-item <el-form-item
label-width="0px" label-width="0px"
:prop="`formData.${$index}.mobile`" :prop="`demoStudentContactList.${$index}.mobile`"
:rules="formRules.mobile" :rules="formRules.mobile"
:inline-message="true" :inline-message="true"
class="mb-0px!"
> >
<el-input type="number" placeholder="输入手机号码" v-model="row.mobile" /> <el-input type="number" placeholder="输入手机号码" v-model="row.mobile" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="60">
<el-button @click="handleAdd" link></el-button>
</el-table-column>
</el-table> </el-table>
<el-button @click="handleAdd" class="w-1/1">+ 添加客户信息</el-button> <el-row justify="center" class="mt-3">
<el-button @click="handleAdd" round>+ 添加联系人</el-button>
</el-row>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const formData = ref([ const props = defineProps<{
{ formData: any[]
name: '芋艿' }>()
}, // const formData = ref([
{ // {
name: '土豆' // name: '',
} // mobile: '15601691300'
]) // },
// {
// name: '',
// mobile: '15601691234'
// }
// ])
const formRules = reactive({ const formRules = reactive({
mobile: [required] mobile: [required]
}) })
@ -56,15 +60,19 @@ const handleDemoStudentContactSelectionChange = (val) => {
const demoStudentContactRef = ref() const demoStudentContactRef = ref()
/** 新增按钮操作 */ /** 新增按钮操作 */
const emit = defineEmits(['update:formData'])
const handleAdd = () => { const handleAdd = () => {
formData.value.push({ emit('update:formData', [
name: '测试' ...props.formData,
}) {
name: '土豆'
}
])
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleRemove = () => { const handleRemove = () => {
formData.value.push({ formData.push({
name: '测试' name: '测试'
}) })
} }

View File

@ -7,16 +7,21 @@
label-width="100px" label-width="100px"
v-loading="formLoading" v-loading="formLoading"
> >
<el-form-item label="表描述" prop="tableComment"> <el-form-item label="字段 1" prop="field1">
<el-input v-model="formData.tableComment" placeholder="请输入" /> <el-input v-model="formData.field1" placeholder="请输入字段 1" />
</el-form-item>
<el-form-item label="字段 2" prop="field2">
<el-input v-model="formData.field2" placeholder="请输入字段 2" />
</el-form-item>
<el-form-item label="字段 3" prop="field3">
<el-input v-model="formData.field3" placeholder="请输入字段 3" />
</el-form-item> </el-form-item>
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
<el-tab-pane label="User" name="first"> <el-tab-pane label="联系人信息" name="first">
<DemoStudentContactForm /> <DemoStudentContactForm v-model:form-data="formData.demoStudentContactList" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="Config" name="second">Config</el-tab-pane> <el-tab-pane label="地址信息" name="third">地址信息</el-tab-pane>
<el-tab-pane label="Role" name="third">Role</el-tab-pane> <el-tab-pane label="其它信息" name="fourth">其它信息</el-tab-pane>
<el-tab-pane label="Task" name="fourth">Task</el-tab-pane>
</el-tabs> </el-tabs>
</el-form> </el-form>
<template #footer> <template #footer>
@ -38,7 +43,12 @@ const formLoading = ref(false) // 表单的加载中1修改时的数据加
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData = ref({ const formData = ref({
id: undefined, id: undefined,
demoStudentContactList: [] demoStudentContactList: [
{
name: '芋艿',
mobile: '15601691300'
}
]
}) })
const formRules = reactive({}) const formRules = reactive({})
const formRef = ref() // Ref const formRef = ref() // Ref