108 lines
3.3 KiB
JavaScript
108 lines
3.3 KiB
JavaScript
/*
|
|
* @Author: hujieh
|
|
* @PageInfo: 物料编辑后事件功能(单据处理辅助属性相关)
|
|
* @Date: 2018-08-14 19:10:07
|
|
* @Last Modified by: hujieh
|
|
* @Last Modified time: 2018-10-23 20:58:19
|
|
*/
|
|
import { ajax, base, toast } from 'nc-lightapp-front';
|
|
import { stringify } from 'querystring';
|
|
|
|
/**
|
|
* 物料辅助属性编辑前处理,如果是参照类型,添加过滤控制
|
|
* @param {*} props
|
|
* @param {*} appcode 小应用编码,可以为空
|
|
* @param {*} pagecode 页面编码
|
|
* @param {*} areacode 辅助属性所在的区域编码
|
|
* @param {*} key 触发事件的字段编码
|
|
* @param {*} record 行数据
|
|
*/
|
|
function resetItem(props, appcode, pagecode, areacode, key, record, configName, pk_org_field) {
|
|
let meta = props.meta.getMeta();
|
|
let item = meta[areacode].items.find((item) => item.attrcode == key);
|
|
if (item.itemtype == 'refer') {
|
|
item.queryCondition = (params) => {
|
|
let queryCondition = {};
|
|
//queryCondition = {
|
|
// ...(typeof queryCondition === 'function'
|
|
// ? queryCondition(params)
|
|
// : typeof queryCondition === 'object' ? queryCondition : {})
|
|
//};
|
|
let reftype_key = 'TreeRefActionExt';
|
|
if (params.refType == 'grid' || params.refType == 'gridTree') {
|
|
reftype_key = 'GridRefActionExt';
|
|
}
|
|
if (pk_org_field && record.values[pk_org_field]) {
|
|
queryCondition.pk_org = record.values[pk_org_field].value;
|
|
}
|
|
else if (record.values['pk_org']) {
|
|
queryCondition.pk_org = record.values['pk_org'].value;
|
|
}
|
|
queryCondition.appcode = appcode;
|
|
queryCondition.pagecode = pagecode;
|
|
queryCondition.areacode = areacode;
|
|
queryCondition.configName = configName;
|
|
queryCondition.data = JSON.stringify({ [areacode]: { areacode: areacode, rows: [record] } });
|
|
queryCondition.defineField = key;
|
|
queryCondition[reftype_key] = 'nccloud.web.mmpub.pub.marasst.MarAsstDefaultRef';
|
|
queryCondition['UsualGridRefActionExt'] = 'nccloud.web.mmpub.pub.marasst.MarAsstDefaultRef';
|
|
return queryCondition;
|
|
};
|
|
props.meta.setMeta(meta);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 物料辅助属性编辑后处理,如果受控字段的值不在值域内,则清空
|
|
* @param {*} props
|
|
* @param {*} appcode
|
|
* @param {*} pagecode
|
|
* @param {*} areacode
|
|
* @param {*} key
|
|
* @param {*} material_field
|
|
* @param {*} record
|
|
* @param {*} index
|
|
*/
|
|
function afterEdit(props, appcode, pagecode, areacode, key, material_field, record, index,configName) {
|
|
let data = {
|
|
appcode,
|
|
pagecode,
|
|
areacode,
|
|
configName,
|
|
controlField: key,
|
|
controlValue: (record.values[key] || {}).value,
|
|
materialvid: (record.values[material_field] || {}).value
|
|
};
|
|
ajax({
|
|
url: '/nccloud/mmpub/pub/marasstAfterEdit.do',
|
|
data: data,
|
|
mode: 'normal',
|
|
success: (res) => {
|
|
console.log(res, 'hj');
|
|
if (res.data && res.data.data) {
|
|
for (let i in res.data.data) {
|
|
let values = res.data.data[i];
|
|
if (!values || values.length == 0) {
|
|
props.cardTable.setValByKeyAndIndex(areacode, index, i, {
|
|
value: null,
|
|
display: null,
|
|
scale: -1
|
|
});
|
|
} else {
|
|
let value = (record.values[i] || {}).value;
|
|
if (!values.includes(value)) {
|
|
props.cardTable.setValByKeyAndIndex(areacode, index, i, {
|
|
value: null,
|
|
display: null,
|
|
scale: -1
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
export default { resetItem, afterEdit };
|