| xqd
@@ -25,7 +25,7 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
this.getProjects()
|
|
|
- if(options.id) {
|
|
|
+ if (options.id) {
|
|
|
this.setData({
|
|
|
id: options.id,
|
|
|
type: 'edit'
|
| xqd
@@ -38,13 +38,13 @@ Page({
|
|
|
this.getRoles()
|
|
|
},
|
|
|
|
|
|
- updateIndex: function() {
|
|
|
+ updateIndex: function () {
|
|
|
var project_user = this.data.project_user
|
|
|
- if(!project_user) return false;
|
|
|
+ if (!project_user) return false;
|
|
|
var projects = this.data.projects
|
|
|
- if(projects.length > 0) {
|
|
|
- for(var i = 0; i < projects.length; ++i) {
|
|
|
- if(projects[i].id == project_user.project_id) {
|
|
|
+ if (projects.length > 0) {
|
|
|
+ for (var i = 0; i < projects.length; ++i) {
|
|
|
+ if (projects[i].id == project_user.project_id) {
|
|
|
this.setData({
|
|
|
projectIndex: i
|
|
|
})
|
| xqd
@@ -53,9 +53,9 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
var roles = this.data.roles
|
|
|
- if(roles.length > 0) {
|
|
|
- for(var i = 0; i < roles.length; ++i) {
|
|
|
- if(roles[i].id == project_user.project_role_id) {
|
|
|
+ if (roles.length > 0) {
|
|
|
+ for (var i = 0; i < roles.length; ++i) {
|
|
|
+ if (roles[i].id == project_user.project_role_id) {
|
|
|
this.setData({
|
|
|
roleIndex: i
|
|
|
})
|
| xqd
@@ -72,8 +72,8 @@ Page({
|
|
|
data: {
|
|
|
id: this.data.id
|
|
|
},
|
|
|
- success: function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code == 0) {
|
|
|
that.setData({
|
|
|
project_user: res.data
|
|
|
})
|
| xqd
@@ -85,15 +85,15 @@ Page({
|
|
|
},
|
|
|
|
|
|
submit() {
|
|
|
- if(this.data.users.length <= 0) {
|
|
|
+ if (this.data.users.length <= 0) {
|
|
|
util.error('请选择成员')
|
|
|
return false
|
|
|
}
|
|
|
- if(this.data.projectIndex < 0) {
|
|
|
+ if (this.data.projectIndex < 0) {
|
|
|
util.error('请选择项目')
|
|
|
return false
|
|
|
}
|
|
|
- if(this.data.roleIndex < 0) {
|
|
|
+ if (this.data.roleIndex < 0) {
|
|
|
util.error('请选择角色')
|
|
|
return false
|
|
|
}
|
| xqd
@@ -106,40 +106,45 @@ Page({
|
|
|
project_id: project_id,
|
|
|
project_role_id: role_id
|
|
|
}
|
|
|
- if(this.data.type == 'edit') {
|
|
|
+ if (this.data.type == 'edit') {
|
|
|
data.id = this.data.project_user.id
|
|
|
}
|
|
|
http({
|
|
|
url: url,
|
|
|
data: data,
|
|
|
- success: function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code == 0) {
|
|
|
util.success('操作成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1,
|
|
|
+ })
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- clear: function() {
|
|
|
+ clear: function () {
|
|
|
this.setData({
|
|
|
keyword: ''
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- blur: function() {
|
|
|
+ blur: function () {
|
|
|
var that = this
|
|
|
- setTimeout(function() {
|
|
|
+ setTimeout(function () {
|
|
|
that.search()
|
|
|
}, 300)
|
|
|
},
|
|
|
|
|
|
- search: function() {
|
|
|
+ search: function () {
|
|
|
var that = this
|
|
|
- if(!this.data.keyword && this.data.type == 'create') return false;
|
|
|
+ if (!this.data.keyword && this.data.type == 'create') return false;
|
|
|
var data = {
|
|
|
keyword: this.data.keyword
|
|
|
}
|
|
|
- if(this.data.type == 'edit') {
|
|
|
+ if (this.data.type == 'edit') {
|
|
|
data = {
|
|
|
keyword: this.data.keyword,
|
|
|
id: this.data.project_user.user_id
|
| xqd
@@ -149,9 +154,9 @@ Page({
|
|
|
http({
|
|
|
url: 'users/search',
|
|
|
data: data,
|
|
|
- success: function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
- if(res.data.length <= 0) {
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code == 0) {
|
|
|
+ if (res.data.length <= 0) {
|
|
|
util.error('未找到相应用户')
|
|
|
}
|
|
|
that.setData({
|
| xqd
@@ -163,57 +168,58 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- bindPickerChange: function(e) {
|
|
|
+ bindPickerChange: function (e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
this.setData({
|
|
|
[name]: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- getRoles: function() {
|
|
|
+ getRoles: function () {
|
|
|
var that = this
|
|
|
http({
|
|
|
url: 'project-roles/getByExclude',
|
|
|
data: {
|
|
|
id: this.data.id
|
|
|
},
|
|
|
- success: function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code == 0) {
|
|
|
that.setData({
|
|
|
roles: res.data
|
|
|
})
|
|
|
- if(that.data.type == 'edit') that.updateIndex()
|
|
|
+ if (that.data.type == 'edit') that.updateIndex()
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- getProjects: function() {
|
|
|
+ getProjects: function () {
|
|
|
var that = this
|
|
|
var users = this.data.users
|
|
|
var user_id = ''
|
|
|
- if(users.length > 0) {
|
|
|
+ if (users.length > 0) {
|
|
|
user_id = users[0].id
|
|
|
}
|
|
|
http({
|
|
|
url: 'projects/getAll',
|
|
|
data: {
|
|
|
user_id: user_id,
|
|
|
- self: true
|
|
|
+ self: true,
|
|
|
+ type: that.data.type
|
|
|
},
|
|
|
- success: function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code == 0) {
|
|
|
that.setData({
|
|
|
projects: res.data,
|
|
|
projectIndex: -1
|
|
|
})
|
|
|
- if(that.data.type == 'edit') that.updateIndex()
|
|
|
+ if (that.data.type == 'edit') that.updateIndex()
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- updateInput: function(e) {
|
|
|
+ updateInput: function (e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
this.setData({
|
|
|
[name]: e.detail.value
|