<template>
  <div class="data-dictionary h100">
    <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:4
     }
   }" :table-header="unitManageHomeHeader" :get-table-list="getTableData" :filter-form="unitManageHome">
      <template #plusBtn>
        <el-button  type="primary" :icon="Plus" @click="$emit('changeOperation','add')">新增</el-button>-->
      </template>
      <template #operation="{data}">
        <el-button  type="info" @click="$emit('changeOperation','detail',data)">查看</el-button>
        <el-button  type="info" @click="$emit('changeOperation','edit',data)">修改</el-button>
        <el-button  type="info" @click="deleteItem(data)">删除</el-button>
      </template>
    </common-layout>
  </div>
</template>

<script>
import CommonLayout from "@/components/CommonLayout.vue";
import {Plus} from "@element-plus/icons-vue";
import {ref} from "vue";
import {useRootStore} from "@/pinia/useStore";
import {handleMes} from "@/units/element-ui/tip";
import {unitManageHome} from "@/data/all-form";
import {unitManageHomeHeader} from "@/data/all-table-header";
import {proXyxxDeleteUnit, proXyxxSelectUnit} from "@/service/system-manage/unit-manage/unit-manage";
import {InsertSyslog} from "@/units/use-method/user-log";

export default {
  name: "UnitManageHome",
  components:{CommonLayout},
  computed: {
    Plus(){
      return Plus
    }
  },
  setup(){
    const layoutRef = ref(null);
    const store =useRootStore();
    function getTableData (){
      proXyxxSelectUnit({
        A_NAME:layoutRef.value.form.A_NAME,
        pageIndex:layoutRef.value.pageIndex,
        pageSize:layoutRef.value.pageSize
      }).then(res =>{
        let originData = res.msg[0].Rows
        InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息查询", "单位管理查询成功", "单位管理", "")
        layoutRef.value.getResData(originData,res.msg[0].TotalRowCount)
      })
    }
    function deleteItem (obj){
      proXyxxDeleteUnit({
        "A_CODE":obj.CODE
      }).then(res=>{
        handleMes(res,() => {
          InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息删除", "单位管理删除成功", "单位管理", "")
          getTableData();
        })
      })
    }
    return {
      unitManageHome,
      unitManageHomeHeader,
      getTableData,
      deleteItem,
      layoutRef
    }

  }
}
</script>

<style scoped>

</style>