<template>
  <div class="data-dictionary h100">
    <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:3
     }
   }" :table-header="policyRegulationInformationHeader" :get-table-list="getTableData" :filter-form="policyRegulationInformation">
      <template v-if="store.isManager" #plusBtn>
        <el-button   type="primary" :icon="Plus" @click="openDialog('add')">新增</el-button>-->
      </template>
      <template #operation="{data}">
        <el-button  type="info" @click="openDialog('detail',data)">查看</el-button>
        <el-button v-if="store.isManager"  type="info" @click="openDialog('edit',data)">修改</el-button>
        <el-button v-if="store.isManager"  type="info" @click="deleteObj(data)">删除</el-button>
      </template>
    </common-layout>

    <template v-if="isEditDialogShow">
      <policy-regulation-information-setting-dialog  :dialog-operation-type="dialogOperationType" @getTableData="getTableData" :current-dialog-obj="currentDialogOpObj" v-model:dialog-visible="isEditDialogShow"/>
    </template>
  </div>
</template>

<script>
import {ref} from "vue";
import {useRootStore} from "@/pinia/useStore";
import CommonLayout from "@/components/CommonLayout.vue";
import {policyRegulationInformationHeader} from "@/data/all-table-header";
import {policyRegulationInformation} from "@/data/all-form";
import {Plus, Search} from "@element-plus/icons-vue"
import {useDetailOrEdit} from "@/units/use-method/usePagination";
import {
  proDeleteXyxxFlag,
  proSelectXyxxSelect
} from "@/service/policy-and-regulation-manage/policy-regulation-information/policy-regulation-information";
import PolicyRegulationInformationSettingDialog
  from "@/views/main/c-views/policy-and-regulation-manage/policy-regulation-information/PolicyRegulationInformationSettingDialog.vue";
import {handleMes} from "@/units/element-ui/tip";
import {InsertSyslog} from "@/units/use-method/user-log";
export default {
  name: "PolicyRegulationInformation",
  components:{PolicyRegulationInformationSettingDialog, CommonLayout},
  computed: {
    Plus(){
      return Plus
    }
  },
  setup(){
    const layoutRef = ref(null);
    const isEditDialogShow = ref(false);
    const {changeOperation,currentOpObj:currentDialogOpObj,operationType:dialogOperationType} = useDetailOrEdit()
    const store =useRootStore();
    function getTableData (){
      debugger
      proSelectXyxxSelect({
        SEL:layoutRef.value.form.SEL,
        GJZ:layoutRef.value.form.GJZ,
        START_TIME:layoutRef.value.form.START_DATE,
        END_TIME:layoutRef.value.form.END_DATE,
        pageIndex:layoutRef.value.pageIndex,
        pageSize:layoutRef.value.pageSize
      }).then(res =>{
        InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"),"信息查询", "政策法规信息查询成功", "政策法规信息", "")
        layoutRef.value.getResData(res.msg[0].Rows,res.msg[0].TotalRowCount)
      })
    }

    function openDialog(type,data){
      isEditDialogShow.value = true;
      changeOperation(type,data)
    }
    function deleteObj(data){
      proDeleteXyxxFlag({
        CODE:data.CODE
      }).then(res =>{
        handleMes(res,() => {
          getTableData();
          InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"),"信息删除", "政策法规信息删除成功", "政策法规信息", "")
        })
      })
    }
    return {
      policyRegulationInformation,
      policyRegulationInformationHeader,
      getTableData,
      openDialog,
      deleteObj,
      layoutRef,
      isEditDialogShow,
      dialogOperationType,
      currentDialogOpObj,
      store
    }

  }

}
</script>

<style scoped lang="scss">
#policy-regulation-information{
  background-color: yellow;
  width: 100%;
  height: 100%;
}
</style>