|
|
|
@ -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 = []
|
|
|
|
|
}
|
|
|
|
|