Commit 513dfaa1 by lishengfu

update

parent fb8d001f
# self-service # typescript
## Project setup ## Project setup
``` ```
npm install yarn install
``` ```
### Compiles and hot-reloads for development ### Compiles and hot-reloads for development
``` ```
npm run serve yarn run serve
``` ```
### Compiles and minifies for production ### Compiles and minifies for production
``` ```
npm run build yarn run build
``` ```
### Run your tests ### Run your tests
``` ```
npm run test yarn run test
``` ```
### Lints and fixes files ### Lints and fixes files
``` ```
npm run lint yarn run lint
``` ```
### Customize configuration ### Customize configuration
......
module.exports = { module.exports = {
presets: [ presets: [
'@vue/app' '@vue/app'
],
plugins: [
['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']
] ]
} }
This diff could not be displayed because it is too large.
{ {
"name": "self-service", "name": "typescript",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build" "build": "vue-cli-service build",
"lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@types/qs": "^6.9.3", "@types/qs": "^6.9.3",
"amfe-flexible": "^2.2.1", "amfe-flexible": "^2.2.1",
"axios": "^0.19.2", "axios": "^0.19.2",
"core-js": "^3.6.4", "core-js": "^2.6.11",
"oidc-client": "^1.10.1", "oidc-client": "^1.10.1",
"qs": "^6.9.4", "qs": "^6.9.4",
"qs.js": "^0.1.12", "vant": "^2.2.0",
"ts-loader": "^7.0.5", "vue": "^2.6.10",
"vant": "^2.8.3",
"vue": "^2.6.11",
"vue-axios": "^2.1.5",
"vue-class-component": "^7.2.3", "vue-class-component": "^7.2.3",
"vue-property-decorator": "^8.4.1", "vue-router": "^3.3.1",
"vue-router": "^3.1.6", "vuex": "^3.4.0"
"vuex": "^3.1.3"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.3.0", "@vue/cli-plugin-babel": "^3.8.0",
"@vue/cli-plugin-typescript": "^4.3.0", "@vue/cli-plugin-typescript": "^3.8.1",
"@vue/cli-service": "^4.3.0", "@vue/cli-service": "^3.8.3",
"babel-plugin-import": "^1.13.0", "less": "^3.9.0",
"less": "^3.0.4",
"less-loader": "^5.0.0", "less-loader": "^5.0.0",
"postcss-pxtorem": "^5.1.1", "postcss-pxtorem": "^5.1.1",
"ts-import-plugin": "^1.6.6", "ts-import-plugin": "^1.5.5",
"typescript": "~3.8.3", "typescript": "^3.5.1",
"vue-template-compiler": "^2.6.11" "vue-property-decorator": "^8.4.2",
"vue-template-compiler": "^2.6.10"
} }
} }
No preview for this file type
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title> <title>typescript</title>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> <strong>We're sorry but typescript doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
......
<template> <template>
<router-view /> <div>
<router-view />
</div>
</template> </template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
export default class App extends Vue {
}
</script>
<style lang="less">
</style>
// import "babel-polyfill"; //import "babel-polyfill";
import Oidc from "oidc-client"; import Oidc from "oidc-client";
var mgr = new Oidc.UserManager({ var mgr = new Oidc.UserManager({
...@@ -8,6 +8,7 @@ var mgr = new Oidc.UserManager({ ...@@ -8,6 +8,7 @@ var mgr = new Oidc.UserManager({
}); });
mgr.signinRedirectCallback().then(function (user: any) { mgr.signinRedirectCallback().then(function (user: any) {
let returnUrl = localStorage.getItem("returnUrl"); let returnUrl = localStorage.getItem("returnUrl");
if (returnUrl) { if (returnUrl) {
window.location.href = returnUrl; window.location.href = returnUrl;
......
import Vue from 'vue' import Vue from 'vue';
import App from './App.vue' import App from './App.vue';
import router from './router' import router from './router'
import store from './store' import store from './store'
import "./assets/css/index.less"
import 'amfe-flexible/index.js' import 'amfe-flexible/index.js'
import server from '@/services/install'; import server from '@/services/install';
Vue.config.productionTip = false;
Vue.config.productionTip = false Vue.use(server)
Vue.use(server);
new Vue({ new Vue({
router, router,
store, store,
render: h => h(App) render: (h) => h(App),
}).$mount('#app') }).$mount('#app');
...@@ -13,12 +13,12 @@ const isOpenHttps = process.env.VUE_APP_OPEN_HTTPS; ...@@ -13,12 +13,12 @@ const isOpenHttps = process.env.VUE_APP_OPEN_HTTPS;
* 加载和设置路由 * 加载和设置路由
*/ */
const router = new Router({ const router = new Router({
mode: 'history', mode: 'history',
base: process.env.BASE_URL,//'/', base: process.env.BASE_URL,//'/',
routes: [ routes: [
...employee_router ...employee_router
] ]
}); });
...@@ -27,8 +27,8 @@ const router = new Router({ ...@@ -27,8 +27,8 @@ const router = new Router({
* @param authCode 授权码 * @param authCode 授权码
*/ */
function loginByAuthcode(authCode: any) { function loginByAuthcode(authCode: any) {
let loginArgs = { extraQueryParams: { authcode: authCode } }; let loginArgs = { extraQueryParams: { authcode: authCode } };
mgr.signIn(loginArgs); mgr.signIn(loginArgs);
} }
/** /**
...@@ -36,15 +36,15 @@ function loginByAuthcode(authCode: any) { ...@@ -36,15 +36,15 @@ function loginByAuthcode(authCode: any) {
* @param authcode 授权码 * @param authcode 授权码
*/ */
function autoLogin(authcode: any) { function autoLogin(authcode: any) {
mgr.getUser().then(user => { mgr.getUser().then(user => {
if (user == null) { if (user == null) {
loginByAuthcode(authcode); loginByAuthcode(authcode);
} else { } else {
//如果已经登录,则先退出 //如果已经登录,则先退出
localStorage.setItem("authcode", authcode); localStorage.setItem("authcode", authcode);
mgr.signOut(); mgr.signOut();
} }
}) })
} }
...@@ -52,43 +52,44 @@ function autoLogin(authcode: any) { ...@@ -52,43 +52,44 @@ function autoLogin(authcode: any) {
* 请求路由前 一些操作 * 请求路由前 一些操作
*/ */
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// console.log(isOpenHttps); // console.log(isOpenHttps);
if (isOpenHttps === "true" && location.href.startsWith("http://")) { if (isOpenHttps === "true" && location.href.startsWith("http://")) {
location.href = location.href.replace("http://", "https://"); location.href = location.href.replace("http://", "https://");
} }
const requiresAuth = to.matched.some(record => record.meta.requiresAuth); const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
localStorage.setItem("returnUrl", to.path);
localStorage.setItem("returnUrl", to.path);
//更改标题
if (to.meta.title) { //更改标题
document.title = to.meta.title; if (to.meta.title) {
} document.title = to.meta.title;
}
let authcode = localStorage.getItem("authcode")
if (authcode) { let authcode = localStorage.getItem("authcode")
localStorage.removeItem("authcode");
loginByAuthcode(authcode)
} else {
let authcode = to.query.authcode;
if (authcode) { if (authcode) {
autoLogin(authcode); localStorage.removeItem("authcode");
loginByAuthcode(authcode)
} else { } else {
if (requiresAuth) { let authcode = to.query.authcode;
mgr.getUser().then(user => { if (authcode) {
if (user == null) { autoLogin(authcode);
mgr.signIn(); } else {
} else { if (requiresAuth) {
next(); mgr.getUser().then(user => {
} if (user == null) {
}); mgr.signIn();
} } else {
else { next();
next(); }
} });
}
else {
next();
}
}
} }
}
}); });
......
...@@ -3,6 +3,20 @@ ...@@ -3,6 +3,20 @@
*/ */
export interface EmployeeInterface { export interface EmployeeInterface {
getUserInfo(params: any): Promise<any>; getUserInfo(params: any): Promise<any>;
getWorkInfoDetail(params: any): Promise<any>; getWorkInfoList(params: any): Promise<any>; //获取工作信息列表
putEmail(params: any): Promise<any>; getWorkInfoDetail(params: any): Promise<any>; //获取工作信息详情
getPersonInfo(params: any): Promise<any>; //获取个人信息
savePersonInfo(params: any): Promise<any>; //保存个人信息
getContactInfo(params: any): Promise<any>; //获取联系信息
saveContactInfo(params: any): Promise<any>; //保存联系信息
getSocialInfo(params: any): Promise<any>; //获取社保信息
saveSocialInfo(params: any): Promise<any>; //保存社保信息
getWageCardInfo(params: any): Promise<any>; //获取工资卡信息
saveWageCardInfo(params:any):Promise<any>; //保存工资卡信息
getEduExperience(params:any):Promise<any>; //获取教育经历
getEduExperienceDetial(params:any):Promise<any>; //获取教育信息详情
addEduExperience(params:any):Promise<any>; //新增教育信息
updateEduExperience(params:any):Promise<any>; //修改教育信息
getTechnologyExperience(params:any):Promise<any>; //获取技术特长
updateTechnologyExperience(params:any):Promise<any>; //修改技术特长
} }
...@@ -52,7 +52,16 @@ class EmployeeService implements EmployeeInterface { ...@@ -52,7 +52,16 @@ class EmployeeService implements EmployeeInterface {
} }
/** /**
* 获取工作信息 * 获取工作信息列表
* @param params 请求参数
*/
public getWorkInfoList(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/work`;
return request.get(url, params, this.header)
}
/**
* 获取工作信息详情
* @param params 请求参数 * @param params 请求参数
*/ */
...@@ -62,17 +71,131 @@ class EmployeeService implements EmployeeInterface { ...@@ -62,17 +71,131 @@ class EmployeeService implements EmployeeInterface {
} }
/** /**
* 修改邮箱 * 获取个人信息
* @param params 请求参数
*/
public getPersonInfo(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/info`;
return request.get(url, params, this.header)
}
/**
* 保存个人信息
* @param params 请求参数
*/
public savePersonInfo(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/info`;
return request.post(url, params, this.header)
}
/**
* 获取联系信息
* @param params 请求参数
*/
public getContactInfo(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/contact/info`;
return request.get(url, params, this.header)
}
/**
* 保存联系信息
* @param params 请求参数
*/
public saveContactInfo(params: any): Promise<any> {
let url = `/api/user/contact/${params.edId}/info`;
return request.post(url, params, this.header)
}
/**
* 获取社保信息
* @param params 请求参数
*/
public getSocialInfo(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/unit/relation`;
return request.get(url, params, this.header)
}
/**
* 保存社保信息
* @param params 请求参数 * @param params 请求参数
*/ */
public putEmail(params: any): Promise<any> { public saveSocialInfo(params: any): Promise<any> {
// // /v2/internal/account/{userId}/download/{accountId}/summary let url = `/api/user/employee/unit/relation/save`;
// let url3=aa('/v2/internal/account/{userId}/download/{accountId}/summary',params) return request.post(url, params, this.header)
// let url1 = `${urls.employeeUrl}/${this.version}/internal/account/${params.userId}/download/${params.accountId}/summary`;
let url = `${urls.employeeUrl}/${this.version}/users/${this.sub}/email`;
return request.put(url, params, this.header);
} }
/**
* 获取工资卡信息
* @param params 请求参数
*/
public getWageCardInfo(params: any): Promise<any> {
let url = `/api/user/contact/${params.edId}/salary/card/info`;
return request.get(url, params, this.header)
}
/**
* 保存工资卡信息
* @params params
*/
public saveWageCardInfo(params: any): Promise<any> {
let url = `/api/user/contact/salary/card/info`;
return request.post(url, params, this.header)
}
/**
* 获取教育经历
* @param params 请求参数
*/
public getEduExperience(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/education`;
return request.get(url, params, this.header)
}
/**
* 获取教育信息详细
* @param params
*/
public getEduExperienceDetial(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/education/detial`;
return request.get(url, params, this.header)
}
/**
* 新增教育信息
* @param params
*/
public addEduExperience(params: any): Promise<any> {
let url = `/api/user/employee/edu/info`;
return request.post(url, params, this.header)
}
/**
* 修改教育信息
* @param params
*/
public updateEduExperience(params: any): Promise<any> {
let url = `/api/user/employee/edu/info`;
return request.put(url, params, this.header)
}
/**
* 获取技术特长
* @param params
*/
public getTechnologyExperience(params: any): Promise<any> {
let url = `/api/user/employee/${params.edId}/expertise/info`;
return request.get(url, params, this.header)
}
/**
* 修改技术特长
* @param params
*/
public updateTechnologyExperience(params: any): Promise<any> {
let url = `/api/user/employee/expertise/info`;
return request.put(url, params, this.header)
}
} }
......
import Vue, { VNode } from 'vue' import Vue, { VNode } from 'vue';
declare global { declare global {
namespace JSX { namespace JSX {
...@@ -7,7 +7,7 @@ declare global { ...@@ -7,7 +7,7 @@ declare global {
// tslint:disable no-empty-interface // tslint:disable no-empty-interface
interface ElementClass extends Vue {} interface ElementClass extends Vue {}
interface IntrinsicElements { interface IntrinsicElements {
[elem: string]: any [elem: string]: any;
} }
} }
} }
declare module '*.vue' { declare module '*.vue' {
import Vue from 'vue' import Vue from 'vue';
export default Vue export default Vue;
} }
<template> <template>
<div class="home"> <div class="home">
<van-button type="primary" ></van-button> <van-button type="primary" >普通按钮</van-button>
</div> </div>
</template> </template>
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
"jsx": "preserve", "jsx": "preserve",
"importHelpers": true, "importHelpers": true,
"moduleResolution": "node", "moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"experimentalDecorators":true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"types": [ "types": [
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"src/**/*.tsx", "src/**/*.tsx",
"src/**/*.vue", "src/**/*.vue",
"tests/**/*.ts", "tests/**/*.ts",
"tests/**/*.tsx", "src/api/index.js" "tests/**/*.tsx"
], ],
"exclude": [ "exclude": [
"node_modules" "node_modules"
......
const path = require("path");
const merge = require('webpack-merge'); const merge = require('webpack-merge');
const tsImportPluginFactory = require('ts-import-plugin'); const tsImportPluginFactory = require('ts-import-plugin');
module.exports = { module.exports = {
// 基本路径
publicPath: "/",
// 输出文件目录
outputDir: "dist",
pages: { outputDir: "dist",
app: { publicPath: process.env.NODE_ENV === 'production' ? '/selfservice/' : '/',
entry: './src/main.ts',
template: 'public/index.html',
filename: 'index.html', pages: {
favicon: 'public/favicon.ico', app: {
chunks: ['app', 'chunk-vendors'], entry: './src/main.ts',
excludeChunks: ['silent-renew-oidc'] template: 'public/index.html',
}, filename: 'index.html',
silentrenewoidc: { favicon: 'public/favicon.ico',
entry: './src/common/silent-renew.ts', chunks: ['app', 'chunk-vendors'],
template: 'public/silent-renew.html', excludeChunks: ['silent-renew-oidc']
filename: 'silent-renew.html',
favicon: 'public/favicon.ico',
excludeChunks: ['app']
},
callback: {
entry: './src/common/callback.ts',
template: 'public/callback.html',
filename: 'callback.html',
favicon: 'public/favicon.ico',
excludeChunks: ['app']
},
},
// eslint-loader 是否在保存的时候检查
lintOnSave: true,
// webpack配置
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
chainWebpack: config => {
config.module
.rule('tsx')
.use('ts-loader')
.loader('ts-loader')
.tap(options => {
options = merge(options, {
transpileOnly: true,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryName: "vant",
libraryDirectory: "es",
style: true
})
]
}),
compilerOptions: {
module: 'es2015'
}
});
return options;
//return Object.assign(options || {}, { allowTsInNodeModules: true });
});
},
configureWebpack: config => {
if (process.env.NODE_ENV === "production") {
// 为生产环境修改配置...
config.mode = "production";
} else {
// 为开发环境修改配置...
config.mode = "development";
}
}, },
// 生产环境是否生成 sourceMap 文件 silentrenewoidc: {
productionSourceMap: true, entry: './src/common/silent-renew.ts',
// css相关配置 template: 'public/silent-renew.html',
css: { filename: 'silent-renew.html',
// 是否使用css分离插件 ExtractTextPlugin favicon: 'public/favicon.ico',
extract: true, excludeChunks: ['app']
// 开启 CSS source maps?
sourceMap: false,
// css预设器配置项
loaderOptions: {},
// 启用 CSS modules for all css / pre-processor files.
modules: false,
//requireModuleExtension
}, },
// use thread-loader for babel & TS in production build callback: {
// enabled by default if the machine has more than 1 cores entry: './src/common/callback.ts',
parallel: require("os").cpus().length > 1, template: 'public/callback.html',
// PWA 插件相关配置 filename: 'callback.html',
// see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa favicon: 'public/favicon.ico',
pwa: {}, excludeChunks: ['app']
// webpack-dev-server 相关配置
devServer: {
open: true,//process.platform === "darwin",
host: "0.0.0.0",
port: 8080,
https: false,
hotOnly: false,
proxy: {
"/api": {
target: "http://192.168.1.101:8080",
// target: "http://192.168.1.46:8001",
// target: "http://106.120.107.150:8001",
ws: true,
changeOrigin: true,
pathRewrite: {
"^/api": "/"
}
},
},
// historyApiFallback: {
// rewrites: [
// { from: /^\/single/, to: '/single.html' },
// ],
// },
before: app => { }
}, },
// 第三方插件配置 },
pluginOptions: { // eslint-loader 是否在保存的时候检查
'style-resources-loader': { lintOnSave: true,
preProcessor: 'scss', // webpack配置
patterns: [] // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
} chainWebpack: config => {
config.module
.rule('ts')
.use('ts-loader')
.tap(options => {
options = merge(options, {
transpileOnly: true,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryName: 'vant',
libraryDirectory: 'es',
style: true
})
]
}),
compilerOptions: {
module: 'es2015'
}
});
return options;
});
},
configureWebpack: config => {
if (process.env.NODE_ENV === "production") {
// 为生产环境修改配置...
config.mode = "production";
} else {
// 为开发环境修改配置...
config.mode = "development";
}
},
// 生产环境是否生成 sourceMap 文件
productionSourceMap: true,
// css相关配置
css: {
// 是否使用css分离插件 ExtractTextPlugin
extract: true,
// 开启 CSS source maps?
sourceMap: false,
// css预设器配置项
loaderOptions: {},
// 启用 CSS modules for all css / pre-processor files.
modules: false,
//requireModuleExtension
},
// use thread-loader for babel & TS in production build
// enabled by default if the machine has more than 1 cores
parallel: require("os").cpus().length > 1,
// PWA 插件相关配置
// see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
pwa: {},
// webpack-dev-server 相关配置
devServer: {
open: false,//process.platform === "darwin",
host: "0.0.0.0",
port: 8080,
https: false,
hotOnly: false,
// proxy: {
// "/api": {
// target: "http://192.168.1.101:8080",
// // target: "http://192.168.1.46:8001",
// // target: "http://106.120.107.150:8001",
// ws: true,
// changeOrigin: true,
// pathRewrite: {
// "^/api": "/"
// }
// },
// },
// historyApiFallback: {
// rewrites: [
// { from: /^\/single/, to: '/single.html' },
// ],
// },
before: app => { }
},
// 第三方插件配置
pluginOptions: {
'style-resources-loader': {
preProcessor: 'scss',
patterns: []
} }
}; }
\ No newline at end of file
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment