| | |
| | | /> |
| | | <div style="width: 120px"> |
| | | <ApiSelect |
| | | v-if="byOrg" |
| | | :api="getOrgTree" |
| | | style="width: 100%" |
| | | :params="{ userId: useUserStore().getUserInfo.userId }" |
| | | v-model:value="factory" |
| | | labelField="deptName" |
| | | valueField="deptCode" |
| | | placeholder="请选择工厂" |
| | | @change="changeProd" |
| | | /> |
| | | <ApiSelect |
| | | v-if="byProd" |
| | | :api="getProdTree" |
| | | style="width: 100%" |
| | | :params="{ userId: useUserStore().getUserInfo.userId }" |
| | |
| | | valueField="deptCode" |
| | | placeholder="请选择工厂" |
| | | @change="changeProd" |
| | | /></div> |
| | | /> |
| | | </div> |
| | | <UserDropDown :theme="getHeaderTheme" /> |
| | | |
| | | <SettingDrawer v-if="getShowSetting" :class="`${prefixCls}-action__item`" /> |
| | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { Layout } from 'ant-design-vue'; |
| | | import { computed, onMounted, ref, unref } from 'vue'; |
| | | import { computed, nextTick, onMounted, ref, unref, watch } from 'vue'; |
| | | import { ApiSelect } from '/@/components/Form/index'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { AppLocalePicker, AppLogo, AppSearch } from '@/components/Application'; |
| | |
| | | import { createAsyncComponent } from '@/utils/factory/createAsyncComponent'; |
| | | import { propTypes } from '@/utils/propTypes'; |
| | | import { ApiTreeSelect } from '@/components/Form'; |
| | | import { getProdTree } from '/@/api/tigerapi/dept'; |
| | | import { getProdTree, getOrgTree } from '/@/api/tigerapi/dept'; |
| | | |
| | | import LayoutMenu from '../menu/index.vue'; |
| | | import LayoutTrigger from '../trigger/index.vue'; |
| | | import { ErrorAction, FullScreen, LayoutBreadcrumb, Notify, UserDropDown } from './components'; |
| | | import { SwitchOrgCode } from '/@/api/sys/user'; |
| | | import { getSysParam } from '/@/api/tigerapi/system'; |
| | | import { treeParamsListItem } from '/@/api/tigerapi/model/systemModel'; |
| | | import { isNullOrEmpty } from '/@/utils/is'; |
| | | |
| | | const SettingDrawer = createAsyncComponent(() => import('@/layouts/default/setting/index.vue'), { |
| | | loading: true, |
| | |
| | | getIsMixSidebar, |
| | | } = useMenuSetting(); |
| | | const { getUseErrorHandle, getShowSettingButton, getSettingButtonPosition } = useRootSetting(); |
| | | const factory = ref(useUserStore().getUserInfo.prodCode); |
| | | const factory = ref(''); // ref(useUserStore().getUserInfo.prodCode); |
| | | const byOrg = ref(false); |
| | | const byProd = ref(false); |
| | | const params = ref<treeParamsListItem[]>([]); |
| | | const { |
| | | getHeaderTheme, |
| | | getShowFullScreen, |
| | |
| | | }, |
| | | ]; |
| | | }); |
| | | |
| | | watch( |
| | | [() => byOrg.value, () => byProd.value], |
| | | (newVal, oldVal) => { |
| | | nextTick(() => { |
| | | if (!isNullOrEmpty(newVal[0])) { |
| | | if (newVal[0]) { |
| | | factory.value = useUserStore().getUserInfo.orgCode; |
| | | } |
| | | } |
| | | if (!isNullOrEmpty(newVal[1])) { |
| | | if (byProd.value) { |
| | | factory.value = useUserStore().getUserInfo.prodCode; |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | { deep: true, immediate: true }, |
| | | ); |
| | | |
| | | const getShowSetting = computed(() => { |
| | | if (!unref(getShowSettingButton)) { |
| | |
| | | return unref(getSplit) ? MenuModeEnum.HORIZONTAL : null; |
| | | }); |
| | | |
| | | onMounted(async () => { |
| | | var action = await getSysParam({ group: 'ByAuthActive' }); |
| | | if (action.IsSuccessed) { |
| | | params.value = action.Data; |
| | | if (action.Data.filter((x) => x.PARAM_CODE == 'ByOrgActive')[0].PARAM_VALUE == 'Y') { |
| | | byOrg.value = true; |
| | | } |
| | | if (action.Data.filter((x) => x.PARAM_CODE == 'ByProdActive')[0].PARAM_VALUE == 'Y') { |
| | | byProd.value = true; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | function changeProd(e) { |
| | | const userInfo = useUserStore().getToken; |
| | | const org = useUserStore().getUserInfo.prodCode; |
| | | // globSetting.useOrg == 'Y' |
| | | // ? useUserStore().getUserInfo.orgCode |
| | | // : useUserStore().getUserInfo.prodCode; |
| | | SwitchOrgCode(userInfo, '', e).then(() => { |
| | | if (org != e) { |
| | | let code = ''; |
| | | let orgCode = ''; |
| | | let prodCode = ''; |
| | | if (params.value.filter((x) => x.PARAM_CODE == 'ByOrgActive')[0].PARAM_VALUE == 'Y') { |
| | | code = useUserStore().getUserInfo.orgCode; |
| | | orgCode = e; |
| | | } |
| | | if (params.value.filter((x) => x.PARAM_CODE == 'ByProdActive')[0].PARAM_VALUE == 'Y') { |
| | | code = useUserStore().getUserInfo.prodCode; |
| | | prodCode = e; |
| | | } |
| | | SwitchOrgCode(userInfo, orgCode, prodCode).then(() => { |
| | | if (code != e) { |
| | | location.reload(); |
| | | } |
| | | }); |