<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-model"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="form-content">
      <div class="company-information">
        <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="是否是第一级">
              <el-select
                style="width:100%"
                v-model="judgmentValue"
                placeholder="请选择"
              >
                <el-option label="是" value="1"> </el-option>
                <el-option label="否" value="0"> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24" v-if="judgmentValue == '0'">
          <el-col :span="12">
            <el-form-item label="上级分类" prop="parentCode">
              <el-cascader
                ref="cascader"
                @change="cascaderChange"
                v-model="parameter.parentCode"
                :options="options"
                :props="{
                  value: 'code',
                  label: 'name',
                  checkStrictly: true,
                  emitPath: false
                }"
                clearable
                style="width:100%"
              ></el-cascader>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="分类名称" prop="name">
              <el-input
                clearable
                v-model="parameter.name"
                placeholder="请输入分类名称"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="分类编号" prop="code">
              <el-input
                clearable
                v-model="parameter.code"
                placeholder="请输入分类编号"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      </div>
    </div>
    <div slot="footer" class="footer">
        <el-button @click="handleClose">{{ $t('domestic.cancel') }}</el-button>
      </div>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
import basicData from '@/api/basicData'
export default {
  name: 'domesticDialog',
  components: {Breadcrumb},
  data() {
    return {
      breadcrumbOpt: [{breadcrumbName: '物料分类'}, {breadcrumbName: '详情'}],
      parameter: {},
      judgmentValue: '1',
      options: []
    }
  },
  created() {
    this.selectTree()
    this.parameter = this.$route.query.detailRows
    if (this.parameter.parentCode === '1') {
      this.judgmentValue = '1'
    } else {
      this.judgmentValue = '0'
    }
    // this.detail(this.parameter.id)
  },
  mounted() {},
  methods: {
    // 关闭//面包屑点击
    handleClose() {
      this.$router.push({
        name: 'materialManagement',
        params: {
          tabsActiveName: 'materialClassification',
          pageBean: this.$route.query.pageBean
        }
      })
      this.parameter = {}
    },
    //查询物料分类树结构
    selectTree() {
      basicData.bizMaterialCategorySelectTree().then(res => {
        this.options = res.value
      })
    },
    //获取详情
    detail(val) {
      // basicData.bizMaterialCategoryId(val).then(res => {
      //   this.options.forEach(item => {
      //     if (item.code == res.parentCode) {
      //       res.parentCode = item.name
      //     }
      //   })
      //   console.log(res)
      //   this.parameter = res
      // })
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__label {
  width: 120px;
  font-size: 14px;
  color: #828282;
  font-weight: 500;
}

::v-deep .el-form-item__content span {
  font-size: 14px;
  color: #000;
  font-weight: 500;
}

::v-deep .el-form-item {
  margin-bottom: 10px;
}
/deep/.el-row {
  display: flex;
  justify-content: center;
}
.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>
