<template>
  <div>
    <list ref="list">
      <!--单位计量-->
      <unitAdd 
        type="add" 
        slot="unitAdd" 
        @unitAddSuccess="unitAddSuccess" 
        v-if="tool.checkAuth($route.name,'insert')" 
      />
      <template v-slot:unitEdit="scope">
        <unitAdd 
          type="edit"  
          @unitAddSuccess="unitAddSuccess" 
          :unitData="scope.data" 
          v-if="tool.checkAuth($route.name,'update')" 
        />
      </template>
      <template v-slot:unitDel="scope">
        <Del type="unit" 
          @deleteSuccess="UnitDeleteSuccess" 
          :id="scope.data.data.unitid"  
          v-if="tool.checkAuth($route.name,'delete')"
        />
      </template>
      <!--单位计量组-->
      <unit-group-add 
        type="add" 
        slot="unitGroupAdd" 
        @unitAddSuccess="unitGroupAddSuccess" 
        :allUnit="unitList" 
        v-if="tool.checkAuth($route.name,'insert')" 
      />
      <template v-slot:unitGroupEdit="scope">
        <unit-group-add 
          type="edit" 
          :unitData="scope.data.row" 
          @unitAddSuccess="unitGroupAddSuccess" 
          :allUnit="scope.data.unitList" 
          v-if="tool.checkAuth($route.name,'update')"
        />
      </template>
      <template v-slot:unitGroupDel="scope">
        <Del type="unitGroup" 
          @deleteSuccess="unitGroupDelSuccess" 
          :id="scope.data.unitgroupid" 
          v-if="tool.checkAuth($route.name,'delete')"
        />
      </template>
    </list>
  </div>
</template>

<script>
import list from './components/list'
import Del from './components/delete'
import unitAdd from './components/unitAdd'
import unitGroupAdd from './components/unitGroupAdd'
export default {
  name: '',
  data() {
    return {
      unitList:''
    };
  },
  components:{list,Del,unitAdd,unitGroupAdd},
  computed:{
  },
  watch:{
  },
  created() {
    this.getUnit()
  },
  methods: {
    /* 计量单位增加成功 */
    unitAddSuccess() {
      this.$refs.list.getUnit()
    },
    /* 计量单位删除成功 */
    UnitDeleteSuccess() {
      this.$refs.list.getUnit()
    },
    /* 计量组添加成功 */
    unitGroupAddSuccess() {
      this.$refs.list.getUnitGroup()
    },
    /* 计量组删除成功 */
    unitGroupDelSuccess() {
      this.$refs.list.getUnitGroup()
    },
    /* 获取单位列表 */
    async getUnit() {
      let res = await this.$api.requested({
        "id": "20220922084803",
        "version":1,
        "content": {
          "nocache":true,
          "where":{
              "condition":""
          }
        }
      })
      this.unitList = res.data
      console.log(res)
    },
  },
};
</script>

<style scoped>

</style>
