提交 d1075d6d authored 作者: leon's avatar leon

add 经销商管理

上级 56b0ddc9
...@@ -5,81 +5,66 @@ ...@@ -5,81 +5,66 @@
*/ */
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { ApiResponse } from '../model/baseModel';
import { import {
Distributor, Distributor,
DistributorParams, DistributorParams,
DistributorPageResult, DistributorPageResult,
DistributorPageResponse,
DistributorResponse,
} from '../model/distributor'; } from '../model/distributor';
const baseApi = '/v1/system/distributor'; const baseApi = '/v1/system/distributor';
/** /**
* 新增 * 新增
*/ */
export const add = (entity: Distributor) => export const add = (entity: Distributor) => defHttp.post<Distributor>({ url: `${baseApi}/`, data: entity });
defHttp.post<Distributor>({ url: `${baseApi}/`, data: entity });
/** /**
* 更新 * 更新
*/ */
export const update = (entity: Distributor) => export const update = (entity: Distributor) => defHttp.put<Distributor>({ url: `${baseApi}/`, data: entity });
defHttp.put<Distributor>({ url: `${baseApi}/`, data: entity });
/** /**
* 删除 * 删除
*/ */
export const remove = (id: any) => export const remove = (id: any) => defHttp.delete<Number>({ url: `${baseApi}/${id}` });
defHttp.delete<Number>({ url: `${baseApi}/${id}` });
/** /**
* 分页查询 * 分页查询
*/ */
export const search = (params?: DistributorParams) => export const search = (params?: DistributorParams) => defHttp.get<DistributorPageResult>({ url: `${baseApi}/search`, params });
defHttp.get<DistributorPageResult>({ url: `${baseApi}/search`, params });
/** /**
* 列表查询 * 列表查询
*/ */
export const all = (params?: DistributorParams) => export const all = (params?: DistributorParams) => defHttp.get<DistributorPageResult>({ url: `${baseApi}/all`, params });
defHttp.get<DistributorPageResult>({ url: `${baseApi}/all`, params });
/** /**
* 通过主键查询 * 通过主键查询
*/ */
export const getById = (id: any) => export const getById = (id: any) => defHttp.get<Distributor>({ url: `${baseApi}/${id}` });
defHttp.get<Distributor>({ url: `${baseApi}/${id}` });
/** /**
* 单个查询 * 单个查询
*/ */
export const getOne = (params?: DistributorParams) => export const getOne = (params?: DistributorParams) => defHttp.get<Distributor>({ url: `${baseApi}/one`, params });
defHttp.get<Distributor>({ url: `${baseApi}/one`, params });
/** /**
* 批量删除 * 批量删除
*/ */
export const batchRemove = (idList: Array<any>) => export const batchRemove = (idList: Array<any>) => defHttp.post<boolean>({ url: `${baseApi}/batch-delete`, data: idList });
defHttp.post<boolean>({ url: `${baseApi}/batch-delete`, data: idList });
/** /**
* 批量新增 * 批量新增
*/ */
export const batchAdd = (entityList: Array<Distributor>) => export const batchAdd = (entityList: Array<Distributor>) => defHttp.post<boolean>({ url: `${baseApi}/batch-save`, data: entityList });
defHttp.post<boolean>({ url: `${baseApi}/batch-save`, data: entityList });
/** /**
* 批量更新 * 批量更新
*/ */
export const batchUpdate = (entityList: Array<Distributor>) => export const batchUpdate = (entityList: Array<Distributor>) => defHttp.post<boolean>({ url: `${baseApi}/batch-update`, data: entityList });
defHttp.post<boolean>({ url: `${baseApi}/batch-update`, data: entityList });
/** /**
* 查询数量 * 查询数量
*/ */
export const count = (params?: DistributorParams) => export const count = (params?: DistributorParams) => defHttp.get<Number>({ url: `${baseApi}/count`, params });
defHttp.get<Number>({ url: `${baseApi}/count`, params });
<template> <template>
<Card :bordered="false"> <Card :bordered="false" :loading="isLoading">
<Descriptions bordered :column="3"> <Descriptions bordered :column="3">
<Descriptions.Item <Descriptions.Item
v-for="p in displayProps" v-for="p in displayProps"
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
:label="p.title" :label="p.title"
:span="['avatar'].includes(p.name) ? 3 : 1" :span="['avatar'].includes(p.name) ? 3 : 1"
> >
<span v-if="p.key === 'avatar'"> <span v-if="p.key === 'licensePic'">
<img :src="p.value" style="width: 120px; height: 120px" /> <ImagePreview :imageList="[p.value]" style="width: 120px" />
</span> </span>
<template v-else> <template v-else>
{{ p.value }} {{ p.value }}
...@@ -18,39 +18,47 @@ ...@@ -18,39 +18,47 @@
</Card> </Card>
</template> </template>
<script lang="ts" setup name="DeviceDetail"> <script lang="ts" setup name="DeviceDetail">
import { onMounted, computed, ref, reactive } from 'vue'; import { onMounted, computed, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useAsyncState } from '@vueuse/core';
import { ImagePreview } from '/@/components/Preview/index';
import { ComputedRef } from '@vue/reactivity'; import { ComputedRef } from '@vue/reactivity';
import { Descriptions, Card } from 'ant-design-vue'; import { Descriptions, Card } from 'ant-design-vue';
import { descriptionColumns } from './schema'; import { descriptionColumns } from './schema';
import * as DistributorApi from '/@/api/system/distributorApi'; import * as DistributorApi from '/@/api/system/distributorApi';
import { Device } from '/@/api/model/device'; import { Distributor } from '/@/api/model/distributor';
const route = useRoute(); const route = useRoute();
const id = ref(route.params?.id); const id = ref(route.params?.id);
let data = reactive({
detail: {}, // id 查询
isOver: false, const {
}); state: detail,
const getDetail = () => { isReady: isDetailReady,
DistributorApi.getById(id.value).then((res: Device) => { isLoading,
data.isOver = true; execute,
data.detail = res; } = useAsyncState(
}); () => {
}; return DistributorApi.getById(id.value).then((res: Distributor) => res);
},
null,
{
immediate: false,
},
);
onMounted(() => { onMounted(() => {
getDetail(); execute();
}); });
const displayProps: ComputedRef<Array<any>> = computed(() => { const displayProps: ComputedRef<Array<any>> = computed(() => {
if (!data.isOver) return {}; if (!isDetailReady.value) return {};
const display: any = descriptionColumns.map(({ title, dataIndex = '', customRender }) => ({ const display: any = descriptionColumns.map(({ title, dataIndex = '', customRender }) => ({
key: dataIndex, key: dataIndex,
title, title,
value: customRender value: customRender
? customRender({ text: data.detail[dataIndex], record: data.detail }) ? customRender({ text: detail.value[dataIndex], record: detail.value })
: data.detail[dataIndex], : detail.value[dataIndex],
})); }));
return display; return display;
}); });
......
<template> <template>
<BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="600px" @ok="handleSubmit"> <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :confirmDisabled="getConfirmDisabled" :title="getTitle" width="600px" @ok="handleSubmit">
<BasicForm @register="registerForm" /> <a-spin :spinning="isLoading">
<BasicForm @register="registerForm" />
</a-spin>
</BasicDrawer> </BasicDrawer>
</template> </template>
<script lang="ts" setup name="DistributorDrawer"> <script lang="ts" setup name="DistributorDrawer">
...@@ -8,7 +10,9 @@ ...@@ -8,7 +10,9 @@
import { BasicForm, useForm } from '/@/components/Form/index'; import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from './schema'; import { formSchema } from './schema';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { useAsyncState } from '@vueuse/core';
import * as DistributorApi from '/@/api/system/distributorApi'; import * as DistributorApi from '/@/api/system/distributorApi';
import { Distributor } from '/@/api/model/distributor';
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const isUpdate = ref(true); const isUpdate = ref(true);
...@@ -20,6 +24,22 @@ ...@@ -20,6 +24,22 @@
showActionButtonGroup: false, showActionButtonGroup: false,
}); });
// id 查询
const {
state: detail,
isReady: isDetailReady,
isLoading,
execute,
} = useAsyncState(
() => {
return DistributorApi.getById(entityId.value).then((res: Distributor) => res);
},
null,
{
immediate: false,
},
);
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
await resetFields(); await resetFields();
setDrawerProps({ confirmLoading: false }); setDrawerProps({ confirmLoading: false });
...@@ -27,9 +47,21 @@ ...@@ -27,9 +47,21 @@
entityId.value = data?.record?.id; entityId.value = data?.record?.id;
if (unref(isUpdate)) { if (unref(isUpdate)) {
await setFieldsValue({ await execute();
...data.record, if (detail.value) {
}); const formData: any = {
...detail.value,
};
await setFieldsValue(formData);
}
}
});
const getConfirmDisabled = computed(() => {
if (unref(isUpdate)) {
return !unref(isDetailReady);
} else {
return false;
} }
}); });
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<span>已选中{{ checkedKeys.length }}条记录</span> <span>已选中{{ checkedKeys.length }}条记录</span>
<a-button type="link" @click="checkedKeys = []" size="small">清空</a-button> <a-button type="link" @click="checkedKeys = []" size="small">清空</a-button>
<a-popconfirm <a-popconfirm
v-auth="'AUTH_SYSTEM_DISTRIBUTOR'"
class="ml-4" class="ml-4"
title="确定要全部删除吗?" title="确定要全部删除吗?"
ok-text="是" ok-text="是"
...@@ -27,9 +28,6 @@ ...@@ -27,9 +28,6 @@
<a-button v-auth="'AUTH_SYSTEM_DISTRIBUTOR:ADD'" type="primary" @click="handleCreate"> 新增</a-button> <a-button v-auth="'AUTH_SYSTEM_DISTRIBUTOR:ADD'" type="primary" @click="handleCreate"> 新增</a-button>
</template> </template>
<template #bodyCell="{ column, record, text }"> <template #bodyCell="{ column, record, text }">
<template v-if="column.dataIndex === 'id'">
<a @click="handleView(record)"> {{ record.id }} </a>
</template>
<template v-if="[&#39;licensePic&#39;].includes(column.dataIndex)"> <template v-if="[&#39;licensePic&#39;].includes(column.dataIndex)">
<img :src="text" class="photo" alt="图片" v-if="!!text" /> <img :src="text" class="photo" alt="图片" v-if="!!text" />
</template> </template>
...@@ -42,6 +40,12 @@ ...@@ -42,6 +40,12 @@
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
ifShow: hasPermission('AUTH_SYSTEM_DISTRIBUTOR:EDIT'), ifShow: hasPermission('AUTH_SYSTEM_DISTRIBUTOR:EDIT'),
}, },
{
tooltip: '详情',
icon: 'ant-design:eye-outlined',
onClick: handleView.bind(null, record),
ifShow: hasPermission('AUTH_SYSTEM_DISTRIBUTOR:QUERY'),
},
{ {
tooltip: '删除', tooltip: '删除',
icon: 'ant-design:delete-outlined', icon: 'ant-design:delete-outlined',
...@@ -60,7 +64,7 @@ ...@@ -60,7 +64,7 @@
<DistributorDrawer @register="registerDrawer" @success="handleSuccess" /> <DistributorDrawer @register="registerDrawer" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" setup name="DeviceIndex"> <script lang="ts" setup name="AUTH_SYSTEM_DISTRIBUTOR">
import { ref } from 'vue'; import { ref } from 'vue';
import { useGo } from '/@/hooks/web/usePage'; import { useGo } from '/@/hooks/web/usePage';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
...@@ -75,15 +79,20 @@ ...@@ -75,15 +79,20 @@
const { hasPermission } = usePermission(); const { hasPermission } = usePermission();
const go = useGo(); const go = useGo();
const { formConfig, showTableSetting, bordered, showIndexColumn } = componentSetting.table; const {
formConfig,
showTableSetting,
bordered,
showIndexColumn,
} = componentSetting.table;
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const onSelectChange = (selectedRowKeys: (string | number)[]) => { const onSelectChange = (selectedRowKeys: (string | number)[]) => {
checkedKeys.value = selectedRowKeys; checkedKeys.value = selectedRowKeys;
}; }
const [registerDrawer, { openDrawer }] = useDrawer(); const [registerDrawer, { openDrawer }] = useDrawer();
const [registerTable, { reload }] = useTable({ const [registerTable, { reload ,setLoading}] = useTable({
title: '经销商表', title: '经销商表',
api: (params) => DistributorApi.search(handleParams(params)), api: (params) => DistributorApi.search(handleParams(params)),
columns, columns,
...@@ -94,6 +103,7 @@ ...@@ -94,6 +103,7 @@
}, },
rowSelection: { rowSelection: {
type: 'checkbox', type: 'checkbox',
// @ts-ignore
selectedRowKeys: checkedKeys, selectedRowKeys: checkedKeys,
onChange: onSelectChange, onChange: onSelectChange,
}, },
...@@ -104,10 +114,9 @@ ...@@ -104,10 +114,9 @@
canResize: false, canResize: false,
rowKey: (record: any) => record.id, rowKey: (record: any) => record.id,
actionColumn: { actionColumn: {
width: 80, width: 120,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
fixed: 'right', fixed: 'right',
}, },
}); });
...@@ -150,14 +159,20 @@ ...@@ -150,14 +159,20 @@
}; };
const handleDelete = (record: Recordable) => { const handleDelete = (record: Recordable) => {
setLoading(true);
DistributorApi.remove(record.id).then((_) => { DistributorApi.remove(record.id).then((_) => {
reload(); reload();
}).catch(() => {
setLoading(false);
}); });
}; };
const handleBatchDelete = () => { const handleBatchDelete = () => {
setLoading(true);
DistributorApi.batchRemove(checkedKeys.value).then((_) => { DistributorApi.batchRemove(checkedKeys.value).then((_) => {
reload(); reload();
}).catch(() => {
setLoading(false);
}); });
}; };
...@@ -166,6 +181,6 @@ ...@@ -166,6 +181,6 @@
}; };
const handleView = (record) => { const handleView = (record) => {
go('/system/distributor/' + record.id); go('/main/system/distributor/' + record.id);
}; };
</script> </script>
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import get from 'lodash.get';
export enum StatusEnum { export enum StatusEnum {
PENDING_REVIEW = '待审核', PENDING_REVIEW = '待审核',
...@@ -33,16 +32,16 @@ export const schema = { ...@@ -33,16 +32,16 @@ export const schema = {
properties: [ properties: [
{ {
field: 'id', field: 'id',
label: 'ID系统自动生成', label: 'ID',
defaultValue: undefined, defaultValue: undefined,
form: { form: {
componentProps: { componentProps: {
allowClear: false, allowClear: false,
placeholder: 'ID系统自动生成', placeholder: 'ID',
}, },
colProps, colProps,
component: 'InputNumber', component: 'InputNumber',
rules: [{ required: true, message: '请输入ID系统自动生成!' }], rules: [{ required: true, message: '请输入ID!' }],
}, },
table: {}, table: {},
}, },
...@@ -254,7 +253,6 @@ export const schema = { ...@@ -254,7 +253,6 @@ export const schema = {
}; };
const queryFields = [ const queryFields = [
'id',
'name', 'name',
'price', 'price',
'usedPrice', 'usedPrice',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论