放舱通道配置

szh-new
张同海 3 months ago
parent 182dd3be08
commit 39d905e84e

@ -0,0 +1,123 @@
<template>
<BasicModal
v-bind="$attrs"
:use-wrapper="true"
:title="getTitle"
width="30%"
@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 { ApiEdit, ApiInfo } from './api'
import { useMessage } from '/@/hooks/web/useMessage'
// Emits
const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true)
const loading = ref(false)
const rowId = ref('')
const { createMessage } = useMessage()
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields()
setModalProps({ confirmLoading: false, loading: true })
isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) {
// setModalProps({ confirmLoading: true });
rowId.value = data.record.id
const res: API.DataResult = await ApiInfo({ id: unref(rowId) })
if (res.succeeded) {
setFieldsValue({
...res.data,
})
// console.log('Form', getFieldsValue());
// setFieldsValue({ trainId: unref(res.data.trainId) });
}
// setModalProps({ confirmLoading: false });
} else {
setFieldsValue({ permissionIdentity: unref(2) })
}
setModalProps({ loading: false })
})
const getTitle = computed(() => (!unref(isUpdate) ? '新增放舱通道配置' : '编辑放舱通道配置'))
async function handleSave(exit) {
try {
const values = await validate()
setModalProps({ confirmLoading: true, loading: true })
// TODO custom api
console.log(values)
// loading.value = true;
const res: API.DataResult = await ApiEdit(values)
console.log(res)
if (res.succeeded) {
createMessage.success(res.message)
emit('success')
//
if (!exit) {
if (unref(isUpdate)) {
await refresh()
} else {
rowId.value = res.data
isUpdate.value = true
await refresh()
}
}
} else {
createMessage.error(res.message)
}
exit && closeModal()
} finally {
// loading.value = false;
setModalProps({ confirmLoading: false, loading: false })
}
}
async function refresh() {
const res: API.DataResult = await ApiInfo({ id: unref(rowId) })
if (res.succeeded) {
await setFieldsValue({
...res.data,
})
}
}
</script>

@ -0,0 +1,68 @@
// @ts-ignore
import { request } from '/@/utils/request'
import { DataResult, PageRequest } from '/@/api/model/baseModel'
enum Api {
list = '/mainApi/ReleaseType/GetList',
editORinfo = '/mainApi/ReleaseType/Edit',
// = '/mainApi/ReleaseType/Edit',
del = '/mainApi/ReleaseType/Delete',
// BasicsList = '/mainApi/CodeCtn/GetBasicsCodeCtnList',
// ExistList = '/mainApi/CodeCtn/GetExistCodeCtnList',
// Import = '/mainApi/CodeCtn/ImportCodeCtn',
}
// 列表 (Auth)
export function ApiList(data: PageRequest) {
return request<DataResult>({
url: Api.list,
method: 'post',
data,
})
}
// 编辑 (Auth)
export function ApiEdit(data: PageRequest) {
return request<DataResult>({
url: Api.editORinfo,
method: 'post',
data,
})
}
// 详情 (Auth)
export function ApiInfo(query) {
return request<DataResult>({
url: Api.editORinfo,
method: 'get',
params: query,
})
}
// 批量删除 (Auth)
export function ApiDel(data: PageRequest) {
return request<DataResult>({
url: Api.del,
method: 'post',
data,
})
}
// // 获取商品类型列表-基础库 (Auth)
// export function ApiBasicsList(data: PageRequest) {
// return request<DataResult>({
// url: Api.BasicsList,
// method: 'post',
// data,
// })
// }
// // 获取当前租户已有的商品类型 (Auth)
// export function ApiExistList() {
// return request<DataResult>({
// url: Api.ExistList,
// method: 'get',
// })
// }
// // 导入商品类型列表-基础库 (Auth)
// export function ApiImport(data: PageRequest) {
// return request<DataResult>({
// url: Api.Import,
// method: 'post',
// data,
// })
// }

@ -0,0 +1,218 @@
import { BasicColumn, FormSchema } from '/@/components/Table'
import { Tag } from 'ant-design-vue'
import { GetClientListByCode, GetClientPortSelectList } from '/@/api/common'
export const columns: BasicColumn[] = [
{
title: '承运商',
dataIndex: 'carrier',
sorter: true,
width: 150,
},
{
title: '起运港代码',
dataIndex: 'loadingPort',
sorter: true,
width: 200,
},
{
title: '委托单位',
dataIndex: 'customerName',
sorter: true,
width: 200,
},
{
title: '放舱方式名称',
dataIndex: 'releaseTypeName',
sorter: true,
width: 200,
},
]
export const searchFormSchema: FormSchema[] = [
{
field: 'carrier',
label: '承运商',
component: 'ApiSelect',
colProps: { span: 4 },
componentProps: () => {
return {
allowClear: true,
showSearch: true,
api: GetClientListByCode,
params: { code: 'carrier' },
labelField: 'pinYinCode',
showName: 'pinYinCode',
valueField: 'codeName',
resultField: 'data',
immediate: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
}
},
},
{
field: 'customerId',
label: '委托单位',
component: 'ApiSelect',
colProps: { span: 4 },
componentProps: () => {
return {
allowClear: true,
showSearch: true,
api: GetClientListByCode,
params: { code: 'controller' },
labelField: 'pinYinCode',
valueField: 'id',
showName: 'shortName',
resultField: 'data',
immediate: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
}
},
},
{
label: '起运港',
field: 'loadingPort',
component: 'ApiSelect',
colProps: { span: 4 },
componentProps: () => {
return {
api: GetClientPortSelectList,
resultField: 'data',
allowClear: true,
showSearch: true,
labelField: 'pinYinCode',
showName: 'pinYinCode',
valueField: 'ediCode',
immediate: true,
}
},
},
{
field: 'releaseType',
label: '放舱方式',
component: 'Select',
colProps: { span: 4 },
componentProps: {
options: [
{ label: '入货通知', value: 1 },
{ label: '转发BC', value: 2 },
],
},
},
]
export const formSchema: FormSchema[] = [
{
label: '',
field: 'id',
component: 'Input',
defaultValue: '',
show: false,
},
{
field: 'carrier',
label: '承运商',
component: 'ApiSelect',
required: false,
dynamicDisabled: false,
colProps: { span: 20 },
componentProps: () => {
return {
allowClear: true,
showSearch: true,
api: GetClientListByCode,
params: { code: 'carrier' },
labelField: 'pinYinCode',
showName: 'pinYinCode',
valueField: 'codeName',
resultField: 'data',
immediate: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
}
},
},
{
label: '委托单位Name',
field: 'customerName',
component: 'Input',
defaultValue: '',
show: false,
},
{
field: 'customerId',
label: '委托单位',
component: 'ApiSelect',
required: true,
dynamicDisabled: false,
colProps: { span: 20 },
componentProps: ({ formModel }) => {
return {
allowClear: true,
showSearch: true,
api: GetClientListByCode,
params: { code: 'controller' },
labelField: 'pinYinCode',
valueField: 'id',
showName: 'shortName',
resultField: 'data',
immediate: true,
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
onChange: (e, obj) => {
console.log(e, obj)
if (e && obj) {
formModel.customerId = obj.value
formModel.customerName = obj.label
}
if (!e && !obj) {
formModel.customerId = ''
formModel.customerName = ''
}
},
}
},
},
{
label: '起运港',
field: 'loadingPort',
component: 'ApiSelect',
required: true,
dynamicDisabled: false,
colProps: { span: 20 },
componentProps: () => {
return {
api: GetClientPortSelectList,
resultField: 'data',
allowClear: true,
showSearch: true,
labelField: 'pinYinCode',
showName: 'pinYinCode',
valueField: 'ediCode',
immediate: true,
}
},
},
{
field: 'releaseType',
label: '放舱方式',
component: 'Select',
required: true,
colProps: { span: 20 },
componentProps: {
options: [
{ label: '入货通知', value: 1 },
{ label: '转发BC', value: 2 },
],
},
},
]

@ -0,0 +1,127 @@
<template>
<div>
<BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleAudit">
<template #tableTitle>
<a-button type="link" @click="handleCreate" :disabled="checkPermissions('op:ctn:add')">
<span class="iconfont icon-new_document"></span>
添加
</a-button>
<a-popconfirm
title="确定删除当前选中数据?"
ok-text="是"
cancel-text="否"
@confirm="handleDel"
>
<a-button type="link" :disabled="checkPermissions('op:ctn:del')">
<span class="iconfont icon-shanchu21"></span>
删除
</a-button>
</a-popconfirm>
<Divider type="vertical" />
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
tooltip: '编辑',
onClick: handleAudit.bind(null, record),
disabled: checkPermissions('op:ctn:edit'),
},
]"
/>
</template>
</template>
</BasicTable>
<TenantAuditStepModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { Divider } from 'ant-design-vue'
import { checkPermissions } from '/@/hooks/Permissions/index'
import { BasicTable, useTable, TableAction, SorterResult } from '/@/components/Table'
import { formatParams } from '/@/hooks/web/common'
import { ApiList, ApiDel } from './api'
import { useModal } from '/@/components/Modal'
import TenantAuditStepModal from './TenantAuditStepModal.vue'
import { columns, searchFormSchema } from './columns'
import { useMessage } from '/@/hooks/web/useMessage'
const { notification } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { reload, getForm, getSelectRows }] = useTable({
title: '放舱通道配置列表',
api: async (p) => {
const res: API.DataResult = await ApiList(p)
return new Promise((resolve) => {
resolve({ data: [...res.data], total: res.count })
})
},
beforeFetch: (p) => {
return formatParams(p)
},
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
},
isTreeTable: false,
pagination: true,
striped: true,
useSearchForm: true,
showTableSetting: true,
bordered: true,
showIndexColumn: true,
indexColumnProps: {
width: 60,
},
canResize: true,
resizeHeightOffset: 35,
immediate: true,
actionColumn: {
width: 80,
title: '操作',
dataIndex: 'action',
fixed: 'right',
},
})
function handleDel() {
const select = getSelectRows()
let ApiData: any = {
ids: [],
}
if (select.length === 0) {
notification.warning({ message: '请至少选择一条数据', duration: 3 })
return false
} else {
ApiData.ids = select.map((item) => {
return item.id
})
}
ApiDel(ApiData).then((res) => {
console.log(res)
notification.success({ message: res.message, duration: 3 })
reload()
})
}
function handleCreate() {
openModal(true, {
isParent: false,
isUpdate: false,
})
}
function handleAudit(record: Recordable) {
if (!checkPermissions('op:ctn:edit')) {
openModal(true, {
record,
isUpdate: true,
})
}
}
function handleSuccess() {
reload()
}
</script>
Loading…
Cancel
Save