<template>
  <div class="data-dictionary h100">
    <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:3
     }
   }" :table-header="MemorandumManageHeader" :get-table-list="getTableData" :filter-form="MemorandumManage">
      <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">
      <memorandum-manage-setting-dialog @getTableData="getTableData" :dialog-operation-type="dialogOperationType" :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 {MemorandumManageHeader} from "@/data/all-table-header";
import {MemorandumManage} from "@/data/all-form";
import {Plus, Search} from "@element-plus/icons-vue"
import {useDetailOrEdit} from "@/units/use-method/usePagination";
import MemorandumManageSettingDialog
  from "@/views/main/c-views/policy-and-regulation-manage/memorandum-manage/MemorandumManageSettingDialog.vue";
import {
  proDeleteXyxxBwl,
  proSelectXyxxBwl
} from "@/service/policy-and-regulation-manage/memorandum-manage/memorandum-manage";
import {handleMes} from "@/units/element-ui/tip";
import {InsertSyslog} from "@/units/use-method/user-log";
export default {
  name: "MemorandumManage",
  components:{MemorandumManageSettingDialog, 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
      proSelectXyxxBwl({
        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){
      proDeleteXyxxBwl({
        CODE:data.CODE
      }).then(res =>{
        handleMes(res,() => {
          InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"),"信息删除", "备忘录管理删除成功", "备忘录管理", "")
          getTableData();
        })
      })
    }
    return {
      MemorandumManage,
      MemorandumManageHeader,
      getTableData,
      openDialog,
      deleteObj,
      layoutRef,
      isEditDialogShow,
      dialogOperationType,
      currentDialogOpObj,
      store
    }

  }

}
</script>

<style scoped lang="scss">
</style>