Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Jun 18, 2024
2 parents e810aa2 + dbf3f7a commit 3e8831c
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 25 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
dist
dist-ssr
*.local
.idea
.idea
.env
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "vite build",
"preview": "vite preview",
"tailwind": "tailwind-config-viewer -o -c tailwind.config.cjs",
"generate:version": "generate-version-file dist public"
"generate:version": "generate-version-file dist public",
"postinstall": "node ./scripts/postinstall.js"
},
"dependencies": {
"@arco-design/color": "^0.4.0",
Expand Down
10 changes: 10 additions & 0 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {access, constants, copyFile} from 'fs';

access('.env', constants.F_OK, (err) => {
if (err) {
copyFile('.env.example', '.env', (err) => {
if (err) throw err;
console.log('.env.example was copied to .env');
});
}
});
6 changes: 6 additions & 0 deletions src/components/ma-crud/components/column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
v-auth="options.see.auth || []"
v-role="options.see.role || []"
type="primary"
:status="options.see.status || 'success'"
:style="{ color: options.see.color || '' }"
:disabled="(isFunction(options.see.disabled) ? options.see.disabled(record) : options.see.disabled)"
@click="seeAction(record)"
><icon-eye /> {{ options.see.text || '查看' }}</a-link>
Expand All @@ -77,6 +79,8 @@
v-auth="options.edit.auth || []"
v-role="options.edit.role || []"
type="primary"
:status="options.edit.status || 'normal'"
:style="{ color: options.edit.color || '' }"
:disabled="(isFunction(options.edit.disabled) ? options.edit.disabled(record) : options.edit.disabled)"
@click="editAction(record)"
>
Expand All @@ -102,6 +106,8 @@
>
<a-link
type="primary"
:status="options.delete.status || 'danger'"
:style="{ color: options.delete.color || '' }"
v-auth="options.delete.auth || []"
v-role="options.delete.role || []"
:disabled="(isFunction(options.delete.disabled) ? options.delete.disabled(record) : options.delete.disabled)"
Expand Down
12 changes: 6 additions & 6 deletions src/components/ma-crud/components/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -326,19 +326,19 @@ const settingFormLayout = (layout) => {

const formItemShow = (item) => {
if (currentAction.value === 'add') {
return item.addDisplay !== false
return isFunction(item.addDisplay) ? (item.addDisplay() !== false) : (item.addDisplay !== false)
}
if (currentAction.value === 'edit' || currentAction.value === 'see') {
return item.editDisplay !== false
return isFunction(item.editDisplay) ? (item.editDisplay(form.value) !== false) : (item.editDisplay !== false)
}
return item.display !== false
}
const formItemDisabled = (item) => {
if (currentAction.value === 'add' && ! isUndefined(item.addDisabled)) {
return item.addDisabled
return isFunction(item.addDisabled) ? item.addDisabled() : item.addDisabled
}
if (currentAction.value === 'edit' && ! isUndefined(item.editDisabled)) {
return item.editDisabled
return isFunction(item.editDisabled) ? item.editDisabled(form.value) : item.editDisabled
}
if (currentAction.value === 'see') {
return true
Expand All @@ -350,10 +350,10 @@ const formItemDisabled = (item) => {
}
const formItemReadonly = (item) => {
if (currentAction.value === 'add' && ! isUndefined(item.addReadonly)) {
return item.addReadonly
return isFunction(item.addReadonly) ? item.addReadonly() : item.addReadonly
}
if (currentAction.value === 'edit' && ! isUndefined(item.editReadonly)) {
return item.editReadonly
return isFunction(item.editReadonly) ? item.editReadonly(form.value) : item.editReadonly
}
if (! isUndefined(item.readonly)) {
return item.readonly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const props = defineProps({
const searchForm = inject('searchForm')
const minData = ref(isArray(props.component?.searchDefaultValue) ? props.component?.searchDefaultValue[0] : undefined)
const maxData = ref(isArray(props.component?.searchDefaultValue) ? props.component?.searchDefaultValue[1] : undefined)
const value = ref(get(searchForm.value, props.component.dataIndex, props.component.searchDefaultValue ?? ''))
const value = ref(get(searchForm.value, props.component.dataIndex, props.component.searchDefaultValue ?? props.component.formType === 'input-number' ? 0 : ''))

if (props.component.formType === 'input-number' && (props.component?.rangeSearch ?? false)) {
set(searchForm.value, `${props.component.dataIndex}Min`, minData.value)
Expand All @@ -61,4 +61,4 @@ watch( () => get(searchForm.value, props.component.dataIndex), vl => value.value
watch( () => value.value, v => set(searchForm.value, props.component.dataIndex, v) )
watch( () => minData.value, v => set(searchForm.value, `${props.component.dataIndex}Min`, v) )
watch( () => maxData.value, v => set(searchForm.value, `${props.component.dataIndex}Max`, v) )
</script>
</script>
3 changes: 2 additions & 1 deletion src/components/ma-crud/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
:hide-expand-button-on-empty="options.hideExpandButtonOnEmpty"
:default-expand-all-rows="options.expandAllRows"
:summary="(options.customerSummary || options.showSummary) && __summary"
@selection-change="setSelecteds"
v-model:selectedKeys="selecteds"
@sorter-change="handlerSort"
>
<template #tr="{ record }">
Expand Down Expand Up @@ -531,6 +531,7 @@ const refresh = async () => {
: options.value.api
await requestHandle()
}
selecteds.value = []
tableRef.value.selectAll(false)
}

Expand Down
16 changes: 8 additions & 8 deletions src/components/ma-crud/types/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { VNodeChild } from "vue";
*/
import { FieldRule } from "@arco-design/web-vue";

export type FormDateType =
export type FormDataType =
| "radio"
| "checkbox"
| "select"
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface BasicColumn {
// 字段名称
dataIndex: string;
// 组件类型
formType?: FormDateType;
formType?: FormDataType;
// 表格列对齐方式
align?: "center" | "right" | "left";
// 字段是否加入搜索
Expand All @@ -74,21 +74,21 @@ export interface BasicColumn {
// 编辑|创建 通用是否显示字段
display?: boolean;
// 添加弹窗是否显示字段
addDisplay?: boolean;
addDisplay?: boolean | (() => boolean);
// 编辑弹窗是否显示字段
editDisplay?: boolean;
editDisplay?: boolean | ((record) => boolean);
// 编辑|创建 通用是否禁用字段
disabled?: boolean;
// 添加弹窗是否禁用字段
addDisabled?: boolean;
addDisabled?: boolean | (() => boolean);
// 编辑弹窗是否禁用字段
editDisabled?: boolean;
editDisabled?: boolean | ((record) => boolean);
// 编辑|创建 通用是否只读字段
readonly?: boolean;
// 添加弹窗是否只读字段
addReadonly?: boolean;
addReadonly?: boolean | (() => boolean);
// 编辑弹窗是否只读字段
editReadonly?: boolean;
editReadonly?: boolean | ((record) => boolean);
// 自定义渲染
customRender?:
| (({ record, column, rowIndex }) => VNodeChild | JSX.Element)
Expand Down
3 changes: 2 additions & 1 deletion src/components/ma-form/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ provide('dictList', dictList)
provide('formModel', form)
provide('formLoading', formLoading)
provide('getColumnService', getColumnService)
provide('maFormRef', maFormRef)

defineExpose({
init, getFormRef, getColumns, getDictList, getColumnService, getCascaderList, getFormData,
Expand All @@ -278,4 +279,4 @@ defineExpose({
.ma-form-title {
font-size: 18px; text-align: center;
}
</style>
</style>
6 changes: 3 additions & 3 deletions src/components/ma-info/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ watch(
{ deep: true, immediate: true }
);
const reset = (vl) => {
const reset = async (vl) => {
data.value = vl;
descriptions.value = [];
if (!columns.value) {
return;
}
columns.value.forEach(async (item) => {
for (let item of columns.value) {
let value = null;
if (isEmpty(item) || item.dataIndex === "__operation" || item.infoShow === false) {
return;
Expand All @@ -105,7 +105,7 @@ const reset = (vl) => {
label: item.title,
value: value ?? get(data.value, item.dataIndex),
});
});
};
};
watch(
Expand Down
4 changes: 2 additions & 2 deletions src/views/appStore/components/appDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ defineExpose({ open })
<div class="w-full lg:w-2/12 h-auto">
<div class="text-xl font-semibold">{{ item.version }}</div>
<div class="text-xs text-gray-500 dark:text-gray-300 space-y-0.5 mt-2">
<div>{{ data?.created_by?.username }}</div>
<div>{{ data?.created_by?.nickname ?? data?.created_by?.username }}</div>
<div>发布于 {{ `${dayjs(item.created_at).fromNow()}` }}</div>
</div>
</div>
Expand Down Expand Up @@ -260,7 +260,7 @@ defineExpose({ open })
:src="data?.created_by?.avatar"
>{{ data?.created_by?.username?.substring(0, 1).toUpperCase() }}</a-avatar>
<div class="ml-3 text-sm leading-6 mt-0.5">
<div class="text-gray-800 dark:text-white">{{ data?.created_by?.username }}</div>
<div class="text-gray-800 dark:text-white">{{ data?.created_by?.nickname ?? data?.created_by?.username }}</div>
<div class="text-gray-500 dark:text-gray-400 text-xs">应用开发者</div>
</div>
</div>
Expand Down

0 comments on commit 3e8831c

Please sign in to comment.