Skip to content

Commit

Permalink
perf: save a temporary codd
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberty-liu committed Mar 26, 2023
1 parent ee24a8e commit 1122124
Show file tree
Hide file tree
Showing 114 changed files with 724 additions and 405 deletions.
2 changes: 1 addition & 1 deletion examples/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const routes = [
},
{
name: 'objAction',
path: 'objAction/:objid?',
path: 'objAction/:objid?/:actionid?',
component: FormEditorObjActionView
}
]
Expand Down
48 changes: 38 additions & 10 deletions examples/views/formEditor/objAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,70 @@ const route = useRoute()
const loading = ref(true)
const lang = ref('en')
const EReditorRef = ref(null)
const isEdit = !!route.params.actionid
const state = reactive({
name: ''
})
window.lang = lang
const getObjData = async () => {
try {
// const {
// data: {
// content,
// name
// }
// } = await hooks.useFetch(`${uri.obj}/${route.params.objid}`, {
// method: 'get'
// })
// state.name = name
// EReditorRef.value.setData(content)
const data = []
const {
data: {
content,
name
}
data: data0
} = await hooks.useFetch(`${uri.obj}/${route.params.objid}`, {
method: 'get'
})
state.name = name
EReditorRef.value.setData(content)
data.push(data0.content)
if (isEdit) {
const {
data: data1
} = await hooks.useFetch(`${uri.obj}/${route.params.objid}/action/${route.params.actionid}`, {
method: 'get'
})
data.push(data1.content)
}
EReditorRef.value.setData(...data)
} finally {
loading.value = false
}
}
const handleListener = async ({ type, data }) => {
console.log(type)
if (type === 'submit') {
loading.value = true
try {
const postData = {
name: state.name,
content: data
}
await hooks.useFetch(`${uri.obj}/${route.params.objid}`, {
method: 'put',
await hooks.useFetch(`${uri.obj}/${route.params.objid}/action${isEdit ? `/${route.params.actionid}` : '/create'}`, {
method: isEdit ? 'put' : 'post',
data: postData
})
} finally {
loading.value = false
}
// loading.value = true
// try {
// const postData = {
// name: state.name,
// content: data
// }
// await hooks.useFetch(`${uri.obj}/${route.params.objid}`, {
// method: 'put',
// data: postData
// })
// } finally {
// loading.value = false
// }
}
}
onMounted(() => {
Expand Down
25 changes: 14 additions & 11 deletions examples/views/formEditorConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,38 @@ import _ from 'lodash-es'
import { ref, onMounted, getCurrentInstance, reactive, computed } from 'vue'
import { erFormConfig, erGeneratorData, erComponentsConfig, utils } from '@ER/formEditor'
console.log(erComponentsConfig)
const EReditorRef = ref(null)
const layoutNodes = erComponentsConfig.fieldConfig[2].list.map(e => erGeneratorData(e, false, 'zh-cn'))
const layoutNodes = erComponentsConfig.fieldConfig[2].list.map(e => erGeneratorData(e, true, 'zh-cn'))
const store = reactive({
fields: [...erComponentsConfig.fieldConfig[0].list, ...erComponentsConfig.fieldConfig[1].list].map(e => erGeneratorData(e, false, 'zh-cn')),
fields: [...erComponentsConfig.fieldConfig[0].list, ...erComponentsConfig.fieldConfig[1].list].map(e => erGeneratorData(e, true, 'zh-cn')),
layouts: []
})
const fieldData = ref({})
layoutNodes.forEach((node, index) => {
store.layouts.push(node)
switch (node.type) {
// console.log(node)
switch (node.columns[0].type) {
case 'grid':
case 'tabs':
case 'collapse':
node.columns[0].label = `${node.label} > ${node.columns[0].type}`
store.layouts.push(node.columns[0])
node.columns[0].columns[0].label = `${node.columns[0].label} > ${node.columns[0].columns[0].type}`
store.layouts.push(node.columns[0].columns[0])
break
case 'table':
node.rows[0].columns[0].label = `${node.label} > ${node.rows[0].columns[0].type}`
store.layouts.push(node.rows[0].columns[0])
node.columns[0].rows[0].columns[0].label = `${node.columns[0].label} > ${node.columns[0].rows[0].columns[0].type}`
store.layouts.push(node.columns[0].rows[0].columns[0])
break
}
})
console.log(store)
const all = [...store.fields, ...store.layouts]
// const value0 = ref('root')
const value0 = ref(store.layouts[2].id)
const sector = computed(() => {
let result = ''
if (value0.value === 'root') {
result = 'root'
} else {
console.log(value0.value)
result = _.find(all, { id: value0.value })
}
return result
Expand All @@ -54,13 +55,15 @@ const handleListener = async ({ type, data }) => {
</el-radio-group>
<h1>字段</h1>
<el-radio-group v-model="value0" size="large">
<el-radio-button v-for="item in store.fields" :key="item.id" :label="item.id">{{item.label}}</el-radio-button>
<el-radio-button v-for="item in store.fields" :key="item.columns[0].id" :label="item.id">{{item.columns[0].label}}</el-radio-button>
</el-radio-group>
</div>
<div>
<h1>布局</h1>
<el-radio-group v-model="value0" size="large">
<el-radio-button v-for="item in store.layouts" :key="item.id" :label="item.id">{{item.label || item.type}}</el-radio-button>
<el-radio-button v-for="item in store.layouts" :key="item.id" :label="item.id">
{{item.label ? (item.label || item.type) : (item.columns[0].label || item.columns[0].type)}}
</el-radio-button>
</el-radio-group>
</div>
</el-header>
Expand Down
1 change: 1 addition & 0 deletions packages/formEditor/components/Layout/InlineLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineComponent({
})
watch(() => props.data.columns.length, (newVal, oldVal) => {
if (newVal !== oldVal) {
console.log(123123)
utils.syncWidthByPlatform(props.data.columns, state.platform)
}
// const averageWidths = utils.calculateAverage(newVal)
Expand Down
Loading

0 comments on commit 1122124

Please sign in to comment.