浏览代码

导出调差工料消耗

ellisran 2 月之前
父节点
当前提交
6381fc9de6
共有 3 个文件被更改,包括 58 次插入0 次删除
  1. 54 0
      app/public/js/material_checklist.js
  2. 1 0
      app/view/material/checklist.ejs
  3. 3 0
      config/web.js

+ 54 - 0
app/public/js/material_checklist.js

@@ -1478,4 +1478,58 @@ $(document).ready(() => {
             return enObj
         })
     }
+
+    $('#exportExcel').click(function () {
+        const data = [];
+        const setting = {
+            cols: [
+                {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
+                {title: '工料编号', colSpan: '1', rowSpan: '2', field: 'gljcode', hAlign: 0, width: 80, formatter: '@'},
+                {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 220, formatter: '@'},
+                {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, type: 'Number'},
+                {title: '规格', colSpan: '1', rowSpan: '2', field: 'specs', hAlign: 0, width: 100, formatter: '@'},
+                {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 90, formatter: '@'},
+                {title: '单位耗量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 90, formatter: '@'},
+            ],
+            headRows: 2,
+            headRowHeight: [25, 25],
+            defaultRowHeight: 21,
+            headerFont: 'bold 10px 微软雅黑',
+            font: '10px 微软雅黑'
+        };
+        if (!materialChecklistData || materialChecklistData.length === 0) return;
+        for (const ml of materialChecklistData) {
+            data.push({
+                b_code: ml.b_code, name: ml.name, unit: ml.unit,
+                unit_price: ml.unit_price,
+            });
+            const index = _.findIndex(gclGatherData, { b_code: ml.b_code, name: ml.name, unit: ml.unit, unit_price: ml.unit_price });
+            if (index === -1) continue;
+            const gcl = gclGatherData[index];
+            if (gcl && gcl.leafXmjs) {
+                const gcl_ids = gcl.leafXmjs ? _.uniq(_.map(gcl.leafXmjs, 'gcl_id')) : [];
+                const newMaterialList = _.uniqBy(_.filter(gclList, function (m) {
+                    return _.indexOf(gcl_ids, m.gcl_id) !== -1;
+                }), 'mb_id');
+                for(const m of newMaterialList) {
+                    const bills = _.find(materialBillsData, { id: m.mb_id });
+                    if(bills) {
+                        m.code = bills.code;
+                        m.name = bills.name;
+                        m.unit = bills.unit;
+                    }
+                }
+                if (newMaterialList.length > 0) {
+                    for (const nm of newMaterialList) {
+                        data.push({
+                            gljcode: nm.code, name: nm.name, unit: nm.unit,
+                            quantity: nm.quantity,
+                        });
+                    }
+                }
+            }
+        }
+        SpreadExcelObj.exportSimpleXlsxSheet(setting, data, $('.sidebar-title').attr('data-original-title') + "-清单材料单位消耗量.xlsx");
+    });
+
 });

+ 1 - 0
app/view/material/checklist.ejs

@@ -29,6 +29,7 @@
             <div class="ml-auto">
                 <!--<a href="https://jiliang-qa.oss-cn-shenzhen.aliyuncs.com/loginimg/%E6%B8%85%E5%8D%95%E6%9D%90%E6%96%99%E5%8D%95%E4%BD%8D%E6%B6%88%E8%80%97%E9%87%8FExcel%E7%A4%BA%E4%BE%8B.xlsx" class="mx-2"-->
                    <!--data-toggle="tooltip" data-placement="top" title="" data-original-title="下载导入示例"><i class="fa fa-cloud-download"></i></a>-->
+                <button class="btn btn-primary btn-sm" id="exportExcel">导出清单工料单位消耗</button>
                 <button class="btn btn-primary btn-sm" id="upload-list">导入清单工料单位消耗</button>
                 <!--<input type="file" class="form-control-file" id="upload-list-file" style="display: none;" accept=".xls,.xlsx,.json">-->
             </div>

+ 3 - 0
config/web.js

@@ -841,6 +841,9 @@ const JsFiles = {
                     '/public/js/export/jschardet.min.js',
                     '/public/js/export/iconv-lite.js',
                     // '/public/js/calc/calcEval.min.js'
+                    '/public/js/spreadjs/sheets/v11/interop/gc.spread.excelio.11.2.2.min.js',
+                    '/public/js/file-saver/FileSaver.js',
+                    '/public/js/shares/export_excel.js',
                 ],
                 mergeFiles: [
                     '/public/js/sub_menu.js',