放舱通道配置
parent
10f92a1a8b
commit
40c0fc7746
@ -1,227 +1,235 @@
|
|||||||
import type { NamePath, RuleObject } from 'ant-design-vue/lib/form/interface';
|
import type { NamePath, RuleObject } from 'ant-design-vue/lib/form/interface'
|
||||||
import type { VNode } from 'vue';
|
import type { VNode } from 'vue'
|
||||||
import type { ButtonProps as AntdButtonProps } from '/@/components/Button';
|
import type { ButtonProps as AntdButtonProps } from '/@/components/Button'
|
||||||
import type { FormItem } from './formItem';
|
import type { FormItem } from './formItem'
|
||||||
import type { ColEx, ComponentType } from './index';
|
import type { ColEx, ComponentType } from './index'
|
||||||
import type { TableActionType } from '/@/components/Table/src/types/table';
|
import type { TableActionType } from '/@/components/Table/src/types/table'
|
||||||
import type { CSSProperties } from 'vue';
|
import type { CSSProperties } from 'vue'
|
||||||
import type { RowProps } from 'ant-design-vue/lib/grid/Row';
|
import type { RowProps } from 'ant-design-vue/lib/grid/Row'
|
||||||
|
|
||||||
export type FieldMapToTime = [string, [string, string], (string | [string, string])?][];
|
export type FieldMapToTime = [string, [string, string], (string | [string, string])?][]
|
||||||
|
|
||||||
export type Rule = RuleObject & {
|
export type Rule = RuleObject & {
|
||||||
trigger?: 'blur' | 'change' | ['change', 'blur'];
|
trigger?: 'blur' | 'change' | ['change', 'blur']
|
||||||
};
|
}
|
||||||
|
|
||||||
export interface RenderCallbackParams {
|
export interface RenderCallbackParams {
|
||||||
schema: FormSchema;
|
schema: FormSchema
|
||||||
values: Recordable;
|
values: Recordable
|
||||||
model: Recordable;
|
model: Recordable
|
||||||
field: string;
|
field: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ButtonProps extends AntdButtonProps {
|
export interface ButtonProps extends AntdButtonProps {
|
||||||
text?: string;
|
text?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormActionType {
|
export interface FormActionType {
|
||||||
submit: () => Promise<void>;
|
submit: () => Promise<void>
|
||||||
setFieldsValue: <T>(values: T) => Promise<void>;
|
setFieldsValue: <T>(values: T) => Promise<void>
|
||||||
resetFields: () => Promise<void>;
|
resetFields: () => Promise<void>
|
||||||
getFieldsValue: () => Recordable;
|
getFieldsValue: () => Recordable
|
||||||
clearValidate: (name?: string | string[]) => Promise<void>;
|
clearValidate: (name?: string | string[]) => Promise<void>
|
||||||
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
|
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>
|
||||||
resetSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
|
resetSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>
|
||||||
setProps: (formProps: Partial<FormProps>) => Promise<void>;
|
setProps: (formProps: Partial<FormProps>) => Promise<void>
|
||||||
removeSchemaByField: (field: string | string[]) => Promise<void>;
|
removeSchemaByField: (field: string | string[]) => Promise<void>
|
||||||
appendSchemaByField: (
|
appendSchemaByField: (
|
||||||
schema: FormSchema | FormSchema[],
|
schema: FormSchema | FormSchema[],
|
||||||
prefixField: string | undefined,
|
prefixField: string | undefined,
|
||||||
first?: boolean | undefined,
|
first?: boolean | undefined,
|
||||||
) => Promise<void>;
|
) => Promise<void>
|
||||||
validateFields: (nameList?: NamePath[]) => Promise<any>;
|
validateFields: (nameList?: NamePath[]) => Promise<any>
|
||||||
validate: (nameList?: NamePath[]) => Promise<any>;
|
validate: (nameList?: NamePath[]) => Promise<any>
|
||||||
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>;
|
getFieldList: (nameList?: NamePath[]) => Promise<any>
|
||||||
|
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>
|
||||||
|
linkageForm: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RegisterFn = (formInstance: FormActionType) => void;
|
export type RegisterFn = (formInstance: FormActionType) => void
|
||||||
|
|
||||||
export type UseFormReturnType = [RegisterFn, FormActionType];
|
export type UseFormReturnType = [RegisterFn, FormActionType]
|
||||||
|
|
||||||
export interface FormProps {
|
export interface FormProps {
|
||||||
name?: string;
|
name?: string
|
||||||
layout?: 'vertical' | 'inline' | 'horizontal';
|
layout?: 'vertical' | 'inline' | 'horizontal'
|
||||||
// Form value
|
// Form value
|
||||||
model?: Recordable;
|
model?: Recordable
|
||||||
// The width of all items in the entire form
|
// The width of all items in the entire form
|
||||||
labelWidth?: number | string;
|
labelWidth?: number | string
|
||||||
// alignment
|
// alignment
|
||||||
labelAlign?: 'left' | 'right';
|
labelAlign?: 'left' | 'right'
|
||||||
// Row configuration for the entire form
|
// Row configuration for the entire form
|
||||||
rowProps?: RowProps;
|
rowProps?: RowProps
|
||||||
// Submit form on reset
|
// Submit form on reset
|
||||||
submitOnReset?: boolean;
|
submitOnReset?: boolean
|
||||||
// Submit form on form changing
|
// Submit form on form changing
|
||||||
submitOnChange?: boolean;
|
submitOnChange?: boolean
|
||||||
// Col configuration for the entire form
|
// Col configuration for the entire form
|
||||||
labelCol?: Partial<ColEx>;
|
labelCol?: Partial<ColEx>
|
||||||
// Col configuration for the entire form
|
// Col configuration for the entire form
|
||||||
wrapperCol?: Partial<ColEx>;
|
wrapperCol?: Partial<ColEx>
|
||||||
|
|
||||||
// General row style
|
// General row style
|
||||||
baseRowStyle?: CSSProperties;
|
baseRowStyle?: CSSProperties
|
||||||
|
|
||||||
// General col configuration
|
// General col configuration
|
||||||
baseColProps?: Partial<ColEx>;
|
baseColProps?: Partial<ColEx>
|
||||||
|
|
||||||
// Form configuration rules
|
// Form configuration rules
|
||||||
schemas?: FormSchema[];
|
schemas?: FormSchema[]
|
||||||
// Function values used to merge into dynamic control form items
|
// Function values used to merge into dynamic control form items
|
||||||
mergeDynamicData?: Recordable;
|
mergeDynamicData?: Recordable
|
||||||
// Compact mode for search forms
|
// Compact mode for search forms
|
||||||
compact?: boolean;
|
compact?: boolean
|
||||||
// Blank line span
|
// Blank line span
|
||||||
emptySpan?: number | Partial<ColEx>;
|
emptySpan?: number | Partial<ColEx>
|
||||||
// Internal component size of the form
|
// Internal component size of the form
|
||||||
size?: 'default' | 'small' | 'large';
|
size?: 'default' | 'small' | 'large'
|
||||||
// Whether to disable
|
// Whether to disable
|
||||||
disabled?: boolean;
|
disabled?: boolean
|
||||||
// Time interval fields are mapped into multiple
|
// Time interval fields are mapped into multiple
|
||||||
fieldMapToTime?: FieldMapToTime;
|
fieldMapToTime?: FieldMapToTime
|
||||||
// Placeholder is set automatically
|
// Placeholder is set automatically
|
||||||
autoSetPlaceHolder?: boolean;
|
autoSetPlaceHolder?: boolean
|
||||||
// Auto submit on press enter on input
|
// Auto submit on press enter on input
|
||||||
autoSubmitOnEnter?: boolean;
|
autoSubmitOnEnter?: boolean
|
||||||
// Check whether the information is added to the label
|
// Check whether the information is added to the label
|
||||||
rulesMessageJoinLabel?: boolean;
|
rulesMessageJoinLabel?: boolean
|
||||||
// Whether to show collapse and expand buttons
|
// Whether to show collapse and expand buttons
|
||||||
showAdvancedButton?: boolean;
|
showAdvancedButton?: boolean
|
||||||
// Whether to focus on the first input box, only works when the first form item is input
|
// Whether to focus on the first input box, only works when the first form item is input
|
||||||
autoFocusFirstItem?: boolean;
|
autoFocusFirstItem?: boolean
|
||||||
// Automatically collapse over the specified number of rows
|
// Automatically collapse over the specified number of rows
|
||||||
autoAdvancedLine?: number;
|
autoAdvancedLine?: number
|
||||||
// Always show lines
|
// Always show lines
|
||||||
alwaysShowLines?: number;
|
alwaysShowLines?: number
|
||||||
// Whether to show the operation button
|
// Whether to show the operation button
|
||||||
showActionButtonGroup?: boolean;
|
showActionButtonGroup?: boolean
|
||||||
|
// 是否使用高级查询
|
||||||
|
useAdvancedSearch?: boolean
|
||||||
|
// 是否使用多单号查询
|
||||||
|
useNumbersSearch?: boolean
|
||||||
// Reset button configuration
|
// Reset button configuration
|
||||||
resetButtonOptions?: Partial<ButtonProps>;
|
resetButtonOptions?: Partial<ButtonProps>
|
||||||
|
|
||||||
// Confirm button configuration
|
// Confirm button configuration
|
||||||
submitButtonOptions?: Partial<ButtonProps>;
|
submitButtonOptions?: Partial<ButtonProps>
|
||||||
|
|
||||||
// Operation column configuration
|
// Operation column configuration
|
||||||
actionColOptions?: Partial<ColEx>;
|
actionColOptions?: Partial<ColEx>
|
||||||
|
|
||||||
// Show reset button
|
// Show reset button
|
||||||
showResetButton?: boolean;
|
showResetButton?: boolean
|
||||||
// Show confirmation button
|
// Show confirmation button
|
||||||
showSubmitButton?: boolean;
|
showSubmitButton?: boolean
|
||||||
|
|
||||||
resetFunc?: () => Promise<void>;
|
resetFunc?: () => Promise<void>
|
||||||
submitFunc?: () => Promise<void>;
|
submitFunc?: () => Promise<void>
|
||||||
transformDateFunc?: (date: any) => string;
|
transformDateFunc?: (date: any) => string
|
||||||
colon?: boolean;
|
colon?: boolean
|
||||||
}
|
}
|
||||||
export interface FormSchema {
|
export interface FormSchema {
|
||||||
// Field name
|
// Field name
|
||||||
field: string;
|
field: string
|
||||||
// Event name triggered by internal value change, default change
|
// Event name triggered by internal value change, default change
|
||||||
changeEvent?: string;
|
changeEvent?: string
|
||||||
// Variable name bound to v-model Default value
|
// Variable name bound to v-model Default value
|
||||||
valueField?: string;
|
valueField?: string
|
||||||
// Label name
|
// Label name
|
||||||
label: string | VNode;
|
label?: string | VNode
|
||||||
|
enLabel?: string | VNode
|
||||||
// Auxiliary text
|
// Auxiliary text
|
||||||
subLabel?: string;
|
subLabel?: string
|
||||||
// Help text on the right side of the text
|
// Help text on the right side of the text
|
||||||
helpMessage?:
|
helpMessage?:
|
||||||
| string
|
| string
|
||||||
| string[]
|
| string[]
|
||||||
| ((renderCallbackParams: RenderCallbackParams) => string | string[]);
|
| ((renderCallbackParams: RenderCallbackParams) => string | string[])
|
||||||
// BaseHelp component props
|
// BaseHelp component props
|
||||||
helpComponentProps?: Partial<HelpComponentProps>;
|
helpComponentProps?: Partial<HelpComponentProps>
|
||||||
// Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid
|
// Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid
|
||||||
labelWidth?: string | number;
|
labelWidth?: string | number
|
||||||
// Disable the adjustment of labelWidth with global settings of formModel, and manually set labelCol and wrapperCol by yourself
|
// Disable the adjustment of labelWidth with global settings of formModel, and manually set labelCol and wrapperCol by yourself
|
||||||
disabledLabelWidth?: boolean;
|
disabledLabelWidth?: boolean
|
||||||
// render component
|
// render component
|
||||||
component: ComponentType;
|
component: ComponentType
|
||||||
// Component parameters
|
// Component parameters
|
||||||
componentProps?:
|
componentProps?:
|
||||||
| ((opt: {
|
| ((opt: {
|
||||||
schema: FormSchema;
|
schema: FormSchema
|
||||||
tableAction: TableActionType;
|
tableAction: TableActionType
|
||||||
formActionType: FormActionType;
|
formActionType: FormActionType
|
||||||
formModel: Recordable;
|
formModel: Recordable
|
||||||
}) => Recordable)
|
}) => Recordable)
|
||||||
| object;
|
| object
|
||||||
// Required
|
// Required
|
||||||
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean)
|
||||||
|
|
||||||
suffix?: string | number | ((values: RenderCallbackParams) => string | number);
|
suffix?: string | number | ((values: RenderCallbackParams) => string | number)
|
||||||
|
|
||||||
// Validation rules
|
// Validation rules
|
||||||
rules?: Rule[];
|
rules?: Rule[]
|
||||||
// Check whether the information is added to the label
|
// Check whether the information is added to the label
|
||||||
rulesMessageJoinLabel?: boolean;
|
rulesMessageJoinLabel?: boolean
|
||||||
|
|
||||||
// Reference formModelItem
|
// Reference formModelItem
|
||||||
itemProps?: Partial<FormItem>;
|
itemProps?: Partial<FormItem>
|
||||||
|
|
||||||
// col configuration outside formModelItem
|
// col configuration outside formModelItem
|
||||||
colProps?: Partial<ColEx>;
|
colProps?: Partial<ColEx>
|
||||||
|
|
||||||
// 默认值
|
// 默认值
|
||||||
defaultValue?: any;
|
defaultValue?: any
|
||||||
|
|
||||||
// 是否自动处理与时间相关组件的默认值
|
// 是否自动处理与时间相关组件的默认值
|
||||||
isHandleDateDefaultValue?: boolean;
|
isHandleDateDefaultValue?: boolean
|
||||||
|
|
||||||
isAdvanced?: boolean;
|
isAdvanced?: boolean
|
||||||
|
|
||||||
// Matching details components
|
// Matching details components
|
||||||
span?: number;
|
span?: number
|
||||||
|
|
||||||
ifShow?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
ifShow?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean)
|
||||||
|
|
||||||
show?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
show?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean)
|
||||||
|
|
||||||
// Render the content in the form-item tag
|
// Render the content in the form-item tag
|
||||||
render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
|
render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string
|
||||||
|
|
||||||
// Rendering col content requires outer wrapper form-item
|
// Rendering col content requires outer wrapper form-item
|
||||||
renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string;
|
renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string
|
||||||
|
|
||||||
renderComponentContent?:
|
renderComponentContent?:
|
||||||
| ((renderCallbackParams: RenderCallbackParams) => any)
|
| ((renderCallbackParams: RenderCallbackParams) => any)
|
||||||
| VNode
|
| VNode
|
||||||
| VNode[]
|
| VNode[]
|
||||||
| string;
|
| string
|
||||||
|
|
||||||
// Custom slot, in from-item
|
// Custom slot, in from-item
|
||||||
slot?: string;
|
slot?: string
|
||||||
|
|
||||||
// Custom slot, similar to renderColContent
|
// Custom slot, similar to renderColContent
|
||||||
colSlot?: string;
|
colSlot?: string
|
||||||
|
// label上的插槽
|
||||||
|
labelSlot?: string
|
||||||
|
|
||||||
dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean);
|
dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean)
|
||||||
|
|
||||||
dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[];
|
dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[]
|
||||||
}
|
}
|
||||||
export interface HelpComponentProps {
|
export interface HelpComponentProps {
|
||||||
maxWidth: string;
|
maxWidth: string
|
||||||
// Whether to display the serial number
|
// Whether to display the serial number
|
||||||
showIndex: boolean;
|
showIndex: boolean
|
||||||
// Text list
|
// Text list
|
||||||
text: any;
|
text: any
|
||||||
// colour
|
// colour
|
||||||
color: string;
|
color: string
|
||||||
// font size
|
// font size
|
||||||
fontSize: string;
|
fontSize: string
|
||||||
icon: string;
|
icon: string
|
||||||
absolute: boolean;
|
absolute: boolean
|
||||||
// Positioning
|
// Positioning
|
||||||
position: any;
|
position: any
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
import { intersection } from 'lodash-es'
|
||||||
|
import { usePermissionStore } from '/@/store/modules/permission'
|
||||||
|
export function checkPermissions(key) {
|
||||||
|
const permissionStore = usePermissionStore()
|
||||||
|
const allCodeList = permissionStore.getPermCodeList as string[]
|
||||||
|
return !((intersection([key], allCodeList) as string[]).length > 0)
|
||||||
|
}
|
@ -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,40 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
import { request } from '/@/utils/request'
|
||||||
|
import { DataResult, PageRequest } from '/@/api/model/baseModel'
|
||||||
|
enum Api {
|
||||||
|
list = '/adminApi/ReleaseType/GetList',
|
||||||
|
editORinfo = '/adminApi/ReleaseType/Edit',
|
||||||
|
del = '/adminApi/ReleaseType/Delete',
|
||||||
|
}
|
||||||
|
// 列表 (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,
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
import { BasicColumn, FormSchema } from '/@/components/Table'
|
||||||
|
import { GetCarrierSelectList, GetClientPortSelectList } from '/@/api/common'
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '承运商',
|
||||||
|
dataIndex: 'carrier',
|
||||||
|
sorter: true,
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '起运港代码',
|
||||||
|
dataIndex: 'loadingPort',
|
||||||
|
sorter: true,
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '放舱方式名称',
|
||||||
|
dataIndex: 'releaseTypeName',
|
||||||
|
sorter: true,
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '承运商',
|
||||||
|
field: 'carrier',
|
||||||
|
labelSlot: 'carrierId',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
componentProps: ({ formModel }) => {
|
||||||
|
return {
|
||||||
|
api: GetCarrierSelectList,
|
||||||
|
labelField: 'pinYinCode',
|
||||||
|
showName: 'cnName',
|
||||||
|
valueField: 'code',
|
||||||
|
resultField: 'data',
|
||||||
|
immediate: false,
|
||||||
|
onChange: (e, obj) => {
|
||||||
|
console.log(obj)
|
||||||
|
|
||||||
|
if (e && obj) {
|
||||||
|
formModel.carrierId = obj.id
|
||||||
|
}
|
||||||
|
if (!e && !obj) {
|
||||||
|
formModel.carrierId = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '起运港',
|
||||||
|
field: 'loadingPort',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
componentProps: () => {
|
||||||
|
return {
|
||||||
|
api: GetClientPortSelectList,
|
||||||
|
resultField: 'data',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
labelField: 'portName',
|
||||||
|
showName: 'portName',
|
||||||
|
valueField: 'ediCode',
|
||||||
|
immediate: true,
|
||||||
|
filterOption: (input: string, option: any) => {
|
||||||
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'releaseType',
|
||||||
|
label: '放舱方式',
|
||||||
|
component: 'Select',
|
||||||
|
|
||||||
|
colProps: { span: 6 },
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '入货通知', value: 1 },
|
||||||
|
{ label: '转发BC', value: 2 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
defaultValue: '',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '承运商',
|
||||||
|
field: 'carrier',
|
||||||
|
labelSlot: 'carrierId',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
required: false,
|
||||||
|
dynamicDisabled: false,
|
||||||
|
colProps: { span: 20 },
|
||||||
|
componentProps: ({ formModel }) => {
|
||||||
|
return {
|
||||||
|
api: GetCarrierSelectList,
|
||||||
|
labelField: 'pinYinCode',
|
||||||
|
showName: 'cnName',
|
||||||
|
valueField: 'code',
|
||||||
|
resultField: 'data',
|
||||||
|
immediate: false,
|
||||||
|
filterOption: (input: string, option: any) => {
|
||||||
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||||
|
},
|
||||||
|
onChange: (e, obj) => {
|
||||||
|
console.log(obj)
|
||||||
|
|
||||||
|
if (e && obj) {
|
||||||
|
formModel.carrierId = obj.id
|
||||||
|
}
|
||||||
|
if (!e && !obj) {
|
||||||
|
formModel.carrierId = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '委托单位',
|
||||||
|
field: 'customerId',
|
||||||
|
component: 'Input',
|
||||||
|
defaultValue: null,
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '起运港',
|
||||||
|
field: 'loadingPort',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
required: true,
|
||||||
|
dynamicDisabled: false,
|
||||||
|
colProps: { span: 20 },
|
||||||
|
componentProps: () => {
|
||||||
|
return {
|
||||||
|
api: GetClientPortSelectList,
|
||||||
|
resultField: 'data',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
labelField: 'portName',
|
||||||
|
showName: 'portName',
|
||||||
|
valueField: 'ediCode',
|
||||||
|
immediate: true,
|
||||||
|
filterOption: (input: string, option: any) => {
|
||||||
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'releaseType',
|
||||||
|
label: '放舱方式',
|
||||||
|
component: 'Select',
|
||||||
|
required: true,
|
||||||
|
colProps: { span: 20 },
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '入货通知', value: 1 },
|
||||||
|
{ label: '转发BC', value: 2 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
@ -0,0 +1,150 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable class="ds-table" @register="registerTable" @row-dbClick="handleAudit">
|
||||||
|
<template #toolbar>
|
||||||
|
<a-button type="primary" @click="handleCreate"> 新增 </a-button>
|
||||||
|
<a-popconfirm
|
||||||
|
title="确定删除当前选中数据?"
|
||||||
|
ok-text="是"
|
||||||
|
cancel-text="否"
|
||||||
|
@confirm="handleDel"
|
||||||
|
>
|
||||||
|
<a-button type="primary" @click="handleCreate"> 删除 </a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
</template>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
icon: 'clarity:note-edit-line',
|
||||||
|
tooltip: '编辑',
|
||||||
|
onClick: handleAudit.bind(null, record),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</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 { BasicTable, useTable, TableAction, SorterResult } from '/@/components/Table'
|
||||||
|
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, getPaginationRef }] = useTable({
|
||||||
|
title: '放舱通道配置列表',
|
||||||
|
api: async (p) => {
|
||||||
|
const res: API.DataResult = await ApiList(p)
|
||||||
|
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.carrier) {
|
||||||
|
condition.push({
|
||||||
|
FieldName: 'carrier',
|
||||||
|
FieldValue: data.carrier,
|
||||||
|
ConditionalType: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!!data.loadingPort) {
|
||||||
|
condition.push({
|
||||||
|
FieldName: 'loadingPort',
|
||||||
|
FieldValue: data.loadingPort,
|
||||||
|
ConditionalType: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!!data.releaseType) {
|
||||||
|
condition.push({
|
||||||
|
FieldName: 'releaseType',
|
||||||
|
FieldValue: data.releaseType,
|
||||||
|
ConditionalType: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
postParam.queryCondition = JSON.stringify(condition)
|
||||||
|
// console.log(postParam);
|
||||||
|
return postParam
|
||||||
|
},
|
||||||
|
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) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function handleSuccess() {
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue