"use strict";
const common_vendor = require("../../../common/vendor.js");
if (!Array) {
  const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  const _easycom_u_loadmore2 = common_vendor.resolveComponent("u-loadmore");
  const _easycom_u_empty2 = common_vendor.resolveComponent("u-empty");
  const _easycom_u__input2 = common_vendor.resolveComponent("u--input");
  const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  const _easycom_ba_tree_picker2 = common_vendor.resolveComponent("ba-tree-picker");
  const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
  (_easycom_u_navbar2 + _easycom_u_icon2 + _easycom_u_loadmore2 + _easycom_u_empty2 + _easycom_u__input2 + _easycom_u_button2 + _easycom_ba_tree_picker2 + _easycom_u_popup2)();
}
const _easycom_u_navbar = () => "../../../node-modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_u_icon = () => "../../../node-modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_u_loadmore = () => "../../../node-modules/uview-plus/components/u-loadmore/u-loadmore.js";
const _easycom_u_empty = () => "../../../node-modules/uview-plus/components/u-empty/u-empty.js";
const _easycom_u__input = () => "../../../node-modules/uview-plus/components/u--input/u--input.js";
const _easycom_u_button = () => "../../../node-modules/uview-plus/components/u-button/u-button.js";
const _easycom_ba_tree_picker = () => "../../../components/ba-tree-picker/ba-tree-picker.js";
const _easycom_u_popup = () => "../../../node-modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
  (_easycom_u_navbar + _easycom_u_icon + _easycom_u_loadmore + _easycom_u_empty + _easycom_u__input + _easycom_u_button + _easycom_ba_tree_picker + _easycom_u_popup)();
}
const _sfc_main = {
  __name: "deviceEvents",
  setup(__props) {
    const { proxy } = common_vendor.getCurrentInstance();
    const instance = common_vendor.getCurrentInstance();
    const {
      device_type,
      device_online_status,
      device_busy_status,
      device_active_status
    } = proxy.$useDict("device_type", "device_online_status", "device_busy_status", "device_active_status");
    const dicts = common_vendor.reactive({
      device_type: [],
      online_status: [],
      busy_status: [],
      active_status: []
    });
    const searchMenu = common_vendor.reactive({
      showPopMenu: false,
      selStatus: 0,
      style: {
        marginTop: "174rpx"
      },
      searchMenu_body_style: {
        height: "600rpx"
      },
      params: {
        mercName: void 0,
        deviceId: void 0,
        deviceType: void 0,
        busyState: void 0,
        activeState: void 0,
        no: void 0
      }
    });
    function openSearchMenu() {
      searchMenu.showPopMenu = true;
      getTreeData();
    }
    function resetSearchMenu() {
      searchMenu.params.deviceId = void 0;
      searchMenu.params.deviceType = void 0;
      searchMenu.params.mercName = void 0;
      searchMenu.params.no = void 0;
    }
    function selectCode() {
      proxy.$refs.treePicker._show();
    }
    function doSearch(o) {
      if (o == 0)
        resetSearchMenu();
      setTimeout(function() {
        searchMenu.showPopMenu = false;
        data.curPage = 1;
        getList();
      }, 500);
    }
    common_vendor.ref("");
    const data = common_vendor.reactive({
      reqUrls: {
        list: "/device/device-event-msg/page",
        tree: "/sys/sys-code-configure/tree"
      },
      curPage: 1,
      loadmoreStatus: "nomore",
      params: {
        page: {
          current: 1,
          size: 10,
          orders: [
            {
              asc: false,
              column: "create_time"
            }
          ]
        }
      },
      fullHeight: 0,
      screenHeight: 1920,
      // screenWidht:1080,
      dataList: [],
      total: 0,
      treeData1: [
        {
          id: 1,
          name: "公司1",
          children: [{
            id: 11,
            name: "研发部",
            children: [{
              id: 111,
              name: "张三"
            }, {
              id: 112,
              name: "李四"
            }]
          }, {
            id: 12,
            name: "综合部"
          }]
        },
        {
          id: 2,
          name: "公司2",
          children: [{
            id: 21,
            name: "研发部"
          }, {
            id: 22,
            name: "综合部"
          }, {
            id: 23,
            name: "财务部"
          }]
        },
        {
          id: 3,
          name: "公司3"
        },
        {
          id: 4,
          name: "公司4",
          children: [{
            id: 41,
            name: "研发部"
          }]
        }
      ]
    });
    common_vendor.onMounted(() => {
      dicts.device_type = [{ value: null, label: "全部" }].concat(device_type.value);
      dicts.online_status = [{ value: null, label: "全部" }].concat(device_online_status.value);
      data.screenHeight = common_vendor.index.getSystemInfoSync().windowHeight;
      searchMenu.searchMenu_body_style.height = data.screenHeight - 90 + "px";
      getList();
      const query = common_vendor.index.createSelectorQuery().in(instance);
      query.select(".scrollview").boundingClientRect((r) => {
        common_vendor.index.getSystemInfo({
          success(res) {
            const model = res.model;
            const modelInclude = [
              "iPhone X",
              "iPhone XR",
              "iPhone XS",
              "iPhone XS MAX",
              "iPhone 12/13 mini",
              "iPhone 12/13 (Pro)",
              "iPhone 12/13 Pro Max",
              "iPhone 14 Pro Max"
            ];
            let safeDistance = modelInclude.includes(model);
            console.log(res.windowHeight, r.top);
            let h = 0;
            if (safeDistance) {
              h = res.windowHeight - r.top;
            } else {
              h = res.windowHeight - r.top;
            }
            data.fullHeight += h + "px";
          }
        });
      }).exec();
    });
    function scrolltolower() {
      if (data.loadmoreStatus == "nomore")
        return;
      data.curPage++;
      getList();
    }
    function getList() {
      return new Promise((resolve, reject) => {
        data.params.page.current = data.curPage;
        data.params.deviceId = searchMenu.params.deviceId;
        data.params.code = searchMenu.params.code;
        if (data.curPage == 1) {
          data.dataList = [];
        }
        proxy.$request({
          url: data.reqUrls.list,
          data: data.params,
          method: "post"
        }).then((res) => {
          console.log("***", res);
          if (res.records) {
            data.dataList = data.dataList.concat(res.records);
          }
          data.total = res.total;
          if (res.records.length < 10) {
            data.loadmoreStatus = "nomore";
          } else {
            data.loadmoreStatus = "loadmore";
          }
          resolve(res);
        }).catch((err) => {
          reject(err);
        });
      });
    }
    function getTreeData() {
      return new Promise((resolve, reject) => {
        proxy.$request({
          url: data.reqUrls.tree,
          data: { code: [] },
          method: "post"
        }).then((res) => {
          data.treeData = res;
          console.log("---***", data.treeData, data.treeData[0], data.treeData[1]);
          resolve(res);
        }).catch((err) => {
          reject(err);
        });
      });
    }
    function treeNodeSelectChange(ids, names) {
      searchMenu.params.code = ids[0];
    }
    function gotoDeviceDetail(o) {
    }
    function rightClick() {
      console.log("点击了右侧");
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(rightClick),
        b: common_vendor.p({
          title: "设备事件",
          titleStyle: "color:#fff;fontSize:36rpx;",
          bgColor: "#2C6FF3",
          autoBack: true,
          leftIconColor: "#fff",
          placeholder: true
        }),
        c: common_vendor.t(data.total),
        d: common_vendor.p({
          name: "arrow-right",
          size: "14"
        }),
        e: common_vendor.o(openSearchMenu),
        f: data.dataList.length > 0
      }, data.dataList.length > 0 ? common_vendor.e({
        g: common_vendor.f(data.dataList, (item1, index1, i0) => {
          return common_vendor.e({
            a: item1.deviceName
          }, item1.deviceName ? {
            b: common_vendor.t(item1.deviceName),
            c: common_vendor.t(item1.deviceId)
          } : {
            d: common_vendor.t(item1.deviceId)
          }, {
            e: common_vendor.t(item1.mercName),
            f: common_vendor.t(item1.code),
            g: common_vendor.t(item1.msg),
            h: common_vendor.t(item1.createTime),
            i: common_vendor.o(($event) => gotoDeviceDetail(item1.deviceId), item1.deviceId),
            j: item1.deviceId
          });
        }),
        h: data.dataList.length > 0
      }, data.dataList.length > 0 ? {
        i: common_vendor.p({
          status: data.loadmoreStatus
        })
      } : {}) : {
        j: common_vendor.p({
          mode: "data",
          text: "数据为空"
        })
      }, {
        k: common_vendor.o(scrolltolower),
        l: data.fullHeight,
        m: common_vendor.o(($event) => searchMenu.params.deviceId = $event),
        n: common_vendor.p({
          placeholder: "请输入机器名称,编号",
          border: "surround",
          modelValue: searchMenu.params.deviceId
        }),
        o: common_vendor.o(($event) => searchMenu.params.code = $event),
        p: common_vendor.p({
          placeholder: "事件代码",
          border: "surround",
          modelValue: searchMenu.params.code
        }),
        q: common_vendor.o(($event) => selectCode()),
        r: common_vendor.p({
          size: "normal",
          plain: true,
          text: "选择"
        }),
        s: common_vendor.o(($event) => doSearch(0)),
        t: common_vendor.p({
          size: "normal",
          plain: true,
          text: "关闭"
        }),
        v: common_vendor.o(resetSearchMenu),
        w: common_vendor.p({
          size: "normal",
          type: "primary",
          plain: true,
          text: "重置"
        }),
        x: common_vendor.o(($event) => doSearch(1)),
        y: common_vendor.p({
          size: "normal",
          type: "primary",
          text: "查找"
        }),
        z: common_vendor.sr("treePicker", "35ae1ae5-11,35ae1ae5-4"),
        A: common_vendor.o(treeNodeSelectChange),
        B: common_vendor.p({
          zindex: "999",
          multiple: false,
          title: "选择事件",
          titleColor: "#ff0000",
          localdata: data.treeData,
          valueKey: "code",
          textKey: "title",
          childrenKey: "sonVos"
        }),
        C: common_vendor.s(searchMenu.searchMenu_body_style),
        D: common_vendor.p({
          show: searchMenu.showPopMenu,
          duration: "0",
          customStyle: searchMenu.style,
          round: 10,
          mode: "right",
          duration: 300,
          overlay: false
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-35ae1ae5"], ["__file", "F:/兴元/开门柜项目/平台端管理系统小程序/src/pages/xy_system/devices/deviceEvents.vue"]]);
wx.createPage(MiniProgramPage);
