<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-icon_analysis_expertsranking"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="form-content">
      <el-form
        ref="formInfo"
        :model="parameter"
        label-width="100px"
        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="24">
            <el-form-item label="分类名称" prop="expertTypeName">
              <el-input
                clearable
                v-model="parameter.expertTypeName"
                placeholder="请输入分类名称"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="备注" prop="remarks">
              <el-input
                clearable
                type="textarea"
                v-model="parameter.remarks"
                placeholder="请输入备注"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div slot="footer" class="footer">
      <el-button @click="handleClose">{{ $t('domestic.cancel') }}</el-button>
      <el-button type="primary" :loading="saveing" @click="handleSave">{{
        $t('domestic.save')
      }}</el-button>
    </div>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
import basicData from '@/api/basicData'
export default {
  name: 'domesticDialog',
  components: {Breadcrumb},
  props: {
    editData: Object
  },
  data() {
    return {
      breadcrumbOpt: [{breadcrumbName: '专家分类'}, {breadcrumbName: '新增'}],
      saveing:false,
      rules: {
        expertTypeName: [
          {
            required: true,
            message: '请输入分类名称',
            trigger: 'blur'
          }
        ],
      },
      parameter: {
        expertTypeCode: '',
        expertTypeName: '',
        remarks: ''
      }
    }
  },
  created() {
    this.addModifyBtn()
  },
  mounted() {},
  methods: {
    //编辑
    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) {
      this.parameter = val
    },
    // 关闭//面包屑点击
    handleClose() {
      this.$router.go(-1)
      this.parameter = {}
    },
    // 保存
    handleSave() {
      this.$refs.formInfo.validate(valid => {
        if (valid) {
          this.saveing = true
          basicData.bizExpertTypeSave(this.parameter).then(res => {
            this.saveing = false
            if (res.state) {
              this.$message.success('保存成功')
              this.handleClose()
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.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>
