<template>
  <div class="unit container normal-panel">
    <el-row>
      <el-col :span="11">
        <p class="normal-title normal-margin">计量单位</p>
        <slot name="unitAdd"/>
        <tableLayout v-if="unitList" :layout="tablecols1" :data="unitList" :custom="false" height="70vh">
          <template v-slot:opreation="scope">
              <div style="display:flex">
                  <slot name="unitEdit" :data="scope.data" />
                  <slot name="unitDel" :data="scope" />
              </div>
          </template>
        </tableLayout>
      </el-col>
      <el-col :span="11" style="margin-left:16px">
        <p class="normal-title normal-margin">计量单位组</p>
        <slot name="unitGroupAdd"/>
        <tableLayout v-if="unitGroupList" :layout="tablecols2" :data="unitGroupList" :custom="false" height="70vh">
          <template v-slot:opreation="scope">
              <div style="display:flex">
                  <slot name="unitGroupEdit" :data="{row:scope.data,unitList:unitList}" />
                  <slot name="unitGroupDel" :data="scope.data" />
              </div>
          </template>
        </tableLayout>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      unitList:'',
      unitGroupList:'',
      tablecols1:'',
      tabelCol2:''
    };
  },
  computed:{
  },
  watch:{
  },
  created() {
    this.getUnit()
    this.getUnitGroup()
    this.tablecols1 = this.tool.tabelCol(this.$route.name).unitTable.tablecols
    this.tablecols2 = this.tool.tabelCol(this.$route.name).unitGroupTable.tablecols
  },
  methods: {
    /* 获取单位列表 */
    async getUnit() {
      let res = await this.$api.requested({
        "id": "20220922084803",
        "version":1,
        "content": {
          "nocache":true,
          "where":{
              "condition":""
          }
        }
      })
      this.unitList = res.data
      console.log(res)
    },
    /* 计量单位组数据 */
    async getUnitGroup() {
      let res = await this.$api.requested({
        "id": "20220922084503",
        "version":1,
        "content": {
          "nocache":true,
          "where":{
              "condition":""
          }
        }
      })
      this.unitGroupList = res.data
      console.log(res);
      
    }
  },
};
</script>

<style scoped>

</style>
