123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- var patt = /^(\d{4})-(0[1-9]|1[0-2])$/;
- var time;
- var hrNumber;
- var billId;
- shr.defineClass("shr.customer.StorefrontBudgetEdit", shr.framework.Edit, {
- initalizeDOM: function () {
- shr.customer.StorefrontBudgetEdit.superClass.initalizeDOM.call(this);
- this.storeF7Event();
- },
- //监控门店F7值
- storeF7Event: function () {
- //var self = this;
- if (this.getOperateState() != "VIEW") {
- time = $("#Time").val();
- hrNumber = $("#HRNumber").val();
- billId = $("#id").val();
- $("#Store").shrPromptBox("option", {
- onchange: function (e, value) {
- if (value.current == null) {
- return;
- }
- hrNumber = value.current.number;
- $("#HRNumber").val(hrNumber);
- if(time){
- var storeId = $("#Store_el").val();
- getNumByStoreFrontNumber(storeId,time);
- }
- }
- });
- //监控时间
- $("#Time").blur(function () {
- time = $("#Time").val();
- if(!time){
- return;
- }else if (!patt.test(time)) {
- shr.showWarning({
- message: "时间格式有误,正确格式为 yyyy-MM",
- });
- return;
- }if(hrNumber){
- var arr = verifyTime(billId,hrNumber,time);
- if(arr[0] == '1'){
- shr.showWarning({
- message: "时间必须在项目筹备期 "+arr[1]+" 至 "+arr[2]+" 内"
- });
- return;
- }else if(arr[0] == '3'){
- shr.showWarning({
- message: "当前门店在该月份已存在预算维护数据, 请勿重复提交!"
- });
- return;
- }
-
- var storeId = $("#Store_el").val();
- getNumByStoreFrontNumber(storeId,time);
- }
- });
- }
- },
- //保存
- saveAction: function () {
- time = $("#Time").val();
- if (time && !patt.test(time)) {
- shr.showWarning({
- message: "时间格式有误,正确格式为 yyyy-MM",
- });
- return;
- }
- // var num;
- // var startPreparedMonth;
- // var openDate;
- var arr;
- hrNumber = $("#HRNumber").val();
- billId = $("#id").val();
- if(time && hrNumber){
- arr = verifyTime(billId,hrNumber,time);
- }
- if(time && hrNumber && arr[0] == '1'){
- shr.showWarning({
- message: "时间必须在项目筹备期 "+arr[1]+" 至 "+arr[2]+" 内"
- });
- return;
- }else if(time && hrNumber && arr[0] == '3'){
- shr.showWarning({
- message: "当前门店在该月份已存在预算维护数据, 请勿重复提交!"
- });
- return;
- }
- shr.customer.StorefrontBudgetEdit.superClass.saveAction.call(this);
- },
- //重写assembleModel的原因是,保存时无法获取到NumberOfPractical的值
- assembleModel: function () {
- var model = shr.customer.StorefrontBudgetEdit.superClass.assembleModel.call(this);
- model.NumberOfPractical = $("#NumberOfPractical").val();
- return model;
- },
-
- });
- //根据门店编码和时间获取实际人数
- function getNumByStoreFrontNumber(storeId,time){
- var url = shr.getContextPath() + "/dynamic.do?handler=com.kingdee.eas.custom.newpreparation.web.customer.StorefrontBudgetEditHandler&method=getNumByStoreFrontNumber";
- shr.ajax({
- async: false,
- type: 'post',
- data: {
- storeId: storeId,
- time: time
- },
- url: url,
- success: function (res) {
- if(res.data){
- $("#NumberOfPractical").val(res.data);
- }else{
- $("#NumberOfPractical").val(0);
- }
- }
- });
- }
- function verifyTime(billId,hrNumber,time){
- var url = shr.getContextPath() + "/dynamic.do?handler=com.kingdee.eas.custom.newpreparation.web.customer.StorefrontBudgetEditHandler&method=verifyTime";
- var arr = new Array();
- shr.ajax({
- async:false,
- type:'post',
- data :{
- billId : billId,
- hrNumber : hrNumber,
- time : time
- },
- url:url,
- success:function(res){
- arr[0] =res.data.num;
- arr[1] =res.data.startPreparedMonth;
- arr[2] =res.data.openDate;
- }
- });
- return arr;
- }
|