546 lines
16 KiB
JavaScript
546 lines
16 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const js_sdk_validator_uniIdUsers = require("../../js_sdk/validator/uni-id-users.js");
|
|
const db = common_vendor.er.database();
|
|
db.command;
|
|
const dbCollectionName = "uni-id-users";
|
|
function getValidator(fields) {
|
|
let result = {};
|
|
for (let key in js_sdk_validator_uniIdUsers.validator) {
|
|
if (fields.includes(key)) {
|
|
result[key] = js_sdk_validator_uniIdUsers.validator[key];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
const _sfc_main = {
|
|
data() {
|
|
let formData = {
|
|
"ali_openid": "",
|
|
"apple_openid": "",
|
|
"avatar": "",
|
|
"avatar_file": null,
|
|
"comment": "",
|
|
"dcloud_appid": [],
|
|
"department_id": [],
|
|
"email": "",
|
|
"email_confirmed": 0,
|
|
"gender": 0,
|
|
"invite_time": null,
|
|
"inviter_uid": [],
|
|
"last_login_date": null,
|
|
"last_login_ip": "",
|
|
"mobile": "",
|
|
"mobile_confirmed": 0,
|
|
"my_invite_code": "",
|
|
"nickname": "",
|
|
"password": null,
|
|
"password_secret_version": null,
|
|
"realname_auth": null,
|
|
"register_date": null,
|
|
"register_ip": "",
|
|
"role": [],
|
|
"tags": [],
|
|
"score": null,
|
|
"status": 0,
|
|
"token": [],
|
|
"username": "",
|
|
"wx_openid": null,
|
|
"wx_unionid": "",
|
|
"qq_openid": null,
|
|
"qq_unionid": "",
|
|
"third_party": null,
|
|
"identities": []
|
|
};
|
|
return {
|
|
formData,
|
|
formOptions: {
|
|
"email_confirmed_localdata": [
|
|
{
|
|
"text": "未验证",
|
|
"value": 0
|
|
},
|
|
{
|
|
"text": "已验证",
|
|
"value": 1
|
|
}
|
|
],
|
|
"gender_localdata": [
|
|
{
|
|
"text": "未知",
|
|
"value": 0
|
|
},
|
|
{
|
|
"text": "男",
|
|
"value": 1
|
|
},
|
|
{
|
|
"text": "女",
|
|
"value": 2
|
|
}
|
|
],
|
|
"mobile_confirmed_localdata": [
|
|
{
|
|
"text": "未验证",
|
|
"value": 0
|
|
},
|
|
{
|
|
"text": "已验证",
|
|
"value": 1
|
|
}
|
|
],
|
|
"status_localdata": [
|
|
{
|
|
"text": "正常",
|
|
"value": 0
|
|
},
|
|
{
|
|
"text": "禁用",
|
|
"value": 1
|
|
},
|
|
{
|
|
"text": "审核中",
|
|
"value": 2
|
|
},
|
|
{
|
|
"text": "审核拒绝",
|
|
"value": 3
|
|
},
|
|
{
|
|
"text": "已注销",
|
|
"value": 4
|
|
}
|
|
]
|
|
},
|
|
rules: {
|
|
...getValidator(Object.keys(formData))
|
|
}
|
|
};
|
|
},
|
|
onLoad(e) {
|
|
if (e.id) {
|
|
const id = e.id;
|
|
this.formDataId = id;
|
|
this.getDetail(id);
|
|
}
|
|
},
|
|
onReady() {
|
|
this.$refs.form.setRules(this.rules);
|
|
},
|
|
methods: {
|
|
/**
|
|
* 验证表单并提交
|
|
*/
|
|
submit() {
|
|
common_vendor.index.showLoading({
|
|
mask: true
|
|
});
|
|
this.$refs.form.validate().then((res) => {
|
|
return this.submitForm(res);
|
|
}).catch(() => {
|
|
}).finally(() => {
|
|
common_vendor.index.hideLoading();
|
|
});
|
|
},
|
|
/**
|
|
* 提交表单
|
|
*/
|
|
submitForm(value) {
|
|
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
|
|
common_vendor.index.showToast({
|
|
title: "修改成功"
|
|
});
|
|
this.getOpenerEventChannel().emit("refreshData");
|
|
setTimeout(() => common_vendor.index.navigateBack(), 500);
|
|
}).catch((err) => {
|
|
common_vendor.index.showModal({
|
|
content: err.message || "请求服务失败",
|
|
showCancel: false
|
|
});
|
|
});
|
|
},
|
|
/**
|
|
* 获取表单数据
|
|
* @param {Object} id
|
|
*/
|
|
getDetail(id) {
|
|
common_vendor.index.showLoading({
|
|
mask: true
|
|
});
|
|
db.collection(dbCollectionName).doc(id).field("ali_openid,apple_openid,avatar,avatar_file,comment,dcloud_appid,department_id,email,email_confirmed,gender,invite_time,inviter_uid,last_login_date,last_login_ip,mobile,mobile_confirmed,my_invite_code,nickname,password,password_secret_version,realname_auth,register_date,register_ip,role,tags,score,status,token,username,wx_openid,wx_unionid,qq_openid,qq_unionid,third_party,identities").get().then((res) => {
|
|
const data = res.result.data[0];
|
|
if (data) {
|
|
this.formData = data;
|
|
}
|
|
}).catch((err) => {
|
|
common_vendor.index.showModal({
|
|
content: err.message || "请求服务失败",
|
|
showCancel: false
|
|
});
|
|
}).finally(() => {
|
|
common_vendor.index.hideLoading();
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
|
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
|
|
const _easycom_uni_file_picker2 = common_vendor.resolveComponent("uni-file-picker");
|
|
const _easycom_uni_data_picker2 = common_vendor.resolveComponent("uni-data-picker");
|
|
const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
|
|
const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
|
|
const _component_undefined = common_vendor.resolveComponent("undefined");
|
|
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
|
|
(_easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_uni_file_picker2 + _easycom_uni_data_picker2 + _easycom_uni_data_checkbox2 + _easycom_uni_datetime_picker2 + _component_undefined + _easycom_uni_forms2)();
|
|
}
|
|
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
|
|
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
|
|
const _easycom_uni_file_picker = () => "../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
|
|
const _easycom_uni_data_picker = () => "../../uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.js";
|
|
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
|
|
const _easycom_uni_datetime_picker = () => "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
|
|
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
|
|
if (!Math) {
|
|
(_easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_uni_file_picker + _easycom_uni_data_picker + _easycom_uni_data_checkbox + _easycom_uni_datetime_picker + _easycom_uni_forms)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.o(($event) => $data.formData.ali_openid = $event),
|
|
b: common_vendor.p({
|
|
placeholder: "支付宝平台openid",
|
|
modelValue: $data.formData.ali_openid
|
|
}),
|
|
c: common_vendor.p({
|
|
name: "ali_openid",
|
|
label: ""
|
|
}),
|
|
d: common_vendor.o(($event) => $data.formData.apple_openid = $event),
|
|
e: common_vendor.p({
|
|
placeholder: "苹果登录openid",
|
|
modelValue: $data.formData.apple_openid
|
|
}),
|
|
f: common_vendor.p({
|
|
name: "apple_openid",
|
|
label: ""
|
|
}),
|
|
g: common_vendor.o(($event) => $data.formData.avatar = $event),
|
|
h: common_vendor.p({
|
|
placeholder: "头像地址",
|
|
trim: "both",
|
|
modelValue: $data.formData.avatar
|
|
}),
|
|
i: common_vendor.p({
|
|
name: "avatar",
|
|
label: "头像地址"
|
|
}),
|
|
j: common_vendor.o(($event) => $data.formData.avatar_file = $event),
|
|
k: common_vendor.p({
|
|
["return-type"]: "object",
|
|
modelValue: $data.formData.avatar_file
|
|
}),
|
|
l: common_vendor.p({
|
|
name: "avatar_file",
|
|
label: "头像文件"
|
|
}),
|
|
m: common_vendor.o(($event) => $data.formData.comment = $event),
|
|
n: common_vendor.p({
|
|
placeholder: "备注",
|
|
trim: "both",
|
|
modelValue: $data.formData.comment
|
|
}),
|
|
o: common_vendor.p({
|
|
name: "comment",
|
|
label: "备注"
|
|
}),
|
|
p: common_vendor.o(($event) => $data.formData.dcloud_appid = $event),
|
|
q: common_vendor.p({
|
|
multiple: true,
|
|
modelValue: $data.formData.dcloud_appid
|
|
}),
|
|
r: common_vendor.p({
|
|
name: "dcloud_appid",
|
|
label: ""
|
|
}),
|
|
s: common_vendor.o(($event) => $data.formData.department_id = $event),
|
|
t: common_vendor.p({
|
|
["self-field"]: "_id",
|
|
["parent-field"]: "parent_id",
|
|
collection: "opendb-department",
|
|
field: "_id as value, name as text",
|
|
orderby: "name asc",
|
|
modelValue: $data.formData.department_id
|
|
}),
|
|
v: common_vendor.p({
|
|
name: "department_id",
|
|
label: "部门"
|
|
}),
|
|
w: common_vendor.o(($event) => $data.formData.email = $event),
|
|
x: common_vendor.p({
|
|
placeholder: "邮箱地址",
|
|
trim: "both",
|
|
modelValue: $data.formData.email
|
|
}),
|
|
y: common_vendor.p({
|
|
name: "email",
|
|
label: "邮箱"
|
|
}),
|
|
z: common_vendor.o(($event) => $data.formData.email_confirmed = $event),
|
|
A: common_vendor.p({
|
|
localdata: $data.formOptions.email_confirmed_localdata,
|
|
modelValue: $data.formData.email_confirmed
|
|
}),
|
|
B: common_vendor.p({
|
|
name: "email_confirmed",
|
|
label: "邮箱验证状态"
|
|
}),
|
|
C: common_vendor.o(($event) => $data.formData.gender = $event),
|
|
D: common_vendor.p({
|
|
localdata: $data.formOptions.gender_localdata,
|
|
modelValue: $data.formData.gender
|
|
}),
|
|
E: common_vendor.p({
|
|
name: "gender",
|
|
label: "性别"
|
|
}),
|
|
F: common_vendor.o(($event) => $data.formData.invite_time = $event),
|
|
G: common_vendor.p({
|
|
["return-type"]: "timestamp",
|
|
modelValue: $data.formData.invite_time
|
|
}),
|
|
H: common_vendor.p({
|
|
name: "invite_time",
|
|
label: ""
|
|
}),
|
|
I: common_vendor.o(($event) => $data.formData.inviter_uid = $event),
|
|
J: common_vendor.p({
|
|
multiple: true,
|
|
modelValue: $data.formData.inviter_uid
|
|
}),
|
|
K: common_vendor.p({
|
|
name: "inviter_uid",
|
|
label: ""
|
|
}),
|
|
L: common_vendor.o(($event) => $data.formData.last_login_date = $event),
|
|
M: common_vendor.p({
|
|
["return-type"]: "timestamp",
|
|
modelValue: $data.formData.last_login_date
|
|
}),
|
|
N: common_vendor.p({
|
|
name: "last_login_date",
|
|
label: ""
|
|
}),
|
|
O: common_vendor.o(($event) => $data.formData.last_login_ip = $event),
|
|
P: common_vendor.p({
|
|
placeholder: "最后登录时 IP 地址",
|
|
modelValue: $data.formData.last_login_ip
|
|
}),
|
|
Q: common_vendor.p({
|
|
name: "last_login_ip",
|
|
label: ""
|
|
}),
|
|
R: common_vendor.o(($event) => $data.formData.mobile = $event),
|
|
S: common_vendor.p({
|
|
placeholder: "手机号码",
|
|
trim: "both",
|
|
modelValue: $data.formData.mobile
|
|
}),
|
|
T: common_vendor.p({
|
|
name: "mobile",
|
|
label: "手机号码"
|
|
}),
|
|
U: common_vendor.o(($event) => $data.formData.mobile_confirmed = $event),
|
|
V: common_vendor.p({
|
|
localdata: $data.formOptions.mobile_confirmed_localdata,
|
|
modelValue: $data.formData.mobile_confirmed
|
|
}),
|
|
W: common_vendor.p({
|
|
name: "mobile_confirmed",
|
|
label: "手机号验证状态"
|
|
}),
|
|
X: common_vendor.o(($event) => $data.formData.my_invite_code = $event),
|
|
Y: common_vendor.p({
|
|
placeholder: "用户自身邀请码",
|
|
modelValue: $data.formData.my_invite_code
|
|
}),
|
|
Z: common_vendor.p({
|
|
name: "my_invite_code",
|
|
label: ""
|
|
}),
|
|
aa: common_vendor.o(($event) => $data.formData.nickname = $event),
|
|
ab: common_vendor.p({
|
|
placeholder: "用户昵称",
|
|
trim: "both",
|
|
modelValue: $data.formData.nickname
|
|
}),
|
|
ac: common_vendor.p({
|
|
name: "nickname",
|
|
label: "昵称"
|
|
}),
|
|
ad: common_vendor.o(($event) => $data.formData.password = $event),
|
|
ae: common_vendor.p({
|
|
placeholder: "密码,加密存储",
|
|
type: "password",
|
|
modelValue: $data.formData.password
|
|
}),
|
|
af: common_vendor.p({
|
|
name: "password",
|
|
label: "密码"
|
|
}),
|
|
ag: common_vendor.o(($event) => $data.formData.password_secret_version = $event),
|
|
ah: common_vendor.p({
|
|
placeholder: "密码使用的passwordSecret版本",
|
|
type: "number",
|
|
modelValue: $data.formData.password_secret_version
|
|
}),
|
|
ai: common_vendor.p({
|
|
name: "password_secret_version",
|
|
label: "passwordSecret"
|
|
}),
|
|
aj: common_vendor.o(($event) => $data.formData.realname_auth = $event),
|
|
ak: common_vendor.p({
|
|
modelValue: $data.formData.realname_auth
|
|
}),
|
|
al: common_vendor.p({
|
|
name: "realname_auth",
|
|
label: ""
|
|
}),
|
|
am: common_vendor.o(($event) => $data.formData.register_date = $event),
|
|
an: common_vendor.p({
|
|
["return-type"]: "timestamp",
|
|
modelValue: $data.formData.register_date
|
|
}),
|
|
ao: common_vendor.p({
|
|
name: "register_date",
|
|
label: ""
|
|
}),
|
|
ap: common_vendor.o(($event) => $data.formData.register_ip = $event),
|
|
aq: common_vendor.p({
|
|
placeholder: "注册时 IP 地址",
|
|
modelValue: $data.formData.register_ip
|
|
}),
|
|
ar: common_vendor.p({
|
|
name: "register_ip",
|
|
label: ""
|
|
}),
|
|
as: common_vendor.o(($event) => $data.formData.role = $event),
|
|
at: common_vendor.p({
|
|
multiple: true,
|
|
collection: "uni-id-roles",
|
|
field: "role_id as value, role_name as text",
|
|
modelValue: $data.formData.role
|
|
}),
|
|
av: common_vendor.p({
|
|
name: "role",
|
|
label: "角色"
|
|
}),
|
|
aw: common_vendor.o(($event) => $data.formData.tags = $event),
|
|
ax: common_vendor.p({
|
|
multiple: true,
|
|
modelValue: $data.formData.tags
|
|
}),
|
|
ay: common_vendor.p({
|
|
name: "tags",
|
|
label: "标签"
|
|
}),
|
|
az: common_vendor.o(($event) => $data.formData.score = $event),
|
|
aA: common_vendor.p({
|
|
placeholder: "用户积分,积分变更记录可参考:uni-id-scores表定义",
|
|
type: "number",
|
|
modelValue: $data.formData.score
|
|
}),
|
|
aB: common_vendor.p({
|
|
name: "score",
|
|
label: ""
|
|
}),
|
|
aC: common_vendor.o(($event) => $data.formData.status = $event),
|
|
aD: common_vendor.p({
|
|
localdata: $data.formOptions.status_localdata,
|
|
modelValue: $data.formData.status
|
|
}),
|
|
aE: common_vendor.p({
|
|
name: "status",
|
|
label: "用户状态"
|
|
}),
|
|
aF: common_vendor.o(($event) => $data.formData.token = $event),
|
|
aG: common_vendor.p({
|
|
multiple: true,
|
|
modelValue: $data.formData.token
|
|
}),
|
|
aH: common_vendor.p({
|
|
name: "token",
|
|
label: ""
|
|
}),
|
|
aI: common_vendor.o(($event) => $data.formData.username = $event),
|
|
aJ: common_vendor.p({
|
|
placeholder: "用户名,不允许重复",
|
|
trim: "both",
|
|
modelValue: $data.formData.username
|
|
}),
|
|
aK: common_vendor.p({
|
|
name: "username",
|
|
label: "用户名"
|
|
}),
|
|
aL: common_vendor.o(($event) => $data.formData.wx_openid = $event),
|
|
aM: common_vendor.p({
|
|
modelValue: $data.formData.wx_openid
|
|
}),
|
|
aN: common_vendor.p({
|
|
name: "wx_openid",
|
|
label: ""
|
|
}),
|
|
aO: common_vendor.o(($event) => $data.formData.wx_unionid = $event),
|
|
aP: common_vendor.p({
|
|
placeholder: "微信unionid",
|
|
modelValue: $data.formData.wx_unionid
|
|
}),
|
|
aQ: common_vendor.p({
|
|
name: "wx_unionid",
|
|
label: ""
|
|
}),
|
|
aR: common_vendor.o(($event) => $data.formData.qq_openid = $event),
|
|
aS: common_vendor.p({
|
|
modelValue: $data.formData.qq_openid
|
|
}),
|
|
aT: common_vendor.p({
|
|
name: "qq_openid",
|
|
label: ""
|
|
}),
|
|
aU: common_vendor.o(($event) => $data.formData.qq_unionid = $event),
|
|
aV: common_vendor.p({
|
|
placeholder: "QQ unionid",
|
|
modelValue: $data.formData.qq_unionid
|
|
}),
|
|
aW: common_vendor.p({
|
|
name: "qq_unionid",
|
|
label: ""
|
|
}),
|
|
aX: common_vendor.o(($event) => $data.formData.third_party = $event),
|
|
aY: common_vendor.p({
|
|
modelValue: $data.formData.third_party
|
|
}),
|
|
aZ: common_vendor.p({
|
|
name: "third_party",
|
|
label: ""
|
|
}),
|
|
ba: common_vendor.o(($event) => $data.formData.identities = $event),
|
|
bb: common_vendor.p({
|
|
multiple: true,
|
|
modelValue: $data.formData.identities
|
|
}),
|
|
bc: common_vendor.p({
|
|
name: "identities",
|
|
label: ""
|
|
}),
|
|
bd: common_vendor.o((...args) => $options.submit && $options.submit(...args)),
|
|
be: common_vendor.sr("form", "7e6b858c-0"),
|
|
bf: common_vendor.p({
|
|
model: $data.formData,
|
|
validateTrigger: "bind"
|
|
})
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/uni-id-users/edit.js.map
|