109 lines
3.5 KiB
JavaScript
109 lines
3.5 KiB
JavaScript
/* ******************* youhong.ai 建模部分 start ******************* */
|
|
$(() => {
|
|
let config = {
|
|
workflowUrl: '',
|
|
table: '',
|
|
detailTable: 'detail_1',
|
|
fieldMap: {
|
|
fkgs: 'fkgs',
|
|
zw: 'zw',
|
|
fj: 'fj'
|
|
}
|
|
}
|
|
|
|
function jumpToWorkflow() {
|
|
let ids = ModeList.getCheckedID();
|
|
let url = `${config.workflowUrl}&table=${config.table}&ids=${ids}&detail=${config.detailTable}&field_map=${JSON.stringify(config.fieldMap)}`
|
|
window.open(url, "_blank")
|
|
}
|
|
|
|
window.jumpToWorkflow = jumpToWorkflow
|
|
})
|
|
|
|
/* ******************* youhong.ai 建模部分 end ******************* */
|
|
|
|
|
|
/* ******************* youhong.ai 流程部分 start ******************* */
|
|
$(() => {
|
|
|
|
function getQueryString(name) {
|
|
let reg = new RegExp("(^|&|\/?)" + name + "=([^&]*)(&|$)", "i");
|
|
let searchStr = window.location.href
|
|
if (searchStr.startsWith('&')) {
|
|
searchStr = searchStr.substr(1)
|
|
}
|
|
let search = searchStr.match(reg)
|
|
if (search != null) {
|
|
return unescape(search[2]);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function getConfig() {
|
|
let tableName = getQueryString("table")
|
|
let ids = getQueryString("ids")
|
|
let mapping = getQueryString("field_map")
|
|
let detail = getQueryString("detail")
|
|
let fieldMap = JSON.parse(mapping)
|
|
return {
|
|
table: tableName,
|
|
ids,
|
|
fieldMap,
|
|
detailTable: detail
|
|
}
|
|
}
|
|
|
|
function runJs(config) {
|
|
console.log("config", config)
|
|
let {WeaLoadingGlobal} = ecCom
|
|
WeaLoadingGlobal.start();
|
|
$.ajax(`/aiyh/taibao/packing2model/packing?table=${config.table}&ids=${config.ids}`, {
|
|
success: (res) => {
|
|
WeaLoadingGlobal.destroy();
|
|
if (res && res.code === 200) {
|
|
console.log("获取到的数据", res.data)
|
|
let modelData = res.data
|
|
let fieldMap = config.fieldMap
|
|
let workflowDetailList = []
|
|
modelData.forEach(item => {
|
|
let obj = {}
|
|
Object.keys(fieldMap).forEach(key => {
|
|
obj[key] = item[fieldMap[key]]
|
|
})
|
|
workflowDetailList.push(obj)
|
|
})
|
|
console.log("收集整理的数据:", workflowDetailList)
|
|
addDetailValue(workflowDetailList, config.detailTable)
|
|
} else {
|
|
WfForm.showMessage("打包数据错误,无法带出数据!", 2, 5);
|
|
}
|
|
},
|
|
error: (err) => {
|
|
WeaLoadingGlobal.destroy();
|
|
WfForm.showMessage("网路异常,打包失败!", 2, 5);
|
|
console.log(err)
|
|
},
|
|
complete: () => {
|
|
WeaLoadingGlobal.destroy();
|
|
}
|
|
})
|
|
}
|
|
|
|
function addDetailValue(workflowDetailList, detail) {
|
|
workflowDetailList.forEach(item => {
|
|
let valueMap = {}
|
|
Object.keys(item).forEach(key => {
|
|
valueMap[WfForm.convertFieldNameToId(key, detail)] = {
|
|
value: item[key]
|
|
}
|
|
})
|
|
console.log("添加明细行数据", valueMap)
|
|
WfForm.addDetailRow(detail, valueMap);
|
|
})
|
|
}
|
|
|
|
runJs(getConfig())
|
|
|
|
})
|
|
|
|
/* ******************* youhong.ai 流程部分 end ******************* */ |