1
1
<template >
2
- <!-- <el-row :gutter="10" class="mb2">-->
3
- <!-- <el-col :span="1.5">-->
4
- <!-- <el-button type="primary" @click="handleAdd">添加</el-button>-->
5
- <!-- </el-col>-->
6
- <!-- <el-col :span="1.5">-->
7
- <!-- <el-button type="danger">删除</el-button>-->
8
- <!-- </el-col>-->
9
- <!-- </el-row>-->
10
2
<el-table
11
3
:data =" formData"
12
4
@selection-change =" handleDemoStudentContactSelectionChange"
13
5
ref =" demoStudentContactRef"
14
6
:stripe =" true"
7
+ class =" -mt-10px"
15
8
>
16
9
<el-table-column label =" 序号" type =" index" width =" 100" />
17
10
<el-table-column label =" 名字" prop =" name" width =" 300" >
18
11
<template #default =" scope " >
19
- <el-form-item label-width =" 0px" :inline-message =" true" >
12
+ <el-form-item label-width =" 0px" :inline-message =" true" class = " mb-0px! " >
20
13
<el-input v-model =" scope.row.name" placeholder =" 请输入名字" />
21
14
</el-form-item >
22
15
</template >
25
18
<template #default =" { row , $index } " >
26
19
<el-form-item
27
20
label-width =" 0px"
28
- :prop =" `formData .${$index}.mobile`"
21
+ :prop =" `demoStudentContactList .${$index}.mobile`"
29
22
:rules =" formRules.mobile"
30
23
:inline-message =" true"
24
+ class =" mb-0px!"
31
25
>
32
26
<el-input type =" number" placeholder =" 输入手机号码" v-model =" row.mobile" />
33
27
</el-form-item >
34
28
</template >
35
29
</el-table-column >
30
+ <el-table-column align =" center" fixed =" right" label =" 操作" width =" 60" >
31
+ <el-button @click =" handleAdd" link >—</el-button >
32
+ </el-table-column >
36
33
</el-table >
37
- <el-button @click =" handleAdd" class =" w-1/1" >+ 添加客户信息</el-button >
34
+ <el-row justify =" center" class =" mt-3" >
35
+ <el-button @click =" handleAdd" round >+ 添加联系人</el-button >
36
+ </el-row >
38
37
</template >
39
38
<script setup lang="ts">
40
- const formData = ref ([
41
- {
42
- name: ' 芋艿'
43
- },
44
- {
45
- name: ' 土豆'
46
- }
47
- ])
39
+ const props = defineProps <{
40
+ formData: any []
41
+ }>()
42
+ // const formData = ref([
43
+ // {
44
+ // name: '芋艿',
45
+ // mobile: '15601691300'
46
+ // },
47
+ // {
48
+ // name: '土豆',
49
+ // mobile: '15601691234'
50
+ // }
51
+ // ])
48
52
const formRules = reactive ({
49
53
mobile: [required ]
50
54
})
@@ -56,15 +60,19 @@ const handleDemoStudentContactSelectionChange = (val) => {
56
60
const demoStudentContactRef = ref ()
57
61
58
62
/** 新增按钮操作 */
63
+ const emit = defineEmits ([' update:formData' ])
59
64
const handleAdd = () => {
60
- formData .value .push ({
61
- name: ' 测试'
62
- })
65
+ emit (' update:formData' , [
66
+ ... props .formData ,
67
+ {
68
+ name: ' 土豆'
69
+ }
70
+ ])
63
71
}
64
72
65
73
/** 删除按钮操作 */
66
74
const handleRemove = () => {
67
- formData .value . push ({
75
+ formData .push ({
68
76
name: ' 测试'
69
77
})
70
78
}
0 commit comments