pref(form): 新增 form 组件 submit 事件 model 属性

This commit is contained in:
就眠仪式
2021-10-20 00:17:51 +08:00
parent fa04937e03
commit 97a3ab87b9
11 changed files with 81 additions and 214 deletions

View File

@@ -1,7 +1,25 @@
<template>
<form class="layui-form">
<form class="layui-form" @submit="submit">
<slot />
</form>
</template>
<script setup name="LayForm" lang="ts"></script>
<script setup name="LayForm" lang="ts">
const props = withDefaults(
defineProps<{
model?: object
}>(),
{
model: function(){
return {}
}
}
)
const emit = defineEmits(['submit'])
const submit = function () {
emit('submit',props.model)
}
</script>

View File

@@ -1,7 +1,7 @@
<template>
<div class="layui-form-item">
<label class="layui-form-label">{{ label }}</label>
<div :class="[mode ? 'layui-input-' + mode : '']" class="layui-input-block">
<div :class="[mode ? 'layui-input-' + mode : '']">
<slot />
</div>
</div>
@@ -15,7 +15,7 @@ const props = withDefaults(
label?: string
}>(),
{
mode: 'block',
mode: 'block'
}
)
</script>

View File

@@ -21,7 +21,7 @@
</div>
<div class="layui-table-box">
<div class="layui-table-header">
<table cellspacing="0" cellpadding="0" border="0" class="layui-table">
<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-size="sm">
<thead>
<tr>
<th v-if="checkbox" class="layui-table-col-special">
@@ -47,7 +47,7 @@
</table>
</div>
<div class="layui-table-body layui-table-main">
<table cellspacing="0" cellpadding="0" border="0" class="layui-table">
<table cellspacing="0" cellpadding="0" border="0" class="layui-table" lay-size="sm">
<tbody>
<template v-for="data in dataSource" :key="data">
<tr>
@@ -63,10 +63,9 @@
</td>
<template v-for="column in columns" :key="column">
<template v-if="column.customSlot">
<td>
<td class="layui-table-cell">
<div
:style="{ width: column.width }"
style="padding: 0px 16px"
>
<slot :name="column.customSlot" :data="data" />
</div>
@@ -78,10 +77,9 @@
v-else
:key="index"
>
<td v-if="column.key == key">
<td class="layui-table-cell" v-if="column.key == key">
<div
:style="{ width: column.width }"
style="padding: 0px 16px"
>
<span v-if="column.slot">
<slot :name="column.slot" :data="data" />
@@ -141,7 +139,7 @@ const props = withDefaults(
},
selectedKeys: function () {
return []
},
}
}
)