小程序端 extrafile/commit
This commit is contained in:
parent
32e9e39ece
commit
a4d3bf4b5c
|
|
@ -71,6 +71,29 @@ export default OakComponent({
|
|||
await Promise.all(promises);
|
||||
}
|
||||
},
|
||||
async onSubmit() {
|
||||
const { oakExecutable } = this.state;
|
||||
const { beforeCommit, afterCommit, action } = this.props;
|
||||
if (oakExecutable) {
|
||||
if (beforeCommit) {
|
||||
const beforeCommitResult = await beforeCommit();
|
||||
if (beforeCommitResult === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await this.execute(action || undefined);
|
||||
await this.upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
await this.upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
features: ['extraFile2'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
/** index.wxss **/
|
||||
|
||||
.btn {
|
||||
display: flex;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<!-- index.wxml -->
|
||||
<l-button size="long" disabled="{{disabled}}" bind:lintap="onSubmit">
|
||||
{{ executeText || t('common:submit') }}
|
||||
</l-button>
|
||||
|
|
@ -10,8 +10,6 @@ export default function render(props: WebComponentProps<EntityDict, any, true, {
|
|||
executeText?: string;
|
||||
action?: string;
|
||||
buttonProps?: ButtonProps;
|
||||
beforeCommit?: () => Promise<boolean | undefined> | boolean | undefined;
|
||||
afterCommit?: () => void;
|
||||
}, {
|
||||
upload: () => Promise<void>;
|
||||
onSubmit: () => Promise<void>;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { Button } from 'antd-mobile';
|
||||
export default function render(props) {
|
||||
const { state, oakExecutable, oakExecuting, oakDirty, size, block, type, executeText, buttonProps, action, beforeCommit, afterCommit, } = props.data;
|
||||
const { t, upload, execute } = props.methods;
|
||||
const { state, oakExecutable, oakExecuting, oakDirty, size, block, type, executeText, buttonProps, } = props.data;
|
||||
const { t, onSubmit } = props.methods;
|
||||
const disabled = oakExecuting ||
|
||||
['uploading'].includes(state) ||
|
||||
(oakExecutable === false && ['uploaded'].includes(state));
|
||||
|
|
@ -18,25 +18,5 @@ export default function render(props) {
|
|||
text = t('upload');
|
||||
}
|
||||
}
|
||||
return (_jsx(Button, { type: type, size: size, block: block, disabled: disabled, onClick: async () => {
|
||||
if (oakExecutable) {
|
||||
if (beforeCommit) {
|
||||
const beforeCommitResult = await beforeCommit();
|
||||
if (beforeCommitResult === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await execute(action || undefined);
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
}, ...buttonProps, children: text }));
|
||||
return (_jsx(Button, { type: type, size: size, block: block, disabled: disabled, onClick: onSubmit, ...buttonProps, children: text }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ export default function render(props: WebComponentProps<EntityDict, any, true, {
|
|||
executeText?: string;
|
||||
action?: string;
|
||||
buttonProps?: ButtonProps;
|
||||
afterCommit?: () => void;
|
||||
beforeCommit?: () => Promise<boolean> | boolean;
|
||||
}, {
|
||||
upload: () => Promise<void>;
|
||||
onSubmit: () => Promise<void>;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { Button } from 'antd';
|
||||
export default function render(props) {
|
||||
const { state, oakExecutable, oakExecuting, size, block, type, executeText, buttonProps = {}, action, afterCommit, beforeCommit, } = props.data;
|
||||
const { t, upload, execute } = props.methods;
|
||||
const { state, oakExecutable, oakExecuting, size, block, type, executeText, buttonProps = {}, } = props.data;
|
||||
const { t, onSubmit } = props.methods;
|
||||
const disabled = oakExecuting ||
|
||||
['uploading'].includes(state) ||
|
||||
(oakExecutable !== true && ['uploaded'].includes(state));
|
||||
|
|
@ -18,27 +18,5 @@ export default function render(props) {
|
|||
text = t('upload');
|
||||
}
|
||||
}
|
||||
return (_jsx(Button, {
|
||||
type: type, size: size, block: block, disabled: disabled, onClick: async () => {
|
||||
if (oakExecutable) {
|
||||
if (beforeCommit) {
|
||||
const beforeCommitResult = await beforeCommit();
|
||||
if (beforeCommitResult === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await execute(action || undefined);
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
}, ...buttonProps, children: text
|
||||
}));
|
||||
return (_jsx(Button, { type: type, size: size, block: block, disabled: disabled, onClick: onSubmit, ...buttonProps, children: text }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,6 +210,7 @@ export default OakComponent({
|
|||
const { errMsg, tempFiles } = await wx.chooseMessageFile({
|
||||
count: selectCount,
|
||||
type: 'all',
|
||||
...(extension && extension.length > 0 ? { extension } : {}),
|
||||
});
|
||||
if (errMsg !== 'chooseMessageFile:ok') {
|
||||
this.triggerEvent('onError', {
|
||||
|
|
@ -257,19 +258,12 @@ export default OakComponent({
|
|||
const { index } = event.currentTarget.dataset;
|
||||
const imageUrl = files[index].url;
|
||||
const urls = files?.filter((ele) => !!ele).map((ele) => ele.url);
|
||||
const detail = {
|
||||
all: files,
|
||||
index,
|
||||
urls,
|
||||
current: imageUrl,
|
||||
};
|
||||
// 预览图片
|
||||
if (!this.props.disablePreview) {
|
||||
const result = await wx.previewImage({
|
||||
urls: urls,
|
||||
current: imageUrl,
|
||||
});
|
||||
this.triggerEvent('onPreview', detail);
|
||||
}
|
||||
},
|
||||
getSort(index = 0) {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,29 @@ exports.default = OakComponent({
|
|||
await Promise.all(promises);
|
||||
}
|
||||
},
|
||||
async onSubmit() {
|
||||
const { oakExecutable } = this.state;
|
||||
const { beforeCommit, afterCommit, action } = this.props;
|
||||
if (oakExecutable) {
|
||||
if (beforeCommit) {
|
||||
const beforeCommitResult = await beforeCommit();
|
||||
if (beforeCommitResult === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await this.execute(action || undefined);
|
||||
await this.upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
await this.upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
features: ['extraFile2'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
/** index.wxss **/
|
||||
|
||||
.btn {
|
||||
display: flex;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<!-- index.wxml -->
|
||||
<l-button size="long" disabled="{{disabled}}" bind:lintap="onSubmit">
|
||||
{{ executeText || t('common:submit') }}
|
||||
</l-button>
|
||||
|
|
@ -10,8 +10,6 @@ export default function render(props: WebComponentProps<EntityDict, any, true, {
|
|||
executeText?: string;
|
||||
action?: string;
|
||||
buttonProps?: ButtonProps;
|
||||
beforeCommit?: () => Promise<boolean | undefined> | boolean | undefined;
|
||||
afterCommit?: () => void;
|
||||
}, {
|
||||
upload: () => Promise<void>;
|
||||
onSubmit: () => Promise<void>;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const antd_mobile_1 = require("antd-mobile");
|
||||
function render(props) {
|
||||
const { state, oakExecutable, oakExecuting, oakDirty, size, block, type, executeText, buttonProps, action, beforeCommit, afterCommit, } = props.data;
|
||||
const { t, upload, execute } = props.methods;
|
||||
const { state, oakExecutable, oakExecuting, oakDirty, size, block, type, executeText, buttonProps, } = props.data;
|
||||
const { t, onSubmit } = props.methods;
|
||||
const disabled = oakExecuting ||
|
||||
['uploading'].includes(state) ||
|
||||
(oakExecutable === false && ['uploaded'].includes(state));
|
||||
|
|
@ -20,26 +20,6 @@ function render(props) {
|
|||
text = t('upload');
|
||||
}
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(antd_mobile_1.Button, { type: type, size: size, block: block, disabled: disabled, onClick: async () => {
|
||||
if (oakExecutable) {
|
||||
if (beforeCommit) {
|
||||
const beforeCommitResult = await beforeCommit();
|
||||
if (beforeCommitResult === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await execute(action || undefined);
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
}, ...buttonProps, children: text }));
|
||||
return ((0, jsx_runtime_1.jsx)(antd_mobile_1.Button, { type: type, size: size, block: block, disabled: disabled, onClick: onSubmit, ...buttonProps, children: text }));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ export default function render(props: WebComponentProps<EntityDict, any, true, {
|
|||
executeText?: string;
|
||||
action?: string;
|
||||
buttonProps?: ButtonProps;
|
||||
afterCommit?: () => void;
|
||||
beforeCommit?: () => Promise<boolean> | boolean;
|
||||
}, {
|
||||
upload: () => Promise<void>;
|
||||
onSubmit: () => Promise<void>;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const antd_1 = require("antd");
|
||||
function render(props) {
|
||||
const { state, oakExecutable, oakExecuting, size, block, type, executeText, buttonProps = {}, action, afterCommit, beforeCommit, } = props.data;
|
||||
const { t, upload, execute } = props.methods;
|
||||
const { state, oakExecutable, oakExecuting, size, block, type, executeText, buttonProps = {}, } = props.data;
|
||||
const { t, onSubmit } = props.methods;
|
||||
const disabled = oakExecuting ||
|
||||
['uploading'].includes(state) ||
|
||||
(oakExecutable !== true && ['uploaded'].includes(state));
|
||||
|
|
@ -20,26 +20,6 @@ function render(props) {
|
|||
text = t('upload');
|
||||
}
|
||||
}
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Button, { type: type, size: size, block: block, disabled: disabled, onClick: async () => {
|
||||
if (oakExecutable) {
|
||||
if (beforeCommit) {
|
||||
const beforeCommitResult = await beforeCommit();
|
||||
if (beforeCommitResult === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await execute(action || undefined);
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
await upload();
|
||||
if (afterCommit) {
|
||||
afterCommit();
|
||||
}
|
||||
}
|
||||
}, ...buttonProps, children: text }));
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Button, { type: type, size: size, block: block, disabled: disabled, onClick: onSubmit, ...buttonProps, children: text }));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@ exports.default = OakComponent({
|
|||
const { errMsg, tempFiles } = await wx.chooseMessageFile({
|
||||
count: selectCount,
|
||||
type: 'all',
|
||||
...(extension && extension.length > 0 ? { extension } : {}),
|
||||
});
|
||||
if (errMsg !== 'chooseMessageFile:ok') {
|
||||
this.triggerEvent('onError', {
|
||||
|
|
@ -259,19 +260,12 @@ exports.default = OakComponent({
|
|||
const { index } = event.currentTarget.dataset;
|
||||
const imageUrl = files[index].url;
|
||||
const urls = files?.filter((ele) => !!ele).map((ele) => ele.url);
|
||||
const detail = {
|
||||
all: files,
|
||||
index,
|
||||
urls,
|
||||
current: imageUrl,
|
||||
};
|
||||
// 预览图片
|
||||
if (!this.props.disablePreview) {
|
||||
const result = await wx.previewImage({
|
||||
urls: urls,
|
||||
current: imageUrl,
|
||||
});
|
||||
this.triggerEvent('onPreview', detail);
|
||||
}
|
||||
},
|
||||
getSort(index = 0) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!-- index.wxml -->
|
||||
<l-button size="long" disabled="{{disabled}}" type="default" bind:lintap="onSubmit">
|
||||
<l-button size="long" disabled="{{disabled}}" bind:lintap="onSubmit">
|
||||
{{ executeText || t('common:submit') }}
|
||||
</l-button>
|
||||
Loading…
Reference in New Issue