Commit db63a1b5 by zhangxw

跳转成功页 修改

1 parent 8275aa4b
<view class="navigation-bar" id="navigation-bar" style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}"> <view class="navigation-bar" id="navigation-bar" style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}"> <block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}"> <view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<block wx:if="{{SHOWBACK}}"> <block wx:if="{{SHOWBACK || customBack}}">
<view class="back " bindtap="back"> <view class="back " bindtap="back">
<image class="img" src="./images/icon-back.png" /> <image class="img" src="./images/icon-back.png" />
</view> </view>
......
const phoneRex = /^[1]([3-9])[0-9]{9}$/
const formRule = {
selectServiceInfo: [{ required: true, message: '所属服务中心不能为空' }],
staffName: [{ required: true, message: '员工姓名不能为空' }],
staffMobile: [
{ required: true, message: '手机号码不能为空' },
{
validator: (rule, value) => {
return !phoneRex.test(value) ? { message: '请输入正确的手机号' } : null
}
}
]
}
const formItems = [{
label: '所属服务中心',
props: 'selectServiceInfo',
valueFn: 'serviceValue',
type: 'select',
placeholder: '请选择服务中心',
pageType: 1
}, {
label: '员工姓名',
props: 'staffName',
type: 'input',
placeholder: '请输入员工姓名',
maxLength: 20
}, {
label: '手机号码',
tips: '(登录凭证)',
props: 'staffMobile',
type: 'input',
placeholder: '请输入手机号码',
maxLength: 11
}, {
label: '可见客户',
props: 'connectionIds',
type: 'select',
valueFn: 'connectionValue',
placeholder: '请选择可见客户',
pageType: 2
}]
export default {
formRule,
formItems
}
// packagesList/mineDetail/pages/staffManage/createStaff/createStaff.js // packagesList/mineDetail/pages/staffManage/createStaff/createStaff.js
import { behavior as computedBehavior } from "~/utils/lib/miniprogram-computed"; import constantData from './constant/data'
import { behavior as computedBehavior } from "~/utils/lib/miniprogram-computed"
Page({ Page({
behaviors: [computedBehavior], behaviors: [computedBehavior],
...@@ -8,34 +9,6 @@ Page({ ...@@ -8,34 +9,6 @@ Page({
*/ */
data: { data: {
addOrEdit: 'add', addOrEdit: 'add',
formItems: [{
label: '所属服务中心',
props: 'selectServiceInfo',
valueFn: 'serviceValue',
type: 'select',
placeholder: '请选择服务中心',
pageType: 1
}, {
label: '员工姓名',
props: 'staffName',
type: 'input',
placeholder: '请输入员工姓名',
maxLength: 20
}, {
label: '手机号码',
tips: '(登录凭证)',
props: 'staffMobile',
type: 'input',
placeholder: '请输入手机号码',
maxLength: 11
}, {
label: '可见客户',
props: 'connectionIds',
type: 'select',
valueFn: 'connectionValue',
placeholder: '请选择可见客户',
pageType: 2
}],
serviceList: [{ serviceList: [{
serviceCode: 1, serviceCode: 1,
staffName: '马保国', staffName: '马保国',
...@@ -103,15 +76,12 @@ Page({ ...@@ -103,15 +76,12 @@ Page({
serviceName: '广东嘀加八号快乐酷爱咖哩鸡服务中心咖哩鸡服务中心咖哩鸡服务中心', serviceName: '广东嘀加八号快乐酷爱咖哩鸡服务中心咖哩鸡服务中心咖哩鸡服务中心',
time: '2022.10.03' time: '2022.10.03'
}], }],
formItems: constantData.formItems,
formData: { formData: {
selectedConnectionList: [],
connectionValue: '全部' connectionValue: '全部'
}, },
showServiceConfirm: false, showServiceConfirm: false
toastList: {
selectServiceInfo: '所属服务中心不能为空',
staffName: '员工姓名不能为空',
staffMobile: '手机号码不能为空'
}
}, },
watch: { watch: {
...@@ -131,11 +101,13 @@ Page({ ...@@ -131,11 +101,13 @@ Page({
}, },
onRoute(options) { onRoute(options) {
// 选择可见客户回退
console.log(constantData)
if (!options.info) return
this.setData({ this.setData({
addOrEdit: options?.info ? 'edit' : 'add', addOrEdit: options?.info ? 'edit' : 'add',
formData: options?.info || {connectionValue: '全部'} formData: options?.info
}) })
console.log(this.data.formData)
}, },
/** /**
...@@ -201,36 +173,14 @@ Page({ ...@@ -201,36 +173,14 @@ Page({
}) })
}, },
// 校验
checkRequired(obj) {
console.log(obj)
let target = ['selectServiceInfo', 'staffName', 'staffMobile']
try {
target.map(key => {
if (!obj[key]) {
throw key
}
})
} catch (error) {
return error
}
return false
},
// 提交 // 提交
handleConfirm() { handleConfirm() {
let { addOrEdit, formData, toastList } = this.data let { addOrEdit, formData } = this.data
const phoneRex = /^[1]([3-9])[0-9]{9}$/ let validObj = wx.$util.checkRule(formData, constantData.formRule)
let key = this.checkRequired(formData) // if (validObj) {
if (key) { // wx.$api.showToast(validObj.message)
wx.$api.showToast(toastList[key]) // return
return // }
}
if (!phoneRex.test(formData?.staffMobile)) {
wx.$api.showToast('请输入正确的手机号')
return
}
console.log(formData)
let message = addOrEdit == 'add' ? '是否确定创建员工?' : '是否确定修改员工信息?' let message = addOrEdit == 'add' ? '是否确定创建员工?' : '是否确定修改员工信息?'
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
...@@ -242,7 +192,9 @@ Page({ ...@@ -242,7 +192,9 @@ Page({
if (res.confirm) { if (res.confirm) {
// 创建/编辑接口 // 创建/编辑接口
if (addOrEdit == 'add') { if (addOrEdit == 'add') {
wx.$router.reLaunch('') wx.$router.redirectTo('packageMine.successPage')
} else {
wx.$router.back()
} }
} }
} }
......
...@@ -127,7 +127,7 @@ Page({ ...@@ -127,7 +127,7 @@ Page({
// confirmColor: '#3666FE', // confirmColor: '#3666FE',
// success(res) { // success(res) {
// if (res.confirm) { // if (res.confirm) {
// wx.$router.reLaunch('') // wx.$router.reLaunch('packageMine.creatService')
// } // }
// } // }
// }) // })
......
...@@ -9,8 +9,7 @@ Page({ ...@@ -9,8 +9,7 @@ Page({
navigationTitle: '创建员工', navigationTitle: '创建员工',
primaryBtn: '继续创建员工', primaryBtn: '继续创建员工',
primaryCallback: 'packageMine.createStaff', primaryCallback: 'packageMine.createStaff',
cancelBtn: 'S后自动跳转我的员工', cancelBtn: 'S后自动跳转我的员工'
cancelCallback: 'packageMine.staffList'
}, },
count: 5 count: 5
}, },
...@@ -22,12 +21,12 @@ Page({ ...@@ -22,12 +21,12 @@ Page({
// this.setData({ // this.setData({
// paramsObj: options // paramsObj: options
// }) // })
let { count, paramsObj } = this.data let { count } = this.data
this.countDownTime = setInterval(() => { this.countDownTime = setInterval(() => {
this.setData({ this.setData({
count: --count count: --count
}) })
if (this.data.count == 0) wx.$router.reLaunch(paramsObj.cancelCallback) if (this.data.count == 0) wx.$router.back()
}, 1 * 1000) }, 1 * 1000)
}, },
...@@ -41,8 +40,12 @@ Page({ ...@@ -41,8 +40,12 @@ Page({
jump(e) { jump(e) {
let { type } = e.currentTarget.dataset let { type } = e.currentTarget.dataset
let { paramsObj } = this.data let { paramsObj } = this.data
let jumpUrl = type == 'primary' ? paramsObj?.primaryCallback : paramsObj?.cancelCallback if (type == 'primary') {
wx.$router.reLaunch(jumpUrl) wx.$router.redirectTo(paramsObj?.primaryCallback)
} else {
wx.$router.back()
}
}, },
/** /**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!