This commit is contained in:
2024-10-19 10:38:52 +08:00
parent 713f24ca3e
commit 00759864ed
75 changed files with 9465 additions and 2063 deletions

View File

@@ -60,6 +60,12 @@
label: '现金支付',
key: 'cashPayment',
icon: 'PayCircleOutlined'
},
{
value: 16,
label: '代付',
key: 'friendPayment',
icon: 'https://oss.wsdns.cn/20241002/3fe17586c7394a1290fd0dae03eb1f24.png'
}
]);

View File

@@ -1,164 +1,166 @@
<template>
<ele-modal
width="75%"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
<ele-modal
width="75%"
:visible="visible"
:maskClosable="false"
:title="title"
:footer="null"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:datasource="datasource"
:columns="columns"
:customRow="customRow"
:pagination="false"
>
<template #toolbar>
<div class="ele-cell">
<div class="ele-cell-content">
<a-space>
<a-upload
v-if="type == 'video'"
:show-upload-list="false"
:customRequest="onUpload"
:accept="'.mp4'"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传视频</span>
</a-button>
</a-upload>
<a-upload
v-else-if="type == 'audio'"
:show-upload-list="false"
:customRequest="onUpload"
:accept="'.mp3'"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传音频</span>
</a-button>
</a-upload>
<a-upload
v-else-if="type == 'file'"
:show-upload-list="false"
:customRequest="onUpload"
:accept="'.xls,.xlsx,.pdf,.doc,.docx'"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传文件</span>
</a-button>
</a-upload>
<a-upload
v-else
:show-upload-list="false"
:accept="'image/*,application/*'"
:customRequest="onUpload"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传图片</span>
</a-button>
</a-upload>
<a-select
show-search
allow-clear
v-model:value="dictDataId"
optionFilterProp="label"
:options="groupList"
style="margin-left: 20px; width: 200px"
placeholder="请选择分组"
@select="onGroupId"
/>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 240px"
@search="reload"
@pressEnter="reload"
/>
</a-space>
</div>
<a-button
style="margin-right: 20px"
@click="openUrl('/cms/photo/dict')"
>管理分组
</a-button
>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'path'">
<!-- 文件类型 -->
<template v-if="!isImage(record.path)">
<span class="ele-text-secondary">[文件]</span>
</template>
<!-- 含http -->
<template v-else-if="record.path.indexOf('http') == 0">
<a-image
:src="`${record.path}`"
:preview="{
<template #toolbar>
<div class="ele-cell">
<div class="ele-cell-content">
<a-space>
<a-upload
v-if="type == 'video'"
:show-upload-list="false"
:customRequest="onUpload"
:accept="'.mp4'"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传视频</span>
</a-button>
</a-upload>
<a-upload
v-else-if="type == 'audio'"
:show-upload-list="false"
:customRequest="onUpload"
:accept="'.mp3'"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传音频</span>
</a-button>
</a-upload>
<a-upload
v-else-if="type == 'file'"
:show-upload-list="false"
:customRequest="onUpload"
:accept="'.xls,.xlsx,.pdf,.doc,.docx'"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传文件</span>
</a-button>
</a-upload>
<a-upload
v-else
:show-upload-list="false"
:accept="'image/*,application/*'"
:customRequest="onUpload"
>
<a-button type="primary" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传图片</span>
</a-button>
</a-upload>
<a-select
show-search
allow-clear
v-model:value="dictDataId"
optionFilterProp="label"
:options="groupList"
style="margin-left: 20px; width: 200px"
placeholder="请选择分组"
@select="onGroupId"
/>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
style="width: 240px"
@search="reload"
@pressEnter="reload"
/>
</a-space>
</div>
<a-button
style="margin-right: 20px"
@click="openUrl('/cms/photo/dict')"
>管理分组
</a-button
>
</div>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'path'">
<!-- 文件类型 -->
<template v-if="!isImage(record.path)">
<span class="ele-text-secondary">[文件]</span>
</template>
<!-- 含http -->
<template v-else-if="record.path.indexOf('http') == 0">
<div class="bg-gray-300">
<a-image
:src="`${record.path}`"
:preview="{
src: `${record.downloadUrl}`
}"
:width="100"
/>
</template>
<!-- path -->
<template v-else>
<a-image
:src="`https://oss.wsdns.cn/${record.path}`"
:width="120"
/>
</template>
</template>
<template v-if="column.dataIndex === 'name'">
<a-space class="ele-cell" style="display: flex">
<span>{{ record.name }}</span>
<EditOutlined title="编辑" @click="openEdit(record)"/>
</a-space>
</template>
<template v-if="column.key === 'action'">
<template v-if="pageId == record.pageId">
<a-radio v-model:checked="checked" @click="onRadio(record)"/>
</template>
<template v-else>
<a-space>
<lebal>
<a-radio @click="onRadio(record)"/>
<a class="ele-text-success">选择</a>
</lebal>
<a-divider type="vertical"/>
<a class="ele-text-placeholder">编辑</a>
<a-divider type="vertical"/>
<a class="ele-text-placeholder">删除</a>
</a-space>
</template>
</template>
</template>
</ele-pro-table>
</ele-modal>
<!-- 编辑弹窗 -->
<FileRecordEdit v-model:visible="showEdit" :data="current" @done="reload"/>
:width="100"
/>
</div>
</template>
<!-- path -->
<template v-else>
<a-image
:src="`https://oss.wsdns.cn/${record.path}`"
:width="120"
/>
</template>
</template>
<template v-if="column.dataIndex === 'name'">
<a-space class="ele-cell" style="display: flex">
<span>{{ record.name }}</span>
<EditOutlined title="编辑" @click="openEdit(record)"/>
</a-space>
</template>
<template v-if="column.key === 'action'">
<template v-if="pageId == record.pageId">
<a-radio v-model:checked="checked" @click="onRadio(record)"/>
</template>
<template v-else>
<a-space>
<lebal>
<a-radio @click="onRadio(record)"/>
<a class="ele-text-success">选择</a>
</lebal>
<a-divider type="vertical"/>
<a class="ele-text-placeholder">编辑</a>
<a-divider type="vertical"/>
<a class="ele-text-placeholder">删除</a>
</a-space>
</template>
</template>
</template>
</ele-pro-table>
</ele-modal>
<!-- 编辑弹窗 -->
<FileRecordEdit v-model:visible="showEdit" :data="current" @done="reload"/>
</template>
<script lang="ts" setup>
import {ref, watch} from 'vue';
import {
ColumnItem,
DatasourceFunction
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import {pageFiles, uploadOss, uploadOssByGroupId} from '@/api/system/file';
import {EleProTable, messageLoading} from 'ele-admin-pro';
@@ -171,24 +173,24 @@ import {message} from 'ant-design-vue/es';
import FileRecordEdit from './file-record-edit.vue';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 标题
title?: string;
// 文件类型
type?: string;
// 修改回显的数据
data?: FileRecord | null;
// 弹窗是否打开
visible: boolean;
// 标题
title?: string;
// 文件类型
type?: string;
// 修改回显的数据
data?: FileRecord | null;
}>();
const emit = defineEmits<{
(e: 'done', data: FileRecord): void;
(e: 'update:visible', visible: boolean): void;
(e: 'done', data: FileRecord): void;
(e: 'update:visible', visible: boolean): void;
}>();
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
emit('update:visible', value);
};
// 搜索内容
@@ -205,190 +207,190 @@ const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id'
},
{
title: '图片',
dataIndex: 'path',
key: 'path'
},
{
title: '名称',
dataIndex: 'name',
key: 'name'
},
{
title: '大小',
dataIndex: 'length',
key: 'length',
customRender: ({text}) => {
if (text < 1024) {
return text + 'B';
} else if (text < 1024 * 1024) {
return (text / 1024).toFixed(1) + 'KB';
} else if (text < 1024 * 1024 * 1024) {
return (text / 1024 / 1024).toFixed(1) + 'M';
} else {
return (text / 1024 / 1024 / 1024).toFixed(1) + 'G';
}
}
},
{
title: '操作',
key: 'action',
align: 'center'
{
title: 'ID',
dataIndex: 'id'
},
{
title: '图片',
dataIndex: 'path',
key: 'path'
},
{
title: '名称',
dataIndex: 'name',
key: 'name'
},
{
title: '大小',
dataIndex: 'length',
key: 'length',
customRender: ({text}) => {
if (text < 1024) {
return text + 'B';
} else if (text < 1024 * 1024) {
return (text / 1024).toFixed(1) + 'KB';
} else if (text < 1024 * 1024 * 1024) {
return (text / 1024 / 1024).toFixed(1) + 'M';
} else {
return (text / 1024 / 1024 / 1024).toFixed(1) + 'G';
}
}
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
where = {};
// 搜索条件
if (searchText.value) {
where.name = searchText.value;
where = {};
// 搜索条件
if (searchText.value) {
where.name = searchText.value;
}
if (dictDataId.value) {
where.groupId = dictDataId.value;
}
if (props.type) {
let contentTypes = ''
switch (props.type) {
case 'audio' : {
contentTypes = 'audio/mpeg';
}
break;
case 'file' : {
contentTypes = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
}
break;
case 'video' : {
contentTypes = 'video/mp4';
}
break;
default : {
contentTypes = 'image/jpeg,image/png,image/jpg';
}
break;
}
if (dictDataId.value) {
where.groupId = dictDataId.value;
}
if (props.type) {
let contentTypes = ''
switch (props.type) {
case 'audio' : {
contentTypes = 'audio/mpeg';
}
break;
case 'file' : {
contentTypes = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
}
break;
case 'video' : {
contentTypes = 'video/mp4';
}
break;
default : {
contentTypes = 'image/jpeg,image/png,image/jpg';
}
break;
}
where.contentTypes = contentTypes;
}
return pageFiles({
...where,
...orders,
page,
limit
});
where.contentTypes = contentTypes;
}
return pageFiles({
...where,
...orders,
page,
limit
});
};
/* 搜索 */
const reload = (where?: FileRecordParam) => {
tableRef?.value?.reload({page: 1, where});
tableRef?.value?.reload({page: 1, where});
};
const onRadio = (record: FileRecord) => {
pageId.value = Number(record.id);
updateVisible(false);
emit('done', record);
pageId.value = Number(record.id);
updateVisible(false);
emit('done', record);
};
const getGroupList = () => {
pageDictData({dictCode: 'groupId'}).then((res) => {
groupList.value = res?.list.map((d) => {
return {
label: d.dictDataName,
value: d.dictDataId
};
});
pageDictData({dictCode: 'groupId'}).then((res) => {
groupList.value = res?.list.map((d) => {
return {
label: d.dictDataName,
value: d.dictDataId
};
});
});
};
const onGroupId = (index: number) => {
dictDataId.value = index;
reload();
dictDataId.value = index;
reload();
};
// 上传文件
const onUpload = (item) => {
const {file} = item;
if (!file.type.startsWith('image') && props.type && !['video', 'audio', 'file'].includes(props.type)) {
message.error('只能选择图片');
return;
const {file} = item;
if (!file.type.startsWith('image') && props.type && !['video', 'audio', 'file'].includes(props.type)) {
message.error('只能选择图片');
return;
}
if (props.type == 'video') {
if (file.size / 1024 / 1024 > 100) {
message.error('大小不能超过 100MB');
return;
}
if (props.type == 'video') {
if (file.size / 1024 / 1024 > 100) {
message.error('大小不能超过 100MB');
return;
}
} else if (props.type == 'audio') {
if (file.size / 1024 / 1024 > 20) {
message.error('大小不能超过 20MB');
return;
}
} else {
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
} else if (props.type == 'audio') {
if (file.size / 1024 / 1024 > 20) {
message.error('大小不能超过 20MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
if (dictDataId.value > 0) {
uploadOssByGroupId(file, dictDataId.value)
.then(() => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
});
} else {
uploadOss(file)
.then(() => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
});
} else {
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
if (dictDataId.value > 0) {
uploadOssByGroupId(file, dictDataId.value)
.then(() => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
});
} else {
uploadOss(file)
.then(() => {
hide();
message.success('上传成功');
reload();
})
.catch((e) => {
message.error(e.message);
hide();
});
}
};
const openEdit = (row?: FileRecord) => {
current.value = row ?? null;
showEdit.value = true;
current.value = row ?? null;
showEdit.value = true;
};
/* 自定义行属性 */
const customRow = (record: FileRecord) => {
return {
// 行点击事件
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
// 行双击事件
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
return {
// 行点击事件
// onClick: () => {
// updateVisible(false);
// emit('done', record);
// },
// 行双击事件
onDblclick: () => {
updateVisible(false);
emit('done', record);
}
};
};
watch(
() => props.visible,
(visible) => {
if (visible) {
getGroupList();
}
() => props.visible,
(visible) => {
if (visible) {
getGroupList();
}
}
);
</script>

View File

@@ -3,12 +3,20 @@
align-items: center;
justify-content: flex-start;flex-wrap: wrap">
<template v-for="(item, index) in data" :key="index">
<video v-if="type === 'video'" :src="item.url" style="width: 400px; height: 200px" controls="controls"></video>
<div v-if="type === 'video' || item.url.includes('.mp4')" class="relative cursor-pointer" @click="open(item.url)">
<img
:src="item.url + '?x-oss-process=video/snapshot,t_2000,f_jpg,w_200,h_200'"
style="width: 80px; height: 80px"
/>
<div class="absolute" style="left: 30px; top: 30px">
<play-circle-outlined style="font-size: 20px; color:white"/>
</div>
</div>
<a-tag :key="item.url" closable @close="onDeleteItem(index)"
@click.native="open(item.url)" style="cursor: pointer"
v-else-if="type && ['audio', 'file'].includes(type)"> {{ item.url }}
</a-tag>
<div class="image-upload-item" v-else>
<div class="image-upload-item bg-gray-300" v-else>
<a-image-preview-group>
<a-image
:width="width"
@@ -57,7 +65,7 @@
</template>
<script lang="ts" setup>
import {PlusOutlined, CloseOutlined} from '@ant-design/icons-vue';
import {PlusOutlined, CloseOutlined, PlayCircleOutlined} from '@ant-design/icons-vue';
import {ref} from 'vue';
import SelectData from './components/select-data.vue';
import {FileRecord} from '@/api/system/file/model';

View File

@@ -64,6 +64,7 @@
title?: string;
// 商户类型
shopType?: string;
type?: string;
// 修改回显的数据
data?: Merchant | null;
}>();
@@ -99,7 +100,7 @@
{
title: '商户类型',
dataIndex: 'shopType',
key: 'shopType'
// key: 'shopType'
},
{
title: '操作',
@@ -120,6 +121,9 @@
} else {
where.shopType = props.shopType;
}
if (props.type) {
where.type = props.type;
}
return pageMerchant({
...where,
...orders,

View File

@@ -17,6 +17,7 @@
:data="current"
:title="placeholder"
:customer-type="customerType"
:shopType="shopType"
@done="onChange"
/>
</div>
@@ -33,6 +34,7 @@
value?: any;
customerType?: string;
placeholder?: string;
shopType?: string;
}>(),
{
placeholder: '请选择商户'