<template>
  <div class="data-dictionary h100">
    <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:3
     }
   }" :table-header="rewardsAndPunishmentsMeasureManageHeader" :get-table-list="getTableData" :filter-form="rewardsAndPunishmentsMeasureManage">
      <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">
      <RewardsAndPunishmentsMeasureManageSettingDialog @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 {rewardsAndPunishmentsMeasureManageHeader} from "@/data/all-table-header";
import {rewardsAndPunishmentsMeasureManage} from "@/data/all-form";
import {Plus, Search} from "@element-plus/icons-vue"
import {useDetailOrEdit} from "@/units/use-method/usePagination";
import RewardsAndPunishmentsMeasureManageSettingDialog
  from "@/views/main/c-views/combined-rewards-and-punishments/rewards-and-punishments-measure-manage/RewardsAndPunishmentsMeasureManageSettingDialog.vue";
import {
  proDeleteXyxxJccs,
  proSelectXyxxJccs
} from "@/service/combined-rewards-and-punishments/rewards-and-punishments-measure-manage/rewards-and-punishments-measure-manage";
import {handleMes} from "@/units/element-ui/tip";
import {InsertSyslog} from "@/units/use-method/user-log";
export default {
  name: "RewardsAndPunishmentsMeasureManage",
  components:{RewardsAndPunishmentsMeasureManageSettingDialog, 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
      proSelectXyxxJccs({
        bwlmc:layoutRef.value.form.BWLMC,
        zrbm:layoutRef.value.form.ZRBM,
        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){
      proDeleteXyxxJccs({
        code:data.CSID
      }).then(res =>{
        handleMes(res,() => {
          InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息删除", "奖惩措施管理删除成功", "奖惩措施管理", "")
          getTableData();
        })
      })
    }
    return {
      store,
      rewardsAndPunishmentsMeasureManage,
      rewardsAndPunishmentsMeasureManageHeader,
      getTableData,
      openDialog,
      deleteObj,
      layoutRef,
      isEditDialogShow,
      dialogOperationType,
      currentDialogOpObj
    }

  }
}
</script>

<style scoped>

</style>