<!--pages/invoiceList/components/info/index.wxml-->
<view class="cardWrapper">
  <card title="发票详情">
    <view 
      slot="operate" 
      class="cardOperate"
      wx:if="{{editType === 'detail' && user.isAdmin}}"
      bind:tap="changeEditType"
    > 
      <van-icon name="edit" /> 
      <view class="editContent">修改</view> 
    </view>
    
    <view slot="content">
      <view wx:if="{{editType === 'detail'}}">
        <van-field
          label="发票类型"
          readonly="{{true}}"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ false }}"
          value="普通发票"
          wx:if="{{detail.type === 0}}"
        />
        <van-field
          label="发票类型"
          readonly="{{true}}"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ false }}"
          value="增值税专用发票"
          wx:elif="{{detail.type === 1}}"
        />
        <van-field
          label="发票类型"
          readonly="{{true}}"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ false }}"
          value="-"
          wx:elif="{{detail.type === 1}}"
        />
        <van-field
          label="抬头类型"
          readonly="{{true}}"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ false }}"
          value="企业单位"
          wx:if="{{detail.headerType === 0}}"
        >
          <view 
            slot="input" 
            style="margin-top: -10rpx;"
          > 
            <view wx:if="{{detail.headerType === 0}}"> 企业单位 </view>
            <view wx:elif="{{detail.headerType === 1}}"> 个人/非企业单位 </view>
            <view wx:else>-</view>
          </view>
        </van-field>
        <van-field
          label="抬头类型"
          readonly="{{true}}"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ false }}"
          value="个人/非企业单位"
          wx:elif="{{detail.headerType === 1}}"
        />
        <van-field
          label="抬头类型"
          readonly="{{true}}"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ false }}"
          value="个人/非企业单位"
          wx:else
        />

        <van-field
          value="{{detail.name || '-'}}"
          label="发票抬头"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{true}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ false }}"
        >
        </van-field>
        <van-field
          label="发票税号"
          value="{{detail.tin || '-'}}"
          wx:if="{{detail.headerType === 0}}"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
        >
        </van-field>
        <van-field
          value="{{detail.bank || '-'}}"
          label="开户行"
          wx:if="{{detail.headerType === 0}}"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
        >
        </van-field>
        <van-field
          label="银行账号"
          value="{{detail.account || '-'}}"
          wx:if="{{(detail.headerType === 0)}}"
          placeholder="{{editType === 'edit' ? '请输入银行账号' : ''}}"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
          bind:change="onChangeText"
          data-name="account"
        >
        </van-field>
        <van-field
          label="地址"
          wx:if="{{(detail.headerType === 0)}}"
          placeholder="{{editType === 'edit' ? '请输入地址' : ''}}"
          custom-style="padding-left: 0; padding-right: 0; height: auto;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
          bind:change="onChangeText"
          data-name="address"
          value="{{detail.address || '-'}}"
        >
        </van-field>
        <van-field
          label="电话"
          wx:if="{{editType === 'detail' }}"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
          bind:change="onChangeText"
          data-name="tenementPhone"
          value="{{detail.tenementPhone || '-'}}"
        >
        </van-field>
        <van-field
          label="备注"
          wx:if="{{editType === 'detail' }}"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
          bind:change="onChangeText"
          data-name="remark"
          value="{{detail.remark || '-'}}"
        >
        </van-field>
      </view>
      <view wx:else>
        <van-field
          label="发票类型"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ true }}"
        >
          <view slot="input" style="margin-top: 16rpx;">
            <van-radio-group direction="horizontal" value="{{formData.type}}" bind:change="onChangeType">
              <van-radio name="{{0}}" icon-size="30rpx" style="font-size: 30rpx;margin-bottom: 20rpx;">普通发票</van-radio>
              <van-radio name="{{1}}" icon-size="30rpx" style="font-size: 30rpx;">增值税专用发票</van-radio>
            </van-radio-group>
          </view>
        </van-field>
        <van-field
          label="抬头类型"
          autosize="{{true}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ true }}"
        >
          <view slot="input" style="margin-top: 16rpx;">
            <van-radio-group direction="horizontal"  bind:change="onChangeHeaderType" value="{{formData.headerType}}">
              <van-radio name="{{0}}" icon-size="30rpx" style="font-size: 30rpx;margin-bottom: 20rpx;">企业单位</van-radio>
              <van-radio name="{{1}}" icon-size="30rpx" style="font-size: 30rpx;">个人/非企业单位</van-radio>
            </van-radio-group>
          </view>
        </van-field>
        <van-field
          wx:if="{{formData.headerType === 0 }}"
          value="{{formData.name || '--'}}"
          label="发票抬头"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{true}}"
          disabled="{{true}}"
          title-width="132rpx"
          border="{{ true }}"
        />
        <van-field
          wx:else
          value="{{formData.name}}"
          label="发票抬头"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          bind:change="onChangeText"
          data-name="name"
          bind:change="onChangeText"
          border="{{ true }}"
        />
        <van-field
          value="{{formData.tin }}"
          label="发票税号"
          wx:if="{{formData.headerType === 0}}"
          placeholder="{{'请输入发票税号'}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          bind:change="onChangeText"
          data-name="tin"
          border="{{true }}"
        />
        
        <van-field
          value="{{formData.bank}}"
          label="开户行"
          wx:if="{{ formData.headerType === 0}}"
          placeholder="{{'请输入开户行'}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ true }}"
          bind:change="onChangeText"
          data-name="bank"
        />
        
        <van-field
          value="{{formData.account}}"
          label="银行账号"
          wx:if="{{(formData.headerType === 0) }}"
          placeholder="{{'请输入银行账号' }}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{true }}"
          bind:change="onChangeText"
          data-name="account"
        />
      
        <van-field
          value="{{formData.address}}"
          label="地址"
          wx:if="{{(formData.headerType === 0)}}"
          placeholder="{{'请输入地址'}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ true }}"
          bind:change="onChangeText"
          data-name="address"
        />
        <van-field
          value="{{formData.tenementPhone}}"
          label="备注"
          placeholder="{{'请输入电话'}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{true }}"
          bind:change="onChangeText"
          data-name="tenementPhone"
        />
        <van-field
          value="{{formData.remark}}"
          label="电话"
          placeholder="{{'请输入备注'}}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{true }}"
          bind:change="onChangeText"
          data-name="remark"
        />
      </view>
      
    </view>
  </card>
</view>
<view class="cardWrapper" style="margin-bottom: 40rpx;">
  <card title="接收信息">
    <view slot="content"> 
      <view wx:if="{{editType === 'detail'}}">
        <van-field
          label="手机号"
          wx:if="{{(detail.headerType === 0)}}"
          placeholder="{{editType === 'edit' ? '请输入手机号' : ''}}"
          custom-style="padding-left: 0; padding-right: 0;"
          readonly="{{editType === 'detail'}}"
          autosize="{{true}}"
          title-width="132rpx"
          border="{{ editType === 'detail' ? false : true }}"
          bind:change="onChangeText"
          data-name="phone"
          value="{{detail.phone || '-'}}"
        >
        </van-field>
      </view>
      <view wx:else>
        <van-field
          value="{{formData.phone }}"
          label="手机号"
          wx:if="{{(formData.headerType === 0) }}"
          placeholder="{{ '请输入手机号' }}"
          custom-style="padding-left: 0; padding-right: 0;"
          title-width="132rpx"
          border="{{ true }}"
          bind:change="onChangeText"
          data-name="phone"
        />
      </view>
      <van-field
        value="{{detail.email || '--'}}"
        wx:if="{{editType === 'detail'}}"
        label="电子邮箱"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="email"
        value="{{detail.email || '-'}}"
      > 
      </van-field>
      <van-field
        value="{{formData.email}}"
        wx:else
        label="电子邮箱"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="email"
        placeholder="请输入电子邮箱"
      />
    </view>
  </card>
</view>

<view class="submit" wx:if="{{editType === 'edit'}}">
  <van-button block class="cancelEdit" bind:click="cancelEdit">取消编辑</van-button>
  <van-button type="info" block class="save" bind:click="submit">保存</van-button>
</view>