<template>
    <div class="edit-add-detail">
      <div class="crumbs">
        <Breadcrumb
          :breadcrumbOpt="breadcrumbOpt"
          svg-name="#icon-bill"
          @breadcrumb-click="handleClose"
        />
      </div>
      <div class="form-content">
        <el-form
          ref="formInfo"
          :model="parameter"
          label-width="auto"
          label-position="right"
          :rules="rules"
        >
          <div class="rows">
            <div class="rows-left">
              <div class="rows-hr"></div>
            </div>
            <div class="rows-title">
              <div class="text-overflow">基本信息</div>
            </div>
          </div>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="管理单位" prop="cardNo">
                <el-input
                  disabled
                  clearable
                  v-model="parameter.cardNo"
                  placeholder="请输入管理单位"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="供应商名称" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入供应商名称"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="供应商类型" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入供应商类型"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="供应商类别" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入供应商类别"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="分类目录" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入分类目录"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所属地区" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入所属地区"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="账号状态" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入账号状态"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入邮箱"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="供应商性质" prop="clientName">
                <el-input
                  clearable
                  v-model="parameter.clientName"
                  placeholder="请输入供应商性质"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="rows">
            <div class="rows-left">
              <div class="rows-hr"></div>
            </div>
            <div class="rows-title">
              <div class="text-overflow">供应商信息</div>
            </div>
          </div>
          <el-table
            ref="singleTable"
            :data="parameter.detail"
            style="width: 100%"
            highlight-current-row
            :cell-style="{'text-align': 'center'}"
            :header-cell-style="{'text-align': 'center'}"
          >
            <el-table-column fixed type="index" width="55" label="序号" />
            <el-table-column
              label="供应商编号"
              min-width="150"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入供应商编号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="供应商名称"
              min-width="150"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入供应商名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="供应商性质"
              min-width="150"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入供应商性质"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="平台账号" min-width="170" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入平台账号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="账号状态" min-width="170" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入账号状态"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="注册资本" min-width="170" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入注册资本"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="联系人" min-width="150" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入联系人"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="邮箱" min-width="150" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入邮箱"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="所属地区" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入所属地区"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="供应商类型"
              min-width="180"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入供应商类型"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="分类目录" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入分类目录"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="申请日期" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-date-picker
                  v-model="scope.row.unloadAddress"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择申请日期"
                  style="width:100%;"
                />
              </template>
            </el-table-column>
            <el-table-column label="A/B类" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入A/B类"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="类别" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入类别"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="停用操作人"
              min-width="180"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入停用操作人"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="停用时间" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-date-picker
                  v-model="scope.row.unloadAddress"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择停用时间"
                  style="width:100%;"
                />
              </template>
            </el-table-column>
            <el-table-column label="拉黑原因" min-width="180" prop="type">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.type"
                  placeholder="请输入拉黑原因"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="移出审批状态" min-width="180" prop="type">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.type"
                  placeholder="请输入移出审批状态"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="备注" min-width="180" prop="unloadAddress">
              <template slot-scope="scope">
                <el-input
                  :readonly="scope.row.readonly"
                  v-model="scope.row.checkContent"
                  :rows="2"
                  maxlength="500"
                  show-word-limit
                  type="textarea"
                  style="width:100%;"
                />
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              align="right"
              width="90px"
              :index="999"
            >
              <template slot="header">
                <el-button
                  size="mini"
                  type="warning"
                  circle
                  icon="el-icon-plus"
                  @click="addTable"
                />
              </template>
              <template slot-scope="scope">
                <el-button
                  v-if="!scope.row.id"
                  size="mini"
                  type="danger"
                  circle
                  icon="el-icon-close"
                  @click="delTable(scope.$index, scope.row)"
                />
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
      <div slot="footer" class="footer">
        <el-button @click="handleClose">{{ $t('domestic.cancel') }}</el-button>
        <el-button type="primary" @click="handleSave">{{
          $t('domestic.save')
        }}</el-button>
      </div>
    </div>
  </template>
  
  <script>
  import Breadcrumb from '@/components/Breadcrumb/index.vue'
  export default {
    name: 'inquiryContractAddDialog',
    components: {Breadcrumb},
    props: {
      editData: Object
    },
    data() {
      return {
        centralizedData: [
          {name: '是', id: 1},
          {name: '否', id: 0}
        ],
        breadcrumbOpt: [{breadcrumbName: '合同查询'}, {breadcrumbName: '新增'}],
        cardTypeData: [
          {
            name: '营业执照',
            value: 0
          },
          {
            name: '身份证',
            value: 1
          },
          {
            name: '驾驶证',
            value: 2
          },
          {
            name: '军官证',
            value: 3
          },
          {
            name: '护照',
            value: 4
          }
        ],
        rules: {
          clientName: [
            {
              required: true,
              message: '请输入客户名称',
              trigger: 'blur'
            }
          ],
          cardNo: [
            {
              required: true,
              message: '请输入证件号码',
              trigger: 'blur'
            },
            {
              pattern: /^[a-zA-Z0-9]+$/,
              message: '证件号码格式不正确',
              trigger: 'blur'
            }
          ],
          contacttel: [
            {
              required: true,
              message: '请输入联系电话',
              trigger: 'blur'
            },
            {
              pattern: /^1[3456789]\d{9}$/,
              message: '手机号码格式不正确',
              trigger: 'blur'
            }
          ],
          bankName: [
            {
              required: true,
              message: '请输入开户银行',
              trigger: 'blur'
            }
          ],
          bankNo: [
            {
              required: true,
              message: '请输入银行账号',
              trigger: 'blur'
            }
          ],
          cardType: [
            {
              required: true,
              message: '请选择证件类型',
              trigger: 'blur'
            }
          ]
        },
        parameter: {
          detail: []
        }
      }
    },
    created() {
      this.addModifyBtn()
    },
    mounted() {},
    methods: {
      //列表删除行
      addTable() {
        this.parameter.detail.push({})
      },
      //列表删除行
      delTable(index, row) {
        this.parameter.detail.splice(index, 1)
        if (row.id) {
          this.parameter.deleteDetailsId.push(row.id)
        }
      },
      //编辑
      addModifyBtn() {
        if (this.$route.query.editRows) {
          console.log()
          this.breadcrumbOpt[1].breadcrumbName = '编辑'
          this.modifychoData(this.$route.query.editRows)
        } else {
          this.breadcrumbOpt[1].breadcrumbName = '新增'
        }
      },
      //获取修改回显数据
      modifychoData(val) {
        console.log(val)
      },
      // 关闭//面包屑点击
      handleClose() {
        if (this.breadcrumbOpt[1].breadcrumbName === '编辑') {
          this.$router.push({
            name: 'inquiryContract',
            params: {
              pageBean: this.$route.query.pageBean
            }
          })
        } else {
          this.$router.push({
            name: 'inquiryContract'
          })
        }
  
        // this.$emit('closeComponent')
        this.parameter = {}
        // this.$refs.formInfo.clearValidate()
      },
      // 保存
      handleSave() {
        this.$refs.formInfo.validate(valid => {
          if (valid) {
          }
        })
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  // /deep/.el-row {
  //   padding: 0 100px;
  // }
  .rows {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ebebeb;
    margin-bottom: 16px;
    padding: 10px 0;
    .rows-left {
      margin-right: 10px;
      .rows-hr {
        width: 3px;
        height: 18px;
        background-color: #0e6eff;
        border-radius: 2px;
      }
    }
    .rows-title {
      .text-overflow {
        width: 100%;
        font-size: 16px;
      }
    }
  }
  </style>
  