Commit 7cfe5110 authored by 陈珠河's avatar 陈珠河

Feat: 新用户首次登陆需要修改密码

parent d6742245
...@@ -15,3 +15,7 @@ npm run serve ...@@ -15,3 +15,7 @@ npm run serve
npm run build npm run build
``` ```
### 注意事项
1.每次更新模板后、若想切换到最新版本,请将旧依赖全部删除后重新下载依赖(缓存配置文件没有实时更新)
2.公司内部脚手架ssnpm暂时不要使用到模板项目中
...@@ -107,7 +107,6 @@ const config = { ...@@ -107,7 +107,6 @@ const config = {
resolve(res.data); resolve(res.data);
}) })
.catch(res => { .catch(res => {
console.log('post error:', res);
reject(res); reject(res);
}); });
}); });
...@@ -133,7 +132,6 @@ const config = { ...@@ -133,7 +132,6 @@ const config = {
resolve(res.data); resolve(res.data);
}) })
.catch(res => { .catch(res => {
console.log('post error:', res);
reject(res); reject(res);
}); });
}); });
...@@ -159,7 +157,6 @@ const config = { ...@@ -159,7 +157,6 @@ const config = {
resolve(res.data); resolve(res.data);
}) })
.catch(res => { .catch(res => {
console.log('post error:', res);
reject(res); reject(res);
}); });
}); });
......
...@@ -19,15 +19,15 @@ const Api = { ...@@ -19,15 +19,15 @@ const Api = {
/** /**
* *
* @param {*} businessDefinitionId
* @param {*} taskId * @param {*} taskId
* @param {*} linkId
* @param {*} linkKey
*/ */
getBusinessStartForm(businessDefinitionId) { getBusinessStartForm(businessDefinitionId, taskId) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/v1.1.0/workflow/workflowForm/getBusinessStartForm', baseUrl + '/v1.1.0/workflow/workflowForm/getBusinessStartForm',
{ {
businessDefinitionId businessDefinitionId,
taskId
} }
); );
}, },
......
...@@ -65,15 +65,20 @@ body { ...@@ -65,15 +65,20 @@ body {
} }
.form-render { .form-render {
padding-top: 28px; padding-top: 44px;
width: 1000px; width: 1000px;
margin: 0 auto; margin: 0 auto;
} }
.is-required { .submit-dialog,
.return-work,
.transform-work {
.is-required {
.el-textarea__inner { .el-textarea__inner {
border-color: $--color-danger; border-color: $--color-danger;
} }
}
} }
.page-view { .page-view {
...@@ -97,7 +102,7 @@ body { ...@@ -97,7 +102,7 @@ body {
@include e(wrapper) { @include e(wrapper) {
width: 100%; width: 100%;
height: 100%; max-height: 20vh;
background-color: inherit; background-color: inherit;
overflow: auto; overflow: auto;
......
...@@ -115,7 +115,7 @@ export function refreshTab(tabId) { ...@@ -115,7 +115,7 @@ export function refreshTab(tabId) {
// 设置高级或某此控件需要【数组】、【对象】类型 // 设置高级或某此控件需要【数组】、【对象】类型
// 比如upload_list, sign // 比如upload_list, sign
const checkObjectJson = data => { const checkObjectJson = data => {
const widgets = ['upload_list', 'sign', 'select']; const widgets = ['upload_list', 'sign', 'select', 'approval'];
if (widgets.includes(data.type)) { if (widgets.includes(data.type)) {
return data.model; return data.model;
} else { } else {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
>{{ item.operationName }}</el-button> >{{ item.operationName }}</el-button>
</div> </div>
<div class="form-render" v-if="isReRender"> <div class="form-render" v-if="!isLoading">
<smart-form :data="formData" :value="values" ref="generateForm"></smart-form> <smart-form :data="formData" :value="values" ref="generateForm"></smart-form>
</div> </div>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
ref="submitTask" ref="submitTask"
:nextLinks="submitData.subTask" :nextLinks="submitData.subTask"
:nextLinkUsers="submitData.userInfos" :nextLinkUsers="submitData.userInfos"
@closed="submitTaskDialogVisible = false" @closed="handleSubmitTaskClose"
@save="handleSubmitTaskSave" @save="handleSubmitTaskSave"
></submit-task> ></submit-task>
<!-- 转办 --> <!-- 转办 -->
...@@ -112,7 +112,6 @@ export default { ...@@ -112,7 +112,6 @@ export default {
return { return {
apiFnName: '', // 加载API的方法名 apiFnName: '', // 加载API的方法名
isLoading: false, // 加载过渡 isLoading: false, // 加载过渡
isReRender: true, // 重渲染
headBtnLists: [], // 头部的按钮列表 headBtnLists: [], // 头部的按钮列表
headCustomBtns: [], // 头部自定义按钮,一般包含表达式 headCustomBtns: [], // 头部自定义按钮,一般包含表达式
formData: {}, formData: {},
...@@ -126,7 +125,8 @@ export default { ...@@ -126,7 +125,8 @@ export default {
submitTaskDialogVisible: false, // 提交dialog submitTaskDialogVisible: false, // 提交dialog
submitData: {}, submitData: {},
transformDialogVisible: false, // 转办dialog transformDialogVisible: false, // 转办dialog
returnTaskVisible: false // 退回dialog returnTaskVisible: false, // 退回dialog
createTaskId: '' // 新建工作后保存时的taskId
}; };
}, },
...@@ -146,8 +146,8 @@ export default { ...@@ -146,8 +146,8 @@ export default {
}, },
// 刷新 // 刷新
refresh() { refresh(taskId) {
this.fetch(); this.fetch(taskId);
}, },
handleResultHtml(data, key) { handleResultHtml(data, key) {
...@@ -159,10 +159,12 @@ export default { ...@@ -159,10 +159,12 @@ export default {
return {}; return {};
} }
}, },
/**
fetch() { * 新建工作时,保存的时候后端返回tId
*/
fetch(tId) {
let taskId = getTaskId() || this.childrenData.taskId; let taskId = getTaskId() || this.childrenData.taskId;
const linkId = getLinkId() || this.childrenData.linkId; const linkId = tId ? tId : getLinkId() || this.childrenData.linkId;
const linkKey = getLinkKey() || this.childrenData.linkKey; const linkKey = getLinkKey() || this.childrenData.linkKey;
// console.log(taskId, linkId, linkKey) // console.log(taskId, linkId, linkKey)
let apiFn = 'renderFormByTaskId'; let apiFn = 'renderFormByTaskId';
...@@ -178,9 +180,7 @@ export default { ...@@ -178,9 +180,7 @@ export default {
taskId = getFinishForm(); taskId = getFinishForm();
apiFn = 'renderFinishForm'; apiFn = 'renderFinishForm';
} }
this.isLoading = true; this.isLoading = true;
Api[apiFn](taskId, linkId, linkKey) Api[apiFn](taskId, linkId, linkKey)
.then(res => { .then(res => {
this.isLoading = false; this.isLoading = false;
...@@ -238,6 +238,7 @@ export default { ...@@ -238,6 +238,7 @@ export default {
'template' 'template'
); );
this.formData = JSON.parse(_data) || {}; this.formData = JSON.parse(_data) || {};
this.$set(this.formData.config, 'disabled', ourselfOperationShow['sign'] || false);
this.handleModels( this.handleModels(
this.handleResultHtml(detailMap['result'], 'values') this.handleResultHtml(detailMap['result'], 'values')
); );
...@@ -392,7 +393,7 @@ export default { ...@@ -392,7 +393,7 @@ export default {
handleFormData() { handleFormData() {
const formData = this.$refs['generateForm'].getData(); const formData = this.$refs['generateForm'].getData();
const fomrDataSub = new FormData(); const fomrDataSub = new FormData();
Object.keys(formData).map(key => { Object.keys(formData).forEach(key => {
let value = formData[key]; let value = formData[key];
// 转JSON字符串提交 // 转JSON字符串提交
if (typeof formData[key] === 'object' && formData[key] !== null) { if (typeof formData[key] === 'object' && formData[key] !== null) {
...@@ -420,6 +421,9 @@ export default { ...@@ -420,6 +421,9 @@ export default {
// console.log(res) // console.log(res)
if (res.status === 0) { if (res.status === 0) {
notification('success', '保存成功!'); notification('success', '保存成功!');
if (!res.data.taskId) return false;
this.createTaskId = res.data.taskId;
this.refresh(res.data.taskId);
} else { } else {
notification('warning', res.message || '保存失败,请重试!'); notification('warning', res.message || '保存失败,请重试!');
} }
...@@ -479,6 +483,7 @@ export default { ...@@ -479,6 +483,7 @@ export default {
if (this.$refs['submitTask']) { if (this.$refs['submitTask']) {
this.$refs['submitTask'].$data.isSubmiting = false; this.$refs['submitTask'].$data.isSubmiting = false;
} }
if (res.status === 0) { if (res.status === 0) {
this.submitTaskDialogVisible = false; this.submitTaskDialogVisible = false;
// 关闭标签 // 关闭标签
...@@ -518,24 +523,18 @@ export default { ...@@ -518,24 +523,18 @@ export default {
]; ];
this.isLoading = true; this.isLoading = true;
this.isReRender = false;
Api.doPostPromiseJson(apiUrl, submitData) Api.doPostPromiseJson(apiUrl, submitData)
.then(res => { .then(res => {
this.isLoading = false; this.isLoading = false;
this.isReRender = true;
// console.log('signTasks', res)
if (res.status === 0) { if (res.status === 0) {
this.handleDataReturnErr(res.data, '接办成功'); this.handleDataReturnErr(res.data, '接办成功');
// 刷新
this.refresh();
} else { } else {
notification('warning', res.message || '接办失败,请重试'); notification('warning', res.message || '接办失败,请重试');
} }
}) })
.catch(err => { .catch(err => {
this.isLoading = false; this.isLoading = false;
this.isReRender = true;
notification('error', err.message || '接办失败!'); notification('error', err.message || '接办失败!');
}); });
}, },
...@@ -595,7 +594,16 @@ export default { ...@@ -595,7 +594,16 @@ export default {
this.isLoading = false; this.isLoading = false;
// console.log('receiveTasks', res) // console.log('receiveTasks', res)
if (res.status === 0) { if (res.status === 0) {
this.handleDataReturnErr(res.data, '退件成功'); // 关闭和刷新标签页
setTimeout(() => {
refreshTab();
closeTab();
outerNotice({
type: 'success',
title: '退件成功!',
message: res.message
});
}, 150);
} else { } else {
notification('warning', res.message || '退件失败,请重试'); notification('warning', res.message || '退件失败,请重试');
} }
...@@ -772,6 +780,12 @@ export default { ...@@ -772,6 +780,12 @@ export default {
/* eslint-disable no-eval */ /* eslint-disable no-eval */
eval(item.operation); eval(item.operation);
} }
},
// 关闭提交后的对话框事件
handleSubmitTaskClose() {
this.submitTaskDialogVisible = false;
this.refresh(this.createTaskId);
} }
} }
}; };
......
...@@ -83,6 +83,8 @@ const config = { ...@@ -83,6 +83,8 @@ const config = {
* @param {Object} options * @param {Object} options
*/ */
doGetPromise(url, params, options = {}) { doGetPromise(url, params, options = {}) {
console.log(_config.baseUrl);
console.log(axios.defaults.baseURL);
const { timeout = 30000, ...arg } = options; const { timeout = 30000, ...arg } = options;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -100,7 +102,6 @@ const config = { ...@@ -100,7 +102,6 @@ const config = {
}).then(response => { }).then(response => {
resolve(response.data); resolve(response.data);
}).catch(response => { }).catch(response => {
// console.error('ajax error:', response)
reject(response); reject(response);
}); });
}); });
...@@ -129,7 +130,6 @@ const config = { ...@@ -129,7 +130,6 @@ const config = {
}).then(res => { }).then(res => {
resolve(res.data); resolve(res.data);
}).catch(res => { }).catch(res => {
console.log('post error:', res);
reject(res); reject(res);
}); });
}); });
...@@ -154,7 +154,6 @@ const config = { ...@@ -154,7 +154,6 @@ const config = {
}).then(res => { }).then(res => {
resolve(res.data); resolve(res.data);
}).catch(res => { }).catch(res => {
// console.log('post error:', res)
reject(res); reject(res);
}); });
}); });
...@@ -179,7 +178,6 @@ const config = { ...@@ -179,7 +178,6 @@ const config = {
}).then(res => { }).then(res => {
resolve(res.data); resolve(res.data);
}).catch(res => { }).catch(res => {
console.log('post error:', res);
reject(res); reject(res);
}); });
}); });
......
...@@ -93,6 +93,10 @@ const Api = { ...@@ -93,6 +93,10 @@ const Api = {
return config.doGetPromise('/authorityManage/queryUserSysAuthorizeInfoList', { return config.doGetPromise('/authorityManage/queryUserSysAuthorizeInfoList', {
moduleId moduleId
}); });
},
// 修改密码
updatePassword(userId, newPassword) {
return config.doGetPromise('/index/updatePassword', {id: userId, newPassword: newPassword});
} }
}; };
......
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
</div> </div>
<!-- <router-view name="loginDialog"></router-view> --> <!-- <router-view name="loginDialog"></router-view> -->
<password-dialog :visiableDialog="visiableDialog" @visiable-dialog="handlePasswordDialogEvent"></password-dialog>
</div> </div>
</template> </template>
<script> <script>
import AppHeader from './common/Header'; import AppHeader from './common/Header';
import AppNavigation from './Navigation'; import AppNavigation from './Navigation';
import passwordDialog from './common/PasswordDialog';
import { changeTheme } from '@/utils/global'; import { changeTheme } from '@/utils/global';
export default { export default {
...@@ -25,7 +27,8 @@ export default { ...@@ -25,7 +27,8 @@ export default {
components: { components: {
AppHeader, AppHeader,
AppNavigation AppNavigation,
passwordDialog
}, },
computed: { computed: {
...@@ -39,7 +42,8 @@ export default { ...@@ -39,7 +42,8 @@ export default {
data() { data() {
return { return {
oldNavigation: null oldNavigation: null,
visiableDialog: false
}; };
}, },
...@@ -53,11 +57,23 @@ export default { ...@@ -53,11 +57,23 @@ export default {
}, },
mounted() { mounted() {
this.handleUserFirstLogin();
}, },
methods: { methods: {
hasOwnProperty(obj, key) { hasOwnProperty(obj, key) {
return obj.hasOwnProperty(key); return obj.hasOwnProperty(key);
},
// 处理用户首次登陆时,需要修改密码
handleUserFirstLogin() {
const userInfo = this.$store.state.userInfo;
if (userInfo && userInfo.Status && userInfo.Status === 1) {
this.visiableDialog = true;
}
},
// 修改密码框显示事件
handlePasswordDialogEvent(visiable) {
this.visiableDialog = !!visiable;
} }
} }
}; };
......
<template>
<el-dialog title="首次登录,请修改密码"
:visible.sync="dialogVisiable"
width="400px"
:before-close="handleBeforeCloseDialog"
:close-on-click-modal="false"
:close-on-press-escape="false">
<el-form
:rules="passwordRule"
:model="passwordForm"
ref="pswForm">
<el-form-item label="新密码" :label-width="formLabelWidth" prop="password">
<el-input v-model="passwordForm.password" type="password" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="确认新密码" :label-width="formLabelWidth" prop="comfirmPassword">
<el-input v-model="passwordForm.comfirmPassword" type="password" autocomplete="off"
@keyup.native.enter="handleSubmitPassword"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary"
:loading="passSubmiting"
@click="handleSubmitPassword">
确 定
</el-button>
</div>
</el-dialog>
</template>
<script>
import sha1 from 'js-sha1';
import Api from '@/api';
export default {
name: 'PasswordDialog',
props: {
visiableDialog: {
type: Boolean,
default: false
}
},
computed: {
dialogVisiable() {
return this.visiableDialog;
}
},
data() {
const password = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'));
} else {
if (this.passwordForm.comfirmPassword !== '') {
this.$refs.pswForm.validateField('comfirmPassword');
}
callback();
}
};
const comfirmPassword = (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'));
} else if (value !== this.passwordForm.password) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
};
return {
dialogVisible: false,
passSubmiting: false,
formLabelWidth: '100px',
passwordForm: {
password: '',
comfirmPassword: ''
},
passwordRule: {
password: [
{required: true, message: '不能为空', trigger: 'change'},
{validator: password, trigger: 'blur'}
],
comfirmPassword: [
{required: true, message: '不能为空', trigger: 'change'},
{validator: comfirmPassword, trigger: 'blur'}
]
}
};
},
methods: {
handleBeforeCloseDialog() {
this.$message.warning('首次登陆,请修改密码哟!');
this.$emit('visiable-dialog', true);
},
// 提交密码修改
handleSubmitPassword() {
this.$refs['pswForm'].validate(valid => {
if (valid) {
this.passSubmiting = true;
const userPassword = sha1(this.passwordForm.password).toUpperCase();
const userInfo = this.$store.state.userInfo;
Api.updatePassword(userInfo.userId, userPassword).then(res => {
if (res.status === 0) {
this.modifyPassDialogVisible = false;
this.loginOutAndReturnLogin();
} else {
this.$message({
message: '修改密码出错',
type: 'warning',
duration: 2000
});
}
}).catch(err => {
this.passSubmiting = false;
this.$message({
message: err.message,
type: 'error',
duration: 2000
});
});
}
});
},
// 退出账号并返回到登陆
loginOutAndReturnLogin() {
Api.logout().then(res => {
if (res.status === 0) {
this.$message({
message: '密码修改成功, 系统将在3s后为您跳转到登录页',
type: 'success',
duration: 3000
});
setTimeout(() => {
this.$router.replace({
path: '/login'
});
this.passSubmiting = false;
}, 3000);
} else {
this.$message({
type: 'warning',
message: '密码修改成功,由于' + res.message
});
}
}).catch(err => {
this.passSubmiting = false;
this.$message({
type: 'error',
message: err.message
});
});
}
}
};
</script>
...@@ -89,5 +89,5 @@ module.exports = { ...@@ -89,5 +89,5 @@ module.exports = {
}, },
// IE兼容 // IE兼容
// transpileDependencies: ['element-ui/src', 'element-ui/packages'] transpileDependencies: ['element-ui/src', 'element-ui/packages']
}; };
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 to comment