username@email.com
2025-04-27 15eb82df2d6ec539e9d4245bfe08d531e8eb6379
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
var currentUserName;
initData = function () {
    if (window.taskid == '') {
        $.ajax({
            url: "/Fm_monthFundsChange/InitData",
            async: false,
            cache: false,
            dataType: "json",
            success: function (data) {
                currentUserName = data.CurrentUserName;
                var $data = data.children;
                for (var name in data) {
                    if (name !== "children") {
                        var $value = data[name];
                        if ($value != null && $value !== '') {
                            var $control = $(".main [field='" + name + "']");
                            var $controltype = $control.prop("tagName");
                            if ($controltype != null && $controltype !== '') {
                                var $type = $control.attr("type");
                                if ($type !== "radio" && $type !== "checkbox") {
                                    $(".main [field='" + name + "']").val($value);
                                }
                                if ($type === "radio") {
                                    $(".main [field='" + name + "'][value='" + $value + "']").attr("checked", "checked");
                                }
                                if ($type === "checkbox") {
                                    var $items = $(".main [field='" + name + "']");
                                    var $arr = $value.split(",");
                                    $.each($items, function (index, obj) {
                                        var value = $(obj).attr("value");
                                        if (contains($arr, value))
                                            $(obj).attr("checked", "checked");
                                    });
                                }
                            }
                        }
                    }
                }
 
            }
        });
    }
    $("#fm_month_funds_plan_change_dept_id").parent().parent().hide();//部门id
    $("#fm_month_funds_plan_change_supplier_id").parent().parent().hide();//供应商id
    $("#fm_month_funds_plan_change_projectName").parent().parent().hide();//项目名称
    
    var $txttitle = $("#txtTitle").text();
    currentUserNameStr = currentUserName ? "(" + currentUserName + ")" : "";
    $txttitle = $txttitle + currentUserNameStr;
    $("#fm_month_funds_plan_change_title").val($txttitle);
    addCSS();
    changeTextarea();
    //项目选择事件
    var $projectSelect = $("#fm_month_funds_plan_change_project_id");
    $projectSelect.change(function () {
        var text = $(this).find("option:selected").text();
        $("#fm_month_funds_plan_change_projectName").val(text);
        $("#fm_month_funds_plan_change_project_id_chosen").attr("title", text);
    });
    setTimeout(function () {
        $("#fm_month_funds_plan_change_project_id_chosen").attr("title", $("#fm_month_funds_plan_change_projectName").val());
    }, 1000);
    
    //绑定日期
    var $orderDate = $("#fm_month_funds_plan_change_createtime");
    $orderDate.val(JsonDateToDate($orderDate.val()).Format('yyyy-MM-dd'));
    //绑定物料选择事件
    $('#fm_month_funds_plan_change_supplier_name').bind('focus', function (i, r) {
        getmaterielinfo(this);
    }).attr("autocomplete", "off");
    //变更前计划付款总额
    addInputWan($("#fm_month_funds_plan_change_total_plan_money"), "back");
    //变更后计划付款总额
    addInputWan($("#fm_month_funds_plan_change_total_change_money"), "back");
    //设置样式
    $("#fm_month_funds_plan_change_total_plan_money,#fm_month_funds_plan_change_total_change_money").parent().parent().find(".form-item-title").css("line-height", "18px");
    
}
//选择计算金额
$(document).on('change', $('input[name="fm_month_funds_plan_change_dtl.before_money"],input[name="fm_month_funds_plan_change_dtl.after_money"]'), function (i, r) {
    countmoney();
});
 
 
//新增子项后触发事假
createMethod = function (materialCode, materialName, Unit, count) {
    changeTextarea();
}
//删除事件后触发操作
deleteMethod = function () {
    countmoney();
}
 
//选择供应商后绑定数据
var setCompanyInfo = function (id, name, UserName, Phone, BankName, BankDeposit, BankAccount) {
    $('#fm_month_funds_plan_change_supplier_id').val($.trim(id));
    $('#fm_month_funds_plan_change_supplier_name').val(name);
    $('#fm_month_funds_plan_change_supplier_bank').val(BankDeposit);
    $('#fm_month_funds_plan_change_supplier_account').val(BankAccount);
    $('#fm_month_funds_plan_change_supplier_accountName').val(BankName);
    layer.closeAll();
}
 
//收入单位选择
var getmaterielinfo = function () {
    layer.open({
        type: 2,
        title: '收款单位',
        shadeClose: true,
        shade: 0.4,
        area: ['90%', '90%'],
        content: "/oa/General/company"
    });
}
 
 
//计算总金额
var countmoney = function () {
    var allmoney_before = 0;
    var allmoney_after = 0;
    //变更前计划付款额
    $.each($('input[name="fm_month_funds_plan_change_dtl.before_money"]'), function () {
        var val = $.trim($(this).val());
        val = isNaN(Number(val)) ? 0 : val;
        allmoney_before = accAdd(allmoney_before, val);
    });
    //变更后计划付款额
    $.each($('input[name="fm_month_funds_plan_change_dtl.after_money"]'), function () {
        var val = $.trim($(this).val());
        val = isNaN(Number(val)) ? 0 : val;
        allmoney_after = accAdd(allmoney_after, val);
    });
    //主表变更前计划付款额
    var $totalPrice_before = $('#fm_month_funds_plan_change_total_plan_money');
    $totalPrice_before.val(allmoney_before).attr("title", allmoney_before);
    //主表变更后计划付款总额
    var $totalPrice_after = $('#fm_month_funds_plan_change_total_change_money');
    $totalPrice_after.val(allmoney_after).attr("title", allmoney_after);
}
 
// 验证重复元素,有重复返回true;否则返回false
function isexist(a) {
    return /(\x0f[^\x0f]+)\x0f[\s\S]*\1/.test("\x0f" + a.join("\x0f\x0f") + "\x0f");
}
 
//动态添加CSS样式
function addCSS() {
    var str_style = 'td{ position:relative;}\
                    .bl{position: relative;}\
                    .bl .back {position: absolute;top: 0;right: 5px;display: inline-block;}\
                    .bl .backdtl {position: absolute;top: 2px;right:10px;display: inline-block;}';
 
 
    if (document.all) { // document.createStyleSheet(url)
        window.style = str_style;
        document.createStyleSheet("javascript:style");
    } else { //document.createElement(style)
        var style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = str_style;
        document.getElementsByTagName('HEAD').item(0).appendChild(style);
    }
}
 
//在input后添加万元div
function addInputWan($input, className) {
    var div = createDivWan(className);
    $input.after(div);
    $input.parent().addClass("bl");
}
//创建div万元
function createDivWan(className) {
    var div = document.createElement("div");
    div.className = className;
    div.innerHTML = "万元";
    return div;
}
//把input改为textarea
function changeTextarea() {
    //业务内容
    $('input[name="fm_month_funds_plan_change_dtl.business_content"]').each(function (i, input) {
        var value = $.trim($(this).val());
        var textarea = createTextarea("fm_month_funds_plan_change_dtl", "business_content");
        changeInputCell(input, textarea, value);
    })
    //变更原因
    $('input[name="fm_month_funds_plan_change_dtl.change_reason"]').each(function (i, input) {
        var value = $.trim($(this).val());
        var textarea = createTextarea("fm_month_funds_plan_change_dtl", "change_reason");
        changeInputCell(input, textarea, value);
    })
}
 
//替换表格控件元素
function changeInputCell(input, newInput, value) {
    value = value || "";
    var $input = $(input);
    var $newInput = $(newInput);
    var parent = input.parentNode;
    $newInput.val(value);
    var hasEdit = $input.hasClass("edit");
    var isDisbale = $input.prop("disabled");
    isDisbale && newInput.setAttribute("disabled", "disabled");
    newInput.innerHTML = value;
    $input.remove();
    parent.appendChild(newInput);
}
 
//创建textarea
function createTextarea(table, name) {
    var textarea = document.createElement("textarea");
    textarea.className = "tex_inp left";
    textarea.id = table + "_" + name;
    textarea.name = table + "." + name;
    textarea.setAttribute("field", name);
    return textarea;
}
 
function setReadOnly() {
    $(".btn:last").parent().hide();
    $("input, textarea, select").attr("disabled", "disabled");
    $(".subtradd_js,.subtrdel_js").hide();
}
 
getQueryVariable = function (parameter) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] === parameter) { return pair[1]; }
    }
    return "";
}