218 lines
6.8 KiB
JavaScript
218 lines
6.8 KiB
JavaScript
|
var m_xmmc = WfForm.convertFieldNameToId("xmmc");//项目名称
|
|||
|
var m_bmwyz = WfForm.convertFieldNameToId("glkcjlb");//关联勘察
|
|||
|
var m_bmwyz1 = WfForm.convertFieldNameToId("glxsxqd");//关联销售
|
|||
|
var m_bmwyz2 = WfForm.convertFieldNameToId("chdadx");//唯一值多选
|
|||
|
var dt2_tyrq = WfForm.convertFieldNameToId("tyrq", "detail_2");//明细2停用日期
|
|||
|
jQuery(document).ready(function () {
|
|||
|
setTimeout("bindFieldChange()", "500");
|
|||
|
});
|
|||
|
|
|||
|
function bindFieldChange() {
|
|||
|
WfForm.bindFieldChangeEvent(m_xmmc, function (obj, id, value) {
|
|||
|
WfForm.changeFieldValue(m_bmwyz, {value: ''});
|
|||
|
WfForm.changeFieldValue(m_bmwyz1, {value: ''});
|
|||
|
WfForm.changeFieldValue(m_bmwyz2, {value: ''});
|
|||
|
});
|
|||
|
//提交检验
|
|||
|
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function (callback) {
|
|||
|
var flag = true;
|
|||
|
var rowArr = WfForm.getDetailAllRowIndexStr("detail_2").split(",");
|
|||
|
for (var i = 0; i < rowArr.length; i++) {
|
|||
|
var rowid = rowArr[i];
|
|||
|
var dt2_tyrq_v = WfForm.getFieldValue(dt2_tyrq + "_" + rowid);
|
|||
|
if (dt2_tyrq_v != "") {
|
|||
|
WfForm.showMessage("明细2第" + (i + 1) + "行设备已在" + dt2_tyrq_v + "停用!", 2, 5);
|
|||
|
flag = flase;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
if (flag) {
|
|||
|
callback(); //继续提交需调用callback,不调用代表阻断
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
var rowArr = WfForm.getDetailAllRowIndexStr("detail_3").split(",");
|
|||
|
// WfForm.delDetailRow("detail_2", "all");
|
|||
|
for (var i = 0; i < rowArr.length; i++) {
|
|||
|
var rowIndex = rowArr[i];
|
|||
|
if (rowIndex !== "") {
|
|||
|
var fieldMark = "field12566" + rowIndex;
|
|||
|
if (fieldMark === "0") {
|
|||
|
var count = WfForm.getFieldValue("field12562" + rowIndex);
|
|||
|
var field7108_ = WfForm.getFieldValue("field6117_" + rowIndex);
|
|||
|
WfForm.addDetailRow("detail_2", {field8567: {value: count}, field7583: {value: field7108_},});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
/*
|
|||
|
dev-1 王宣然 限制明细表选择的bom不能重复
|
|||
|
*/
|
|||
|
const detailBomField = WfForm.convertFieldNameToId('bombm', 'detail_1');
|
|||
|
/**
|
|||
|
* 主表辅助字段
|
|||
|
*/
|
|||
|
const mainAttrField = WfForm.convertFieldNameToId('ycbmpzx');
|
|||
|
/**
|
|||
|
* 明细1数量
|
|||
|
*/
|
|||
|
const detail1NumFieldId = WfForm.convertFieldNameToId('sl1', "detail_1");
|
|||
|
/**
|
|||
|
* 明细3 明细2数量
|
|||
|
*/
|
|||
|
const detail3NumFieldId = WfForm.convertFieldNameToId('mx2sl', "detail_3");
|
|||
|
/**
|
|||
|
* 明细3数量
|
|||
|
*/
|
|||
|
const detail3NumFieldId2 = WfForm.convertFieldNameToId('sl1', "detail_3");
|
|||
|
/**
|
|||
|
* 明细3需求数量
|
|||
|
*/
|
|||
|
const detail3NumFieldId3 = WfForm.convertFieldNameToId('sl', "detail_3");
|
|||
|
/**
|
|||
|
* 明细3bom编码
|
|||
|
*/
|
|||
|
const detail3BomFieldId = WfForm.convertFieldNameToId('bombm', "detail_3");
|
|||
|
/**
|
|||
|
* 明细1bom编码
|
|||
|
*/
|
|||
|
const detail1BomFieldId = WfForm.convertFieldNameToId('bombm', "detail_1");
|
|||
|
/*
|
|||
|
*已经选择的bom
|
|||
|
*/
|
|||
|
let choiceArr = new Set();
|
|||
|
let updateNum = {};
|
|||
|
|
|||
|
const yjdhrq = WfForm.convertFieldNameToId('yjdhrq');
|
|||
|
console.log('id ', yjdhrq)
|
|||
|
// 明细到货日期
|
|||
|
const detail1yjdhsj = WfForm.convertFieldNameToId('yjdhsj', "detail_2");
|
|||
|
|
|||
|
WfForm.bindFieldChangeEvent(yjdhrq, function (obj, id, value) {
|
|||
|
initDeatail2Date(value);
|
|||
|
});
|
|||
|
|
|||
|
WfForm.registerCheckEvent(WfForm.OPER_ADDROW + "2", function (callback) {
|
|||
|
callback();
|
|||
|
let value = WfForm.getFieldValue(yjdhrq);
|
|||
|
initDeatail2Date(value);
|
|||
|
});
|
|||
|
|
|||
|
WfForm.bindDetailFieldChangeEvent(detailBomField, function (id, rowIndex, value) {
|
|||
|
if (!value) {
|
|||
|
return;
|
|||
|
}
|
|||
|
if (choiceArr.has(value)) {
|
|||
|
WfForm.showMessage('不能选择重复的bom,请重新选择!');
|
|||
|
setTimeout(() => {
|
|||
|
WfForm.changeFieldValue(`${detailBomField}_${rowIndex}`, {value: '', specialobj: []});
|
|||
|
}, 5);
|
|||
|
}
|
|||
|
initChoiceArr();
|
|||
|
getBomArr();
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
// 数量变化自动计算
|
|||
|
WfForm.bindDetailFieldChangeEvent(`${detail1NumFieldId},${detailBomField}`, function (id, rowIndex, value) {
|
|||
|
let detail1RowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
|
|||
|
console.log(detail1RowArr);
|
|||
|
for (let i = 0; i < detail1RowArr.length; i++) {
|
|||
|
let rowIndex = detail1RowArr[i];
|
|||
|
if (rowIndex !== "") {
|
|||
|
let num = WfForm.getFieldValue(`${detail1NumFieldId}_${rowIndex}`);
|
|||
|
// bom编码
|
|||
|
let bom = WfForm.getFieldValue(`${detail1BomFieldId}_${rowIndex}`);
|
|||
|
setTimeout(() => {
|
|||
|
computeNum(bom, num);
|
|||
|
}, 500);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
function initDeatail2Date(value) {
|
|||
|
let detail2RowArr = WfForm.getDetailAllRowIndexStr('detail_2').split(",");
|
|||
|
for (let i = 0; i < detail2RowArr.length; i++) {
|
|||
|
let rowIndex = detail2RowArr[i];
|
|||
|
if (rowIndex !== "") {
|
|||
|
WfForm.changeFieldValue(`${detail1yjdhsj}_${rowIndex}`, {value: value});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 计算明细3数量
|
|||
|
*/
|
|||
|
function computeNum(detail1Bom, detail1Num) {
|
|||
|
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
|
|||
|
console.log(detail3RowArr);
|
|||
|
for (let i = 0; i < detail3RowArr.length; i++) {
|
|||
|
let rowIndex = detail3RowArr[i];
|
|||
|
if (rowIndex !== "") {
|
|||
|
// bom编码
|
|||
|
let bom = WfForm.getFieldValue(`${detail3BomFieldId}_${rowIndex}`);
|
|||
|
if (bom != detail1Bom) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
console.log('需要改变的index ', rowIndex)
|
|||
|
WfForm.changeFieldValue(`${detail3NumFieldId}_${rowIndex}`, {value: detail1Num});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* 初始化已经选择的数组
|
|||
|
*/
|
|||
|
function initChoiceArr() {
|
|||
|
choiceArr = new Set();
|
|||
|
let rowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
|
|||
|
for (let i = 0; i < rowArr.length; i++) {
|
|||
|
let rowIndex = rowArr[i];
|
|||
|
if (rowIndex !== "") {
|
|||
|
let bom = WfForm.getFieldValue(`${detailBomField}_${rowIndex}`);
|
|||
|
// console.log('bom ', bom);
|
|||
|
if (!bom) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
choiceArr.add(bom);
|
|||
|
}
|
|||
|
}
|
|||
|
console.log('choiceArr ', choiceArr)
|
|||
|
}
|
|||
|
|
|||
|
WfForm.registerCheckEvent(WfForm.OPER_DELROW + "1", function (callback) {
|
|||
|
callback();
|
|||
|
getBomArr();
|
|||
|
initChoiceArr();
|
|||
|
});
|
|||
|
|
|||
|
function getBomArr() {
|
|||
|
let arr = [];
|
|||
|
let rowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
|
|||
|
for (let i = 0; i < rowArr.length; i++) {
|
|||
|
let rowIndex = rowArr[i];
|
|||
|
if (rowIndex !== "") {
|
|||
|
arr.push(WfForm.getFieldValue(`${detailBomField}_${rowIndex}`));
|
|||
|
}
|
|||
|
}
|
|||
|
let bom = new Set(arr);
|
|||
|
let arr2 = [...bom];
|
|||
|
let obj = {};
|
|||
|
obj.value = arr2.join(',');
|
|||
|
let specialobjArr = [];
|
|||
|
for (let i = 0; i < arr2.length; i++) {
|
|||
|
let obj = {};
|
|||
|
obj.id = arr2[i];
|
|||
|
obj.name = arr2[i];
|
|||
|
specialobjArr.push(obj);
|
|||
|
}
|
|||
|
obj.specialobj = specialobjArr;
|
|||
|
let val = WfForm.changeFieldValue(mainAttrField, obj);
|
|||
|
if (!val) {
|
|||
|
WfForm.delDetailRow("detail_3", "all");
|
|||
|
}
|
|||
|
console.log('主表辅助字段值 : ', WfForm.getFieldValue(mainAttrField));
|
|||
|
}
|
|||
|
|