<!-- 添加食材 -->
<view class="container">
  <view class="page-title">{{editId ? '编辑食材' : '添加食材'}}</view>

  <view class="form-group">
    <text class="form-label">食材名称 *</text>
    <input class="form-input" placeholder="如：西红柿、鸡蛋" value="{{name}}" bindinput="onInput" data-field="name"/>
  </view>

  <view class="form-group">
    <text class="form-label">分类</text>
    <view class="cat-picker">
      <text class="cat-option {{category===item?'active':''}}" wx:for="{{['蔬菜','水果','肉类','海鲜','蛋奶','豆制品','调料','主食','其他']}}" wx:key="*this" bindtap="pickCat" data-cat="{{item}}">{{item}}</text>
    </view>
  </view>

  <view class="form-row">
    <view class="form-group half">
      <text class="form-label">数量</text>
      <input class="form-input" type="digit" placeholder="1" value="{{quantity}}" bindinput="onInput" data-field="quantity"/>
    </view>
    <view class="form-group half">
      <text class="form-label">单位</text>
      <input class="form-input" placeholder="个/斤/把" value="{{unit}}" bindinput="onInput" data-field="unit"/>
    </view>
  </view>

  <view class="form-group">
    <text class="form-label">保质期</text>
    <picker mode="date" value="{{expiryDate}}" bindchange="onDateChange">
      <view class="form-input picker">{{expiryDate || '选择日期（选填）'}}</view>
    </picker>
  </view>

  <view class="form-group">
    <text class="form-label">备注</text>
    <input class="form-input" placeholder="如：妈妈买的" value="{{notes}}" bindinput="onInput" data-field="notes"/>
  </view>

  <button class="btn-primary mt-30" bindtap="save">保存</button>

  <view class="mt-30 text-center text-muted">或</view>
  <button class="scan-btn mt-20" bindtap="scanBarcode">📷 扫条形码入库</button>
</view>
