优化vuex mutations
This commit is contained in:
parent
6981ee03bf
commit
1f08c596a4
@ -113,6 +113,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {mapMutations} from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -127,6 +129,9 @@ export default {
|
|||||||
code: '',
|
code: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapMutations(['setUserInfo']),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
reCode() {
|
reCode() {
|
||||||
this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random())
|
this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random())
|
||||||
@ -173,7 +178,7 @@ export default {
|
|||||||
},
|
},
|
||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
this.$store.commit('setUserInfo', data);
|
this.setUserInfo(data);
|
||||||
//
|
//
|
||||||
this.goNext();
|
this.goNext();
|
||||||
} else {
|
} else {
|
||||||
|
@ -231,7 +231,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import {mapMutations, mapState} from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -252,13 +252,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.commit('getUserInfo');
|
this.$store.commit("getUserInfo");
|
||||||
},
|
},
|
||||||
deactivated() {
|
deactivated() {
|
||||||
this.addShow = false;
|
this.addShow = false;
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['projectList']),
|
...mapState(['projectList']),
|
||||||
|
...mapMutations(['getProjectList']),
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'$route' (route) {
|
'$route' (route) {
|
||||||
@ -352,7 +353,7 @@ export default {
|
|||||||
this.$set(this.addData, 'template', 0);
|
this.$set(this.addData, 'template', 0);
|
||||||
//
|
//
|
||||||
this.loadIng++;
|
this.loadIng++;
|
||||||
this.$store.commit('getProjectList', () => {
|
this.getProjectList(() => {
|
||||||
this.loadIng--;
|
this.loadIng--;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import DragInput from "../../../components/DragInput";
|
import DragInput from "../../../components/DragInput";
|
||||||
import ScrollerY from "../../../components/ScrollerY";
|
import ScrollerY from "../../../components/ScrollerY";
|
||||||
import {mapState} from "vuex";
|
import {mapMutations, mapState} from "vuex";
|
||||||
import DialogView from "./DialogView";
|
import DialogView from "./DialogView";
|
||||||
import DialogUpload from "./DialogUpload";
|
import DialogUpload from "./DialogUpload";
|
||||||
|
|
||||||
@ -67,6 +67,7 @@ export default {
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userId', 'dialogId', 'dialogDetail', 'dialogMsgLoad', 'dialogMsgList']),
|
...mapState(['userId', 'dialogId', 'dialogDetail', 'dialogMsgLoad', 'dialogMsgList']),
|
||||||
|
...mapMutations(["spliceDialogMsg"]),
|
||||||
|
|
||||||
peopleNum() {
|
peopleNum() {
|
||||||
return this.dialogDetail.type === 'group' ? $A.runNum(this.dialogDetail.people) : 0;
|
return this.dialogDetail.type === 'group' ? $A.runNum(this.dialogDetail.people) : 0;
|
||||||
@ -107,7 +108,7 @@ export default {
|
|||||||
text: this.msgText,
|
text: this.msgText,
|
||||||
},
|
},
|
||||||
error:() => {
|
error:() => {
|
||||||
this.$store.commit('spliceDialogMsg', {id: tempId});
|
this.spliceDialogMsg({id: tempId});
|
||||||
},
|
},
|
||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret !== 1) {
|
if (ret !== 1) {
|
||||||
@ -116,7 +117,7 @@ export default {
|
|||||||
content: msg
|
content: msg
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.$store.commit('spliceDialogMsg', {
|
this.spliceDialogMsg({
|
||||||
id: tempId,
|
id: tempId,
|
||||||
data: ret === 1 ? data : null
|
data: ret === 1 ? data : null
|
||||||
});
|
});
|
||||||
@ -184,11 +185,11 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'error':
|
case 'error':
|
||||||
this.$store.commit('spliceDialogMsg', {id: file.tempId});
|
this.spliceDialogMsg({id: file.tempId});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'success':
|
case 'success':
|
||||||
this.$store.commit('spliceDialogMsg', {id: file.tempId, data: file.data});
|
this.spliceDialogMsg({id: file.tempId, data: file.data});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</li>
|
</li>
|
||||||
<li :class="['project-icon', $store.state.projectChatShow ? 'active' : '']" @click="$store.commit('toggleBoolean', 'projectChatShow')">
|
<li :class="['project-icon', projectChatShow ? 'active' : '']" @click="toggleBoolean('projectChatShow')">
|
||||||
<Icon type="ios-chatbubbles" />
|
<Icon type="ios-chatbubbles" />
|
||||||
<Badge :count="projectMsgUnread"></Badge>
|
<Badge :count="projectMsgUnread"></Badge>
|
||||||
</li>
|
</li>
|
||||||
@ -45,14 +45,14 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="project-switch">
|
<div class="project-switch">
|
||||||
<div :class="['project-switch-button', !$store.state.projectListPanel ? 'menu' : '']" @click="$store.commit('toggleBoolean', 'projectListPanel')">
|
<div :class="['project-switch-button', !projectListPanel ? 'menu' : '']" @click="toggleBoolean('projectListPanel')">
|
||||||
<div><i class="iconfont"></i></div>
|
<div><i class="iconfont"></i></div>
|
||||||
<div><i class="iconfont"></i></div>
|
<div><i class="iconfont"></i></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="$store.state.projectListPanel" class="project-column">
|
<div v-if="projectListPanel" class="project-column">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="column in projectDetail.project_column">
|
<li v-for="column in projectDetail.project_column">
|
||||||
<div class="column-head">
|
<div class="column-head">
|
||||||
@ -107,8 +107,8 @@
|
|||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
<!--我的任务-->
|
<!--我的任务-->
|
||||||
<div :class="['project-table-body', !$store.state.taskMyShow ? 'project-table-hide' : '']">
|
<div :class="['project-table-body', !taskMyShow ? 'project-table-hide' : '']">
|
||||||
<div @click="$store.commit('toggleBoolean', 'taskMyShow')">
|
<div @click="toggleBoolean('taskMyShow')">
|
||||||
<Row class="project-row">
|
<Row class="project-row">
|
||||||
<Col span="12" class="row-title">
|
<Col span="12" class="row-title">
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
@ -165,8 +165,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--未完成任务-->
|
<!--未完成任务-->
|
||||||
<div :class="['project-table-body', !$store.state.taskUndoneShow ? 'project-table-hide' : '']">
|
<div :class="['project-table-body', !taskUndoneShow ? 'project-table-hide' : '']">
|
||||||
<div @click="$store.commit('toggleBoolean', 'taskUndoneShow')">
|
<div @click="toggleBoolean('taskUndoneShow')">
|
||||||
<Row class="project-row">
|
<Row class="project-row">
|
||||||
<Col span="12" class="row-title">
|
<Col span="12" class="row-title">
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
@ -212,8 +212,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--已完成任务-->
|
<!--已完成任务-->
|
||||||
<div :class="['project-table-body', !$store.state.taskCompletedShow ? 'project-table-hide' : '']">
|
<div :class="['project-table-body', !taskCompletedShow ? 'project-table-hide' : '']">
|
||||||
<div @click="$store.commit('toggleBoolean', 'taskCompletedShow')">
|
<div @click="toggleBoolean('taskCompletedShow')">
|
||||||
<Row class="project-row">
|
<Row class="project-row">
|
||||||
<Col span="12" class="row-title">
|
<Col span="12" class="row-title">
|
||||||
<i class="iconfont"></i>
|
<i class="iconfont"></i>
|
||||||
@ -828,7 +828,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import TaskPriority from "./TaskPriority";
|
import TaskPriority from "./TaskPriority";
|
||||||
import TaskAdd from "./TaskAdd";
|
import TaskAdd from "./TaskAdd";
|
||||||
import {mapState} from "vuex";
|
import {mapState, mapMutations} from "vuex";
|
||||||
import UserInput from "../../../components/UserInput";
|
import UserInput from "../../../components/UserInput";
|
||||||
export default {
|
export default {
|
||||||
name: "ProjectList",
|
name: "ProjectList",
|
||||||
@ -869,7 +869,18 @@ export default {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userId', 'projectDetail', 'projectLoad', 'projectMsgUnread']),
|
...mapState([
|
||||||
|
'userId',
|
||||||
|
'projectDetail',
|
||||||
|
'projectLoad',
|
||||||
|
'projectMsgUnread',
|
||||||
|
'projectChatShow',
|
||||||
|
'projectListPanel',
|
||||||
|
'taskMyShow',
|
||||||
|
'taskUndoneShow',
|
||||||
|
'taskCompletedShow'
|
||||||
|
]),
|
||||||
|
...mapMutations(['toggleBoolean', 'getProjectList', 'getProjectDetail']),
|
||||||
|
|
||||||
panelTask() {
|
panelTask() {
|
||||||
const {searchText} = this;
|
const {searchText} = this;
|
||||||
@ -973,7 +984,7 @@ export default {
|
|||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.$store.commit('getProjectDetail', this.addData.project_id);
|
this.getProjectDetail(this.addData.project_id);
|
||||||
this.addShow = false;
|
this.addShow = false;
|
||||||
this.addData = {
|
this.addData = {
|
||||||
owner: 0,
|
owner: 0,
|
||||||
@ -1026,7 +1037,7 @@ export default {
|
|||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.$store.commit('getProjectDetail', this.userData.project_id);
|
this.getProjectDetail(this.userData.project_id);
|
||||||
this.userShow = false;
|
this.userShow = false;
|
||||||
} else {
|
} else {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
@ -1049,7 +1060,7 @@ export default {
|
|||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.$store.commit('getProjectDetail', this.transferData.project_id);
|
this.getProjectDetail(this.transferData.project_id);
|
||||||
this.transferShow = false;
|
this.transferShow = false;
|
||||||
} else {
|
} else {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
@ -1077,7 +1088,7 @@ export default {
|
|||||||
this.$Modal.remove();
|
this.$Modal.remove();
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.$store.commit('getProjectList');
|
this.getProjectList();
|
||||||
this.goForward({path: '/manage/dashboard'}, true);
|
this.goForward({path: '/manage/dashboard'}, true);
|
||||||
}else{
|
}else{
|
||||||
$A.modalError(msg, 301);
|
$A.modalError(msg, 301);
|
||||||
@ -1107,7 +1118,7 @@ export default {
|
|||||||
this.$Modal.remove();
|
this.$Modal.remove();
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess(msg);
|
$A.messageSuccess(msg);
|
||||||
this.$store.commit('getProjectList');
|
this.getProjectList();
|
||||||
this.goForward({path: '/manage/dashboard'}, true);
|
this.goForward({path: '/manage/dashboard'}, true);
|
||||||
}else{
|
}else{
|
||||||
$A.modalError(msg, 301);
|
$A.modalError(msg, 301);
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {mapMutations} from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -33,6 +35,9 @@ export default {
|
|||||||
ruleDatum: { },
|
ruleDatum: { },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapMutations(['setUserInfo']),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initLanguage() {
|
initLanguage() {
|
||||||
this.ruleDatum = {
|
this.ruleDatum = {
|
||||||
@ -88,7 +93,7 @@ export default {
|
|||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess('修改成功!');
|
$A.messageSuccess('修改成功!');
|
||||||
this.$store.commit('setUserInfo', data);
|
this.setUserInfo(data);
|
||||||
this.$refs.formDatum.resetFields();
|
this.$refs.formDatum.resetFields();
|
||||||
} else {
|
} else {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ImgUpload from "../../../components/ImgUpload";
|
import ImgUpload from "../../../components/ImgUpload";
|
||||||
import {mapState} from "vuex";
|
import {mapMutations, mapState} from "vuex";
|
||||||
export default {
|
export default {
|
||||||
components: {ImgUpload},
|
components: {ImgUpload},
|
||||||
data() {
|
data() {
|
||||||
@ -45,6 +45,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userInfo']),
|
...mapState(['userInfo']),
|
||||||
|
...mapMutations(['getUserInfo']),
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
userInfo() {
|
userInfo() {
|
||||||
@ -81,7 +82,7 @@ export default {
|
|||||||
success: ({ret, data, msg}) => {
|
success: ({ret, data, msg}) => {
|
||||||
if (ret === 1) {
|
if (ret === 1) {
|
||||||
$A.messageSuccess('修改成功');
|
$A.messageSuccess('修改成功');
|
||||||
this.$store.commit('getUserInfo');
|
this.getUserInfo();
|
||||||
} else {
|
} else {
|
||||||
$A.modalError(msg);
|
$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 state
|
||||||
* @param params {userid, success, complete}
|
* @param params // {userid, success, complete}
|
||||||
*/
|
*/
|
||||||
getUserBasic(state, params) {
|
getUserBasic(state, params) {
|
||||||
if (!state.method.isJson(params)) {
|
if (!state.method.isJson(params)) {
|
||||||
@ -274,7 +274,7 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 根据消息ID 删除 或 替换 对话数据
|
* 根据消息ID 删除 或 替换 对话数据
|
||||||
* @param state
|
* @param state
|
||||||
* @param params {id, data}
|
* @param params // {id, data}
|
||||||
*/
|
*/
|
||||||
spliceDialogMsg(state, params) {
|
spliceDialogMsg(state, params) {
|
||||||
let {id, data} = params;
|
let {id, data} = params;
|
||||||
@ -388,7 +388,7 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 发送 websocket 消息
|
* 发送 websocket 消息
|
||||||
* @param state
|
* @param state
|
||||||
* @param params {type, data, callback, msgId}
|
* @param params // {type, data, callback, msgId}
|
||||||
*/
|
*/
|
||||||
wsSend(state, params) {
|
wsSend(state, params) {
|
||||||
if (!state.method.isJson(params)) {
|
if (!state.method.isJson(params)) {
|
||||||
@ -418,7 +418,7 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 监听消息
|
* 监听消息
|
||||||
* @param state
|
* @param state
|
||||||
* @param params {name, callback}
|
* @param params // {name, callback}
|
||||||
*/
|
*/
|
||||||
wsMsgListener(state, params) {
|
wsMsgListener(state, params) {
|
||||||
const {name, callback} = params;
|
const {name, callback} = params;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user