| | |
| | | :row-key="rowKey" |
| | | :style="tableStyle" |
| | | tooltip-effect="dark" |
| | | :tooltip-options="{ appendTo: 'body' }" |
| | | :expand-row-keys="expandRowKeys" |
| | | :show-summary="isShowSummary" |
| | | :summary-method="summaryMethod" |
| | |
| | | <template v-for="(o, key) in item.operation" |
| | | :key="key"> |
| | | <el-button v-show="o.type != 'upload'" |
| | | v-if="o.showHide ? o.showHide(scope.row) : true" |
| | | v-if="isOperationVisible(o, scope.row)" |
| | | :disabled="isOperationDisabled(o, scope.row)" |
| | | :loading="isOperationLoading(o, scope.row)" |
| | | :plain="o.plain" |
| | | type="primary" |
| | | :style="{ |
| | |
| | | " |
| | | v-if="o.type == 'upload'" |
| | | style="display: inline-block; width: 50px" |
| | | v-show="o.showHide ? o.showHide(scope.row) : true" |
| | | v-show="isOperationVisible(o, scope.row)" |
| | | :headers="uploadHeader" |
| | | :before-upload="(file) => beforeUpload(file, scope.$index)" |
| | | :on-change=" |
| | |
| | | }; |
| | | |
| | | const formatters = (val, format) => { |
| | | return typeof format === "function" ? format(val) : val; |
| | | if (typeof format === "function") return format(val); |
| | | if (format && typeof format === "object") return format[val] ?? val; |
| | | return val; |
| | | }; |
| | | |
| | | // Props(使用 defineProps 的非 TS 形式) |
| | |
| | | const uploadRefs = ref([]); |
| | | const currentFiles = ref({}); |
| | | const uploadKeys = ref({}); |
| | | const parentMethods = inject("parentMethods", {}); |
| | | |
| | | const indexMethod = index => { |
| | | return (props.page.current - 1) * props.page.size + index + 1; |
| | |
| | | const goLink = (row, linkMethod) => { |
| | | if (!linkMethod) { |
| | | return ElMessage.warning("请配置 link 事件"); |
| | | } |
| | | if (typeof linkMethod === "function") { |
| | | linkMethod(row); |
| | | return; |
| | | } |
| | | const parentMethod = getParentMethod(linkMethod); |
| | | if (typeof parentMethod === "function") { |
| | |
| | | |
| | | // 获取父组件方法(示例实现) |
| | | const getParentMethod = methodName => { |
| | | const parentMethods = inject("parentMethods", {}); |
| | | return parentMethods[methodName]; |
| | | return parentMethods?.[methodName]; |
| | | }; |
| | | |
| | | const dataTypeFn = (val, format) => { |
| | |
| | | return typeof operation.disabled === "function" |
| | | ? !!operation.disabled(row) |
| | | : !!operation.disabled; |
| | | }; |
| | | |
| | | const isOperationVisible = (operation, row) => { |
| | | const visibleHandler = operation?.showHide ?? operation?.show; |
| | | if (visibleHandler === undefined) return true; |
| | | return typeof visibleHandler === "function" ? !!visibleHandler(row) : !!visibleHandler; |
| | | }; |
| | | |
| | | const isOperationLoading = (operation, row) => { |
| | | if (!operation?.loading) return false; |
| | | return typeof operation.loading === "function" |
| | | ? !!operation.loading(row) |
| | | : !!operation.loading; |
| | | }; |
| | | |
| | | const parseHexToRgb = hex => { |
| | |
| | | // 文件上传前校验 |
| | | const beforeUpload = (rawFile, index) => { |
| | | currentFiles.value[index] = {}; |
| | | if (rawfile.size > 1024 * 1024 * 10 * 10) { |
| | | if (rawFile.size > 1024 * 1024 * 10 * 10) { |
| | | ElMessage.error("上传文件不超过10M"); |
| | | return false; |
| | | } |