fix:字段无法删除
This commit is contained in:
Submodule modules/Cms deleted from 36e9e66e38
11
modules/Develop/views/dymaic/create.vue
Normal file
11
modules/Develop/views/dymaic/create.vue
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
$END$
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
|
||||||
|
</style>
|
@@ -90,7 +90,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, Ref, ref } from 'vue'
|
import { Ref, ref } from 'vue'
|
||||||
import { useSchemaStore, Structure } from '../store'
|
import { useSchemaStore, Structure } from '../store'
|
||||||
import { Delete, Plus, Edit } from '@element-plus/icons-vue'
|
import { Delete, Plus, Edit } from '@element-plus/icons-vue'
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
@@ -119,6 +119,8 @@ const updateField = (id: number) => {
|
|||||||
structure.value = s
|
structure.value = s
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
schemaStore.setStructures(structures.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const form = ref<FormInstance>()
|
const form = ref<FormInstance>()
|
||||||
@@ -136,7 +138,10 @@ const submitStructure = (formEl: FormInstance | undefined) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteField = (id: number) => {
|
const deleteField = (id: number) => {
|
||||||
schemaStore.filterStructures(id)
|
structures.value = structures.value.filter((s: Structure) => {
|
||||||
|
return !(s.id === id)
|
||||||
|
})
|
||||||
|
schemaStore.setStructures(structures.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const next = () => {
|
const next = () => {
|
||||||
@@ -153,7 +158,6 @@ const next = () => {
|
|||||||
}
|
}
|
||||||
// 调整数据结构
|
// 调整数据结构
|
||||||
const onEnd = () => {
|
const onEnd = () => {
|
||||||
console.log(structures.value)
|
|
||||||
schemaStore.setStructures(structures.value)
|
schemaStore.setStructures(structures.value)
|
||||||
}
|
}
|
||||||
const types: string[] = [
|
const types: string[] = [
|
||||||
|
85
resources/admin/composables/upload.ts
Normal file
85
resources/admin/composables/upload.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { getFileExt, getFilename } from '@/form/support/helper'
|
||||||
|
import { Code } from '@/form/enum/app'
|
||||||
|
import Message from '@/form/support/message'
|
||||||
|
import { genFileId } from 'element-plus'
|
||||||
|
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'
|
||||||
|
|
||||||
|
// 上传文件
|
||||||
|
export function uploadFile(action: string, ext: Array<String>, isValidate: boolean = true) {
|
||||||
|
const upload = ref<UploadInstance>()
|
||||||
|
|
||||||
|
const file = ref<string>('')
|
||||||
|
const filename = ref<string>('')
|
||||||
|
const fileExtensions = ext.join('|')
|
||||||
|
|
||||||
|
// 上传前的钩子 判断文件类型
|
||||||
|
const beforeUpload = (file: UploadRawFile) => {
|
||||||
|
if (isValidate) {
|
||||||
|
const isCanUpload = ext.indexOf(getFileExt(file.name).substring(1)) > -1
|
||||||
|
if (!isCanUpload) {
|
||||||
|
Message.error('不符合上传文件类型,仅支持' + fileExtensions)
|
||||||
|
}
|
||||||
|
return isCanUpload
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleExceed: UploadProps['onExceed'] = files => {
|
||||||
|
upload.value!.clearFiles()
|
||||||
|
const file = files[0] as UploadRawFile
|
||||||
|
file.uid = genFileId()
|
||||||
|
upload.value!.handleStart(file)
|
||||||
|
upload.value!.submit()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSuccess = (response: any, uploadFile: any) => {
|
||||||
|
if (response.code === Code.SUCCESS) {
|
||||||
|
file.value = response.data.path
|
||||||
|
filename.value = getFilename(file.value)
|
||||||
|
} else {
|
||||||
|
Message.error(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { upload, beforeUpload, handleExceed, handleSuccess, file, filename, fileExtensions }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上传图片
|
||||||
|
// 上传文件
|
||||||
|
export function uploadImage(action: string, extensions: Array<String>) {
|
||||||
|
const upload = ref<UploadInstance>()
|
||||||
|
|
||||||
|
const file = ref<string>('')
|
||||||
|
const filename = ref<string>('')
|
||||||
|
const fileExtensions = extensions
|
||||||
|
|
||||||
|
// 上传前的钩子 判断文件类型
|
||||||
|
const beforeUpload = (file: UploadRawFile) => {
|
||||||
|
const isCanUpload = fileExtensions.indexOf(getFileExt(file.name).substring(1)) > -1
|
||||||
|
if (!isCanUpload) {
|
||||||
|
Message.error('不符合上传文件类型,仅支持' + fileExtensions)
|
||||||
|
}
|
||||||
|
return isCanUpload
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleExceed: UploadProps['onExceed'] = files => {
|
||||||
|
upload.value!.clearFiles()
|
||||||
|
const file = files[0] as UploadRawFile
|
||||||
|
file.uid = genFileId()
|
||||||
|
upload.value!.handleStart(file)
|
||||||
|
upload.value!.submit()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSuccess = (response: any, uploadFile: any) => {
|
||||||
|
if (response.code === Code.SUCCESS) {
|
||||||
|
file.value = response.data.path
|
||||||
|
filename.value = getFilename(file.value)
|
||||||
|
} else {
|
||||||
|
Message.error(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { upload, beforeUpload, handleExceed, handleSuccess, file, filename, fileExtensions }
|
||||||
|
}
|
Reference in New Issue
Block a user