Skip to content

Commit

Permalink
feat style config
Browse files Browse the repository at this point in the history
  • Loading branch information
hyl committed Dec 2, 2024
1 parent 27ba76f commit be2ee83
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/components/FormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,5 @@ watch(value, (newVal, oldVal) => {
})
formInstance.updateFormValues(temp)
})
},{immediate:true})
</script>
36 changes: 28 additions & 8 deletions packages/config/template/__test__/formList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('template formList', async () => {
const wrapper = mount(formRender, {
props: {
schema,
modelValue:{}
modelValue: {}
}
})

Expand All @@ -34,25 +34,45 @@ describe('template formList', async () => {
const wrapper = mount(formRender, {
props: {
schema,
modelValue:{}
modelValue: {}
}
})

await wait(100)



const listDom = wrapper.find('.FormList-users')

await listDom.find('.addBtn').trigger('click')

await listDom.find('.addBtn').trigger('click')
await listDom.find('.addBtn').trigger('click') // 增加两行

expect(wrapper.vm.formValues.users.length).toBe(2)

// await listDom.find('.Switch-vip').trigger('click')
expect(wrapper.vm.formValues.users.every((item) => item.vip === 0)).toBe(true)

await wrapper.find('.Switch-vip input').trigger('click') // 批量设为管理员

expect(wrapper.vm.formValues.users.every((item) => item.vip === 1)).toBe(true)
})

it('username has admin && set row vip true', async () => {
const wrapper = mount(formRender, {
props: {
schema,
modelValue: {}
}
})

await wait(100)

const listDom = wrapper.find('.FormList-users')

await listDom.find('.addBtn').trigger('click') // 增加一行

expect(wrapper.vm.formValues.users[0].vip).toBe(0)

await wrapper.find('.Input-users\\.0\\.username input').setValue('admin999') // 单行

// console.log(wrapper.vm.formValues.users);

expect(wrapper.vm.formValues.users[0].vip).toBe(1)
})
})
21 changes: 19 additions & 2 deletions packages/form-design/Right/AttrEdit/StyleConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { ref } from 'vue'
import type { FormSchema } from '@vue-form-craft/types'
import FormRender from '../../../form-render'
import { ns } from '@vue-form-craft/utils';
import { ns } from '@vue-form-craft/utils'
const currentProps = defineModel<Record<string, any>>()
Expand Down Expand Up @@ -196,6 +196,23 @@ const schema: FormSchema = {
designKey: 'design-A2bj',
name: 'style.color'
},
{
label: '缩放',
component: 'Slider',
designKey: 'design-A2sf',
name: 'style.transform',
props: {
min: 50,
max: 150
},
initialValue:100,
change: [
{
target: 'style.transform',
value: '{{ `scale(${$values.style.transform / 100 })` }}'
}
]
},
{
label: '自定义',
component: 'JsonEdit',
Expand All @@ -204,4 +221,4 @@ const schema: FormSchema = {
}
]
}
</script>
</script>

0 comments on commit be2ee83

Please sign in to comment.