You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
15 KiB

7 months ago
<template>
<div class="ns-skeleton" :key="'detail_' + $route.name">
<page-title :title="getTitle" />
<a-page-header v-if="showBack">
<template #extra>
<a-button @click="navigateBack">返回</a-button>
</template>
</a-page-header>
<Skeleton
active
v-for="(detailGroup, index) in getDetail"
:key="index"
:loading="loading"
:paragraph="detailGroup.SkeletonParagraphProps"
:title="detailGroup.SkeletonTitleProps">
<div class="ns-detail">
<a-descriptions :title="detailGroup.title">
<template v-if="detailGroup.items">
<template v-for="(item, index) in detailGroup.items" :key="index">
<a-descriptions-item v-if="item.ifShow">
<template #label v-if="item.label">
<div v-if="item.showTip">
<a-popover title="" class="detailLabelProver">
<template #content>
<span style="margin-top: 10px; white-space: pre-wrap">{{
item.showTip
}}</span>
</template>
<span style="margin-right: 8px">{{ item.label }}</span>
<question-circle-outlined style="option: 0.8; cursor: pointer" /> </a-popover
></div>
<div v-else>{{ item.label }}</div>
</template>
<!--默认-->
<template v-if="!item.type">
<span class="ns-detail-text">{{ item.value }}</span>
</template>
<!--富文本-->
<template v-if="item.type == 'html'">
<div class="ns-detail-html" v-html="item.value"></div>
</template>
<!--链接-->
<template v-if="item.type == 'link'">
<a class="ns-detail-link" target="_blank" :href="item.value">发票链接 </a>
</template>
<!--图片 值为数组则为图片列表 可继续扩展-->
<template v-if="item.type === 'image'">
<template v-if="typeof item.value == 'object'">
<div
class="ns-detail-image-list"
v-for="src in item.value"
:key="src"
style="display: inline-block; margin: 0 5px 5px 0">
<a-image
:width="100"
:src="`/api/op/objs/ParkPic/${src}`"
fallback="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVT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MoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==" />
</div>
</template>
<template v-else>
<a-image
class="ns-detail-image"
:width="100"
:src="item.value"
fallback="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJE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Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==" />
</template>
</template>
<!--表格-->
<template v-else-if="item.type === 'table'">
<ns-basic-table
class="ns-detail-table"
:dataSource="dataRef[item.props.listField]"
:columns="item.props.columns"
:pagination="false"
:rowKey="item.props.rowKey" />
</template>
<template v-for="slot in Object.keys($slots)" :key="slot">
<div v-if="item.type === slot" :class="`ns-detail-${slot}`">
<slot :name="slot" v-bind="item || {}" :dataRef="dataRef" :basicInfo="item">
</slot>
</div>
</template>
</a-descriptions-item>
</template>
</template>
</a-descriptions>
</div>
</Skeleton>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref, PropType, watch } from 'vue';
import { useRoute } from 'vue-router';
import { QuestionCircleOutlined } from '@ant-design/icons-vue';
import { cloneDeep, get, isFunction, isUndefined } from 'lodash-es';
import { Skeleton } from 'ant-design-vue';
import PageTitle from '/nerv-lib/paas/component/page-title/page-title.vue';
import { PropTypes } from '/nerv-lib/util/type';
import { AxiosRequestConfig } from 'axios';
import { useApi } from '/nerv-lib/use/use-api';
import { useNavigate } from '/nerv-lib/use/use-navigate';
export interface DetailItem {
label: string;
name: string;
value?: string;
ifShow?: Boolean | Function;
format?: Function;
type?: 'image' | 'table';
props?: Recordable;
}
export interface DetailGroup {
title: string;
items: Array<DetailItem>;
}
export default defineComponent({
name: 'NsViewDetail',
props: {
detail: {
type: Array as PropType<DetailGroup[]>,
default: () => [],
},
api: {
type: [String, Object, Function] as PropType<string | Function | AxiosRequestConfig>,
default: undefined,
},
title: PropTypes.string,
showBack: PropTypes.bool.def(false),
dataHandle: Function,
},
components: { PageTitle, Skeleton, QuestionCircleOutlined },
setup(props) {
const route = useRoute();
const dataRef = ref([]);
const { navigateBack } = useNavigate();
let loading = ref<boolean>(true);
function request() {
const { api } = props;
if (api) {
const { query, params } = route;
const { httpRequest } = useApi();
httpRequest({ api, params: query, pathParams: params }).then((res) => {
dataRef.value = props.dataHandle ? props.dataHandle(res) : res;
loading.value = false;
});
}
}
const getTitle = computed(() => {
const {
params: { pageTitle },
} = route;
if (pageTitle) return pageTitle;
const { title } = props;
return title;
});
request();
const getDetail = computed(() => {
const detail = cloneDeep(props.detail);
return (detail as Array<DetailGroup>).map((group: DetailGroup) => {
const SkeletonWidth = [];
for (let i = 0; i < group.items.length; i++) {
if (group.items[i].type === 'table') {
SkeletonWidth.push('82%');
} else {
SkeletonWidth.push('20%');
}
}
const { title, items } = group;
return {
title: title,
items: items.map((item) => {
const { ifShow } = item;
item.value = get(dataRef.value, item.name);
item.ifShow = isFunction(ifShow)
? ifShow(dataRef.value)
: isUndefined(ifShow)
? true
: ifShow;
if (item.format) {
item.value = item.format(item.value, dataRef.value);
}
return item;
}),
SkeletonParagraphProps: {
rows: items.length,
width: SkeletonWidth,
},
SkeletonTitleProps: {
width: 150,
},
};
});
});
return {
dataRef,
getDetail,
loading,
getTitle,
navigateBack,
request,
};
},
methods: {
onBack() {
this.$router.go(-1);
},
},
});
</script>
<style lang="less" scoped>
.ant-page-header {
padding: 0 24px;
margin-bottom: 15px;
}
:deep(.ant-page-header-heading-extra) {
margin-right: auto !important;
margin-left: 0;
}
:deep(.ant-skeleton-paragraph) {
display: inline;
// display: flex;
// flex-wrap: wrap;
}
:deep(.ant-skeleton-paragraph li:nth-child(n)) {
float: left;
display: inline;
margin-right: 130px;
margin-top: 16px;
margin-bottom: 4px;
}
:deep(.ant-skeleton-paragraph li:nth-child(3n + 1)) {
clear: both;
display: inline;
}
:deep(.ant-skeleton-content) {
padding: 0 8px 10px 10px;
}
.ns-detail {
padding: 0 24px 24px 24px;
}
.ns-detail-table {
width: 100%;
}
:deep(.ant-table-wrapper) {
padding: 0;
}
.ns-detail-html {
:deep(table) {
border-top: 1px solid #ffffff;
border-left: 1px solid #ffffff;
}
:deep(th) {
border-right: 1px solid #ffffff;
font-size: 13px;
padding-top: 5px;
padding-bottom: 5px;
font-weight: normal;
background: #eff0f2;
}
:deep(td) {
border-top: 1px solid #ffffff;
border-right: 1px solid #ffffff;
padding-top: 5px;
padding-bottom: 5px;
font-size: 12px;
color: #606060;
text-align: center;
:deep(text) {
border-bottom: 1px solid #ffffff;
}
background: rgba(240, 242, 245, 0.5);
}
:deep(p) {
font-size: 12px;
color: #898e91;
}
}
</style>