zhangwei
2025-08-22 83af3dd309889489f541fc8e21894c9f79e5788c
src/views/mine/index.vue
@@ -4,25 +4,40 @@
import { useUserStoreHook } from "@/store/modules/user";
import type { FormInstance, FormRules, UploadProps } from "element-plus";
import { cloneDeep } from "@pureadmin/utils";
import { onMounted, reactive, ref, watch } from "vue";
import { onMounted, reactive, ref, watch, computed, onBeforeUpdate } from "vue";
import { getToken } from "@/utils/auth";
const { route } = useNav();
import { baseUrlApi } from "@/api/util";
import { cusExtendInfo, changeCusExtend } from "@/api/mine";
import { Edit } from "@element-plus/icons-vue";
import { enterpriseTypes } from "@/api/register/index";
import {
  addDialog,
  closeDialog,
  updateDialog,
  closeAllDialog
} from "@/components/ReDialog";
import { initRouter, getTopMenu, handleAliveRoute } from "@/router/utils";
const isManager = useUserStoreHook().isManager;
import { type CusExtendDto } from "@/utils/auth";
const ruleFormRef = ref<FormInstance>();
const isLoading = ref(false);
const showDialog = ref(false);
const nowRole = ref({});
const nowRole = computed(() => {
  if (!state?.ruleForm?.exRoles) {
    return {};
  }
  let nowRoleLiet;
  let obj = {};
  let nowRole = useUserStoreHook()?.nowRole;
  if (state?.ruleForm?.exRoles.length > 1) {
    nowRoleLiet = state.ruleForm.exRoles.find(item => {
      return item.exRoleId == nowRole.id;
    });
    obj = Object.assign(nowRole, nowRoleLiet);
  } else {
    obj = Object.assign(nowRole, state.ruleForm.exRoles[0]);
  }
  return obj;
});
const userInfo = computed<CusExtendDto>(() => {
  let obj = useUserStoreHook().enterpriseInfo;
  return obj;
});
const state = reactive({
  userInfo: useUserStoreHook().enterpriseInfo,
  headers: {
@@ -40,7 +55,7 @@
    // 交易主体代码(同角色代码,不可空,最小长度为1)
    transactionCode: "", // string,必填
    // 交易主体名称
    transactionName: null, // string,可空
    transactionName: "", // string,可空
    // 营业执照文件路径
    businessLicense: null, // string,可空
    // 企业名称
@@ -78,7 +93,9 @@
    // 企业开户行
    bankName: null, // string,可空
    // 企业银行账号
    bankAccount: null // string,可空
    bankAccount: null, // string,可空
    bankAccountIMG: null,
    exRoles: null
  },
  enterpriseList: [],
  type: "",
@@ -186,24 +203,37 @@
  expirySeconds: 60, // 验证码过期时间
  phoneSeconds: 0, // 手机验证码倒计时
  roleList: [],
  showDialog: false
  showDialog: false,
  srcList: []
});
onMounted(async () => {
  state.ruleForm = cloneDeep(state.userInfo);
  state.ruleForm.enterpriseType = state.ruleForm.enterpriseType.split(",");
  nowRole.value = useUserStoreHook()?.nowRole;
  console.log(nowRole.value);
  // nowRole.value = useUserStoreHook()?.nowRole;
  if (nowRole.value) {
    state.ruleForm.transactionCode = nowRole.value.code;
    state.userInfo.transactionName = nowRole.value.name;
    // let nowRoleLiet;
    // if (state.ruleForm.exRoles.length > 1) {
    //   nowRoleLiet = state.ruleForm.exRoles.find(item => {
    //     return item.exRoleId == nowRole.value.id;
    //   });
    //   nowRole.value = Object.assign(nowRole.value, nowRoleLiet);
    // } else {
    //   nowRole.value = Object.assign(nowRole.value, state.ruleForm.exRoles[0]);
    // }
    // state.userInfo.transactionName = nowRole.value.name;
  } else {
    state.ruleForm.transactionCode = route.query.code;
    state.userInfo.enterpriseTypeName = route.query.name;
    state.ruleForm.transactionCode = route.query.code as string;
    // state.userInfo.enterpriseTypeName = route.query.name;
  }
  let restypes = await enterpriseTypes();
  state.enterpriseList = restypes?.result;
});
const showPreview = ref(false);
const showImg = (name: string | number) => {
  showPreview.value = true;
  state.srcList = [state.ruleForm[name]];
};
const isLeaf = data => {
  data.forEach(item => {
    if (!item.child) {
@@ -223,24 +253,24 @@
  }
};
const showImg = name => {
  addDialog({
    width: "40%",
    title: "查看营业执照",
    contentRenderer: () => <img src={state.userInfo[name]} />, // jsx 语法 (注意在.vue文件启用jsx语法,需要在script开启lang="tsx")
    closeCallBack: ({ options, args }) => {
      // options.props 是响应式的
      // const { formInline } = options.props as FormProps;
      // const text = `姓名:${formInline.user} 城市:${formInline.region}`;
      if (args?.command === "cancel") {
        // 您点击了取消按钮
        // active.value -= 1;
      } else if (args?.command === "sure") {
      } else {
      }
    }
  });
};
// const showImg = name => {
//   addDialog({
//     width: "40%",
//     title: "查看营业执照",
//     contentRenderer: () => <img src={state.userInfo[name]} />, // jsx 语法 (注意在.vue文件启用jsx语法,需要在script开启lang="tsx")
//     closeCallBack: ({ options, args }) => {
//       // options.props 是响应式的
//       // const { formInline } = options.props as FormProps;
//       // const text = `姓名:${formInline.user} 城市:${formInline.region}`;
//       if (args?.command === "cancel") {
//         // 您点击了取消按钮
//         // active.value -= 1;
//       } else if (args?.command === "sure") {
//       } else {
//       }
//     }
//   });
// };
const handleAvatarSuccess: UploadProps["onSuccess"] = (
  response,
  uploadFile
@@ -321,7 +351,10 @@
  let res = await changeCusExtend(obj);
  if (res.code == "200") {
    showDialog.value = false;
    await useUserStoreHook().getCusExtendInfo();
    await useUserStoreHook().changeLogoInExRule({
      ruleCode: useUserStoreHook().nowRole.code
    });
    initRouter();
    message("修改成功!", {
      type: "success"
    });
@@ -331,6 +364,22 @@
    });
  }
};
const handlebankAccountIMG: UploadProps["onSuccess"] = (
  response,
  uploadFile
) => {
  if (response.code == "200") {
    // state.ruleForm.businessLicense = URL.createObjectURL(uploadFile.raw!);
    state.ruleForm.bankAccountIMG = response.result;
  } else {
    message(response.message, {
      type: "error"
    });
  }
  isLoading.value = false;
};
defineOptions({
  name: "mine"
});
@@ -338,7 +387,13 @@
<template>
  <div>
    <el-descriptions class="margin-top" title="" :column="3" border>
    <el-descriptions
      v-if="state.userInfo.enterpriseName"
      class="margin-top"
      title=""
      :column="3"
      border
    >
      <!-- <template #extra>
      <el-button type="primary">Operation</el-button>
    </template> -->
@@ -346,14 +401,18 @@
        <template #label>
          <div class="cell-item">交易主体</div>
        </template>
        {{ state.userInfo.transactionName }}
        <el-tag v-if="!nowRole.hasFlsh" type="danger">资料审核中 </el-tag>
        {{ nowRole?.name }}
        <el-tag v-if="nowRole.steps == 2" type="success">审核已通过 </el-tag>
        <el-tag v-else-if="nowRole.steps == 3" type="danger"
          >资料未通过
        </el-tag>
        <el-tag v-else type="warning">资料审核中 </el-tag>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">企业名称</div>
        </template>
        {{ state.userInfo.enterpriseName }}
        {{ userInfo.enterpriseName }}
        <span @click="showImg('businessLicense')">
          <el-link type="primary" underline>查看营业执照</el-link>
@@ -363,62 +422,62 @@
        <template #label>
          <div class="cell-item">统一社会信用代码</div>
        </template>
        {{ state.userInfo.unifiedSocialCreditCode }}
        {{ userInfo.unifiedSocialCreditCode }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">注册资金</div>
        </template>
        {{ state.userInfo.registeredCapital }}
        {{ userInfo.registeredCapital }}
      </el-descriptions-item>
      <el-descriptions-item :span="2">
        <template #label>
          <div class="cell-item">企业类型</div>
        </template>
        {{ state.userInfo.enterpriseType }}
        {{ userInfo.enterpriseType }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">住所地</div>
        </template>
        {{ state.userInfo.residence }}
        {{ userInfo.residence }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">联系电话</div>
        </template>
        {{ state.userInfo.legalRepresentativePhone }}
        {{ userInfo.enterprisePhone }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">成立时间</div>
        </template>
        {{ state.userInfo.establishmentTime }}
        {{ userInfo.establishmentTime }}
      </el-descriptions-item>
      <el-descriptions-item :span="2">
        <template #label>
          <div class="cell-item">电子邮箱</div>
        </template>
        {{ state.userInfo.enterpriseEmail }}
        {{ userInfo.enterpriseEmail }}
      </el-descriptions-item>
      <el-descriptions-item :span="3" label-width="100">
        <template #label>
          <div class="cell-item">主营业务</div>
        </template>
        {{ state.userInfo.mainBusiness }}
        {{ userInfo.mainBusiness }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">法定代表人</div>
        </template>
        {{ state.userInfo.legalRepresentativeName }}
        {{ userInfo.legalRepresentativeName }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">身份证</div>
        </template>
        {{ state.userInfo.legalRepresentativeIdNumber }}
        {{ userInfo.legalRepresentativeIdNumber }}
        <span @click="showImg('legalRepresentativeIdCard')">
          <el-link type="primary" underline>查看身份证</el-link>
        </span>
@@ -427,19 +486,19 @@
        <template #label>
          <div class="cell-item">联系电话</div>
        </template>
        {{ state.userInfo.legalRepresentativePhone }}
        {{ userInfo.legalRepresentativePhone }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">业务经办人</div>
        </template>
        {{ state.userInfo.operatorName }}
        {{ userInfo.operatorName }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">身份证</div>
        </template>
        {{ state.userInfo.operatorIdNumber }}
        {{ userInfo.operatorIdNumber }}
        <span style="margin-right: auto" @click="showImg('operatorIdCard')">
          <el-link type="primary" underline>查看身份证</el-link>
        </span>
@@ -448,22 +507,30 @@
        <template #label>
          <div class="cell-item">联系电话</div>
        </template>
        {{ state.userInfo.operatorPhone }}
        {{ userInfo.operatorPhone }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">开户银行</div>
        </template>
        {{ state.userInfo.bankName }}
        {{ userInfo.bankName }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">银行账号</div>
        </template>
        {{ state.userInfo.bankAccount }}
        {{ userInfo.bankAccount }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <div class="cell-item">银行收款二维码</div>
        </template>
        <span style="margin-right: auto" @click="showImg('bankAccountIMG')">
          <el-link type="primary" underline>查看二维码</el-link>
        </span>
      </el-descriptions-item>
    </el-descriptions>
    <div class="m-5">
    <div v-if="isManager" class="m-5">
      <el-button type="primary" :icon="Edit" @click="() => (showDialog = true)"
        >修改资料</el-button
      >
@@ -539,8 +606,8 @@
                  <img
                    v-if="state.ruleForm.businessLicense"
                    :src="state.ruleForm.businessLicense"
                    width="200px"
                    height="150px"
                    width="80px"
                    height="50px"
                  />
                  <el-button v-else type="primary">上传</el-button>
                </el-upload>
@@ -635,7 +702,43 @@
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
              <el-form-item label="开户行" prop="bankName">
                <el-input
                  v-model="state.ruleForm.bankName"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
              <el-form-item label="银行账号" prop="bankAccount">
                <el-input
                  v-model="state.ruleForm.bankAccount"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="开户行收款二维码" prop="bankAccountIMG">
                <el-upload
                  :action="`${baseUrlApi('/api/upFile/file')}`"
                  :show-file-list="false"
                  :on-success="handlebankAccountIMG"
                  :before-upload="beforeAvatarUpload"
                  :headers="state.headers"
                >
                  <img
                    v-if="state.ruleForm.bankAccountIMG"
                    :src="state.ruleForm.bankAccountIMG"
                    width="85.6px"
                    height="5.4px"
                  />
                  <el-button v-else type="primary">上传</el-button>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="法定代表人" prop="legalRepresentativeIdCard">
@@ -733,22 +836,6 @@
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
              <el-form-item label="开户行" prop="bankName">
                <el-input
                  v-model="state.ruleForm.bankName"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
              <el-form-item label="银行账号" prop="bankAccount">
                <el-input
                  v-model="state.ruleForm.bankAccount"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
@@ -761,6 +848,12 @@
        </span>
      </template>
    </el-dialog>
    <el-image-viewer
      v-if="showPreview"
      :url-list="state.srcList"
      show-progress
      @close="showPreview = false"
    />
  </div>
</template>