箱管 调整 formatParams hooks 添加 精准查询

szh-new
张同海 3 months ago
parent ab24e34c2e
commit 1dc9339076

@ -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 = [{
postData.pageCondition.sortConditions = [
{
sortField: params.field,
listSortDirection: params.order == "ascend" ? 0 : 1
}]
listSortDirection: params.order == 'ascend' ? 0 : 1,
},
]
} else {
postData.pageCondition.sortConditions = []
}

@ -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 })
}
}

@ -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, {

@ -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<any>([])
// //
// 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;
// }
// }
</style>

@ -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()
})

@ -143,6 +143,9 @@ export const formSchema: FormSchema[] = [
label: '箱型箱量',
component: 'Input',
colProps: { span: 6 },
dynamicDisabled: ({}) => {
return true
},
},
{
field: 'billState',

@ -65,7 +65,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['bsdate', 'accdate'])
},
columns,
formConfig: {

@ -222,7 +222,6 @@ export const searchFormSchema: FormSchema[] = [
label: '箱来源',
component: 'ApiSelect',
colProps: { span: 4 },
defaultValue: '',
componentProps: ({ formModel }) => {
return {
api: () => {

@ -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,

@ -57,7 +57,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['oldContainerOwner', 'rentDirectId'])
},
columns,
formConfig: {

@ -65,7 +65,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['oldContainerOwner', 'rentDirectId', 'bsdate', 'accdate'])
},
columns,
formConfig: {

@ -65,7 +65,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['rentCustomerName', 'bsdate', 'accdate'])
},
columns,
formConfig: {

@ -65,7 +65,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['rentCustomerName', 'rentDirectId', 'bsdate', 'accdate'])
},
columns,
formConfig: {

@ -65,7 +65,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['bsdate', 'accdate'])
},
columns,
formConfig: {

@ -43,7 +43,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['ctnBizState', 'changeSourceId'])
},
columns,
rowSelection: { type: 'checkbox' },

@ -32,7 +32,7 @@
})
},
beforeFetch: (p) => {
return formatParams(p)
return formatParams(p, ['ctnall', 'ctnSourceId', 'isOnlineId'])
},
columns,
rowSelection: { type: 'checkbox' },

Loading…
Cancel
Save