From 1dc93390768f8372699603b89d13c74a87d8b055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8C=E6=B5=B7?= <14166000+zhangtonghai@user.noreply.gitee.com> Date: Wed, 28 Aug 2024 17:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=B1=E7=AE=A1=20=E8=B0=83=E6=95=B4=20=20fo?= =?UTF-8?q?rmatParams=20hooks=20=E6=B7=BB=E5=8A=A0=20=E7=B2=BE=E5=87=86?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/web/common.ts | 67 +++---- .../BaseInfo/TenantAuditStepModal.vue | 10 +- .../ContainerManagement/BaseInfo/index.vue | 8 +- .../BuyCtn/TenantAuditStepModal.vue | 166 ------------------ .../ContainerManagement/BuyCtn/index.vue | 3 +- .../ContainerManagement/CtnScrap/columns.tsx | 3 + .../ContainerManagement/CtnScrap/index.vue | 2 +- .../CurrentState/columns.tsx | 1 - .../CurrentState/index.vue | 33 +--- .../ContainerManagement/CustFeeDui/index.vue | 2 +- .../ContainerManagement/RentIn/index.vue | 2 +- .../ContainerManagement/RentOneWay/index.vue | 2 +- .../ContainerManagement/RentOut/index.vue | 2 +- .../ContainerManagement/SellCtn/index.vue | 2 +- .../ContainerManagement/StateChange/index.vue | 2 +- .../ContainerManagement/dsxxcl/index.vue | 2 +- 16 files changed, 52 insertions(+), 255 deletions(-) diff --git a/src/hooks/web/common.ts b/src/hooks/web/common.ts index df76a6f9..e2c4d26b 100644 --- a/src/hooks/web/common.ts +++ b/src/hooks/web/common.ts @@ -1,4 +1,4 @@ -import { router } from "/@/router" +import { router } from '/@/router' import { useMultipleTabStore } from '/@/store/modules/multipleTab' import { useMessage } from '/@/hooks/web/useMessage' // 获取表单更改过的字段接口 @@ -20,7 +20,7 @@ export function formatTableData(v) { /* 关闭当前标签页 (默认关闭当前标签页面返回上一级路由) * topath: 指定跳转的path -*/ + */ export function closePage(topath) { const tabStore = useMultipleTabStore() tabStore.closeTab(router.currentRoute._value, router) @@ -42,19 +42,19 @@ export function closePage(topath) { /* 根据接口和过滤条件导出excel(目前支持单表头表格导出) * api: 接口,params: 过滤条件,columes: 表格列,name: excel名称 -*/ + */ export function exportExcel(api, params = {}, columns = [], name = '未命名') { if (!api) return createMessage.warning('缺少api') params['pageCondition']['isExport'] = true // 过滤出需要显示的列 - const cols = columns.filter(item => { + const cols = columns.filter((item) => { return !item.defaultHidden || item.visible }) - api(params).then(res => { + api(params).then((res) => { const { data } = res - const fileData = data.map(row => { + const fileData = data.map((row) => { const obj = {} - cols.forEach(item => { + cols.forEach((item) => { for (var key in row) { if (item.dataIndex === key) { obj[item.title] = row[key] @@ -77,15 +77,15 @@ function s2ab(s) { /* 根据数据直接导出excel(目前支持单表头表格导出) * data: 表格数据,columes: 表格列,name: excel名称 -*/ + */ export function exportExcelByData(data = [], columns = [], name = '未命名') { // 过滤出需要显示的列 - const cols = columns.filter(item => { + const cols = columns.filter((item) => { return !item.defaultHidden || item.visible }) - const fileData = data.map(row => { + const fileData = data.map((row) => { const obj = {} - cols.forEach(item => { + cols.forEach((item) => { for (var key in row) { if (item.dataIndex === key) { obj[item.title] = row[key] @@ -124,7 +124,7 @@ function toBlob(fileData, name) { // 更新表单数据 export function updateFormItem(updateSchema, formNo) { - getFormSetInfoByModule({ permissionId: permissionsInfo().permissionId, formNo }).then(res => { + getFormSetInfoByModule({ permissionId: permissionsInfo().permissionId, formNo }).then((res) => { if (res?.data?.content) { const content = JSON.parse(res.data.content) console.log(content) @@ -134,14 +134,14 @@ export function updateFormItem(updateSchema, formNo) { } // 返回表格查询的参数 multipleList(需要多选查询的字段名数组) -export function formatParams(params = {}) { +export function formatParams(params = {}, equal:any = []) { const postData = { queryCondition: '', pageCondition: { pageIndex: params?.page, pageSize: params?.pageSize, - sortConditions: [] - } + sortConditions: [], + }, } const conditions = [] as any for (let key in params) { @@ -157,25 +157,25 @@ export function formatParams(params = {}) { // 判定为日期 if (isDate != 'Invalid Date' && isDate.getFullYear() > 1000) { //替换时分秒 查询用 - params[key][0] = params[key][0].substring(0, 11) + "00:00:00"; - params[key][1] = params[key][1].substring(0, 11) + "23:59:59"; + params[key][0] = params[key][0].substring(0, 11) + '00:00:00' + params[key][1] = params[key][1].substring(0, 11) + '23:59:59' conditions.push({ FieldName: key, FieldValue: params[key][0], - ConditionalType: 3 + ConditionalType: 3, }) conditions.push({ FieldName: key, FieldValue: params[key][1], - ConditionalType: 5 + ConditionalType: 5, }) } else { // 判定为筛选 - params[key].forEach(item => { + params[key].forEach((item) => { conditions.push({ FieldName: key, FieldValue: item, - ConditionalType: 1 + ConditionalType: 1, }) }) } @@ -184,26 +184,31 @@ export function formatParams(params = {}) { const orKeys = key.split(':') const ConditionalList = { ConditionalList: [] } if (params[key]) { - orKeys.forEach(item => { + orKeys.forEach((item) => { let obj = { Key: 1, Value: { FieldName: item, FieldValue: params[key], - ConditionalType: 1 - } + ConditionalType: 1, + }, } ConditionalList.ConditionalList.push(obj) }) conditions.push(ConditionalList) } } else { - // 其他普通查询 + let isEqual = false + + if (equal.length) { + isEqual = equal.includes(key) + } + // 其他普通查询(模糊/等于) 1-模糊 0-等于 if (params[key] || params[key] === 0) { conditions.push({ FieldName: key, FieldValue: params[key], - ConditionalType: 1 + ConditionalType: !isEqual ? 1 : 0, }) } } @@ -212,10 +217,12 @@ export function formatParams(params = {}) { } // 排序 if (params?.field) { - postData.pageCondition.sortConditions = [{ - sortField: params.field, - listSortDirection: params.order == "ascend" ? 0 : 1 - }] + postData.pageCondition.sortConditions = [ + { + sortField: params.field, + listSortDirection: params.order == 'ascend' ? 0 : 1, + }, + ] } else { postData.pageCondition.sortConditions = [] } diff --git a/src/views/ContainerManagement/BaseInfo/TenantAuditStepModal.vue b/src/views/ContainerManagement/BaseInfo/TenantAuditStepModal.vue index 881e2c96..70d89d07 100644 --- a/src/views/ContainerManagement/BaseInfo/TenantAuditStepModal.vue +++ b/src/views/ContainerManagement/BaseInfo/TenantAuditStepModal.vue @@ -62,17 +62,13 @@ 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) }) } @@ -83,11 +79,8 @@ 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') @@ -107,7 +100,6 @@ exit && closeModal() } finally { - // loading.value = false; setModalProps({ confirmLoading: false, loading: false }) } } diff --git a/src/views/ContainerManagement/BaseInfo/index.vue b/src/views/ContainerManagement/BaseInfo/index.vue index b930b855..477f685b 100644 --- a/src/views/ContainerManagement/BaseInfo/index.vue +++ b/src/views/ContainerManagement/BaseInfo/index.vue @@ -33,7 +33,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['ctnCode']) }, columns, formConfig: { @@ -53,12 +53,6 @@ canResize: true, resizeHeightOffset: 35, immediate: true, - // actionColumn: { - // width: 80, - // title: '操作', - // dataIndex: 'action', - // fixed: 'right', - // }, }) function handleCreate() { openModal(true, { diff --git a/src/views/ContainerManagement/BuyCtn/TenantAuditStepModal.vue b/src/views/ContainerManagement/BuyCtn/TenantAuditStepModal.vue index a38cca53..c1f9bcd5 100644 --- a/src/views/ContainerManagement/BuyCtn/TenantAuditStepModal.vue +++ b/src/views/ContainerManagement/BuyCtn/TenantAuditStepModal.vue @@ -266,17 +266,9 @@ queryCondition: `[{ FieldName: 'Pid', FieldValue: '${rowId.value}', ConditionalType: 1 }]`, pageCondition: { pageIndex: 1, pageSize: 999, sortConditions: [] }, }).then((res) => { - // console.log(res) - - // list.value.splice(0) - // res.data.forEach((item) => { - // list.value.push(item) - // }) - // ------------------ list.value.splice(0) let Arr = ['pickupDate', 'dropoffDate', 'feeStartDate', 'bsdate'] res.data.forEach((item) => { - console.log(item) Arr.forEach((e) => { if (item[e]) { item[e] = item[e].split(' ')[0] @@ -369,9 +361,7 @@ }) }) if (values.bsdate) { - console.log(values.bsdate) values.bsdate = moment(values.bsdate).format('YYYY-MM-DD 00:00:00') - console.log(values.bsdate) } if (values.accdate) { values.accdate = moment(values.bsdate).format('YYYY-MM') @@ -578,8 +568,6 @@ : await getDictOption('CM_CtnFlowState') if (!CtnFlowStateDict.value.length) CtnFlowStateDict.value = res const dict = res.map((res) => { - console.log(res) - return res.label }) process(dict) @@ -641,17 +629,6 @@ ] const settings = { height: 260, - // height: () => { - // // 表头高度 28 - // let RData = 260 - // if (list.value.length) { - // RData = 28 + list.value.length * 26 - // } - // console.log(RData) - - // // list.value - // return RData - // }, autoWrapRow: true, autoWrapCol: true, // 每行的高度 @@ -754,140 +731,6 @@ }) } } - //--------------------------------------- tab1 View --------------------------------------- - // const [ - // registerSearchBoxForm, - // { resetFields: resetSearchBoxFields, validate: validateSearchBox }, - // ] = useForm({ - // labelWidth: 100, - // schemas: formSearchBoxSchema, - // showActionButtonGroup: false, - // submitFunc: submit, - // }) - // const Viewlist = ref([]) - // // 全部勾选 - // const ViewlallCheck = ref(false) - // 部分勾选 - // const ViewlsomeCheck = ref(false) - // watchEffect(() => { - // // 全选 - // if (ViewlallCheck.value) { - // Viewlist.value.forEach((item: any) => { - // item.selected = true - // }) - // } else { - // // 取消全选 - // Viewlist.value.forEach((item: any) => { - // item.selected = false - // }) - // } - // }) - // watch( - // Viewlist.value, - // (val) => { - // let a = 0 - // let b = 0 - // val.forEach((item: any) => { - // if (item.selected) { - // a += 1 - // } else { - // b += 1 - // } - // }) - // if (a == 0) { - // ViewlallCheck.value = false - // } - // if (b == 0) { - // ViewlallCheck.value = true - // } - // if (a != 0 && b != 0) { - // ViewlsomeCheck.value = true - // } else { - // ViewlsomeCheck.value = false - // } - // }, - // { - // deep: true, - // }, - // ) - // const Viewsettings = { - // height: '163', - // readOnly: true, - // // autoWrapRow: true, - // // autoWrapCol: true, - // // 每行的高度 - // rowHeights: 26, - // fixedColumnsLeft: 1, - // // 需要隐藏的列 - // hiddenColumns: { - // columns: [1, 2, 3, 4, 5, 6, 7, 8], - // indicators: true, - // }, - // // // 控制回车移动 - // // enterMoves: 'row', - // // columnSorting: false, - // // // 如果通过复制或者填写校验出现错误,清空输入框 - // // afterValidate: function (isValid, value, row, prop, source) { - // // if (!isValid) { - // // hotTb.value.hotInstance.setDataAtRowProp(row, prop, '') - // // } - // // }, - // columns: columns, - // // 此行直接复制,必须(非商用) - // licenseKey: 'non-commercial-and-evaluation', - // // // 定义所有单元格发生变化的回调处理 - // // async afterChange(changes, source) {}, - // } - // function handleReset() { - // resetSearchBoxFields() - // handleSearch() - // } - // async function handleSearch() { - // const values = await validateSearchBox() - // console.log(values) - // let ApiData: any = [] - // Object.keys(values).forEach((item) => { - // if (values[item]) { - // console.log(values[item].split(',')) - - // if (item == 'cntrno') { - // ApiData.push({ FieldName: item, FieldValue: values[item], ConditionalType: 15 }) - // } else { - // ApiData.push({ FieldName: item, FieldValue: values[item], ConditionalType: 1 }) - // } - // } - // }) - // GetViewListDetail(JSON.stringify(ApiData)) - // } - // function ViewTableAdd() { - // let ApiData: any = { id: rowId.value, ids: [] } - // Viewlist.value.forEach((e: any, i) => { - // if (e.selected) { - // ApiData.ids.push(e.id) - // } - // }) - // console.log(ApiData.ids) - // if (ApiData.ids.length) { - // ApiAddCtn(ApiData).then(async (res) => { - // if (res.succeeded) { - // const res: API.DataResult = await ApiInfo({ id: unref(rowId) }) - // if (res.succeeded) { - // allCheck.value = false - // someCheck.value = false - // ViewlallCheck.value = false - // ViewlsomeCheck.value = false - // submit() - // GetListDetail() - // handleReset() - // GetViewListDetail('[]') - // } - // // getData(false) - // notification.success({ message: res.message, duration: 3 }) - // } - // }) - // } - // } - //--------------------------------------- tab3 --------------------------------------- // 应收传到应付的数据 const broReceiveData = ref([]) // 应付传到应收的数据 @@ -906,13 +749,4 @@ position: absolute; left: 15px; } - // .SearchBox { - // display: flex; - // .Form { - // flex: 1; - // } - // .mt-4 { - // margin-left: 10px; - // } - // } diff --git a/src/views/ContainerManagement/BuyCtn/index.vue b/src/views/ContainerManagement/BuyCtn/index.vue index 85e4e069..dbfbb59d 100644 --- a/src/views/ContainerManagement/BuyCtn/index.vue +++ b/src/views/ContainerManagement/BuyCtn/index.vue @@ -65,7 +65,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['oldContainerOwner', 'bsdate', 'accdate']) }, columns, formConfig: { @@ -150,7 +150,6 @@ } ApiDel(ApiData).then((res) => { - console.log(res) notification.success({ message: res.message, duration: 3 }) reload() }) diff --git a/src/views/ContainerManagement/CtnScrap/columns.tsx b/src/views/ContainerManagement/CtnScrap/columns.tsx index 7c5dd321..2fc4d8d3 100644 --- a/src/views/ContainerManagement/CtnScrap/columns.tsx +++ b/src/views/ContainerManagement/CtnScrap/columns.tsx @@ -143,6 +143,9 @@ export const formSchema: FormSchema[] = [ label: '箱型箱量', component: 'Input', colProps: { span: 6 }, + dynamicDisabled: ({}) => { + return true + }, }, { field: 'billState', diff --git a/src/views/ContainerManagement/CtnScrap/index.vue b/src/views/ContainerManagement/CtnScrap/index.vue index 85e4e069..fbad336e 100644 --- a/src/views/ContainerManagement/CtnScrap/index.vue +++ b/src/views/ContainerManagement/CtnScrap/index.vue @@ -65,7 +65,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['bsdate', 'accdate']) }, columns, formConfig: { diff --git a/src/views/ContainerManagement/CurrentState/columns.tsx b/src/views/ContainerManagement/CurrentState/columns.tsx index 9a9ca243..56f31fab 100644 --- a/src/views/ContainerManagement/CurrentState/columns.tsx +++ b/src/views/ContainerManagement/CurrentState/columns.tsx @@ -222,7 +222,6 @@ export const searchFormSchema: FormSchema[] = [ label: '箱来源', component: 'ApiSelect', colProps: { span: 4 }, - defaultValue: '', componentProps: ({ formModel }) => { return { api: () => { diff --git a/src/views/ContainerManagement/CurrentState/index.vue b/src/views/ContainerManagement/CurrentState/index.vue index f45494f0..573e38c3 100644 --- a/src/views/ContainerManagement/CurrentState/index.vue +++ b/src/views/ContainerManagement/CurrentState/index.vue @@ -50,39 +50,8 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['ctnOwner', 'ctnSourceId', 'isOnlineId', 'portid']) }, - // beforeFetch: (p) => { - // var data = getForm().getFieldsValue() - // const postParam: API.PageRequest = { - // queryCondition: '', - // pageCondition: { - // pageIndex: p.page, - // pageSize: p.pageSize, - // sortConditions: [], - // }, - // } - // if (p.field) { - // postParam.pageCondition.sortConditions = [ - // { - // sortField: p.field, - // listSortDirection: p.order == 'ascend' ? 0 : 1, - // }, - // ] - // } else { - // postParam.pageCondition.sortConditions = [] - // } - // let condition: API.ConditionItem[] = [] - // if (!!data.CtnName) { - // condition.push({ - // FieldName: 'CtnName', - // FieldValue: data.CtnName, - // ConditionalType: 1, - // }) - // } - // postParam.queryCondition = JSON.stringify(condition) - // return postParam - // }, columns, formConfig: { labelWidth: 120, diff --git a/src/views/ContainerManagement/CustFeeDui/index.vue b/src/views/ContainerManagement/CustFeeDui/index.vue index f64ac7c9..111c72c4 100644 --- a/src/views/ContainerManagement/CustFeeDui/index.vue +++ b/src/views/ContainerManagement/CustFeeDui/index.vue @@ -57,7 +57,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['oldContainerOwner', 'rentDirectId']) }, columns, formConfig: { diff --git a/src/views/ContainerManagement/RentIn/index.vue b/src/views/ContainerManagement/RentIn/index.vue index 85e4e069..7e3fd1df 100644 --- a/src/views/ContainerManagement/RentIn/index.vue +++ b/src/views/ContainerManagement/RentIn/index.vue @@ -65,7 +65,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['oldContainerOwner', 'rentDirectId', 'bsdate', 'accdate']) }, columns, formConfig: { diff --git a/src/views/ContainerManagement/RentOneWay/index.vue b/src/views/ContainerManagement/RentOneWay/index.vue index 85e4e069..231aef66 100644 --- a/src/views/ContainerManagement/RentOneWay/index.vue +++ b/src/views/ContainerManagement/RentOneWay/index.vue @@ -65,7 +65,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['rentCustomerName', 'bsdate', 'accdate']) }, columns, formConfig: { diff --git a/src/views/ContainerManagement/RentOut/index.vue b/src/views/ContainerManagement/RentOut/index.vue index 85e4e069..c89d9cd3 100644 --- a/src/views/ContainerManagement/RentOut/index.vue +++ b/src/views/ContainerManagement/RentOut/index.vue @@ -65,7 +65,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['rentCustomerName', 'rentDirectId', 'bsdate', 'accdate']) }, columns, formConfig: { diff --git a/src/views/ContainerManagement/SellCtn/index.vue b/src/views/ContainerManagement/SellCtn/index.vue index 85e4e069..fbad336e 100644 --- a/src/views/ContainerManagement/SellCtn/index.vue +++ b/src/views/ContainerManagement/SellCtn/index.vue @@ -65,7 +65,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['bsdate', 'accdate']) }, columns, formConfig: { diff --git a/src/views/ContainerManagement/StateChange/index.vue b/src/views/ContainerManagement/StateChange/index.vue index 86f0ff45..568096fe 100644 --- a/src/views/ContainerManagement/StateChange/index.vue +++ b/src/views/ContainerManagement/StateChange/index.vue @@ -43,7 +43,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['ctnBizState', 'changeSourceId']) }, columns, rowSelection: { type: 'checkbox' }, diff --git a/src/views/ContainerManagement/dsxxcl/index.vue b/src/views/ContainerManagement/dsxxcl/index.vue index 1417bd8c..b760419d 100644 --- a/src/views/ContainerManagement/dsxxcl/index.vue +++ b/src/views/ContainerManagement/dsxxcl/index.vue @@ -32,7 +32,7 @@ }) }, beforeFetch: (p) => { - return formatParams(p) + return formatParams(p, ['ctnall', 'ctnSourceId', 'isOnlineId']) }, columns, rowSelection: { type: 'checkbox' },