/**
 * 用户操作工具类
 * import { PushUtil } from "@/funclib/PushUtil"
 * 
 * @author hhb
 * @date 2023-11-23
 */
import axios from "@/funclib/AxiosUtil";
import { $CONST } from "@/funclib/ConstUtil";

const modelFilePath = '/platf/useroperate/entity/SysUseroperate.xml'
export const UserOperateUtil = {
  // 查询操作表数据
  getData(url,key, userId, type) {
    let param ={}
    let __body = {};
    let cdion = { join: "and", items: [
      {
        sign:"eq",
        name:"FKEY",
        dataType:"String",
        value:key,
        enable: true,
      },
      {
        sign:"eq",
        name:"FUSERID",
        dataType:"String",
        value:userId,
        enable: true,
      },
      {
        sign:"eq",
        name:"FTYPE",
        dataType:"String",
        value:type || 'pagecontrolstate',
        enable: true,
      },
    ]}
    __body[$CONST.QUERYCDIONS] = cdion;
    // 附加数据集模型路径 
    param[$CONST.MODELFILEPATH] = modelFilePath;
    if(!param.pageSize){
      param.pageSize = -1
    }
    // 附加__body参数包
    param[$CONST.__BODY] = JSON.stringify(__body);
    return axios.post(url, param).then(res =>{
      let data = res[$CONST.DATAPACK]?.rows
      return data
    }).catch(e =>{
      return false
    })
  },
  save(url, key, userId, type, obj){
    let param ={}
    let data = {
      modelFilePath:modelFilePath,
      data:[ 
        {
          $state: "rsOverride",
          FKEY: key,
          FUSERID: userId,
          FTYPE: type,
          FVALUE: obj
        }
      ]
    }
    param[$CONST.__BODY] = JSON.stringify([data]);
    axios.post(url, param).then(res =>{
      
    }).catch(e =>{
      
    })
  }
};