<template>
  <div>
    <el-form label-width="120px" :inline="false" size="small" label-position="left">
      <div class="sty">
        <el-page-header @back="goBack" content="详情页面"> </el-page-header>
      </div>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>组织信息</span>
        </div>
        <el-row :gutter="20">
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item label="创建组织" size="small">
              <el-input
                v-model="detail.createOrgName"
                :readonly="isReadonly"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item label="编码" size="small">
              <el-input
                v-model="detail.useOrgNumber"
                :readonly="isReadonly"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item label="名称" size="small">
              <el-input v-model="detail.name" :readonly="isReadonly" size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>基本信息</span>
        </div>
        <div class="baseInfo">
          <el-row :gutter="40">
            <el-col :span="12" :offset="0">
              <div>
                <div class="base-header">
                  <span>基本信息</span>
                </div>
                <el-row>
                  <el-col :span="24"
                    ><span class="marg-r"></span>

                    <el-form-item label="仓库属性" size="small">
                      <el-input
                        v-model="detail.stockProperty"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="供应商" size="small">
                      <el-input
                        v-model="detail.supplierName"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="客户" size="small">
                      <el-input
                        v-model="detail.customerName"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >

                    <el-form-item label="仓库地址" size="small">
                      <el-input
                        v-model="detail.address"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >

                       <el-form-item label="仓库负责人" size="small">
                      <el-input
                        v-model="detail.principalName"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                     <el-form-item label="联系电话" size="small">
                      <el-input
                        v-model="detail.tel"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >

                           <el-form-item label="描述" size="small">
                      <el-input
                        v-model="detail.description"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                     <el-form-item label="分组" size="small">
                      <el-input
                        v-model="detail.groupName"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                   </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                       <el-form-item label="管易仓" size="small">
                      <el-input
                        :value="detail.gysStock?'是':'否'"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>


                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                         <el-form-item label="管易仓编码" size="small">
                      <el-input
                        v-model="detail.gysStockNumber"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>



                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                      <el-form-item label="第三方仓储类型" size="small">
                      <el-input
                        v-model="detail.thirdStockType"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >

                        <el-form-item label="第三方仓库编码" size="small">
                      <el-input
                        v-model="detail.thirdStockNo"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                    </el-col>
                </el-row>
              </div>
            </el-col>
            <el-col :span="12" :offset="0">
              <div>
                <div class="base-header">
                  <span>库存状态</span>
                </div>
                <el-row>
                  <el-col :span="24"
                    >
                      <el-form-item label="库存状态类型" size="small">
                      <el-input
                        v-model="stockStatusType"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                       <el-form-item label="默认库存状态" size="small">
                      <el-input
                        v-model="detail.defStockStatusName"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                    </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >

                        <el-form-item label="默认收料状态" size="small">
                      <el-input
                        v-model="detail.defReceiveStatusName"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>

                    </el-col>
                </el-row>
                <div class="base-header">
                  <span>控制</span>
                </div>
                <el-row>

                  <el-row>
                       <el-col :span="12"
                      >
                    <el-form-item label="允许客户查询" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.inquire" :true-label="1" :false-label="0">{{''}}</el-checkbox>
                    </el-form-item>

                     </el-col>
                    <el-col :span="12"
                      >
                    <el-form-item label="允许即时库存负库存" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.allowMinusQty" :label="true">{{''}}</el-checkbox>
                    </el-form-item>
                     </el-col>
                    <el-col :span="12"
                      >
                        <el-form-item label="允许MRP计划" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.allowMrpPlan" :label="true">{{''}}</el-checkbox>
                    </el-form-item>
                     </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="12"
                      >
                           <el-form-item label="允许锁库" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.allowLock" :label="true">{{''}}</el-checkbox>
                    </el-form-item>
                     </el-col>
                    <el-col :span="12"
                      >
                            <el-form-item label="参与预警" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.availableAlert" :label="true">{{''}}</el-checkbox>
                    </el-form-item>
                     </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="12"
                      >
                           <el-form-item label="启用仓位管理" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.openLocation" :label="true">{{''}}</el-checkbox>
                    </el-form-item>

                      </el-col>
                         <el-col :span="12"
                      >
                           <el-form-item label="虚拟仓" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.stockType" :true-label="1" :false-label="0">{{''}}</el-checkbox>
                    </el-form-item>

                      </el-col>
                    <el-col :span="12"
                      >
                          <el-form-item label="参与拣货" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.availablePicking" :label="true">{{''}}</el-checkbox>
                    </el-form-item>

                      </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="12"
                      >
                         <el-form-item label="不参与可发量统计" size="small">
                        <el-checkbox :readonly="isReadonly" v-model="detail.notExpQty" :label="true">{{''}}</el-checkbox>
                    </el-form-item>

                      </el-col>
                    <el-col :span="12"> </el-col>
                  </el-row>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                        <el-form-item label="拣货优先级(1~9999)" size="small">
                      <el-input
                        v-model="detail.sortingPriority"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                    >
                      <el-form-item label="仓位维度数据列表显示格式" size="small">
                      <el-input
                        v-model="detail.loclistFormatter"
                        :readonly="isReadonly"
                        size="small"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>

              </div>
            </el-col>
          </el-row>
        </div>
        <el-button type="primary"  @click="setStock">保存</el-button>

      </el-card>
    </el-form>
  </div>
</template>

<script>

import { setStock } from "@/api/basic_data/warehouse";

export default {
  props: {
    detail: {
      type: Object,
      default: {},
      isReadonly:true
    },
  },
  computed: {
    stockStatusType() {
      let typeStr = "";
      const typeArr = this.detail.stockStatusType.split(",");
      for (let i = 0; i < typeArr.length; i++) {
        switch (typeArr[i]) {
          case "1":
            typeStr += "1待检";
            break;
          case "2":
            typeStr += "2冻结";
            break;
          case "3":
            typeStr += "3退回";
            break;
          case "4":
            typeStr += "4在途";
            break;
          case "5":
            typeStr += "5收货";
            break;
          case "6":
            typeStr += "6废品";
            break;
          case "7":
            typeStr += "7不良";
            break;
          case "8":
            typeStr += "8外借";
            break;
          default:
            typeStr += "0可用";
            break;
        }
      }
      console.log(typeStr);
      return typeStr;
    },
  },
  methods: {
    goBack() {
      console.log(this.$parent);
      this.$parent.isShow = true;
    },
    setStock(){
      setStock({
        inquire:this.detail.inquire,
        stockType:this.detail.stockType,
        id:this.detail.id
      }).then((res) => {
        this.$successMsg('保存成功')
         this.$parent.isShow = true;
      })
    }
  },
};
</script>

<style lang="scss" scoped>
.flex {
  display: flex;
  div {
    width: 120px;
  }
}
.baseWidth {
  width: 46%;
}
.inputDate {
  width: 46%;
}
.selectStyle2 {
  width: 35%;
}
.selectStyle {
  width: 35%;
}
.textareaStyle {
  vertical-align: text-top;
  resize: none;
  width: 35%;
  height: 100px;
}
.color {
  color: #1f93ec;
}
.el-col-24 {
  margin: 6px 0;
}

.marg-r {
  padding-right: 15px;
  font-size: 12px;
  display: inline-block;
  width: 120px;
}
.base-header {
  height: 20px;
  width: 60%;
  border-bottom: 2px solid gray;
  span {
    width: 100px;
    height: 100%;
    display: block;
    text-align: center;
    color: #fff;

    background-color: gray;
  }
}
.box-card {
  margin-bottom: 20px;
}
.el-col-8 {
  span {
    padding-right: 10px;
    display: inline-block;
    width: 100px;
  }
}
// .baseInfo {
//   display: flex;
//   justify-content: space-between;
//   > div {
//     width: 33%;
//   }
// }
.sty {
  margin-bottom: 20px;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
</style>
