优化vuex mutations
This commit is contained in:
parent
1f08c596a4
commit
c8f88dc3ee
@ -113,8 +113,6 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import {mapMutations} from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -129,9 +127,6 @@ export default {
|
||||
code: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapMutations(['setUserInfo']),
|
||||
},
|
||||
methods: {
|
||||
reCode() {
|
||||
this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random())
|
||||
@ -167,8 +162,9 @@ export default {
|
||||
}
|
||||
this.loadIng++;
|
||||
$A.ajaxc({
|
||||
url: $A.apiUrl('users/login?type=' + this.loginType),
|
||||
url: $A.apiUrl('users/login'),
|
||||
data: {
|
||||
type: this.loginType,
|
||||
email: this.email,
|
||||
password: this.password,
|
||||
code: this.code,
|
||||
@ -178,7 +174,7 @@ export default {
|
||||
},
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
this.setUserInfo(data);
|
||||
this.$store.commit('setUserInfo', data);
|
||||
//
|
||||
this.goNext();
|
||||
} else {
|
||||
|
@ -231,7 +231,7 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import {mapMutations, mapState} from 'vuex'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -252,14 +252,13 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$store.commit("getUserInfo");
|
||||
this.$store.commit('getUserInfo');
|
||||
},
|
||||
deactivated() {
|
||||
this.addShow = false;
|
||||
},
|
||||
computed: {
|
||||
...mapState(['projectList']),
|
||||
...mapMutations(['getProjectList']),
|
||||
},
|
||||
watch: {
|
||||
'$route' (route) {
|
||||
@ -353,7 +352,7 @@ export default {
|
||||
this.$set(this.addData, 'template', 0);
|
||||
//
|
||||
this.loadIng++;
|
||||
this.getProjectList(() => {
|
||||
this.$store.commit('getProjectList', () => {
|
||||
this.loadIng--;
|
||||
});
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@
|
||||
<script>
|
||||
import DragInput from "../../../components/DragInput";
|
||||
import ScrollerY from "../../../components/ScrollerY";
|
||||
import {mapMutations, mapState} from "vuex";
|
||||
import {mapState} from "vuex";
|
||||
import DialogView from "./DialogView";
|
||||
import DialogUpload from "./DialogUpload";
|
||||
|
||||
@ -67,7 +67,6 @@ export default {
|
||||
|
||||
computed: {
|
||||
...mapState(['userId', 'dialogId', 'dialogDetail', 'dialogMsgLoad', 'dialogMsgList']),
|
||||
...mapMutations(["spliceDialogMsg"]),
|
||||
|
||||
peopleNum() {
|
||||
return this.dialogDetail.type === 'group' ? $A.runNum(this.dialogDetail.people) : 0;
|
||||
@ -108,7 +107,7 @@ export default {
|
||||
text: this.msgText,
|
||||
},
|
||||
error:() => {
|
||||
this.spliceDialogMsg({id: tempId});
|
||||
this.$store.commit('spliceDialogMsg', {id: tempId});
|
||||
},
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret !== 1) {
|
||||
@ -117,7 +116,7 @@ export default {
|
||||
content: msg
|
||||
});
|
||||
}
|
||||
this.spliceDialogMsg({
|
||||
this.$store.commit('spliceDialogMsg', {
|
||||
id: tempId,
|
||||
data: ret === 1 ? data : null
|
||||
});
|
||||
@ -185,11 +184,11 @@ export default {
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
this.spliceDialogMsg({id: file.tempId});
|
||||
this.$store.commit('spliceDialogMsg', {id: file.tempId});
|
||||
break;
|
||||
|
||||
case 'success':
|
||||
this.spliceDialogMsg({id: file.tempId, data: file.data});
|
||||
this.$store.commit('spliceDialogMsg', {id: file.tempId, data: file.data});
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -828,7 +828,7 @@
|
||||
<script>
|
||||
import TaskPriority from "./TaskPriority";
|
||||
import TaskAdd from "./TaskAdd";
|
||||
import {mapState, mapMutations} from "vuex";
|
||||
import {mapState} from "vuex";
|
||||
import UserInput from "../../../components/UserInput";
|
||||
export default {
|
||||
name: "ProjectList",
|
||||
@ -880,7 +880,6 @@ export default {
|
||||
'taskUndoneShow',
|
||||
'taskCompletedShow'
|
||||
]),
|
||||
...mapMutations(['toggleBoolean', 'getProjectList', 'getProjectDetail']),
|
||||
|
||||
panelTask() {
|
||||
const {searchText} = this;
|
||||
@ -984,7 +983,7 @@ export default {
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.getProjectDetail(this.addData.project_id);
|
||||
this.$store.commit('getProjectDetail', this.addData.project_id);
|
||||
this.addShow = false;
|
||||
this.addData = {
|
||||
owner: 0,
|
||||
@ -1037,7 +1036,7 @@ export default {
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.getProjectDetail(this.userData.project_id);
|
||||
this.$store.commit('getProjectDetail', this.userData.project_id);
|
||||
this.userShow = false;
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
@ -1060,7 +1059,7 @@ export default {
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.getProjectDetail(this.transferData.project_id);
|
||||
this.$store.commit('getProjectDetail', this.transferData.project_id);
|
||||
this.transferShow = false;
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
@ -1088,7 +1087,7 @@ export default {
|
||||
this.$Modal.remove();
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.getProjectList();
|
||||
this.$store.commit('getProjectList');
|
||||
this.goForward({path: '/manage/dashboard'}, true);
|
||||
}else{
|
||||
$A.modalError(msg, 301);
|
||||
@ -1118,7 +1117,7 @@ export default {
|
||||
this.$Modal.remove();
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess(msg);
|
||||
this.getProjectList();
|
||||
this.$store.commit('getProjectList');
|
||||
this.goForward({path: '/manage/dashboard'}, true);
|
||||
}else{
|
||||
$A.modalError(msg, 301);
|
||||
@ -1161,6 +1160,10 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
toggleBoolean(type) {
|
||||
this.$store.commit('toggleBoolean', type);
|
||||
},
|
||||
|
||||
formatTime(date) {
|
||||
let time = Math.round(new Date(date).getTime() / 1000),
|
||||
string = '';
|
||||
|
@ -19,8 +19,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapMutations} from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -35,9 +33,6 @@ export default {
|
||||
ruleDatum: { },
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapMutations(['setUserInfo']),
|
||||
},
|
||||
methods: {
|
||||
initLanguage() {
|
||||
this.ruleDatum = {
|
||||
@ -93,7 +88,7 @@ export default {
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess('修改成功!');
|
||||
this.setUserInfo(data);
|
||||
this.$store.commit('setUserInfo', data);
|
||||
this.$refs.formDatum.resetFields();
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
<script>
|
||||
import ImgUpload from "../../../components/ImgUpload";
|
||||
import {mapMutations, mapState} from "vuex";
|
||||
import {mapState} from "vuex";
|
||||
export default {
|
||||
components: {ImgUpload},
|
||||
data() {
|
||||
@ -45,7 +45,6 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapState(['userInfo']),
|
||||
...mapMutations(['getUserInfo']),
|
||||
},
|
||||
watch: {
|
||||
userInfo() {
|
||||
@ -82,7 +81,7 @@ export default {
|
||||
success: ({ret, data, msg}) => {
|
||||
if (ret === 1) {
|
||||
$A.messageSuccess('修改成功');
|
||||
this.getUserInfo();
|
||||
this.$store.commit('getUserInfo');
|
||||
} else {
|
||||
$A.modalError(msg);
|
||||
}
|
||||
|
8
resources/assets/js/store/mutations.js
vendored
8
resources/assets/js/store/mutations.js
vendored
@ -152,7 +152,7 @@ export default {
|
||||
/**
|
||||
* 获取用户基本信息
|
||||
* @param state
|
||||
* @param params // {userid, success, complete}
|
||||
* @param params {userid, success, complete}
|
||||
*/
|
||||
getUserBasic(state, params) {
|
||||
if (!state.method.isJson(params)) {
|
||||
@ -274,7 +274,7 @@ export default {
|
||||
/**
|
||||
* 根据消息ID 删除 或 替换 对话数据
|
||||
* @param state
|
||||
* @param params // {id, data}
|
||||
* @param params {id, data}
|
||||
*/
|
||||
spliceDialogMsg(state, params) {
|
||||
let {id, data} = params;
|
||||
@ -388,7 +388,7 @@ export default {
|
||||
/**
|
||||
* 发送 websocket 消息
|
||||
* @param state
|
||||
* @param params // {type, data, callback, msgId}
|
||||
* @param params {type, data, callback, msgId}
|
||||
*/
|
||||
wsSend(state, params) {
|
||||
if (!state.method.isJson(params)) {
|
||||
@ -418,7 +418,7 @@ export default {
|
||||
/**
|
||||
* 监听消息
|
||||
* @param state
|
||||
* @param params // {name, callback}
|
||||
* @param params {name, callback}
|
||||
*/
|
||||
wsMsgListener(state, params) {
|
||||
const {name, callback} = params;
|
||||
|
Loading…
x
Reference in New Issue
Block a user