Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3c4ebb86e7 | ||
![]() |
dede7b0ba0 | ||
![]() |
d995a8ce0d | ||
![]() |
898ce1305d | ||
![]() |
7362bdd70f | ||
![]() |
4e104bfd47 | ||
![]() |
4700990507 | ||
![]() |
808dd7118d |
@@ -11,19 +11,18 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"php": "^8.2",
|
||||
"ext-pdo": "*",
|
||||
"ext-zip": "*",
|
||||
"doctrine/dbal": "^3.4",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel/tinker": "^2.8",
|
||||
"catchadmin/core": "^0.2.7"
|
||||
"guzzlehttp/guzzle": "^7.8.1",
|
||||
"laravel/framework": "^11.0",
|
||||
"laravel/tinker": "^v2.9.0",
|
||||
"catchadmin/core": "^0.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"pestphp/pest": "^1.22"
|
||||
"fakerphp/faker": "^v1.23.1",
|
||||
"mockery/mockery": "^1.6.9",
|
||||
"pestphp/pest": "^v2.34.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
Submodule modules/Cms deleted from 36e9e66e38
@@ -6,8 +6,8 @@ use Catch\Base\CatchModel;
|
||||
use Catch\Enums\Status;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Develop\Support\Generate\Create\Schema;
|
||||
use Illuminate\Support\Facades\Schema as SchemaFacade;
|
||||
|
||||
class Schemas extends CatchModel
|
||||
{
|
||||
@@ -90,16 +90,13 @@ class Schemas extends CatchModel
|
||||
{
|
||||
$schema = parent::firstBy($id);
|
||||
|
||||
$columns = [];
|
||||
|
||||
foreach (getTableColumns($schema->name) as $columnString) {
|
||||
$column = DB::connection()->getDoctrineColumn(DB::connection()->getTablePrefix().$schema->name, $columnString);
|
||||
foreach (SchemaFacade::getColumns($schema->name) as $column) {
|
||||
$columns[] = [
|
||||
'name' => $column->getName(),
|
||||
'type' => $column->getType()->getName(),
|
||||
'nullable' => ! $column->getNotnull(),
|
||||
'default' => $column->getDefault(),
|
||||
'comment' => $column->getComment()
|
||||
'name' => $column['name'],
|
||||
'type' => $column['type_name'],
|
||||
'nullable' => $column['nullable'],
|
||||
'default' => $column['default'],
|
||||
'comment' => $column['comment'],
|
||||
];
|
||||
}
|
||||
|
||||
|
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>
|
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-table :data="structures" class="draggable">
|
||||
<VueDraggable v-model="structures" target=".el-table__body tbody" animation="150" @end="onEnd">
|
||||
<el-table :data="structures" class="draggable" :lazy="false">
|
||||
<el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" />
|
||||
<el-table-column prop="type" :label="$t('generate.schema.structure.type.name')">
|
||||
<template #default="scope">
|
||||
@@ -22,6 +23,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</VueDraggable>
|
||||
|
||||
<div class="flex justify-end mt-4">
|
||||
<el-button type="success" :icon="Plus" @click="addField">{{ $t('system.add') }}</el-button>
|
||||
@@ -88,21 +90,21 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed, Ref, ref } from 'vue'
|
||||
import { Ref, ref } from 'vue'
|
||||
import { useSchemaStore, Structure } from '../store'
|
||||
import { Delete, Plus, Edit } from '@element-plus/icons-vue'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Message from '/admin/support/message'
|
||||
import http from '/admin/support/http'
|
||||
import { Code } from '/admin/enum/app'
|
||||
import { VueDraggable } from 'vue-draggable-plus'
|
||||
|
||||
const schemaStore = useSchemaStore()
|
||||
const emits = defineEmits(['prev', 'next'])
|
||||
const visible = ref(false)
|
||||
|
||||
const structures = computed(() => {
|
||||
return schemaStore.getStructures
|
||||
})
|
||||
// 初始化
|
||||
const structures = ref(schemaStore.getStructures)
|
||||
|
||||
const structure: Ref<Structure> = ref(schemaStore.initStructure())
|
||||
// structure
|
||||
@@ -117,6 +119,8 @@ const updateField = (id: number) => {
|
||||
structure.value = s
|
||||
}
|
||||
})
|
||||
|
||||
schemaStore.setStructures(structures.value)
|
||||
}
|
||||
|
||||
const form = ref<FormInstance>()
|
||||
@@ -134,7 +138,10 @@ const submitStructure = (formEl: FormInstance | undefined) => {
|
||||
}
|
||||
|
||||
const deleteField = (id: number) => {
|
||||
schemaStore.filterStructures(id)
|
||||
structures.value = structures.value.filter((s: Structure) => {
|
||||
return !(s.id === id)
|
||||
})
|
||||
schemaStore.setStructures(structures.value)
|
||||
}
|
||||
|
||||
const next = () => {
|
||||
@@ -149,7 +156,10 @@ const next = () => {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 调整数据结构
|
||||
const onEnd = () => {
|
||||
schemaStore.setStructures(structures.value)
|
||||
}
|
||||
const types: string[] = [
|
||||
'id',
|
||||
'smallIncrements',
|
||||
@@ -201,7 +211,6 @@ const types: string[] = [
|
||||
'tinyIncrements',
|
||||
'tinyInteger',
|
||||
'tinyText',
|
||||
'unsignedDecimal',
|
||||
'uuid',
|
||||
'year',
|
||||
]
|
||||
|
@@ -16,6 +16,7 @@
|
||||
"pinia": "^2.1.7",
|
||||
"terser": "^5.29.2",
|
||||
"vue": "^3.4.21",
|
||||
"vue-draggable-plus": "^0.4.0",
|
||||
"vue-i18n": "9",
|
||||
"vue-router": "4.3.0",
|
||||
"vuedraggable": "^2.24.3"
|
||||
|
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