tk2312-web/src/ic/ic/pub/beforeEvents/vbatchcodeBeforeEvent.js

70 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ajax, toast } from 'nc-lightapp-front';
/**
*
* @param {参数点击字段key表头区域id表体区域id组织主键物料主键对应入库单id行索引} constance
*/
export default function (props, constance, record) {
return new Promise(function (resolve, reject) {
let { key, headareaid, bodyareaid, pk_org_field, cmaterialid_field, ccorrespondhid_field, index } = constance;
//组织为空,不可编辑
let pk_org = props.form.getFormItemsValue(headareaid, pk_org_field);
if (!pk_org) {
resolve(false);
}
//物料为空,不可编辑
let cmaterialvid;
if (record) {
cmaterialvid = record.values[cmaterialid_field];
} else {
cmaterialvid = props.cardTable.getValByKeyAndIndex(bodyareaid, index, cmaterialid_field);
}
if (!cmaterialvid) {
resolve(false);
}
//对应入库单id不为空不可编辑
let ccorrespondhid;
if (record) {
ccorrespondhid = record.values[ccorrespondhid_field];
} else {
ccorrespondhid = props.cardTable.getValByKeyAndIndex(bodyareaid, index, ccorrespondhid_field);
}
if (ccorrespondhid && ccorrespondhid.value) {
resolve(false);
}
let data = {
key: key,
params: {
cmaterialvid: cmaterialvid.value,
pk_org: pk_org.value
}
};
ajax({
url: '/nccloud/ic/event/before.do',
data: data,
async: false,
success: (res) => {
if (res.data) {
let isedit = res.data.isedit;
if (isedit) {
resolve(isedit);
} else if (res.data.message) {
toast({
color: 'warning',
content: res.data.message
});
}
resolve(false);
}
},
error: (error) => {
toast({
color: 'warning',
content: error.message
});
resolve(false);
}
});
});
}