diff --git a/.env b/.env.example similarity index 100% rename from .env rename to .env.example diff --git a/.gitignore b/.gitignore index 95d95164..ff7e0e4b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ node_modules dist dist-ssr *.local -.idea \ No newline at end of file +.idea +.env \ No newline at end of file diff --git a/package.json b/package.json index a3b0ba2f..38835789 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/postinstall.js b/scripts/postinstall.js new file mode 100644 index 00000000..cafbbfd0 --- /dev/null +++ b/scripts/postinstall.js @@ -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'); + }); + } +}); \ No newline at end of file diff --git a/src/components/ma-crud/components/column.vue b/src/components/ma-crud/components/column.vue index 74190979..54318836 100644 --- a/src/components/ma-crud/components/column.vue +++ b/src/components/ma-crud/components/column.vue @@ -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)" > {{ options.see.text || '查看' }} @@ -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)" > @@ -102,6 +106,8 @@ > { 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 @@ -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 diff --git a/src/components/ma-crud/components/searchFormItem/form-input.vue b/src/components/ma-crud/components/searchFormItem/form-input.vue index c844c4da..b4defcb7 100644 --- a/src/components/ma-crud/components/searchFormItem/form-input.vue +++ b/src/components/ma-crud/components/searchFormItem/form-input.vue @@ -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) @@ -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) ) - \ No newline at end of file + diff --git a/src/components/ma-crud/index.vue b/src/components/ma-crud/index.vue index 03b58b8e..e42e4a64 100644 --- a/src/components/ma-crud/index.vue +++ b/src/components/ma-crud/index.vue @@ -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" > @@ -531,6 +531,7 @@ const refresh = async () => { : options.value.api await requestHandle() } + selecteds.value = [] tableRef.value.selectAll(false) } diff --git a/src/components/ma-crud/types/columns.ts b/src/components/ma-crud/types/columns.ts index 6920fa05..c6c40188 100644 --- a/src/components/ma-crud/types/columns.ts +++ b/src/components/ma-crud/types/columns.ts @@ -5,7 +5,7 @@ import { VNodeChild } from "vue"; */ import { FieldRule } from "@arco-design/web-vue"; -export type FormDateType = +export type FormDataType = | "radio" | "checkbox" | "select" @@ -62,7 +62,7 @@ export interface BasicColumn { // 字段名称 dataIndex: string; // 组件类型 - formType?: FormDateType; + formType?: FormDataType; // 表格列对齐方式 align?: "center" | "right" | "left"; // 字段是否加入搜索 @@ -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) diff --git a/src/components/ma-form/index.vue b/src/components/ma-form/index.vue index 5025d86c..deedbc9d 100644 --- a/src/components/ma-form/index.vue +++ b/src/components/ma-form/index.vue @@ -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, @@ -278,4 +279,4 @@ defineExpose({ .ma-form-title { font-size: 18px; text-align: center; } - \ No newline at end of file + diff --git a/src/components/ma-info/index.vue b/src/components/ma-info/index.vue index e7fdf71e..08c8716d 100644 --- a/src/components/ma-info/index.vue +++ b/src/components/ma-info/index.vue @@ -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; @@ -105,7 +105,7 @@ const reset = (vl) => { label: item.title, value: value ?? get(data.value, item.dataIndex), }); - }); + }; }; watch( diff --git a/src/views/appStore/components/appDetail.vue b/src/views/appStore/components/appDetail.vue index 710c66e1..4b56caf5 100644 --- a/src/views/appStore/components/appDetail.vue +++ b/src/views/appStore/components/appDetail.vue @@ -225,7 +225,7 @@ defineExpose({ open }) {{ item.version }} - {{ data?.created_by?.username }} + {{ data?.created_by?.nickname ?? data?.created_by?.username }} 发布于 {{ `${dayjs(item.created_at).fromNow()}` }} @@ -260,7 +260,7 @@ defineExpose({ open }) :src="data?.created_by?.avatar" >{{ data?.created_by?.username?.substring(0, 1).toUpperCase() }} - {{ data?.created_by?.username }} + {{ data?.created_by?.nickname ?? data?.created_by?.username }} 应用开发者