<template>
  <div class="other">
    <el-form label-width="120px" ref="form" :model="form">
      <div class="divider">
        <div class="title">
          <div class="ele-bg-primary"></div>
          <span>采购信息</span>
        </div>
        <div class="ele-bg-primary ele-width"></div>
      </div>
      <el-row :gutter="24">
        <el-col :span="8">
          <el-form-item label="周期" prop="purchasingCycle">
            <el-input-number
              v-model="form.purchasingCycle"
              placeholder="请输入"
              :min="0"
              :controls="false"
              style="width: calc(100% - 100px)"
            />
            <DictSelection
              dictName="周期单位"
              clearable
              v-model="form.purchasingCycleUnit"
              style="width: 100px"
            >
            </DictSelection>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="倍数" prop="purchaseMultiplier">
            <el-input-number
              style="width: 100%"
              v-model="form.purchaseMultiplier"
              placeholder="请输入"
              :min="0"
              :controls="false"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="最低订购量" prop="minimumOrderQuantity">
            <el-input-number
              v-model="form.minimumOrderQuantity"
              placeholder="请输入"
              :min="0"
              :controls="false"
              style="width: calc(100% - 100px)"
            />
            <DictSelection
              dictName="计量单位"
              clearable
              v-model="form.measuringUnit"
              style="width: 100px"
            >
            </DictSelection>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="采购组织" prop="checkDepart">
            <deptSelect
              v-model="form.checkDepart"
              @changeGroup="searchDeptNodeClick"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="采购员" prop="checkPerson">
            <personSelect
              ref="directorRef"
              v-model="form.checkPerson"
              :init="false"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
  import deptSelect from '@/components/CommomSelect/dept-select.vue';
  import personSelect from '@/components/CommomSelect/person-select.vue';
  export default {
    props: {
      form: {
        type: Object,
        default: {}
      }
    },
    components: { deptSelect, personSelect },
    data() {
      return {};
    },
    watch: {
      form(data) {
        console.log(data, 'data');
        if (data.checkDepart) {
          const params = { executeGroupId: data.checkDepart };
          this.$nextTick(() => {
            this.$refs.directorRef.getList(params);
          });
        }
      }
    },
    methods: {
      // 选择所属部门
      searchDeptNodeClick(id, info) {
        // 根据部门获取人员
        const params = { executeGroupId: id };
        this.$nextTick(() => {
          this.$refs.directorRef.getList(params);
        });
      }
    }
  };
</script>

<style lang="scss" scoped>
  .other {
    background: #fff;
    padding: 1px 17px;
  }
  .divider {
    margin: 0px 0 20px;
    .title {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      div {
        width: 8px;
        height: 20px;
        margin-right: 10px;
      }
      span {
        font-size: 20px;
      }
    }
    .ele-width {
      width: 100%;
      height: 2px;
    }
  }
  .form-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .line-select {
      margin-left: 15px;
    }
  }
  ::v-deep .el-input-number .el-input__inner {
    text-align: left !important;
  }
</style>
