tk2312-web/src/sscivm/invoiceApplication/invoiceApl/card/common/valueChange.js

107 lines
4.4 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.

/*JioT+qO4mP4R+mDgiabLRephl6ShZZnbmhIGdMpitGg=*/
import {get} from 'lodash'
import presetVar from '../presetVar'
import requestApi from '../requestApi'
/**
* pk_org申请组织,
* pk_customer客户,
* gmf_zh客户账户,
* pk_customer_v客户,
* gmf_dz购买方地址,
* gmf_dh购买方电话,
* gmf_yh购买方银行账号,
* pk_supplier供应商,
* pk_supplier_v供应商,
* xsf_dz销售方地址,
* xsf_dh销售方电话,
* xsf_yh销售方开户行,
* xsf_zhh销售方银行账号,
* xsf_zh销售方账号,
* xsf_khh销售方开户行
* pk_freecustom: 散户
*/
const headKeys = ['pk_org', 'pk_customer', 'gmf_zh', 'pk_customer_v', 'gmf_dz', 'gmf_dh', 'gmf_yh', 'gmf_zhh', "pk_supplier", "pk_supplier_v", "xsf_dz", "xsf_dh", "xsf_yh", "xsf_zhh", "xsf_zh", "xsf_khh", "pk_freecustom"];
/**
* xmdj:单价
* sl:税率
* xmje:无税金额
* se:税额
* xmsl:数量
* xmjshj:价税合计
* pk_materiel:物料
* zkje:折扣金额
* fphxz:发票行性质
* taxcode:税码
* spbm:税收分类编码
* sl:税率
* xmjshj:价税合计
* def1:合同销售订单编号
*/
const bodyKeys = ['xmdj', 'sl', 'xmje', 'se', 'xmsl', 'xmjshj', 'pk_materiel',
'zkje', 'fphxz', 'taxcode', 'spbm', 'sl', 'def1'];
export default function (moduleId, key, value, changedrows, index, record) {
// console.log('valueChange', moduleId, key, value, changedrows, index);
let hasChange = false;
if ((moduleId == presetVar.formAreaId && headKeys.indexOf(key) > -1) ||
(moduleId == presetVar.bodyAreaId && bodyKeys.indexOf(key) > -1)) {
hasChange = true;
}
/*if (bodyKeys.includes(key)) {
debugger;
}*/
if (hasChange) {
// 取得表头数据
let headBodyData;
if (moduleId == presetVar.formAreaId) {
headBodyData = this.props.createHeadAfterEventData(presetVar.pagecode, presetVar.formAreaId, presetVar.bodyAreaId, moduleId, key, value);
} else {
headBodyData = this.props.createBodyAfterEventData(presetVar.pagecode, presetVar.formAreaId, presetVar.bodyAreaId, moduleId, key, changedrows)
}
headBodyData.templateid = this.props.meta.getMeta().pageid;
headBodyData.userjson = JSON.stringify({
appcode: this.props.getSearchParam('c'),
pagecode: this.props.getSearchParam('p'),
templateid: this.props.meta.getMeta().pageid,
checkrule: 'true'
});
// 组装发送数据
let sendData = {
...headBodyData,
checkrule: 'true',
templateid: this.props.meta.getMeta().pageid
}
if (key == 'xmjshj') {
console.log('sendData = ', sendData);
}
requestApi.valueChange({
data: sendData,
success: (data) => {
data.head && data.head[presetVar.formAreaId] && this.props.form.setAllFormValue(data.head);
// console.log('data.body = ', data.body);
data.body && data.body[presetVar.bodyAreaId] && this.props.cardTable.updateDataByRowId(presetVar.bodyAreaId, data.body[presetVar.bodyAreaId]);
if (moduleId == presetVar.bodyAreaId && key == 'zkje') {
// 折扣金额编辑后可能增加折扣行
let addRow = data.body[presetVar.bodyAreaId].rows.find(one => !one.rowid);
addRow && this.props.cardTable.addRow(presetVar.bodyAreaId, index + 1, addRow.values, false);
// 删除不要得折扣行
const allRows = this.props.cardTable.getAllRows(presetVar.bodyAreaId);
allRows.find((one) => {
const pk_ivappdetail = get(one, 'values.pk_ivappdetail.value');
const rowid = get(one, 'rowid');
if (one.status == '3' && (pk_ivappdetail == null || pk_ivappdetail == '')) {
this.props.cardTable.delRowByRowId(presetVar.bodyAreaId, rowid, null, true);
return true;
} else if (one.status == '3' && pk_ivappdetail) {
this.props.cardTable.delRowByRowId(presetVar.bodyAreaId, rowid, null, false);
return true;
}
})
}
}
});
}
}
/*JioT+qO4mP4R+mDgiabLRephl6ShZZnbmhIGdMpitGg=*/