Browse Source

物料资料不复制从表数据

zhuth 7 years ago
parent
commit
29dd54e305
1 changed files with 41 additions and 0 deletions
  1. 41 0
      frontend/saas-web/app/view/document/product/FormController.js

+ 41 - 0
frontend/saas-web/app/view/document/product/FormController.js

@@ -51,6 +51,47 @@ Ext.define('saas.view.document.product.FormController', {
         });
 
     },
+
+    initCopyData: function(formData) {
+        var me = this;
+        var form = this.getView();
+        var detailCount = form.detailCount;
+        var main = formData.main;
+        var auditTexts = form.auditTexts;
+
+        // 单号、id清空
+        main[form._idField] = 0;
+        main[form._codeField] = '';
+        // 单据状态为录入状态(未审核)
+        main[form._statusCodeField] = auditTexts.unAuditCode;
+        main[form._statusField] = auditTexts.unAuditText;
+
+        for(var k in main) {
+            // 主表日期改为当前日期
+            if(saas.util.BaseUtil.isDateString(main[k])) {
+                main[k] = Ext.Date.format(new Date, 'Y-m-d H:i:s');
+            }
+        }
+
+        for(var j = 0; j < detailCount; j++) {
+            var grid = form.query('detailGridField')[j],
+            emptyRows = grid.emptyRows,
+            detnoColumn = grid.detnoColumn,
+            detno = 0,
+            datas = [];
+
+            Ext.Array.each(new Array(emptyRows), function() {
+                detno += 1;
+                var data = {};
+                data[detnoColumn] = detno;
+                datas.push(data);
+            })
+            formData['detail' + j] = datas;
+        }
+
+        return me.myInitCopyData(formData);;
+    },
+
     auditBtnClick: function() {
         var me = this,
         form = me.getView(),