parent
1a968ebe48
commit
8655c2ed97
@ -0,0 +1,31 @@
|
|||||||
|
import { defHttp } from '@/utils/http/axios'
|
||||||
|
|
||||||
|
// 查询业务线/仓库列表
|
||||||
|
export function getBusinessWarehousePage(params) {
|
||||||
|
return defHttp.get({ url: '/xxjj/business-warehouse/page', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询业务线/仓库详情
|
||||||
|
export function getBusinessWarehouse(id: number) {
|
||||||
|
return defHttp.get({ url: '/xxjj/business-warehouse/get?id=' + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增业务线/仓库
|
||||||
|
export function createBusinessWarehouse(data) {
|
||||||
|
return defHttp.post({ url: '/xxjj/business-warehouse/create', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改业务线/仓库
|
||||||
|
export function updateBusinessWarehouse(data) {
|
||||||
|
return defHttp.put({ url: '/xxjj/business-warehouse/update', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除业务线/仓库
|
||||||
|
export function deleteBusinessWarehouse(id: number) {
|
||||||
|
return defHttp.delete({ url: '/xxjj/business-warehouse/delete?id=' + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出业务线/仓库 Excel
|
||||||
|
export function exportBusinessWarehouse(params) {
|
||||||
|
return defHttp.download({ url: '/xxjj/business-warehouse/export-excel', params }, '业务线/仓库.xls')
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? t('action.edit') : t('action.create')" @ok="handleSubmit">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, unref } from 'vue'
|
||||||
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
import { BasicForm, useForm } from '@/components/Form'
|
||||||
|
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||||
|
import { createFormSchema, updateFormSchema } from './businessWarehouse.data'
|
||||||
|
import { createBusinessWarehouse, getBusinessWarehouse, updateBusinessWarehouse } from '@/api/xxjj/businessWarehouse'
|
||||||
|
|
||||||
|
defineOptions({ name: 'BusinessWarehouseModal' })
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const { createMessage } = useMessage()
|
||||||
|
const emit = defineEmits(['success', 'register'])
|
||||||
|
const isUpdate = ref(true)
|
||||||
|
|
||||||
|
const [registerForm, { setFieldsValue, resetFields, resetSchema, validate }] = useForm({
|
||||||
|
labelWidth: 120,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
schemas: createFormSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
actionColOptions: { span: 23 }
|
||||||
|
})
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
resetFields()
|
||||||
|
setModalProps({ confirmLoading: false })
|
||||||
|
isUpdate.value = !!data?.isUpdate
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
resetSchema(updateFormSchema)
|
||||||
|
const res = await getBusinessWarehouse(data.record.id)
|
||||||
|
setFieldsValue({ ...res })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate()
|
||||||
|
setModalProps({ confirmLoading: true })
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await updateBusinessWarehouse(values)
|
||||||
|
} else {
|
||||||
|
await createBusinessWarehouse(values)
|
||||||
|
}
|
||||||
|
closeModal()
|
||||||
|
emit('success')
|
||||||
|
createMessage.success(t('common.saveSuccessText'))
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,92 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable">
|
||||||
|
<template #toolbar>
|
||||||
|
<a-button type="primary" v-auth="['xxjj:business-warehouse:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
|
||||||
|
{{ t('action.create') }}
|
||||||
|
</a-button>
|
||||||
|
<a-button type="warning" v-auth="['xxjj:business-warehouse:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
|
||||||
|
{{ t('action.export') }}
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'xxjj:business-warehouse:update', onClick: handleEdit.bind(null, record) },
|
||||||
|
{
|
||||||
|
icon: IconEnum.DELETE,
|
||||||
|
color: 'error',
|
||||||
|
label: t('action.delete'),
|
||||||
|
auth: 'xxjj:business-warehouse:delete',
|
||||||
|
popConfirm: {
|
||||||
|
title: t('common.delMessage'),
|
||||||
|
placement: 'left',
|
||||||
|
confirm: handleDelete.bind(null, record)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
<BusinessWarehouseModal @register="registerModal" @success="reload()" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
import { useModal } from '@/components/Modal'
|
||||||
|
import BusinessWarehouseModal from './BusinessWarehouseModal.vue'
|
||||||
|
import { IconEnum } from '@/enums/appEnum'
|
||||||
|
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||||
|
import { deleteBusinessWarehouse, exportBusinessWarehouse, getBusinessWarehousePage } from '@/api/xxjj/businessWarehouse'
|
||||||
|
import { columns, searchFormSchema } from './businessWarehouse.data'
|
||||||
|
|
||||||
|
defineOptions({ name: 'BusinessWarehouse' })
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const { createConfirm, createMessage } = useMessage()
|
||||||
|
const [registerModal, { openModal }] = useModal()
|
||||||
|
|
||||||
|
const [registerTable, { getForm, reload }] = useTable({
|
||||||
|
title: '业务线/仓库列表',
|
||||||
|
api: getBusinessWarehousePage,
|
||||||
|
columns,
|
||||||
|
formConfig: { labelWidth: 120, schemas: searchFormSchema },
|
||||||
|
useSearchForm: true,
|
||||||
|
showTableSetting: true,
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
title: t('common.action'),
|
||||||
|
dataIndex: 'action',
|
||||||
|
fixed: 'right'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleCreate() {
|
||||||
|
openModal(true, { isUpdate: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleExport() {
|
||||||
|
createConfirm({
|
||||||
|
title: t('common.exportTitle'),
|
||||||
|
iconType: 'warning',
|
||||||
|
content: t('common.exportMessage'),
|
||||||
|
async onOk() {
|
||||||
|
await exportBusinessWarehouse(getForm().getFieldsValue())
|
||||||
|
createMessage.success(t('common.exportSuccessText'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteBusinessWarehouse(record.id)
|
||||||
|
createMessage.success(t('common.delSuccessText'))
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in new issue