fix: 商城仓库管理
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import {ref} from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
import {useVbenModal} from '@vben/common-ui';
|
||||
import {useUserStore} from '@vben/stores';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
import {message} from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
|
||||
import { createWesternMedicine, updateWesternMedicine } from '../api';
|
||||
import { modalFormProps } from '../config/form';
|
||||
import {getDrugUseList} from "#/views/doctor/doctor-reception/api";
|
||||
import {useVbenForm} from '#/adapter/form';
|
||||
import {getDrugUseList} from '#/views/doctor/doctor-reception/api';
|
||||
|
||||
import {createWesternMedicine, getWesternMedicineInfo, updateWesternMedicine,} from '../api';
|
||||
import {modalFormProps} from '../config/form';
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
@@ -52,7 +51,6 @@ const gridApi = ref();
|
||||
|
||||
const [Form, formApi] = useVbenForm(modalFormProps);
|
||||
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
@@ -83,7 +81,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
onOpenChange(isOpen: boolean) {
|
||||
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
||||
if (isOpen) {
|
||||
|
||||
formApi.updateSchema([
|
||||
{
|
||||
componentProps: {
|
||||
@@ -112,9 +109,41 @@ const [Modal, modalApi] = useVbenModal({
|
||||
]);
|
||||
const { values, update } = modalApi.getData<Record<string, any>>();
|
||||
if (values) {
|
||||
console.log(values, 'sssssssssssss')
|
||||
isUpdate.value = update;
|
||||
formApi.setValues(values);
|
||||
|
||||
// 如果是编辑模式且有id,获取完整详情并写入表单
|
||||
if (update && values.id) {
|
||||
getWesternMedicineInfo(values.id)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
// 确保introduction_images是数组格式
|
||||
// if (
|
||||
// !detailData.introduction_images ||
|
||||
// !Array.isArray(detailData.introduction_images)
|
||||
// ) {
|
||||
// detailData.introduction_images = [];
|
||||
// }
|
||||
// 使用详情数据覆盖表单,确保所有字段都是最新的
|
||||
formApi.setValues({
|
||||
...values,
|
||||
introduction_images: res.introduction_images,
|
||||
});
|
||||
|
||||
console.log(formApi.getValues());
|
||||
} else {
|
||||
// 如果获取详情失败,使用传入的values
|
||||
formApi.setValues(values);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('获取商品详情失败:', error);
|
||||
// 获取失败时,使用传入的values
|
||||
formApi.setValues(values);
|
||||
});
|
||||
} else {
|
||||
// 新增模式,直接使用传入的values
|
||||
formApi.setValues(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -181,11 +181,11 @@ export const modalFormProps: VbenFormProps = {
|
||||
placeholder: '请选择',
|
||||
options: [
|
||||
{
|
||||
label: '否',
|
||||
label: '是',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
label: '是',
|
||||
label: '否',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
@@ -230,6 +230,16 @@ export const modalFormProps: VbenFormProps = {
|
||||
rules: 'required',
|
||||
formItemClass: 'col-span-6',
|
||||
},
|
||||
{
|
||||
component: 'UploadImageSortable',
|
||||
fieldName: 'introduction_images',
|
||||
label: '商品介绍图',
|
||||
formItemClass: 'col-span-12',
|
||||
componentProps: {
|
||||
maxCount: 20,
|
||||
multiple: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
};
|
||||
|
||||
@@ -67,3 +67,11 @@ export async function openQrCodeApi(id: number) {
|
||||
id,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新门店包邮状态
|
||||
* @param data
|
||||
*/
|
||||
export async function updateStoreShippingFree(data: { id: number }) {
|
||||
return requestClient.post<any>(`${prefix}update-shipping-free`, data);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,34 @@ export const modalFormProps: VbenFormProps = {
|
||||
label: 'ERP ID',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '诊所', value: 0 },
|
||||
{ label: '药店', value: 1 },
|
||||
],
|
||||
placeholder: '请选择门店类型',
|
||||
},
|
||||
fieldName: 'type',
|
||||
label: '门店类型',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '不包邮', value: 0 },
|
||||
{ label: '包邮', value: 1 },
|
||||
],
|
||||
placeholder: '是否包邮',
|
||||
},
|
||||
fieldName: 'is_shipping_free',
|
||||
label: '是否包邮',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
formItemClass: 'col-span-6',
|
||||
|
||||
@@ -33,6 +33,19 @@ export const formOptions: VbenFormProps = {
|
||||
fieldName: 'mobile',
|
||||
label: '联系人手机号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择类型',
|
||||
options: [
|
||||
{ label: '诊所', value: 0 },
|
||||
{ label: '药店', value: 1 },
|
||||
],
|
||||
},
|
||||
defaultValue: undefined,
|
||||
fieldName: 'type',
|
||||
label: '类型',
|
||||
},
|
||||
// {
|
||||
// component: 'RangePicker',
|
||||
// componentProps: {
|
||||
|
||||
@@ -25,6 +25,20 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', align: 'left', title: '诊所名称' },
|
||||
{
|
||||
field: 'type',
|
||||
align: 'left',
|
||||
title: '类型',
|
||||
slots: { default: 'type' },
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'is_shipping_free',
|
||||
align: 'left',
|
||||
title: '是否包邮',
|
||||
slots: { default: 'is_shipping_free' },
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'qr_code',
|
||||
align: 'left',
|
||||
|
||||
@@ -6,14 +6,19 @@ import { ref } from 'vue';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { Button, Image, message, Tag } from 'ant-design-vue';
|
||||
import { Button, Image, message, Switch, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { Icon } from '#/components/icon';
|
||||
import QrCodePreview from '#/components/modal/QrCodePreview.vue';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
|
||||
import { deleteStore, openPcWindowsApiByStore, openQrCodeApi } from './api';
|
||||
import {
|
||||
deleteStore,
|
||||
openPcWindowsApiByStore,
|
||||
openQrCodeApi,
|
||||
updateStoreShippingFree,
|
||||
} from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
@@ -103,6 +108,16 @@ function copyText(source) {
|
||||
message.success('复制成功');
|
||||
}
|
||||
const { copy } = useClipboard({ legacy: true });
|
||||
|
||||
/**
|
||||
* 更新包邮状态
|
||||
*/
|
||||
const updateShippingFree = (id: number) => {
|
||||
updateStoreShippingFree({ id }).then(() => {
|
||||
message.success('修改成功!');
|
||||
gridApi.query();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -169,6 +184,21 @@ const { copy } = useClipboard({ legacy: true });
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #type="{ row }">
|
||||
<Tag :color="row.type === 1 ? 'blue' : 'green'">
|
||||
{{ row.type === 1 ? '药店' : '诊所' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #is_shipping_free="{ row }">
|
||||
<Switch
|
||||
:checked="row.is_shipping_free"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="包邮"
|
||||
un-checked-children="不包邮"
|
||||
@click="updateShippingFree(row.id)"
|
||||
/>
|
||||
</template>
|
||||
<template #start-time="{ row }">
|
||||
早:<Tag color="success">{{ row.start_time }}</Tag>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user