Skip to content

Commit

Permalink
release: v1.0.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cloydlau committed Aug 14, 2024
1 parent 6e492c2 commit 07458fb
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 277 deletions.
6 changes: 3 additions & 3 deletions demo/utils/useAdmateAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default (
// 可访问 this(组件实例)
// this 判空原因:只有表单没有列表时,openForm 会在 setup 时执行
getElFormRefOfFormData = function () {
return this?.$refs.formRef
return this?.$refs.faFormDialogRef.$refs.elFormRef
},

// 校验详情表单
Expand Down Expand Up @@ -104,7 +104,7 @@ export default (
// 列表筛选项的 ref
const listFilterRef = ref()
// 详情的 ref
const formRef = ref()
const faFormDialogRef = ref()

// 初始化 admate
const { list, form } = useAdmate(
Expand Down Expand Up @@ -376,7 +376,7 @@ export default (
// 表单
form,
// 详情的 ref
formRef,
faFormDialogRef,
// 表单标题
formTitle: computed(() => formTitleMap[form.status]),
// 表单标题字典
Expand Down
83 changes: 25 additions & 58 deletions demo/vue2.6/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,53 @@ const {
list,
listFilterRef,
queryList,
resetList,
form,
formRef,
faFormDialogRef,
formTitle,
} = useAdmateAdapter({
axiosConfig: {
urlPrefix,
},
list: {
filter: {
name: '123',
},
},
}, {
getElFormRefOfFormData() {
return formRef.value
},
})
</script>

<template>
<div class="p-20px">
<div p-20px>
<el-form
ref="listFilterRef"
:model="list.filter"
inline
>
<el-form-item
prop="name"
required
>
<el-form-item prop="name">
<el-input
v-model="list.filter.name"
placeholder="姓名"
/>
</el-form-item>
<el-form-item prop="status">
<el-select
<FaSelect
v-model="list.filter.status"
w="180px!"
placeholder="状态"
>
<el-option
v-for="(v, i) of ['停用', '启用']"
:key="i"
:label="v"
:value="v"
/>
</el-select>
:options="['停用', '启用']"
/>
</el-form-item>
<el-form-item>
<el-button
v-if="!list.watchFilter"
type="primary"
@click="queryList"
@click="queryList()"
>
查询
</el-button>
<el-button
@click="() => {
listFilterRef.resetFields()
}"
>
<el-button @click="resetList()">
重置
</el-button>
</el-form-item>
</el-form>

<div class="flex justify-between my-10px">
<div flex justify-between my-10px>
<div>
<el-button
type="primary"
Expand Down Expand Up @@ -123,35 +103,22 @@ const {
</el-table-column>
</el-table>

<el-dialog
<FaFormDialog
ref="faFormDialogRef"
v-model="form.data"
:readonly="form.status === 'read'"
:show.sync="form.show"
:title="formTitle"
:visible.sync="form.show"
:retrieving="form.loading"
:confirm="form.submit"
>
<el-form
ref="formRef"
v-loading="form.loading"
:model="form.data"
:disabled="form.status === 'read' || form.submitting"
<el-form-item
label="姓名"
prop="name"
required
>
<el-form-item
label="姓名"
prop="name"
required
>
<el-input v-model="form.data.name" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="form.show = false">取 消</el-button>
<el-button
v-if="form.status !== 'read' && !form.loading"
type="primary"
:loading="form.submitting"
@click="form.submit()"
>
确 定
</el-button>
</template>
</el-dialog>
<el-input v-model="form.data.name" />
</el-form-item>
</FaFormDialog>
</div>
</template>
6 changes: 3 additions & 3 deletions demo/vue2.6/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import 'uno.css'

import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui'

import { FaFormDialog, FaSelect } from 'faim'
import FaimLocale from 'faim/dist/locale/zh-cn.mjs'

import App from './index.vue'
import router from './router'

Vue.use(ElementUI)
Vue.use(FaFormDialog)
Vue.use(FaSelect)
Vue.use(FaFormDialog, { locale: FaimLocale.FaFormDialog })
Vue.use(FaSelect, { locale: FaimLocale.FaSelect })

new Vue({
render: h => h(App),
Expand Down
83 changes: 25 additions & 58 deletions demo/vue2.7/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,53 @@ const {
list,
listFilterRef,
queryList,
resetList,
form,
formRef,
faFormDialogRef,
formTitle,
} = useAdmateAdapter({
axiosConfig: {
urlPrefix,
},
list: {
filter: {
name: '123',
},
},
}, {
getElFormRefOfFormData() {
return formRef.value
},
})
</script>

<template>
<div class="p-20px">
<div p-20px>
<el-form
ref="listFilterRef"
:model="list.filter"
inline
>
<el-form-item
prop="name"
required
>
<el-form-item prop="name">
<el-input
v-model="list.filter.name"
placeholder="姓名"
/>
</el-form-item>
<el-form-item prop="status">
<el-select
<FaSelect
v-model="list.filter.status"
w="180px!"
placeholder="状态"
>
<el-option
v-for="(v, i) of ['停用', '启用']"
:key="i"
:label="v"
:value="v"
/>
</el-select>
:options="['停用', '启用']"
/>
</el-form-item>
<el-form-item>
<el-button
v-if="!list.watchFilter"
type="primary"
@click="queryList"
@click="queryList()"
>
查询
</el-button>
<el-button
@click="() => {
listFilterRef.resetFields()
}"
>
<el-button @click="resetList()">
重置
</el-button>
</el-form-item>
</el-form>

<div class="flex justify-between my-10px">
<div flex justify-between my-10px>
<div>
<el-button
type="primary"
Expand Down Expand Up @@ -123,35 +103,22 @@ const {
</el-table-column>
</el-table>

<el-dialog
<FaFormDialog
ref="faFormDialogRef"
v-model="form.data"
:readonly="form.status === 'read'"
:show.sync="form.show"
:title="formTitle"
:visible.sync="form.show"
:retrieving="form.loading"
:confirm="form.submit"
>
<el-form
ref="formRef"
v-loading="form.loading"
:model="form.data"
:disabled="form.status === 'read' || form.submitting"
<el-form-item
label="姓名"
prop="name"
required
>
<el-form-item
label="姓名"
prop="name"
required
>
<el-input v-model="form.data.name" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="form.show = false">取 消</el-button>
<el-button
v-if="form.status !== 'read' && !form.loading"
type="primary"
:loading="form.submitting"
@click="form.submit()"
>
确 定
</el-button>
</template>
</el-dialog>
<el-input v-model="form.data.name" />
</el-form-item>
</FaFormDialog>
</div>
</template>
5 changes: 3 additions & 2 deletions demo/vue2.7/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import 'uno.css'
import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui'
import { FaFormDialog, FaSelect } from 'faim'
import FaimLocale from 'faim/dist/locale/zh-cn.mjs'

import App from './index.vue'
import router from './router'

Vue.use(ElementUI)
Vue.use(FaFormDialog)
Vue.use(FaSelect)
Vue.use(FaFormDialog, { locale: FaimLocale.FaFormDialog })
Vue.use(FaSelect, { locale: FaimLocale.FaSelect })

new Vue({
render: h => h(App),
Expand Down
Loading

0 comments on commit 07458fb

Please sign in to comment.