第一次提交
This commit is contained in:
170
src/views/baocan/agent/components/edit.vue
Normal file
170
src/views/baocan/agent/components/edit.vue
Normal file
@@ -0,0 +1,170 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="500"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '编辑代报餐人员' : '添加代报餐人员'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
>
|
||||
<a-form-item label="代报餐人员" name="parentId">
|
||||
<SelectUser
|
||||
:placeholder="`请选择帮代报餐的人员`"
|
||||
v-model:value="parentName"
|
||||
@done="chooseParentId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="报餐人姓名" name="userId">
|
||||
<SelectUser
|
||||
:placeholder="`请选择需要代报的人员`"
|
||||
v-model:value="nickName"
|
||||
@done="chooseUserId"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BCAgent } from '@/api/apps/bc/agent/model';
|
||||
import { addBCAgent, updateBCAgent } from '@/api/apps/bc/agent';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { User } from '@/api/user/model';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BCAgent | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const parentName = ref();
|
||||
const nickName = ref();
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<BCAgent>({
|
||||
userId: undefined,
|
||||
parentId: undefined,
|
||||
sortNumber: 100
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
parentId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择代报餐的人员',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择报餐的人员姓名',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const chooseUserId = (data: User) => {
|
||||
form.userId = data.userId;
|
||||
nickName.value = data.nickname;
|
||||
};
|
||||
|
||||
const chooseParentId = (data: User) => {
|
||||
form.parentId = data.userId;
|
||||
parentName.value = data.nickname;
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const merchantForm = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateBCAgent : addBCAgent;
|
||||
saveOrUpdate(merchantForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
resetFields();
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.flex-sb {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
</style>
|
||||
123
src/views/baocan/agent/components/search.vue
Normal file
123
src/views/baocan/agent/components/search.vue
Normal file
@@ -0,0 +1,123 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<!-- <a-button-->
|
||||
<!-- danger-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- :v-role="`dev`"-->
|
||||
<!-- @click="removeBatch"-->
|
||||
<!-- v-if="props.selection.length > 0"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <DeleteOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>批量删除</span>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-input-search-->
|
||||
<!-- allow-clear-->
|
||||
<!-- v-model:value="searchText"-->
|
||||
<!-- placeholder="请输入搜索关键词"-->
|
||||
<!-- @search="search"-->
|
||||
<!-- @pressEnter="search"-->
|
||||
<!-- >-->
|
||||
<!-- <template #addonBefore>-->
|
||||
<!-- <a-select v-model:value="type" style="width: 120px; margin: -5px -12px">-->
|
||||
<!-- <a-select-option value="merchantName">商户名称</a-select-option>-->
|
||||
<!-- <a-select-option value="merchantCode">商户编号</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- </template>-->
|
||||
<!-- </a-input-search>-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { MerchantParam } from '@/api/merchant/model';
|
||||
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: MerchantParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<MerchantParam>({
|
||||
merchantId: undefined,
|
||||
merchantName: '',
|
||||
merchantCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('merchantName');
|
||||
// tabType
|
||||
const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
if (type.value == 'merchantName') {
|
||||
where.merchantName = searchText.value;
|
||||
where.merchantCode = undefined;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
where.merchantName = undefined;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// const handleTabs = (e) => {
|
||||
// listType.value = e.target.value;
|
||||
// if (listType.value == 'all') {
|
||||
// resetFields();
|
||||
// }
|
||||
// if (listType.value == 'onSale') {
|
||||
// where.status = 0;
|
||||
// }
|
||||
// if (listType.value == 'offSale') {
|
||||
// where.status = 1;
|
||||
// }
|
||||
// if (listType.value == 'soldOut') {
|
||||
// where.stockTotal = 0;
|
||||
// }
|
||||
// emit('search', where);
|
||||
// };
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
244
src/views/baocan/agent/index.vue
Normal file
244
src/views/baocan/agent/index.vue
Normal file
@@ -0,0 +1,244 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="代报餐管理">
|
||||
<div class="ele-text-secondary">
|
||||
代报餐管理,给特定账号添加代报餐权限。
|
||||
</div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="userId"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
:parse-data="parseData"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'user'">
|
||||
<User v-if="record.user" :record="record.user" />
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<span>{{ record.nickname }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'parentUser'">
|
||||
<User v-if="record.parentUser" :record="record.parentUser" />
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">营业中</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="orange">停业中</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments" placement="topLeft">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
{{ timeAgo(record.createTime) }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a class="ele-text-danger" @click="remove(record)">移除</a>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo, toTreeData } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
listBCAgent,
|
||||
removeBCAgent,
|
||||
removeBatchBCAgent
|
||||
} from '@/api/apps/bc/agent';
|
||||
import type { BCAgent, BCAgentParam } from '@/api/apps/bc/agent/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '代报餐人/报餐人',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<BCAgent[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<BCAgent | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return listBCAgent({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: BCAgentParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: BCAgent) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 数据转为树形结构 */
|
||||
const parseData = (data) => {
|
||||
const result: any[] = [];
|
||||
data.forEach((item) => {
|
||||
let index = result.findIndex((citem) => item.parentId == citem.userId);
|
||||
if (index < 0) {
|
||||
result.push({
|
||||
userId: item.parentId,
|
||||
nickname: item.parentName,
|
||||
children: []
|
||||
});
|
||||
index = result.length - 1;
|
||||
}
|
||||
result[index].children.push({
|
||||
userId: item.userId,
|
||||
nickname: item.nickname,
|
||||
agentId: item.agentId
|
||||
});
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: BCAgent) => {
|
||||
console.log(row);
|
||||
removeBCAgent(row.agentId)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchBCAgent(selection.value.map((d) => d.agentId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'BCAgentIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
256
src/views/baocan/cookbook/components/photo-edit.vue
Normal file
256
src/views/baocan/cookbook/components/photo-edit.vue
Normal file
@@ -0,0 +1,256 @@
|
||||
<!-- 角色编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '编辑' : '上传文件'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
okText="保存"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 5, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="上传文件" name="fileName" v-if="!isUpdate">
|
||||
<span
|
||||
class="ele-text-success"
|
||||
v-if="fileName"
|
||||
style="margin-right: 10px"
|
||||
>
|
||||
{{ fileName }}
|
||||
</span>
|
||||
<a-upload
|
||||
:show-upload-list="false"
|
||||
:accept="'video/*'"
|
||||
v-if="!fileName"
|
||||
:customRequest="onUpload"
|
||||
>
|
||||
<a-button type="primary" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
<span>上传文件</span>
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="文件名称" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入文件名称"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="图片描述"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<div style="margin-bottom: 22px">
|
||||
<a-divider orientation="left">图片分享</a-divider>
|
||||
</div>
|
||||
<a-form-item label="图片URL链接">
|
||||
<a-input v-model:value="share.url" @click="copyText(share.url)" />
|
||||
</a-form-item>
|
||||
<a-form-item label="网页代码(HTML)">
|
||||
<a-input v-model:value="share.html" @click="copyText(share.html)" />
|
||||
</a-form-item>
|
||||
<a-form-item label="Markdown">
|
||||
<a-input
|
||||
v-model:value="share.Markdown"
|
||||
@click="copyText(share.Markdown)"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="论坛BBCode">
|
||||
<a-input v-model:value="share.bbCode" @click="copyText(share.bbCode)" />
|
||||
</a-form-item>
|
||||
|
||||
<!-- <a-form-item label="封面图" name="images">-->
|
||||
<!-- <ele-image-upload-->
|
||||
<!-- v-model:value="images"-->
|
||||
<!-- :limit="1"-->
|
||||
<!-- :drag="true"-->
|
||||
<!-- :item-style="{ width: '60px', height: '60px' }"-->
|
||||
<!-- :accept="'image/*'"-->
|
||||
<!-- :upload-handler="uploadHandler"-->
|
||||
<!-- @upload="onUpload"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import type { FileRecord } from '@/api/system/file/model';
|
||||
import { messageLoading } from 'ele-admin-pro';
|
||||
import { addFiles, updateFiles, uploadFile } from '@/api/system/file';
|
||||
import { UploadOutlined } from '@ant-design/icons-vue';
|
||||
import { RuleObject } from 'ant-design-vue/es/form';
|
||||
import { copyText } from '@/utils/common';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: FileRecord | null;
|
||||
}>();
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const fileName = ref('');
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 图片资源分享
|
||||
const share = ref({
|
||||
url: '',
|
||||
Markdown: '',
|
||||
html: '',
|
||||
bbCode: ''
|
||||
});
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<FileRecord>({
|
||||
id: 0,
|
||||
name: '',
|
||||
comments: ''
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
fileName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请上传文件',
|
||||
type: 'string',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject) => {
|
||||
if (!isUpdate.value && fileName.value.length == 0) {
|
||||
return Promise.reject('请上传文件');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入文件名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
if (!file.type.startsWith('video')) {
|
||||
message.error('文件格式不正确!');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 100) {
|
||||
message.error('大小不能超过 100MB');
|
||||
return;
|
||||
}
|
||||
const hide = messageLoading({
|
||||
content: '上传中..',
|
||||
duration: 0,
|
||||
mask: true
|
||||
});
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
hide();
|
||||
fileName.value = String(data.name);
|
||||
// images.value.push({
|
||||
// uid: data.id,
|
||||
// url: FILE_THUMBNAIL + data.path,
|
||||
// status: 'done'
|
||||
// });
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
hide();
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const saveOrUpdate = isUpdate.value ? updateFiles : addFiles;
|
||||
saveOrUpdate(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
// 图片分享代码
|
||||
share.value.url = `${props.data.url}`;
|
||||
share.value.html = `<a href="${props.data.url}"><img src="${props.data.url}" alt="${props.data.name}" border="0" /></a>`;
|
||||
share.value.Markdown = `[](${props.data.url})`;
|
||||
share.value.bbCode = `[url=${props.data.url}][img]${props.data.url}[/img][/url]`;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
114
src/views/baocan/cookbook/image.vue
Normal file
114
src/views/baocan/cookbook/image.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-row :gutter="20">
|
||||
<a-col
|
||||
v-for="(item, index) in data"
|
||||
:key="index"
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 5, lg: 8, md: 12, sm: 12, xs: 24 }
|
||||
: { span: 6 }
|
||||
"
|
||||
>
|
||||
<a-card :bordered="false" hoverable style="margin-top: 16px" @click="openEdit(item)">
|
||||
<template #cover>
|
||||
<img :src="item.url" alt="" :width="120" :height="180" />
|
||||
</template>
|
||||
<a-card-meta :title="item.name">
|
||||
<template #description>
|
||||
<div
|
||||
class="project-list-desc"
|
||||
v-if="item.comments"
|
||||
:title="item.comments"
|
||||
>
|
||||
{{ item.comments }}
|
||||
</div>
|
||||
</template>
|
||||
</a-card-meta>
|
||||
<div class="ele-cell">
|
||||
<div class="ele-cell-content ele-text-secondary">
|
||||
<!-- <a-tooltip :title="item.createNickname" placement="top">-->
|
||||
<!-- <a-avatar :src="item.avatar" size="small" />-->
|
||||
<!-- </a-tooltip>-->
|
||||
{{ timeAgo(item.createTime) }}
|
||||
</div>
|
||||
<a-button type="primary" @click="openEdit(item)">
|
||||
加入菜品
|
||||
</a-button>
|
||||
</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<!-- 编辑弹窗 -->
|
||||
<PhotoEdit v-model:visible="showEdit" :data="current" @done="query" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { FileRecord, FileRecordParam } from '@/api/system/file/model';
|
||||
import PhotoEdit from './components/photo-edit.vue';
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
|
||||
const props = defineProps<{
|
||||
// 搜索关键字
|
||||
searchText: string;
|
||||
// 搜索条件
|
||||
where?: FileRecordParam | null;
|
||||
// 修改回显的数据
|
||||
data?: FileRecord | null;
|
||||
}>();
|
||||
|
||||
// 当前编辑数据
|
||||
const current = ref<FileRecord | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
}>();
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: FileRecord) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const query = () => {
|
||||
emit('done');
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
console.log(props.data);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'PhotoImage'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.project-list-desc {
|
||||
height: 44px;
|
||||
line-height: 22px;
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
</style>
|
||||
142
src/views/baocan/cookbook/index.vue
Normal file
142
src/views/baocan/cookbook/index.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="常用菜谱">
|
||||
<div class="ele-text-secondary"> 发布分享和完善有菜谱库 </div>
|
||||
<template #footer>
|
||||
<a-tabs v-model:activeKey="activeKey">
|
||||
<a-tab-pane key="1" tab="家常菜谱" />
|
||||
<a-tab-pane key="2" tab="中国菜谱" />
|
||||
<a-tab-pane key="3" tab="烘焙" />
|
||||
<a-tab-pane key="4" tab="外国菜谱" />
|
||||
<a-tab-pane key="5" tab="食材大全" />
|
||||
<template #rightExtra v-if="activeKey === '1'">
|
||||
<div style="margin-bottom: 10px">
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
v-permission="'shop:goods:save'"
|
||||
@click="add"
|
||||
>
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>发布菜谱</span>
|
||||
</a-button>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
style="width: 240px; margin-left: 10px"
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入关键词"
|
||||
@search="query"
|
||||
@pressEnter="query"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</a-tabs>
|
||||
</template>
|
||||
</a-page-header>
|
||||
<div class="ele-body" v-if="activeKey === '1'">
|
||||
<Image :data="data" :where="where" @done="query" />
|
||||
<div class="ele-text-center" style="margin-top: 38px">
|
||||
<a-pagination
|
||||
:total="count"
|
||||
v-model:current="page"
|
||||
v-model:page-size="limit"
|
||||
show-quick-jumper
|
||||
:show-total="(total) => `共 ${total} 条`"
|
||||
@change="query"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ele-body" v-if="activeKey === '2'">
|
||||
<List :data="data" :where="where" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { FileRecord, FileRecordParam } from '@/api/system/file/model';
|
||||
import Image from './image.vue';
|
||||
import List from './list.vue';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import { pageFiles, uploadFile } from '@/api/system/file';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
|
||||
const type = ref('name');
|
||||
const searchText = ref('');
|
||||
const data = ref<FileRecord[]>([]);
|
||||
// 当前选项卡
|
||||
const activeKey = ref('1');
|
||||
// 第几页
|
||||
const page = ref(1);
|
||||
// 每页多少条
|
||||
const limit = ref(12);
|
||||
// 总数量
|
||||
const count = ref(0);
|
||||
// 搜索表单
|
||||
const where = reactive<FileRecordParam>({
|
||||
name: '',
|
||||
createNickname: ''
|
||||
});
|
||||
|
||||
/* 查询数据 */
|
||||
const query = () => {
|
||||
console.log('query()');
|
||||
if (type.value == 'name') {
|
||||
where.name = searchText.value;
|
||||
}
|
||||
if (type.value == 'createNickname') {
|
||||
where.createNickname = searchText.value;
|
||||
}
|
||||
where.page = page.value;
|
||||
where.limit = limit.value;
|
||||
where.contentType = 'image';
|
||||
console.log(where);
|
||||
pageFiles(where).then((res) => {
|
||||
count.value = Number(res?.count);
|
||||
data.value = res?.list;
|
||||
});
|
||||
};
|
||||
|
||||
query();
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return;
|
||||
}
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
message.success('发布成功');
|
||||
query();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'PhotoIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.project-list-desc {
|
||||
height: 44px;
|
||||
line-height: 22px;
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
</style>
|
||||
299
src/views/baocan/cookbook/list.vue
Normal file
299
src/views/baocan/cookbook/list.vue
Normal file
@@ -0,0 +1,299 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
cache-key="proCmsVideoTable"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<a-upload
|
||||
:show-upload-list="false"
|
||||
:accept="'image/*'"
|
||||
:customRequest="onUpload"
|
||||
>
|
||||
<a-button type="primary" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
<span>上传图片</span>
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
v-if="selection.length > 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>删除</span>
|
||||
</a-button>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入关键词"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select
|
||||
v-model:value="type"
|
||||
style="width: 100px; margin: -5px -12px"
|
||||
>
|
||||
<a-select-option value="name">文件名称</a-select-option>
|
||||
<a-select-option value="createNickname">
|
||||
上传人
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'path'">
|
||||
<a-image :src="record.url" :width="120" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'name'">
|
||||
<span>{{ record.name }}</span>
|
||||
<copy-outlined
|
||||
style="padding-left: 4px"
|
||||
@click="openEdit(record)"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'comments'">
|
||||
<span @click="openEdit(record)">{{ record.comments }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">编辑</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此评价吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<PhotoEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue/es';
|
||||
import {
|
||||
UploadOutlined,
|
||||
DeleteOutlined,
|
||||
CopyOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading, toDateString } from 'ele-admin-pro/es';
|
||||
import PhotoEdit from './components/photo-edit.vue';
|
||||
import {
|
||||
pageFiles,
|
||||
removeFile,
|
||||
removeFiles,
|
||||
uploadFile
|
||||
} from '@/api/system/file/index';
|
||||
import type {
|
||||
FileRecord,
|
||||
FileRecordParam
|
||||
} from '@/api/system/file/model/index';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 表格选中数据
|
||||
const selection = ref<FileRecord[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<FileRecord | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const type = ref('name');
|
||||
const searchText = ref('');
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '图片',
|
||||
dataIndex: 'path',
|
||||
width: 180,
|
||||
key: 'path'
|
||||
},
|
||||
{
|
||||
title: '文件名称',
|
||||
dataIndex: 'name'
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'comments',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '文件大小',
|
||||
dataIndex: 'length',
|
||||
sorter: true,
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true,
|
||||
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';
|
||||
}
|
||||
},
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '发布者',
|
||||
width: 120,
|
||||
dataIndex: 'createNickname'
|
||||
},
|
||||
{
|
||||
title: '发布时间',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where = {};
|
||||
if (type.value == 'name') {
|
||||
where.name = searchText.value;
|
||||
}
|
||||
if (type.value == 'createNickname') {
|
||||
where.createNickname = searchText.value;
|
||||
}
|
||||
where.contentType = 'image';
|
||||
return pageFiles({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: FileRecordParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ page: 1, where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: FileRecord) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: FileRecord) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeFile(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeFiles(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return;
|
||||
}
|
||||
const hide = messageLoading({
|
||||
content: '上传中..',
|
||||
duration: 0,
|
||||
mask: true
|
||||
});
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
hide();
|
||||
message.success('上传成功');
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
hide();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'VideoIndex'
|
||||
};
|
||||
</script>
|
||||
124
src/views/baocan/cookbook/player/index.vue
Normal file
124
src/views/baocan/cookbook/player/index.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
<!-- 角色编辑弹窗 -->
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" :title="form.name">
|
||||
<div class="ele-text-secondary">
|
||||
{{ form.comments }}
|
||||
</div>
|
||||
</a-page-header>
|
||||
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" style="width: 70%">
|
||||
<ele-xg-player
|
||||
:config="{
|
||||
id: 'demoPlayer1',
|
||||
lang: 'zh-cn',
|
||||
fluid: true,
|
||||
// 视频地址
|
||||
url: FILE_SERVER + form.path,
|
||||
// 封面
|
||||
poster: '',
|
||||
// 开启倍速播放
|
||||
playbackRate: [0.5, 1, 1.5, 2],
|
||||
// 开启画中画
|
||||
pip: true
|
||||
}"
|
||||
@player="onPlayer1"
|
||||
/>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch, unref } from 'vue';
|
||||
import Player from 'xgplayer';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import { setPageTabTitle } from '@/utils/page-tab-util';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import { getFile } from '@/api/system/file';
|
||||
const { currentRoute } = useRouter();
|
||||
import { FILE_SERVER } from '@/config/setting';
|
||||
const ROUTE_PATH = '/cms/video/player';
|
||||
|
||||
// 视频播放器一实例
|
||||
let player1: Player;
|
||||
// 视频播放器一是否实例化完成
|
||||
const ready1 = ref(false);
|
||||
|
||||
// 视频播放器一配置
|
||||
const config1 = reactive({
|
||||
id: 'demoPlayer1',
|
||||
lang: 'zh-cn',
|
||||
fluid: true,
|
||||
// 视频地址
|
||||
url: 'https://file.wsdns.cn/20221126/cf17ef352db54bf28efeda268107714f.mp4',
|
||||
// 封面
|
||||
poster:
|
||||
'https://file.wsdns.cn/20221125/49f0c461d61e48f28b324366a0a63a2e.jpg',
|
||||
// 开启倍速播放
|
||||
playbackRate: [0.5, 1, 1.5, 2],
|
||||
// 开启画中画
|
||||
pip: true
|
||||
});
|
||||
|
||||
/* 播放器一渲染完成 */
|
||||
const onPlayer1 = (player: Player) => {
|
||||
player1 = player;
|
||||
player1.on('play', () => {
|
||||
ready1.value = true;
|
||||
});
|
||||
};
|
||||
// 视频信息
|
||||
const { form, assignFields } = useFormData<FileRecord>({
|
||||
id: 0,
|
||||
name: '',
|
||||
url: '',
|
||||
path: '',
|
||||
comments: '',
|
||||
createNickname: '',
|
||||
createTime: ''
|
||||
});
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
/* */
|
||||
const query = () => {
|
||||
const { query } = unref(currentRoute);
|
||||
const id = query.id;
|
||||
if (!id || form.id === Number(id)) {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
getFile(Number(id))
|
||||
.then((data) => {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...data,
|
||||
createTime: toDateString(data.createTime)
|
||||
});
|
||||
// 修改页签标题
|
||||
if (unref(currentRoute).path === ROUTE_PATH) {
|
||||
setPageTabTitle(String(data.comments));
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
(route) => {
|
||||
const { path } = unref(route);
|
||||
if (path !== ROUTE_PATH) {
|
||||
return;
|
||||
}
|
||||
query();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
229
src/views/baocan/department/components/org-edit.vue
Normal file
229
src/views/baocan/department/components/org-edit.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<!-- 机构编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="620"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改机构' : '添加机构'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 7, sm: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="styleResponsive ? { md: 17, sm: 24 } : { flex: '1' }"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="上级机构" name="parentId">
|
||||
<org-select
|
||||
:data="organizationList"
|
||||
placeholder="请选择上级机构"
|
||||
v-model:value="form.parentId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="机构名称" name="organizationName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入机构名称"
|
||||
v-model:value="form.organizationName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="机构全称" name="organizationFullName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入机构全称"
|
||||
v-model:value="form.organizationFullName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="机构代码">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入机构代码"
|
||||
v-model:value="form.organizationCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="机构类型" name="organizationType">
|
||||
<org-type-select v-model:value="form.organizationType" />
|
||||
</a-form-item>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="99999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import OrgSelect from './org-select.vue';
|
||||
import OrgTypeSelect from './org-type-select.vue';
|
||||
import {
|
||||
addOrganization,
|
||||
updateOrganization
|
||||
} from '@/api/system/organization';
|
||||
import type { Organization } from '@/api/system/organization/model';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Organization | null;
|
||||
// 机构id
|
||||
organizationId?: number;
|
||||
// 全部机构
|
||||
organizationList: Organization[];
|
||||
}>();
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Organization>({
|
||||
organizationId: undefined,
|
||||
parentId: undefined,
|
||||
organizationName: '',
|
||||
organizationFullName: '',
|
||||
organizationCode: '',
|
||||
organizationType: undefined,
|
||||
sortNumber: undefined,
|
||||
comments: ''
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
organizationName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入机构名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
organizationFullName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入机构全称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
organizationType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择机构类型',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const orgData = {
|
||||
...form,
|
||||
parentId: form.parentId || 0
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateOrganization
|
||||
: addOrganization;
|
||||
saveOrUpdate(orgData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.parentId = props.organizationId;
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
39
src/views/baocan/department/components/org-select.vue
Normal file
39
src/views/baocan/department/components/org-select.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- 机构选择下拉框 -->
|
||||
<template>
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:placeholder="placeholder"
|
||||
:value="value || undefined"
|
||||
:tree-data="data"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="updateValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Organization } from '@/api/system/organization/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value?: number): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据(v-modal)
|
||||
value?: number;
|
||||
// 提示信息
|
||||
placeholder?: string;
|
||||
// 机构数据
|
||||
data: Organization[];
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择角色'
|
||||
}
|
||||
);
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value?: number) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
</script>
|
||||
39
src/views/baocan/department/components/org-type-select.vue
Normal file
39
src/views/baocan/department/components/org-type-select.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- 机构类型选择下拉框 -->
|
||||
<template>
|
||||
<a-select
|
||||
allow-clear
|
||||
:value="value"
|
||||
:placeholder="placeholder"
|
||||
@update:value="updateValue"
|
||||
>
|
||||
<a-select-option v-for="item in data" :key="item.label" :value="item.value">
|
||||
{{ item.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { getDictionaryOptions } from '@/utils/common';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value: string): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择机构类型'
|
||||
}
|
||||
);
|
||||
|
||||
// 机构类型数据
|
||||
const data = getDictionaryOptions('organizationType');
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value: string) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
</script>
|
||||
295
src/views/baocan/department/components/org-user-edit.vue
Normal file
295
src/views/baocan/department/components/org-user-edit.vue
Normal file
@@ -0,0 +1,295 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改用户' : '新建用户'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 7, sm: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="styleResponsive ? { md: 17, sm: 24 } : { flex: '1' }"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="所属机构">
|
||||
<org-select
|
||||
:data="organizationList"
|
||||
placeholder="请选择所属机构"
|
||||
v-model:value="form.organizationId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="账号" name="username">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入用户账号"
|
||||
v-model:value="form.username"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="姓名" name="realName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入真实姓名"
|
||||
v-model:value="form.realName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="性别" name="sex">
|
||||
<sex-select v-model:value="form.sex" />
|
||||
</a-form-item>
|
||||
<a-form-item label="角色" name="roleIds">
|
||||
<role-select v-model:value="form.roles" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="手机号" name="phone">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="11"
|
||||
placeholder="请输入手机号"
|
||||
v-model:value="form.phone"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="邮箱" name="email">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入邮箱"
|
||||
v-model:value="form.email"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="出生日期">
|
||||
<a-date-picker
|
||||
class="ele-fluid"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择出生日期"
|
||||
v-model:value="form.birthday"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="!isUpdate" label="登录密码" name="password">
|
||||
<a-input-password
|
||||
:maxlength="20"
|
||||
v-model:value="form.password"
|
||||
placeholder="请输入登录密码"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="个人简介">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入个人简介"
|
||||
v-model:value="form.introduction"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { emailReg, phoneReg } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import OrgSelect from './org-select.vue';
|
||||
import RoleSelect from './role-select.vue';
|
||||
import SexSelect from './sex-select.vue';
|
||||
import { addUser, updateUser, checkExistence } from '@/api/system/user';
|
||||
import type { User } from '@/api/system/user/model';
|
||||
import type { Organization } from '@/api/system/organization/model';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: User | null;
|
||||
// 全部机构
|
||||
organizationList: Organization[];
|
||||
// 机构id
|
||||
organizationId?: number;
|
||||
}>();
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<User>({
|
||||
userId: undefined,
|
||||
organizationId: undefined,
|
||||
username: '',
|
||||
nickname: '',
|
||||
realName: '',
|
||||
sex: undefined,
|
||||
roles: [],
|
||||
email: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
introduction: ''
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
username: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
validator: (_rule: Rule, value: string) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (!value) {
|
||||
return reject('请输入用户账号');
|
||||
}
|
||||
checkExistence('username', value, props.data?.userId)
|
||||
.then(() => {
|
||||
reject('账号已经存在');
|
||||
})
|
||||
.catch(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
nickname: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入昵称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
realName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入真实姓名',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// sex: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请选择性别',
|
||||
// type: 'string',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
// roleIds: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请选择角色',
|
||||
// type: 'array',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
email: [
|
||||
{
|
||||
pattern: emailReg,
|
||||
message: '邮箱格式不正确',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
password: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
validator: async (_rule: Rule, value: string) => {
|
||||
if (isUpdate.value || /^[\S]{5,18}$/.test(value)) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.reject('密码必须为5-18位非空白字符');
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: phoneReg,
|
||||
message: '手机号格式不正确',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
form.nickname = form.realName;
|
||||
form.alias = form.realName;
|
||||
const saveOrUpdate = isUpdate.value ? updateUser : addUser;
|
||||
saveOrUpdate(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.organizationId = props.organizationId;
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
239
src/views/baocan/department/components/org-user-list.vue
Normal file
239
src/views/baocan/department/components/org-user-list.vue
Normal file
@@ -0,0 +1,239 @@
|
||||
<template>
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="userId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
height="calc(100vh - 290px)"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 800 }"
|
||||
tools-theme="default"
|
||||
bordered
|
||||
cache-key="proSystemOrgUserTable"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<org-user-search @search="reload" @add="openEdit()" />
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'roles'">
|
||||
<a-tag v-for="item in record.roles" :key="item.roleId" color="blue">
|
||||
{{ item.roleName }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<a-switch
|
||||
:checked="record.status === 0"
|
||||
@change="(checked: boolean) => editStatus(checked, record)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'balance'">
|
||||
<span class="ele-text-success">
|
||||
¥{{ formatNumber(record.balance) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此用户吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
<!-- 编辑弹窗 -->
|
||||
<org-user-edit
|
||||
:data="current"
|
||||
v-model:visible="showEdit"
|
||||
:organization-list="organizationList"
|
||||
:organization-id="organizationId"
|
||||
@done="reload"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading } from 'ele-admin-pro/es';
|
||||
import OrgUserSearch from './org-user-search.vue';
|
||||
import OrgUserEdit from './org-user-edit.vue';
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import { pageUsers, removeUser, updateUserStatus } from '@/api/system/user';
|
||||
import type { User, UserParam } from '@/api/system/user/model';
|
||||
import type { Organization } from '@/api/system/organization/model';
|
||||
|
||||
const props = defineProps<{
|
||||
// 机构 id
|
||||
organizationId?: number;
|
||||
// 全部机构
|
||||
organizationList: Organization[];
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '用户ID',
|
||||
dataIndex: 'userId',
|
||||
sorter: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '用户账号',
|
||||
dataIndex: 'username',
|
||||
sorter: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'realName',
|
||||
sorter: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '余额',
|
||||
dataIndex: 'balance',
|
||||
key: 'balance',
|
||||
sorter: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '性别',
|
||||
dataIndex: 'sexName',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
showSorterTooltip: false,
|
||||
hideInTable: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '角色',
|
||||
key: 'roles'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true,
|
||||
showSorterTooltip: false,
|
||||
hideInTable: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => timeAgo(text)
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'status',
|
||||
sorter: true,
|
||||
showSorterTooltip: false,
|
||||
width: 80,
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 当前编辑数据
|
||||
const current = ref<User | null>(null);
|
||||
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
if (props.organizationId) {
|
||||
where.organizationId = props.organizationId;
|
||||
}
|
||||
return pageUsers({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: UserParam) => {
|
||||
tableRef?.value?.reload({ page: 1, where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: User) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: User) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeUser(row.userId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 修改用户状态 */
|
||||
const editStatus = (checked: boolean, row: User) => {
|
||||
const status = checked ? 0 : 1;
|
||||
updateUserStatus(row.userId, status)
|
||||
.then((msg) => {
|
||||
row.status = status;
|
||||
message.success(msg);
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 监听机构 id 变化
|
||||
watch(
|
||||
() => props.organizationId,
|
||||
() => {
|
||||
reload();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
83
src/views/baocan/department/components/org-user-search.vue
Normal file
83
src/views/baocan/department/components/org-user-search.vue
Normal file
@@ -0,0 +1,83 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive ? { xl: 6, lg: 8, md: 12, sm: 24, xs: 24 } : { span: 6 }
|
||||
"
|
||||
>
|
||||
<a-input
|
||||
v-model:value.trim="form.keywords"
|
||||
placeholder="请输入关键词"
|
||||
allow-clear
|
||||
/>
|
||||
</a-col>
|
||||
<!-- <a-col-->
|
||||
<!-- v-bind="-->
|
||||
<!-- styleResponsive ? { xl: 6, lg: 8, md: 12, sm: 24, xs: 24 } : { span: 6 }-->
|
||||
<!-- "-->
|
||||
<!-- >-->
|
||||
<!-- <a-input-->
|
||||
<!-- v-model:value.trim="form.nickname"-->
|
||||
<!-- placeholder="请输入昵称"-->
|
||||
<!-- allow-clear-->
|
||||
<!-- />-->
|
||||
<!-- </a-col>-->
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 12, lg: 8, md: 24, sm: 24, xs: 24 }
|
||||
: { span: 12 }
|
||||
"
|
||||
>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="search">
|
||||
<template #icon>
|
||||
<search-outlined />
|
||||
</template>
|
||||
<span>查询</span>
|
||||
</a-button>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<plus-outlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, SearchOutlined } from '@ant-design/icons-vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import type { UserParam } from '@/api/system/user/model';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: UserParam): void;
|
||||
(e: 'add'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { form } = useFormData<UserParam>({
|
||||
keywords: '',
|
||||
username: '',
|
||||
nickname: ''
|
||||
});
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
emit('search', form);
|
||||
};
|
||||
|
||||
/* 添加 */
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
</script>
|
||||
71
src/views/baocan/department/components/role-select.vue
Normal file
71
src/views/baocan/department/components/role-select.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<!-- 角色选择下拉框 -->
|
||||
<template>
|
||||
<a-select
|
||||
allow-clear
|
||||
mode="multiple"
|
||||
:value="roleIds"
|
||||
:placeholder="placeholder"
|
||||
@update:value="updateValue"
|
||||
@blur="onBlur"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="item in data"
|
||||
:key="item.roleId"
|
||||
:value="item.roleId"
|
||||
>
|
||||
{{ item.roleName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { listRoles } from '@/api/system/role';
|
||||
import type { Role } from '@/api/system/role/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value: Role[]): void;
|
||||
(e: 'blur'): void;
|
||||
}>();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
value?: Role[];
|
||||
//
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择角色'
|
||||
}
|
||||
);
|
||||
|
||||
// 选中的角色id
|
||||
const roleIds = computed(() => props.value?.map((d) => d.roleId as number));
|
||||
|
||||
// 角色数据
|
||||
const data = ref<Role[]>([]);
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value: number[]) => {
|
||||
emit(
|
||||
'update:value',
|
||||
value.map((v) => ({ roleId: v }))
|
||||
);
|
||||
};
|
||||
|
||||
/* 获取角色数据 */
|
||||
listRoles()
|
||||
.then((list) => {
|
||||
data.value = list;
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
|
||||
/* 失去焦点 */
|
||||
const onBlur = () => {
|
||||
emit('blur');
|
||||
};
|
||||
</script>
|
||||
45
src/views/baocan/department/components/sex-select.vue
Normal file
45
src/views/baocan/department/components/sex-select.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<!-- 角色选择下拉框 -->
|
||||
<template>
|
||||
<a-select
|
||||
show-search
|
||||
optionFilterProp="label"
|
||||
:options="data"
|
||||
allow-clear
|
||||
:value="value"
|
||||
:placeholder="placeholder"
|
||||
@update:value="updateValue"
|
||||
@blur="onBlur"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { getDictionaryOptions } from '@/utils/common';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value: string): void;
|
||||
(e: 'blur'): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择性别'
|
||||
}
|
||||
);
|
||||
|
||||
// 字典数据
|
||||
const data = getDictionaryOptions('sex');
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value: string) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
|
||||
/* 失去焦点 */
|
||||
const onBlur = () => {
|
||||
emit('blur');
|
||||
};
|
||||
</script>
|
||||
212
src/views/baocan/department/index.vue
Normal file
212
src/views/baocan/department/index.vue
Normal file
@@ -0,0 +1,212 @@
|
||||
<template>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-split-layout
|
||||
width="266px"
|
||||
allow-collapse
|
||||
:right-style="{ overflow: 'hidden' }"
|
||||
:style="{ minHeight: 'calc(100vh - 152px)' }"
|
||||
>
|
||||
<div>
|
||||
<ele-toolbar theme="default">
|
||||
<a-space :size="10">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
|
||||
<template #icon>
|
||||
<plus-outlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
:disabled="!current"
|
||||
class="ele-btn-icon"
|
||||
@click="openEdit(current)"
|
||||
>
|
||||
<template #icon>
|
||||
<edit-outlined />
|
||||
</template>
|
||||
<span>修改</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
:disabled="!current"
|
||||
class="ele-btn-icon"
|
||||
@click="remove"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>删除</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</ele-toolbar>
|
||||
<div class="ele-border-split sys-organization-list">
|
||||
<a-tree
|
||||
:tree-data="(data as any)"
|
||||
v-model:expanded-keys="expandedRowKeys"
|
||||
v-model:selected-keys="selectedRowKeys"
|
||||
@select="onTreeSelect"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<template #content>
|
||||
<org-user-list
|
||||
v-if="current"
|
||||
:organization-list="data"
|
||||
:organization-id="current.organizationId"
|
||||
/>
|
||||
</template>
|
||||
</ele-split-layout>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<org-edit
|
||||
v-model:visible="showEdit"
|
||||
:data="editData"
|
||||
:organization-list="data"
|
||||
:organization-id="current?.organizationId"
|
||||
@done="query"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue/es';
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import { messageLoading, toTreeData, eachTreeData } from 'ele-admin-pro/es';
|
||||
import OrgUserList from './components/org-user-list.vue';
|
||||
import OrgEdit from './components/org-edit.vue';
|
||||
import {
|
||||
listOrganizations,
|
||||
removeOrganization
|
||||
} from '@/api/system/organization';
|
||||
import type { Organization } from '@/api/system/organization/model';
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 树形数据
|
||||
const data = ref<Organization[]>([]);
|
||||
|
||||
// 树展开的key
|
||||
const expandedRowKeys = ref<number[]>([]);
|
||||
|
||||
// 树选中的key
|
||||
const selectedRowKeys = ref<number[]>([]);
|
||||
|
||||
// 选中数据
|
||||
const current = ref<Organization | null>(null);
|
||||
|
||||
// 是否显示表单弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 编辑回显数据
|
||||
const editData = ref<Organization | null>(null);
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
listOrganizations()
|
||||
.then((list) => {
|
||||
loading.value = false;
|
||||
const eks: number[] = [];
|
||||
list.forEach((d, i) => {
|
||||
console.log(d);
|
||||
if (d.parentId > 0) {
|
||||
d.title = i + '.' + d.organizationName;
|
||||
} else {
|
||||
d.title = d.organizationName;
|
||||
}
|
||||
d.key = d.organizationId;
|
||||
d.value = d.organizationId;
|
||||
|
||||
if (typeof d.key === 'number') {
|
||||
eks.push(d.key);
|
||||
}
|
||||
});
|
||||
expandedRowKeys.value = eks;
|
||||
data.value = toTreeData({
|
||||
data: list,
|
||||
idField: 'organizationId',
|
||||
parentIdField: 'parentId'
|
||||
});
|
||||
if (list.length) {
|
||||
if (typeof list[0].key === 'number') {
|
||||
selectedRowKeys.value = [list[0].key];
|
||||
}
|
||||
current.value = list[0];
|
||||
current.value.organizationId = 0;
|
||||
} else {
|
||||
selectedRowKeys.value = [];
|
||||
current.value = null;
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 选择数据 */
|
||||
const onTreeSelect = () => {
|
||||
eachTreeData(data.value, (d) => {
|
||||
if (typeof d.key === 'number' && selectedRowKeys.value.includes(d.key)) {
|
||||
current.value = d;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (item?: Organization | null) => {
|
||||
editData.value = item ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除 */
|
||||
const remove = () => {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的机构吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeOrganization(current.value?.organizationId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
query();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'SystemOrganization'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sys-organization-list {
|
||||
padding: 12px 6px;
|
||||
height: calc(100vh - 242px);
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
215
src/views/baocan/equipment/components/bc-equipment-edit.vue
Normal file
215
src/views/baocan/equipment/components/bc-equipment-edit.vue
Normal file
@@ -0,0 +1,215 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="880"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '编辑设备' : '添加设备'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="设备编码" name="equipmentCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备编码"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属档口" name="gear">
|
||||
<a-radio-group v-model:value="form.gear">
|
||||
<a-radio :value="10">食堂档口</a-radio>
|
||||
<a-radio :value="20">物品档口</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入描述内容"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="启用状态" name="status">-->
|
||||
<!-- <a-switch :checked="form.status === 0" @change="editStatus" />-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BcEquipment } from '@/api/apps/bc/equipment/model';
|
||||
import { addBcEquipment, updateBcEquipment } from '@/api/apps/bc/equipment';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BcEquipment | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<BcEquipment>({
|
||||
bcEquipmentId: undefined,
|
||||
equipmentName: undefined,
|
||||
equipmentCode: '',
|
||||
gear: 10,
|
||||
createTime: '',
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写设备编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateBcEquipment(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const equipmentForm = {
|
||||
...form
|
||||
};
|
||||
console.log(equipmentForm, 'equipmentForm');
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateBcEquipment
|
||||
: addBcEquipment;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
107
src/views/baocan/equipment/components/search.vue
Normal file
107
src/views/baocan/equipment/components/search.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>绑定设备</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
:disabled="props.selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-input-search-->
|
||||
<!-- allow-clear-->
|
||||
<!-- v-model:value="searchText"-->
|
||||
<!-- placeholder="请输入搜索关键词"-->
|
||||
<!-- @search="search"-->
|
||||
<!-- @pressEnter="search"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<EquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
equipmentName: '',
|
||||
equipmentCode: '',
|
||||
merchantCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
// const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
where.equipmentName = undefined;
|
||||
where.equipmentCode = undefined;
|
||||
where.merchantCode = undefined;
|
||||
if (type.value == 'equipmentName') {
|
||||
where.equipmentName = searchText.value;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
225
src/views/baocan/equipment/index.vue
Normal file
225
src/views/baocan/equipment/index.vue
Normal file
@@ -0,0 +1,225 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="设备管理">
|
||||
<div class="ele-text-secondary"> 绑定的消费机设备管理 </div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="bcEquipmentId"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'comments'">
|
||||
<span class="ele-text-placeholder">{{ record.comments }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openEdit(record)">绑定设备</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<bc-equipment-edit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import BcEquipmentEdit from './components/bc-equipment-edit.vue';
|
||||
import {
|
||||
pageBcEquipment,
|
||||
removeBatchBcEquipment
|
||||
} from '@/api/apps/bc/equipment';
|
||||
import type {
|
||||
BcEquipment,
|
||||
BcEquipmentParam
|
||||
} from '@/api/apps/bc/equipment/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '设备编号',
|
||||
dataIndex: 'equipmentCode',
|
||||
key: 'equipmentCode'
|
||||
},
|
||||
{
|
||||
title: '设备描述',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 90,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<BcEquipment[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<BcEquipment | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
// const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// if (filters) {
|
||||
// where.brand = filters.brand;
|
||||
// }
|
||||
return pageBcEquipment({ ...where, ...orders, ...filters, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: BcEquipmentParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: BcEquipment) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
// const openInfo = (row?: BcEquipment) => {
|
||||
// current.value = row ?? null;
|
||||
// showEdit.value = true;
|
||||
// };
|
||||
|
||||
/* 删除单个 */
|
||||
// const remove = (row: BcEquipment) => {
|
||||
// const hide = message.loading('请求中..', 0);
|
||||
// removeBcEquipment(row.bcEquipmentId)
|
||||
// .then((msg) => {
|
||||
// hide();
|
||||
// message.success(msg);
|
||||
// reload();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// hide();
|
||||
// message.error(e.message);
|
||||
// });
|
||||
// };
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchBcEquipment(selection.value.map((d) => d.bcEquipmentId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'BcEquipmentIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
391
src/views/baocan/export/components/order-info.vue
Normal file
391
src/views/baocan/export/components/order-info.vue
Normal file
@@ -0,0 +1,391 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="`80%`"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑订单' : '订单详情'"
|
||||
:body-style="{ paddingBottom: '8px', background: '#f3f3f3' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
:footer="null"
|
||||
@ok="save"
|
||||
>
|
||||
<!-- <a-card class="order-card" :bordered="false">-->
|
||||
<!-- <a-steps-->
|
||||
<!-- :current="active"-->
|
||||
<!-- direction="horizontal"-->
|
||||
<!-- :responsive="styleResponsive"-->
|
||||
<!-- >-->
|
||||
<!-- <template v-for="(item, index) in steps" :key="index">-->
|
||||
<!-- <a-step-->
|
||||
<!-- :title="item.title"-->
|
||||
<!-- :description="timeAgo(item.description)"-->
|
||||
<!-- />-->
|
||||
<!-- </template>-->
|
||||
<!-- </a-steps>-->
|
||||
<!-- </a-card>-->
|
||||
<a-card title="订单详情" class="order-card">
|
||||
<!-- <a-space>-->
|
||||
<!-- <a-button>发货</a-button>-->
|
||||
<!-- <a-button>商家备注</a-button>-->
|
||||
<!-- <a-button>打印小票</a-button>-->
|
||||
<!-- </a-space>-->
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单号" name="orderId">
|
||||
<span>{{ order.orderId }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="实付款金额" name="payPrice">
|
||||
<span class="ele-text-warning"
|
||||
>¥{{ formatNumber(order.payPrice) }}</span
|
||||
>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单状态" name="orderStatus">
|
||||
<a-tag>{{ order.payStatus === 20 ? '已下单' : '' }}</a-tag>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家信息" name="deliveryType">
|
||||
<router-link :to="'/system/user/details?id=' + order.userId">
|
||||
<span class="ele-text-primary">{{ order.nickname }}</span>
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="预定日期" name="deliveryTime">
|
||||
{{ toDateString(order.deliveryTime, 'yyyy-MM-dd') }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="下单时间" name="createTime">
|
||||
{{ order.createTime }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="交易流水号" name="orderNo">
|
||||
{{ order.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家留言" name="buyerRemark">
|
||||
<span>{{ order.buyerRemark }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单备注" name="comments">
|
||||
<span>{{ order.comments }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-card title="菜品信息" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="orderGoodsList"
|
||||
:columns="columns"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<div class="goods-info">
|
||||
<a-image
|
||||
v-if="record.imageUrl"
|
||||
:src="record.imageUrl"
|
||||
:preview="false"
|
||||
:width="50"
|
||||
/>
|
||||
<div class="info">
|
||||
<div>{{ record.goodsName }}</div>
|
||||
<div class="ele-text-placeholder">{{ record.comments }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { assignObject, toDateString } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { OrderGoods } from '@/api/order/goods/model';
|
||||
import { getOrder } from '@/api/order';
|
||||
import { listOrderGoods } from '@/api/order/goods';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
export interface step {
|
||||
title?: String | undefined;
|
||||
subTitle?: String | undefined;
|
||||
description?: String | undefined;
|
||||
}
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const orderGoodsList = ref<OrderGoods[]>([]);
|
||||
|
||||
// 步骤条
|
||||
const steps = ref<step[]>([
|
||||
{
|
||||
title: '报餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '付款',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '发餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '取餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '完成',
|
||||
description: undefined
|
||||
}
|
||||
]);
|
||||
const active = ref(2);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 订单信息
|
||||
const order = reactive<Order>({
|
||||
orderId: undefined,
|
||||
orderNo: '',
|
||||
userId: undefined,
|
||||
orderSourceData: '',
|
||||
nickname: '',
|
||||
comments: '',
|
||||
createTime: undefined,
|
||||
deliveryTime: '',
|
||||
payPrice: undefined,
|
||||
payStatus: undefined
|
||||
});
|
||||
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
|
||||
const { resetFields } = useForm(order);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: '菜品ID',
|
||||
// dataIndex: 'goodsId'
|
||||
// },
|
||||
{
|
||||
title: '菜品信息',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '菜品价格',
|
||||
dataIndex: 'goodsPrice',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '购买数量',
|
||||
dataIndex: 'totalNum',
|
||||
key: 'totalNum'
|
||||
}
|
||||
]);
|
||||
|
||||
/* 制作步骤条 */
|
||||
const loadSteps = (order) => {
|
||||
steps.value = [];
|
||||
steps.value.push({
|
||||
title: '下单'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '付款'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '发货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '收货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '完成'
|
||||
});
|
||||
|
||||
// 下单
|
||||
if (order.payStatus == 10) {
|
||||
active.value = 0;
|
||||
steps.value[0].description = order.createTime;
|
||||
}
|
||||
// 付款
|
||||
if (order.payStatus == 20) {
|
||||
active.value = 1;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
}
|
||||
// 发货
|
||||
if (order.payStatus == 20 && order.deliveryStatus == 20) {
|
||||
active.value = 2;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
}
|
||||
// 收货
|
||||
if (order.payStatus == 20 && order.receiptStatus == 20) {
|
||||
active.value = 3;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 完成
|
||||
if (order.payStatus == 20 && order.orderStatus == 30) {
|
||||
active.value = 4;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 已取消
|
||||
if (order.orderStatus == 20) {
|
||||
active.value = 4;
|
||||
}
|
||||
};
|
||||
|
||||
const queryOrder = () => {
|
||||
var orderId = props.data?.orderId;
|
||||
getOrder(orderId).then((res) => {
|
||||
assignObject(order, res);
|
||||
});
|
||||
};
|
||||
|
||||
const getOrderGoods = () => {
|
||||
const orderId = props.data?.orderId;
|
||||
listOrderGoods({ orderId }).then((data) => {
|
||||
orderGoodsList.value = data;
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
queryOrder();
|
||||
// assignObject(order, props.data);
|
||||
loadSteps(props.data);
|
||||
getOrderGoods();
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.order-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ant-form-item {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.goods-info {
|
||||
display: flex;
|
||||
.info {
|
||||
padding-left: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
184
src/views/baocan/export/components/search.vue
Normal file
184
src/views/baocan/export/components/search.vue
Normal file
@@ -0,0 +1,184 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search">
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<SelectOrganization
|
||||
:placeholder="`请选择部门`"
|
||||
v-model:value="organizationName"
|
||||
@done="chooseOrganization"
|
||||
/>
|
||||
<!-- <a-date-picker-->
|
||||
<!-- placeholder="预定日期"-->
|
||||
<!-- value-format="YYYY-MM-DD"-->
|
||||
<!-- v-model:value="where.deliveryTime"-->
|
||||
<!-- @change="search"-->
|
||||
<!-- />-->
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
@change="search"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="ele-fluid"
|
||||
/>
|
||||
<a-button type="primary" @click="reset">统计</a-button>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="handleExport">
|
||||
<template #icon>
|
||||
<download-outlined />
|
||||
</template>
|
||||
<span>导出</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
DeleteOutlined,
|
||||
DownloadOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { BcExportParam } from '@/api/apps/bc/export/model';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import ExcelJS from 'exceljs';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
exportData?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: BcExportParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'done'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<BcExportParam>({
|
||||
exportId: undefined,
|
||||
keywords: undefined,
|
||||
organizationId: undefined
|
||||
});
|
||||
// 下来选项
|
||||
// const categoryId = ref<number>(0);
|
||||
const post = ref<number>(0);
|
||||
const sign = ref<number>(0);
|
||||
const noSign = ref<number>(0);
|
||||
const organizationName = ref<string>();
|
||||
const exportTitle = `贵港资源报餐人员统计`;
|
||||
// 请求状态
|
||||
// const loading = ref(true);
|
||||
// const deliveryStatus = ref<number>(0);
|
||||
// const gear = ref<number>(0);
|
||||
// 预定日期
|
||||
// const deliveryTime = ref<Dayjs>();
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>([
|
||||
toDateString(new Date(), 'YYYY-MM-dd 00:00:00'),
|
||||
toDateString(new Date(), 'YYYY-MM-dd 00:00:00')
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
where.deliveryTimeStart = d1 ? d1 + ' 00:00:00' : undefined;
|
||||
where.deliveryTimeEnd = d2 ? d2 + ' 23:59:59' : undefined;
|
||||
// where.deliveryTime = where.deliveryTime
|
||||
// ? where.deliveryTime + ' 00:00:00'
|
||||
// : undefined;
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
const chooseOrganization = (data: Organization) => {
|
||||
organizationName.value = data.organizationName;
|
||||
where.organizationId = data.organizationId;
|
||||
// 查询全部
|
||||
if (data.organizationId == 52) {
|
||||
where.organizationId = undefined;
|
||||
}
|
||||
search();
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
post.value = 0;
|
||||
sign.value = 0;
|
||||
noSign.value = 0;
|
||||
search();
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
if (!props.selection?.length) {
|
||||
emit('done');
|
||||
return;
|
||||
}
|
||||
// 创建工作簿
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
// 添加工作表
|
||||
const sheet = workbook.addWorksheet(exportTitle, {
|
||||
headerFooter: { firstHeader: 'Hello Exceljs' }
|
||||
});
|
||||
const style: ExcelJS.Style = {
|
||||
alignment: { horizontal: 'center' }
|
||||
};
|
||||
sheet.columns = [
|
||||
{ header: '部门', key: 'organizationName', style, width: 30 },
|
||||
{ header: '编号', key: 'userId', style, width: 20 },
|
||||
{ header: '姓名', key: 'nickname', style, width: 20 },
|
||||
{ header: '早餐报餐次数', key: 'breakfastPost', style, width: 20 },
|
||||
{ header: '早餐签到次数', key: 'breakfastSign', style, width: 20 },
|
||||
{ header: '午餐报餐次数', key: 'lunchPost', style, width: 20 },
|
||||
{ header: '午餐签到次数', key: 'lunchSign', style, width: 20 },
|
||||
{ header: '晚餐报餐次数', key: 'dinnerPost', style, width: 20 },
|
||||
{ header: '晚餐签到次数', key: 'dinnerSign', style, width: 20 },
|
||||
{ header: '消费金额', key: 'expendMoney', style, width: 20 }
|
||||
];
|
||||
sheet.addRows(props.selection);
|
||||
sheet.insertRow(1, [
|
||||
`贵港资源${toDateString(
|
||||
dateRange.value[0],
|
||||
'yyyy-MM-dd'
|
||||
)} 至 ${toDateString(dateRange.value[1], 'yyyy-MM-dd')}报餐人员统计`
|
||||
]);
|
||||
const a1 = sheet.getCell(1, 1);
|
||||
|
||||
a1.style = {
|
||||
alignment: { horizontal: 'center' },
|
||||
font: {
|
||||
bold: true,
|
||||
size: 20
|
||||
}
|
||||
};
|
||||
sheet.mergeCells('A1:J1');
|
||||
// sheet.getRow(2).fill = {
|
||||
// type: 'pattern',
|
||||
// pattern: 'solid',
|
||||
// fgColor: { argb: '92d050' },
|
||||
// bgColor: { argb: '92d050' }
|
||||
// };
|
||||
// 写入 buffer
|
||||
const buffer = await workbook.xlsx.writeBuffer();
|
||||
let blob = new Blob([buffer]);
|
||||
var aEle = document.createElement('a'); // 创建a标签
|
||||
aEle.download = exportTitle + '.xlsx'; // 设置下载文件的文件名
|
||||
aEle.href = URL.createObjectURL(blob);
|
||||
aEle.click(); // 设置点击事件
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
|
||||
// count();
|
||||
</script>
|
||||
266
src/views/baocan/export/index.vue
Normal file
266
src/views/baocan/export/index.vue
Normal file
@@ -0,0 +1,266 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card title="报餐人员统计" :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="userId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:parse-data="parseData"
|
||||
v-model:selection="selection"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 1200 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
:export-data="exportData"
|
||||
@done="handleExport"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'lunchPost'">
|
||||
<div v-if="index === 0">
|
||||
<div>{{ record.lunchPost }}</div>
|
||||
<div>{{ record.gear10 }}/{{ record.gear20 }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'lunchSign'">
|
||||
<div v-if="index === 0">
|
||||
<div>{{ record.lunchSign }}</div>
|
||||
<div>{{ record.signGear10 }}/{{ record.signGear20 }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import Search from './components/search.vue';
|
||||
import { listBcExport } from '@/api/apps/bc/export';
|
||||
import type { BcExport, BcExportParam } from '@/api/apps/bc/export/model';
|
||||
import ExcelJS from 'exceljs';
|
||||
import { EleProTable, toDateString } from 'ele-admin-pro';
|
||||
import {
|
||||
ColumnItem,
|
||||
DatasourceFunction
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<BcExport[]>([]);
|
||||
const exportData = ref<BcExport[]>([]);
|
||||
const exportTitle = ref<string>(`贵港资源报餐人员统计`);
|
||||
|
||||
/* 导出数据 */
|
||||
const parseData = (data: BcExport[]) => {
|
||||
exportData.value = data;
|
||||
return data;
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
// 创建工作簿
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
// 添加工作表
|
||||
const sheet = workbook.addWorksheet(exportTitle.value, {
|
||||
headerFooter: { firstHeader: 'Hello Exceljs' }
|
||||
});
|
||||
const style: ExcelJS.Style = {
|
||||
alignment: { horizontal: 'center' }
|
||||
};
|
||||
sheet.columns = [
|
||||
{ header: '部门', key: 'organizationName', style, width: 30 },
|
||||
{ header: '编号', key: 'userId', style, width: 20 },
|
||||
{ header: '姓名', key: 'nickname', style, width: 20 },
|
||||
{ header: '早餐报餐次数', key: 'breakfastPost', style, width: 20 },
|
||||
{ header: '早餐签到次数', key: 'breakfastSign', style, width: 20 },
|
||||
{ header: '午餐报餐次数(食堂/领物)', key: 'lunchPostText', style, width: 20 },
|
||||
{ header: '午餐签到次数(食堂/领物)', key: 'lunchSignText', style, width: 20 },
|
||||
{ header: '晚餐报餐次数', key: 'dinnerPost', style, width: 20 },
|
||||
{ header: '晚餐签到次数', key: 'dinnerSign', style, width: 20 },
|
||||
{ header: '消费金额', key: 'expendMoney', style, width: 20 }
|
||||
];
|
||||
sheet.addRows(exportData.value);
|
||||
sheet.insertRow(1, [exportTitle.value]);
|
||||
const a1 = sheet.getCell(1, 1);
|
||||
|
||||
a1.style = {
|
||||
alignment: { horizontal: 'center' },
|
||||
font: {
|
||||
bold: true,
|
||||
size: 26
|
||||
}
|
||||
};
|
||||
sheet.mergeCells('A1:J1');
|
||||
// sheet.getRow(2).fill = {
|
||||
// type: 'pattern',
|
||||
// pattern: 'darkTrellis',
|
||||
// fgColor: { argb: '92d050' },
|
||||
// bgColor: { argb: '92d050' }
|
||||
// };
|
||||
// 写入 buffer
|
||||
const buffer = await workbook.xlsx.writeBuffer();
|
||||
let blob = new Blob([buffer]);
|
||||
var aEle = document.createElement('a'); // 创建a标签
|
||||
aEle.download = exportTitle.value + '.xlsx'; // 设置下载文件的文件名
|
||||
aEle.href = URL.createObjectURL(blob);
|
||||
aEle.click(); // 设置点击事件
|
||||
};
|
||||
|
||||
// const reload = (where) => {
|
||||
// title.value.deliveryTimeStart = where.deliveryTimeStart;
|
||||
// title.value.deliveryTimeEnd = where.deliveryTimeEnd;
|
||||
//
|
||||
// listBcExport(where).then((data) => {
|
||||
// exportData.value = data;
|
||||
// });
|
||||
// };
|
||||
// reload({});
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: BcExportParam) => {
|
||||
exportTitle.value = `贵港资源${toDateString(
|
||||
where?.deliveryTimeStart,
|
||||
'yyyy-MM-dd'
|
||||
)} 至 ${toDateString(where?.deliveryTimeEnd, 'yyyy-MM-dd')}报餐人员统计`;
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.deliveryStatus) {
|
||||
where.deliveryStatus = filters.deliveryStatus;
|
||||
}
|
||||
// 默认查询今天
|
||||
// where.deliveryTime = toDateString(new Date(), 'YYYY-MM-dd 00:00:00');
|
||||
return listBcExport({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '部门名称',
|
||||
dataIndex: 'organizationName',
|
||||
key: 'organizationName'
|
||||
},
|
||||
{
|
||||
title: '编号',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId'
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname'
|
||||
},
|
||||
{
|
||||
title: '早餐报餐次数',
|
||||
dataIndex: 'breakfastPost',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '早餐签到次数',
|
||||
dataIndex: 'breakfastSign',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '午餐报餐次数(食堂/领物)',
|
||||
dataIndex: 'lunchPost',
|
||||
key: 'lunchPost',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '午餐签到次数(食堂/领物)',
|
||||
dataIndex: 'lunchSign',
|
||||
key: 'lunchSign',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '晚餐报餐次数',
|
||||
dataIndex: 'dinnerPost',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '晚餐签到次数',
|
||||
dataIndex: 'dinnerSign',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '消费金额',
|
||||
dataIndex: 'expendMoney',
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'BcExportIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.comments {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
391
src/views/baocan/food/components/order-info.vue
Normal file
391
src/views/baocan/food/components/order-info.vue
Normal file
@@ -0,0 +1,391 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="`80%`"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑订单' : '订单详情'"
|
||||
:body-style="{ paddingBottom: '8px', background: '#f3f3f3' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
:footer="null"
|
||||
@ok="save"
|
||||
>
|
||||
<!-- <a-card class="order-card" :bordered="false">-->
|
||||
<!-- <a-steps-->
|
||||
<!-- :current="active"-->
|
||||
<!-- direction="horizontal"-->
|
||||
<!-- :responsive="styleResponsive"-->
|
||||
<!-- >-->
|
||||
<!-- <template v-for="(item, index) in steps" :key="index">-->
|
||||
<!-- <a-step-->
|
||||
<!-- :title="item.title"-->
|
||||
<!-- :description="timeAgo(item.description)"-->
|
||||
<!-- />-->
|
||||
<!-- </template>-->
|
||||
<!-- </a-steps>-->
|
||||
<!-- </a-card>-->
|
||||
<a-card title="订单详情" class="order-card">
|
||||
<!-- <a-space>-->
|
||||
<!-- <a-button>发货</a-button>-->
|
||||
<!-- <a-button>商家备注</a-button>-->
|
||||
<!-- <a-button>打印小票</a-button>-->
|
||||
<!-- </a-space>-->
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单号" name="orderId">
|
||||
<span>{{ order.orderId }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="实付款金额" name="payPrice">
|
||||
<span class="ele-text-warning"
|
||||
>¥{{ formatNumber(order.payPrice) }}</span
|
||||
>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单状态" name="orderStatus">
|
||||
<a-tag>{{ order.payStatus === 20 ? '已下单' : '' }}</a-tag>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家信息" name="deliveryType">
|
||||
<router-link :to="'/system/user/details?id=' + order.userId">
|
||||
<span class="ele-text-primary">{{ order.nickname }}</span>
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="预定日期" name="deliveryTime">
|
||||
{{ toDateString(order.deliveryTime, 'yyyy-MM-dd') }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="下单时间" name="createTime">
|
||||
{{ order.createTime }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="交易流水号" name="orderNo">
|
||||
{{ order.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家留言" name="buyerRemark">
|
||||
<span>{{ order.buyerRemark }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单备注" name="comments">
|
||||
<span>{{ order.comments }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-card title="菜品信息" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="orderGoodsList"
|
||||
:columns="columns"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<div class="goods-info">
|
||||
<a-image
|
||||
v-if="record.imageUrl"
|
||||
:src="record.imageUrl"
|
||||
:preview="false"
|
||||
:width="50"
|
||||
/>
|
||||
<div class="info">
|
||||
<div>{{ record.goodsName }}</div>
|
||||
<div class="ele-text-placeholder">{{ record.comments }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { assignObject, toDateString } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { OrderGoods } from '@/api/order/goods/model';
|
||||
import { getOrder } from '@/api/order';
|
||||
import { listOrderGoods } from '@/api/order/goods';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
export interface step {
|
||||
title?: String | undefined;
|
||||
subTitle?: String | undefined;
|
||||
description?: String | undefined;
|
||||
}
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const orderGoodsList = ref<OrderGoods[]>([]);
|
||||
|
||||
// 步骤条
|
||||
const steps = ref<step[]>([
|
||||
{
|
||||
title: '报餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '付款',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '发餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '取餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '完成',
|
||||
description: undefined
|
||||
}
|
||||
]);
|
||||
const active = ref(2);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 订单信息
|
||||
const order = reactive<Order>({
|
||||
orderId: undefined,
|
||||
orderNo: '',
|
||||
userId: undefined,
|
||||
orderSourceData: '',
|
||||
nickname: '',
|
||||
comments: '',
|
||||
createTime: undefined,
|
||||
deliveryTime: '',
|
||||
payPrice: undefined,
|
||||
payStatus: undefined
|
||||
});
|
||||
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
|
||||
const { resetFields } = useForm(order);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: '菜品ID',
|
||||
// dataIndex: 'goodsId'
|
||||
// },
|
||||
{
|
||||
title: '菜品信息',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '菜品价格',
|
||||
dataIndex: 'goodsPrice',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '购买数量',
|
||||
dataIndex: 'totalNum',
|
||||
key: 'totalNum'
|
||||
}
|
||||
]);
|
||||
|
||||
/* 制作步骤条 */
|
||||
const loadSteps = (order) => {
|
||||
steps.value = [];
|
||||
steps.value.push({
|
||||
title: '下单'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '付款'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '发货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '收货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '完成'
|
||||
});
|
||||
|
||||
// 下单
|
||||
if (order.payStatus == 10) {
|
||||
active.value = 0;
|
||||
steps.value[0].description = order.createTime;
|
||||
}
|
||||
// 付款
|
||||
if (order.payStatus == 20) {
|
||||
active.value = 1;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
}
|
||||
// 发货
|
||||
if (order.payStatus == 20 && order.deliveryStatus == 20) {
|
||||
active.value = 2;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
}
|
||||
// 收货
|
||||
if (order.payStatus == 20 && order.receiptStatus == 20) {
|
||||
active.value = 3;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 完成
|
||||
if (order.payStatus == 20 && order.orderStatus == 30) {
|
||||
active.value = 4;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 已取消
|
||||
if (order.orderStatus == 20) {
|
||||
active.value = 4;
|
||||
}
|
||||
};
|
||||
|
||||
const queryOrder = () => {
|
||||
var orderId = props.data?.orderId;
|
||||
getOrder(orderId).then((res) => {
|
||||
assignObject(order, res);
|
||||
});
|
||||
};
|
||||
|
||||
const getOrderGoods = () => {
|
||||
const orderId = props.data?.orderId;
|
||||
listOrderGoods({ orderId }).then((data) => {
|
||||
orderGoodsList.value = data;
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
queryOrder();
|
||||
// assignObject(order, props.data);
|
||||
loadSteps(props.data);
|
||||
getOrderGoods();
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.order-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ant-form-item {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.goods-info {
|
||||
display: flex;
|
||||
.info {
|
||||
padding-left: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
313
src/views/baocan/food/components/search.vue
Normal file
313
src/views/baocan/food/components/search.vue
Normal file
@@ -0,0 +1,313 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search">
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<!-- <a-button type="primary" class="ele-btn-icon" @click="add">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>发布菜品</span>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button-->
|
||||
<!-- danger-->
|
||||
<!-- type="primary"-->
|
||||
<!-- class="ele-btn-icon"-->
|
||||
<!-- :disabled="selection.length === 0"-->
|
||||
<!-- @click="removeBatch"-->
|
||||
<!-- >-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <DeleteOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>批量删除</span>-->
|
||||
<!-- </a-button>-->
|
||||
<SelectOrganization
|
||||
:placeholder="`请选择部门`"
|
||||
v-model:value="where.organizationName"
|
||||
@done="chooseOrganization"
|
||||
/>
|
||||
<a-date-picker
|
||||
placeholder="按天筛选"
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model:value="where.deliveryTime"
|
||||
@change="search"
|
||||
/>
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
@change="search"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="ele-fluid"
|
||||
/>
|
||||
<a-select
|
||||
v-model:value="where.week"
|
||||
style="width: 120px"
|
||||
placeholder="请选择星期"
|
||||
allow-clear
|
||||
@change="handleWeek"
|
||||
>
|
||||
<a-select-option :value="1">星期一</a-select-option>
|
||||
<a-select-option :value="2">星期二</a-select-option>
|
||||
<a-select-option :value="3">星期三</a-select-option>
|
||||
<a-select-option :value="4">星期四</a-select-option>
|
||||
<a-select-option :value="5">星期五</a-select-option>
|
||||
<a-select-option :value="6">星期六</a-select-option>
|
||||
<a-select-option :value="0">星期日</a-select-option>
|
||||
</a-select>
|
||||
<a-radio-group v-model:value="where.categoryId" @change="search">
|
||||
<a-radio-button :value="25">早餐</a-radio-button>
|
||||
<a-radio-button :value="26">午餐</a-radio-button>
|
||||
<a-radio-button :value="27">晚餐</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-radio-group v-model:value="where.deliveryStatus" @change="search">
|
||||
<a-radio-button :value="20">已签到</a-radio-button>
|
||||
<a-radio-button :value="10">未签到</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-radio-group v-model:value="where.gear" @change="search">
|
||||
<a-radio-button :value="10">食堂档口</a-radio-button>
|
||||
<a-radio-button :value="20">物品档口</a-radio-button>
|
||||
</a-radio-group>
|
||||
<!-- <a-button @click="onRepairData">修复数据</a-button>-->
|
||||
<!-- <a-button type="primary" class="ele-btn-icon" @click="handleExport">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <download-outlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>导出</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入订单号|姓名"
|
||||
v-model:value="where.keywords"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
style="width: 196px"
|
||||
/>
|
||||
<a-button @click="reset">重置</a-button>
|
||||
<!-- <span style="margin-left: 20px"-->
|
||||
<!-- >已签到 {{ signUsers }} / 已报餐 {{ postUsers }}</span-->
|
||||
<!-- >-->
|
||||
</a-space>
|
||||
<a-spin :spinning="loading">
|
||||
<a-alert
|
||||
:message="`报餐统计:已报餐 ${post} / 已签到 ${sign} / 未签到 ${noSign}`"
|
||||
type="info"
|
||||
style="margin-top: 8px; max-width: 602px"
|
||||
/>
|
||||
</a-spin>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { OrderGoods, OrderGoodsParam } from '@/api/order/goods/model';
|
||||
import { countOrderGoods } from '@/api/apps/statistics';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
// import { Dayjs } from 'dayjs';
|
||||
// import { message } from 'ant-design-vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: OrderGoodsParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<OrderGoodsParam>({
|
||||
categoryId: undefined,
|
||||
deliveryTime: undefined,
|
||||
deliveryStatus: undefined,
|
||||
deliveryTimeStart: undefined,
|
||||
deliveryTimeEnd: undefined,
|
||||
gear: undefined,
|
||||
week: undefined,
|
||||
organizationId: undefined,
|
||||
keywords: undefined
|
||||
});
|
||||
// 下来选项
|
||||
// const categoryId = ref<number>(0);
|
||||
const post = ref<number>(0);
|
||||
const sign = ref<number>(0);
|
||||
const noSign = ref<number>(0);
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
// const deliveryStatus = ref<number>(0);
|
||||
// const gear = ref<number>(0);
|
||||
// 预定日期
|
||||
// const deliveryTime = ref<Dayjs>();
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
where.deliveryTimeStart = d1 ? d1 + ' 00:00:00' : undefined;
|
||||
where.deliveryTimeEnd = d2 ? d2 + ' 00:00:00' : undefined;
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
count();
|
||||
};
|
||||
|
||||
const handleWeek = (index) => {
|
||||
where.week = index;
|
||||
search();
|
||||
};
|
||||
|
||||
// const handleTabs = (e) => {
|
||||
// const index = Number(e.target.value);
|
||||
// resetFields();
|
||||
// categoryId.value = index;
|
||||
// search();
|
||||
// };
|
||||
//
|
||||
// const onDeliveryStatus = (e) => {
|
||||
// const index = Number(e.target.value);
|
||||
// resetFields();
|
||||
// deliveryStatus.value = index;
|
||||
// search();
|
||||
// };
|
||||
|
||||
// const onGear = (e) => {
|
||||
// const index = Number(e.target.value);
|
||||
// resetFields();
|
||||
// gear.value = index;
|
||||
// search();
|
||||
// };
|
||||
//
|
||||
// // 发布菜品
|
||||
// const add = () => {
|
||||
// emit('add');
|
||||
// };
|
||||
|
||||
const chooseOrganization = (e: Organization) => {
|
||||
where.organizationName = e.organizationName;
|
||||
where.organizationId = e.organizationId;
|
||||
search();
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
post.value = 0;
|
||||
sign.value = 0;
|
||||
noSign.value = 0;
|
||||
search();
|
||||
};
|
||||
|
||||
const count = () => {
|
||||
if (
|
||||
where.categoryId == undefined &&
|
||||
where.deliveryTime == undefined &&
|
||||
where.deliveryTimeStart == undefined
|
||||
) {
|
||||
console.log('sss>>>');
|
||||
loading.value = false;
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
countOrderGoods(where)
|
||||
.then((data) => {
|
||||
console.log('data>>>', data);
|
||||
if (data) {
|
||||
post.value = data.post;
|
||||
sign.value = data.sign;
|
||||
noSign.value = data.noSign;
|
||||
} else {
|
||||
post.value = 0;
|
||||
sign.value = 0;
|
||||
noSign.value = 0;
|
||||
}
|
||||
loading.value = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
message.error(err.message);
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = () => {
|
||||
if (!props.selection?.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'部门',
|
||||
'编号',
|
||||
'姓名',
|
||||
'早餐报餐次数',
|
||||
'早餐签到次数',
|
||||
'午餐报餐次数',
|
||||
'午餐签到次数',
|
||||
'晚餐报餐次数',
|
||||
'晚餐签到次数',
|
||||
'消费金额'
|
||||
]
|
||||
];
|
||||
props.selection?.forEach((d: OrderGoods) => {
|
||||
array.push([
|
||||
`${d.organizationName}`,
|
||||
`${d.userId}`,
|
||||
`${d.nickname}`,
|
||||
`${d.breakfastPostUsers}`,
|
||||
`${d.breakfastSignUsers}`,
|
||||
`${d.lunchPostUsers}`,
|
||||
`${d.lunchSignUsers}`,
|
||||
`${d.dinnerPostUsers}`,
|
||||
`${d.dinnerSignUsers}`
|
||||
]);
|
||||
});
|
||||
const sheetName = '报餐统计导出';
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 40 },
|
||||
{ wch: 10 }
|
||||
];
|
||||
writeFile(workbook, '报餐统计导出.xlsx');
|
||||
};
|
||||
|
||||
// const onRepairData = () => {
|
||||
// where.deliveryTime = deliveryTime.value
|
||||
// ? deliveryTime.value + ' 00:00:00'
|
||||
// : '';
|
||||
// // where.payStatus = 10;
|
||||
// repairData({}).then(() => {
|
||||
// // message.success(res.message);
|
||||
// });
|
||||
// };
|
||||
|
||||
// 批量删除
|
||||
// const removeBatch = () => {
|
||||
// emit('remove');
|
||||
// };
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
|
||||
count();
|
||||
</script>
|
||||
350
src/views/baocan/food/index.vue
Normal file
350
src/views/baocan/food/index.vue
Normal file
@@ -0,0 +1,350 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="orderGoodsId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 1200 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<!-- <template v-if="column.key === 'imageUrl'">-->
|
||||
<!-- <img :src="record.imageUrl" width="100" height="70" />-->
|
||||
<!-- </template>-->
|
||||
<template v-if="column.key === 'categoryId'">
|
||||
{{ record.categoryId === 25 ? '早餐' : '' }}
|
||||
{{ record.categoryId === 26 ? '午餐' : '' }}
|
||||
{{ record.categoryId === 27 ? '晚餐' : '' }}
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
{{ record.nickname }}
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryTime'">
|
||||
{{ toDateString(record.deliveryTime, 'MM-dd') }}
|
||||
{{ getWeek(record.week) }}
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryStatus'">
|
||||
<a-tag
|
||||
v-if="record.deliveryStatus === 10"
|
||||
color="orange"
|
||||
@click="onDeliveryStatus(record, 20)"
|
||||
>未签到</a-tag
|
||||
>
|
||||
<a-tag
|
||||
v-if="record.deliveryStatus === 20"
|
||||
color="green"
|
||||
@click="onDeliveryStatus(record, 10)"
|
||||
>已签到</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openInfo(record)">详情</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 订单详情 -->
|
||||
<order-info v-model:visible="showInfo" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import OrderInfo from './components/order-info.vue';
|
||||
import { getWeek } from '@/utils/common';
|
||||
import {
|
||||
pageOrderGoods,
|
||||
removeBatchOrderGoods,
|
||||
updateOrderGoods
|
||||
} from '@/api/order/goods';
|
||||
import type { OrderGoods, OrderGoodsParam } from '@/api/order/goods/model';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// key: 'index',
|
||||
// width: 48,
|
||||
// align: 'center',
|
||||
// fixed: 'left',
|
||||
// hideInSetting: true,
|
||||
// hideInTable: true,
|
||||
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
// },
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 120,
|
||||
// align: 'center',
|
||||
// fixed: 'left',
|
||||
// hideInSetting: true
|
||||
// },
|
||||
// {
|
||||
// title: '菜品封面图',
|
||||
// dataIndex: 'imageUrl',
|
||||
// key: 'imageUrl',
|
||||
// align: 'center'
|
||||
// },
|
||||
{
|
||||
title: '订单号',
|
||||
dataIndex: 'orderId',
|
||||
key: 'orderId',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '预定日期',
|
||||
dataIndex: 'deliveryTime',
|
||||
key: 'deliveryTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'nickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '菜品名称',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '餐段',
|
||||
dataIndex: 'categoryId',
|
||||
key: 'categoryId',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '数量',
|
||||
dataIndex: 'totalNum',
|
||||
align: 'center',
|
||||
sorter: true
|
||||
},
|
||||
// {
|
||||
// title: '付款状态',
|
||||
// dataIndex: 'payStatus',
|
||||
// align: 'center',
|
||||
// sorter: true,
|
||||
// customRender: ({ text }) => {
|
||||
// if (text == 10) {
|
||||
// return '未付款';
|
||||
// }
|
||||
// if (text == 20) {
|
||||
// return '已支付';
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// title: '订单状态',
|
||||
// dataIndex: 'orderStatus',
|
||||
// align: 'center',
|
||||
// sorter: true,
|
||||
// customRender: ({ text }) => {
|
||||
// if (text == 10) {
|
||||
// return '进行中';
|
||||
// }
|
||||
// if (text == 20) {
|
||||
// return '已取消';
|
||||
// }
|
||||
// if (text == 30) {
|
||||
// return '已完成';
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
{
|
||||
title: '签到状态',
|
||||
dataIndex: 'deliveryStatus',
|
||||
key: 'deliveryStatus',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '报餐时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<OrderGoods[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<OrderGoods | null>(null);
|
||||
// 是否显示资产详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.deliveryStatus) {
|
||||
where.deliveryStatus = filters.deliveryStatus;
|
||||
}
|
||||
where.payStatus = 20;
|
||||
where.hasNum = false;
|
||||
where.orderStatus = 10;
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
return pageOrderGoods({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form } = useFormData<OrderGoods>({
|
||||
orderGoodsId: undefined,
|
||||
deliveryStatus: undefined
|
||||
});
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: OrderGoodsParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openInfo = (row?: OrderGoods) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
const onDeliveryStatus = (row?: OrderGoods, deliveryStatus?: number) => {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要修改签到状态吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
form.orderGoodsId = row?.orderGoodsId;
|
||||
form.deliveryStatus = deliveryStatus;
|
||||
updateOrderGoods(form).then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchOrderGoods(selection.value.map((d) => d.orderGoodsId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: OrderGoods) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
// openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'OrderGoodsIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.comments {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
39
src/views/baocan/goods/components/category-select.vue
Normal file
39
src/views/baocan/goods/components/category-select.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- 目录选择下拉框 -->
|
||||
<template>
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
:placeholder="placeholder"
|
||||
:value="value || undefined"
|
||||
:tree-data="data"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="updateValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Goods } from '@/api/goods/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value?: number): void;
|
||||
}>();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据(v-modal)
|
||||
value?: number;
|
||||
// 提示信息
|
||||
placeholder?: string;
|
||||
// 文章分类
|
||||
data: Goods[];
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择上级分类'
|
||||
}
|
||||
);
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value?: number) => {
|
||||
emit('update:value', value);
|
||||
};
|
||||
</script>
|
||||
536
src/views/baocan/goods/components/goods-edit.vue
Normal file
536
src/views/baocan/goods/components/goods-edit.vue
Normal file
@@ -0,0 +1,536 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="650"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑菜品' : '添加菜品'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
@ok="save"
|
||||
>
|
||||
<a-tabs v-model:activeKey="activeKey" type="card">
|
||||
<a-tab-pane key="1" tab="基本信息">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ md: { span: 12 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
>
|
||||
<a-form-item label="菜品名称" name="goodsName">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入菜品名称"
|
||||
v-model:value="form.goodsName"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="菜品类别" name="categoryId">
|
||||
<category-select
|
||||
:data="categoryList"
|
||||
placeholder="请选择菜品类别"
|
||||
v-model:value="form.categoryId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-row :gutter="16">
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="所属档口" name="gear">
|
||||
<a-radio-group v-model:value="form.gear">
|
||||
<a-radio :value="10">食堂档口</a-radio>
|
||||
<a-radio :value="20">物品档口</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="菜品价格"
|
||||
name="goodsPriceMin"
|
||||
v-if="form.specType === 0"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.goodsPriceMin"
|
||||
/>
|
||||
<span class="ml-10">元</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item
|
||||
label="内部员工临时报餐价"
|
||||
name="linePrice"
|
||||
v-if="form.specType === 0"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.linePriceMin"
|
||||
/>
|
||||
<span class="ml-10">元</span>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="外部人员价格"
|
||||
name="linePriceMax"
|
||||
v-if="form.specType === 0"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
v-model:value="form.linePriceMax"
|
||||
/>
|
||||
<span class="ml-10">元</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-form-item label="菜品图片" name="images">
|
||||
<ele-image-upload
|
||||
v-model:value="images"
|
||||
:limit="14"
|
||||
:drag="true"
|
||||
:multiple="true"
|
||||
:upload-handler="uploadHandler"
|
||||
@upload="onUpload"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" tab="其他信息">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
>
|
||||
<a-form-item label="是否开启限购" name="purchaseLimit">
|
||||
<a-radio-group v-model:value="form.purchaseLimit">
|
||||
<a-radio :value="0">否</a-radio>
|
||||
<a-radio :value="1">是</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="状态" name="status">
|
||||
<a-radio-group v-model:value="form.status">
|
||||
<a-radio :value="0">上架</a-radio>
|
||||
<a-radio :value="1">下架</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="99999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号(数字越小越靠前)"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { Goods } from '@/api/goods/model';
|
||||
import { addGoods, updateGoods } from '@/api/goods';
|
||||
import { FormInstance, Rule, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import CategorySelect from './category-select.vue';
|
||||
import TinymceEditor from '@/components/TinymceEditor/index.vue';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { createCode } from '@/utils/common';
|
||||
// import MultiSpec from './MultiSpec.vue';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
// const disabled = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Goods | null;
|
||||
categoryList?: Category[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否开启响应式布局
|
||||
// const themeStore = useThemeStore();
|
||||
// const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 选项卡位置
|
||||
const activeKey = ref('1');
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Goods>({
|
||||
goodsType: 1,
|
||||
goodsName: '',
|
||||
goodsCode: `G${createCode()}`,
|
||||
categoryId: 0,
|
||||
image: '',
|
||||
files: '',
|
||||
goodsPriceMin: 0,
|
||||
linePriceMin: 0,
|
||||
linePriceMax: 0,
|
||||
createTime: '',
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0,
|
||||
goodsId: 0,
|
||||
specType: 0,
|
||||
deliveryType: 0,
|
||||
period: undefined,
|
||||
gear: 10,
|
||||
content: '',
|
||||
deliveryId: 0,
|
||||
sellingPoint: '',
|
||||
purchaseLimit: 1,
|
||||
deductStockType: 10,
|
||||
salesActual: 180,
|
||||
goodsWeight: 0,
|
||||
stockTotal: 2000
|
||||
});
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (item) => {
|
||||
const { file } = item;
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: FILE_THUMBNAIL + data.path,
|
||||
status: 'done'
|
||||
});
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
goodsName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入菜品名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
categoryId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择菜品分类',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
goodsCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写菜品编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
gear: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择所属档口',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deliveryType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择配送方式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
goodsPriceMin: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入菜品价格',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
stockTotal: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入菜品库存',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
specType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择规格类型',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deliveryId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择运费模板',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择菜品状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
deductStockType: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置库存计算方式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
purchaseLimit: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置是否限购',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
images: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择菜品图片',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (images.value.length == 0) {
|
||||
return Promise.reject('请上传菜品图片');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
customerId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择客户'
|
||||
}
|
||||
],
|
||||
linePriceMin: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入菜品划线价',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入文章内容',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (content.value == '') {
|
||||
return Promise.reject('请输入文字内容');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
brand: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选项菜品厂商',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
|
||||
// const config = ref({
|
||||
// height: 500,
|
||||
// // 自定义文件上传(这里使用把选择的文件转成 blob 演示)
|
||||
// file_picker_callback: (callback: any, _value: any, meta: any) => {
|
||||
// const input = document.createElement('input');
|
||||
// input.setAttribute('type', 'file');
|
||||
// // 设定文件可选类型
|
||||
// if (meta.filetype === 'image') {
|
||||
// input.setAttribute('accept', 'image/*');
|
||||
// } else if (meta.filetype === 'media') {
|
||||
// input.setAttribute('accept', 'video/*');
|
||||
// }
|
||||
// input.onchange = () => {
|
||||
// const file = input.files?.[0];
|
||||
// if (!file) {
|
||||
// return;
|
||||
// }
|
||||
// if (meta.filetype === 'media') {
|
||||
// if (!file.type.startsWith('video/')) {
|
||||
// editorRef.value?.alert({ content: '只能选择视频文件' });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if (file.size / 1024 / 1024 > 20) {
|
||||
// editorRef.value?.alert({ content: '大小不能超过 20MB' });
|
||||
// return;
|
||||
// }
|
||||
// const reader = new FileReader();
|
||||
// reader.onload = (e) => {
|
||||
// if (e.target?.result != null) {
|
||||
// const blob = new Blob([e.target.result], { type: file.type });
|
||||
// callback(URL.createObjectURL(blob));
|
||||
// }
|
||||
// };
|
||||
// reader.readAsArrayBuffer(file);
|
||||
// };
|
||||
// input.click();
|
||||
// }
|
||||
// });
|
||||
|
||||
// const onSelect = (item) => {
|
||||
// form.goodsId = item.goodsId;
|
||||
// };
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 获取第一张图片作为封面图
|
||||
images.value.map((d, i) => {
|
||||
if (i === 0) {
|
||||
form.image = d.url;
|
||||
}
|
||||
});
|
||||
const goodsForm = {
|
||||
...form,
|
||||
files: JSON.stringify(images.value),
|
||||
content: content.value
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateGoods : addGoods;
|
||||
saveOrUpdate(goodsForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data,
|
||||
files: JSON.parse(String(props.data.files))
|
||||
});
|
||||
images.value = JSON.parse(String(props.data.files));
|
||||
content.value = props.data.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
content.value = '';
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
65
src/views/baocan/goods/components/goods-search.vue
Normal file
65
src/views/baocan/goods/components/goods-search.vue
Normal file
@@ -0,0 +1,65 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-form
|
||||
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
||||
>
|
||||
<a-row>
|
||||
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="服务器名称">
|
||||
<a-input
|
||||
v-model:value.trim="where.name"
|
||||
placeholder="请输入服务器名称"
|
||||
allow-clear
|
||||
@pressEnter="search"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="IP地址">
|
||||
<a-input
|
||||
v-model:value.trim="where.code"
|
||||
placeholder="请输入服务器IP"
|
||||
allow-clear
|
||||
@pressEnter="search"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
||||
<a-form-item class="ele-text-right" :wrapper-col="{ span: 24 }">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="search">查询</a-button>
|
||||
<a-button @click="reset">重置</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { AssetsParam } from '@/api/oa/assets/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: AssetsParam): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<AssetsParam>({
|
||||
name: '',
|
||||
code: '',
|
||||
isExpire: ''
|
||||
});
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
search();
|
||||
};
|
||||
</script>
|
||||
131
src/views/baocan/goods/components/search.vue
Normal file
131
src/views/baocan/goods/components/search.vue
Normal file
@@ -0,0 +1,131 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
v-permission="'shop:goods:save'"
|
||||
@click="add"
|
||||
>
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
v-if="props.selection.length > 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-radio-group v-model:value="listType" @change="handleTabs">
|
||||
<a-radio-button value="all">全部</a-radio-button>
|
||||
<a-radio-button value="onSale">出售中</a-radio-button>
|
||||
<a-radio-button value="offSale">已下架</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
|
||||
<a-select-option value="goodsName">菜品名称</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input-search>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { GoodsParam } from '@/api/goods/model';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GoodsParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<GoodsParam>({
|
||||
goodsId: undefined,
|
||||
goodsName: '',
|
||||
goodsCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('goodsName');
|
||||
// tabType
|
||||
const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
if (type.value == 'goodsName') {
|
||||
where.goodsName = searchText.value;
|
||||
where.goodsCode = undefined;
|
||||
}
|
||||
if (type.value == 'goodsCode') {
|
||||
where.goodsCode = searchText.value;
|
||||
where.goodsName = undefined;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
listType.value = e.target.value;
|
||||
if (listType.value == 'all') {
|
||||
resetFields();
|
||||
}
|
||||
if (listType.value == 'onSale') {
|
||||
where.status = 0;
|
||||
}
|
||||
if (listType.value == 'offSale') {
|
||||
where.status = 1;
|
||||
}
|
||||
if (listType.value == 'soldOut') {
|
||||
where.stockTotal = 0;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
344
src/views/baocan/goods/index.vue
Normal file
344
src/views/baocan/goods/index.vue
Normal file
@@ -0,0 +1,344 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="goodsId"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@search="reload"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :preview="false" :width="80" />
|
||||
</template>
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<a-tooltip :title="record.goodsName">
|
||||
<div class="ele-text-heading">
|
||||
<b>{{ record.goodsName }}</b>
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
{{ record.comments }}
|
||||
</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'gear'">
|
||||
<a-tag v-if="record.gear === 10" color="red">食堂档口</a-tag>
|
||||
<a-tag v-if="record.gear === 20">物品档口</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">上架</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="orange">下架</a-tag>
|
||||
</template>
|
||||
<!-- <template v-if="column.key === 'comments'">-->
|
||||
<!-- <a-tooltip :title="record.comments" placement="topLeft">-->
|
||||
<!-- {{ record.comments }}-->
|
||||
<!-- </a-tooltip>-->
|
||||
<!-- </template>-->
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<goods-edit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:category-list="data"
|
||||
@done="reload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo, toTreeData } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import GoodsEdit from './components/goods-edit.vue';
|
||||
import { pageGoods, removeGoods, removeBatchGoods } from '@/api/goods';
|
||||
import type { Goods, GoodsParam } from '@/api/goods/model';
|
||||
import { listCategory } from '@/api/goods/category';
|
||||
import { Category } from '@/api/goods/category/model';
|
||||
import { FILE_THUMBNAIL } from '@/config/setting';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 树展开的key
|
||||
const expandedRowKeys = ref<number[]>([]);
|
||||
// 树选中的key
|
||||
const selectedRowKeys = ref<number[]>([]);
|
||||
// 当前用户信息
|
||||
// const brand = getDictionaryOptions('serverBrand');
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '菜品图片',
|
||||
dataIndex: 'image',
|
||||
width: 110,
|
||||
key: 'image'
|
||||
},
|
||||
{
|
||||
title: '菜品名称',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName',
|
||||
width: 320,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '所属档口',
|
||||
dataIndex: 'gear',
|
||||
key: 'gear'
|
||||
},
|
||||
{
|
||||
title: '类别',
|
||||
dataIndex: 'categoryName'
|
||||
},
|
||||
{
|
||||
title: '菜品价格',
|
||||
dataIndex: 'goodsPriceMin',
|
||||
key: 'goodsPriceMin',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
hideInTable: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
sorter: true,
|
||||
key: 'status',
|
||||
showSorterTooltip: false,
|
||||
customRender: ({ text }) => ['上架', '下架'][text]
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sortNumber',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Goods[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Goods | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 树形数据
|
||||
const data = ref<Category[]>([]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return pageGoods({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
listCategory()
|
||||
.then((list) => {
|
||||
loading.value = false;
|
||||
const eks: number[] = [];
|
||||
list.forEach((d) => {
|
||||
d.key = d.categoryId;
|
||||
d.value = d.categoryId;
|
||||
if (typeof d.categoryId === 'number') {
|
||||
eks.push(d.categoryId);
|
||||
}
|
||||
});
|
||||
expandedRowKeys.value = eks;
|
||||
data.value = toTreeData({
|
||||
data: list,
|
||||
idField: 'categoryId',
|
||||
parentIdField: 'parentId'
|
||||
});
|
||||
if (list.length) {
|
||||
if (typeof list[0].categoryId === 'number') {
|
||||
selectedRowKeys.value = [list[0].categoryId];
|
||||
}
|
||||
current.value = list[0];
|
||||
} else {
|
||||
selectedRowKeys.value = [];
|
||||
current.value = null;
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: GoodsParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Goods) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Goods) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeGoods(row.goodsId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchGoods(selection.value.map((d) => d.goodsId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Goods) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'GoodsIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
215
src/views/baocan/notice/components/bc-equipment-edit.vue
Normal file
215
src/views/baocan/notice/components/bc-equipment-edit.vue
Normal file
@@ -0,0 +1,215 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="880"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '编辑设备' : '添加设备'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="设备编码" name="equipmentCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备编码"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属档口" name="gear">
|
||||
<a-radio-group v-model:value="form.gear">
|
||||
<a-radio :value="10">食堂档口</a-radio>
|
||||
<a-radio :value="20">物品档口</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入描述内容"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="启用状态" name="status">-->
|
||||
<!-- <a-switch :checked="form.status === 0" @change="editStatus" />-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BcEquipment } from '@/api/apps/bc/equipment/model';
|
||||
import { addBcEquipment, updateBcEquipment } from '@/api/apps/bc/equipment';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BcEquipment | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<BcEquipment>({
|
||||
bcEquipmentId: undefined,
|
||||
equipmentName: undefined,
|
||||
equipmentCode: '',
|
||||
gear: 10,
|
||||
createTime: '',
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写设备编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateBcEquipment(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const equipmentForm = {
|
||||
...form
|
||||
};
|
||||
console.log(equipmentForm, 'equipmentForm');
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateBcEquipment
|
||||
: addBcEquipment;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
107
src/views/baocan/notice/components/search.vue
Normal file
107
src/views/baocan/notice/components/search.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>绑定设备</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
:disabled="props.selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-input-search-->
|
||||
<!-- allow-clear-->
|
||||
<!-- v-model:value="searchText"-->
|
||||
<!-- placeholder="请输入搜索关键词"-->
|
||||
<!-- @search="search"-->
|
||||
<!-- @pressEnter="search"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<EquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
equipmentName: '',
|
||||
equipmentCode: '',
|
||||
merchantCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
// const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
where.equipmentName = undefined;
|
||||
where.equipmentCode = undefined;
|
||||
where.merchantCode = undefined;
|
||||
if (type.value == 'equipmentName') {
|
||||
where.equipmentName = searchText.value;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
231
src/views/baocan/notice/index.vue
Normal file
231
src/views/baocan/notice/index.vue
Normal file
@@ -0,0 +1,231 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="标题" name="title">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入标题"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.title"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="发送范围" name="channel">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入用户名"
|
||||
v-model:value="form.channel"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="内容" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入内容"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
style="margin-top: 10px"
|
||||
@click="save"
|
||||
>
|
||||
<span>保存</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
class="ele-btn-icon"
|
||||
style="margin-top: 10px"
|
||||
@click="send"
|
||||
>
|
||||
<span>发送</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BcEquipment } from '@/api/apps/bc/equipment/model';
|
||||
import {
|
||||
addBcEquipment,
|
||||
updateBcEquipment,
|
||||
addSend
|
||||
} from '@/api/apps/bc/equipment';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { Notice } from '@/api/oa/notice/model';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BcEquipment | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Notice>({
|
||||
title: '通知',
|
||||
channel: 'ZhaiLing',
|
||||
comments: '您的申请已通过',
|
||||
status: 0
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
channel: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择发布范围',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
comments: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写内容',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateBcEquipment(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
const send = () => {
|
||||
addSend(form).then();
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const equipmentForm = {
|
||||
...form
|
||||
};
|
||||
console.log(equipmentForm, 'equipmentForm');
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateBcEquipment
|
||||
: addBcEquipment;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
118
src/views/baocan/order/components/field.vue
Normal file
118
src/views/baocan/order/components/field.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="500px"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`修改价格`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form layout="horizontal">
|
||||
<a-form-item>
|
||||
<a-input-number :min="0" style="width: 200px" v-model:value="content" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { updateOrder } from '@/api/order';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { createOrderNo } from "@/utils/common";
|
||||
// import { reloadPageTab } from '@/utils/page-tab-util';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
data?: Order | null;
|
||||
// 修改回显的数据
|
||||
field?: string | null;
|
||||
orderId?: number | 0;
|
||||
content?: number | 0;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const content = ref<number>(0);
|
||||
const placeholder = ref('请输入订单金额');
|
||||
// 用户信息
|
||||
const form = reactive<Order>({
|
||||
orderId: 0,
|
||||
comments: '',
|
||||
payPrice: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(form);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 判断更新字段
|
||||
form.orderId = props.orderId;
|
||||
if (props.field === 'payPrice') {
|
||||
form.payPrice = Number(content.value);
|
||||
form.totalPrice = Number(content.value);
|
||||
form.orderNo = createOrderNo();
|
||||
}
|
||||
updateOrder(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.orderId) {
|
||||
loading.value = false;
|
||||
content.value = props.content;
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
|
||||
if (props.field == 'tenantCode') {
|
||||
placeholder.value = '请输入要绑定的主体编号';
|
||||
content.value = undefined;
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
139
src/views/baocan/order/components/markdown.vue
Normal file
139
src/views/baocan/order/components/markdown.vue
Normal file
@@ -0,0 +1,139 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="600px"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="`修改内容`"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<!-- 编辑器 -->
|
||||
<byte-md-editor
|
||||
v-model:value="content"
|
||||
:locale="zh_Hans"
|
||||
:plugins="plugins"
|
||||
uploadImages
|
||||
height="300px"
|
||||
:editorConfig="{ lineNumbers: true }"
|
||||
/>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { updateOrder } from '@/api/order';
|
||||
import { Order } from '@/api/order/model';
|
||||
// import { reloadPageTab } from '@/utils/page-tab-util';
|
||||
import 'bytemd/dist/index.min.css';
|
||||
import 'github-markdown-css/github-markdown-light.css';
|
||||
// import TinymceEditor from '@/components/TinymceEditor/index.vue';
|
||||
import ByteMdEditor from '@/components/ByteMdEditor/index.vue';
|
||||
import highlight from '@bytemd/plugin-highlight';
|
||||
// 中文语言文件
|
||||
import zh_Hans from 'bytemd/locales/zh_Hans.json';
|
||||
// // 链接、删除线、复选框、表格等的插件
|
||||
import gfm from '@bytemd/plugin-gfm';
|
||||
// // 插件的中文语言文件
|
||||
import zh_HansGfm from '@bytemd/plugin-gfm/locales/zh_Hans.json';
|
||||
// // 预览界面的样式,这里用的 github 的 markdown 主题
|
||||
import 'github-markdown-css/github-markdown-light.css';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
data?: Order | null;
|
||||
// 修改回显的数据
|
||||
field?: string | null;
|
||||
content?: string;
|
||||
orderId?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 插件
|
||||
const plugins = ref([
|
||||
gfm({
|
||||
locale: zh_HansGfm
|
||||
}),
|
||||
highlight()
|
||||
]);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const content = ref('');
|
||||
// 用户信息
|
||||
const form = reactive<Order>({
|
||||
orderId: 0,
|
||||
comments: ''
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(form);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 判断更新字段
|
||||
form.orderId = props.orderId;
|
||||
if (props.field === 'content') {
|
||||
form.comments = content.value;
|
||||
}
|
||||
if (props.field === 'comments') {
|
||||
form.comments = content.value;
|
||||
}
|
||||
updateOrder(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
content.value = String(props.content);
|
||||
console.log(visible);
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
content.value = String(props.content);
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
289
src/views/baocan/order/components/order-edit.vue
Normal file
289
src/views/baocan/order/components/order-edit.vue
Normal file
@@ -0,0 +1,289 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="680"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑订单' : '添加订单'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-space>
|
||||
<a-form
|
||||
:label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="订单名称" v-bind="validateInfos.customerName">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="30"
|
||||
placeholder="请输入订单名称"
|
||||
v-model:value="form.customerName"
|
||||
@blur="
|
||||
validate('customerName', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单标识" v-bind="validateInfos.customerCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入用户账号"
|
||||
v-model:value="form.customerCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="跟进状态" v-bind="validateInfos.progress">
|
||||
<progress-select
|
||||
v-model:value="form.progress"
|
||||
@blur="
|
||||
validate('progress', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单类型" v-bind="validateInfos.customerType">
|
||||
<type-select
|
||||
v-model:value="form.customerType"
|
||||
@blur="
|
||||
validate('customerType', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="订单来源" v-bind="validateInfos.customerSource">
|
||||
<source-select
|
||||
v-model:value="form.customerSource"
|
||||
@blur="
|
||||
validate('customerSource', { trigger: 'blur' }).catch(() => {})
|
||||
"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="头像" v-bind="validateInfos.customerAvatar">
|
||||
<ele-image-upload
|
||||
v-model:value="images"
|
||||
:item-style="{ width: '90px', height: '90px' }"
|
||||
:limit="1"
|
||||
@upload="onUpload"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :sm="24" :xs="24">
|
||||
<a-form-item label="联系人" v-bind="validateInfos.customerContacts">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写联系人"
|
||||
v-model:value="form.customerContacts"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="手机号码" v-bind="validateInfos.customerMobile">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写联系人手机号码"
|
||||
v-model:value="form.customerMobile"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="联系地址"
|
||||
v-bind="validateInfos.customerAddress"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请填写联系地址"
|
||||
v-model:value="form.customerAddress"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="公司座机" v-bind="validateInfos.customerPhone">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请填写公司座机电话"
|
||||
v-model:value="form.customerPhone"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" v-bind="validateInfos.sortNumber">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="排序"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" v-bind="validateInfos.comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-space>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import TypeSelect from './customer-edit/type-select.vue';
|
||||
import ProgressSelect from './customer-edit/progress-select.vue';
|
||||
import SourceSelect from './customer-edit/source-select.vue';
|
||||
import { addCustomer, updateCustomer } from '@/api/oa/customer';
|
||||
import type { Customer } from '@/api/oa/customer/model';
|
||||
import { createCode } from '@/utils/common';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import type { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FILE_SERVER } from '@/config/setting';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Customer | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<Customer>({
|
||||
customerCode: '',
|
||||
customerName: '',
|
||||
customerType: undefined,
|
||||
progress: undefined,
|
||||
customerMobile: '',
|
||||
customerAvatar: '',
|
||||
customerPhone: '',
|
||||
customerContacts: '',
|
||||
customerAddress: '',
|
||||
comments: '',
|
||||
status: '0',
|
||||
sortNumber: 100,
|
||||
customerId: 0,
|
||||
userId: '',
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
customerName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入订单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
customerCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入合法的IP地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
progress: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择跟进状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
form.customerName = form.customerName?.replace(/\s*/g, '');
|
||||
if(isUpdate.value == false) {
|
||||
form.userId = loginUser.value.userId;
|
||||
}
|
||||
const data = {
|
||||
...form
|
||||
};
|
||||
// 转字符串
|
||||
const saveOrUpdate = isUpdate.value ? updateCustomer : addCustomer;
|
||||
saveOrUpdate(data)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
form.customerAvatar = result.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
// 头像赋值
|
||||
images.value = [];
|
||||
if(props.data.customerAvatar){
|
||||
images.value.push({ uid:1, url: FILE_SERVER + props.data.customerAvatar, status: '' });
|
||||
}
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.customerCode = createCode();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
379
src/views/baocan/order/components/order-info.vue
Normal file
379
src/views/baocan/order/components/order-info.vue
Normal file
@@ -0,0 +1,379 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="`80%`"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑订单' : '订单详情'"
|
||||
:body-style="{ paddingBottom: '8px', background: '#f3f3f3' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
:footer="null"
|
||||
@ok="save"
|
||||
>
|
||||
<a-card title="订单详情" class="order-card">
|
||||
<!-- <a-space>-->
|
||||
<!-- <a-button>发货</a-button>-->
|
||||
<!-- <a-button>商家备注</a-button>-->
|
||||
<!-- <a-button>打印小票</a-button>-->
|
||||
<!-- </a-space>-->
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单号" name="orderId">
|
||||
<span>{{ data.orderId }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="实付款金额" name="payPrice">
|
||||
<span class="ele-text-warning"
|
||||
>¥{{ formatNumber(data.payPrice) }}</span
|
||||
>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单状态" name="orderStatus">
|
||||
<a-tag>{{ data.payStatus === 20 ? '已下单' : '' }}</a-tag>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家信息" name="deliveryType">
|
||||
<router-link :to="'/system/user/details?id=' + data.userId">
|
||||
<span class="ele-text-primary">{{ data.nickname }}</span>
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="预定日期" name="deliveryTime">
|
||||
{{ toDateString(data.deliveryTime, 'yyyy-MM-dd') }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="下单时间" name="createTime">
|
||||
{{ data.createTime }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="交易流水号" name="orderNo">
|
||||
{{ data.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家留言" name="buyerRemark">
|
||||
<span>{{ data.buyerRemark }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单备注" name="comments">
|
||||
<span>{{ data.comments }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-card title="菜品信息" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="orderGoodsList"
|
||||
:columns="columns"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<div class="goods-info">
|
||||
<a-image
|
||||
v-if="record.imageUrl"
|
||||
:src="record.imageUrl"
|
||||
:preview="false"
|
||||
:width="50"
|
||||
/>
|
||||
<div class="info">
|
||||
<div>{{ record.goodsName }}</div>
|
||||
<div class="ele-text-placeholder" v-if="record.gear === 10">
|
||||
食堂档口
|
||||
</div>
|
||||
<div class="ele-text-placeholder" v-if="record.gear === 20">
|
||||
物品档口
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { assignObject, toDateString } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { OrderGoods } from '@/api/order/goods/model';
|
||||
import { listOrderGoods } from '@/api/order/goods';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
export interface step {
|
||||
title?: String | undefined;
|
||||
subTitle?: String | undefined;
|
||||
description?: String | undefined;
|
||||
}
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const orderGoodsList = ref<OrderGoods[]>([]);
|
||||
|
||||
// 步骤条
|
||||
const steps = ref<step[]>([
|
||||
{
|
||||
title: '报餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '付款',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '发餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '取餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '完成',
|
||||
description: undefined
|
||||
}
|
||||
]);
|
||||
const active = ref(2);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 订单信息
|
||||
const order = reactive<Order>({
|
||||
orderId: undefined,
|
||||
orderNo: '',
|
||||
userId: undefined,
|
||||
orderSourceData: ''
|
||||
});
|
||||
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
|
||||
const { resetFields } = useForm(order);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: '菜品ID',
|
||||
// dataIndex: 'goodsId'
|
||||
// },
|
||||
{
|
||||
title: '菜品信息',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '菜品价格',
|
||||
dataIndex: 'goodsPrice',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '购买数量',
|
||||
dataIndex: 'totalNum',
|
||||
key: 'totalNum'
|
||||
},
|
||||
{
|
||||
title: '预定日期',
|
||||
dataIndex: 'deliveryTime',
|
||||
key: 'deliveryTime',
|
||||
customRender: () => toDateString(props.data?.deliveryTime, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'deliveryStatus',
|
||||
key: 'deliveryStatus',
|
||||
customRender: ({ text }) => (text == 10 ? '未签到' : '已签到')
|
||||
}
|
||||
]);
|
||||
|
||||
/* 制作步骤条 */
|
||||
const loadSteps = (order) => {
|
||||
steps.value = [];
|
||||
steps.value.push({
|
||||
title: '下单'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '付款'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '发货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '收货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '完成'
|
||||
});
|
||||
|
||||
// 下单
|
||||
if (order.payStatus == 10) {
|
||||
active.value = 0;
|
||||
steps.value[0].description = order.createTime;
|
||||
}
|
||||
// 付款
|
||||
if (order.payStatus == 20) {
|
||||
active.value = 1;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
}
|
||||
// 发货
|
||||
if (order.payStatus == 20 && order.deliveryStatus == 20) {
|
||||
active.value = 2;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
}
|
||||
// 收货
|
||||
if (order.payStatus == 20 && order.receiptStatus == 20) {
|
||||
active.value = 3;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 完成
|
||||
if (order.payStatus == 20 && order.orderStatus == 30) {
|
||||
active.value = 4;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 已取消
|
||||
if (order.orderStatus == 20) {
|
||||
active.value = 4;
|
||||
}
|
||||
};
|
||||
|
||||
const getOrderGoods = () => {
|
||||
const orderId = props.data?.orderId;
|
||||
listOrderGoods({ orderId }).then((data) => {
|
||||
orderGoodsList.value = data.filter((d) => d.totalNum > 0);
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignObject(order, props.data);
|
||||
loadSteps(props.data);
|
||||
getOrderGoods();
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.order-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ant-form-item {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.goods-info {
|
||||
display: flex;
|
||||
.info {
|
||||
padding-left: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
161
src/views/baocan/order/components/search.vue
Normal file
161
src/views/baocan/order/components/search.vue
Normal file
@@ -0,0 +1,161 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-radio-group v-model:value="listType" @change="handleTabs">
|
||||
<a-radio-button :value="0">全部</a-radio-button>
|
||||
<a-radio-button :value="1">已下单</a-radio-button>
|
||||
<a-radio-button :value="4">已完成</a-radio-button>
|
||||
<a-radio-button :value="5">待付款</a-radio-button>
|
||||
<a-radio-button :value="6">临时报餐</a-radio-button>
|
||||
</a-radio-group>
|
||||
<a-date-picker
|
||||
placeholder="预定日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model:value="where.deliveryTime"
|
||||
@change="search"
|
||||
/>
|
||||
<a-select
|
||||
v-model:value="where.week"
|
||||
style="width: 120px"
|
||||
placeholder="请选择星期"
|
||||
allow-clear
|
||||
@change="handleWeek"
|
||||
>
|
||||
<a-select-option :value="1">星期一</a-select-option>
|
||||
<a-select-option :value="2">星期二</a-select-option>
|
||||
<a-select-option :value="3">星期三</a-select-option>
|
||||
<a-select-option :value="4">星期四</a-select-option>
|
||||
<a-select-option :value="5">星期五</a-select-option>
|
||||
<a-select-option :value="6">星期六</a-select-option>
|
||||
<a-select-option :value="0">星期日</a-select-option>
|
||||
</a-select>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="where.keywords"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { OrderParam } from '@/api/order/model';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: OrderParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<OrderParam>({
|
||||
orderNo: undefined,
|
||||
userId: undefined,
|
||||
payStatus: undefined,
|
||||
week: undefined,
|
||||
deliveryStatus: undefined,
|
||||
orderStatus: undefined
|
||||
});
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
const listType = ref<number>(0);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
emit('search', {
|
||||
...where,
|
||||
createTimeStart: d1 ? d1 + ' 00:00:00' : '',
|
||||
createTimeEnd: d2 ? d2 + ' 23:59:59' : '',
|
||||
deliveryTime: where.deliveryTime ? where.deliveryTime + ' 00:00:00' : ''
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
const handleTabs = (e) => {
|
||||
resetFields();
|
||||
const listType = Number(e.target.value);
|
||||
|
||||
// 全部订单
|
||||
if (listType == 0) {
|
||||
assignObject(where, {});
|
||||
console.log('全部');
|
||||
}
|
||||
// 待发货
|
||||
if (listType == 1) {
|
||||
console.log('已下单');
|
||||
where.payStatus = 20;
|
||||
where.orderStatus = 10;
|
||||
}
|
||||
// 待收货
|
||||
// if (listType == 2) {
|
||||
// console.log('待发货');
|
||||
// where.payStatus = 20;
|
||||
// where.deliveryStatus = 20;
|
||||
// where.receiptStatus = 10;
|
||||
// }
|
||||
// 待付款
|
||||
// if (listType == 3) {
|
||||
// console.log('待付款');
|
||||
// where.orderStatus = 20;
|
||||
// }
|
||||
// 已完成
|
||||
if (listType == 4) {
|
||||
console.log('已完成');
|
||||
where.payStatus = 20;
|
||||
where.deliveryStatus = 30;
|
||||
}
|
||||
// 已取消
|
||||
if (listType == 5) {
|
||||
where.payStatus = 10;
|
||||
}
|
||||
// 已取消
|
||||
if (listType == 6) {
|
||||
console.log('临时报餐');
|
||||
where.isTemporary = 1;
|
||||
}
|
||||
console.log(where);
|
||||
emit('search', {
|
||||
...where
|
||||
});
|
||||
};
|
||||
|
||||
const handleWeek = (index) => {
|
||||
where.week = index;
|
||||
search();
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
415
src/views/baocan/order/index.vue
Normal file
415
src/views/baocan/order/index.vue
Normal file
@@ -0,0 +1,415 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="orderId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 1200 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@advanced="openAdvanced"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'totalPrice'">
|
||||
<span class="ele-text-warning price-edit">
|
||||
¥{{ record.totalPrice }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryTime'">
|
||||
{{ toDateString(record.deliveryTime, 'MM-dd') }}
|
||||
{{ getWeek(record.week) }}
|
||||
</template>
|
||||
<template v-if="column.key === 'goods'">
|
||||
<template v-if="record.equipment">
|
||||
<p class="ele-text">{{ record.equipment.equipmentName }}</p>
|
||||
<p class="ele-text">{{ record.equipment.batteryModel }}</p>
|
||||
<p class="ele-text">{{ record.equipment.equipmentCode }}</p>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'payMethod'">
|
||||
<a-tag v-if="record.payMethod === '10'" color="orange"
|
||||
>余额支付</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '20'" color="green"
|
||||
>微信支付</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '30'" color="blue"
|
||||
>支付宝</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payMethod === '40'" color="purple"
|
||||
>通联支付</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'deliveryType'">
|
||||
<span v-if="record.deliveryType === 10">快递配送</span>
|
||||
<span v-if="record.deliveryType === 20">门店自提</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'payStatus'">
|
||||
<a-tag
|
||||
v-if="record.payStatus === 20 && record.orderStatus === 10"
|
||||
color="green"
|
||||
>已下单</a-tag
|
||||
>
|
||||
<a-tag
|
||||
v-if="record.payStatus === 20 && record.orderStatus === 20"
|
||||
color="red"
|
||||
>已撤单</a-tag
|
||||
>
|
||||
<a-tag v-if="record.payStatus === 10" color="red">未付款</a-tag>
|
||||
<a-tag v-if="record.orderStatus === 30" color="green"
|
||||
>已核销</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<FormOutlined
|
||||
@click="onEditContent('comments', record.comments, record)"
|
||||
/>
|
||||
<a-popover placement="topLeft">
|
||||
<template #content>
|
||||
<div class="comments">{{ record.comments }}</div>
|
||||
</template>
|
||||
{{ record.comments }}
|
||||
</a-popover>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === '0'" color="green">正常</a-tag>
|
||||
<a-tag v-if="record.status === '1'" color="red">禁用</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
{{ record.username }}
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'goodsList'">
|
||||
<div v-for="(item, index) in record.goodsList" :key="index">
|
||||
<div class="ele-text-secondary">
|
||||
{{ item.goodsName }} x{{ item.totalNum }}
|
||||
</div>
|
||||
<div class="ele-text-placeholder">
|
||||
{{ item.deliveryStatus === 10 ? '未签到' : '已签到' }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openInfo(record)">详情</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<Markdown
|
||||
v-model:visible="showMarkdown"
|
||||
:data="data"
|
||||
:field="field"
|
||||
:orderId="orderId"
|
||||
:content="markdown"
|
||||
@done="reload"
|
||||
/>
|
||||
<Field
|
||||
v-model:visible="showEdit"
|
||||
:data="data"
|
||||
:field="field"
|
||||
:orderId="orderId"
|
||||
:content="content"
|
||||
@done="reload"
|
||||
/>
|
||||
<!-- 订单详情 -->
|
||||
<order-info v-model:visible="showInfo" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
FormOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Markdown from './components/markdown.vue';
|
||||
import Field from './components/field.vue';
|
||||
import OrderInfo from './components/order-info.vue';
|
||||
import { pageOrder, removeBatchOrder } from '@/api/order';
|
||||
// import { alipayQuery } from '@/api/system/payment';
|
||||
import type { Order, OrderParam } from '@/api/order/model';
|
||||
import { getWeek } from '@/utils/common';
|
||||
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '订单号',
|
||||
dataIndex: 'orderId',
|
||||
key: 'orderId'
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname'
|
||||
},
|
||||
{
|
||||
title: '预定日期',
|
||||
dataIndex: 'deliveryTime',
|
||||
key: 'deliveryTime'
|
||||
},
|
||||
{
|
||||
title: '订单金额(元)',
|
||||
dataIndex: 'totalPrice',
|
||||
key: 'totalPrice',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '菜品信息',
|
||||
dataIndex: 'goodsList',
|
||||
key: 'goodsList'
|
||||
},
|
||||
{
|
||||
title: '临时报餐',
|
||||
dataIndex: 'isTemporary',
|
||||
customRender: ({ text }) => ['否', '是'][text]
|
||||
},
|
||||
{
|
||||
title: '报餐时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '交易状态',
|
||||
key: 'payStatus'
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Order[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Order | null>(null);
|
||||
// 是否显示资产详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const markdown = ref('请输入备注内容');
|
||||
const content = ref('请输入要修改的内容');
|
||||
const showMarkdown = ref(false);
|
||||
// const deliveryEdit = ref(false);
|
||||
const field = ref('comments');
|
||||
const orderId = ref(undefined);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payMethod) {
|
||||
where.payMethod = filters.payMethod;
|
||||
}
|
||||
if (filters.deliveryType) {
|
||||
where.deliveryType = filters.deliveryType;
|
||||
}
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.orderSource) {
|
||||
where.orderSource = filters.orderSource;
|
||||
}
|
||||
where.showGoodsList = true;
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
// where.payStatus = 20;
|
||||
return pageOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: OrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// const onEdit = (name, text, item) => {
|
||||
// orderId.value = item.orderId;
|
||||
// field.value = name;
|
||||
// content.value = text;
|
||||
// showEdit.value = true;
|
||||
// };
|
||||
|
||||
const onEditContent = (name, text, item) => {
|
||||
orderId.value = item.orderId;
|
||||
field.value = name;
|
||||
markdown.value = text;
|
||||
showMarkdown.value = true;
|
||||
};
|
||||
|
||||
// const openDelivery = (row?: Order) => {
|
||||
// current.value = row ?? null;
|
||||
// deliveryEdit.value = true;
|
||||
// };
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: Order) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
|
||||
/* 支付宝统一收单交易查询 */
|
||||
// const onAlipayQuery = (orderNo) => {
|
||||
// alipayQuery(orderNo).then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
// };
|
||||
|
||||
/* 删除单个 */
|
||||
// const remove = (row: Order) => {
|
||||
// const hide = message.loading('请求中..', 0);
|
||||
// removeOrder(row.orderId)
|
||||
// .then((msg) => {
|
||||
// hide();
|
||||
// message.success(msg);
|
||||
// reload();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// hide();
|
||||
// message.error(e.message);
|
||||
// });
|
||||
// };
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchOrder(selection.value.map((d) => d.orderId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Order) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openInfo(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopOrderIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.comments {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
376
src/views/baocan/plan/components/order-info.vue
Normal file
376
src/views/baocan/plan/components/order-info.vue
Normal file
@@ -0,0 +1,376 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="`80%`"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑订单' : '订单详情'"
|
||||
:body-style="{ paddingBottom: '8px', background: '#f3f3f3' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
:footer="null"
|
||||
@ok="save"
|
||||
>
|
||||
<!-- <a-card class="order-card" :bordered="false">-->
|
||||
<!-- <a-steps-->
|
||||
<!-- :current="active"-->
|
||||
<!-- direction="horizontal"-->
|
||||
<!-- :responsive="styleResponsive"-->
|
||||
<!-- >-->
|
||||
<!-- <template v-for="(item, index) in steps" :key="index">-->
|
||||
<!-- <a-step-->
|
||||
<!-- :title="item.title"-->
|
||||
<!-- :description="timeAgo(item.description)"-->
|
||||
<!-- />-->
|
||||
<!-- </template>-->
|
||||
<!-- </a-steps>-->
|
||||
<!-- </a-card>-->
|
||||
<a-card title="订单详情" class="order-card">
|
||||
<!-- <a-space>-->
|
||||
<!-- <a-button>发货</a-button>-->
|
||||
<!-- <a-button>商家备注</a-button>-->
|
||||
<!-- <a-button>打印小票</a-button>-->
|
||||
<!-- </a-space>-->
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单号" name="orderId">
|
||||
<span>{{ data.orderId }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="实付款金额" name="payPrice">
|
||||
<span class="ele-text-warning"
|
||||
>¥{{ formatNumber(data.payPrice) }}</span
|
||||
>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单状态" name="orderStatus">
|
||||
<a-tag>{{ data.payStatus === 20 ? '已下单' : '' }}</a-tag>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家信息" name="deliveryType">
|
||||
<router-link :to="'/system/user/details?id=' + data.userId">
|
||||
<span class="ele-text-primary">{{ data.nickname }}</span>
|
||||
</router-link>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="预定日期" name="deliveryTime">
|
||||
{{ toDateString(data.deliveryTime, 'yyyy-MM-dd') }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="下单时间" name="createTime">
|
||||
{{ data.createTime }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="交易流水号" name="orderNo">
|
||||
{{ data.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="买家留言" name="buyerRemark">
|
||||
<span>{{ data.buyerRemark }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive
|
||||
? { xl: 8, lg: 12, md: 12, sm: 24, xs: 24 }
|
||||
: { span: 8 }
|
||||
"
|
||||
>
|
||||
<a-form-item label="订单备注" name="comments">
|
||||
<span>{{ data.comments }}</span>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
<a-card title="菜品信息" class="order-card">
|
||||
<a-spin :spinning="loading">
|
||||
<a-table
|
||||
:data-source="orderGoodsList"
|
||||
:columns="columns"
|
||||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goodsName'">
|
||||
<div class="goods-info">
|
||||
<a-image
|
||||
v-if="record.imageUrl"
|
||||
:src="record.imageUrl"
|
||||
:preview="false"
|
||||
:width="50"
|
||||
/>
|
||||
<div class="info">
|
||||
<div>{{ record.goodsName }}</div>
|
||||
<div class="ele-text-placeholder">{{ record.comments }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { assignObject, toDateString } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { formatNumber } from 'ele-admin-pro/es';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Order } from '@/api/order/model';
|
||||
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { OrderGoods } from '@/api/order/goods/model';
|
||||
import { listOrderGoods } from '@/api/order/goods';
|
||||
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Order | null;
|
||||
}>();
|
||||
|
||||
export interface step {
|
||||
title?: String | undefined;
|
||||
subTitle?: String | undefined;
|
||||
description?: String | undefined;
|
||||
}
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const orderGoodsList = ref<OrderGoods[]>([]);
|
||||
|
||||
// 步骤条
|
||||
const steps = ref<step[]>([
|
||||
{
|
||||
title: '报餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '付款',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '发餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '取餐',
|
||||
description: undefined
|
||||
},
|
||||
{
|
||||
title: '完成',
|
||||
description: undefined
|
||||
}
|
||||
]);
|
||||
const active = ref(2);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 订单信息
|
||||
const order = reactive<Order>({
|
||||
orderId: undefined,
|
||||
orderNo: '',
|
||||
userId: undefined,
|
||||
orderSourceData: ''
|
||||
});
|
||||
|
||||
// 请求状态
|
||||
const loading = ref(true);
|
||||
|
||||
const { resetFields } = useForm(order);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: '菜品ID',
|
||||
// dataIndex: 'goodsId'
|
||||
// },
|
||||
{
|
||||
title: '菜品信息',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '菜品价格',
|
||||
dataIndex: 'goodsPrice',
|
||||
customRender: ({ text }) => '¥' + text
|
||||
},
|
||||
{
|
||||
title: '购买数量',
|
||||
dataIndex: 'totalNum',
|
||||
key: 'totalNum'
|
||||
}
|
||||
]);
|
||||
|
||||
/* 制作步骤条 */
|
||||
const loadSteps = (order) => {
|
||||
steps.value = [];
|
||||
steps.value.push({
|
||||
title: '下单'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '付款'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '发货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '收货'
|
||||
});
|
||||
steps.value.push({
|
||||
title: '完成'
|
||||
});
|
||||
|
||||
// 下单
|
||||
if (order.payStatus == 10) {
|
||||
active.value = 0;
|
||||
steps.value[0].description = order.createTime;
|
||||
}
|
||||
// 付款
|
||||
if (order.payStatus == 20) {
|
||||
active.value = 1;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
}
|
||||
// 发货
|
||||
if (order.payStatus == 20 && order.deliveryStatus == 20) {
|
||||
active.value = 2;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
}
|
||||
// 收货
|
||||
if (order.payStatus == 20 && order.receiptStatus == 20) {
|
||||
active.value = 3;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 完成
|
||||
if (order.payStatus == 20 && order.orderStatus == 30) {
|
||||
active.value = 4;
|
||||
steps.value[0].description = order.createTime;
|
||||
steps.value[1].description = order.payTime;
|
||||
steps.value[2].description = order.deliveryTime;
|
||||
steps.value[3].description = order.receiptTime;
|
||||
}
|
||||
// 已取消
|
||||
if (order.orderStatus == 20) {
|
||||
active.value = 4;
|
||||
}
|
||||
};
|
||||
|
||||
const getOrderGoods = () => {
|
||||
const orderId = props.data?.orderId;
|
||||
listOrderGoods({ orderId }).then((data) => {
|
||||
orderGoodsList.value = data;
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignObject(order, props.data);
|
||||
loadSteps(props.data);
|
||||
getOrderGoods();
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.order-card {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ant-form-item {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.goods-info {
|
||||
display: flex;
|
||||
.info {
|
||||
padding-left: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
342
src/views/baocan/plan/components/plan-edit.vue
Normal file
342
src/views/baocan/plan/components/plan-edit.vue
Normal file
@@ -0,0 +1,342 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
width="80%"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑菜品' : '发布菜品'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-space :size="16" style="margin-bottom: 30px">
|
||||
<a-space v-if="!isUpdate">
|
||||
<a-radio-group v-model:value="form.type">
|
||||
<a-radio-button value="single">发布一天</a-radio-button>
|
||||
<a-radio-button value="multiple" disabled="">发布多天</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-space>
|
||||
<a-space v-if="form.type === 'single'">
|
||||
<span class="ele-text-secondary">发布日期</span>
|
||||
<a-date-picker
|
||||
placeholder="发布日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.dayTime"
|
||||
/>
|
||||
</a-space>
|
||||
<a-space v-if="form.type === 'multiple'" :size="16">
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="ele-fluid"
|
||||
/>
|
||||
<a-radio-group v-model:value="form.isRepeat">
|
||||
<a-radio :value="1">多天菜品重复</a-radio>
|
||||
<a-radio :value="2">多天菜品不重复</a-radio>
|
||||
</a-radio-group>
|
||||
</a-space>
|
||||
<a-space>
|
||||
<span class="ele-text-secondary">使用往日菜单</span>
|
||||
<a-date-picker
|
||||
placeholder="选择往日菜单"
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model:value="form.oldTime"
|
||||
@change="selectOldTime"
|
||||
/>
|
||||
</a-space>
|
||||
</a-space>
|
||||
<!-- <a-divider style="margin: 12px 0 12px 0" />-->
|
||||
<!-- <div>{{ targetKeys1 }}</div>-->
|
||||
<!-- <div>{{ targetKeys2 }}</div>-->
|
||||
<!-- <div>{{ targetKeys3 }}</div>-->
|
||||
<!-- <div>{{ selectedGoodsIds }}</div>-->
|
||||
<div
|
||||
style="background-color: #f3f3f3; padding: 8px;">
|
||||
<a-form
|
||||
:label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
|
||||
>
|
||||
<a-row type="flex" :gutter="8" justify="space-around">
|
||||
<a-col :md="8" :sm="24" :xs="24">
|
||||
<a-card title="早餐" :bordered="false">
|
||||
<a-transfer
|
||||
v-model:target-keys="targetKeys1"
|
||||
v-model:selected-keys="selectedKeys1"
|
||||
:data-source="breakfast"
|
||||
:list-style="{
|
||||
width: '250px',
|
||||
height: '500px',
|
||||
}"
|
||||
:titles="['菜品', '已选']"
|
||||
:render="item => item.title"
|
||||
:disabled="disabled"
|
||||
@selectChange="onChange1"
|
||||
/>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col :md="8" :sm="24" :xs="24">
|
||||
<a-card title="午餐" :bordered="false">
|
||||
<a-transfer
|
||||
v-model:target-keys="targetKeys2"
|
||||
v-model:selected-keys="selectedKeys2"
|
||||
:data-source="lunch"
|
||||
:list-style="{
|
||||
width: '250px',
|
||||
height: '500px',
|
||||
}"
|
||||
:titles="['菜品', '已选']"
|
||||
:render="item => item.title"
|
||||
:disabled="disabled"
|
||||
@selectChange="onChange2"
|
||||
/>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col :md="8" :sm="24" :xs="24">
|
||||
<a-card title="晚餐" :bordered="false">
|
||||
<a-transfer
|
||||
v-model:target-keys="targetKeys3"
|
||||
v-model:selected-keys="selectedKeys3"
|
||||
:data-source="dinner"
|
||||
:list-style="{
|
||||
width: '250px',
|
||||
height: '500px',
|
||||
}"
|
||||
:titles="['菜品', '已选']"
|
||||
:render="item => item.title"
|
||||
:disabled="disabled"
|
||||
@selectChange="onChange3"
|
||||
/>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
|
||||
</a-spin>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch, computed} from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, toDateString } from "ele-admin-pro";
|
||||
import { addBCPlan, updateBCPlan, listBCPlan } from '@/api/apps/bc/plan';
|
||||
import type { Customer } from '@/api/oa/customer/model';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { pageGoods } from "@/api/goods";
|
||||
import { BCPlan } from "@/api/apps/bc/plan/model";
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Customer | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 当期时间
|
||||
const dayTime = toDateString(new Date());
|
||||
// 类型 single|multiple
|
||||
// const type = ref<string>('single');
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
// 穿梭框数据
|
||||
const breakfast = ref<any[]>();
|
||||
const targetKeys1 = ref<any[]>([]);
|
||||
const selectedKeys1 =ref<any[]>();
|
||||
const lunch = ref<any[]>();
|
||||
const targetKeys2 = ref<any[]>([]);
|
||||
const selectedKeys2 =ref<any[]>();
|
||||
const dinner = ref<any[]>();
|
||||
const targetKeys3 = ref<any[]>([]);
|
||||
const selectedKeys3 =ref<any[]>();
|
||||
const selectedGoodsIds = ref<any[]>([]);
|
||||
|
||||
// 合并选中的菜品
|
||||
const onChange1 = () => {
|
||||
selectedGoodsIds.value = [...targetKeys1.value,...targetKeys2.value,...targetKeys3.value]
|
||||
}
|
||||
const onChange2 = () => {
|
||||
selectedGoodsIds.value = [...targetKeys1.value,...targetKeys2.value,...targetKeys3.value]
|
||||
}
|
||||
const onChange3 = () => {
|
||||
selectedGoodsIds.value = [...targetKeys1.value,...targetKeys2.value,...targetKeys3.value]
|
||||
}
|
||||
|
||||
// 选择往日菜单
|
||||
const selectOldTime = (date) => {
|
||||
form.oldTime = date
|
||||
listBCPlan({oldTime: toDateString(form.oldTime, 'YYYY-MM-DD HH:mm:ss')}).then(data => {
|
||||
if(data[0]){
|
||||
selectedGoodsIds.value = JSON.parse(data[0].goodsIds);
|
||||
reload();
|
||||
message.success('加载成功');
|
||||
}else{
|
||||
message.info('当天没有发布数据')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<BCPlan>({
|
||||
type: 'single',
|
||||
bcPlanId: undefined,
|
||||
isRepeat: 1,
|
||||
period: '',
|
||||
dayTime: toDateString(new Date(),'YYYY-MM-DD'),
|
||||
oldTime: '',
|
||||
goodsIds: '',
|
||||
comments: '',
|
||||
status: 1
|
||||
});
|
||||
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref(<any>[]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
customerName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入订单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
customerCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入合法的IP地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
progress: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择跟进状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields, validate, validateInfos } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
// 去除空格
|
||||
// form.customerName = form.customerName?.replace(/\s*/g, '');
|
||||
// const data = {
|
||||
// ...form
|
||||
// };
|
||||
// 转字符串
|
||||
|
||||
form.userId = loginUser.value.userId;
|
||||
form.goodsIds = JSON.stringify(selectedGoodsIds.value)
|
||||
form.dayTime = toDateString(form.dayTime, 'YYYY-MM-DD HH:mm:ss');
|
||||
form.period = (targetKeys1.value.length > 0 ? '早餐 ' : '') + (targetKeys2.value.length > 0 ? '午餐 ' : '') + (targetKeys3.value.length > 0 ? '晚餐' : '');
|
||||
const saveOrUpdate = isUpdate.value ? updateBCPlan : addBCPlan;
|
||||
saveOrUpdate(form)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
loading.value = true;
|
||||
pageGoods({limit:100}).then(data => {
|
||||
targetKeys1.value = []
|
||||
targetKeys2.value = []
|
||||
targetKeys3.value = []
|
||||
breakfast.value = data?.list.filter(d => d.categoryId == 25).map(d => {
|
||||
// 处理编辑状态下是否选中
|
||||
if(selectedGoodsIds.value.indexOf(d.goodsId) > -1){
|
||||
targetKeys1.value.push(d.goodsId);
|
||||
}
|
||||
return {
|
||||
key: d.goodsId,
|
||||
title: d.goodsName
|
||||
}
|
||||
})
|
||||
lunch.value = data?.list.filter(d => d.categoryId == 26).map(d => {
|
||||
// 处理编辑状态下是否选中
|
||||
if(selectedGoodsIds.value.indexOf(d.goodsId) > -1){
|
||||
targetKeys2.value.push(d.goodsId);
|
||||
}
|
||||
return {
|
||||
key: d.goodsId,
|
||||
title: d.goodsName
|
||||
}
|
||||
})
|
||||
dinner.value = data?.list.filter(d => d.categoryId == 27).map(d => {
|
||||
// 处理编辑状态下是否选中
|
||||
if(selectedGoodsIds.value.indexOf(d.goodsId) > -1){
|
||||
targetKeys3.value.push(d.goodsId);
|
||||
}
|
||||
return {
|
||||
key: d.goodsId,
|
||||
title: d.goodsName
|
||||
}
|
||||
})
|
||||
loading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
reload();
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
selectedGoodsIds.value = JSON.parse(form.goodsIds);
|
||||
reload();
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
131
src/views/baocan/plan/components/search.vue
Normal file
131
src/views/baocan/plan/components/search.vue
Normal file
@@ -0,0 +1,131 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>发布菜品</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
@change="search"
|
||||
value-format="YYYY-MM-DD"
|
||||
class="ele-fluid"
|
||||
/>
|
||||
<a-select
|
||||
v-model:value="where.week"
|
||||
style="width: 120px"
|
||||
placeholder="请选择星期"
|
||||
allow-clear
|
||||
@change="handleTabs"
|
||||
>
|
||||
<a-select-option :value="1">星期一</a-select-option>
|
||||
<a-select-option :value="2">星期二</a-select-option>
|
||||
<a-select-option :value="3">星期三</a-select-option>
|
||||
<a-select-option :value="4">星期四</a-select-option>
|
||||
<a-select-option :value="5">星期五</a-select-option>
|
||||
<a-select-option :value="6">星期六</a-select-option>
|
||||
<a-select-option :value="0">星期日</a-select-option>
|
||||
</a-select>
|
||||
<!-- <a-radio-group v-model:value="where.week" @change="handleTabs">-->
|
||||
<!-- <a-radio-button :value="0">星期日</a-radio-button>-->
|
||||
<!-- <a-radio-button :value="1">星期一</a-radio-button>-->
|
||||
<!-- <a-radio-button :value="2">星期二</a-radio-button>-->
|
||||
<!-- <a-radio-button :value="3">星期三</a-radio-button>-->
|
||||
<!-- <a-radio-button :value="4">星期四</a-radio-button>-->
|
||||
<!-- <a-radio-button :value="5">星期五</a-radio-button>-->
|
||||
<!-- <a-radio-button :value="6">星期六</a-radio-button>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="where.keywords"
|
||||
@pressEnter="search"
|
||||
@search="search"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ref, watch } from 'vue';
|
||||
import { BCPlanParam } from '@/api/apps/bc/plan/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: BCPlanParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'advanced'): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<BCPlanParam>({
|
||||
keywords: undefined,
|
||||
userId: undefined,
|
||||
week: undefined,
|
||||
dayTime: undefined,
|
||||
createTimeStart: '',
|
||||
createTimeEnd: ''
|
||||
});
|
||||
// 下来选项
|
||||
const type = ref('keywords');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
const [d1, d2] = dateRange.value ?? [];
|
||||
if (type.value == 'keywords') {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
emit('search', {
|
||||
...where,
|
||||
createTimeStart: d1 ? d1 + ' 00:00:00' : '',
|
||||
createTimeEnd: d2 ? d2 + ' 23:59:59' : ''
|
||||
});
|
||||
};
|
||||
|
||||
// 发布菜品
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
const handleTabs = (index) => {
|
||||
where.week = index;
|
||||
search();
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
287
src/views/baocan/plan/index.vue
Normal file
287
src/views/baocan/plan/index.vue
Normal file
@@ -0,0 +1,287 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="bcPlanId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
:scroll="{ x: 1200 }"
|
||||
class="sys-org-table"
|
||||
:striped="true"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@advanced="openAdvanced"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'dayTime'">
|
||||
{{ toDateString(record.dayTime, 'YYYY-MM-dd') }}
|
||||
{{ getWeek(record.week) }}
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
{{ record.nickname }}
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ record.createTime }}
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button @click="openEdit(record)">详情</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 编辑弹窗 -->
|
||||
<PlanEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
<!-- 订单详情 -->
|
||||
<order-info v-model:visible="showInfo" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import PlanEdit from './components/plan-edit.vue';
|
||||
import OrderInfo from './components/order-info.vue';
|
||||
import { getWeek } from '@/utils/common';
|
||||
import {
|
||||
pageBCPlan,
|
||||
removeBCPlan,
|
||||
removeBatchBCPlan
|
||||
} from '@/api/apps/bc/plan';
|
||||
import { BCPlan, BCPlanParam } from '@/api/apps/bc/plan/model';
|
||||
|
||||
defineProps<{
|
||||
activeKey?: boolean;
|
||||
data?: any;
|
||||
}>();
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// key: 'index',
|
||||
// width: 48,
|
||||
// align: 'center',
|
||||
// fixed: 'left',
|
||||
// hideInSetting: true,
|
||||
// hideInTable: true,
|
||||
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
// },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '发布日期',
|
||||
dataIndex: 'dayTime',
|
||||
key: 'dayTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '发布类型',
|
||||
dataIndex: 'period',
|
||||
key: 'period',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '发布状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
align: 'center',
|
||||
customRender: ({ text }) => ['待发布', '已发布'][text]
|
||||
},
|
||||
{
|
||||
title: '发布人',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '发布时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<BCPlan[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<BCPlan | null>(null);
|
||||
// 是否显示资产详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示高级搜索
|
||||
const showAdvancedSearch = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
// 搜索条件
|
||||
if (filters.payMethod) {
|
||||
where.payMethod = filters.payMethod;
|
||||
}
|
||||
if (filters.deliveryType) {
|
||||
where.deliveryType = filters.deliveryType;
|
||||
}
|
||||
if (filters.payStatus) {
|
||||
where.payStatus = filters.payStatus;
|
||||
}
|
||||
if (filters.orderSource) {
|
||||
where.orderSource = filters.orderSource;
|
||||
}
|
||||
where.tenantId = localStorage.getItem('tenantId');
|
||||
where.payStatus = 20;
|
||||
return pageBCPlan({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: BCPlanParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: BCPlan) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: BCPlan) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
/* 打开高级搜索 */
|
||||
const openAdvanced = () => {
|
||||
showAdvancedSearch.value = !showAdvancedSearch.value;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: BCPlan) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBCPlan(row.bcPlanId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
console.log(selection.value);
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchBCPlan(selection.value.map((d) => d.bcPlanId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: BCPlan) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'BCPlanIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
p {
|
||||
line-height: 0.8;
|
||||
}
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.price-edit {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.comments {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
228
src/views/baocan/setting/index.vue
Normal file
228
src/views/baocan/setting/index.vue
Normal file
@@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card title="报餐设置" :bordered="false">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="
|
||||
styleResponsive ? { md: 3, sm: 5, xs: 24 } : { flex: '90px' }
|
||||
"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 9, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="报餐规则" name="type">
|
||||
<a-select
|
||||
v-model:value="form.type"
|
||||
style="width: 100%"
|
||||
placeholder="请选择报餐规则"
|
||||
:options="options"
|
||||
@change="handleKeyword"
|
||||
>
|
||||
<a-select-option :value="20"
|
||||
>仅可预定第二天及以后的菜品</a-select-option
|
||||
>
|
||||
<a-select-option :value="10"
|
||||
>可预定当天及以后的菜品</a-select-option
|
||||
>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="早餐就餐时间" name="breakfast">
|
||||
<a-space>
|
||||
<a-time-picker
|
||||
v-model:value="form.breakfastStartTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
<span>截止时间</span>
|
||||
<a-time-picker
|
||||
v-model:value="form.breakfastEndTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="中餐就餐时间" name="lunch">
|
||||
<a-space>
|
||||
<a-time-picker
|
||||
v-model:value="form.lunchStartTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
<span>截止时间</span>
|
||||
<a-time-picker v-model:value="form.lunchEndTime" format="HH:mm" />
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="晚餐就餐时间" name="dinner">
|
||||
<a-space>
|
||||
<a-time-picker
|
||||
v-model:value="form.dinnerStartTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
<span>截止时间</span>
|
||||
<a-time-picker
|
||||
v-model:value="form.dinnerEndTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="操作" name="logo">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="save">
|
||||
<span>保存</span>
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { addSetting, listSetting, updateSetting } from '@/api/system/setting';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
|
||||
// 保存字段信息(设定好key和描述,content里的字段是随意加的会自动转为json保存到数据库)
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
export interface BaoCan {
|
||||
settingId?: number;
|
||||
settingKey?: string;
|
||||
type?: number;
|
||||
breakfastStartTime?: any;
|
||||
breakfastEndTime?: any;
|
||||
breakfastEndMinute?: number;
|
||||
lunchStartTime?: any;
|
||||
lunchEndTime?: any;
|
||||
dinnerStartTime?: any;
|
||||
dinnerEndTime?: any;
|
||||
tenantId?: string | null;
|
||||
}
|
||||
const { form, assignFields } = useFormData<BaoCan>({
|
||||
type: 10,
|
||||
settingId: undefined,
|
||||
settingKey: 'BaoCan',
|
||||
breakfastStartTime: undefined,
|
||||
breakfastEndTime: undefined,
|
||||
breakfastEndMinute: 0,
|
||||
lunchStartTime: undefined,
|
||||
lunchEndTime: undefined,
|
||||
dinnerStartTime: undefined,
|
||||
dinnerEndTime: undefined
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
type: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择报餐类型',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const handleKeyword = (keyword) => {
|
||||
keyword.value = keyword;
|
||||
form.keyword = JSON.stringify(keyword);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
console.log(form);
|
||||
// form.breakfastEndMinute = ;
|
||||
// form.breakfastStartTime = toDateString(
|
||||
// form.breakfastStartTime,
|
||||
// 'HH:mm'
|
||||
// );
|
||||
// form.breakfastEndTime = toDateString(form.breakfastEndTime, 'HH:mm');
|
||||
// form.lunchStartTime = toDateString(form.lunchStartTime, 'HH:mm');
|
||||
// form.lunchEndTime = toDateString(form.lunchEndTime, 'HH:mm');
|
||||
// form.dinnerStartTime = toDateString(form.dinnerStartTime, 'HH:mm');
|
||||
// form.dinnerEndTime = toDateString(form.dinnerEndTime, 'HH:mm');
|
||||
const appForm = {
|
||||
...form,
|
||||
content: JSON.stringify(form)
|
||||
};
|
||||
console.log(appForm);
|
||||
return false;
|
||||
const saveOrUpdate = isUpdate.value ? updateSetting : addSetting;
|
||||
saveOrUpdate(appForm)
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
listSetting({ settingKey: 'BaoCan' }).then((res) => {
|
||||
if (res.length > 0) {
|
||||
const data = res[0];
|
||||
form.settingId = data.settingId;
|
||||
isUpdate.value = true;
|
||||
if (data.content) {
|
||||
// 时间转换
|
||||
const jsonData = JSON.parse(data.content);
|
||||
// // assignFields(jsonData);
|
||||
// console.log(jsonData);
|
||||
// console.log(jsonData.breakfastStartTime);
|
||||
form.breakfastStartTime = toDateString(
|
||||
jsonData.breakfastEndTime,
|
||||
"yyyy-MM-dd'T'HH:mm:ssZ"
|
||||
);
|
||||
var s = toDateString(jsonData.breakfastStartTime, 'HH:mm');
|
||||
console.log(s);
|
||||
const breakfastStartTime = toDateString(
|
||||
jsonData.breakfastStartTime,
|
||||
'HH:mm'
|
||||
);
|
||||
form.breakfastStartTime = dayjs(breakfastStartTime, 'HH:mm');
|
||||
const breakfastEndTime = toDateString(
|
||||
jsonData.breakfastEndTime,
|
||||
'HH:mm'
|
||||
);
|
||||
form.breakfastEndTime = dayjs(breakfastEndTime, 'HH:mm');
|
||||
const lunchStartTime = toDateString(jsonData.lunchStartTime, 'HH:mm');
|
||||
form.lunchStartTime = dayjs(lunchStartTime, 'HH:mm');
|
||||
const lunchEndTime = toDateString(jsonData.lunchEndTime, 'HH:mm');
|
||||
form.lunchEndTime = dayjs(lunchEndTime, 'HH:mm');
|
||||
const dinnerStartTime = toDateString(
|
||||
jsonData.dinnerStartTime,
|
||||
'HH:mm'
|
||||
);
|
||||
form.dinnerStartTime = dayjs(dinnerStartTime, 'HH:mm');
|
||||
const dinnerEndTime = toDateString(jsonData.dinnerEndTime, 'HH:mm');
|
||||
form.dinnerEndTime = dayjs(dinnerEndTime, 'HH:mm');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
189
src/views/baocan/setting/index2.vue
Normal file
189
src/views/baocan/setting/index2.vue
Normal file
@@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card title="报餐设置" :bordered="false">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="
|
||||
styleResponsive ? { md: 3, sm: 5, xs: 24 } : { flex: '90px' }
|
||||
"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 9, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="报餐规则" name="type">
|
||||
<a-select
|
||||
v-model:value="form.type"
|
||||
style="width: 100%"
|
||||
placeholder="请选择报餐规则"
|
||||
:options="options"
|
||||
@change="handleKeyword"
|
||||
>
|
||||
<a-select-option :value="20"
|
||||
>仅可预定第二天及以后的菜品</a-select-option
|
||||
>
|
||||
<a-select-option :value="10"
|
||||
>可预定当天及以后的菜品</a-select-option
|
||||
>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="早餐就餐时间" name="breakfast">
|
||||
<a-space>
|
||||
<a-time-picker
|
||||
v-model:value="form.breakfastStartTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
<span>截止时间</span>
|
||||
<a-time-picker
|
||||
v-model:value="form.breakfastEndTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="中餐就餐时间" name="lunch">
|
||||
<a-space>
|
||||
<a-time-picker
|
||||
v-model:value="form.lunchStartTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
<span>截止时间</span>
|
||||
<a-time-picker v-model:value="form.lunchEndTime" format="HH:mm" />
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="晚餐就餐时间" name="dinner">
|
||||
<a-space>
|
||||
<a-time-picker
|
||||
v-model:value="form.dinnerStartTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
<span>截止时间</span>
|
||||
<a-time-picker
|
||||
v-model:value="form.dinnerEndTime"
|
||||
format="HH:mm"
|
||||
/>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="操作" name="logo">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="save">
|
||||
<span>保存</span>
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { addSetting, listSetting, updateSetting } from '@/api/system/setting';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
|
||||
// 保存字段信息(设定好key和描述,content里的字段是随意加的会自动转为json保存到数据库)
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
export interface BaoCan {
|
||||
settingId?: number;
|
||||
settingKey?: string;
|
||||
type?: number;
|
||||
breakfastStartTime?: any;
|
||||
breakfastEndTime?: any;
|
||||
lunchStartTime?: any;
|
||||
lunchEndTime?: any;
|
||||
dinnerStartTime?: any;
|
||||
dinnerEndTime?: any;
|
||||
tenantId?: string | null;
|
||||
}
|
||||
const { form, assignFields } = useFormData<BaoCan>({
|
||||
type: 10,
|
||||
settingId: undefined,
|
||||
settingKey: 'BaoCan',
|
||||
breakfastStartTime: dayjs('2015/01/01', ),
|
||||
breakfastEndTime: '',
|
||||
lunchStartTime: '',
|
||||
lunchEndTime: '',
|
||||
dinnerStartTime: '',
|
||||
dinnerEndTime: ''
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
type: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择报餐类型',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const handleKeyword = (keyword) => {
|
||||
keyword.value = keyword;
|
||||
form.keyword = JSON.stringify(keyword);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const appForm = {
|
||||
...form,
|
||||
content: JSON.stringify(form)
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateSetting : addSetting;
|
||||
saveOrUpdate(appForm)
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
listSetting({ settingKey: 'BaoCan' }).then((res) => {
|
||||
console.log(res);
|
||||
if (res.length > 0) {
|
||||
const data = res[0];
|
||||
if (data.content) {
|
||||
const jsonData = JSON.parse(data.content);
|
||||
assignFields(jsonData);
|
||||
form.settingId = data.settingId;
|
||||
// form.breakfastStartTime = toDateString(
|
||||
// form.breakfastStartTime,
|
||||
// 'YYYY-MM-DD HH:mm'
|
||||
// );
|
||||
form.breakfastEndTime = dayjs('07:00', 'HH:mm');
|
||||
console.log(form);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
173
src/views/baocan/temporary/components/edit.vue
Normal file
173
src/views/baocan/temporary/components/edit.vue
Normal file
@@ -0,0 +1,173 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="750"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:maxable="maxAble"
|
||||
:title="isUpdate ? '编辑临时报餐人员' : '添加临时报餐人员'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="false"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
>
|
||||
<a-form-item label="姓名" name="userId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入姓名ID"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.userId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="代报餐人员姓名ID" name="parentId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入代报餐人员姓名ID"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.parentId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="99999"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号(数字越小越靠前)"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BCAgent } from '@/api/apps/bc/agent/model';
|
||||
import { addBCTemporary, updateBCTemporary } from '@/api/apps/bc/temporary';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxAble = ref(true);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BCAgent | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<BCAgent>({
|
||||
userId: undefined,
|
||||
parentId: undefined,
|
||||
sortNumber: 100
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入姓名ID',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
parentId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请输入代报餐人员姓名ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const merchantForm = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateBCTemporary
|
||||
: addBCTemporary;
|
||||
saveOrUpdate(merchantForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
resetFields();
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.flex-sb {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
</style>
|
||||
59
src/views/baocan/temporary/components/search.vue
Normal file
59
src/views/baocan/temporary/components/search.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<!-- <a-button type="primary" class="ele-btn-icon" @click="pass">-->
|
||||
<!-- <span>通过</span>-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button type="primary" class="ele-btn-icon" @click="reject">-->
|
||||
<!-- <span>拒绝</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'pass'): void;
|
||||
(e: 'reject'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 审核通过
|
||||
const pass = () => {
|
||||
emit('pass');
|
||||
};
|
||||
|
||||
// 拒绝
|
||||
const reject = () => {
|
||||
emit('reject');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
285
src/views/baocan/temporary/index.vue
Normal file
285
src/views/baocan/temporary/index.vue
Normal file
@@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<a-page-header :ghost="false" title="临时报餐">
|
||||
<div class="ele-text-secondary">
|
||||
临时报餐模块,可以给超过报餐时间临时报餐。
|
||||
</div>
|
||||
</a-page-header>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="temporaryId"
|
||||
:columns="columns"
|
||||
:height="tableHeight"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 800 }"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
:selection="selection"
|
||||
@pass="onPass"
|
||||
@reject="onReject"
|
||||
@remove="removeBatch"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'user'">
|
||||
<User v-if="record.user" :record="record.user" />
|
||||
</template>
|
||||
<template v-if="column.key === 'parentUser'">
|
||||
<User v-if="record.parentUser" :record="record.parentUser" />
|
||||
</template>
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<a-tag v-if="record.applyStatus === 1" color="green">
|
||||
审核通过
|
||||
</a-tag>
|
||||
<a-tag
|
||||
v-if="record.applyStatus === 0"
|
||||
color="error"
|
||||
@click="onPass(record)"
|
||||
>待审核</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 1" color="green">已报餐</a-tag>
|
||||
<a-tag
|
||||
v-if="record.status === 0"
|
||||
color="error"
|
||||
@click="onPass(record)"
|
||||
>未报餐</a-tag
|
||||
>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<a-tooltip :title="record.comments" placement="topLeft">
|
||||
{{ record.comments }}
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-tooltip :title="`${toDateString(record.createTime)}`">
|
||||
<div>{{ timeAgo(record.createTime) }}</div>
|
||||
<div>{{ timeAgo(record.expirationTime) }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="onPass(record)">通过</a>
|
||||
<a-divider type="vertical" />
|
||||
<a class="ele-text-danger" @click="onReject(record)">拒绝</a>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<edit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { timeAgo } from 'ele-admin-pro';
|
||||
import { createVNode, computed, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import Search from './components/search.vue';
|
||||
import Edit from './components/edit.vue';
|
||||
import {
|
||||
pageBCTemporary,
|
||||
removeBCTemporary,
|
||||
removeBatchBCTemporary,
|
||||
updateBCTemporary
|
||||
} from '@/api/apps/bc/temporary';
|
||||
import type {
|
||||
BCTemporary,
|
||||
BCTemporaryParam
|
||||
} from '@/api/apps/bc/temporary/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'nickname',
|
||||
key: 'nickname',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '申报理由',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '申请时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '审核状态',
|
||||
key: 'applyStatus',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '报餐状态',
|
||||
key: 'status',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<BCTemporary[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<BCTemporary | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.brand = filters.brand;
|
||||
}
|
||||
return pageBCTemporary({ ...where, ...orders, page, limit });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: BCTemporaryParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
// 搜索是否展开
|
||||
const searchExpand = ref(false);
|
||||
|
||||
// 表格固定高度
|
||||
const fixedHeight = ref(false);
|
||||
|
||||
// 表格高度
|
||||
const tableHeight = computed(() => {
|
||||
return fixedHeight.value
|
||||
? searchExpand.value
|
||||
? 'calc(100vh - 618px)'
|
||||
: 'calc(100vh - 562px)'
|
||||
: void 0;
|
||||
});
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: BCTemporary) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: BCTemporary) => {
|
||||
console.log(row);
|
||||
removeBCTemporary(row.temporaryId)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onPass = (item) => {
|
||||
updateBCTemporary({
|
||||
temporaryId: item.temporaryId,
|
||||
applyStatus: 1
|
||||
}).then(() => {
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
const onReject = (item) => {
|
||||
updateBCTemporary({
|
||||
temporaryId: item.temporaryId,
|
||||
applyStatus: 0
|
||||
}).then(() => {
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchBCTemporary(selection.value.map((d) => d.temporaryId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'BCTemporaryIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 文字超出隐藏(两行)
|
||||
// 需要设置文字容器的宽度
|
||||
.twoline-hide {
|
||||
width: 320px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
72
src/views/baocan/workplace/components/hot-search.vue
Normal file
72
src/views/baocan/workplace/components/hot-search.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<a-card :bordered="false" title="热门搜索">
|
||||
<v-chart
|
||||
ref="hotSearchChartRef"
|
||||
:option="hotSearchChartOption"
|
||||
style="height: 330px"
|
||||
/>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { use } from 'echarts/core';
|
||||
import type { EChartsCoreOption } from 'echarts/core';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { LineChart, BarChart } from 'echarts/charts';
|
||||
import { GridComponent, TooltipComponent } from 'echarts/components';
|
||||
import VChart from 'vue-echarts';
|
||||
import 'echarts-wordcloud';
|
||||
import { wordCloudColor } from 'ele-admin-pro/es';
|
||||
import { getWordCloudList } from '@/api/dashboard/analysis';
|
||||
import useEcharts from '@/utils/use-echarts';
|
||||
|
||||
use([CanvasRenderer, LineChart, BarChart, GridComponent, TooltipComponent]);
|
||||
|
||||
//
|
||||
const hotSearchChartRef = ref<InstanceType<typeof VChart> | null>(null);
|
||||
|
||||
useEcharts([hotSearchChartRef]);
|
||||
|
||||
// 词云图表配置
|
||||
const hotSearchChartOption: EChartsCoreOption = reactive({});
|
||||
|
||||
/* 获取词云数据 */
|
||||
const getWordCloudData = () => {
|
||||
getWordCloudList()
|
||||
.then((data) => {
|
||||
Object.assign(hotSearchChartOption, {
|
||||
tooltip: {
|
||||
show: true,
|
||||
confine: true,
|
||||
borderWidth: 1
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'wordCloud',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
sizeRange: [12, 24],
|
||||
gridSize: 6,
|
||||
textStyle: {
|
||||
color: wordCloudColor
|
||||
},
|
||||
emphasis: {
|
||||
textStyle: {
|
||||
shadowBlur: 8,
|
||||
shadowColor: 'rgba(0, 0, 0, .15)'
|
||||
}
|
||||
},
|
||||
data: data
|
||||
}
|
||||
]
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
getWordCloudData();
|
||||
</script>
|
||||
248
src/views/baocan/workplace/components/sale-card.vue
Normal file
248
src/views/baocan/workplace/components/sale-card.vue
Normal file
@@ -0,0 +1,248 @@
|
||||
<template>
|
||||
<a-card :bordered="false" :body-style="{ padding: 0 }">
|
||||
<a-tabs
|
||||
size="large"
|
||||
v-model:activeKey="saleSearch.type"
|
||||
class="monitor-card-tabs"
|
||||
@change="onSaleTypeChange"
|
||||
>
|
||||
<a-tab-pane tab="销售额" key="saleroom" />
|
||||
<a-tab-pane tab="访问量" key="visits" />
|
||||
<template #rightExtra>
|
||||
<a-space
|
||||
size="middle"
|
||||
:class="[
|
||||
'analysis-tabs-extra',
|
||||
{ 'hidden-lg-and-down': styleResponsive }
|
||||
]"
|
||||
>
|
||||
<a-radio-group v-model:value="saleSearch.dateType">
|
||||
<a-radio-button value="1">今天</a-radio-button>
|
||||
<a-radio-button value="2">本周</a-radio-button>
|
||||
<a-radio-button value="3">本月</a-radio-button>
|
||||
<a-radio-button value="4">本年</a-radio-button>
|
||||
</a-radio-group>
|
||||
<div style="width: 300px">
|
||||
<a-range-picker
|
||||
value-format="YYYY-MM-DD"
|
||||
v-model:value="saleSearch.datetime"
|
||||
/>
|
||||
</div>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-tabs>
|
||||
<div style="padding-bottom: 10px">
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive ? { lg: 17, md: 15, sm: 24, xs: 24 } : { span: 17 }
|
||||
"
|
||||
>
|
||||
<div v-if="saleSearch.type === 'saleroom'" class="demo-monitor-title">
|
||||
销售量趋势
|
||||
</div>
|
||||
<div v-else class="demo-monitor-title">访问量趋势</div>
|
||||
<v-chart
|
||||
ref="saleChartRef"
|
||||
:option="saleChartOption"
|
||||
style="height: 320px"
|
||||
/>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive ? { lg: 7, md: 9, sm: 24, xs: 24 } : { span: 7 }
|
||||
"
|
||||
>
|
||||
<div v-if="saleSearch.type === 'saleroom'">
|
||||
<div class="demo-monitor-title">门店销售额排名</div>
|
||||
<div
|
||||
v-for="(item, index) in saleroomRankData"
|
||||
:key="index"
|
||||
class="demo-monitor-rank-item ele-cell"
|
||||
>
|
||||
<ele-tag
|
||||
shape="circle"
|
||||
:color="index < 3 ? '#314659' : ''"
|
||||
style="border: none"
|
||||
>
|
||||
{{ index + 1 }}
|
||||
</ele-tag>
|
||||
<div class="ele-cell-content ele-elip">{{ item.name }}</div>
|
||||
<div class="ele-text-secondary">{{ item.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="demo-monitor-title">门店访问量排名</div>
|
||||
<div
|
||||
v-for="(item, index) in visitsRankData"
|
||||
:key="index"
|
||||
class="demo-monitor-rank-item ele-cell"
|
||||
>
|
||||
<ele-tag
|
||||
shape="circle"
|
||||
:color="index < 3 ? '#314659' : ''"
|
||||
style="border: none"
|
||||
>
|
||||
{{ index + 1 }}
|
||||
</ele-tag>
|
||||
<div class="ele-cell-content ele-elip">{{ item.name }}</div>
|
||||
<div class="ele-text-secondary">{{ item.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { use } from 'echarts/core';
|
||||
import type { EChartsCoreOption } from 'echarts/core';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { BarChart } from 'echarts/charts';
|
||||
import { GridComponent, TooltipComponent } from 'echarts/components';
|
||||
import VChart from 'vue-echarts';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { getSaleroomList } from '@/api/dashboard/analysis';
|
||||
import type { SaleroomData } from '@/api/dashboard/analysis/model';
|
||||
import useEcharts from '@/utils/use-echarts';
|
||||
|
||||
use([CanvasRenderer, BarChart, GridComponent, TooltipComponent]);
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
//
|
||||
const saleChartRef = ref<InstanceType<typeof VChart> | null>(null);
|
||||
|
||||
useEcharts([saleChartRef]);
|
||||
|
||||
// 销售额柱状图配置
|
||||
const saleChartOption: EChartsCoreOption = reactive({});
|
||||
|
||||
// 门店销售排名数据
|
||||
const saleroomRankData = ref([
|
||||
{ name: '工专路 1 号店', value: '323,234' },
|
||||
{ name: '工专路 2 号店', value: '323,234' },
|
||||
{ name: '工专路 3 号店', value: '323,234' },
|
||||
{ name: '工专路 4 号店', value: '323,234' },
|
||||
{ name: '工专路 5 号店', value: '323,234' },
|
||||
{ name: '工专路 6 号店', value: '323,234' },
|
||||
{ name: '工专路 7 号店', value: '323,234' }
|
||||
]);
|
||||
|
||||
// 门店访问排名数据
|
||||
const visitsRankData = ref([
|
||||
{ name: '工专路 1 号店', value: '323,234' },
|
||||
{ name: '工专路 2 号店', value: '323,234' },
|
||||
{ name: '工专路 3 号店', value: '323,234' },
|
||||
{ name: '工专路 4 号店', value: '323,234' },
|
||||
{ name: '工专路 5 号店', value: '323,234' },
|
||||
{ name: '工专路 6 号店', value: '323,234' },
|
||||
{ name: '工专路 7 号店', value: '323,234' }
|
||||
]);
|
||||
|
||||
// 销售量趋势数据
|
||||
const saleroomData1 = ref<SaleroomData[]>([]);
|
||||
|
||||
// 访问量趋势数据
|
||||
const saleroomData2 = ref<SaleroomData[]>([]);
|
||||
|
||||
interface SaleSearchType {
|
||||
type: string;
|
||||
dateType: string;
|
||||
datetime: [string, string];
|
||||
}
|
||||
|
||||
// 销售量搜索参数
|
||||
const saleSearch = reactive<SaleSearchType>({
|
||||
type: 'saleroom',
|
||||
dateType: '1',
|
||||
datetime: ['2022-01-08', '2022-02-12']
|
||||
});
|
||||
|
||||
/* 获取销售量数据 */
|
||||
const getSaleroomData = () => {
|
||||
getSaleroomList()
|
||||
.then((data) => {
|
||||
saleroomData1.value = data.list1;
|
||||
saleroomData2.value = data.list2;
|
||||
onSaleTypeChange();
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 销售量tab选择改变事件 */
|
||||
const onSaleTypeChange = () => {
|
||||
if (saleSearch.type === 'saleroom') {
|
||||
Object.assign(saleChartOption, {
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
data: saleroomData1.value.map((d) => d.month)
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: saleroomData1.value.map((d) => d.value)
|
||||
}
|
||||
]
|
||||
});
|
||||
} else {
|
||||
Object.assign(saleChartOption, {
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
data: saleroomData2.value.map((d) => d.month)
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: saleroomData2.value.map((d) => d.value)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
getSaleroomData();
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.monitor-card-tabs :deep(.ant-tabs-nav) {
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.demo-monitor-title {
|
||||
padding: 6px 20px;
|
||||
}
|
||||
|
||||
.demo-monitor-rank-item {
|
||||
padding: 0 20px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
</style>
|
||||
246
src/views/baocan/workplace/components/statistics-card.vue
Normal file
246
src/views/baocan/workplace/components/statistics-card.vue
Normal file
@@ -0,0 +1,246 @@
|
||||
<!-- 统计卡片 -->
|
||||
<template>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { lg: 8, md: 12, sm: 24, xs: 24 } : { span: 6 }"
|
||||
>
|
||||
<a-card class="analysis-chart-card" :bordered="false">
|
||||
<div class="ele-text-secondary ele-cell">
|
||||
<div class="ele-cell-content">总销售额</div>
|
||||
<a-tooltip title="指标说明">
|
||||
<question-circle-outlined />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<h1 class="analysis-chart-card-num">¥ 126,560</h1>
|
||||
<div class="analysis-chart-card-content" style="padding-top: 16px">
|
||||
<a-space size="middle">
|
||||
<span class="analysis-trend-text">
|
||||
周同比12% <caret-up-outlined class="ele-text-danger" />
|
||||
</span>
|
||||
<span class="analysis-trend-text">
|
||||
日同比11% <caret-down-outlined class="ele-text-success" />
|
||||
</span>
|
||||
</a-space>
|
||||
</div>
|
||||
<a-divider />
|
||||
<div>日销售额 ¥12,423</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { lg: 8, md: 12, sm: 24, xs: 24 } : { span: 6 }"
|
||||
>
|
||||
<a-card class="analysis-chart-card" :bordered="false">
|
||||
<div class="ele-text-secondary ele-cell">
|
||||
<div class="ele-cell-content">访问量</div>
|
||||
<ele-tag color="red">日</ele-tag>
|
||||
</div>
|
||||
<h1 class="analysis-chart-card-num">8,846</h1>
|
||||
<v-chart
|
||||
ref="visitChartRef"
|
||||
:option="visitChartOption"
|
||||
style="height: 40px"
|
||||
/>
|
||||
<a-divider />
|
||||
<div>日访问量 1,234</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { lg: 8, md: 12, sm: 24, xs: 24 } : { span: 6 }"
|
||||
>
|
||||
<a-card class="analysis-chart-card" :bordered="false">
|
||||
<div class="ele-text-secondary ele-cell">
|
||||
<div class="ele-cell-content">支付笔数</div>
|
||||
<ele-tag color="blue">月</ele-tag>
|
||||
</div>
|
||||
<h1 class="analysis-chart-card-num">6,560</h1>
|
||||
<v-chart
|
||||
ref="payNumChartRef"
|
||||
:option="payNumChartOption"
|
||||
style="height: 40px"
|
||||
/>
|
||||
<a-divider />
|
||||
<div>转化率 60%</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<!-- <a-col-->
|
||||
<!-- v-bind="styleResponsive ? { lg: 6, md: 12, sm: 24, xs: 24 } : { span: 6 }"-->
|
||||
<!-- >-->
|
||||
<!-- <a-card class="analysis-chart-card" :bordered="false">-->
|
||||
<!-- <div class="ele-text-secondary ele-cell">-->
|
||||
<!-- <div class="ele-cell-content">活动运营效果</div>-->
|
||||
<!-- <ele-tag color="green">周</ele-tag>-->
|
||||
<!-- </div>-->
|
||||
<!-- <h1 class="analysis-chart-card-num">78%</h1>-->
|
||||
<!-- <div class="analysis-chart-card-content" style="padding-top: 16px">-->
|
||||
<!-- <a-progress-->
|
||||
<!-- :percent="78"-->
|
||||
<!-- :show-info="false"-->
|
||||
<!-- stroke-color="#13c2c2"-->
|
||||
<!-- status="active"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
<!-- <a-divider />-->
|
||||
<!-- <a-space size="middle">-->
|
||||
<!-- <span class="analysis-trend-text">-->
|
||||
<!-- 周同比12% <caret-up-outlined class="ele-text-danger" />-->
|
||||
<!-- </span>-->
|
||||
<!-- <span class="analysis-trend-text">-->
|
||||
<!-- 日同比11% <caret-down-outlined class="ele-text-success" />-->
|
||||
<!-- </span>-->
|
||||
<!-- </a-space>-->
|
||||
<!-- </a-card>-->
|
||||
<!-- </a-col>-->
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import {
|
||||
QuestionCircleOutlined,
|
||||
CaretUpOutlined,
|
||||
CaretDownOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import { use } from 'echarts/core';
|
||||
import type { EChartsCoreOption } from 'echarts/core';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { LineChart, BarChart } from 'echarts/charts';
|
||||
import { GridComponent, TooltipComponent } from 'echarts/components';
|
||||
import VChart from 'vue-echarts';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { getPayNumList } from '@/api/dashboard/analysis';
|
||||
import useEcharts from '@/utils/use-echarts';
|
||||
|
||||
use([CanvasRenderer, LineChart, BarChart, GridComponent, TooltipComponent]);
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
//
|
||||
const visitChartRef = ref<InstanceType<typeof VChart> | null>(null);
|
||||
const payNumChartRef = ref<InstanceType<typeof VChart> | null>(null);
|
||||
|
||||
useEcharts([visitChartRef, payNumChartRef]);
|
||||
|
||||
// 访问量折线图配置
|
||||
const visitChartOption: EChartsCoreOption = reactive({});
|
||||
|
||||
// 支付笔数柱状图配置
|
||||
const payNumChartOption: EChartsCoreOption = reactive({});
|
||||
|
||||
/* 获取支付笔数数据 */
|
||||
const getPayNumData = () => {
|
||||
getPayNumList()
|
||||
.then((data) => {
|
||||
Object.assign(visitChartOption, {
|
||||
color: '#975fe5',
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter:
|
||||
'<i class="ele-chart-dot" style="background: #975fe5;"></i>{b0}: {c0}'
|
||||
},
|
||||
grid: {
|
||||
top: 10,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
show: false,
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: data.map((d) => d.date)
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
show: false,
|
||||
type: 'value',
|
||||
splitLine: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
areaStyle: {
|
||||
opacity: 0.5
|
||||
},
|
||||
data: data.map((d) => d.value)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Object.assign(payNumChartOption, {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter:
|
||||
'<i class="ele-chart-dot" style="background: #5b8ff9;"></i>{b0}: {c0}'
|
||||
},
|
||||
grid: {
|
||||
top: 10,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
show: false,
|
||||
type: 'category',
|
||||
data: data.map((d) => d.date)
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
show: false,
|
||||
type: 'value',
|
||||
splitLine: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: data.map((d) => d.value)
|
||||
}
|
||||
]
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
getPayNumData();
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.analysis-chart-card {
|
||||
:deep(.ant-card-body) {
|
||||
padding: 16px 22px 12px 22px;
|
||||
}
|
||||
|
||||
:deep(.ant-divider) {
|
||||
margin: 12px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.analysis-chart-card-num {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.analysis-chart-card-content {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.analysis-trend-text {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
101
src/views/baocan/workplace/components/visit-hour.vue
Normal file
101
src/views/baocan/workplace/components/visit-hour.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<a-card
|
||||
:bordered="false"
|
||||
title="最近1小时访问情况"
|
||||
:body-style="{ padding: '16px 6px 0 0' }"
|
||||
>
|
||||
<v-chart
|
||||
ref="visitHourChartRef"
|
||||
:option="visitHourChartOption"
|
||||
style="height: 362px"
|
||||
/>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { use } from 'echarts/core';
|
||||
import type { EChartsCoreOption } from 'echarts/core';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { LineChart } from 'echarts/charts';
|
||||
import {
|
||||
GridComponent,
|
||||
TooltipComponent,
|
||||
LegendComponent
|
||||
} from 'echarts/components';
|
||||
import VChart from 'vue-echarts';
|
||||
import { getVisitHourList } from '@/api/dashboard/analysis';
|
||||
import useEcharts from '@/utils/use-echarts';
|
||||
|
||||
use([
|
||||
CanvasRenderer,
|
||||
LineChart,
|
||||
GridComponent,
|
||||
TooltipComponent,
|
||||
LegendComponent
|
||||
]);
|
||||
|
||||
//
|
||||
const visitHourChartRef = ref<InstanceType<typeof VChart> | null>(null);
|
||||
|
||||
useEcharts([visitHourChartRef]);
|
||||
|
||||
// 最近 1 小时访问情况折线图配置
|
||||
const visitHourChartOption: EChartsCoreOption = reactive({});
|
||||
|
||||
/* 获取最近 1 小时访问情况数据 */
|
||||
const getVisitHourData = () => {
|
||||
getVisitHourList()
|
||||
.then((data) => {
|
||||
Object.assign(visitHourChartOption, {
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ['浏览量', '访问量'],
|
||||
right: 20
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: data.map((d) => d.time)
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '浏览量',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
areaStyle: {
|
||||
opacity: 0.5
|
||||
},
|
||||
data: data.map((d) => d.views)
|
||||
},
|
||||
{
|
||||
name: '访问量',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
areaStyle: {
|
||||
opacity: 0.5
|
||||
},
|
||||
data: data.map((d) => d.visits)
|
||||
}
|
||||
]
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
getVisitHourData();
|
||||
</script>
|
||||
41
src/views/baocan/workplace/index.vue
Normal file
41
src/views/baocan/workplace/index.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<div class="ele-body ele-body-card">
|
||||
<statistics-card />
|
||||
<sale-card />
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive ? { lg: 16, md: 14, sm: 24, xs: 24 } : { span: 16 }
|
||||
"
|
||||
>
|
||||
<visit-hour />
|
||||
</a-col>
|
||||
<a-col
|
||||
v-bind="
|
||||
styleResponsive ? { lg: 8, md: 10, sm: 24, xs: 24 } : { span: 8 }
|
||||
"
|
||||
>
|
||||
<hot-search />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import StatisticsCard from './components/statistics-card.vue';
|
||||
import SaleCard from './components/sale-card.vue';
|
||||
import VisitHour from './components/visit-hour.vue';
|
||||
import HotSearch from './components/hot-search.vue';
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'DashboardAnalysis'
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user