Ben Lin
2025-01-01 3f3817a39238b262155cd5ec76fa351bb344602d
src/views/sys/login/LoginForm.vue
@@ -26,6 +26,15 @@
    </FormItem>
    <FormItem name="factory" class="enter-x dept">
      <ApiSelect
        v-if="byOrg"
        :api="getTreeList"
        v-model:value="formData.factory"
        labelField="deptName"
        valueField="deptCode"
        placeholder="请选择工厂"
      />
      <ApiSelect
        v-if="byProd"
        :api="getProdTreeList"
        v-model:value="formData.factory"
        labelField="deptName"
@@ -90,7 +99,7 @@
  </Form>
</template>
<script lang="ts" setup>
  import { reactive, ref, unref, computed } from 'vue';
  import { reactive, ref, unref, computed, onMounted, onUnmounted } from 'vue';
  import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue';
  // import {
@@ -104,11 +113,12 @@
  import { ApiSelect } from '/@/components/Form/index';
  import { useI18n } from '@/hooks/web/useI18n';
  import { useMessage } from '@/hooks/web/useMessage';
  import { getProdTreeList } from '/@/api/tigerapi/dept';
  import { getProdTreeList, getTreeList } from '/@/api/tigerapi/dept';
  import { useUserStore } from '@/store/modules/user';
  import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin';
  import { useDesign } from '@/hooks/web/useDesign';
  import { AccountInfo } from '/@/api/tigerapi/model/systemModel';
  import { getSysParam } from '/@/api/tigerapi/system';
  //import { onKeyStroke } from '@vueuse/core';
  const ACol = Col;
@@ -126,6 +136,8 @@
  const formRef = ref();
  const loading = ref(false);
  const rememberMe = ref(false);
  const byOrg = ref(false);
  const byProd = ref(false);
  const formData = reactive({
    account: '',
@@ -139,6 +151,18 @@
  const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN);
  onMounted(async () => {
    var action = await getSysParam({ group: 'ByAuthActive' });
    if (action.IsSuccessed) {
      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;
      }
    }
  });
  async function handleLogin() {
    const data = await validForm();
    if (!data) return;
@@ -148,7 +172,7 @@
      const accountInfo: AccountInfo = {
        useR_CODE: data.account,
        password: data.password,
        ORG_CODE: '', //globSetting.useOrg == 'Y' ? orgData.dept : '',
        ORG_CODE: data.factory, //globSetting.useOrg == 'Y' ? orgData.dept : '',
        ad_info: Info.ad_info,
        ip: Info.ip,
        PROD_CODE: data.factory, //globSetting.useOrg == 'N' ? orgData.dept : '',