|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
v-model="showModal"
|
|
|
- :title="$t('createProject')"
|
|
|
+ :title="mode === 'add' ? $t('createProject') : $t('editProject')"
|
|
|
width="1000px"
|
|
|
body-class="h-500px overflow-y-auto overflow-x-hidden modal-body-scroll px-12px"
|
|
|
:modal="false"
|
|
|
@@ -22,7 +22,9 @@
|
|
|
<el-form-item :label="$t('projectPath')" prop="path" required>
|
|
|
<el-input v-model="formData.path" readonly>
|
|
|
<template #append>
|
|
|
- <el-button @click="selectPath"><LuFolder :size="16" /></el-button>
|
|
|
+ <el-button @click="selectPath"
|
|
|
+ ><LuFolder :size="16" :disabled="mode === 'edit'"
|
|
|
+ /></el-button>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
@@ -361,7 +363,9 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
- <el-button type="primary" @click="handleSetScreen">{{ $t('confirm') }}</el-button>
|
|
|
+ <el-button type="primary" @click="mode === 'add' ? handleSetScreen : handleEdit">{{
|
|
|
+ $t('confirm')
|
|
|
+ }}</el-button>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
</el-dialog>
|
|
|
@@ -370,7 +374,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import type { AppMeta } from '@/types/appMeta'
|
|
|
import type { FormInstance } from 'element-plus'
|
|
|
-import { computed, reactive, ref, defineExpose } from 'vue'
|
|
|
+import { computed, reactive, ref, defineExpose, nextTick } from 'vue'
|
|
|
import { LuFolder } from 'vue-icons-plus/lu'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
import { useAppStore } from '@/store/modules/app'
|
|
|
@@ -379,8 +383,10 @@ import { useI18n } from 'vue-i18n'
|
|
|
import chipConfig from '@/config/multi_chip_config.json'
|
|
|
import boardConfig from '@/config/board_card_config.json'
|
|
|
import displayConfig from '@/config/analog_display_config.json'
|
|
|
+import { klona } from 'klona'
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
+const mode = ref<'add' | 'edit'>('add')
|
|
|
const formData = reactive<
|
|
|
AppMeta & {
|
|
|
path: string
|
|
|
@@ -734,12 +740,25 @@ const handleSubmit = async () => {
|
|
|
showModal.value = false
|
|
|
}
|
|
|
|
|
|
+// 编辑项目
|
|
|
+const handleEdit = async () => {
|
|
|
+ await form.value?.validate()
|
|
|
+}
|
|
|
+
|
|
|
// expose
|
|
|
defineExpose({
|
|
|
- open: () => {
|
|
|
+ create: async () => {
|
|
|
+ mode.value = 'add'
|
|
|
showModal.value = true
|
|
|
+ await nextTick()
|
|
|
+ form.value?.resetFields()
|
|
|
},
|
|
|
- close: () => {
|
|
|
+ edit: () => {
|
|
|
+ const data = klona(projectStore.project?.meta || {})
|
|
|
+ Object.entries(data).forEach(([key, value]) => {
|
|
|
+ formData[key] = value
|
|
|
+ })
|
|
|
+ mode.value = 'edit'
|
|
|
showModal.value = false
|
|
|
}
|
|
|
})
|