vbenbug
parent
6015da4997
commit
feb4fc4955
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* @Description: 包装映射api
|
||||
* @Author: lijj
|
||||
* @Date: 2024-04-25 15:48:33
|
||||
*/
|
||||
|
||||
import { request } from '/@/utils/request'
|
||||
import { DataResult, PageRequest } from '/@/api/model/baseModel'
|
||||
enum Api {
|
||||
list = '/mainApi/CodePackage/GetCodePackageList',
|
||||
edit = '/mainApi/CodePackage/EditCodePackage',
|
||||
info = '/mainApi/CodePackage/GetCodePackageInfo'
|
||||
}
|
||||
// 列表 (Auth)
|
||||
export function GetCodePackageList(data: PageRequest) {
|
||||
return request<DataResult>({
|
||||
url: Api.list,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// 编辑 (Auth)
|
||||
export function EditCodePackage(data: PageRequest) {
|
||||
return request<DataResult>({
|
||||
url: Api.edit,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
// 详情 (Auth)
|
||||
export function GetCodePackageInfo(query) {
|
||||
return request<DataResult>({
|
||||
url: Api.info,
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* @Description: 场站映射tsx
|
||||
* @Author: lijj
|
||||
* @Date: 2024-04-25 15:48:33
|
||||
*/
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table'
|
||||
import { GetCarrierlist } from '/@/views/operation/seaexport/api/BookingLedger'
|
||||
// 引入字典数据
|
||||
import { getDictOption } from '/@/utils/dictUtil'
|
||||
// 包装下拉数据
|
||||
import { GetPackageSelectList } from '/@/api/common'
|
||||
// 模块字典
|
||||
const modulesDict = await getDictOption('modules')
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '包装',
|
||||
dataIndex: 'packageName',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '模块',
|
||||
dataIndex: 'module',
|
||||
width: 200,
|
||||
customRender: ({ text }) => {
|
||||
const data = modulesDict.filter(item => {
|
||||
return item.value == text
|
||||
})
|
||||
if (data && data.length) {
|
||||
return data[0].label
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '船公司',
|
||||
dataIndex: 'carrierName',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: '映射名称',
|
||||
dataIndex: 'mapName',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '映射代码',
|
||||
dataIndex: 'mapCode',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'note',
|
||||
width: 200
|
||||
}
|
||||
]
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'code',
|
||||
label: '包装',
|
||||
colProps: { span: 6 },
|
||||
component: 'ApiSelect',
|
||||
componentProps: () => {
|
||||
return {
|
||||
api: GetPackageSelectList,
|
||||
labelField: 'ctnName',
|
||||
valueField: 'ediCode',
|
||||
resultField: 'data'
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
export const formSchema: FormSchema[] = [
|
||||
{
|
||||
label: '',
|
||||
field: 'id',
|
||||
component: 'Input',
|
||||
defaultValue: '',
|
||||
show: false
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
field: 'linkId',
|
||||
component: 'Input',
|
||||
defaultValue: '',
|
||||
show: false
|
||||
},
|
||||
{
|
||||
field: 'code',
|
||||
label: '包装',
|
||||
component: 'ApiSelect',
|
||||
colProps: { span: 12 },
|
||||
componentProps: ({ formModel, formActionType }) => {
|
||||
return {
|
||||
api: GetPackageSelectList,
|
||||
labelField: 'packageName',
|
||||
valueField: 'ediCode',
|
||||
showSearch: true,
|
||||
resultField: 'data',
|
||||
onChange: (v, obj) => {
|
||||
if (obj) {
|
||||
formModel['packageName'] = obj.packageName
|
||||
formModel['linkId'] = obj.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'module',
|
||||
label: '模块',
|
||||
required: true,
|
||||
component: 'Select',
|
||||
colProps: { span: 12 },
|
||||
componentProps: () => {
|
||||
return {
|
||||
options: modulesDict,
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
filterOption: (input: string, option: any) => {
|
||||
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'carrierId',
|
||||
label: '船公司',
|
||||
component: 'ApiSelect',
|
||||
colProps: { span: 12 },
|
||||
componentProps: ({ formActionType, formModel }) => {
|
||||
return {
|
||||
api: GetCarrierlist,
|
||||
labelField: 'shortName',
|
||||
valueField: 'id',
|
||||
resultField: 'data',
|
||||
onChange: (v, obj) => {
|
||||
// formActionType.validateFields(['code'])
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'mapName',
|
||||
label: '映射名称',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
colProps: { span: 12 }
|
||||
},
|
||||
{
|
||||
field: 'mapCode',
|
||||
label: '映射代码',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
colProps: { span: 12 }
|
||||
},
|
||||
{
|
||||
field: 'note',
|
||||
label: '备注',
|
||||
component: 'InputTextArea',
|
||||
colProps: { span: 24 }
|
||||
}
|
||||
]
|
@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
:use-wrapper="true"
|
||||
:title="getTitle"
|
||||
:form-schema="formSchema"
|
||||
width="50%"
|
||||
@register="registerModal"
|
||||
@ok="handleSave"
|
||||
>
|
||||
<!-- 包装表单 -->
|
||||
<BasicForm @register="registerForm" />
|
||||
<!--右下角按钮-->
|
||||
<template #footer>
|
||||
<a-button
|
||||
pre-icon="ant-design:close-outlined"
|
||||
type="warning"
|
||||
:loading="loading"
|
||||
ghost
|
||||
style="margin-right: 0.8rem"
|
||||
@click="closeModal"
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
<a-button
|
||||
type="success"
|
||||
:loading="loading"
|
||||
pre-icon="ant-design:check-outlined"
|
||||
style="margin-right: 0.8rem"
|
||||
@click="handleSave(false)"
|
||||
>
|
||||
仅保存
|
||||
</a-button>
|
||||
<a-button
|
||||
pre-icon="ant-design:check-circle-outlined"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="handleSave(true)"
|
||||
>
|
||||
保存并关闭
|
||||
</a-button>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref } from 'vue'
|
||||
// 弹窗组件
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal'
|
||||
import { BasicForm, useForm } from '/@/components/Form/index'
|
||||
// 表单字段数据
|
||||
import { formSchema } from '../columns'
|
||||
// 相关接口
|
||||
import { EditCodePackage, GetCodePackageInfo } from '../api'
|
||||
// 提示消息混入
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
// 声明Emits
|
||||
const emit = defineEmits(['success', 'register'])
|
||||
const isUpdate = ref(true)
|
||||
// 按钮loading
|
||||
const loading = ref(false)
|
||||
const rowId = ref('')
|
||||
const { createMessage } = useMessage()
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] =
|
||||
useForm({
|
||||
labelWidth: 100,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
})
|
||||
|
||||
const [registerModal, { setModalProps, closeModal, updateFormField }] = useModalInner(async (data) => {
|
||||
resetFields()
|
||||
setModalProps({ confirmLoading: false, loading: true })
|
||||
isUpdate.value = !!data?.isUpdate
|
||||
if (unref(isUpdate)) {
|
||||
setModalProps({ confirmLoading: true });
|
||||
updateFormField(updateSchema)
|
||||
rowId.value = data.record.id
|
||||
const res: API.DataResult = await GetCodePackageInfo({ id: unref(rowId) })
|
||||
if (res.succeeded) {
|
||||
setFieldsValue({
|
||||
...res.data,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
setFieldsValue({ permissionIdentity: unref(2) })
|
||||
}
|
||||
setModalProps({ loading: false })
|
||||
})
|
||||
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑'))
|
||||
|
||||
async function handleSave(exit) {
|
||||
try {
|
||||
const values = await validate()
|
||||
loading.value = true
|
||||
setModalProps({ confirmLoading: true, loading: true })
|
||||
const res: API.DataResult = await EditCodePackage(values)
|
||||
loading.value = false
|
||||
if (res.succeeded) {
|
||||
createMessage.success(res.message)
|
||||
emit('success')
|
||||
} else {
|
||||
createMessage.error(res.message)
|
||||
}
|
||||
exit && closeModal()
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false, loading: false })
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> 新建 </a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'userName'">
|
||||
<span style="color: #0d84ff" @click="handleEdit(record)">{{ record.userName }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
icon: 'clarity:note-edit-line',
|
||||
tooltip: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
}
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<Modal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { onMounted } from 'vue'
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'
|
||||
import { GetCodePackageList } from './api'
|
||||
import { useModal } from '/@/components/Modal'
|
||||
import Modal from './components/Modal.vue'
|
||||
import { columns, searchFormSchema } from './columns'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
const { notification } = useMessage()
|
||||
const [registerModal, { openModal }] = useModal()
|
||||
const [registerTable, { reload, getForm, getPaginationRef }] = useTable({
|
||||
title: '包装映射信息表',
|
||||
// api: getSysDictTypeList,
|
||||
api: async (p) => {
|
||||
const res: API.DataResult = await GetCodePackageList(p)
|
||||
console.log(res)
|
||||
// console.log(items);
|
||||
return new Promise((resolve) => {
|
||||
resolve({ data: [...res.data], total: res.count })
|
||||
})
|
||||
},
|
||||
beforeFetch: () => {
|
||||
var currentPageInfo: any = getPaginationRef()
|
||||
var data = getForm().getFieldsValue()
|
||||
const postParam: API.PageRequest = {
|
||||
queryCondition: '',
|
||||
pageCondition: {
|
||||
pageIndex: currentPageInfo.current,
|
||||
pageSize: currentPageInfo.pageSize,
|
||||
sortConditions: [],
|
||||
},
|
||||
}
|
||||
let condition: API.ConditionItem[] = []
|
||||
if (!!data.code) {
|
||||
condition.push({
|
||||
FieldName: 'code',
|
||||
FieldValue: data.code,
|
||||
ConditionalType: 1,
|
||||
})
|
||||
}
|
||||
postParam.queryCondition = JSON.stringify(condition)
|
||||
return postParam
|
||||
},
|
||||
columns,
|
||||
formConfig: {
|
||||
labelWidth: 120,
|
||||
schemas: searchFormSchema,
|
||||
},
|
||||
isTreeTable: false,
|
||||
pagination: true,
|
||||
striped: true,
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
bordered: true,
|
||||
showIndexColumn: true,
|
||||
canResize: false,
|
||||
actionColumn: {
|
||||
width: 80,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
fixed: 'right',
|
||||
},
|
||||
})
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isParent: false,
|
||||
isUpdate: false,
|
||||
})
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
})
|
||||
}
|
||||
// 删除
|
||||
// async function handleDelete(record: Recordable) {
|
||||
// console.log(record)
|
||||
// const res: API.DataResult = await BatchDelMappingCtn({
|
||||
// id: '',
|
||||
// ids: [record.id],
|
||||
// })
|
||||
// if (res.succeeded) {
|
||||
// notification.success({ message: res.message, duration: 3 })
|
||||
// reload()
|
||||
// } else {
|
||||
// notification.error({ message: res.message, duration: 3 })
|
||||
// }
|
||||
// }
|
||||
onMounted(() => {
|
||||
//初始化字典选项
|
||||
})
|
||||
function handleSuccess() {
|
||||
reload()
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue