Commit 50d2e58b by chenwq

技师列表

1 parent d4d6dff9
...@@ -46,7 +46,7 @@ const updateService = data => { ...@@ -46,7 +46,7 @@ const updateService = data => {
const getTechnicianList = data => { const getTechnicianList = data => {
return api.post( return api.post(
{ {
method: 'scrm.api.businessAssistant.technicianConfig.page', method: 'scrm.api.busassistant.technicianConfig.page',
...data ...data
} }
) )
...@@ -56,7 +56,7 @@ const getTechnicianList = data => { ...@@ -56,7 +56,7 @@ const getTechnicianList = data => {
const addTechnician = data => { const addTechnician = data => {
return api.post( return api.post(
{ {
method: 'scrm.api.businessAssistant.technicianConfig.add', method: 'scrm.api.busassistant.technicianConfig.add',
...data ...data
}, },
true true
...@@ -67,7 +67,7 @@ const addTechnician = data => { ...@@ -67,7 +67,7 @@ const addTechnician = data => {
const updateTechnician = data => { const updateTechnician = data => {
return api.post( return api.post(
{ {
method: 'scrm.api.businessAssistant.technicianConfig.update', method: 'scrm.api.busassistant.technicianConfig.update',
...data ...data
}, },
true true
...@@ -78,7 +78,7 @@ const updateTechnician = data => { ...@@ -78,7 +78,7 @@ const updateTechnician = data => {
const deleteTechnician = data => { const deleteTechnician = data => {
return api.post( return api.post(
{ {
method: 'scrm.api.businessAssistant.technicianConfig.delete', method: 'scrm.api.busassistant.technicianConfig.delete',
...data ...data
}, },
true true
......
...@@ -32,7 +32,10 @@ ...@@ -32,7 +32,10 @@
<view class="employee-list"> <view class="employee-list">
<!-- 技师 --> <!-- 技师 -->
<view class="employee-list"> <view class="employee-list">
<glsx-image class="avatar-box" src="personal/staff_defalut_avatar.png" /> <view class="avatar-box">
<glsx-image class="avatar-img" src="personal/staff_defalut_avatar.png" />
<view wx:if="{{item.technicianCount != '0'}}" class="num">{{item.technicianCount > maxNum ? (maxNum + '+') : item.technicianCount}}</view>
</view>
<view class="look-btn" data-target="{{item}}" catchtap="handleTechnician">技师</view> <view class="look-btn" data-target="{{item}}" catchtap="handleTechnician">技师</view>
</view> </view>
<view class="line">|</view> <view class="line">|</view>
......
const formRule = {
technicianName: [{ required: true, message: '客户名称不能为空' }]
}
const formItems = [{
label: '技师',
props: 'technicianName',
type: 'input',
placeholder: '请输入技师的名称',
maxlength: 10
}]
export default {
formRule,
formItems
}
\ No newline at end of file \ No newline at end of file
// packageMine/pages/customerManagement/technicianList/technicianList.js // packageMine/pages/customerManagement/technicianList/technicianList.js
import { IMG_URL } from '~/utils/constantData' import { IMG_URL } from '~/utils/constantData'
import mineServiceApi from '~/api/mineApi/mineService' import mineServiceApi from '~/api/mineApi/mineService'
import constantData from './constant/data'
Page({ Page({
/** /**
...@@ -14,17 +15,125 @@ Page({ ...@@ -14,17 +15,125 @@ Page({
pageCof: { pageCof: {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
},
formData: {
technicianName: ''
},
formItems: constantData.formItems,
targetIdx: '-1',
target: {},
targetIdx: {}
},
handleInput(e) {
let { attr } = e.currentTarget.dataset
let { value } = e.detail
this.setData({
['formData.' + attr]: value
})
},
handleDialogShow() {
this.setData({
isDialogShow: !this.data.isDialogShow
})
},
addTech() {
this.handleDialogShow()
},
editTech() {
let { targetIdx } = this.data
this.setData({
[`technicianList[${targetIdx}].isEdit`]: !this.data.technicianList[targetIdx]?.isEdit
})
},
editClear() {
let { addOrEdit } = this.data
addOrEdit == 'add' ? this.addTech() : this.editTech()
this.setData({
targetIdx: '-1',
target: {},
formData: { technicianName: '' }
})
},
handleConfirm() {
let { formData, target, customerInfo, addOrEdit } = this.data
let apiName = {
'add': 'addTechnician',
'edit': 'updateTechnician',
} }
let params = {
...formData,
merchantId: customerInfo.merchantId,
merchantName: customerInfo.merchantName
}
if (addOrEdit == 'edit') {
params.id = target.id
}
wx.$api.showLoading('加载中...')
mineServiceApi[apiName[addOrEdit]](params).then(res => {
let { code, data, message } = res
if (code == '0') {
wx.hideLoading()
wx.$api.showToast(addOrEdit == 'add' ? '新增成功' : '修改成功')
this.editClear()
this.handleSearch(true)
} else {
wx.$api.showToast(message)
}
})
}, },
handleEdit(e) { handleEdit(e) {
let { type } = e.currentTarget.dataset let { type, target, idx } = e.currentTarget.dataset
let params = { this.setData({
addOrEdit: type, addOrEdit: type,
target: e.currentTarget.dataset?.target || {} target: e.currentTarget.dataset?.target || {},
targetIdx: idx || 0
})
switch (type) {
case 'add':
this.addTech()
break
case 'edit':
this.setData({
['formData.technicianName']: target.technicianName
})
this.editTech(target)
break
} }
delete params.target?.createdDate },
// wx.$router.go('packageMine.edittechnician', params)
handleDelete(e) {
let { target } = e.currentTarget.dataset
let params = {
id: target.id
}
let _this = this
wx.showModal({
title: '删除',
content: '确认删除' + target.technicianName + '技师吗?',
confirmText: '确定',
cancelText: '取消',
confirmColor: '#3666FE',
success(res) {
wx.$api.showLoading('加载中...')
mineServiceApi.deleteTechnician(params).then(res => {
let { code, data, message } = res
if (code == '0') {
wx.hideLoading()
wx.$api.showToast('删除成功')
_this.handleSearch(true)
} else {
wx.$api.showToast(message)
}
})
}
})
}, },
handleSearch() { handleSearch() {
...@@ -40,12 +149,13 @@ Page({ ...@@ -40,12 +149,13 @@ Page({
}, },
getList(isReset = false) { getList(isReset = false) {
let { technicianList, pageCof, total } = this.data let { technicianList, pageCof, total, customerInfo } = this.data
if (total == technicianList.length) { if (total == technicianList.length) {
return true return true
} }
let params = { let params = {
...pageCof ...pageCof,
merchantId: customerInfo.merchantId
} }
mineServiceApi.getTechnicianList(params).then(res => { mineServiceApi.getTechnicianList(params).then(res => {
let { list, total } = res let { list, total } = res
...@@ -67,7 +177,12 @@ Page({ ...@@ -67,7 +177,12 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
wx.$router.getData(res => {
this.setData({
customerInfo: res
})
this.getList(true) this.getList(true)
})
}, },
/** /**
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
.message { .message {
display: flex; display: flex;
align-items: center;
.avatar { .avatar {
flex-shrink: 0; flex-shrink: 0;
...@@ -80,11 +81,17 @@ ...@@ -80,11 +81,17 @@
font-size: 26rpx; font-size: 26rpx;
} }
} }
}
.arrow_right { .icon-edit {
width: 36rpx; width: 36rpx;
height: 36rpx; height: 36rpx;
margin-left: 4rpx;
}
}
.delete {
font-size: 24rpx;
color: #3666FE;
} }
} }
...@@ -114,3 +121,98 @@ ...@@ -114,3 +121,98 @@
line-height: 40rpx; line-height: 40rpx;
} }
} }
// 弹窗
// 提示
.layout {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 998;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.bg {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
background: rgba(0, 0, 0, .8);
}
.content {
position: relative;
text-align: center;
box-sizing: border-box;
width: 614rpx;
height: 440rpx;
background: #FFFFFF;
border-radius: 32rpx;
.form {
margin: 64rpx 40rpx;
text-align: left;
.input {
width: 534rpx;
height: 88rpx;
background: #F8F9FC;
border-radius: 12rpx;
padding-left: 32rpx;
}
.input-placeholder {
font-size: 28rpx;
color: #858A94;
}
}
.title {
height: 110rpx;
line-height: 110rpx;
text-align: center;
font-weight: 600;
font-size: 32rpx;
color: #323436;
border-bottom: 2rpx solid #F5F6F7;
}
.dialog-btn {
position: absolute;
display: flex;
bottom: 0;
left: 0;
width: 100%;
height: 110rpx;
line-height: 110rpx;
border-top: 2rpx solid #F5F6F7;
font-size: 32rpx;
color: #6C737A;
.cancel-btn {
width: 50%;
}
.default-btn {
width: 50%;
color: #3666FE;
border-left: 2rpx solid #F5F6F7;
}
}
}
.close {
position: absolute;
top: 324rpx;
right: 96rpx;
width: 56rpx;
height: 56rpx;
}
\ No newline at end of file \ No newline at end of file
...@@ -10,20 +10,21 @@ ...@@ -10,20 +10,21 @@
</view> </view>
</view> </view>
<scroll-view scroll-y enable-back-to-top refresher-enabled="{{true}}" bindrefresherrefresh="handleSearch" bindscrolltolower="scrollonReachBottom" class="list" style="height:calc(100vh - 148rpx - 110rpx);" scroll-top="{{scrollTop}}" refresher-threshold="104" refresher-triggered="{{triggered}}"> <scroll-view scroll-y enable-back-to-top refresher-enabled="{{true}}" bindrefresherrefresh="handleSearch" bindscrolltolower="scrollonReachBottom" class="list" style="height:calc(100vh - 148rpx - 110rpx);" scroll-top="{{scrollTop}}" refresher-threshold="104" refresher-triggered="{{triggered}}">
<view class="item-box" wx:for="{{technicianList}}" wx:key="index" bindtap="handleEdit" data-type="edit" data-target="{{item}}"> <view class="item-box" wx:for="{{technicianList}}" wx:key="index">
<view class="top"> <view class="top">
<view class="message"> <view class="message">
<glsx-image src="personal/service_head.png" class="avatar" /> <glsx-image src="personal/staff_defalut_avatar.png" class="avatar" />
<view class="message-text"> <view class="message-text">
<view class="merchant">{{item.merchantName}}</view> <input wx:if="{{item.isEdit}}" type="text" placeholder="{{formItems[0].placeholder}}" maxlength="{{formItems[0].maxlength}}" class="input" value="{{formData.technicianName}}" focus="{{item.isEdit}}" placeholder-class="input-placeholder" data-attr="{{formItems[0].props}}" confirm-type="done" bindinput="handleInput" bindblur="handleConfirm" />
<view class="contact">{{item.contactName}} {{item.phone}}</view> <view wx:else class="merchant">{{item.technicianName}}</view>
</view> </view>
<glsx-image wx:if="{{!item.isEdit}}" src="personal/icon-department.png" class="icon-edit" bindtap="handleEdit" data-type="edit" data-target="{{item}}" data-idx="{{index}}" />
</view> </view>
<glsx-image src="personal/arrow_right.png" class="arrow_right" /> <view class="delete" bindtap="handleDelete" data-target="{{item}}">删除</view>
</view> </view>
<view class="bottom"> <view class="bottom">
<view class="technician_name"> <view class="technician_name">
商户号:{{item.merchantId}} 所属:{{item.merchantName}}
</view> </view>
<view class="time">{{item.createdDate}}</view> <view class="time">{{item.createdDate}}</view>
</view> </view>
...@@ -35,3 +36,17 @@ ...@@ -35,3 +36,17 @@
<nothing-tips tips="暂无技师~" bgColor="{{'#F2F3F7'}}" bg="{{bgUrl}}" /> <nothing-tips tips="暂无技师~" bgColor="{{'#F2F3F7'}}" bg="{{bgUrl}}" />
</view> </view>
</view> </view>
<!-- 新增技师 -->
<view wx:if="{{isDialogShow}}" class="layout">
<view class="bg" bindtap="handleDialogShow" />
<view class="content">
<view class="title">新增技师</view>
<view class="form" wx:for="{{formItems}}" wx:key="index">
<input type="text" placeholder="{{item.placeholder || '请输入' + item.label}}" maxlength="{{item.maxlength}}" class="input" value="{{formData[item.props]}}" type="{{item.inputType || 'text'}}" password="{{item.password}}" placeholder-class="input-placeholder" data-attr="{{item.props}}" bindinput="handleInput" />
</view>
<view class="dialog-btn">
<view class="cancel-btn" bindtap="handleDialogShow">取消</view>
<view class="default-btn" bindtap="handleConfirm">确定</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!