123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /**
- * Created by Zhong on 2017/12/20.
- */
- //定额章节节点说明、计算规则
- let explanatoryOprObj = {
- preTreeNode: null,
- currentTreeNode: null,//定额章节树节点
- currentExplanation: null,
- currentRuleText: null,
- setAttribute: function (preNode, currentNode, explanation, ruleText) {
- let me = explanatoryOprObj;
- me.preTreeNode = preNode;
- me.currentTreeNode = currentNode;
- me.currentExplanation = explanation;
- me.currentRuleText = ruleText;
- },
- clickUpdate: function (exarea, ruarea) {//解决编辑完后在未失去焦点的时候直接定额章节树
- let me = explanatoryOprObj;
- if(exarea.is(':focus')){
- let explanation = exarea.val();
- if(explanation !== me.currentExplanation){
- me.preTreeNode.data.explanation = explanation;
- me.unbindEvents(exarea, ruarea);
- exarea.blur();
- me.updateExplanation(pageOprObj.rationLibId, me.preTreeNode.getID(), explanation, function () {
- me.bindEvents(exarea, ruarea);
- });
- }
- }
- if(ruarea.is(':focus')){
- let ruleText = ruarea.val();
- if(ruleText !== me.currentRuleText){
- me.preTreeNode.data.ruleText = ruleText;
- me.unbindEvents(exarea, ruarea);
- ruarea.blur();
- me.updateRuleText(pageOprObj.rationLibId, me.preTreeNode.getID(), ruleText, function () {
- me.bindEvents(exarea, ruarea);
- });
- }
- }
- },
- unbindEvents: function (exarea, ruarea) {
- exarea.unbind();
- ruarea.unbind();
- },
- bindEvents: function (exEd, calcEd) {
- let me = explanatoryOprObj;
- exEd.on('change', function () {
- let node = me.currentTreeNode;
- let newData = exEd.getValue();
- if(node && node.data.explanation !== newData){
- me.updateExplanation(pageOprObj.rationLibId, node.getID(), newData, function () {
- node.data.explanation = newData;
- });
- }
- });
- calcEd.on('change', function () {
- let node = me.currentTreeNode;
- let newData = calcEd.getValue();
- if(node && node.data.ruleText !== newData){
- me.updateRuleText(pageOprObj.rationLibId, node.getID(), newData, function () {
- node.data.ruleText = newData;
- });
- }
- })
- /*exarea.bind('change', function () {
- let explanation = exarea.val();
- let node = me.currentTreeNode;
- exarea.attr('disabled', true);
- me.updateExplanation(pageOprObj.rationLibId, node.getID(), explanation, function () {
- node.data.explanation = explanation;
- exarea.attr('disabled', false);
- });
- });*/
- /*ruarea.bind('change', function () {
- let ruleText = ruarea.val();
- let node = me.currentTreeNode;
- ruarea.attr('disabled', true);
- me.updateRuleText(pageOprObj.rationLibId, node.getID(), ruleText, function () {
- node.data.ruleText = ruleText;
- ruarea.attr('disabled', false);
- });
- });*/
- },
- showText: function (exEd, calcEd, explanation, ruleText) {
- exEd.setValue(explanation && explanation !== 'undefined' ? explanation : '');
- calcEd.setValue(ruleText && ruleText !== 'undefined' ? ruleText : '');
- //exarea.val(explanation && explanation !== 'undefined' ? explanation : '');
- //ruarea.val(ruleText && ruleText !== 'undefined' ? ruleText : '');
- },
- //更新说明
- updateExplanation: function (repId, nodeId, explanation, callback) {
- $.ajax({
- type: 'post',
- url: 'api/updateExplanation',
- data: {lastOpr: userAccount, repId: pageOprObj.rationLibId, nodeId: nodeId, explanation: explanation},
- dataType: 'json',
- success: function () {
- callback();
- }
- });
- },
- //更新计算规则
- updateRuleText: function (repId, nodeId, explanation, callback) {
- $.ajax({
- type: 'post',
- url: 'api/updateRuleText',
- data: {lastOpr: userAccount, repId: pageOprObj.rationLibId, nodeId: nodeId, ruleText: explanation},
- dataType: 'json',
- success: function () {
- callback();
- }
- });
- }
- };
|