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" >