import { getDataSet } from "@/utils/util";

Page({
  /**
   * 页面的初始数据
   */
  data: {
    process: [
      {
        p_process_name: "办公流程",
        parent_process_id: 34,
        child: [
          {
            process_name: "录单亲亲我",
            process_id: 86,
            parent_process_id: 34,
            p_process_name: "办公流程",
            num: 1,
            tot_num: 1,
          },
        ],
      },
      {
        p_process_name: "车间流程",
        parent_process_id: 36,
        child: [
          {
            process_name: "接单",
            process_id: 85,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 12,
            tot_num: 12,
          },
          {
            process_name: "测量",
            process_id: 91,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 11,
            tot_num: 12,
          },
          {
            process_name: "报价",
            process_id: 92,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "复尺",
            process_id: 93,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "备料",
            process_id: 94,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "拆单",
            process_id: 95,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "跟单",
            process_id: 96,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "排单",
            process_id: 97,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "开料",
            process_id: 98,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "封边",
            process_id: 99,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "打孔",
            process_id: 100,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "特殊加工",
            process_id: 101,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "分拣",
            process_id: 102,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 5,
            tot_num: 6,
          },
          {
            process_name: "包装",
            process_id: 103,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 6,
            tot_num: 7,
          },
          {
            process_name: "入库",
            process_id: 104,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
          {
            process_name: "出库",
            process_id: 105,
            parent_process_id: 36,
            p_process_name: "车间流程",
            num: 7,
            tot_num: 8,
          },
        ],
      },
    ],
  },
  navDetail(e: any) {
    const index = getDataSet(e).index.split(",");
    const pProcess = this.data.process[index[0]];
    const cProcess = pProcess.child[index[1]];
    const { p_process_name, process_name, process_id } = cProcess;
    const title = encodeURIComponent(`${p_process_name} - ${process_name}`);
    console.log(title);
    wx.navigateTo({
      url: `/pages/produce/processManageDetail/processManageDetail?process_id=${process_id}&title=${title}`,
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});

