<template>
  <div class="app-container">
    <div>
      <div class="tab-header webtop">
        <div>{{ viewTitle }}</div>
        <div>
          <el-button type="primary" size="small" :disabled="submitdisabled" @click="handleSave()">保存
          </el-button>
          <el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
        </div>
      </div>
      <div class="listconadd">
        <el-form ref="form_obj" :model="baseManufacturerDto" :rules="rules" class="formadd">
          <div class="title">
            <div>基本信息</div>
          </div>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>厂商名称</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.manufacturerName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>简称</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.manufacturerAs }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>编码</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <el-input v-model="baseManufacturerDto.manufacturerCode" maxlength="20" placeholder="" class="addinputw" clearable/>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>分类</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.supplierTypeValue }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>通讯地址</span>
            </el-col>
            <el-col :span="20">
              <el-form-item>
                <span>{{ baseManufacturerDto.manufacturerAddress }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>厂商办公电话</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.manufacturerTelePhone }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>传真</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.manufacturerFax }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>联系人姓名</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.contactName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span><span class="icon">*</span>联系人手机号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.contactMobile }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>联系人办公电话</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.contactTelePhone }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>微信号</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.weChatID }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4" class="tleftb">
              <span>邮编</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.zipCode }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="4" class="tleftb">
              <span>邮箱</span>
            </el-col>
            <el-col :span="8">
              <el-form-item>
                <span>{{ baseManufacturerDto.email }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="title">
            <div>开户行信息</div>
          </div>
          <el-table :key="tableKey" :data="baseManufacturerBankDto" :index="index" border style="width: 100%">
            <el-table-column fixed width="60px" label="序号" type="index" :index="index + 1" align="center"/>
            <el-table-column prop="dueBankValue" width="140px" label="账户类型" align="center"/>
            <el-table-column prop="depositBank" width="180px" label="开户银行" align="center"/>
            <el-table-column prop="bankAccount" width="160px" label="银行账号" align="center"/>
            <el-table-column prop="accountName" width="130px" label="账号名称" align="center"/>
            <el-table-column prop="bankingOutlets" width="180px" label="银行网点" align="center"/>
            <el-table-column prop="bankAddress" width="260px" label="开户行地址" align="center"/>
            <el-table-column prop="paymentLines" width="160px" label="联行号" align="center"/>
            <el-table-column prop="swiftCode" width="200px" label="swiftcode(银行代码)" align="center"/>
            <el-table-column prop="currency" width="130px" label="币种" align="center"/>
            <el-table-column prop="remarks" width="240px" label="描述" align="center"/>
            <el-table-column prop="actualPay" width="240px" label="厂家销售通路" align="center"/>
            <el-table-column prop="paymentAccessNoValue" width="240px" label="付款通路编码" align="center"/>
          </el-table>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import req from '@/api/gongyingshang/gongyingshang'

export default {
  name: 'gongyingshangInfo',
  data() {
    return {
      tableKey: 0,
      index: 0,
      viewTitle: '',
      supplierType_list: [],
      baseManufacturerDto: {
        manufacturerName: '',
        manufacturerAs: '',
        manufacturerCode: '',
        supplierType: '',
        supplierTypeValue: '',
        manufacturerAddress: '',
        manufacturerTelePhone: '',
        manufacturerFax: '',
        contactName: '',
        contactMobile: '',
        contactTelePhone: '',
        weChatID: '',
        zipCode: '',
        email: '',
        createOrg: '',
        useOrg: ''
      },
      sid: '',
      baseManufacturerBankDto: [],
      rules: {},
      submitdisabled: false
    }
  },
  methods: {
    showInfo(row) {
      this.$nextTick(() => {
        this.$refs['form_obj'].clearValidate()
      })
      this.viewTitle = '供应商详情'
      req.fetchBySid(row.sid).then(resp => {
        this.sid = row.sid
        this.baseManufacturerDto = resp.data.baseManufacturerDto
        this.baseManufacturerBankDto = resp.data.baseManufacturerBankDto
      }).catch(e => {
        this.formobj = row
      })
    },
    handleSave() {
      if (this.baseManufacturerDto.manufacturerCode === '') {
        this.$message({ showClose: true, type: 'error', message: '编码不能为空' })
        return
      }
      const tip = '请确认编码是否正确,保存后信息将无法修改'
      this.$confirm(tip, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const formobj = {
          baseManufacturerBankDto: this.baseManufacturerBankDto,
          baseManufacturerDto: this.baseManufacturerDto
        }
        req.update(formobj, this.sid).then(resp => {
          this.submitdisabled = false
          if (resp.success) {
            this.$message({ showClose: true, type: 'success', message: resp.msg })
            this.handleReturn('true')
          }
        }).catch(() => {
          this.submitdisabled = false
        })
      })
    },
    handleReturn(isreload) {
      if (isreload === 'true') this.$emit('reloadlist')
      this.dialogStatus = ''
      this.sid = ''
      this.baseManufacturerDto = {}
      this.baseManufacturerBankDto = []
      this.$refs['form_obj'].resetFields()
      this.$emit('doback')
    }
  }
}
</script>

<style scoped>
</style>
