|
@@ -1,10 +1,12 @@
|
|
|
-// pages/teams/addUsers.js
|
|
|
-Page({
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
|
|
|
+Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ sa_agent_hrid: 0,
|
|
|
+ remarks: "", //备注
|
|
|
fromList: [{
|
|
|
label: "姓名",
|
|
|
error: false,
|
|
@@ -12,7 +14,7 @@ Page({
|
|
|
type: "text",
|
|
|
value: "",
|
|
|
placeholder: "请填写",
|
|
|
- valueName: "username", //绑定的字段名称
|
|
|
+ valueName: "name", //绑定的字段名称
|
|
|
required: true, //必填
|
|
|
}, {
|
|
|
label: "职位",
|
|
@@ -21,7 +23,7 @@ Page({
|
|
|
type: "text",
|
|
|
value: "",
|
|
|
placeholder: "请填写",
|
|
|
- valueName: "gender", //绑定的字段名称
|
|
|
+ valueName: "position", //绑定的字段名称
|
|
|
required: false, //必填
|
|
|
}, {
|
|
|
label: "手机号码",
|
|
@@ -30,36 +32,134 @@ Page({
|
|
|
type: "text",
|
|
|
value: "",
|
|
|
placeholder: "请填写",
|
|
|
- valueName: "phone", //绑定的字段名称
|
|
|
+ valueName: "phonenumber", //绑定的字段名称
|
|
|
required: false, //必填
|
|
|
}, {
|
|
|
label: "角色配置",
|
|
|
error: false,
|
|
|
errMsg: "",
|
|
|
- type: "date",
|
|
|
- value: "",
|
|
|
- placeholder: "请填写",
|
|
|
- valueName: "phone", //绑定的字段名称
|
|
|
- required: false, //必填
|
|
|
- }, {
|
|
|
- label: "权限设置",
|
|
|
- error: false,
|
|
|
- errMsg: "",
|
|
|
- type: "date",
|
|
|
+ type: "custom",
|
|
|
value: "",
|
|
|
placeholder: "请填写",
|
|
|
- valueName: "phone", //绑定的字段名称
|
|
|
+ valueName: "rolenames", //绑定的字段名称
|
|
|
required: false, //必填
|
|
|
- }]
|
|
|
+ }],
|
|
|
+ roleids: [], //已选角色ID
|
|
|
+ roleList: [], //角色列表
|
|
|
+ disabled: true, //按钮禁用
|
|
|
+ loading: false, //按钮加载
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
-
|
|
|
+ if (options.item) {
|
|
|
+ let item = JSON.parse(options.item)
|
|
|
+ console.log(item)
|
|
|
+ this.setData({
|
|
|
+ sa_agent_hrid: item.sa_agent_hrid,
|
|
|
+ ['fromList[0].value']: item.name,
|
|
|
+ ['fromList[1].value']: item.position,
|
|
|
+ ['fromList[2].value']: item.phonenumber,
|
|
|
+ ['fromList[3].value']: item.rolenames,
|
|
|
+ remarks: item.remarks,
|
|
|
+ roleids: item.roleids,
|
|
|
+ disabled: false
|
|
|
+ })
|
|
|
+ };
|
|
|
+ this.queryRole();
|
|
|
+ },
|
|
|
+ /* 查询角色列表 */
|
|
|
+ queryRole() {
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "sale.team.team",
|
|
|
+ "method": "queryRole",
|
|
|
+ "content": {
|
|
|
+ "sa_agent_hrid": this.data.sa_agent_hrid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("角色列表", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ roleList: res.data
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 表单是否完成 */
|
|
|
+ formCompletedOrNot({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ disabled: !detail
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 提交数据 */
|
|
|
+ submitRole() {
|
|
|
+ if (this.data.disabled || this.data.loading) return;
|
|
|
+ let {
|
|
|
+ isReturn,
|
|
|
+ returnData
|
|
|
+ } = this.selectComponent("#form").getData();
|
|
|
+ if (returnData.phonenumber.length != 11) return wx.showToast({
|
|
|
+ title: '手机号码错误,请输入11位手机号码',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ delete(returnData.rolenames);
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ })
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "sale.team.team",
|
|
|
+ "method": "insertormodify_team",
|
|
|
+ "content": {
|
|
|
+ "sa_agent_hrid": this.data.sa_agent_hrid,
|
|
|
+ ...returnData,
|
|
|
+ "remarks": this.data.remarks,
|
|
|
+ "roleids": this.data.roleids
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ disabled: true
|
|
|
+ })
|
|
|
+ let pages = getCurrentPages(),
|
|
|
+ prevPage = pages[pages.length - 2];
|
|
|
+ prevPage.getList(true);
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 0
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: '保存成功!'
|
|
|
+ })
|
|
|
+ }, 300)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 得到多选结果 */
|
|
|
+ getResult({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ roleids: detail.roleids,
|
|
|
+ ['fromList[3].value']: detail.rolenames
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 文本域输入 */
|
|
|
+ textareaInput(e) {
|
|
|
+ this.setData({
|
|
|
+ remarks: e.detail.value.trim()
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|