8 Commits

Author SHA1 Message Date
JaguarJack
3c4ebb86e7 chore:移除unsignedDecimal类型 2024-04-22 17:36:26 +08:00
JaguarJack
dede7b0ba0 fix:字段无法删除 2024-04-22 17:24:51 +08:00
JaguarJack
d995a8ce0d feat:创建数据表字段,支持拖拽 2024-04-21 13:46:53 +08:00
JaguarJack
898ce1305d fix:修复 Laravel11 获取表栏目 2024-04-15 09:17:33 +08:00
JaguarJack
7362bdd70f chore: update version 2024-04-15 09:05:24 +08:00
JaguarJack
4e104bfd47 chore: update version 2024-04-15 09:04:36 +08:00
JaguarJack
4700990507 chore: update version 2024-04-15 09:02:51 +08:00
JaguarJack
808dd7118d chore: update version 2024-04-15 09:00:17 +08:00
7 changed files with 150 additions and 49 deletions

View File

@@ -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

View File

@@ -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'],
]; ];
} }

View File

@@ -0,0 +1,11 @@
<script setup lang="ts">
</script>
<template>
$END$
</template>
<style scoped lang="scss">
</style>

View File

@@ -1,27 +1,29 @@
<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-column prop="field" :label="$t('generate.schema.structure.field_name.name')" /> <el-table :data="structures" class="draggable" :lazy="false">
<el-table-column prop="type" :label="$t('generate.schema.structure.type.name')"> <el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" />
<template #default="scope"> <el-table-column prop="type" :label="$t('generate.schema.structure.type.name')">
<el-tag type="success">{{ scope.row.type }}</el-tag> <template #default="scope">
</template> <el-tag type="success">{{ scope.row.type }}</el-tag>
</el-table-column> </template>
<el-table-column prop="nullable" :label="$t('generate.schema.structure.nullable')" width="90px"> </el-table-column>
<template #default="scope"> <el-table-column prop="nullable" :label="$t('generate.schema.structure.nullable')" width="90px">
<el-tag v-if="scope.row.nullable">{{ $t('system.yes') }}</el-tag> <template #default="scope">
<el-tag v-else type="info">{{ $t('system.no') }}</el-tag> <el-tag v-if="scope.row.nullable">{{ $t('system.yes') }}</el-tag>
</template> <el-tag v-else type="info">{{ $t('system.no') }}</el-tag>
</el-table-column> </template>
<el-table-column prop="default" :label="$t('generate.schema.structure.default')" /> </el-table-column>
<!--<el-table-column prop="comment" label="注释" />--> <el-table-column prop="default" :label="$t('generate.schema.structure.default')" />
<el-table-column prop="id" :label="$t('generate.schema.structure.operate')" width="120px"> <!--<el-table-column prop="comment" label="注释" />-->
<template #default="scope"> <el-table-column prop="id" :label="$t('generate.schema.structure.operate')" width="120px">
<el-button type="primary" :icon="Edit" @click="updateField(scope.row.id)" size="small" /> <template #default="scope">
<el-button type="danger" :icon="Delete" @click="deleteField(scope.row.id)" size="small" /> <el-button type="primary" :icon="Edit" @click="updateField(scope.row.id)" size="small" />
</template> <el-button type="danger" :icon="Delete" @click="deleteField(scope.row.id)" size="small" />
</el-table-column> </template>
</el-table> </el-table-column>
</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',
] ]

View File

@@ -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"

View 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 }
}