Răsfoiți Sursa

多公司配置模块制作,钉钉登录对接

asd26269546 1 an în urmă
părinte
comite
0bf0f57f12

+ 4 - 0
src/assets/css/index.scss

@@ -226,4 +226,8 @@ li {
     button{
         border:none!important;
     }
+}
+
+:root{
+    --van-field-label-width:8.2em!important;
 }

+ 16 - 3
src/lang/index.js

@@ -1,12 +1,25 @@
 import { createI18n } from 'vue-i18n'
-export default createI18n({ 
+import VueI18n from 'vue-i18n'
+import {
+  post,
+  get
+} from '@/utils/axios'
+const i18n = createI18n({ 
   legacy: false, // 让 setup 函数可以通过 t 访问
   globalInjection: true, // 让 template 可以像 vue2 那样使用 $t 来访问
   locale: 'zh-cn',
   fallbackLocale: 'zh-cn',
   
   messages: {
-    'zh-cn': require('./cn.js').lang,
+    // 'zh-cn': require('./cn.js').lang,
     'en-us': require('./en.js').lang,
   }
-})
+})
+console.log(require('./cn.js').lang)
+get('/open/multilingual/getJson',{}).then(res=>{
+  console.log(JSON.parse(res.data),'下载')
+  window.localStorage.setItem('lang',res.data)
+  i18n.global.setLocaleMessage('zh-cn', require('./cn.js').lang)
+})
+
+export default i18n

+ 11 - 1
src/router/index.js

@@ -75,7 +75,17 @@ const routes = [{
 				name: '官网',
 				component: () => import('../views/working/iframWinfaster.vue')
 			},
-			
+			//公共模块
+			{
+				path: 'multiCompanyConfig',
+				name: '多公司配置',
+				component: () => import('../views/commonModule/multiCompanyConfig/index.vue')
+			},
+			{
+				path: 'multiCompanyConfigAdd',
+				name: '多公司配置新增',
+				component: () => import('../views/commonModule/multiCompanyConfig/add.vue')
+			},
 			{
 				path: 'xiamenList',
 				name: '发酵机列表',

+ 3 - 1
src/utils/axios.js

@@ -78,9 +78,11 @@ service.interceptors.response.use(res => {
     return res.data
   }
   if (code === 401) {
+    
     showFailToast('登录失效,请重新登录');
     console.log(router)
-    router.push({ path: '/' })
+    localStorage.clear()
+    router.push({ path: '/?id=$CORPID$' })
     
 
     return Promise.reject('无效的会话,或者会话已过期,请重新登录。')

+ 242 - 0
src/views/commonModule/multiCompanyConfig/add.vue

@@ -0,0 +1,242 @@
+<template>
+	<div class="form">
+		<van-nav-bar
+			title="多公司配置"
+			left-text="返回"
+			left-arrow
+			@click-left="onClickLeft"
+		>
+		</van-nav-bar>
+		<testForm
+			v-model="formData.data"
+			:formOption="formOption"
+			:formConfig="formConfig"
+			:rules="rules"
+			@onSubmit="onSubmit"
+			ref="formDom"
+		></testForm>
+	</div>
+</template>
+
+<script setup>
+import { ref, getCurrentInstance, onMounted, reactive } from 'vue'
+import { showSuccessToast, showToast } from 'vant'
+import { useRoute } from 'vue-router'
+import { getUserInfo } from '@/utils/auth'
+import testForm from '@/components/testForm/index.vue'
+const proxy = getCurrentInstance().proxy
+const route = useRoute()
+const show = ref(false)
+const typeModal = ref(false)
+const unitModal = ref(false)
+const classification = ref([])
+const formData = reactive({
+	data: {
+		type:null,
+	},
+})
+const formDom = ref(null)
+const formOption = reactive({
+	readonly: false, //用于控制整个表单是否只读
+	disabled: false,
+	labelAlign: 'top',
+	scroll: true,
+	labelWidth: '62pk',
+	// hiddenSubmitBtn: true,
+})
+const formConfig = reactive([
+	{
+		type: 'input',
+		itemType: 'text',
+		label: '公司名称',
+		prop: 'name',
+		clearable: true,
+	},
+	{
+		type: 'input',
+		itemType: 'text',
+		label: '英文名',
+		prop: 'nameEn',
+		clearable: true,
+	},
+	{
+		type: 'picker',
+		label: '企业类型',
+		prop: 'type',
+		itemType: 'onePicker',
+		showPicker: false,
+		fieldNames: {
+			text: 'dictValue',
+			value: 'dictKey',
+		},
+        data:[],
+	},
+
+	{
+		type: 'input',
+		itemType: 'text',
+		label: '统一社会信用代码',
+		prop: 'uscCode',
+		clearable: true,
+	},
+	{
+		type: 'input',
+		itemType: 'text',
+		label: '法定代表人',
+		prop: 'legalPersonName',
+		clearable: true,
+	},
+	{
+		type: 'input',
+		itemType: 'text',
+		label: '注册资本',
+		prop: 'registeredCapital',
+		clearable: true,
+	},
+	{
+		type: 'picker',
+		label: '营业时间(开始)',
+		prop: 'startDate',
+		itemType: 'datePicker',
+		showPicker: false,
+		split: '-',
+	},
+	{
+		type: 'picker',
+		label: '营业时间(结束)',
+		prop: 'stopDate',
+		itemType: 'datePicker',
+		showPicker: false,
+		split: '-',
+	},
+	{
+		type: 'cascader',
+		label: '注册地址',
+		prop: 'city',
+		itemType: 'city',
+		showPicker: false,
+	},
+	{
+		type: 'input',
+		itemType: 'textarea',
+		label: '详细地址',
+		prop: 'detailedAddress',
+	},
+	{
+		type: 'picker',
+		label: '纳税人资质',
+		prop: 'taxpayerQualification',
+		clearable: true,
+		itemType: 'onePicker',
+		showPicker: false,
+		fieldNames: {
+			text: 'dictValue',
+			value: 'dictKey',
+		},
+	},
+	{
+		type: 'input',
+		itemType: 'text',
+		label: '海关注册代码',
+		prop: 'crCode',
+		clearable: true,
+	},
+	{
+		type: 'upload',
+		label: '企业logo',
+		prop: 'enterpriseLogoList',
+	},
+	{
+		type: 'upload',
+		label: '法人签名',
+		prop: 'larSignList',
+	},
+	{
+		type: 'upload',
+		label: '公章',
+		prop: 'officialSealList',
+	},
+	{
+		type: 'upload',
+		label: '合同章',
+		prop: 'contractSealList',
+	},
+])
+const rules = {
+	name: [{ required: true, message: '公司名称不能为空' }],
+}
+const unitList = ref([])
+
+const getDict = () => {
+	proxy
+		.post('/tenantDict/getDict', {
+			dictCode: 'enterprise_type',
+		})
+		.then((res) => {
+			formConfig[2].data = res.data
+		})
+	proxy
+		.post('/tenantDict/getDict', {
+			dictCode: 'taxpayer_qualification',
+		})
+		.then((res) => {
+			formConfig[10].data = res.data
+		})
+}
+getDict()
+const fileList = ref([])
+const onOversize = () => {
+	showToast('文件大小不能超过 5MB')
+}
+const onClickLeft = () => history.back()
+const onSubmit = () => {
+	if (
+        formData.data.cityObj &&
+		formData.data.cityObj.selectedOptions &&
+		formData.data.cityObj.selectedOptions.length > 0
+	) {
+		formData.data.countryId = formData.data.cityObj.selectedOptions[0].value
+		if (formData.data.cityObj.selectedOptions.length == 2) {
+			formData.data.cityId =
+				formData.data.cityObj.selectedOptions[1].value
+		} else {
+			formData.data.provinceId =
+				formData.data.cityObj.selectedOptions[1].value
+			formData.data.cityId =
+				formData.data.cityObj.selectedOptions[2].value
+		}
+	}
+	proxy.post('/corporation/' + route.query.type, formData.data).then(() => {
+		showSuccessToast('添加成功')
+		setTimeout(() => {
+			history.back()
+		}, 500)
+	})
+}
+const treeToList = (arr) => {
+	let res = [] // 用于存储递归结果(扁平数据)
+	// 递归函数
+	let fn = (source) => {
+		source.forEach((el) => {
+			res.push(el)
+			el.children && el.children.length > 0 ? fn(el.children) : '' // 子级递归
+		})
+	}
+	fn(arr)
+	return res
+}
+onMounted(() => {
+	if (route.query.id) {
+		proxy
+			.post('/corporation/detail', { id: route.query.id })
+			.then((resDetail) => {
+				formData.data = resDetail.data
+			})
+	}
+})
+</script>
+<style lang="scss" scoped>
+.form {
+	padding-bottom: 50px;
+}
+</style>

+ 109 - 0
src/views/commonModule/multiCompanyConfig/index.vue

@@ -0,0 +1,109 @@
+<template>
+  <van-nav-bar title="多公司配置" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
+    <template #right> 添加 </template>
+  </van-nav-bar>
+  <van-search v-model="req.keyword" placeholder="请输入搜索关键词" @search="onRefresh" />
+  <van-pull-refresh v-model="loading" @refresh="onRefresh">
+    <div class="list">
+      <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" style="margin-bottom: 60px">
+        <commonList :data="listData" @onClick="toDtl" :config="listConfig"></commonList>
+      </van-list>
+    </div>
+  </van-pull-refresh>
+</template>
+<script setup>
+import { ref, getCurrentInstance } from "vue";
+import commonList from "@/components/common-list.vue";
+import { useRoute } from "vue-router";
+
+const loading = ref(false);
+const router = useRoute();
+const req = ref({
+  pageNum: 1,
+  keyword: null,
+  definition: "2",
+});
+const finished = ref(false);
+const proxy = getCurrentInstance().proxy;
+const listData = ref([]);
+const classification = ref([]);
+const listConfig = ref([
+  {
+    label: "公司名称",
+    prop: "name",
+  },
+  {
+    label: "公司英文名称",
+    prop: "nameEn",
+  },
+  {
+    label: "法定代表人",
+    prop: "legalPersonName",
+  },
+]);
+const onRefresh = () => {
+  req.value.pageNum = 1;
+  finished.value = false;
+  getList("refresh");
+};
+const onLoad = () => {
+  getClassification();
+};
+const onClickLeft = () => proxy.$router.push("/main/working");
+const onClickRight = () => {
+  proxy.$router.push({
+    path: "multiCompanyConfigAdd",
+    query: {
+        type: 'add'
+    },
+  });
+};
+const toDtl = (row) => {
+  proxy.$router.push({
+    path: "multiCompanyConfigAdd",
+    query: {
+      id: row.id,
+      type: 'edit'
+    },
+  });
+};
+const treeToList = (arr) => {
+  let res = []; // 用于存储递归结果(扁平数据)
+  // 递归函数
+  let fn = (source) => {
+    source.forEach((el) => {
+      res.push(el);
+      el.children && el.children.length > 0 ? fn(el.children) : ""; // 子级递归
+    });
+  };
+  fn(arr);
+  return res;
+};
+const getClassification = () => {
+  getList();
+};
+const getList = (type) => {
+  
+  loading.value = true;
+  proxy
+    .post("/corporation/page", req.value)
+    .then((res) => {
+      listData.value = type === "refresh" ? res.data.rows : listData.value.concat(res.data.rows);
+      if (req.value.pageNum * 10 >= res.data.total) {
+        
+        finished.value = true;
+      }
+      req.value.pageNum++;
+      loading.value = false;
+    })
+    .catch((err) => {
+      loading.value = false;
+    });
+};
+</script>
+
+<style lang="scss" scoped>
+.list {
+  min-height: 70vh;
+}
+</style>

+ 2 - 1
src/views/home/index.vue

@@ -69,8 +69,9 @@ const logout = () => {
 		proxy.get('logout').then((res) => {
             if (res.code == 200) {
                 showSuccessToast('退出成功')
+				localStorage.clear()
                 //清除路由历史记录
-                proxy.$router.replace('/')
+                proxy.$router.replace('/?id=$CORPID$')
             } else {
                 showFailToast('退出失败')
             }

+ 11 - 5
src/views/login.vue

@@ -2,9 +2,7 @@
 	<div class="login">
 		<div class="login-header">
 			<img class="logo" src="../assets/logo.png" />
-
 			<h2>{{ $t('login.title') }}</h2>
-			
 		</div> 
 		<div class="login-form">
 			<van-field
@@ -129,7 +127,8 @@
 <script setup>
 import 'vant/lib/index.css'
 import { ref, getCurrentInstance, onMounted } from 'vue'
-import { setUserInfo, setToken, getUserInfo } from '@/utils/auth'
+import { setUserInfo, setToken, getUserInfo,getToken } from '@/utils/auth'
+import { showSuccessToast, showFailToast,showConfirmDialog } from 'vant'
 import * as dd from 'dingtalk-jsapi'
 import axios from 'axios'
 import { useRoute } from 'vue-router'
@@ -188,6 +187,7 @@ const getInfo = () => {
 				window.localStorage.setItem('tenantId', '')
 				window.localStorage.setItem('rememberMe', false)
 			}
+			showSuccessToast('登录成功')
 			proxy.$router.push('/main')
 		}
 	})
@@ -207,16 +207,22 @@ onMounted(() => {
 const loginData = ref({})
 let code = ref('')
 const ddLoginInit = () => {
+	if(getToken()){
+		proxy.$router.push('/main')
+	}
 	dd.ready(function () {
+		alert(route.query.id)
 		dd.runtime.permission.requestAuthCode({
 			corpId: route.query.id, // 企业id
 			onSuccess: function (info) {
 				code.value = info.code
+				
 				proxy
 					.post('/open/dingApi/getUserToken', { code: code.value,corpId:route.query.id })
 					.then((res) => {
-						loginData.value = res
-						alert(JSON.stringify(res))
+						
+						setToken(res.data)
+						getInfo()
 					})
 			},
 			onFail: function (err) {

+ 21 - 1
src/views/main.vue

@@ -20,11 +20,31 @@
 <script setup>
 import { ref, getCurrentInstance } from 'vue'
 import { getUserInfo } from '@/utils/auth';
-
+import {lang} from '@/lang/cn'
 import '@/assets/icon/iconfont.css'
 import 'vant/lib/index.css';
 import axios from 'axios'
 const tenantId = getUserInfo().tenantId
 const proxy = getCurrentInstance().proxy
 const tabType = ref('home')
+//判断是否为开发环境.如果是开发环境,则同步前后台中文配置表
+const isDev = process.env.NODE_ENV === 'development'
+if(isDev) {
+	
+	let networkLang = window.localStorage.getItem('lang')
+	if(networkLang || networkLang != JSON.stringify(lang)){
+		try {
+			networkLang = JSON.parse(networkLang)
+			networkLang.app.cn = lang
+			proxy.post('/open/multilingual/setJson',{configValue:JSON.stringify(networkLang)}).then(res=>{
+				console.log(res)
+			})
+		} catch (error) {
+			
+		}
+	}
+	
+
+}
+
 </script>

+ 0 - 1
src/views/working/index.vue

@@ -30,7 +30,6 @@ const getRouter = () => {
   proxy.get("getRouters", {}).then((res) => {
     for (let i = 0; i < res.data.length; i++) {
       const element = res.data[i];
-      console.log(element.type)
       if(element.type == 2){
         
         routerData.value = element.children;