tav-ui
Version:
359 lines (356 loc) • 16.7 kB
JavaScript
import { ref, useSlots, watch, computed, onBeforeUnmount, openBlock, createElementBlock, unref, normalizeClass, createElementVNode, renderSlot, Fragment, toDisplayString, createCommentVNode, normalizeProps, mergeProps, createBlock, createVNode, withCtx, createSlots, guardReactiveProps, defineComponent } from 'vue';
import { ButtonGroup } from 'ant-design-vue';
import { TaFileTypeSelect } from './components/FileTypeSelect/index3.mjs';
import { TaFileActionUpload } from './components/FileActionUpload/index3.mjs';
import { TaFileTable } from './components/FileTable/index3.mjs';
import './typings/index2.mjs';
import { DEFAULT_APIPARAMS, DEFAULT_FILE_ID, DEFAULT_FILE_CLASSNAME, DEFAULT_FILEACTIONS_ID, DEFAULT_FILEACTIONS_CLASSNAME } from './consts2.mjs';
import { TaFileActionUploadLink } from './components/FileActionUploadLink/index4.mjs';
import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';
import { fileProps, fileEmits } from './typings/types2.mjs';
const _hoisted_1 = ["id"];
const _hoisted_2 = ["id"];
const __default__ = {
name: "TaFile",
inheritAttrs: false
};
function setup(__props, { expose, emit: emits }) {
const props = __props;
const headerElRef = ref();
const slots = useSlots();
if (JSON.stringify(props.fileActualIds) && JSON.stringify(props.fileActualIds) !== "[]") {
console.error('[tavui TaFile] not pass value to "fileActualIds", "fileActualIds" only accpet "[]" to get actualIds');
}
const fileApiParams = ref(props.apiParams);
const fileTableInnerUploadDataSource = ref(props.fileTable?.__uploadDataSource);
const fileTableInnerUploadLinkDataSource = ref(props.fileTable?.__uploadLinkDataSource);
watch(() => [
JSON.stringify(props.apiParams),
JSON.stringify(props.fileTable?.__uploadDataSource ?? []),
JSON.stringify(props.fileTable?.__uploadLinkDataSource ?? [])
], async ([curapiParams, curuploadDataSource, curuploadLinkDataSource], [preapiParams, preuploadDataSource, preuploadLinkDataSource]) => {
if (curapiParams !== preapiParams) {
fileApiParams.value = props.apiParams;
}
if (curuploadDataSource !== preuploadDataSource) {
fileTableInnerUploadDataSource.value = props.fileTable?.__uploadDataSource;
}
if (curuploadLinkDataSource !== preuploadLinkDataSource) {
fileTableInnerUploadLinkDataSource.value = props.fileTable?.__uploadLinkDataSource;
}
});
const fileTypeSelectRef = ref();
const fileTypeSelectProps = computed(() => {
return {
...props.fileTypeSelect,
mode: props.mode,
apiParams: {
appId: fileApiParams.value.appId,
moduleCode: fileApiParams.value.moduleCode,
typeCodes: fileApiParams.value.typeCodes,
permissionControl: fileApiParams.value.permissionControl ?? DEFAULT_APIPARAMS.permissionControl,
...props.fileTypeSelect?.apiParams ?? {}
}
};
});
const fileActionUploadRef = ref();
const fileActionUploadProps = computed(() => {
return {
...props.fileActionUpload,
mode: props.mode,
apiParams: {
appId: fileApiParams.value.appId,
moduleCode: fileApiParams.value.moduleCode,
typeCode: fileApiParams.value.typeCode,
businessId: fileApiParams.value.businessId,
businessKey: fileApiParams.value.businessKey,
businessParamsJson: fileApiParams.value.businessParamsJson ?? DEFAULT_APIPARAMS.businessParamsJson,
fileName: fileApiParams.value.fileName,
...props.fileActionUpload?.apiParams ?? {}
}
};
});
const fileActionUploadLinkRef = ref();
const fileActionUploadLinkProps = computed(() => {
return {
...props.fileActionUploadLink,
mode: props.mode,
apiParams: {
appId: fileApiParams.value.appId,
moduleCode: fileApiParams.value.moduleCode,
typeCode: fileApiParams.value.typeCode,
businessId: fileApiParams.value.businessId,
businessKey: fileApiParams.value.businessKey,
businessParamsJson: fileApiParams.value.businessParamsJson ?? DEFAULT_APIPARAMS.businessParamsJson,
...props.fileActionUploadLink?.apiParams ?? {}
},
getFormContainer: () => headerElRef.value
};
});
const fileTableRef = ref();
const fileTableProps = computed(() => {
return {
...props.fileTable,
mode: props.mode,
apiParams: {
typeCode: fileApiParams.value.typeCode,
businessId: fileApiParams.value.businessId,
businessParamsJson: fileApiParams.value.businessParamsJson ?? DEFAULT_APIPARAMS.businessParamsJson,
appId: fileApiParams.value.appId,
businessCheck: fileApiParams.value.businessCheck ?? DEFAULT_APIPARAMS.businessCheck,
businessDisplayItem: fileApiParams.value.businessDisplayItem,
businessIds: fileApiParams.value.businessIds,
businessKey: fileApiParams.value.businessKey,
businessSearchItems: fileApiParams.value.businessSearchItems,
endTime: fileApiParams.value.endTime,
excludeDeleted: fileApiParams.value.excludeDeleted,
excludeStaging: fileApiParams.value.excludeStaging,
id: fileApiParams.value.id,
moduleCode: fileApiParams.value.moduleCode,
owners: fileApiParams.value.owners,
permissionControl: fileApiParams.value.permissionControl ?? DEFAULT_APIPARAMS.permissionControl,
searchValue: fileApiParams.value.searchValue,
startTime: fileApiParams.value.startTime,
suffix: fileApiParams.value.suffix,
typeCodes: fileApiParams.value.typeCodes,
visibleSubModules: fileApiParams.value.visibleSubModules,
file: fileApiParams.value.file,
fileActualId: fileApiParams.value.fileActualId,
instantUpdate: fileApiParams.value.instantUpdate,
actualIds: fileApiParams.value.actualIds,
...props.fileTable?.apiParams ?? {}
},
__uploadDataSource: fileTableInnerUploadDataSource.value ?? props.fileTable?.__uploadDataSource,
__uploadLinkDataSource: fileTableInnerUploadLinkDataSource.value ?? props.fileTable?.__uploadLinkDataSource
};
});
function handleFileTypeSelectChange(...args) {
const data = args;
const [typeCode, option] = data;
fileApiParams.value = {
...fileApiParams.value,
typeCode: typeCode === void 0 && option === void 0 ? "" : `${typeCode}`
};
emits("fileTypeSelect:change", ...args);
}
function handleFileTypeSelectOptionsChange(...args) {
emits("fileTypeSelect:optionsChange", ...args);
}
function handleFileActionUploadChangeValidateSuccessChange(...args) {
emits("fileActionUpload:validateSuccessChange", ...args);
}
function handleFileActionUploadChangeValidateFailureChange(...args) {
emits("fileActionUpload:validateFailureChange", ...args);
}
function handleFileActionUploadChange(...args) {
emits("fileActionUpload:uploadedChange", ...args);
const [files] = args;
fileTableInnerUploadDataSource.value = [...files];
}
function handleFileActionUploadLinkChangeValidateSuccessChange(...args) {
emits("fileActionUploadLink:validateSuccessChange", ...args);
}
function handleFileActionUploadLinkChangeValidateFailureChange(...args) {
emits("fileActionUploadLink:validateFailureChange", ...args);
}
function handleFileActionUploadLinkChange(...args) {
emits("fileActionUploadLink:uploadedChange", ...args);
const [files] = args;
fileTableInnerUploadLinkDataSource.value = [...files];
}
function handleFileTableActualidsChange(...args) {
const _args = args;
emits("update:fileActualIds", ..._args);
}
function handleFileTableRowEdit(...args) {
const _args = args;
emits("fileTable:rowEdit", ..._args);
}
function handleFileTableRowUpdate(...args) {
const _args = args;
emits("fileTable:rowUpdate", ..._args);
}
function handleFileTableRowDelete(...args) {
const _args = args;
emits("fileTable:rowDelete", ..._args);
}
async function fileTableReload(params) {
await fileTableRef.value?.reload?.(params);
}
async function fileTableCreateRows(...args) {
await fileTableRef.value?.createRows(...args);
}
async function fileTableReadRows(...args) {
const rows = await fileTableRef.value?.readRows(...args);
return rows;
}
async function fileTableUpdateRows(...args) {
await fileTableRef.value?.updateRows(...args);
}
async function fileTableDeleteRows(...args) {
await fileTableRef.value?.deleteRows(...args);
}
async function getFileTableSelectRowKeys() {
return await fileTableRef.value?.tableProRef?.instance?.getSelectRowKeys();
}
async function clearFileTableSelectedRowByKey(key) {
return await fileTableRef.value?.tableProRef?.instance?.clearSelectedRowByKey(key);
}
async function getFileTableSelectRows() {
return await fileTableRef.value?.tableProRef?.instance?.getSelectRows();
}
async function clearFileTableSelectedRows() {
return await fileTableRef.value?.tableProRef?.instance?.clearSelectedRows();
}
function cleanup() {
fileTypeSelectRef.value?.cleanup();
fileActionUploadRef.value?.cleanup();
fileActionUploadLinkRef.value?.cleanup();
fileTableRef.value?.cleanup();
}
onBeforeUnmount(() => {
cleanup();
});
expose({
fileTypeSelectRef,
fileActionUploadRef,
fileActionUploadLinkRef,
fileTableRef,
fileTableReload,
fileTableCreateRows,
fileTableReadRows,
fileTableUpdateRows,
fileTableDeleteRows,
getFileTableSelectRowKeys,
clearFileTableSelectedRowByKey,
getFileTableSelectRows,
clearFileTableSelectedRows,
cleanup
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("section", {
id: unref(DEFAULT_FILE_ID),
class: normalizeClass(unref(DEFAULT_FILE_CLASSNAME))
}, [
props.headerVisible ? (openBlock(), createElementBlock("section", {
key: 0,
ref: (_value, _refs) => {
_refs["headerElRef"] = _value;
headerElRef.value = _value;
},
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-header`)
}, [
createElementVNode("section", {
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-title-wrapper`)
}, [
unref(slots).FileTitle ? renderSlot(_ctx.$slots, "FileTitle", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
props.titleVisible ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-title`)
}, toDisplayString(props.title), 3)) : createCommentVNode("v-if", true)
], 2112))
], 2),
props.headerActionsVisible && props.mode !== "read" ? (openBlock(), createElementBlock("section", {
key: 0,
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-header-actions`)
}, [
createElementVNode("section", {
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-type-select-wrapper`)
}, [
unref(slots).FileTypeSelect ? renderSlot(_ctx.$slots, "FileTypeSelect", normalizeProps(mergeProps({ key: 0 }, unref(fileTypeSelectProps)))) : (openBlock(), createBlock(unref(TaFileTypeSelect), mergeProps({
key: 1,
ref: (_value, _refs) => {
_refs["fileTypeSelectRef"] = _value;
fileTypeSelectRef.value = _value;
}
}, unref(fileTypeSelectProps), {
onChange: handleFileTypeSelectChange,
onOptionsChange: handleFileTypeSelectOptionsChange
}), null, 16))
], 2),
createElementVNode("section", {
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-actions-wrapper`)
}, [
unref(slots).FileActions ? renderSlot(_ctx.$slots, "FileActions", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
props.fileActionsVisible ? (openBlock(), createElementBlock("section", {
key: 0,
id: unref(DEFAULT_FILEACTIONS_ID),
class: normalizeClass(unref(DEFAULT_FILEACTIONS_CLASSNAME))
}, [
createVNode(unref(ButtonGroup), null, {
default: withCtx(() => [
unref(slots)["FileActionPrefix"] ? renderSlot(_ctx.$slots, "FileActionPrefix", { key: 0 }) : createCommentVNode("v-if", true),
unref(slots)["FileActionUpload"] ? renderSlot(_ctx.$slots, "FileActionUpload", normalizeProps(mergeProps({ key: 1 }, unref(fileActionUploadProps)))) : (openBlock(), createBlock(unref(TaFileActionUpload), mergeProps({
key: 2,
ref: (_value, _refs) => {
_refs["fileActionUploadRef"] = _value;
fileActionUploadRef.value = _value;
}
}, unref(fileActionUploadProps), {
onValidateSuccessChange: handleFileActionUploadChangeValidateSuccessChange,
onValidateFailureChange: handleFileActionUploadChangeValidateFailureChange,
onUploadedChange: handleFileActionUploadChange
}), createSlots({ _: 2 }, [
unref(slots)["FileActionUploadButton"] ? {
name: "FileActionUploadButton",
fn: withCtx((data) => [
renderSlot(_ctx.$slots, "FileActionUploadButton", normalizeProps(guardReactiveProps(data || {})))
])
} : void 0
]), 1040)),
unref(slots)["FileActionMiddle"] ? renderSlot(_ctx.$slots, "FileActionMiddle", { key: 3 }) : createCommentVNode("v-if", true),
unref(slots)["FileActionUploadLink"] ? renderSlot(_ctx.$slots, "FileActionUploadLink", normalizeProps(mergeProps({ key: 4 }, unref(fileActionUploadLinkProps)))) : (openBlock(), createBlock(unref(TaFileActionUploadLink), mergeProps({
key: 5,
ref: (_value, _refs) => {
_refs["fileActionUploadLinkRef"] = _value;
fileActionUploadLinkRef.value = _value;
}
}, unref(fileActionUploadLinkProps), {
onValidateSuccessChange: handleFileActionUploadLinkChangeValidateSuccessChange,
onValidateFailureChange: handleFileActionUploadLinkChangeValidateFailureChange,
onUploadedChange: handleFileActionUploadLinkChange
}), null, 16, ["onValidateSuccessChange", "onValidateFailureChange"])),
unref(slots)["FileActionSuffix"] ? renderSlot(_ctx.$slots, "FileActionSuffix", { key: 6 }) : createCommentVNode("v-if", true)
]),
_: 3
})
], 10, _hoisted_2)) : createCommentVNode("v-if", true)
], 2112))
], 2)
], 2)) : createCommentVNode("v-if", true)
], 2)) : createCommentVNode("v-if", true),
createElementVNode("section", {
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-main`)
}, [
createElementVNode("section", {
class: normalizeClass(`${unref(DEFAULT_FILE_CLASSNAME)}-table-wrapper`)
}, [
unref(slots).FileTable ? renderSlot(_ctx.$slots, "FileTable", normalizeProps(mergeProps({ key: 0 }, unref(fileTableProps)))) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
createCommentVNode(' @change="handleFileTableChange" '),
createVNode(unref(TaFileTable), mergeProps({
ref: (_value, _refs) => {
_refs["fileTableRef"] = _value;
fileTableRef.value = _value;
}
}, unref(fileTableProps), {
onActualidsChange: handleFileTableActualidsChange,
onRowEdit: handleFileTableRowEdit,
onRowUpdate: handleFileTableRowUpdate,
onRowDelete: handleFileTableRowDelete
}), null, 16)
], 2112))
], 2)
], 2),
createCommentVNode(' <section :class="`${DEFAULT_FILE_CLASSNAME}-footer`"></section> ')
], 10, _hoisted_1);
};
}
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: fileProps,
emits: fileEmits,
setup
});
var File = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/file/src/index.vue"]]);
export { File as default };
//# sourceMappingURL=index2.mjs.map