Skip to content

Commit

Permalink
refactor(baInput):优化已有表单项的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
build-admin committed Jun 27, 2024
1 parent 291d3f4 commit 10527eb
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 129 deletions.
4 changes: 2 additions & 2 deletions web/src/components/formItem/createData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
:label="form.type.title"
type="select"
v-model="form.type.value"
:data="{ content: state.inputTypes }"
:placeholder="t('Please select field', { field: form.type.title })"
:input-attr="{
onChange: updateValue,
content: state.inputTypes,
...props.options?.type?.inputAttr,
}"
prop="type"
Expand Down Expand Up @@ -72,10 +72,10 @@
:label="form.rule.title"
type="selects"
v-model="form.rule.value"
:data="{ content: state.validators }"
:placeholder="t('Please select field', { field: form.rule.title })"
:input-attr="{
onChange: updateValue,
content: state.validators,
...props.options?.rule?.inputAttr,
}"
prop="rule"
Expand Down
11 changes: 7 additions & 4 deletions web/src/components/terminal/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,25 @@
v-model="startCommand"
type="string"
:input-attr="{ disabled: true }"
:attr="{ blockHelp: t('terminal.Please execute this command to start the service (add Su under Linux)') }"
:block-help="t('terminal.Please execute this command to start the service (add Su under Linux)')"
/>
<FormItem
:label="t('terminal.Installation service URL')"
v-model="serviceURL"
type="string"
:input-attr="{ disabled: true }"
:attr="{ blockHelp: t('terminal.Please access the site through the installation service URL (except in debug mode)') }"
:block-help="t('terminal.Please access the site through the installation service URL (except in debug mode)')"
/>
</el-form>
<FormItem
:label="t('terminal.Clean up successful tasks when starting a new task')"
:model-value="terminal.state.automaticCleanupTask"
type="radio"
:data="{ content: { '0': t('Disable'), '1': t('Enable') }, childrenAttr: { border: true } }"
:input-attr="{ onChange: terminal.changeAutomaticCleanupTask }"
:input-attr="{
border: true,
content: { '0': t('Disable'), '1': t('Enable') },
onChange: terminal.changeAutomaticCleanupTask,
}"
/>
<div class="config-buttons">
<el-button @click="terminal.toggleConfigDialog(false)">{{ t('terminal.Back to terminal') }}</el-button>
Expand Down
7 changes: 5 additions & 2 deletions web/src/views/backend/auth/admin/popupForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
multiple: true,
params: { isTree: true, absoluteAuth: adminInfo.id == baTable.form.items!.id ? 0 : 1 },
field: 'name',
'remote-url': '/admin/auth.Group/index',
remoteUrl: '/admin/auth.Group/index',
placeholder: t('Click select'),
}"
/>
Expand Down Expand Up @@ -94,7 +94,10 @@
:label="t('State')"
v-model="baTable.form.items!.status"
type="radio"
:data="{ content: { '0': t('Disable'), '1': t('Enable') }, childrenAttr: { border: true } }"
:input-attr="{
border: true,
content: { '0': t('Disable'), '1': t('Enable') },
}"
/>
</el-form>
</div>
Expand Down
7 changes: 5 additions & 2 deletions web/src/views/backend/auth/group/popupForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
:input-attr="{
params: { isTree: true },
field: 'name',
'remote-url': baTable.api.actionUrl.get('index'),
remoteUrl: baTable.api.actionUrl.get('index'),
placeholder: t('Click select'),
}"
/>
Expand Down Expand Up @@ -64,7 +64,10 @@
:label="t('State')"
v-model="baTable.form.items!.status"
type="radio"
:data="{ content: { '0': t('Disable'), '1': t('Enable') }, childrenAttr: { border: true } }"
:input-attr="{
border: true,
content: { '0': t('Disable'), '1': t('Enable') },
}"
/>
</el-form>
</div>
Expand Down
22 changes: 12 additions & 10 deletions web/src/views/backend/auth/rule/popupForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
:input-attr="{
params: { isTree: true },
field: 'title',
'remote-url': baTable.api.actionUrl.get('index'),
remoteUrl: baTable.api.actionUrl.get('index'),
}"
/>
<FormItem
:label="t('auth.rule.Rule type')"
v-model="baTable.form.items!.type"
type="radio"
:data="{
:input-attr="{
border: true,
content: { menu_dir: t('auth.rule.type menu_dir'), menu: t('auth.rule.type menu'), button: t('auth.rule.type button') },
childrenAttr: { border: true },
}"
/>
<el-form-item prop="title" :label="t('auth.rule.Rule title')">
Expand Down Expand Up @@ -77,16 +77,18 @@
type="icon"
:label="t('auth.rule.Rule Icon')"
v-model="baTable.form.items!.icon"
:input-attr="{ 'show-icon-name': true }"
:input-attr="{
showIconName: true,
}"
/>
<FormItem
v-if="baTable.form.items!.type == 'menu'"
:label="t('auth.rule.Menu type')"
v-model="baTable.form.items!.menu_type"
type="radio"
:data="{
:input-attr="{
border: true,
content: { tab: t('auth.rule.Menu type tab'), link: t('auth.rule.Menu type link (offsite)'), iframe: 'Iframe' },
childrenAttr: { border: true },
}"
/>
<el-form-item
Expand Down Expand Up @@ -150,18 +152,18 @@
:label="t('auth.rule.cache')"
v-model="baTable.form.items!.keepalive"
type="radio"
:data="{
:input-attr="{
border: true,
content: { 0: t('Disable'), 1: t('Enable') },
childrenAttr: { border: true },
}"
/>
<FormItem
:label="t('State')"
v-model="baTable.form.items!.status"
type="radio"
:data="{
:input-attr="{
border: true,
content: { '0': t('Disable'), '1': t('Enable') },
childrenAttr: { border: true },
}"
/>
</el-form>
Expand Down
76 changes: 31 additions & 45 deletions web/src/views/backend/crud/design.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
:label="t('crud.crud.sort order')"
v-model="state.table.defaultSortType"
type="select"
:data="{
:input-attr="{
content: { desc: t('crud.crud.sort order desc'), asc: t('crud.crud.sort order asc') },
}"
/>
Expand Down Expand Up @@ -92,10 +92,8 @@
:label="t('crud.crud.The relative path to the generated code')"
v-model="state.table.generateRelativePath"
type="string"
:attr="{
labelWidth: 140,
blockHelp: t('crud.crud.For quick combination code generation location, please fill in the relative path'),
}"
:label-width="140"
:block-help="t('crud.crud.For quick combination code generation location, please fill in the relative path')"
:input-attr="{
onChange: onTableChange,
}"
Expand All @@ -104,9 +102,7 @@
:label="t('crud.crud.Generated Controller Location')"
v-model="state.table.controllerFile"
type="string"
:attr="{
labelWidth: 140,
}"
:label-width="140"
/>
<el-form-item :label="t('crud.crud.Generated Data Model Location')" :label-width="140">
<el-input v-model="state.table.modelFile" type="string">
Expand All @@ -126,30 +122,19 @@
:label="t('crud.crud.Generated Validator Location')"
v-model="state.table.validateFile"
type="string"
:attr="{
labelWidth: 140,
}"
/>
<FormItem
:label="t('crud.crud.WEB end view directory')"
v-model="state.table.webViewsDir"
type="string"
:attr="{
labelWidth: 140,
}"
:label-width="140"
/>
<FormItem :label="t('crud.crud.WEB end view directory')" v-model="state.table.webViewsDir" type="string" :label-width="140" />
<FormItem
:label="t('Database connection')"
v-model="state.table.databaseConnection"
type="remoteSelect"
:attr="{
labelWidth: 140,
blockHelp: t('Database connection help'),
}"
:label-width="140"
:block-help="t('Database connection help')"
:input-attr="{
pk: 'key',
field: 'key',
'remote-url': getDatabaseConnectionListUrl,
remoteUrl: getDatabaseConnectionListUrl,
}"
/>
</div>
Expand Down Expand Up @@ -384,10 +369,10 @@
:type="item.type"
v-model="state.fields[state.activateField].table[idx].value"
:placeholder="state.fields[state.activateField].table[idx].placeholder ?? ''"
:data="{
:input-attr="{
content: state.fields[state.activateField].table[idx].options ?? {},
...(state.fields[state.activateField].table[idx].attr ?? {}),
}"
:input-attr="state.fields[state.activateField].table[idx].attr ?? {}"
/>
</template>
</template>
Expand All @@ -399,10 +384,10 @@
:type="item.type"
v-model="state.fields[state.activateField].form[idx].value"
:placeholder="state.fields[state.activateField].form[idx].placeholder ?? ''"
:data="{
:input-attr="{
content: state.fields[state.activateField].form[idx].options ?? {},
...(state.fields[state.activateField].form[idx].attr ?? {}),
}"
:input-attr="state.fields[state.activateField].form[idx].attr ?? {}"
/>
</template>
</template>
Expand Down Expand Up @@ -453,7 +438,7 @@
'user_score_log',
],
},
'remote-url': getTableListUrl,
remoteUrl: getTableListUrl,
onChange: onJoinTableChange,
}"
prop="table"
Expand All @@ -466,7 +451,7 @@
v-model="state.remoteSelectPre.form.pk"
:placeholder="t('crud.crud.Please select the value field of the select component')"
:key="'select-value' + JSON.stringify(state.remoteSelectPre.fieldList)"
:data="{
:input-attr="{
content: state.remoteSelectPre.fieldList,
}"
/>
Expand All @@ -477,7 +462,7 @@
v-model="state.remoteSelectPre.form.label"
:placeholder="t('crud.crud.Please select the label field of the select component')"
:key="'select-label' + JSON.stringify(state.remoteSelectPre.fieldList)"
:data="{
:input-attr="{
content: state.remoteSelectPre.fieldList,
}"
/>
Expand All @@ -489,7 +474,7 @@
v-model="state.remoteSelectPre.form.joinField"
:placeholder="t('crud.crud.Please select the fields displayed in the table')"
:key="'join-field' + JSON.stringify(state.remoteSelectPre.fieldList)"
:data="{
:input-attr="{
content: state.remoteSelectPre.fieldList,
}"
/>
Expand All @@ -500,29 +485,29 @@
v-model="state.remoteSelectPre.form.controllerFile"
:placeholder="t('crud.crud.Please select the controller of the data table')"
:key="'controller-file' + JSON.stringify(state.remoteSelectPre.controllerFileList)"
:data="{
:input-attr="{
content: state.remoteSelectPre.controllerFileList,
}"
:attr="{
blockHelp: t(
:block-help="
t(
'crud.crud.The remote pull-down will request the corresponding controller to obtain data, so it is recommended that you create the CRUD of the associated table'
),
}"
)
"
/>
<FormItem
type="select"
:label="t('crud.crud.Data Model Location')"
v-model="state.remoteSelectPre.form.modelFile"
:placeholder="t('crud.crud.Please select the data model location of the data table')"
:key="'model-file' + JSON.stringify(state.remoteSelectPre.modelFileList)"
:data="{
:input-attr="{
content: state.remoteSelectPre.modelFileList,
}"
:attr="{
blockHelp: t(
:block-help="
t(
'crud.crud.If it is left blank, the model of the associated table will be generated automatically If the table already has a model, it is recommended to select it to avoid repeated generation'
),
}"
)
"
/>
<el-form-item
v-if="state.table.databaseConnection && state.remoteSelectPre.form.modelFile"
Expand Down Expand Up @@ -615,10 +600,11 @@
class="rebuild-form-item"
v-model="state.table.rebuild"
type="radio"
:data="{ content: { No: t('crud.crud.No'), Yes: t('crud.crud.Yes') }, childrenAttr: { border: true } }"
:attr="{
blockHelp: t('crud.crud.tableReBuildBlockHelp'),
:input-attr="{
border: true,
content: { No: t('crud.crud.No'), Yes: t('crud.crud.Yes') },
}"
:block-help="t('crud.crud.tableReBuildBlockHelp')"
/>
</el-scrollbar>
<template #footer>
Expand Down
Loading

0 comments on commit 10527eb

Please sign in to comment.