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