後端的js:exports.uc盤點單明細_onBeforeInsert = function(row, sqls, callback)
{
var dm = this.dataModule;
var clientInfo = dm.clientInfo;
var sql = "select max(年月) AS LASTYM from 庫存結帳表";
dm.queryRaw(clientInfo, clientInfo.database, sql, {}, function(err, datas) {
var last_period = datas[0].LASTYM;
sql = "select 平均成本 from 庫存結帳表 Where 產品編號='"+row.產品編號+"' and 年月='"+last_period+"'";
dm.queryRaw(clientInfo, clientInfo.database, sql,{}, function(err, datas) {
if (datas.length>0) {
row.單價 = datas[0].平均成本;
}
callback(null, true);
});
});
}