修复:智能判断订单商品orderGoods和订单信息orderInfo的显示问题

This commit is contained in:
2024-09-14 15:41:55 +08:00
parent ea5a48fa29
commit befa701207
11 changed files with 548 additions and 320 deletions

View File

@@ -123,7 +123,7 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, htmlToText, uuid } from 'ele-admin-pro';
import { addArticle, updateArticle } from "@/api/cms/article";
import { addArticle, getArticle, updateArticle } from "@/api/cms/article";
import { Article } from '@/api/cms/article/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -137,6 +137,8 @@
import { listArticleCategory } from "@/api/cms/category";
import { Navigation } from "@/api/cms/navigation/model";
import SourceSelect from "@/views/cms/article/dictionary/source-select.vue";
import { getCmsArticleContent } from "@/api/cms/cmsArticleContent";
import { isImage } from "@/utils/common";
// 是否是修改
const isUpdate = ref(false);
@@ -175,7 +177,6 @@
const active = ref('base');
const spec = ref<SpecValue[]>([]);
const showSpecForm = ref(false);
const files = ref<ItemType[]>([]);
const category = ref<string[]>([]);
const takeaway = ref<ArticleCategory[]>([]);
@@ -453,24 +454,45 @@
category.value = [];
files.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
});
}
if(props.data.files){
const arr = JSON.parse(props.data.files)
arr.map((url:string) => {
files.value.push({
// 文章详情
getArticle(Number(props.data?.articleId)).then(data => {
assignObject(form, data);
if (data.content){
content.value = data.content;
}
if (data.image) {
images.value.push({
uid: uuid(),
url: url,
url: data.image,
status: 'done'
});
}
if(data.files){
const arr = JSON.parse(data.files)
arr.map((url:string) => {
files.value.push({
uid: uuid(),
url: url,
status: 'done'
})
})
})
}
}
})
// 外卖文章分类
listArticleCategory({merchantId: props.merchantId}).then(list => {
takeaway.value = list
})
// assignObject(form, props.data);
// 文章分类
// if(props.data.categoryParent){
@@ -479,13 +501,6 @@
// if(props.data.categoryChildren){
// category.value.push(props.data.categoryChildren);
// }
if (props.data.content){
content.value = props.data.content;
}
// 外卖文章分类
listArticleCategory({merchantId: props.merchantId}).then(list => {
takeaway.value = list
})
isUpdate.value = true;
} else {

View File

@@ -36,7 +36,7 @@
record.articleId
)
"
>{{ record.title }}</span
>{{ record.title }}</span
>
</template>
<template v-if="column.key === 'categoryName'">
@@ -49,7 +49,7 @@
record.categoryId
)
"
>{{ record.categoryName }}</span
>{{ record.categoryName }}</span
>
</template>
<template v-if="column.key === 'type'">
@@ -57,7 +57,8 @@
<a-tag v-if="record.type === 1">实物文章</a-tag>
</template>
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="80" />
<a-image v-if="isImage(record.image)" :src="record.image" :width="80" />
<span v-else class="text-gray-400">[文件]</span>
</template>
<template v-if="column.key === 'salePrice'">
{{ formatNumber(record.salePrice) }}
@@ -67,7 +68,8 @@
:color="record.status == 0 ? 'green' : 'red'"
class="cursor-pointer"
@click="onUpdate(record)"
>{{ record.statusText }}</a-tag
>{{ record.statusText }}
</a-tag
>
</template>
<template v-if="column.key === 'action'">
@@ -99,272 +101,272 @@
</template>
<script lang="ts" setup>
import { createVNode, ref, watch } 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 Search from './components/search.vue';
import ArticleEdit from './components/articleEdit.vue';
import {
pageArticle,
removeArticle,
removeBatchArticle
} from '@/api/cms/article';
import type { Article, ArticleParam } from '@/api/cms/article/model';
import { formatNumber } from 'ele-admin-pro/es';
import router from '@/router';
import { toTreeData } from 'ele-admin-pro';
import { openSpmUrl } from '@/utils/common';
import { listNavigation } from '@/api/cms/navigation';
import { Navigation } from '@/api/cms/navigation/model';
import { createVNode, ref, watch } 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 Search from "./components/search.vue";
import ArticleEdit from "./components/articleEdit.vue";
import {
pageArticle,
removeArticle,
removeBatchArticle
} from "@/api/cms/article";
import type { Article, ArticleParam } from "@/api/cms/article/model";
import { formatNumber } from "ele-admin-pro/es";
import router from "@/router";
import { toTreeData } from "ele-admin-pro";
import { isImage, openSpmUrl } from "@/utils/common";
import { listNavigation } from "@/api/cms/navigation";
import { Navigation } from "@/api/cms/navigation/model";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Article[]>([]);
// 当前编辑数据
const current = ref<Article | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 栏目ID
const categoryId = ref<number>();
// 当前模型
const model = ref<number>();
// 栏目数据
const navigationList = ref<Navigation[]>();
// 表格选中数据
const selection = ref<Article[]>([]);
// 当前编辑数据
const current = ref<Article | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<number>();
// 栏目ID
const categoryId = ref<number>();
// 当前模型
const model = ref<number>();
// 栏目数据
const navigationList = ref<Navigation[]>();
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
return pageArticle({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
width: 90
},
{
title: '封面图',
dataIndex: 'image',
key: 'image',
width: 120,
align: 'center'
},
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
{
title: '栏目名称',
dataIndex: 'categoryName',
key: 'categoryName',
width: 120,
align: 'center'
},
{
title: '所属栏目',
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
hideInTable: true
},
{
title: '实际阅读量',
dataIndex: 'actualViews',
key: 'actualViews',
sorter: true,
width: 120,
align: 'center'
},
{
title: '虚拟阅读量',
dataIndex: 'virtualViews',
key: 'virtualViews',
width: 120,
align: 'center'
},
{
title: '推荐',
dataIndex: 'recommend',
key: 'recommend',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 120,
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ArticleParam) => {
if (where?.categoryId) {
categoryId.value = where.categoryId;
}
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Article) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const onUpdate = (row?: Article) => {
// const isShow = row?.isShow == 0 ? 1 : 0;
// updateArticle({ ...row, isShow }).then((msg) => {
// message.success(msg);
// reload();
// });
};
/* 删除单个 */
const remove = (row: Article) => {
const hide = message.loading('请求中..', 0);
removeArticle(row.articleId)
.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);
removeBatchArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: Article) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (d.model != 'article') {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
return pageArticle({
...where,
...orders,
page,
limit
});
};
watch(
() => router.currentRoute.value.query,
(query) => {
console.log(query);
if (query) {
categoryId.value = Number(query.id);
model.value = Number(query.type);
reload();
}
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: "ID",
dataIndex: "articleId",
key: "articleId",
align: "center",
width: 90
},
{
title: "封面图",
dataIndex: "image",
key: "image",
width: 120,
align: "center"
},
{
title: "文章标题",
dataIndex: "title",
key: "title"
},
{
title: "栏目名称",
dataIndex: "categoryName",
key: "categoryName",
width: 120,
align: "center"
},
{
title: "所属栏目",
dataIndex: "categoryId",
key: "categoryId",
align: "center",
hideInTable: true
},
{
title: "实际阅读量",
dataIndex: "actualViews",
key: "actualViews",
sorter: true,
width: 120,
align: "center"
},
{
title: "虚拟阅读量",
dataIndex: "virtualViews",
key: "virtualViews",
width: 120,
align: "center"
},
{
title: "推荐",
dataIndex: "recommend",
key: "recommend",
sorter: true,
align: "center",
hideInTable: true
},
{
title: "状态",
dataIndex: "status",
key: "status",
sorter: true,
width: 120,
align: "center"
},
{
title: "排序号",
dataIndex: "sortNumber",
key: "sortNumber",
sorter: true,
align: "center",
hideInTable: true
},
{
title: "创建时间",
dataIndex: "createTime",
key: "createTime",
align: "center",
width: 180,
sorter: true
},
{
title: "操作",
key: "action",
width: 180,
fixed: "right",
align: "center",
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ArticleParam) => {
if (where?.categoryId) {
categoryId.value = where.categoryId;
}
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Article) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const onUpdate = (row?: Article) => {
// const isShow = row?.isShow == 0 ? 1 : 0;
// updateArticle({ ...row, isShow }).then((msg) => {
// message.success(msg);
// reload();
// });
};
/* 删除单个 */
const remove = (row: Article) => {
const hide = message.loading("请求中..", 0);
removeArticle(row.articleId)
.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);
removeBatchArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: Article) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
{ immediate: true }
);
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (d.model != "article") {
d.disabled = true;
}
return d;
}),
idField: "navigationId",
parentIdField: "parentId"
});
});
}
watch(
() => router.currentRoute.value.query,
(query) => {
console.log(query);
if (query) {
categoryId.value = Number(query.id);
model.value = Number(query.type);
reload();
}
},
{ immediate: true }
);
</script>
<script lang="ts">
export default {
name: 'ArticleV2'
};
export default {
name: "ArticleV2"
};
</script>

View File

@@ -53,15 +53,10 @@
<span class="cursor-pointer" v-if="isDirectory(record)"></span>
<span
v-else
@click="openSpmUrl(record.path, record, record.navigationId)"
@click="openSpmUrl(`https://${record.tenantId}.wsdns.cn${record.path}`, record, record.navigationId)"
class="ele-text-placeholder cursor-pointer"
>{{ record.path }}</span
>
<!-- <span-->
<!-- class="ele-text-placeholder cursor-pointer"-->
<!-- @click="openSpmUrl(record.path, record, record.navigationId)"-->
<!-- >{{ record.path }}</span-->
<!-- >-->
</template>
<template v-if="column.key === 'component'">
<template v-if="!isDirectory(record)">

View File

@@ -147,6 +147,8 @@
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FileRecord } from '@/api/system/file/model';
import { checkExistence } from '@/api/cms/domain';
import { updateCmsWebsite } from '@/api/cms/cmsWebsite';
import { updateCmsDomain } from '@/api/cms/cmsDomain';
// 是否是修改
const isUpdate = ref(false);
@@ -318,12 +320,8 @@
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
tenantId: localStorage.getItem('TenantId')
};
const saveOrUpdate = isUpdate.value ? updateWebsite : addWebsite;
saveOrUpdate(formData)
saveOrUpdate(form)
.then((msg) => {
loading.value = false;
message.success(msg);
@@ -333,6 +331,10 @@
} else {
localStorage.setItem('Domain', `${form.websiteCode}.wsdns.cn`);
}
updateCmsDomain({
websiteId: form.websiteId,
domain: `${form.websiteCode}.wsdns.cn`
});
emit('done');
})
.catch((e) => {

View File

@@ -12,7 +12,7 @@
:footer="null"
@ok="save"
>
<a-card class="order-card" :bordered="false">
<a-card class="order-card" :bordered="false" v-if="form">
<a-descriptions title="基本信息" :column="3">
<a-descriptions-item
label="订单号"
@@ -139,10 +139,24 @@
<a-card class="order-card" :bordered="false">
<a-spin :spinning="loading">
<a-table
:data-source="form.orderInfoList"
v-if="form.orderInfo && form.orderInfo.length > 0"
:data-source="form.orderInfo"
:columns="columns"
:pagination="false"
/>
<a-table
v-if="form.orderGoods && form.orderGoods.length > 0"
:data-source="form.orderGoods"
:columns="columnsGoods"
:pagination="false"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'goodsName'">
<a-avatar :src="record.image" :size="40" />
<span style="margin-left: 8px">{{ record.goodsName }}</span>
</template>
</template>
</a-table>
</a-spin>
</a-card>
</ele-modal>
@@ -150,7 +164,7 @@
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from "ant-design-vue";
import { Form } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { Order } from '@/api/shop/order/model';
import { ColumnItem } from 'ele-admin-pro/es/ele-pro-table/types';
@@ -160,6 +174,8 @@
CoffeeOutlined
} from '@ant-design/icons-vue';
import { pageOrderInfo } from '@/api/shop/orderInfo';
import { pageOrderGoods } from '@/api/shop/orderGoods';
import record from "@/views/cms/design/record/index.vue";
const useForm = Form.useForm;
@@ -230,12 +246,12 @@
payPrice: undefined,
price: undefined,
money: undefined,
payType: undefined,
refundMoney: undefined,
coachPrice: undefined,
coachId: undefined,
payType: undefined,
payStatus: undefined,
orderStatus: undefined,
payStatus: undefined,
couponType: undefined,
couponDesc: undefined,
qrcode: undefined,
@@ -250,14 +266,11 @@
isSettled: undefined,
version: undefined,
userId: undefined,
deleted: undefined,
tenantId: undefined,
updateTime: undefined,
createTime: undefined,
status: 0,
comments: '',
sortNumber: 100,
orderInfoList: []
orderGoods: [],
orderInfo: []
});
// 请求状态
@@ -292,6 +305,28 @@
}
]);
const columnsGoods = ref<ColumnItem[]>([
{
title: '商品名称',
dataIndex: 'goodsName',
key: 'goodsName'
},
{
title: '商品规格',
dataIndex: 'spec'
},
{
title: '购买数量',
dataIndex: 'totalNum',
key: 'totalNum'
},
{
title: '金额',
dataIndex: 'price',
customRender: ({ text }) => '¥' + text
}
]);
/* 制作步骤条 */
const loadSteps = (order) => {
steps.value = [];
@@ -368,8 +403,12 @@
if (props.data) {
loading.value = true;
assignObject(form, props.data);
pageOrderGoods({ orderId: form.orderId }).then((res) => {
form.orderGoods = res?.list;
loading.value = false;
});
pageOrderInfo({ oid: form.orderId }).then((res) => {
form.orderInfoList = res?.list;
form.orderInfo = res?.list;
loading.value = false;
});
loadSteps(props.data);