/*
 * @Author: 廖明明
 * @Date: 2022-03-31 16:36:19
 * @LastEditors: 廖明明
 * @LastEditTime: 2022-04-01 17:45:03
 * @Description:vuex入口文件
 */
import Vue from "vue";
import Vuex from "vuex";

import user from "@/store/modules/user";

Vue.use(Vuex);

const myPlugin = (store) => {
  // 当 store 初始化后调用
  let vuexStorage = uni.getStorageSync("vuexStorage");
  if (vuexStorage) {
    console.log(vuexStorage)
    store.replaceState(vuexStorage);
  }
  store.subscribe((mutation, state) => {
    uni.setStorageSync("vuexStorage", state);
  });
};

export default new Vuex.Store({
  state: {
    isShowSeiminModel: false, //是否显示切换科室弹窗
    qucikCreateOrderType: '', //快捷建单类型
    qucikCreateOrderTypeId: '', //快捷建单类型id
    deptDisplay: 1, //护士端科室显示选择(名称还是别名)1是名称,2是别名
    updateTipsForNurses: '', //护士端更新提示
    specimenButton: '', //标本按钮文字
    //护士科室切换提示自动关闭设置
    // (1)	当用户设置为正数时,用户必须查看此窗体指定秒数。
    // (2)	当用户设置为负数时,用户可点击知道了也可倒计时自动关闭。
    // (3)	如果用户填写0则为无自动关闭和强制查看时间。
    nurseDeptSwitchTip: 0,
    // 搜索到的科室-searchDept
    searchDeptResult: {},
    // 搜索科室需要传递的参数
    searchDeptParams: {},
  },
  mutations: {
    //是否显示切换科室弹窗
    changeSeiminModel(state, args) {
      state.isShowSeiminModel = args;
    },
    //快捷建单类型
    changeQucikCreateOrderType(state, args = {}) {
      state.qucikCreateOrderType = args.type;
      state.qucikCreateOrderTypeId = args.taskTypeId;
    },
    //护士端科室显示选择(名称还是别名)1是名称,2是别名
    changeDeptDisplay(state, args) {
      state.deptDisplay = args;
    },
    //护士端更新提示
    changeUpdateTipsForNurses(state, args) {
      state.updateTipsForNurses = args;
    },
    //标本按钮文字
    changeSpecimenButton(state, args) {
      state.specimenButton = args;
    },
    //护士科室切换提示自动关闭设置
    changeNurseDeptSwitchTip(state, args) {
      state.nurseDeptSwitchTip = args;
    },
    //搜索到的科室-searchDept
    changeSearchDeptResult(state, args) {
      state.searchDeptResult = args;
    },
    //搜索科室需要传递的参数
    changeSearchDeptParams(state, args) {
      state.searchDeptParams = args;
    },
  },
  modules: {
    user,
  },
  plugins: [myPlugin],
});