<!--pages/updateInvoice/index.wxml-->
<navigator title="发票抬头" canBack="{{true}}" />
<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">
      <van-field
        label="发票类型"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        custom-style="padding-left: 0; padding-right: 0;"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
      >
        <view slot="input" style="margin-top: 16rpx;" wx:if="{{editType === 'edit'}}">
          <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>
        
        <view wx:else slot="input" style="margin-top: -10rpx;"> 
          <view wx:if="{{detail.type === 0}}"> 普通发票 </view>
          <view wx:elif="{{detail.type === 1}}"> 增值税专用发票 </view>
          <view wx:else>-</view>
        </view>
      </van-field>
      <van-field
        label="抬头类型"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        custom-style="padding-left: 0; padding-right: 0;"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
      >
        <view slot="input" style="margin-top: 16rpx;" wx:if="{{editType === 'edit'}}">
          <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>
        <view 
          wx:else  
          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
        wx:if="{{editType === 'detail'}}"
        value="{{detail.name || '--'}}"
        label="发票抬头"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{true}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ false }}"
      />
      <van-field
        wx:elif="{{editType === 'edit' }}"
        value="{{detail.name || '--'}}"
        label="发票抬头"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{true}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ false }}"
      />
      <van-field
        wx:else
        value="{{formData.name}}"
        label="发票抬头"
        custom-style="padding-left: 0; padding-right: 0;"
        disabled="{{formData.headerType !== 1}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        bind:change="onChangeText"
        data-name="name"
        bind:change="onChangeText"
        border="{{ true }}"
      />
      <van-field
        value="{{detail.tin|| '--'}}"
        label="发票税号"
        wx:if="{{editType === 'detail' && detail.headerType === 0}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
      />
      <van-field
        value="{{formData.tin }}"
        label="发票税号"
        wx:if="{{editType === 'edit' && formData.headerType === 0}}"
        placeholder="{{editType === 'edit' ? '请输入发票税号' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        bind:change="onChangeText"
        data-name="tin"
        border="{{ editType === 'detail' ? false : true }}"
      />
      <van-field
        value="{{detail.bank || '--'}}"
        label="开户行"
        wx:if="{{editType === 'detail' && detail.headerType === 0}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
      />
      <van-field
        value="{{formData.bank}}"
        label="开户行"
        wx:if="{{editType === 'edit' && formData.headerType === 0}}"
        placeholder="{{'请输入开户行'}}"
        custom-style="padding-left: 0; padding-right: 0;"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="bank"
      />
      <van-field
        value="{{detail.account || '--'}}"
        label="银行账号"
        wx:if="{{(editType === 'detail' && detail.headerType === 0)}}"
        placeholder="{{editType === 'edit' ? '请输入银行账号' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="account"
      />
      <van-field
        value="{{formData.account}}"
        label="银行账号"
        wx:if="{{(editType === 'edit' && formData.headerType === 0) }}"
        placeholder="{{editType === 'edit' ? '请输入银行账号' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="account"
      />
      <van-field
        value="{{detail.address || '--'}}"
        label="地址"
        wx:if="{{(editType === 'detail' && detail.headerType === 0)}}"
        placeholder="{{editType === 'edit' ? '请输入地址' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="address"
      />
      <van-field
        value="{{formData.address}}"
        label="地址"
        wx:if="{{(editType === 'edit' && formData.headerType === 0)}}"
        placeholder="{{editType === 'edit' ? '请输入地址' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="address"
      />
      <van-field
        value="{{detail.phone || '--'}}"
        label="电话"
        wx:if="{{(editType === 'detail' && detail.headerType === 0)}}"
        placeholder="{{editType === 'edit' ? '请输入电话' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="phone"
      />
      <van-field
        value="{{formData.phone }}"
        label="电话"
        wx:if="{{(editType === 'edit' && formData.headerType === 0) }}"
        placeholder="{{editType === 'edit' ? '请输入电话' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="phone"
      />
      <van-field
        value="{{detail.remark || '--'}}"
        label="备注"
        wx:if="{{editType === 'detail' }}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="remark"
      />
      <van-field
        value="{{formData.remark}}"
        label="备注"
        wx:else
        placeholder="{{editType === 'edit' ? '请输入备注' : ''}}"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="remark"
      />
    </view>
  </card>
</view>
<view class="cardWrapper" style="margin-bottom: 40rpx;">
  <card title="接收信息">
    <view slot="content"> 
      <van-field
        value="{{detail.email || '--'}}"
        wx:if="{{editType === 'detail'}}"
        label="电子邮箱"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="email"
      />
      <van-field
        value="{{formData.email}}"
        wx:else
        label="电子邮箱"
        custom-style="padding-left: 0; padding-right: 0;"
        readonly="{{editType === 'detail'}}"
        autosize="{{true}}"
        type="textarea"
        title-width="132rpx"
        border="{{ editType === 'detail' ? false : true }}"
        bind:change="onChangeText"
        data-name="email"
      />
    </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>