UNPKG

tav-ui

Version:
363 lines (358 loc) 17 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var antDesignVue = require('ant-design-vue'); var index = require('./components/FileTypeSelect/index3.js'); var index$1 = require('./components/FileActionUpload/index3.js'); var index$3 = require('./components/FileTable/index3.js'); require('./typings/index2.js'); var consts = require('./consts2.js'); var index$2 = require('./components/FileActionUploadLink/index4.js'); var pluginVue_exportHelper = require('../../../../_virtual/plugin-vue_export-helper.js'); var types = require('./typings/types2.js'); 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 = vue.ref(); const slots = vue.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 = vue.ref(props.apiParams); const fileTableInnerUploadDataSource = vue.ref(props.fileTable?.__uploadDataSource); const fileTableInnerUploadLinkDataSource = vue.ref(props.fileTable?.__uploadLinkDataSource); vue.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 = vue.ref(); const fileTypeSelectProps = vue.computed(() => { return { ...props.fileTypeSelect, mode: props.mode, apiParams: { appId: fileApiParams.value.appId, moduleCode: fileApiParams.value.moduleCode, typeCodes: fileApiParams.value.typeCodes, permissionControl: fileApiParams.value.permissionControl ?? consts.DEFAULT_APIPARAMS.permissionControl, ...props.fileTypeSelect?.apiParams ?? {} } }; }); const fileActionUploadRef = vue.ref(); const fileActionUploadProps = vue.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 ?? consts.DEFAULT_APIPARAMS.businessParamsJson, fileName: fileApiParams.value.fileName, ...props.fileActionUpload?.apiParams ?? {} } }; }); const fileActionUploadLinkRef = vue.ref(); const fileActionUploadLinkProps = vue.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 ?? consts.DEFAULT_APIPARAMS.businessParamsJson, ...props.fileActionUploadLink?.apiParams ?? {} }, getFormContainer: () => headerElRef.value }; }); const fileTableRef = vue.ref(); const fileTableProps = vue.computed(() => { return { ...props.fileTable, mode: props.mode, apiParams: { typeCode: fileApiParams.value.typeCode, businessId: fileApiParams.value.businessId, businessParamsJson: fileApiParams.value.businessParamsJson ?? consts.DEFAULT_APIPARAMS.businessParamsJson, appId: fileApiParams.value.appId, businessCheck: fileApiParams.value.businessCheck ?? consts.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 ?? consts.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(); } vue.onBeforeUnmount(() => { cleanup(); }); expose({ fileTypeSelectRef, fileActionUploadRef, fileActionUploadLinkRef, fileTableRef, fileTableReload, fileTableCreateRows, fileTableReadRows, fileTableUpdateRows, fileTableDeleteRows, getFileTableSelectRowKeys, clearFileTableSelectedRowByKey, getFileTableSelectRows, clearFileTableSelectedRows, cleanup }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("section", { id: vue.unref(consts.DEFAULT_FILE_ID), class: vue.normalizeClass(vue.unref(consts.DEFAULT_FILE_CLASSNAME)) }, [ props.headerVisible ? (vue.openBlock(), vue.createElementBlock("section", { key: 0, ref: (_value, _refs) => { _refs["headerElRef"] = _value; headerElRef.value = _value; }, class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-header`) }, [ vue.createElementVNode("section", { class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-title-wrapper`) }, [ vue.unref(slots).FileTitle ? vue.renderSlot(_ctx.$slots, "FileTitle", { key: 0 }) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [ props.titleVisible ? (vue.openBlock(), vue.createElementBlock("div", { key: 0, class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-title`) }, vue.toDisplayString(props.title), 3)) : vue.createCommentVNode("v-if", true) ], 2112)) ], 2), props.headerActionsVisible && props.mode !== "read" ? (vue.openBlock(), vue.createElementBlock("section", { key: 0, class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-header-actions`) }, [ vue.createElementVNode("section", { class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-type-select-wrapper`) }, [ vue.unref(slots).FileTypeSelect ? vue.renderSlot(_ctx.$slots, "FileTypeSelect", vue.normalizeProps(vue.mergeProps({ key: 0 }, vue.unref(fileTypeSelectProps)))) : (vue.openBlock(), vue.createBlock(vue.unref(index.TaFileTypeSelect), vue.mergeProps({ key: 1, ref: (_value, _refs) => { _refs["fileTypeSelectRef"] = _value; fileTypeSelectRef.value = _value; } }, vue.unref(fileTypeSelectProps), { onChange: handleFileTypeSelectChange, onOptionsChange: handleFileTypeSelectOptionsChange }), null, 16)) ], 2), vue.createElementVNode("section", { class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-actions-wrapper`) }, [ vue.unref(slots).FileActions ? vue.renderSlot(_ctx.$slots, "FileActions", { key: 0 }) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [ props.fileActionsVisible ? (vue.openBlock(), vue.createElementBlock("section", { key: 0, id: vue.unref(consts.DEFAULT_FILEACTIONS_ID), class: vue.normalizeClass(vue.unref(consts.DEFAULT_FILEACTIONS_CLASSNAME)) }, [ vue.createVNode(vue.unref(antDesignVue.ButtonGroup), null, { default: vue.withCtx(() => [ vue.unref(slots)["FileActionPrefix"] ? vue.renderSlot(_ctx.$slots, "FileActionPrefix", { key: 0 }) : vue.createCommentVNode("v-if", true), vue.unref(slots)["FileActionUpload"] ? vue.renderSlot(_ctx.$slots, "FileActionUpload", vue.normalizeProps(vue.mergeProps({ key: 1 }, vue.unref(fileActionUploadProps)))) : (vue.openBlock(), vue.createBlock(vue.unref(index$1.TaFileActionUpload), vue.mergeProps({ key: 2, ref: (_value, _refs) => { _refs["fileActionUploadRef"] = _value; fileActionUploadRef.value = _value; } }, vue.unref(fileActionUploadProps), { onValidateSuccessChange: handleFileActionUploadChangeValidateSuccessChange, onValidateFailureChange: handleFileActionUploadChangeValidateFailureChange, onUploadedChange: handleFileActionUploadChange }), vue.createSlots({ _: 2 }, [ vue.unref(slots)["FileActionUploadButton"] ? { name: "FileActionUploadButton", fn: vue.withCtx((data) => [ vue.renderSlot(_ctx.$slots, "FileActionUploadButton", vue.normalizeProps(vue.guardReactiveProps(data || {}))) ]) } : void 0 ]), 1040)), vue.unref(slots)["FileActionMiddle"] ? vue.renderSlot(_ctx.$slots, "FileActionMiddle", { key: 3 }) : vue.createCommentVNode("v-if", true), vue.unref(slots)["FileActionUploadLink"] ? vue.renderSlot(_ctx.$slots, "FileActionUploadLink", vue.normalizeProps(vue.mergeProps({ key: 4 }, vue.unref(fileActionUploadLinkProps)))) : (vue.openBlock(), vue.createBlock(vue.unref(index$2.TaFileActionUploadLink), vue.mergeProps({ key: 5, ref: (_value, _refs) => { _refs["fileActionUploadLinkRef"] = _value; fileActionUploadLinkRef.value = _value; } }, vue.unref(fileActionUploadLinkProps), { onValidateSuccessChange: handleFileActionUploadLinkChangeValidateSuccessChange, onValidateFailureChange: handleFileActionUploadLinkChangeValidateFailureChange, onUploadedChange: handleFileActionUploadLinkChange }), null, 16, ["onValidateSuccessChange", "onValidateFailureChange"])), vue.unref(slots)["FileActionSuffix"] ? vue.renderSlot(_ctx.$slots, "FileActionSuffix", { key: 6 }) : vue.createCommentVNode("v-if", true) ]), _: 3 }) ], 10, _hoisted_2)) : vue.createCommentVNode("v-if", true) ], 2112)) ], 2) ], 2)) : vue.createCommentVNode("v-if", true) ], 2)) : vue.createCommentVNode("v-if", true), vue.createElementVNode("section", { class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-main`) }, [ vue.createElementVNode("section", { class: vue.normalizeClass(`${vue.unref(consts.DEFAULT_FILE_CLASSNAME)}-table-wrapper`) }, [ vue.unref(slots).FileTable ? vue.renderSlot(_ctx.$slots, "FileTable", vue.normalizeProps(vue.mergeProps({ key: 0 }, vue.unref(fileTableProps)))) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [ vue.createCommentVNode(' @change="handleFileTableChange" '), vue.createVNode(vue.unref(index$3.TaFileTable), vue.mergeProps({ ref: (_value, _refs) => { _refs["fileTableRef"] = _value; fileTableRef.value = _value; } }, vue.unref(fileTableProps), { onActualidsChange: handleFileTableActualidsChange, onRowEdit: handleFileTableRowEdit, onRowUpdate: handleFileTableRowUpdate, onRowDelete: handleFileTableRowDelete }), null, 16) ], 2112)) ], 2) ], 2), vue.createCommentVNode(' <section :class="`${DEFAULT_FILE_CLASSNAME}-footer`"></section> ') ], 10, _hoisted_1); }; } const _sfc_main = /* @__PURE__ */ vue.defineComponent({ ...__default__, props: types.fileProps, emits: types.fileEmits, setup }); var File = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/file/src/index.vue"]]); exports["default"] = File; //# sourceMappingURL=index2.js.map