曹睿
2025-04-22 03426aefbf891aa1fe3064d4301d17d5de869114
fix: 修复用户信息无法及时响应
已修改4个文件
53 ■■■■ 文件已修改
src/components/worker-calling-card/index.vue 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/production/index.vue 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/production/list/index.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/user.ts 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/worker-calling-card/index.vue
@@ -3,12 +3,12 @@
    <template #title>
      <view>
        <text class="font-medium">
          {{ user.nickName }}
          <text class="text-[#0D867F] text-xs">·{{ user.roleName }}</text>
          {{ userInfo?.nickName }}
          <text class="text-[#0D867F] text-xs">·{{ userInfo?.roles[0].roleName }}</text>
        </text>
      </view>
      <view>
        <text class="font-medium text-[#3D3D3D] text-sm">工号: {{ user.userName }}</text>
        <text class="font-medium text-[#3D3D3D] text-sm">工号: {{ userInfo?.userName }}</text>
      </view>
    </template>
    <view class="mt-2">
@@ -18,21 +18,8 @@
</template>
<script setup lang="ts">
import { useUserStore } from "@/store/modules/user";
import { nextTick } from "vue";
const userStore = useUserStore();
const userInfo: any = computed(() => userStore.userInfo);
const user = reactive({
  nickName: "",
  userName: "",
  roleName: "",
});
onLoad(() => {
  nextTick();
  user.nickName = userInfo.value.user?.nickName;
  user.userName = userInfo.value.user?.userName;
  user.roleName = userInfo.value.user?.roles[0].roleName;
});
const userInfo = computed(() => userStore.userInfo);
</script>
<style lang="scss" scoped>
.calling_card {
src/pages/production/index.vue
@@ -12,10 +12,20 @@
    </wd-row>
    <wd-tabs v-model="tab" auto-line-width>
      <wd-tab :title="`待生产(${total.wait})`" class="tab_bg">
        <ProductList :api="ManageApi.getProductList" state="待完成" @ok="changeWait" />
        <ProductList
          ref="waitRef"
          :api="ManageApi.getProductList"
          state="待完成"
          @ok="changeWait"
        />
      </wd-tab>
      <wd-tab :title="`已生产(${total.already})`" class="tab_bg">
        <ProductList :api="ManageApi.getProductList" state="已完成" @ok="changeAlready" />
        <ProductList
          ref="alreadyRef"
          :api="ManageApi.getProductList"
          state="已完成"
          @ok="changeAlready"
        />
      </wd-tab>
    </wd-tabs>
  </view>
@@ -23,9 +33,11 @@
<script lang="ts" setup>
import ManageApi from "@/api/product/manage";
import { onMounted, ref } from "vue";
import { ref } from "vue";
import ProductList from "./list/index.vue";
const waitRef = ref();
const alreadyRef = ref();
const tab = ref<number>(0);
const total = reactive({
  wait: 0,
@@ -39,8 +51,6 @@
const changeAlready = (num: number) => {
  total.already = num;
};
onMounted(() => {});
</script>
<style lang="scss" scoped>
@@ -48,12 +58,12 @@
  border-radius: unset;
}
.scan_box {
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 6px;
  background: #fff;
}
::v-deep .wd-tabs__line {
src/pages/production/list/index.vue
@@ -25,7 +25,8 @@
import ProductCard from "@/components/product_card/index.vue";
import { useUserStore } from "@/store/modules/user";
import zPaging from "@/components/z-paging/z-paging.vue";
const userStore = useUserStore();
const userInfo: any = computed(() => userStore.userInfo);
const pagingRef = ref();
const props = defineProps({
  api: {
@@ -54,10 +55,8 @@
};
const getList = async (pageNo: number, pageSize: number) => {
  const userStore = useUserStore();
  const userInfo: any = computed(() => userStore.userInfo);
  const { code, data } = await props.api({
    userName: userInfo.value.user?.userName,
    userName: userInfo.value.userName,
    state: props.state,
    current: pageNo,
    size: pageSize,
src/store/modules/user.ts
@@ -41,7 +41,8 @@
    return new Promise((resolve, reject) => {
      UserAPI.getUserInfo()
        .then((data: any) => {
          setUserInfo(data.data);
          console.log("获取用户信息成功", data.data.user);
          setUserInfo(data.data.user);
          userInfo.value = data.data.user;
          resolve(data.data);
        })