Showing
7 changed files
with
267 additions
and
9 deletions
src/api/equipment/supplier.ts
0 → 100644
1 | +import {omit} from "lodash-es"; | ||
2 | +import {defHttp} from "/@/utils/http/axios"; | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | +/** | ||
7 | + * 获取列表 | ||
8 | + */ | ||
9 | +export const getSupplierList = (params) => { | ||
10 | + const { page, pageSize } = params; | ||
11 | + const otherParams = omit(params, ['page', 'pageSize']); | ||
12 | + return defHttp.post<any>({ | ||
13 | + url: `/supplier/pageData?page=${page}&pageSize=${pageSize}`, | ||
14 | + params: otherParams, | ||
15 | + }); | ||
16 | +}; | ||
17 | + | ||
18 | + | ||
19 | +/** | ||
20 | + * 新增 | ||
21 | + */ | ||
22 | +export const saveSupplier = (params) => { | ||
23 | + return defHttp.post<any>({ | ||
24 | + url: `/supplier/save`, | ||
25 | + params, | ||
26 | + }); | ||
27 | +}; | ||
28 | +/** | ||
29 | + * 删除 | ||
30 | + */ | ||
31 | +export const deleteSupplier = (params) => { | ||
32 | + return defHttp.post<any>({ | ||
33 | + url: `/supplier/delete`, | ||
34 | + params, | ||
35 | + }); | ||
36 | +}; | ||
37 | + | ||
38 | +/** | ||
39 | + * 选择列表 | ||
40 | + */ | ||
41 | +export const supplierListPull = (params) => { | ||
42 | + return defHttp.post<any>({ | ||
43 | + url: `/supplier/list`, | ||
44 | + params, | ||
45 | + }); | ||
46 | +}; |
src/locales/lang/zh-CN/equipment/supplier.ts
0 → 100644
@@ -113,8 +113,8 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async ( | @@ -113,8 +113,8 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async ( | ||
113 | if (!selectedItem.value) { | 113 | if (!selectedItem.value) { |
114 | selectedItem.value = { id: '', username: '' }; | 114 | selectedItem.value = { id: '', username: '' }; |
115 | } | 115 | } |
116 | - selectedItem.value.username = data?.record?.reportByName || ''; | ||
117 | - selectedItem.value.id = data?.record?.reportBy || ''; | 116 | + selectedItem.value.username = data?.record?.directorName || ''; |
117 | + selectedItem.value.id = data?.record?.directorId || ''; | ||
118 | setFieldsValue(setDefaultTime()); | 118 | setFieldsValue(setDefaultTime()); |
119 | updateSchema(disableCustomWeekly(0)); | 119 | updateSchema(disableCustomWeekly(0)); |
120 | setDrawerProps(setPropsForModal(businessText.value)); | 120 | setDrawerProps(setPropsForModal(businessText.value)); |
@@ -3,6 +3,7 @@ import {useI18n} from "../../../../hooks/web/useI18n"; | @@ -3,6 +3,7 @@ import {useI18n} from "../../../../hooks/web/useI18n"; | ||
3 | const { t } = useI18n(); | 3 | const { t } = useI18n(); |
4 | import { CategoryTreeSelect } from '../../../common/CategoryTreeSelect'; | 4 | import { CategoryTreeSelect } from '../../../common/CategoryTreeSelect'; |
5 | import { OrgTreeSelect } from '../../../common/OrgTreeSelect'; | 5 | import { OrgTreeSelect } from '../../../common/OrgTreeSelect'; |
6 | +import {supplierListPull} from "/@/api/equipment/supplier"; | ||
6 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); | 7 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); |
7 | useComponentRegister('CategoryTreeSelect', CategoryTreeSelect); | 8 | useComponentRegister('CategoryTreeSelect', CategoryTreeSelect); |
8 | const statusOptions = [ | 9 | const statusOptions = [ |
@@ -154,15 +155,20 @@ export const formSchema: BFormSchema[] = [ | @@ -154,15 +155,20 @@ export const formSchema: BFormSchema[] = [ | ||
154 | }, | 155 | }, |
155 | { | 156 | { |
156 | field: 'supplierId', | 157 | field: 'supplierId', |
157 | - component: 'OrgTreeSelect', | 158 | + component: 'ApiSelect', |
158 | label: '供应商', | 159 | label: '供应商', |
159 | colProps: { span: 24 }, | 160 | colProps: { span: 24 }, |
160 | - componentProps: { | ||
161 | - // 添加 change 事件 | ||
162 | - onChange: (value: string) => { | ||
163 | - // 这里需要触发加载人员数据的逻辑 | ||
164 | - console.log(value,'value') | ||
165 | - }, | 161 | + required: true, |
162 | + componentProps: ({ }) => { | ||
163 | + return { | ||
164 | + api: supplierListPull, | ||
165 | + params: { | ||
166 | + | ||
167 | + }, | ||
168 | + labelField: 'name', | ||
169 | + valueField: 'id', | ||
170 | + getPopupContainer: () => document.body, | ||
171 | + }; | ||
166 | }, | 172 | }, |
167 | }, | 173 | }, |
168 | { | 174 | { |
1 | +<template> | ||
2 | + <div> | ||
3 | + <BasicModal | ||
4 | + v-bind="$attrs" | ||
5 | + width="30rem" | ||
6 | + :title="getTitle" | ||
7 | + @register="register" | ||
8 | + @cancel="handleCancel" | ||
9 | + @ok="handleOk" | ||
10 | + destroyOnClose | ||
11 | + > | ||
12 | + <div> | ||
13 | + <BasicForm @register="registerForm" /> | ||
14 | + </div> | ||
15 | + </BasicModal> | ||
16 | + </div> | ||
17 | +</template> | ||
18 | +<script setup lang="ts"> | ||
19 | +import {BasicModal, useModalInner} from "/@/components/Modal"; | ||
20 | +import {BasicForm, useForm} from "/@/components/Form"; | ||
21 | +import {computed, ref, unref} from "vue"; | ||
22 | +import {useI18n} from "/@/hooks/web/useI18n"; | ||
23 | +import {schemas} from "../index"; | ||
24 | +import {saveSupplier} from "/@/api/equipment/supplier"; | ||
25 | +import {useMessage} from "/@/hooks/web/useMessage"; | ||
26 | +const { t } = useI18n(); | ||
27 | +const isUpdate = ref<Boolean>(false); | ||
28 | +const { createMessage } = useMessage(); | ||
29 | +const emit = defineEmits(['handleReload', 'register']); | ||
30 | +const recordInfo = ref<any>({}); | ||
31 | +const [registerForm, { getFieldsValue, setFieldsValue, validate }] = useForm({ | ||
32 | + labelWidth: 140, | ||
33 | + schemas, | ||
34 | + actionColOptions: { | ||
35 | + span: 14, | ||
36 | + }, | ||
37 | + showActionButtonGroup: false, | ||
38 | +}); | ||
39 | + | ||
40 | +const getTitle = computed(() => | ||
41 | + !unref(isUpdate) | ||
42 | + ? t('equipment.supplier.createPlanText') | ||
43 | + : t('equipment.supplier.editPlanText') | ||
44 | +); | ||
45 | + | ||
46 | +const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { | ||
47 | + setModalProps({ confirmLoading: false, loading: true }); | ||
48 | + isUpdate.value = data?.isUpdate; | ||
49 | + recordInfo.value = data?.record; | ||
50 | + if (data?.record) { | ||
51 | + setFieldsValue(data?.record); | ||
52 | + } | ||
53 | + setModalProps({ loading: false }); | ||
54 | +}); | ||
55 | + | ||
56 | +const handleCancel = () => { | ||
57 | + closeModal(); | ||
58 | +}; | ||
59 | + | ||
60 | +const handleOk = async () => { | ||
61 | + await validate(); | ||
62 | + let values = getFieldsValue(); | ||
63 | + if (unref(isUpdate)) { | ||
64 | + values = { ...values, id: unref(recordInfo).id }; | ||
65 | + } | ||
66 | + await saveSupplier(values); | ||
67 | + createMessage.success(t('common.operationSuccessText')); | ||
68 | + emit('handleReload'); | ||
69 | + handleCancel(); | ||
70 | +}; | ||
71 | + | ||
72 | +</script> |
src/views/equipment/supplier/index.vue
0 → 100644
1 | +<template> | ||
2 | + <div> | ||
3 | + <BasicTable :clickToRowSelect="false" @register="registerTable"> | ||
4 | + <template #toolbar> | ||
5 | + <Authority value="api:yt:product:category:post"> | ||
6 | + <Button type="primary" @click="handleCreate"> | ||
7 | + {{ t('equipment.supplier.createPlanText') }} | ||
8 | + </Button> | ||
9 | + </Authority> | ||
10 | + </template> | ||
11 | + <template #action="{ record }"> | ||
12 | + <TableAction | ||
13 | + :actions="[ | ||
14 | + { | ||
15 | + label: t('common.editText'), | ||
16 | + auth: 'api:yt:product:category:update', | ||
17 | + icon: 'clarity:note-edit-line', | ||
18 | + onClick: handleEdit.bind(null, record), | ||
19 | + }, | ||
20 | + { | ||
21 | + label: t('common.delText'), | ||
22 | + auth: 'api:yt:product:category:delete', | ||
23 | + icon: 'ant-design:delete-outlined', | ||
24 | + color: 'error', | ||
25 | + popConfirm: { | ||
26 | + title: t('common.deleteConfirmText'), | ||
27 | + confirm: handleDelete.bind(null, record), | ||
28 | + }, | ||
29 | + }, | ||
30 | + ]" | ||
31 | + /> | ||
32 | + </template> | ||
33 | + </BasicTable> | ||
34 | + <supplierModal @register="registerModal" @handleReload="handleReload" /> | ||
35 | + </div> | ||
36 | +</template> | ||
37 | + | ||
38 | +<script setup lang="ts"> | ||
39 | +import {BasicTable, TableAction, useTable} from '/@/components/Table'; | ||
40 | +import {deleteSupplier, getSupplierList} from "/@/api/equipment/supplier"; | ||
41 | +import {columns, searchFormSchema} from "./index"; | ||
42 | +import {useI18n} from "/@/hooks/web/useI18n"; | ||
43 | +import { supplierModal } from "./components/index" | ||
44 | +const { t } = useI18n(); | ||
45 | +import {Button} from "ant-design-vue"; | ||
46 | +import {useModal} from "/@/components/Modal"; | ||
47 | +import {useMessage} from "/@/hooks/web/useMessage"; | ||
48 | +const [registerModal, { openModal }] = useModal(); | ||
49 | +const { createMessage } = useMessage(); | ||
50 | + | ||
51 | +const [ | ||
52 | + registerTable, | ||
53 | + { reload, setLoading, getSelectRowKeys, setSelectedRowKeys, getRowSelection }, | ||
54 | +] = useTable({ | ||
55 | + title: t('equipment.supplier.listText'), | ||
56 | + api: getSupplierList, | ||
57 | + columns, | ||
58 | + formConfig: { | ||
59 | + labelWidth: 100, | ||
60 | + schemas: searchFormSchema, | ||
61 | + }, | ||
62 | + immediate: true, | ||
63 | + useSearchForm: true, | ||
64 | + showTableSetting: true, | ||
65 | + bordered: true, | ||
66 | + showIndexColumn: false, | ||
67 | + clickToRowSelect: false, | ||
68 | + rowKey: 'id', | ||
69 | + actionColumn: { | ||
70 | + width: 230, | ||
71 | + title: t('common.actionText'), | ||
72 | + slots: { customRender: 'action' }, | ||
73 | + fixed: 'right', | ||
74 | + }, | ||
75 | + rowSelection: { | ||
76 | + type: 'checkbox', | ||
77 | + getCheckboxProps: (record: any) => {}, | ||
78 | + }, | ||
79 | +}); | ||
80 | + | ||
81 | +const handleReload = () => { | ||
82 | + setSelectedRowKeys([]); | ||
83 | + reload(); | ||
84 | +}; | ||
85 | + | ||
86 | +// 新增 | ||
87 | +const handleCreate = () => { | ||
88 | + openModal(true, { | ||
89 | + isUpdate: false, | ||
90 | + }); | ||
91 | +}; | ||
92 | + | ||
93 | +// 编辑 | ||
94 | +const handleEdit = (record?: any) => { | ||
95 | + openModal(true, { | ||
96 | + isUpdate: true, | ||
97 | + record, | ||
98 | + }); | ||
99 | +}; | ||
100 | + | ||
101 | +const handleDelete = async (record?: any) => { | ||
102 | + let ids: string[] = []; | ||
103 | + if (record) { | ||
104 | + ids = [record.id]; | ||
105 | + } else { | ||
106 | + ids = getSelectRowKeys(); | ||
107 | + } | ||
108 | + try { | ||
109 | + setLoading(true); | ||
110 | + await deleteSupplier({ ids }); | ||
111 | + createMessage.success(t('common.deleteSuccessText')); | ||
112 | + handleReload(); | ||
113 | + } catch (error) { | ||
114 | + throw error; | ||
115 | + } finally { | ||
116 | + setLoading(false); | ||
117 | + } | ||
118 | +}; | ||
119 | + | ||
120 | +</script> | ||
121 | + |