You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
5.6 KiB

4 years ago
define(function(require, exports, module) {
let Window = require('system/views/pages/window');
let tpl = require('text!apps/rht/fsh/fsh140101/myedit.tpl');
let Service = require('./fsh140101service');
let rhtComm = require('../../comm/rhtComm');
function MyEdit(dsData) {
this.options = {
title: "单品价格调整",
content: tpl,
width: 450,
height: 370,
modal: true,
closed: true,
closable: true,
draggable: true,
maximizable: false,
resizable: false,
data: null
}
this.dsData = dsData;
Window.call(this, this.options);
}
inherits(MyEdit, Window);
MyEdit.prototype.init = function() {
}
MyEdit.prototype.open = function() {
Window.prototype.open.call(this);
let $sPluCode = this.getElement('.oldPluCode');
let $sPluName = this.getElement('.oldPluName');
let $oldPrice = this.getElement('.oldPrice');
let $newPrice = this.getElement('.newPrice');
$sPluCode.textbox('textbox').bind('keydown', function(e){
if (e.keyCode == 13){ // 当按下回车键时接受输入的值。
let newPluCode = $(this).val();
let ret= Service.getSlideMenuData("actExecute","GetPluInf", newPluCode,"","","","");
if (ret.result !== 1) {
document.getElementById("errMsg").innerHTML = '商品编码:'+newPluCode+''+ret.message;
$sPluCode.textbox('setValue', '');
$sPluCode.focus();
}
else{
if (ret.data != null) {
document.getElementById("errMsg").innerHTML = '';
$sPluName.textbox('setValue', ret.data.pluname);
$oldPrice.numberbox('setValue', ret.data.price);
$newPrice.numberbox('setValue', '');
$newPrice.numberbox().next('span').find('input').focus();
}
}
}
});
/*
$newPrice.numberbox({
inputEvents:$.extend({},$.fn.numberbox.defaults.inputEvents,{
keydown:function(e){
if (e.keyCode == 13){
$btnOK.focus();
}
}
})
});
*/
}
//执行windows窗体上自定义按钮事件
MyEdit.prototype.customerize = function() {
let self = this;
let $sPluCode = this.getElement('.oldPluCode');
let $sPluName = this.getElement('.oldPluName');
$sPluCode.textbox('setValue', this.dsData.PluCode);
$sPluName.textbox('setValue', this.dsData.PluName);
let $oldPrice = this.getElement('.oldPrice');
let $newPrice = this.getElement('.newPrice');
let $newSxDate = this.getElement('.newSxDate');
let dateTimeDef = rhtComm.GetServerDate(0)+' 23:59:59';
$oldPrice.numberbox('setValue', this.dsData.Price);
$newPrice.numberbox('setValue', '');
$newSxDate.datetimebox('setValue', dateTimeDef);
//确定按钮事件
this.getElement('.btnOK').on('click', function(event) {
if (Store.confirm("您确认对生鲜商品进行调价吗?")) {
let selectPluCode = $sPluCode.numberbox('getValue');
let selectSxDate = $newSxDate.datetimebox('getValue');
let selectPrice = $newPrice.numberbox('getValue');
if (rhtComm.GetServerDateTime(0) > selectSxDate){
document.getElementById("errMsg").innerHTML='失效日期时间不能早于当前日期时间!';
}
else{
if (TypeUtil.toFloat(selectPrice) < 0){
document.getElementById("errMsg").innerHTML='商品新零售价不能为负数!';
}
else{
if ((selectPluCode.length <= 0) || (selectPrice.length <= 0 ) || (selectSxDate.length <= 0 )){
document.getElementById("errMsg").innerHTML='商品['+selectPluCode+']价格更新失败!商品编码、零售价格和失效日期都不能为空!';
}
else{
let ret= Service.getSlideMenuData("actExecute","myedit", selectPluCode,selectPrice,selectSxDate,"","");
if (ret.result !== 1) {
document.getElementById("errMsg").innerHTML='商品['+selectPluCode+']价格更新失败!'+ret.message;
}
else{
document.getElementById("errMsg").innerHTML='商品['+selectPluCode+']价格更新成功!';
$sPluCode.textbox('setValue', '');
$sPluName.textbox('setValue', '');
$oldPrice.numberbox('setValue', '');
$newPrice.numberbox('setValue', '');
}
}
}
}
}
});
//取消按钮事件
this.getElement('.btnCancel').on('click', function(event) {
if (self.callback) {
self.callback();
}
self.close();
});
}
return MyEdit;
})