This commit is contained in:
孟帅
2024-07-21 22:21:02 +08:00
parent 7d8330f72f
commit a37d088360
440 changed files with 6303 additions and 3339 deletions

View File

@@ -74,7 +74,7 @@
<n-form-item label="功能分组" path="group">
<n-select
placeholder="请选择"
:options="options.addonsGroupOptions"
:options="dict.getOptionUnRef('addonsGroupOptions')"
v-model:value="formParams.group"
:on-update:value="onUpdateValueGroup"
/>
@@ -86,7 +86,7 @@
<n-checkbox
:value="option.value"
:label="option.label"
v-for="option in options.addonsExtend"
v-for="option in dict.getOptionUnRef('addonsExtend')"
:key="option"
/>
</n-space>
@@ -128,15 +128,17 @@
</template>
<script lang="ts" setup>
import { computed, h, reactive, ref } from 'vue';
import { computed, h, onMounted, reactive, ref } from 'vue';
import { NIcon, useMessage, useDialog, useNotification } from 'naive-ui';
import { BasicTable, TableAction } from '@/components/Table';
import { BasicForm, useForm } from '@/components/Form/index';
import { List, Build, UnInstall, Install, Upgrade } from '@/api/develop/addons';
import { PlusOutlined } from '@vicons/antd';
import { newState, schemas, columns, options } from './model';
import { newState, schemas, columns, loadOptions } from './model';
import { adaModalWidth } from '@/utils/hotgo';
import { useDictStore } from '@/store/modules/dict';
const dict = useDictStore();
const dialog = useDialog();
const message = useMessage();
const notification = useNotification();
@@ -315,6 +317,10 @@
},
});
}
onMounted(async () => {
loadOptions();
});
</script>
<style lang="less" scoped></style>

View File

@@ -1,11 +1,13 @@
import { cloneDeep } from 'lodash-es';
import { h, ref } from 'vue';
import { Dicts } from '@/api/dict/dict';
import { errorImg, Option, Options } from '@/utils/hotgo';
import { fallbackSrc } from '@/utils/hotgo';
import { isUrl } from '@/utils/is';
import { NIcon, NIconWrapper, NImage, NTag } from 'naive-ui';
import { getIconComponent } from '@/utils/icons';
import { FormSchema } from '@/components/Form';
import { useDictStore } from '@/store/modules/dict';
const dict = useDictStore();
export const genInfoObj = {
label: '',
@@ -36,7 +38,7 @@ export const columns = [
width: 48,
height: 48,
src: row.logo,
fallbackSrc: errorImg,
fallbackSrc: fallbackSrc(),
style: {
width: '48px',
height: '48px',
@@ -152,7 +154,7 @@ export const schemas = ref<FormSchema[]>([
label: '分组',
componentProps: {
placeholder: '请选择分组',
options: [],
options: dict.getOption('addonsGroupOptions'),
onUpdateValue: (e: any) => {
console.log(e);
},
@@ -164,7 +166,7 @@ export const schemas = ref<FormSchema[]>([
label: '安装状态',
componentProps: {
placeholder: '请选择状态',
options: [],
options: dict.getOption('addonsInstallStatus'),
onUpdateValue: (e: any) => {
console.log(e);
},
@@ -172,32 +174,6 @@ export const schemas = ref<FormSchema[]>([
},
]);
export interface IOptions extends Options {
addonsGroupOptions: Option[];
addonsInstallStatus: Option[];
addonsExtend: Option[];
export function loadOptions() {
dict.loadOptions(['addonsGroupOptions', 'addonsInstallStatus', 'addonsExtend']);
}
export const options = ref<IOptions>({
addonsGroupOptions: [],
addonsInstallStatus: [],
addonsExtend: [],
});
async function loadOptions() {
options.value = await Dicts({
types: ['addonsGroupOptions', 'addonsInstallStatus', 'addonsExtend'],
});
for (const item of schemas.value) {
switch (item.field) {
case 'status':
item.componentProps.options = options.value.addonsInstallStatus;
break;
case 'group':
item.componentProps.options = options.value.addonsGroupOptions;
break;
}
}
}
await loadOptions();

View File

@@ -31,7 +31,12 @@
</template>
立即生成
</n-button>
<n-button type="error" @click="batchDelete" :disabled="batchDeleteDisabled" class="min-left-space">
<n-button
type="error"
@click="batchDelete"
:disabled="batchDeleteDisabled"
class="min-left-space"
>
<template #icon>
<n-icon>
<DeleteOutlined />
@@ -145,14 +150,13 @@
<script lang="ts" setup>
import { h, onBeforeMount, reactive, ref } from 'vue';
import { NTag, TreeSelectOption, useDialog, useMessage } from 'naive-ui';
import { NTag, useDialog, useMessage } from 'naive-ui';
import { BasicTable, TableAction } from '@/components/Table';
import { BasicForm, FormSchema, useForm } from '@/components/Form/index';
import { List, Delete, Edit, Selects, TableSelect } from '@/api/develop/code';
import { useRouter } from 'vue-router';
import { PlusOutlined, DeleteOutlined } from '@vicons/antd';
import { newState } from '@/views/develop/code/components/model';
import { getOptionLabel } from '@/utils/hotgo';
const selectList = ref({
db: [],
@@ -347,9 +351,6 @@
reloadTable();
});
},
onNegativeClick: () => {
// message.error('取消');
},
});
}
@@ -365,9 +366,6 @@
reloadTable();
});
},
onNegativeClick: () => {
// message.error('取消');
},
});
}
@@ -401,9 +399,7 @@
e.preventDefault();
formBtnLoading.value = true;
formRef.value.validate((errors) => {
console.log('formParams:' + JSON.stringify(formParams.value));
if (!errors) {
console.log('formParams:' + JSON.stringify(formParams.value));
Edit(formParams.value).then((res) => {
message.success('生成成功,正在前往配置');
setTimeout(() => {
@@ -427,17 +423,23 @@
} else {
dialogWidth.value = def + 'px';
}
return dialogWidth.value;
}
onBeforeMount(async () => {
await loadSelect();
});
function getOptionLabel(options, value) {
if (!options || options?.length === 0) {
return `unknown`;
}
for (const item of options) {
if (item.value == value) {
return item.label;
}
}
return `unknown`;
}
const loadSelect = async () => {
selectList.value = await Selects({});
for (const item of schemas.value) {
switch (item.field) {
case 'status':
@@ -452,10 +454,7 @@
const tablesLoading = ref(false);
// 处理选项更新
async function handleDbUpdateValue(
value: string | number | Array<string | number> | null,
_option: TreeSelectOption | null | Array<TreeSelectOption | null>
) {
async function handleDbUpdateValue(value: string | number | Array<string | number> | null) {
tablesLoading.value = true;
await loadTableSelect(value);
tablesLoading.value = false;
@@ -491,6 +490,10 @@
formParams.value.genTemplate = value;
selectAddon.value = option.isAddon === true;
}
onBeforeMount(async () => {
await loadSelect();
});
</script>
<style lang="less" scoped></style>