diff --git a/src/pagesApp/components/addUser.vue b/src/pagesApp/components/addUser.vue index dd6b091..b430586 100644 --- a/src/pagesApp/components/addUser.vue +++ b/src/pagesApp/components/addUser.vue @@ -3,7 +3,7 @@ @@ -35,7 +35,9 @@ :maxlength="item.key === 'password' ? 8 : -1" @change="(e:any) => {handleInput(e, item)}" :disabled="item.type === 'select'" - :disabledColor="['性别', '用户角色'].indexOf(item.name) > -1?'#ffffff':'#f5f7fa'" + :disabledColor=" + ['性别', '用户角色'].indexOf(item.name) > -1 ? '#ffffff' : '#f5f7fa' + " @clear="handleClear(item)" > - + { - (model1.formData as any)[item.key] = ''; -} +const handleClear = (item: any) => { + (model1.formData as any)[item.key] = ""; +}; const handleInput = (e: any, item: any) => { if (item.key === "phone") { const temp = e?.replace(valid.valid_number, ""); @@ -90,10 +92,9 @@ const handleInput = (e: any, item: any) => { } }; const model1 = reactive({ - formData: { - }, + formData: {}, }); -const rules = ref({ +const rules1 = ref({ "formData.userName": { type: "string", required: true, @@ -107,6 +108,14 @@ const rules = ref({ trigger: ["blur", "change"], }, }); +const rules2 = ref({ + "formData.userName": { + type: "string", + required: true, + message: "请输入账号", + trigger: ["blur", "change"], + }, +}); const contrlModalParams = reactive({ role: { isShow: false, @@ -129,7 +138,7 @@ const contrlModalParams = reactive({ }, }); -const formAttrList = reactive([ +const formAttrList1 = reactive([ { name: "姓名", key: "name", @@ -174,6 +183,45 @@ const formAttrList = reactive([ }, ]); +const formAttrList2 = reactive([ + { + name: "姓名", + key: "name", + type: "input", + }, + { + name: "性别", + key: "genderName", + type: "select", + childKey: "gender", + fn: () => { + contrlModalParams.gender.isShow = true; + contrlModalParams.gender.title = "选择性别"; + }, + }, + { + name: "用户角色", + key: "roleName", + type: "select", + childKey: "role", + fn: () => { + contrlModalParams.role.isShow = true; + contrlModalParams.role.title = "选择角色"; + }, + }, + { + name: "账号", + key: "userName", + type: "input", + required: true, + }, + { + name: "联系手机", + key: "phone", + type: "input", + }, +]); + const handleSelect = (key: string, v: any) => { contrlModalParams[key].isShow = false; if (key === "role") { @@ -211,15 +259,18 @@ const save = () => { return; } } - if (model1.formData.password) { - if (!valid.valid_password.pattern.test(model1.formData.password)) { - uni.showToast({ - icon: "none", - title: valid.valid_password.message, - }); - return; + if (!model1.formData.id) { + if (model1.formData.password) { + if (!valid.valid_password.pattern.test(model1.formData.password)) { + uni.showToast({ + icon: "none", + title: valid.valid_password.message, + }); + return; + } } } + check().then((res) => { if (res) { startSave(); @@ -229,15 +280,22 @@ const save = () => { const startSave = () => { if (model1.formData.id) { - ProfileApi.updateUserById(model1.formData).then((res) => { + ProfileApi.updateUserById({ + name: model1.formData.name, + id: model1.formData.id, + roleIds: model1.formData.roleIds, + userName: model1.formData.userName, + phone: model1.formData.phone, + gender: model1.formData.gender, + }).then((res) => { if (res.code === 200) { - uni.navigateBack() + uni.navigateBack(); } }); } else { ProfileApi.addUser({ userType: 1, ...model1.formData }).then((res) => { if (res.code === 200) { - uni.navigateBack() + uni.navigateBack(); } }); } @@ -261,11 +319,11 @@ onMounted(() => { onLoad((option) => { // 接收传递的标题参数; const title = (option as any).title; - const obj = JSON.parse((option as any).item) - model1.formData = {...obj, genderName: ['未知','男','女'][obj.gender]}; + const obj = JSON.parse((option as any).item); + model1.formData = { ...obj, genderName: ["未知", "男", "女"][obj.gender] }; if (obj.roleVos.length > 0) { - model1.formData.roleIds = [obj.roleVos[0].id] - model1.formData.roleName = obj.roleVos[0].roleName + model1.formData.roleIds = [obj.roleVos[0].id]; + model1.formData.roleName = obj.roleVos[0].roleName; } // 设置页面标题; if (title) { diff --git a/src/pagesApp/role.vue b/src/pagesApp/role.vue index e9bd754..e24c367 100644 --- a/src/pagesApp/role.vue +++ b/src/pagesApp/role.vue @@ -91,7 +91,7 @@ const add = () => { const edit = (item: any) => { uni.navigateTo({ url: - "/pagesApp/components/addRole?title=新增角色&item=" + + "/pagesApp/components/addRole?title=编辑角色&item=" + JSON.stringify(item), // 要跳转到的页面路径 }); }; diff --git a/src/pagesApp/shipmentProduct.vue b/src/pagesApp/shipmentProduct.vue index 58e1509..f7612cb 100644 --- a/src/pagesApp/shipmentProduct.vue +++ b/src/pagesApp/shipmentProduct.vue @@ -109,7 +109,7 @@ const update = (item: any) => { const edit = (item: any) => { uni.navigateTo({ url: - "/pagesApp/components/addShipmentProduct?title=编辑收货产品&item=" + + "/pagesApp/components/addShipmentProduct?title=编辑出货产品&item=" + JSON.stringify(item), // 要跳转到的页面路径 }); }; diff --git a/src/pagesLogin/profile/baseinfo.vue b/src/pagesLogin/profile/baseinfo.vue index a16d3bb..46091b1 100644 --- a/src/pagesLogin/profile/baseinfo.vue +++ b/src/pagesLogin/profile/baseinfo.vue @@ -1,7 +1,7 @@