ncpub-multipage-demo-2005/src/ssctpaaa/intelligentApproval/approvalMonitoring/config/events/logicalEvents.js

196 lines
5.0 KiB
JavaScript

/*0YgIFuXJoC2x+5JNXKiUO11ZXLxRDpeZUyfdJGHH3Ew=*/
/* eslint-disable no-console */
import {
requestPromise,
setStatePromise
} from 'ssccommon/utils/asyncFunctions.js';
import { toast } from "nc-lightapp-front";
import sscOpenTo from 'ssccommon/utils/sscOpenTo';
/**
* @method logicalSearchList 查询区查询按钮点击回调
* @param {Array} conditions 查询区所有字段值
* @return {Undefined} 无返回值
*/
async function logicalSearchList(querycondition, allpks = false) {
try {
const result = await requestPromise({
url: `/nccloud/ssctp/sscapv/ApproveMonitorQryAction.do`,
data: allpks ? { pks: allpks } : {
querycondition,
pagecode: `701004SPJK_L`,
queryAreaCode: `approvalMonitoringSearchArea`,
querytype: `tree`,
oid: `1001ZG100000000010NY`
},
});
const { data } = result
if (allpks) { // 翻页
this.props.table.setAllTableData('approvalMonitoringList', {
rows: data ? data.data.rows : []
})
} else { // 查询区查询
this.props.table.setAllTableData('approvalMonitoringList', {
rows: data ? data.data.rows : [],
pageInfo: {
pageIndex: 0,
pageSize: 10,
totalPage: data ? Math.ceil(data.pks.length / 10) : 0,
total: data ? data.pks.length : 0
},
allpks: data ? data.pks : []
})
this.pubMessage.querySuccess((data ? data.pks : []).length);
}
this.setState({ disabled: true })
} catch (e) {
console.error(e)
}
}
/**
* @method logicalSearchAreaAfterEvent 查询区编辑后事件
* @param {String} attrcode 当前操作项对应键值
* @param {String || Object} values 当前操作项对应字段值
* @param {String} area 查询区区域id
* @return {Undefined} 无返回值
*/
async function logicalSearchAreaAfterEvent(attrcode, values, area) {
console.log('logicalSearchAreaAfterEvent: ', attrcode, values, area);
}
/**
* @method logicalManualReturn 退回人工处理
* @return {Undefined} 无返回值
*/
async function logicalManualReturn() {
const { state: { modalVal, multiLang }, props: {
table: { getCheckedRows, updateDataByIndexs, selectAllRows, },
} } = this
// 校验 退回原因
if (!modalVal) return toast({
color: 'warning',
title: multiLang['701004SPJK_007'],
duration: 3
})
const checkedRows = [this.selectedRow];//getCheckedRows('approvalMonitoringList')
// 入参
const filterRows = checkedRows.filter(e => {
return !(e.resultsflag.value === 'N' && e.expuntreated.value === 'N') && !e.workinggroupname.value
})
const pks = filterRows.map(e => e.pk_currenttask.value),
billtypecodes = filterRows.map(e => e.billtypecode.value),
busiids = filterRows.map(e => e.busiid.value),
transtypecodes = filterRows.map(e => e.transtypecode.value),
monitorPks = filterRows.map(e => e.pk_approvemonitor.value)
const payload = {
reason: modalVal,
pks,
billtypecodes,
busiids,
transtypecodes,
monitorPks,
}
// 所选单据已转过人工处理,不能再进进行人工处理。
if (pks.length === 0) return toast({
color: 'warning',
title: multiLang['701004SPJK_012'],
duration: 3
})
// 退回处理
try {
const modules = this.selectedRow.module.value || "";
const result = await requestPromise({
url: `/nccloud/${modules}/ssctp/sscapv/TransToManualAction.do`,
data: payload,
});
if (!result) return
const {
data: {
message, color, rows,
},
} = result
toast({
color,
title: message,
duration: 3
})
await setStatePromise.call(this, { showCheckModal: false, modalVal: '' }) // 重置弹出框
// 刷新列表
const newRows = [{
index: this.selectedIdx, data: rows[0],
}]
updateDataByIndexs('approvalMonitoringList', newRows)
selectAllRows('approvalMonitoringList', false)
} catch (e) {
toast({
color: 'warning',
title: multiLang['701004SPJK_010'],
content: e.data,
duration: 3
})
}
}
/**
* @method logicalOpenBill 单据编码点击打开单据
* @param {Object} record 当前行数据
* @return {Undefined} 无返回值
*/
async function logicalOpenBill(record) {
const { billtypecode, transtypecode, busiid, pk_group } = record
// 打开单据
try {
const result = await requestPromise({
url: `/nccloud/sscrp/rpbill/BrowseBillAction.do`,
data: {
billtypeCode: billtypecode.value,
transtypeCode: transtypecode.value,
billid: busiid.value,
pk_group: pk_group.value
},
});
const { data: { data, url, system } } = result
sscOpenTo(this.props, system, [
url,
{
...data,
scene: 'bzcx'
}, null,
{
pk_group: record.pk_group.value
}
])
} catch (e) {
console.error(e)
}
}
export {
logicalSearchList,
logicalSearchAreaAfterEvent,
logicalManualReturn,
logicalOpenBill,
};
/*0YgIFuXJoC2x+5JNXKiUO11ZXLxRDpeZUyfdJGHH3Ew=*/