{
  "id": "scene-inventory",
  "version": "2024-12-24",
  "name": "库存台账：流水加一行，结存自己变",
  "category": "场景模板",
  "description": "一张出入库流水、一张物料清单，按 SKU 连起来。累计入库、累计出库、结存、库存金额、要不要补货，五列全是跨表算的。流水里加一行，物料清单当场变，再也不用月底盘一遍。",
  "locale": "zh_CN",
  "imageSrc": "",
  "vipOnly": false,
  "author": "TableDI",
  "tags": {
    "functions": []
  },
  "resourceCount": {
    "Sheet": 2,
    "Component": 3,
    "Dashboard": 1
  },
  "installations": 0,
  "resources": {
    "sheet1": {
      "key": "sheet1",
      "type": "Sheet",
      "name": "出入库流水",
      "content": {
        "sheet": {
          "name": "出入库流水",
          "uniqueIndex": {
            "uniqueHeaders": []
          },
          "headers": [
            {
              "title": "#",
              "meta": {
                "AUTO_SCALE": 3,
                "thousandPoint": false,
                "type": "Number",
                "decimal": 0
              }
            },
            {
              "title": "日期",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "SKU",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "方向",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "数量",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "备注",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "入库数",
              "formula": "IF({{$sheet1.headers[3].code}} = \"入库\", {{$sheet1.headers[4].code}}, 0)",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "出库数",
              "formula": "IF({{$sheet1.headers[3].code}} = \"出库\", {{$sheet1.headers[4].code}}, 0)",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            }
          ]
        },
        "entries": {
          "csv": "日期,SKU,方向,数量,备注\n2026-09-01,AC-1001,入库,60,补货—供应商甲\n2026-09-01,CB-2001,入库,200,补货—供应商甲\n2026-09-02,DS-3001,入库,12,补货—供应商乙\n2026-09-03,AC-1001,出库,14,订单 #4471\n2026-09-03,CB-2001,出库,45,订单 #4471\n2026-09-04,PW-4001,入库,80,补货—供应商甲\n2026-09-05,AC-1002,入库,40,补货—供应商丙\n2026-09-05,DS-3001,出库,3,订单 #4478\n2026-09-08,CB-2002,入库,90,补货—供应商甲\n2026-09-08,AC-1003,入库,24,补货—供应商丙\n2026-09-09,PW-4001,出库,22,订单 #4483\n2026-09-10,CB-2001,出库,38,订单 #4486\n2026-09-11,AC-1001,出库,19,订单 #4490\n2026-09-12,DS-3002,入库,16,补货—供应商乙\n2026-09-15,CB-2003,入库,120,补货—供应商甲\n2026-09-15,AC-1002,出库,11,订单 #4495\n2026-09-16,PW-4002,入库,36,补货—供应商丙\n2026-09-17,CB-2002,出库,27,订单 #4499\n2026-09-18,DS-3002,出库,5,订单 #4502\n2026-09-19,AC-1003,出库,7,订单 #4505\n2026-09-22,CB-2003,出库,64,订单 #4508\n2026-09-23,PW-4002,出库,9,订单 #4511\n2026-09-24,AC-1001,出库,12,订单 #4515\n2026-09-25,CB-2001,入库,150,补货—供应商甲\n2026-09-26,DS-3001,出库,4,订单 #4519\n2026-09-29,PW-4001,出库,17,订单 #4523"
        }
      }
    },
    "sheet2": {
      "key": "sheet2",
      "type": "Sheet",
      "name": "物料清单",
      "content": {
        "sheet": {
          "name": "物料清单",
          "uniqueIndex": {
            "uniqueHeaders": []
          },
          "headers": [
            {
              "title": "#",
              "meta": {
                "AUTO_SCALE": 3,
                "thousandPoint": false,
                "type": "Number",
                "decimal": 0
              }
            },
            {
              "title": "SKU",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "名称",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "类别",
              "meta": {
                "type": "Text"
              }
            },
            {
              "title": "单价",
              "meta": {
                "type": "Number",
                "decimal": 2,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "安全库存",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "累计入库",
              "formula": "SUMIF({{$sheet1.headers[6].code}}, {{$sheet2.headers[1].code}} = {{$sheet1.headers[2].code}})",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "累计出库",
              "formula": "SUMIF({{$sheet1.headers[7].code}}, {{$sheet2.headers[1].code}} = {{$sheet1.headers[2].code}})",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "结存",
              "formula": "{{$sheet2.headers[6].code}} - {{$sheet2.headers[7].code}}",
              "meta": {
                "type": "Number",
                "decimal": 0,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "库存金额",
              "formula": "{{$sheet2.headers[8].code}} * {{$sheet2.headers[4].code}}",
              "meta": {
                "type": "Number",
                "decimal": 2,
                "unit": "none",
                "thousandPoint": true
              }
            },
            {
              "title": "需补货",
              "formula": "IF({{$sheet2.headers[8].code}} < {{$sheet2.headers[5].code}}, \"补货\", \"正常\")",
              "meta": {
                "type": "Text"
              }
            }
          ]
        },
        "entries": {
          "csv": "SKU,名称,类别,单价,安全库存\nAC-1001,USB-C 扩展坞(7 口),配件,42.00,20\nAC-1002,笔记本支架,配件,31.50,15\nAC-1003,机械键盘,配件,89.00,10\nCB-2001,USB-C 数据线 2m,线材,9.80,60\nCB-2002,HDMI 线 3m,线材,12.40,40\nCB-2003,网线 5m,线材,7.20,50\nDS-3001,27 寸显示器,显示设备,268.00,6\nDS-3002,15 寸便携屏,显示设备,184.00,8\nPW-4001,65W 充电器,电源,28.90,30\nPW-4002,20000mAh 充电宝,电源,54.00,18"
        }
      }
    },
    "component1": {
      "key": "component1",
      "type": "Component",
      "name": "各类别库存金额",
      "content": {
        "@t": "next.component.pivot.table",
        "sheetId": "{{$sheet2.id}}",
        "type": "Pivot",
        "title": "各类别库存金额",
        "config": {
          "@t": "next.component.pivot.config",
          "pivotDataOption": {
            "@t": "next.component.pivot.config.data.option",
            "filters": {
              "@t": "core.or.filter",
              "filters": [],
              "type": "OR"
            },
            "simpleFilters": [],
            "orders": [],
            "rows": [],
            "columns": [
              {
                "@t": "next.component.pivot.config.textHeader.item",
                "headerId": "{{$sheet2.headers[3].id}}",
                "dataItemType": "TextHeader",
                "label": "类别",
                "showTotal": false,
                "meta": {
                  "@t": "next.component.pivot.table.meta.text",
                  "type": "Text"
                }
              }
            ],
            "values": [
              {
                "@t": "next.component.pivot.config.formula.item",
                "headerId": "{{$sheet2.headers[9].id}}",
                "calcType": "Sum",
                "formula": "",
                "dataItemType": "FormulaHeader",
                "label": "库存金额",
                "showTotal": false,
                "meta": {
                  "@t": "next.component.pivot.table.meta.number",
                  "type": "Number",
                  "decimal": 2,
                  "unit": "none",
                  "thousandPoint": true
                }
              }
            ],
            "aggregated": true
          },
          "displayType": "ChartColumnar",
          "configType": "Pivot"
        },
        "css": {
          "@t": "next.component.pivot.css",
          "titleSize": 15,
          "dataLabel": {
            "@t": "next.component.mixmap.css.datalable",
            "showRule": "AllShow",
            "fontSize": 12,
            "placement": "outSideTop",
            "intervalNumber": 0
          },
          "legendSize": 12,
          "axisLabel": {
            "@t": "next.component.pivot.css.axis",
            "fontSize": 12,
            "interval": 0,
            "rotate": 0
          },
          "horizontalDisplay": false,
          "chartPieDisplay": "Ring",
          "cssType": "Pivot",
          "background": {
            "@t": "next.component.css.background",
            "color": "#ffffff",
            "opacity": 1
          },
          "border": {
            "@t": "next.component.css.border",
            "opacity": 0,
            "color": "#CAD0D5"
          },
          "showTitle": true
        },
        "actions": []
      }
    },
    "component2": {
      "key": "component2",
      "type": "Component",
      "name": "要不要补货",
      "content": {
        "@t": "next.component.pivot.table",
        "sheetId": "{{$sheet2.id}}",
        "type": "Pivot",
        "title": "要不要补货",
        "config": {
          "@t": "next.component.pivot.config",
          "pivotDataOption": {
            "@t": "next.component.pivot.config.data.option",
            "filters": {
              "@t": "core.or.filter",
              "filters": [],
              "type": "OR"
            },
            "simpleFilters": [],
            "orders": [],
            "rows": [],
            "columns": [
              {
                "@t": "next.component.pivot.config.textHeader.item",
                "headerId": "{{$sheet2.headers[10].id}}",
                "dataItemType": "TextHeader",
                "label": "需补货",
                "showTotal": false,
                "meta": {
                  "@t": "next.component.pivot.table.meta.text",
                  "type": "Text"
                }
              }
            ],
            "values": [
              {
                "@t": "next.component.pivot.config.formula.item",
                "headerId": "{{$sheet2.headers[8].id}}",
                "calcType": "Count",
                "formula": "",
                "dataItemType": "FormulaHeader",
                "label": "结存",
                "showTotal": false,
                "meta": {
                  "@t": "next.component.pivot.table.meta.number",
                  "type": "Number",
                  "decimal": 0,
                  "unit": "none",
                  "thousandPoint": true
                }
              }
            ],
            "aggregated": true
          },
          "displayType": "ChartPie",
          "configType": "Pivot"
        },
        "css": {
          "@t": "next.component.pivot.css",
          "titleSize": 15,
          "dataLabel": {
            "@t": "next.component.mixmap.css.datalable",
            "showRule": "AllShow",
            "fontSize": 12,
            "placement": "outSideTop",
            "intervalNumber": 0
          },
          "legendSize": 12,
          "axisLabel": {
            "@t": "next.component.pivot.css.axis",
            "fontSize": 12,
            "interval": 0,
            "rotate": 0
          },
          "horizontalDisplay": false,
          "chartPieDisplay": "Ring",
          "cssType": "Pivot",
          "background": {
            "@t": "next.component.css.background",
            "color": "#ffffff",
            "opacity": 1
          },
          "border": {
            "@t": "next.component.css.border",
            "opacity": 0,
            "color": "#CAD0D5"
          },
          "showTitle": true
        },
        "actions": []
      }
    },
    "component3": {
      "key": "component3",
      "type": "Component",
      "name": "物料清单 · 结存与补货",
      "content": {
        "@t": "next.component.workbook",
        "sheetId": "{{$sheet2.id}}",
        "type": "Workbook",
        "title": "物料清单 · 结存与补货",
        "config": {
          "@t": "next.component.workbookConfig",
          "headers": [
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[1].id}}",
              "width": 100
            },
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[2].id}}",
              "width": 180
            },
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[3].id}}",
              "width": 110
            },
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[8].id}}",
              "width": 90
            },
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[9].id}}",
              "width": 110
            },
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[5].id}}",
              "width": 100
            },
            {
              "@t": "next.component.workbook.header",
              "id": "{{$sheet2.headers[10].id}}",
              "width": 90
            }
          ],
          "page": 0,
          "pageSize": 12,
          "editable": true,
          "filters": {
            "@t": "core.or.filter",
            "filters": [],
            "type": "OR"
          },
          "orders": [],
          "configType": "Workbook"
        },
        "css": {
          "@t": "next.component.workbook.css",
          "titleSize": 15,
          "headerSize": 14,
          "paginationSize": 11,
          "cssType": "Workbook",
          "background": {
            "@t": "next.component.css.background",
            "color": "#ffffff",
            "opacity": 1
          },
          "border": {
            "@t": "next.component.css.border",
            "opacity": 0,
            "color": "#CAD0D5"
          },
          "showTitle": true
        },
        "actions": []
      }
    },
    "dashboard1": {
      "key": "dashboard1",
      "type": "Dashboard",
      "name": "库存总览",
      "content": {
        "@t": "net.thingworks.jarvis.dashboard",
        "name": "库存总览",
        "components": [
          {
            "@t": "dashboard.component",
            "innerComponentId": "{{$component1.id}}",
            "position": {
              "@t": "dashboard.component.position",
              "x": 0,
              "y": 0,
              "w": 14,
              "h": 10
            }
          },
          {
            "@t": "dashboard.component",
            "innerComponentId": "{{$component2.id}}",
            "position": {
              "@t": "dashboard.component.position",
              "x": 14,
              "y": 0,
              "w": 10,
              "h": 10
            }
          },
          {
            "@t": "dashboard.component",
            "innerComponentId": "{{$component3.id}}",
            "position": {
              "@t": "dashboard.component.position",
              "x": 0,
              "y": 10,
              "w": 24,
              "h": 12
            }
          }
        ]
      }
    }
  }
}
