zoukankan      html  css  js  c++  java
  • Edojs应用

    记录一个edojs的各种实现页面代码,是实现公司的工作周报的各种需求,edojs脚本库对于前台构造还是非常给力的,只是苦于相关应用文档太少,很多东西都是自己一点点try出来的,记录一下,以便日后复用和修正。

     这是自己有史以来一个页面里写的JS代码最多的一次,1600+行的JS。。代码上传都不能一次上传,只能分段。

      1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="OAWeekItemListEdit.aspx.cs"
    2 Inherits="OAWeekItemListEdit" %>
    3
    4 <html xmlns="http://www.w3.org/1999/xhtml">
    5 <head id="Head1" runat="server">
    6 <title></title>
    7 <script type="text/javascript" language="javascript" src="../lib/SysMain.js"></script>
    8 <script type="text/javascript" language="javascript" src="../Lib/SysEditMainFunction.js"></script>
    9 <script type="text/javascript" language="javascript" src="../lib/SysOpenWin.aspx"></script>
    10 <script type="text/javascript" language="javascript" src="../lib/SysInput.js"></script>
    11 <script type="text/javascript" language="javascript" src="../lib/SysList.js"></script>
    12 <link href="../Themes/Default/SysStyle.css" rel="stylesheet" type="text/css" />
    13 <link href="../Lib/edo/scripts/edo/res/css/edo-all.css" rel="stylesheet" type="text/css" />
    14 <link href="../Lib/edo/scripts/edo/res/skins/gray/skin.css" rel="stylesheet" type="text/css" />
    15 <link href="../Lib/edo/ifcaskin/style.css" rel="stylesheet" type="text/css" />
    16 <script src="../Lib/edo/scripts/edo/edo.js" type="text/javascript"></script>
    17 <script src="../Lib/jquery-1.3.2.min.js" type="text/javascript"></script>
    18 <script src="../Lib/edo/scripts/edo/locale/en.js" type="text/javascript"></script>
    19 <script src="js/WeekCommon.js" type="text/javascript"></script>
    20 <style type="text/css">
    21 .weekButtonBgColor
    22 {
    23 background-color: #8C84B3;
    24 }
    25 .selectBox
    26 {
    27 150px;
    28 float: left;
    29 margin-left: 10px;
    30 }
    31 .e-datepicker-year
    32 {
    33 background-image: none;
    34 font-size: 12px;
    35 }
    36 .e-datepicker-month
    37 {
    38 background-image: none;
    39 font-size: 12px;
    40 }
    41 </style>
    42 <script type="text/javascript" defer="defer">
    43 var dateFormat = '<%=dateFormat %>';
    44 var init_accountcode = false;
    45 // 初始化项目
    46 var init_project = false;
    47 // 初始化本周日期
    48 var init_Date = [];
    49 // 时间格式
    50 var dateFormat = "dd/MM/yyyy";
    51 //
    52 //初始化当前日期
    53 var _currYear=<%= Year %>;
    54 var _currWeek=<%= Week %>;
    55 var time = new Date();
    56 var init_CostItem = false;
    57 var day;
    58 var date;
    59
    60 // $("td[id$='BillAble']").children().click( function() {
    61 // alert('aa');
    62 // });
    63 // function f_init() {
    64 // f_initData();
    65 // f_initDate();
    66 //
    67 // }
    68 // }
    69 // 初始化
    70 // function f_initData() {
    71 function f_init() {
    72 f_initDate();
    73 var MessageCollection = { Title: "", Tip: "Loading...", Pic: "Wait", Buttons: [] };
    74 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    75
    76 // WeekItemService.GetAccountCodeList(
    77 // function (result) {
    78 // if (result) {
    79 // var json = Edo.util.Json.decode(result);
    80 // init_accountcode = Edo.data.ArraytoTree(json, 'AccountCodeID', 'ParentID');
    81 //
    82 // f_initcontrol();
    83 // MessageClose();
    84 // }
    85 // else{
    86 // MessageClose();
    87 // var MessageCollection = { Title: 'Alert', Tip: 'Please do account code setting first!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_initok()"}] };
    88 // if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    89 // return;
    90 // }
    91 // }
    92 // );
    93 // 初始化科目及项目数据信息
    94
    95 WeekItemEditService.GetAccountCodeProjectCost(
    96 function (result) {
    97 if (result) {
    98 var entity = Edo.util.Json.decode(result);
    99 var code = entity.accountcode;
    100 var project = entity.project;
    101 var cost = entity.cost;
    102
    103 if (code.length <= 0 && project.length <= 0) {
    104 MessageClose();
    105 var MessageCollection = { Title: '', Tip: 'Code, project and cost item can not be empty!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_initok()"}] };
    106 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    107 return;
    108 }
    109 if (code.length <= 0) {
    110 MessageClose();
    111 var MessageCollection = { Title: '', Tip: 'Code can not be empty!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_initok()"}] };
    112 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    113 return;
    114 }
    115
    116 if (project.length <= 0) {
    117 MessageClose();
    118 var MessageCollection = { Title: '', Tip: 'Project can not be empty!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_initok()"}] };
    119 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    120 return;
    121 }
    122 //2012年3月14日10:32:30 by Jxb 取消费项为空时的判断。
    123 // if (cost.length <= 0) {
    124 // MessageClose();
    125 // var MessageCollection = { Title: '', Tip: 'Cost item can not be empty!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_initok()"}] };
    126 // if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    127 // return;
    128 // }
    129
    130 init_accountcode = Edo.data.ArraytoTree(code, 'AccountCodeID', 'ParentID');
    131 init_project = Edo.data.ArraytoTree(project, 'ProjectID', 'ParentID');
    132 init_CostItem = cost;
    133
    134
    135 //f_initcontrol();
    136
    137 MessageClose();
    138
    139 }
    140 else {
    141
    142 MessageClose();
    143 var MessageCollection = { Title: '', Tip: 'Code and project can not be empty!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_initok()"}] };
    144 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    145 return;
    146 }
    147 //f_initGrid();
    148 }
    149 );
    150 f_initGrid();
    151 }
    152
    153 function f_initok() {
    154 window.close();
    155 }
    156
    157 // 根据周得到开始结束日期
    158 function getDateByWeek(year, week) {
    159 if (year == "" || week == "")
    160 return;
    161 ;
    162 var firstDate = new Date(year, 0, 1);
    163 firstDate.setDate(firstDate.getDay() == 1 ? ((week) * 7) : (parseInt("1065432".charAt(firstDate.getDay())) + (week) * 7));
    164 return getFirstAndEnd(firstDate);
    165 }
    166 //返回指定日期是所在年份的第几周
    167 function GetWeek(temp) {
    168 //alert("aa");
    169 ;
    170 //alert("bb");
    171 var date1 = new Date(temp);
    172 var Year = date1.getYear();
    173 var Month = date1.getMonth();
    174 var Day = date1.getDate();
    175
    176 // var d1 = new Date(Year, Month, Day);
    177 // var d2 = new Date(Year, 0, 1);
    178 // var d = Math.round((d1 - d2) / 86400000) - 1;
    179 // var Week = Math.ceil((d + ((d2.getDay() + 1) - 1)) / 7);
    180 // alert(Week);
    181
    182
    183 var day1 = new Date(Year, Month, Day);
    184 var day2 = new Date(Year, 0, 1);
    185
    186 var firstweek = day2.getDay(); //1月1日是星期几
    187 if (firstweek == 0) {
    188 firstweek = 6;
    189 } else {
    190 firstweek = firstweek - 1;
    191 } //转化为0表示星期一,6表示星期日
    192 firstweek = (7 - firstweek) % 7; //计算1月1日离第一周的天数
    193 var day3 = new Date(Year, 0, 1 + firstweek)
    194 var result = Math.round((day1.getTime() - day3.getTime()) / (1000 * 60 * 60 * 24));
    195 result = Math.floor(result / 7) + 1; //这个地方应该用floor返回最小次数然后+1
    196 //alert(result);
    197 return result;
    198
    199
    200 //return Week;
    201 }
    View Code
      1         // 得到某一周有开始日期和结束日期
    2 function getFirstAndEnd(date) {
    3 var w = date.getDay(), n = 24 * 60 * 60 * 1000;
    4 var begin = new Date(date.getTime() - parseInt("6012345".charAt(w)) * n);
    5 var end = new Date(begin.getTime() + parseInt("6543210".charAt(w)) * n);
    6 return { begin: begin, end: end };
    7 }
    8 // 星期列表
    9 var d = [
    10 "星期日",
    11 "星期一",
    12 "星期二",
    13 "星期三",
    14 "星期四",
    15 "星期五",
    16 "星期六"
    17 ];
    18 //当前日期
    19 var time;
    20 // 当前年
    21 var currentYear;
    22 // 当前周
    23 var currentWeek;
    24 // 当前周的开始时间
    25 var FormDate = false;
    26 // 当前周的结束时间
    27 var endDate = false;
    28
    29 function f_changeweek(time) {
    30 if (time.getDay() == 0) day = "Sun."
    31 if (time.getDay() == 1) day = "Mon."
    32 if (time.getDay() == 2) day = "Tues."
    33 if (time.getDay() == 3) day = "Wed."
    34 if (time.getDay() == 4) day = "Thurs."
    35 if (time.getDay() == 5) day = "Fri."
    36 if (time.getDay() == 6) day = "Sat."
    37 }
    38 function f_changedate(time) {
    39 var t = time.getDate();
    40 if (t < 10) {
    41 t = '0' + t;
    42 }
    43 date = t;
    44 }
    45
    46 // 日历控件初始化
    47 function f_initDate() {
    48 var d = new Date();
    49 // d.setTime(d.getTime() - 30 * 24 * 3600 * 1000);
    50
    51 new Edo.controls.Date().set({
    52 id: "sltTargetDate",
    53 format: dateFormat,
    54 readOnly: true,
    55 date: d,
    56 ondatechange: function (e) {
    57
    58 time = e.date;
    59 // alert(time);
    60 if(_currYear==0)
    61 currentYear = time.getYear();
    62 // alert(currentYear);
    63 if(_currWeek==0)
    64 currentWeek = GetWeek(time);
    65 // alert(currentWeek);
    66 // f_createcolumns(currentYear, currentWeek)
    67 // f_initData();
    68 f_initGrid();
    69 },
    70 render: document.getElementById("sltTargetDate")
    71
    72 });
    73 }
    74 //判断当前日期是
    75 // 创建列
    76 function f_createcolumns(year, week)
    77 {
    78 var listcolumns = [];
    79 var weekDate = getDateByWeek(year, week);
    80 FormDate = weekDate.begin;
    81 endDate = weekDate.end;
    82 var i = 0;
    83 var AccountCodeID = false;
    84
    85 var temp =
    86 [
    87 {
    88 header: "Activity Code", dataIndex: 'CodeName', id: 'CodeName', enableMove: false, enableResize: false,
    89 editor: {
    90 type: 'trigger',
    91 readOnly: true,
    92
    93
    94 onbeforeeditcomplete: function (e) {
    95 if (winCode && winCode.isDisplay())
    96 return false;
    97 },
    98 ontrigger: function (e) {
    99 var winCode = getWinCode();
    100 winCode.show('center', 'middle', true);
    101 }
    102 },
    103 renderer: function (value, record, column, rowIndex, data, table)
    104 {
    105 return (value==""||value==null)?"":"<span title=\""+value+"\">"+value+"</span>";
    106 }
    107
    108 },
    109 { header: "Charge To", dataIndex: "ProjectName", id: "ProjectName", enableMove: false, enableResize: false,
    110 renderer:function (value, record, column, rowIndex, data, table)
    111 {
    112 return (value==""||value==null)?"":"<span title=\""+value+"\">"+value+"</span>";
    113 },
    114 editor:
    115 {
    116 type: 'trigger',
    117 readOnly: true,
    118 onbeforeeditcomplete: function (e)
    119 {
    120 if (winProject && winProject.isDisplay())
    121 {
    122 return false;
    123 }
    124 },
    125 ontrigger: function (e)
    126 {
    127 var selected = tabWeekItem.data.getSelected();
    128 var codeID = selected.AccountCodeID;
    129 if (codeID) {
    130 var codeName = GetParentCode(codeID, init_accountcode);
    131
    132 var winProject = getWinProject(codeName);
    133 winProject.show('center', 'middle', true);
    134 treeProject.data.clearFilter();
    135 if (codeName != "") {
    136 treeProject.data.filter(function (o, i) {
    137 if (o.children == null && o.ParentID == null) {
    138 return false;
    139 }
    140 if (o.ProjectType.toLowerCase() == codeName.toLowerCase())
    141 {
    142 if (o.ProjectType.toLowerCase() == ("OA_Administration").toLowerCase()) {
    143 return false;
    144 }
    145 return true;
    146 }
    147 return false;
    148 });
    149 }
    150 }
    151 }
    152 }
    153 },
    154 { header: "Description", dataIndex: "Description", id: "Description", enableMove: false, enableResize: false,
    155 editor: {
    156 type: 'textarea',
    157 oneditstart: function (e) {
    158 this.minWidth = 200;
    159 this.minHeight = 100;
    160 }
    161 },
    162 renderer:function(v,r)
    163 {
    164 if (r.Type == "total") return "";
    165 else return "<span title='"+v+"'>"+v+"</span>";
    166 }
    167 },
    168 { header: "Ref. NO.", dataIndex: "JIRANO", id: "JIRANO", enableMove: false, enableResize: false, align: 'center', editor: 'text', 25,
    169 renderer: function (value, record, column, rowIndex, data, table) {
    170 return value;
    171 }
    172 },
    173 {
    174 header: "Billable", dataIndex: "BillAble", id: "BillAble", enableMove: false, enableResize: false, 33,
    175 editor:
    176 {
    177 type:'checkBox',
    178 minWidth:30,
    179 align: 'right'
    180 },
    181
    182 renderer: function (value,record)
    183 {
    184
    185 if (record.Type == "total")
    186 return '<span style="text-align:center;color:Red;font-weight:bolder;">Grand Total</span>';
    187 else
    188 {
    189
    190 if (value!=null) {
    191 if (value.toString()=="true")
    192 return '<span style="color:Red">√</span>';
    193 else if(value.toString()=="false") return 'X';
    194 else
    195 return value;
    196 }
    197 else return 'X';
    198 }
    199 }
    200 }
    201 ];
    202
    203 listcolumns.push({ header: '', columns: temp, enableMove: false, enableResize: false,
    204 renderer: function (value, record, column, rowIndex, data, table) {
    205 if (record.Type == "total")
    206 return '<span class="listTitle" style="text-align:left">Grand Total</span>';
    207 }
    208 });
    209 init_Date = [];
    210 for (var i = 0; i < 7; i++)
    211 {
    212 temp = [];
    213 FormDate.setDate(FormDate.getDate() + i);
    214
    215 var _year = FormDate.getYear();
    216 var _month = FormDate.getMonth();
    217 var _day = FormDate.getDate();
    218 var _newDate = new Date(_year, _month, _day);
    219
    220 init_Date.push({ id: _newDate, text: FormDate.format("dd/MM/yyyy") });
    221 f_changeweek(FormDate);
    222 f_changedate(FormDate);
    223 temp.push({ header: day, dataIndex: 'UseTime_' + i, name: 'UseTime_' + i, enableMove: false, enableResize: false, type: 'text', align: 'right', 20, editor: { type: 'spinner', minValue: 0, maxValue: 24, align: 'right' },
    224 renderer: function (v, r, column, rowIndex, data, table) {
    225
    226 var _sum = false;
    227 if (r.Type == "total") {
    228
    229 for (var j = 0; j < rowIndex; j++) {
    230 _sum += data.source[j][column.name];
    231 //data;
    232 }
    233 if (_sum) {
    234 if (_sum>=24) {
    235 return "<span style='color:red;'><h1>" + _sum + "</h1></span>";
    236 }
    237 else return "<h1>"+_sum+"</h1>";
    238 }
    239 else
    240 return "<h1>" + v + "</h1>";
    241 }
    242 else return v ;
    243 }
    244
    245 });
    246 if (time.getDay() == FormDate.getDay())
    247 listcolumns.push({ header: '<span style="color:red;">' + date + '</span>', columns: temp, enableMove: false, enableResize: false });
    248 else {
    249 listcolumns.push({ header: date, columns: temp, enableMove: false, enableResize: false
    250
    251 });
    252 }
    253 FormDate.setDate(FormDate.getDate() - i);
    254 }
    255
    256 listcolumns.push({ header: "Total", dataIndex: "Sum_UseTime", id: "Sum_UseTime", align: 'right', enableMove: false, enableResize: false,20,
    257 renderer: function (v, r) {
    258
    259 var sum = false;
    260 for (var i = 0; i < 7; i++) {
    261 sum += r["UseTime_" + i];
    262 }
    263 if (sum)
    264 return "<h1>"+sum+"</h1>";
    265 else
    266 return 0;
    267 }
    268 });
    269 listcolumns.push({ header: "Expenses", dataIndex: "Amount", id: "Amount", align: 'right', enableMove: false, enableResize: false,25,
    270 editor: {
    271 type: 'trigger',
    272 readOnly: true,
    273 onbeforeeditcomplete: function (e) {
    274 if (winAmount && winAmount.isDisplay())
    275 return false;
    276 },
    277 ontrigger: function (e,r) {
    278 //debugger;
    279 var selected = tabWeekItem.getSelected();
    280 //弹出费项设置窗
    281 if(selected.CodeFullName=="Project.Project") _BillableFlag=true;
    282 else _BillableFlag=false;
    283 var winAmount = getWinAmount();
    284 winAmount.show('center', 'middle', true);
    285
    286 if (selected.AmountData) {
    287 tableAmount.set('data', selected.AmountData);
    288 var r = tableAmount.data.getSource();
    289 if(!_BillableFlag)
    290 {
    291 for(var j=0;j<r.length;j++){
    292 //debugger;
    293 tableAmount.data.update(r[j], "BillAble", false);
    294 }
    295 }
    296
    297 } else {
    298 tableAmount.set('data', '');
    299 }
    300 }
    301 }
    302
    303 });
    304
    305
    306 return listcolumns;
    307 }
    View Code
            function GetParentCode(codeID, data){
    //init_accountcode
    ;
    var len = data.length;
    var CodeName = "";
    for(var i=0; i<len; i++ ){
    if(!data[i].ParentID)
    CodeName = data[i].AccountCode;

    if(data[i].AccountCodeID == codeID)
    break;

    if(data[i].children.length > 0){
    if(GetChildrenCode(codeID, data[i].children))
    return CodeName;
    }
    }
    return "";
    }

    function GetChildrenCode(codeID, data){
    var len = data.length;
    for(var i=0; i<len; i++ ){

    if(data[i].AccountCodeID == codeID)
    return true;

    if(data[i].children.length > 0){
    if(GetChildrenCode(codeID, data[i].children))
    return true;
    }
    }
    return false;
    }

    // function f_resetdate(data){
    //
    var result = [];
    //
    if(data && data.length>0){
    //
    for(var i=0;i<data.length;i++){
    //
    var temp = data[i];
    //
    temp.Datetime = new Date(temp.Datetime.getYear(), temp.Datetime.getMonth(), temp.Datetime.getDate());
    //
    result.push(temp);
    //
    }
    //
    return result;
    //
    }else{
    //
    return '';
    //
    }
    //
    }
    function f_initGrid() {
    var tdContent = document.getElementById("tdContent");
    var tab = document.getElementById('tabWeekItem');
    if (tab)
    tabWeekItem.destroy();

    new Edo.lists.TreeGrid()
    .set({
    cls: 'e-toolbar',
    id: 'tabWeekItem',
    tdContent.offsetWidth,
    height: tdContent.offsetHeight,
    render: tdContent,

    showHeader: true,
    rowSelectMode: 'multi',
    enableDragDrop: false,
    autoColumns: true,
    cellDirtyVisible: true,
    summaryRowVisible: true,
    summaryRowPosition: 'bottom',
    foolterVisible: false,
    enableCellEdit: true,

    editAction: 'click',

    columns: f_createcolumns(currentYear, currentWeek),
    onselectionchange: function (e) {
    var r = this.getSelecteds();
    if (r) {
    }
    }
    });
    // return;
    //编辑结束触发事件
    tabWeekItem.on('submitedit', function (e) {
    //----------------------------------------------------------
    if (this.data.indexOf(e.record) == this.data.getCount() - 1) {
    return false;
    }
    if (e.columnIndex >= 4 && e.columnIndex <= 10) {
    var _sum = false;
    //this.data.getCount() - 1
    for (var j = 0; j <= this.data.getCount() - 2; j++) {
    // if (j == e.rowIndex) {
    // continue;
    // }
    _sum += this.data.source[j][e.field];
    }
    if (_sum) {
    if (_sum > 24) {
    //alert("The day has been accumulated hours in excess of 24 hours, please re-enter!");
    //
    var MessageCollection = { Title: ' ', Tip: 'The day has been accumulated hours in excess of 24 hours, please re-enter!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    //
    if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    //
    e.value = e.oldValue;
    }
    }
    }

    //-----------------------------------------------------------
    // debugger;
    var record = e.record;
    var column = e.column;
    var cellValue = e.value;
    //replace(new RegExp(reallyDo, 'g'), replaceWith);
    if (e.columnIndex >= 2 && e.columnIndex <= 3)
    {
    cellValue=cellValue.replace(new RegExp("'", 'g'), "‘");
    }
    //cellValue=cellValue.replace(new RegExp("'", 'g'), "‘");
    var id = column.id;
    var dataIndex = column.dataIndex;
    if (dataIndex.toLowerCase() == "codename" && id.toLowerCase() == "codename") {
    tabWeekItem.data.update(record, "AccountCodeID", cellValue.AccountCodeID);
    tabWeekItem.data.update(record, "CodeName", cellValue.CodeName);
    tabWeekItem.data.update(record, "CodeFullName", cellValue.CodeFullName);
    //更改Code 联动改变

    //tabWeekItem.data.update(record, "AmountData", record.AmountData.clear());
    tabWeekItem.data.update(record, "ProjectID", 0);
    tabWeekItem.data.update(record, "ProjectName", "");
    tabWeekItem.data.update(record, "RefTable", "");
    tabWeekItem.data.update(record, "BillAble", false);
    } else if (dataIndex.toLowerCase() == "projectname" && id.toLowerCase() == "projectname") {
    tabWeekItem.data.update(record, "ProjectID", cellValue.ProjectID);
    tabWeekItem.data.update(record, "ProjectName", cellValue.ProjectName);
    tabWeekItem.data.update(record, "RefTable", cellValue.RefTable);

    } else if (dataIndex.toLowerCase() == "amount" && id.toLowerCase() == "amount") {
    tabWeekItem.data.update(record, "Amount", cellValue.Amount);
    tabWeekItem.data.update(record, "AmountData", cellValue.AmountData);
    } else {
    tabWeekItem.data.update(record, dataIndex, cellValue);
    }
    });
    tabWeekItem.on('beforecelledit', function (e) {
    //alert(this.data.indexOf(e.record));
    //alert(this.data.getCount() - 1);
    // debugger;
    if (this.data.indexOf(e.record) == this.data.getCount() - 1) {
    //document.getElementById("Save").disabled = true;
    // document.getElementById("Add").disabled = true;
    document.getElementById("Delete").disabled = true;
    var SubFlag=false;
    for (var i = 0; i < tabWeekItem.data.source.length-1; i++) {

    if(tabWeekItem.data.source[i].RecordStatus=='Active' || tabWeekItem.data.source[i].RecordStatus=='Rejected'|| !tabWeekItem.data.source[i].RecordStatus)
    {
    SubFlag=true;
    }
    }
    if(SubFlag)
    document.getElementById("Submit").disabled = false;
    else document.getElementById("Submit").disabled = true;
    return false;
    }
    //debugger;
    if (!e.record.RecordStatus) {
    document.getElementById("Delete").disabled = false;
    document.getElementById("Submit").disabled = false;
    document.getElementById("Save").disabled = false;
    document.getElementById("Add").disabled = false;

    }
    else {
    if (e.record.RecordStatus != "Active" && e.record.RecordStatus != "Rejected") {
    //document.getElementById("Save").disabled = true;
    // document.getElementById("Add").disabled = true;
    document.getElementById("Delete").disabled = true;
    document.getElementById("Submit").disabled = true;
    return false;
    }
    else {
    document.getElementById("Delete").disabled = false;
    document.getElementById("Submit").disabled = false;
    document.getElementById("Save").disabled = false;
    document.getElementById("Add").disabled = false;
    }

    }


    //判断changto 置灰
    if (e.columnIndex == 1) {
    var _selected = tabWeekItem.data.getSelected();
    var _codeID = _selected.AccountCodeID;
    if (_codeID) {
    var _codeName = GetParentCode(_codeID, init_accountcode);
    if (_codeName.toLowerCase() == ("OA_Administration").toLowerCase()) {
    return false;
    }
    }

    }
    //判断Billable 置灰
    if (e.columnIndex == 4) {
    var _selected = tabWeekItem.data.getSelected();
    var _codeID = _selected.AccountCodeID;
    if (_codeID) {
    var _codeName = GetParentCode(_codeID, init_accountcode);
    if (_codeName.toLowerCase() == ("OA_Project").toLowerCase()) {
    return true;
    }
    else return false;
    }

    }
    //2012年2月22日12:00:39 by:Jxb 判断当天的工时是否已经大于24,如果大于,不让输入
    if (e.columnIndex >= 5 && e.columnIndex <= 11) {

    e.editor.selectOnFocus=true;
    var _sum = false;
    for (var j = 0; j < e.rowIndex; j++) {
    _sum += this.data.source[j][e.field];
    }
    if (_sum) {
    if (_sum >= 24) {
    // return false;

    }
    }
    }
    });

    WeekItemService.GetWeekItemList(currentYear, currentWeek,
    function (result) {
    if (result) {

    var json = Edo.util.Json.decode(result);
    tabWeekItem.set('data', json);
    //2012年2月22日11:28:39 by Jxb 判断是否是合并列
    //debugger;
    if (json[0].Type != "total") {

    //2012年2月
    if (json[0].RecordStatus != "Active" && json[0].RecordStatus != "Rejected") {
    // tabWeekItem.set('enableCellEdit', false);
    // document.getElementById("Save").disabled = true;
    // document.getElementById("Add").disabled = true;
    // document.getElementById("Delete").disabled = true;
    // document.getElementById("Submit").disabled = true;
    document.getElementById("Save").disabled = false;
    document.getElementById("Add").disabled = false;
    document.getElementById("Delete").disabled = true;
    document.getElementById("Submit").disabled = true;


    } else {
    document.getElementById("Save").disabled = false;
    document.getElementById("Add").disabled = false;
    document.getElementById("Delete").disabled = false;
    document.getElementById("Submit").disabled = true;
    }
    }
    else {
    //tabWeekItem.set('enableCellEdit', false);
    document.getElementById("Save").disabled = false;
    document.getElementById("Add").disabled = false;
    document.getElementById("Delete").disabled = true;
    document.getElementById("Submit").disabled = true;
    }
    } else {
    document.getElementById("Save").disabled = false;
    document.getElementById("Add").disabled = false;
    document.getElementById("Delete").disabled = false;
    }
    }
    );
    }
    View Code
      1         //生成科目弹出窗口
    2 var winCode;
    3 function getWinCode() {
    4 if (!winCode) {
    5 var treeCode = new Edo.lists.TreeGrid().set({
    6 id: "treeCode",
    7 cls: 'e-tree-allow',
    8 600,
    9 height: 400,
    10 autoColumns: false,
    11 rowHeight: 22,
    12 //展开收缩节点列
    13 treeColumn: 'CodeName',
    14 columns: [
    15 { header: 'Name', id: 'CodeName', dataIndex: 'CodeName', 300 },
    16 { header: 'Description', id: 'Description', dataIndex: 'Description', 200 }
    17 ],
    18 data: init_accountcode
    19 });
    20 treeCode.on("itemdblclick", function(e){
    21 var r = e.record;
    22 if (r && r.__hasChildren || r.__pid == -1) {
    23 return;
    24 }
    25
    26 tabWeekItem.submitEdit(r ? {AccountCodeID:r.AccountCodeID, CodeName: r.CodeName, CodeFullName: r.CodeFullName} : null);
    27 this.parent.parent.hide();
    28 });
    29
    30
    31 winCode = new Edo.containers.Window();
    32
    33 winCode.set({
    34 title: 'Activity Code',
    35 titlebar: [{
    36 cls: 'e-titlebar-close',
    37 onclick: function () {
    38 tabWeekItem.cancelEdit();
    39 this.parent.owner.hide();
    40 }
    41 }],
    42 verticalGap: 0,
    43 children: [{
    44 type: 'box',
    45 style: 'background-color:Transparent;',
    46 '100%',
    47 minWidth: 600,
    48 minHeight: 400,
    49 layout: 'vertical',
    50 children: [treeCode]
    51 }, {
    52 type: 'ct',
    53 cls: 'e-dialog-toolbar',
    54 '100%',
    55 layout: 'horizontal',
    56 height: 28,
    57 horizontalAlign: 'center',
    58 verticalAlign: 'bottom',
    59 horizontalGap: 10,
    60 children: [{
    61 type: 'button',
    62 text: 'OK',
    63 minWidth: 70,
    64
    65 onclick: function (e) {
    66 //将选中的数据, 设置到选中行的列属性上.
    67 var r = treeCode.getSelected();
    68
    69 if (r && r.__hasChildren || r.__pid == -1) {
    70 alert("Please select children!");
    71 return ;
    72 }
    73
    74 if (r && r.AccountCodeID ) {
    75 var codeid = r.AccountCodeID;
    76 var itemlist = tabWeekItem.data.source;
    77 for(var i = 0; i < itemlist.length; i++) {
    78 if(codeid == itemlist[i].AccountCodeID) {
    79 alert("Code is exists!");
    80 return ;
    81 }
    82 }
    83 }
    84
    85 if (r && !r.__hasChildren) {
    86 tabWeekItem.submitEdit(r ? {AccountCodeID:r.AccountCodeID, CodeName: r.CodeName, CodeFullName: r.CodeFullName} : null);
    87 this.parent.parent.hide();
    88 }
    89 else {
    90 alert("Please select children!");
    91 }
    92 }
    93 }, {
    94 type: 'button',
    95 text: 'Cancel',
    96 minWidth: 70,
    97 onclick: function (e) {
    98 tabWeekItem.cancelEdit();
    99 this.parent.parent.hide();
    100 }
    101 }]
    102 }]
    103 });
    104 }
    105 return winCode;
    106 }
    107 // 生成项目弹出窗口
    108 var winProject;
    109 function getWinProject(_codeName) {
    110 if (winProject)
    111 winProject.destroy();
    112
    113 var treeProject = null;
    114 if (_codeName.toLowerCase() == "oa_Product".toLowerCase()) {
    115 treeProject = new Edo.lists.TreeGrid().set({
    116 id: "treeProject",
    117 cls: 'e-tree-allow',
    118 700,
    119 height: 400,
    120 autoColumns: true,
    121 rowHeight: 22,
    122 //展开收缩节点列
    123 treeColumn: 'ProjectName',
    124 columns: [
    125 { header: 'Product Name', id: 'ProjectName', dataIndex: 'ProjectName', 300 },
    126 { header: 'Description', id: 'Description', dataIndex: 'Description', 200 }
    127 ],
    128
    129 data: init_project
    130 });
    131 }
    132 else if(_codeName.toLowerCase() == "oa_Project".toLowerCase()){
    133 treeProject = new Edo.lists.TreeGrid().set({
    134 id: "treeProject",
    135 cls: 'e-tree-allow',
    136 700,
    137 height: 400,
    138 autoColumns: true,
    139 rowHeight: 22,
    140 //展开收缩节点列
    141 treeColumn: 'ProjectName',
    142 columns: [
    143 { header: 'Project Name', id: 'ProjectName', dataIndex: 'ProjectName', 300 },
    144 { header: 'Company', id: 'CompanyID', dataIndex: 'CompanyName', 200 },
    145 { header: 'Description', id: 'Description', dataIndex: 'Description', 200 }
    146 ],
    147 data: init_project
    148 });
    149 }
    150 else if(_codeName.toLowerCase() == "oa_marketing".toLowerCase()){
    151 treeProject = new Edo.lists.TreeGrid().set({
    152 id: "treeProject",
    153 cls: 'e-tree-allow',
    154 700,
    155 height: 400,
    156 autoColumns: true,
    157 rowHeight: 22,
    158 //展开收缩节点列
    159 treeColumn: 'ProjectName',
    160 columns: [
    161 { header: 'Market Name', id: 'ProjectName', dataIndex: 'ProjectName', 300 },
    162 { header: 'Company', id: 'CompanyID', dataIndex: 'CompanyName', 200 },
    163 { header: 'Description', id: 'Description', dataIndex: 'Description', 200 }
    164 ],
    165 data: init_project
    166 });
    167 }
    168 else {
    169 treeProject = new Edo.lists.TreeGrid().set({
    170 id: "treeProject",
    171 cls: 'e-tree-allow',
    172 700,
    173 height: 400,
    174 autoColumns: true,
    175 rowHeight: 22,
    176 //展开收缩节点列
    177 treeColumn: 'ProjectName',
    178 columns: [
    179 { header: 'Prospect Name', id: 'ProjectName', dataIndex: 'ProjectName', 300 },
    180 { header: 'Company', id: 'CompanyID', dataIndex: 'CompanyName', 200 },
    181 { header: 'Description', id: 'Description', dataIndex: 'Description', 200 }
    182 ],
    183 data: init_project
    184 });
    185 }
    186 treeProject.on("itemdblclick", function(e){
    187 var r = e.record;
    188 if (r && r.__hasChildren) {
    189 return;
    190 }
    191 var RefTable = r.ProjectID.split('_')[0] + "_" + r.ProjectID.split('_')[1];
    192 var ProjectID = r.ProjectID.split('_')[2];
    193 tabWeekItem.submitEdit(r ? { RefTable: RefTable, ProjectID: ProjectID, ProjectName: r.ProjectName } : null);
    194 this.parent.parent.hide();
    195 });
    196
    197 winProject = new Edo.containers.Window();
    198
    199 winProject.set({
    200 title: 'Charge To',
    201 titlebar: [{
    202 cls: 'e-titlebar-close',
    203 onclick: function () {
    204 tabWeekItem.cancelEdit();
    205 this.parent.owner.hide();
    206 }
    207 }],
    208 verticalGap: 0,
    209 children: [{
    210 type: 'box',
    211 style: 'background-color:Transparent;',
    212 '100%',
    213 minWidth: 600,
    214 minHeight: 400,
    215 layout: 'vertical',
    216 children: [treeProject]
    217 }, {
    218 type: 'ct',
    219 cls: 'e-dialog-toolbar',
    220 '100%',
    221 layout: 'horizontal',
    222 height: 28,
    223 horizontalAlign: 'center',
    224 verticalAlign: 'bottom',
    225 horizontalGap: 10,
    226 children: [{
    227 type: 'button',
    228 text: 'OK',
    229 minWidth: 70,
    230 onclick: function (e) {
    231 //将选中的数据, 设置到选中行的列属性上.
    232 var r = treeProject.getSelected();
    233 if (r && r.__hasChildren) {
    234 alert("Please select children!");
    235 return;
    236 }
    237
    238 if (r && !r.__hasChildren) {
    239 var RefTable = r.ProjectID.split('_')[0] + "_" + r.ProjectID.split('_')[1];
    240 var ProjectID = r.ProjectID.split('_')[2];
    241 tabWeekItem.submitEdit(r ? { RefTable: RefTable, ProjectID: ProjectID, ProjectName: r.ProjectName} : null);
    242 this.parent.parent.hide();
    243 }
    244 else {
    245 alert("Please select children!");
    246 }
    247 }
    248 },
    249 {
    250 type: 'button',
    251 text: 'Cancel',
    252 minWidth: 70,
    253 onclick: function (e) {
    254 tabWeekItem.cancelEdit();
    255 this.parent.parent.hide();
    256 }
    257 }]
    258 }]
    259 });
    260 //}
    261 return winProject;
    262 }
    View Code
      1 //深拷贝JS数组
    2
    3 function getType(o)
    4 {
    5 var _t;
    6 return ((_t = typeof(o)) == "object" ? o==null && "null" || Object.prototype.toString.call(o).slice(8,-1):_t).toLowerCase();
    7 }
    8 function extend(destination,source)
    9 {
    10 for(var p in source)
    11 {
    12 if(getType(source[p])=="array"||getType(source[p])=="object")
    13 {
    14 destination[p]=getType(source[p])=="array"?[]:{};
    15 arguments.callee(destination[p],source[p]);
    16 }
    17 else
    18 {
    19 destination[p]=source[p];
    20 }
    21 }
    22 }
    23 //生成费用窗口
    24 var winAmount;
    25 var _BillableFlag=false;
    26
    27 function getWinAmount() {
    28 var _CostTemp=new Array();
    29 extend(_CostTemp,init_CostItem);
    30 for (var i = 0; i < _CostTemp.length; i++) {
    31 _CostTemp[i].CostItemName="<span title='"+_CostTemp[i].Description+"'>"+_CostTemp[i].CostItemName+"</span>";
    32
    33 }
    34 if (!winAmount)
    35 {
    36 new Edo.lists.TreeGrid().set({
    37 cls: 'e-toolbar',
    38 id: 'tableAmount',
    39 750,
    40 height: 400,
    41
    42 showHeader: true,
    43 rowSelectMode: 'multi',
    44 enableDragDrop: false,
    45 autoColumns: true,
    46 cellDirtyVisible: true,
    47 summaryRowVisible: true,
    48 summaryRowPosition: 'bottom',
    49 foolterVisible: false,
    50
    51 editAction: 'click',
    52
    53 columns:
    54 [
    55 { header: 'Date', id: 'Datetime', dataIndex: 'Datetime', 83, enableMove: false, enableResize: false,
    56 editor: {
    57 type: 'combo', data: init_Date, valueField: 'id', displayField: 'text'
    58 }
    59 ,
    60 renderer: function (value, record, column, rowIndex, data, table) {
    61 if (value) {
    62
    63 var _dd = new Date(value);
    64 for (var i = 0; i < init_Date.length; i++) {
    65 var o = init_Date[i];
    66 if (o.id.getTime() == value.getTime())
    67 return o.text;
    68 }
    69 }
    70
    71 }
    72 },
    73 { header: 'Expense Items Claim', id: 'WeekCostItemID', dataIndex: 'WeekCostItemID', 285,
    74 enableMove: false, enableResize: false,
    75 editor: {
    76 type: 'combo', data: _CostTemp, valueField: 'WeekCostItemID',
    77 displayField: 'Description',
    78 onselectionchange: f_costitem
    79 },
    80 renderer: function (value, record, column, rowIndex, data, table) {
    81 for (var i = 0; i < init_CostItem.length; i++)
    82 {
    83 var o = init_CostItem[i];
    84 if (o.WeekCostItemID == value) return "<span title='"+o.Description+"'>"+o.Description+"</span>";
    85 }
    86 }
    87 },
    88 { header: 'Description', id: 'Description', dataIndex: 'Description',175,
    89 enableMove: false, enableResize: false, editor: 'text'
    90 },
    91 { header: 'Expenses', id: 'Amount', dataIndex: 'Amount', 55, align: 'right',
    92 enableMove: false, enableResize: false,
    93 editor: {
    94 type: 'spinner', minValue: 0, align: 'right'
    95 }
    96 },
    97 { header: "Billable", dataIndex: "BillAble", id: "BillAble", 42, enableMove: false, enableResize: false,
    98 editor: {
    99 type:'checkBox',
    100 minWidth:30,
    101 align: 'right'},
    102
    103 renderer: function (value,record) {
    104 //debugger;
    105 if (record.Type == "total")
    106 return '<span style="text-align:center;color:Red;font-weight:bolder;">Grand Total</span>';
    107 else
    108 {
    109 //debugger;
    110 if (value!=null) {
    111 if (value.toString()=="true")
    112 {
    113 return '<span style="color:Red">√</span>';
    114 }
    115 else if(value.toString()=="false") return 'X';
    116 else
    117 return value;
    118 }
    119 else return 'X';
    120 }
    121 }}
    122 ],
    123
    124 onselectionchange: function (e) {
    125 var r = this.getSelecteds();
    126 if (r) {
    127 }
    128 }
    129 });
    130 tableAmount.on('beforecelledit', function (e)
    131 {
    132 //debugger;
    133 if (e.columnIndex==3) {
    134 e.editor.selectOnFocus=true;
    135 }
    136 if (e.columnIndex==4) {
    137 if(_BillableFlag)
    138 return true;
    139 else {
    140 return false};
    141 }
    142 });
    143 tableAmount.on("submitedit", function (e) {
    144 ;
    145 var record = e.record;
    146 var column = e.column;
    147 var cellValue = e.value;
    148
    149 //cellValue=cellValue.replace(new RegExp("'", 'g'), "‘");
    150 var id = column.id;
    151 var dataIndex = column.dataIndex;
    152 //debugger;
    153
    154
    155 if (id == "Datetime" && dataIndex == "Datetime") {
    156 if (cellValue) {
    157 //var _daform = new date(cellValue);
    158 tableAmount.data.update(record, dataIndex, cellValue);
    159 }
    160 else
    161 tableAmount.data.update(record, dataIndex, e.oldValue);
    162 } else {
    163 tableAmount.data.update(record, dataIndex, cellValue);
    164 }
    165
    166 });
    167
    168 winAmount = new Edo.containers.Window();
    169 //获取费用列表内容
    170
    171 winAmount.set({
    172 title: 'Expense Detail',
    173 titlebar:
    174 [{
    175 cls: 'e-titlebar-close',
    176 onclick: function ()
    177 {
    178 tabWeekItem.cancelEdit();
    179 this.parent.owner.hide();
    180 }
    181 }],
    182 verticalGap: 0,
    183 children: [{
    184 type: 'box',
    185 style: 'background-color:Transparent;',
    186 '100%',
    187 minWidth: 600,
    188 minHeight: 400,
    189 layout: 'vertical',
    190 children:
    191 [
    192 { type: 'ct',layout: 'horizontal',
    193 children: [
    194 {type: 'button', text: 'Add', height: 20, 50, arrowAlign:'right', onclick: f_AddTableAmount },
    195 {type: 'button', text: 'Delete', height: 20, 50,arrowAlign:'right', onclick: f_DeleteTableAmount },
    196 {type: 'button', text: 'Save', height: 20, 50,arrowAlign:'right',
    197 onclick: function(e){
    198 //将选中的数据, 设置到选中行的列属性上.
    199 var r = tableAmount.data.getSource();
    200 if (r) {
    201 var amt = 0;
    202 for(var n=0;n<r.length;n++){
    203 if(!r[n].Amount || !r[n].WeekCostItemID || !r[n].Datetime){
    204 Edo.MessageBox.alert("", "Date, Code and Expenses can not be null!");
    205 return false;
    206 }
    207 amt+= parseFloat(r[n].Amount);
    208 }
    209 //tabWeekItem.submitEdit(amt ? amt : null);
    210 //tabWeekItem.data.update(record, "AmountData", r);
    211 tabWeekItem.submitEdit(r ? { Amount: amt, AmountData: r } : null);
    212
    213 winAmount.hide();
    214 }
    215 else {
    216 Edo.MessageBox.alert("", "Please enter record!");
    217 }
    218 }
    219 },
    220 {type: 'button', text: 'Close', height: 20, 50,arrowAlign:'right',
    221 onclick: function (e) {
    222 tabWeekItem.cancelEdit();
    223 winAmount.hide();
    224 }
    225 }
    226 ]
    227 },
    228 tableAmount
    229 ]
    230 }
    231 // , {
    232 // type: 'ct',
    233 // cls: 'e-dialog-toolbar',
    234 // '100%',
    235 // layout: 'horizontal',
    236 // height: 28,
    237 // horizontalAlign: 'center',
    238 // verticalAlign: 'bottom',
    239 // horizontalGap: 10,
    240 // children: [{
    241 // type: 'button',
    242 // text: 'Submit',
    243 // minWidth: 70,
    244 // onclick: function (e) {
    245 // //将选中的数据, 设置到选中行的列属性上.
    246 // var r = tableAmount.data.getSource();
    247 // if (r) {
    248 // var amt = 0;
    249 // for(var n=0;n<r.length;n++){
    250 // amt+= parseFloat(r[n].Amount);
    251 // }
    252 // //tabWeekItem.submitEdit(amt ? amt : null);
    253 // //tabWeekItem.data.update(record, "AmountData", r);
    254 // tabWeekItem.submitEdit(r ? { Amount: amt, AmountData: r } : null);
    255 // this.parent.parent.hide();
    256 // }
    257 // else {
    258 // alert("Please select children!");
    259 // }
    260 // }
    261 // }, {
    262 // type: 'button',
    263 // text: 'Cancel',
    264 // minWidth: 70,
    265 // onclick: function (e) {
    266 // tabWeekItem.cancelEdit();
    267 // this.parent.parent.hide();
    268 // }
    269 // }]
    270 // }
    271 ]
    272 });
    273 }
    274
    275 return winAmount;
    276 }
    277
    278
    279 function f_costitem(e) {
    280 // debugger;
    281 var comboItem = e.selectedItem;
    282 var r = tableAmount.getSelected();
    283 // e.selectedItem.CostItemName="aa";
    284 if (comboItem) {
    285 for (var i = 0; i < init_CostItem.length; i++) {
    286 var o = init_CostItem[i];
    287 if (o.WeekCostItemID == comboItem.WeekCostItemID)
    288 {
    289 //debugger;
    290 e.source.set('text',o.Description);
    291 }
    292 //e.source.text=o.CostItemName;
    293 }
    294 }
    295
    296 }
    297 // var FromCItemID;
    298 // function f_costitem(e) {
    299 // var comboItem = e.selectedItem;
    300 // var r = tableAmount.getSelected();
    301 // if (comboItem) {
    302 // if (FromCItemID && FromCItemID == comboItem.WeekCostItemID)
    303 // return;
    304
    305 // tableAmount.submitEdit(r ? { WeekCostItemID: comboItem.WeekCostItemID, CostItemName: comboItem.CostItemName } : null);
    306 // tableAmount.data.update(tselected, 'WeekCostItemID', comboItem.WeekCostItemID);
    307 // tableAmount.data.update(tselected, 'CodeItemName', comboItem.CodeItemName);
    308
    309 // FromCItemID = comboItem.WeekCostItemID;
    310
    311 // CodeCombo.hidePopup();
    312 // }
    313 // }
    314
    315 // // 日期格式化
    316 // // 参数说明:date 要格式化的日期 Date 类型, format 日期的格式,如:"yyyy-MM-dd"
    317 // function formatDate(date, format) {
    318 // try {
    319 // var z = {
    320 // M: date.getMonth() + 1,
    321 // d: date.getDate(),
    322 // h: date.getHours(),
    323 // m: date.getMinutes(),
    324 // s: date.getSeconds()
    325 // };
    326 // format = format.replace(/(M+|d+|h+|m+|s+)/g, function (v) {
    327 // return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-2);
    328 // });
    329 // return format.replace(/(y+)/g, function (v) {
    330 // return date.getFullYear().toString().slice(-v.length);
    331 // });
    332 // } catch (e) {
    333 // return "";
    334 // }
    335 // }
    336
    337 function CostDetailEntity()
    338 {
    339 this.Week='';
    340 this.Description='';
    341 this.WeekCostItemID=0;
    342 this.CostItemName='';
    343 this.Amount=0;
    344 }
    345 function f_AddTableAmount(){
    346 var data = tableAmount.data.getSource()
    347 var i = data.length;
    348 tableAmount.data.insert(i,
    349 new CostDetailEntity(),
    350 false);
    351 }
    352 function f_DeleteTableAmount(){
    353 var selected = tableAmount.getSelected();
    354 if(selected){
    355 Edo.MessageBox.confirm("", "Confirm to delete selected record?", function(action, value){
    356 if(action=='yes')
    357 tableAmount.data.remove(selected);
    358 });
    359 } else {
    360 Edo.MessageBox.alert("", "Please select a record!");
    361 }
    362 }
    View Code
      1 function tabWeekItemData() {
    2 this.WeekID = 0;
    3 this.WeekMasterID = 0;
    4 this.AccountCodeID = 0;
    5 this.CodeName = '';
    6 this.CodeFullName = '';
    7 this.RefTable = '';
    8 this.ProjectID = 0;
    9 this.ProjectName = '';
    10 this.JIRANO = '';
    11 this.Description = '';
    12 this.UseTime_0 = 0;
    13 this.UseTime_1 = 0;
    14 this.UseTime_2 = 0;
    15 this.UseTime_3 = 0;
    16 this.UseTime_4 = 0;
    17 this.UseTime_5 = 0;
    18 this.UseTime_6 = 0;
    19 this.Sum_UseTime = 0;
    20 this.Amount = 0;
    21 this.AmountData = [];
    22 }
    23
    24 function f_add() {
    25 var data = tabWeekItem.data.getSource();
    26 var i = data.length-1;
    27 tabWeekItem.data.insert(i,new tabWeekItemData(), false);
    28 }
    29
    30 function f_delete() {
    31 var selecteds = tabWeekItem.getSelecteds();
    32 if (selecteds.length > 0) {
    33 var MessageCollection = { Title: '', Tip: 'Are you sure to delete?', Pic: "Remind", Buttons: [{Name: 'Yes', Event: "f_confirm()"},{Name: 'No', Event: "f_cancle()"}] };
    34 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    35 } else {
    36 alert("Please select a record!");
    37 }
    38 }
    39
    40 function f_save() {
    41 var week = {
    42 WeekID: 0,
    43 Year: currentYear,
    44 Week: currentWeek,
    45 StartTime: FormDate,
    46 EndTime: endDate,
    47 Remark: '',
    48 RecordStatus: 'Active'
    49 }
    50
    51 var jsonWeek = Edo.util.Json.encode(week);
    52
    53 var alldata = tabWeekItem.data.source;
    54 var datalist = Edo.util.JSON.encode(alldata);
    55
    56 var addlist = tabWeekItem.data.getAdded();
    57
    58 //datalist = Edo.util.JSON.encode(addlist); //by jxb;
    59 var updatelist = tabWeekItem.data.getUpdated();
    60 var deletelist = tabWeekItem.data.getDeleted();
    61
    62 // 未填写任何信息,请填写
    63
    64 if(tabWeekItem.data.getCount()<=0) {
    65 var MessageCollection = { Title: ' ', Tip: 'Can not save without enter information!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    66 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    67 return;
    68 }
    69 // 未做任何修改
    70 if(addlist.length<=0 && updatelist.length<=0 && deletelist.length<=0) {
    71 var MessageCollection = { Title: ' ', Tip: 'No update!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    72 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    73 return;
    74 }
    75 // 科目名称不能为空
    76 for (var i = 0; i < alldata.length; i++) {
    77 if (alldata[i].CodeName == '') {
    78 var MessageCollection = { Title: ' ', Tip: 'Code Name can not null!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    79 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    80 return;
    81 }
    82 var _codeID = alldata[i].AccountCodeID;
    83 if (_codeID) {
    84 var _codeName = GetParentCode(_codeID, init_accountcode);
    85 if (_codeName.toLowerCase() != ("OA_Administration").toLowerCase() && _codeName.toLowerCase() != ("OA_Marketing").toLowerCase()) {
    86 if (alldata[i].ProjectName == '') {
    87 var MessageCollection = { Title: ' ', Tip: 'Charge To can not null!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    88 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    89 return;
    90 }
    91 }
    92 }
    93 }
    94
    95 var MessageCollection = { Title: ' ', Tip: 'Saving, please wait...', Pic: "Wait", Buttons: [] };
    96 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    97
    98 WeekItemService.SaveWeekItem(jsonWeek, datalist, function (result) {
    99 if (result == "success") {
    100 MessageClose();
    101 var MessageCollection = { Title: ' ', Tip: 'Save Successful!', Pic: "Successful", Buttons: [{ Name: 'OK', Event: "f_ok()"}] };
    102 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    103 try{
    104 opener.f_refresh();
    105 }catch(e){
    106 }
    107 } else {
    108 MessageClose();
    109 alert(result);
    110 }
    111 });
    112
    113 return false;
    114 }
    115
    116
    117 function f_SubmitSave() {
    118 var week = {
    119 WeekID: 0,
    120 Year: currentYear,
    121 Week: currentWeek,
    122 StartTime: FormDate,
    123 EndTime: endDate,
    124 Remark: '',
    125 RecordStatus: 'Active'
    126 }
    127
    128 var jsonWeek = Edo.util.Json.encode(week);
    129
    130 var alldata = tabWeekItem.data.source;
    131 var datalist = Edo.util.JSON.encode(alldata);
    132
    133 var addlist = tabWeekItem.data.getAdded();
    134
    135 //datalist = Edo.util.JSON.encode(addlist); //by jxb;
    136 var updatelist = tabWeekItem.data.getUpdated();
    137 var deletelist = tabWeekItem.data.getDeleted();
    138
    139
    140 // 科目名称不能为空
    141 for (var i = 0; i < alldata.length; i++) {
    142 if (alldata[i].CodeName == '') {
    143 var MessageCollection = { Title: ' ', Tip: 'Code Name can not null!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    144 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    145 return;
    146 }
    147 var _codeID = alldata[i].AccountCodeID;
    148 if (_codeID) {
    149 var _codeName = GetParentCode(_codeID, init_accountcode);
    150 if (_codeName.toLowerCase() != ("OA_Administration").toLowerCase() && _codeName.toLowerCase() != ("OA_Marketing").toLowerCase()) {
    151 if (alldata[i].ProjectName == '') {
    152 var MessageCollection = { Title: ' ', Tip: 'Charge To can not null!', Pic: "Remind", Buttons: [{ Name: 'OK', Event: "f_vailok()"}] };
    153 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    154 return;
    155 }
    156 }
    157 }
    158 }
    159
    160 // var MessageCollection = { Title: ' ', Tip: 'Saveing,Please Wait...', Pic: "Wait", Buttons: [] };
    161 // if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    162
    163 WeekItemService.SaveWeekItem(jsonWeek, datalist, function (result) {
    164 if (result == "success") {
    165 MessageClose();
    166 f_initGrid();
    167 SaveSuccessSubmit(); //-------------------------------------------------------保存成功后提交!
    168 try {
    169 opener.f_refresh();
    170
    171 } catch (e) {
    172 }
    173 } else {
    174 MessageClose();
    175 alert(result);
    176 }
    177 });
    178
    179 return false;
    180 }
    181
    182 function f_close() {
    183 window.close();
    184 }
    185
    186 function f_ok() {
    187 // 保存完成重新加载页面
    188 //location.href="OAWeekItemListEdit.aspx?Year="+currentYear+"&Week="+currentWeek;
    189 f_search();
    190 }
    191 function _RefreshPage() {
    192 // 保存完成重新加载页面
    193 location.href="OAWeekItemListEdit.aspx?Year="+currentYear+"&Week="+currentWeek;
    194 // f_search();
    195 }
    196
    197 function f_vailok() {
    198 MessageClose();
    199 }
    200
    201 function f_confirm() {
    202 var selecteds = tabWeekItem.getSelecteds();
    203 if (selecteds.length > 0) {
    204 tabWeekItem.data.removeRange(selecteds);
    205 }
    206 }
    207
    208 function f_cancle() {
    209 MessageClose();
    210 }
    211 function f_search() {
    212 f_initGrid();
    213 }
    214
    215 // 提交审核
    216 function f_submit() {
    217 f_SubmitSave();
    218 }
    219 function SaveSuccessSubmit() {
    220 var MessageCollection = { Title: '', Tip: 'Are you sure you want to submit your time report?', Pic: "Remind", Buttons: [{Name: 'Yes', Event: "_SubMessage()"},{Name: 'No', Event: "f_cancle()"}] };
    221 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    222 }
    223 function _SubMessage()
    224 {
    225 var r = tabWeekItem.data.source[0];
    226 if (r) {
    227 if (r.WeekID > 0) {
    228 document.all.myframe.src = "../Workflow/WorkflowStart.aspx?ET=IFCA.OA.WF.OA_WF_Week&EK=0&CID=<%= CompanyID %>&CurID=" + r.WeekID;
    229 //alert('<%= _SubmitSuccessCode %>');
    230 var MessageCollection = { Title: ' ', Tip: '<%= _SubmitSuccessCode %>', Pic: "Successful", Buttons: [{ Name: 'OK', Event: "_RefreshPage()"}] };
    231 if (typeof MessageCollection != "undefined") { MessageShow(MessageCollection); }
    232 }
    233 else {
    234 alert('<%= _NoDataCode %>');
    235 }
    236 }}
    237
    238 </script>
    239 </head>
    240 <body onload="try{f_init();}catch(e){alert('7');}" scroll="no">
    241 <form id="form1" runat="server">
    242 <asp:ScriptManager ID="ScriptManager1" runat="server">
    243 <Services>
    244 <asp:ServiceReference Path="../WebService/OA/WeekItemService.asmx" InlineScript="true" />
    245 <asp:ServiceReference Path="../WebService/OA/WeekItemEditService.asmx" InlineScript="true" />
    246 </Services>
    247 </asp:ScriptManager>
    248 <table style=" 100%; height: 100%" cellpadding="0" cellspacing="0" border="0">
    249 <tr>
    250 <td style=" 100%; height: 20px" valign="top">
    251 <IFCAUI:SysToolbar ID="SysToolBar1" runat="server" Style=" 100%;" Title=""
    252 MenuClass="OA.WeekClass" MenuNo="OA.Week-02" ShowFilter="false" ShowQryCondition="false"
    253 ShowFloatMenu="false" ShowSettingMenu="false" ShowPrintBtn="false" ShowTitleImg="false">
    254 </IFCAUI:SysToolbar>
    255 </td>
    256 </tr>
    257 <tr>
    258 <td style=" 100%;">
    259 <fieldset class="search_bg" style=" auto;">
    260 <legend style="margin-left: 10px;">
    261 <%=IFCA.Framework.BL.Strings.GetString("SearchByCriteria")%></legend>
    262 <table border="0" bgcolor="#e0e4f0" height="35" class="search_bg">
    263 <tr>
    264 <td style="padding-left: 10px" width="90%">
    265 <%--<span class="search_title"><span class="star">*</span>Year</span>
    266 <select id="sltYear" style="float:left;100px;border:1px solid #000;" onchange="f_sltYearChange()"></select>--%>
    267 <span class="search_title" style="float: left; padding-right: 5px;">Target Date</span>
    268 <div id="sltTargetDate" class="selectBox">
    269 </div>
    270 </td>
    271 <td style=" 20%;" align="right">
    272 <a id="a1" style="cursor: hand; visibility: visible">
    273 <img src='../Themes/Default/Images/Search1.gif' border='0' onclick="f_search()" />
    274 </a>&nbsp;&nbsp;&nbsp;&nbsp;
    275 </td>
    276 </tr>
    277 </table>
    278 </fieldset>
    279 </td>
    280 </tr>
    281 <tr>
    282 <td>
    283 </td>
    284 </tr>
    285 <tr>
    286 <td style=" 100%; height: 100%" valign="top" id="tdContent">
    287 </td>
    288 </tr>
    289 </table>
    290 <iframe id="myframe" style="display: none;"></iframe>
    291 </form>
    292 </body>
    293 </html>







  • 相关阅读:
    【转】解决UpdatePanel 与 jQuery的冲突
    服务器控件的使用注意事项
    2019年8月12日星期一(系统编程)
    2019年8月9日星期五(系统编程)
    2019年8月8日星期四(系统编程)
    2019年8月1日星期四(数据结构)
    2019年7月30日星期二(数据结构)例题代码
    2019年7月31日星期三(数据结构)
    2019年7月30日星期二(数据结构)
    2019年7月29日星期一(文件IO)
  • 原文地址:https://www.cnblogs.com/Loofah/p/2423747.html
Copyright © 2011-2022 走看看