Browse Source

no message

feature/v1.2
xpz2018 5 years ago
parent
commit
ffcb1d1ac1
18 changed files with 333 additions and 215 deletions
  1. 4
      api/user.js
  2. 58
      components/checker/index.js
  3. 7
      components/checker/index.json
  4. 22
      components/checker/index.wxml
  5. 12
      components/checker/index.wxs
  6. 1
      components/checker/index.wxss
  7. 21
      components/checker/shared.js
  8. 11
      components/checker/toolbar.wxml
  9. 15
      components/picker/index.js
  10. 41
      components/picker/index.wxml
  11. 27
      components/picker/toolbar.wxml
  12. 23
      components/radio/index.wxml
  13. 105
      pages/home/employee-info/index.js
  14. 5
      pages/home/employee-info/index.json
  15. 42
      pages/home/employee-info/index.wxml
  16. 151
      pages/home/employee/index.js
  17. 1
      pages/home/employee/index.json
  18. 2
      pages/home/employee/index.wxml

4
api/user.js

@ -28,7 +28,7 @@ const applyEmplyee = (params) => mPost(`/uec/apply/to/be/employee/of/enterprise-
const getCheckList = (params) => mGet(`/uec/get/employee-joining-department-application-list`, params, config)
const auditEmploye = (params) => mPost(`/uec/audit/employee-joining-department-application`, params, config)
const deleteEmploye = (params) => mPost(`/uec/remove/employees`, params, config)
const adminEmploye = (params) => mPost(`/uec/grant/admin-role/to/employees`, params, config)
const editEmploye = (params) => mPost(`/uec/save/self-department-member`, params, config)
// ****************************************************************************************************************************************
// /authorize/by-wechat-applet小程序登录
function loginWechat(form) {
@ -204,5 +204,5 @@ export {
getCheckList,
auditEmploye,
deleteEmploye,
adminEmploye
editEmploye
}

58
components/checker/index.js

@ -0,0 +1,58 @@
import { VantComponent } from '../common/component';
import { pickerProps } from './shared';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), {
max: {
type: Number,
value: Infinity,
},
activeId: {
type: Array,
value: []
},
toolbarPosition: {
type: String,
value: 'top'
},
defaultIndex: {
type: Number,
value: 0
},
columns: {
type: Array,
value: []
},
selectedIcon: {
type: String,
value: 'success',
}
}),
methods: {
emit(event) {
const { type } = event.currentTarget.dataset;
if (this.data.columns.length) {
this.$emit(type, this.data.activeId );
} else {
this.$emit(type, { });
}
},
onSelectItem(event) {
const { item } = event.currentTarget.dataset;
const isArray = Array.isArray(this.data.activeId);
// 判断有没有超出右侧选择的最大数
const isOverMax = isArray && this.data.activeId.length >= this.data.max;
// 判断该项有没有被选中, 如果有被选中,则忽视是否超出的条件
const index = this.data.activeId.indexOf(item.id)
if (!item.disabled && !isOverMax) {
if(index > -1){
this.data.activeId.splice(index, 1)
} else {
this.data.activeId.push(item.id)
}
this.setData({ activeId: this.data.activeId });
}
},
}
});

7
components/checker/index.json

@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"van-icon": "../icon/index",
"loading": "../loading/index"
}
}

22
components/checker/index.wxml

@ -0,0 +1,22 @@
<import src="./toolbar.wxml" />
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="wxs" />
<view class="van-picker custom-class">
<template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}"
data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
<view wx:if="{{ loading }}" class="van-picker__loading">
<loading color="#1989fa" />
</view>
<scroll-view scroll-y class="van-tree-select__content" style="height: {{ itemHeight * visibleItemCount }}px; padding: 0rpx 32rpx">
<slot name="content" />
<view wx:for="{{ columns }}" wx:key="id"
class="van-ellipsis content-item-class {{ utils.bem('tree-select__item', { active: wxs.isActive(activeId, item.id), disabled: item.disabled }) }} {{ wxs.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}"
data-item="{{ item }}" style="height: {{ itemHeight }}px;border-bottom: 1rpx solid #f3f3f3" bind:tap="onSelectItem">
{{ item.name }}
<van-icon wx:if="{{ wxs.isActive(activeId, item.id) }}" name="{{ selectedIcon }}" size="16px" class="van-tree-select__selected" />
</view>
</scroll-view>
<template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}"
data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
</view>

12
components/checker/index.wxs

@ -0,0 +1,12 @@
/* eslint-disable */
var array = require('../wxs/array.wxs');
function isActive (activeList, itemId) {
if (array.isArray(activeList)) {
return activeList.indexOf(itemId) > -1;
}
return activeList === itemId;
}
module.exports.isActive = isActive;

1
components/checker/index.wxss

@ -0,0 +1 @@
@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;-webkit-user-select:none;user-select:none;background-color:#fff;background-color:var(--picker-background-color,#fff)}.van-picker__toolbar{display:-webkit-flex;display:flex;-webkit-justify-content:space-between;justify-content:space-between;height:44px;height:var(--picker-toolbar-height,44px);line-height:44px;line-height:var(--picker-toolbar-height,44px)}.van-picker__cancel{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px);color:#666666;color:var(--picker-action-text-color,#666666)}.van-picker__confirm{padding:0 16px;padding:var(--picker-action-padding,0 16px);font-size:14px;font-size:var(--picker-action-font-size,14px);color:#1989fa;color:var(--picker-action-text-color,#1989fa)}.van-picker__cancel--hover,.van-picker__confirm--hover{background-color:#f2f3f5;background-color:var(--picker-action-active-color,#f2f3f5)}.van-picker__title{max-width:50%;text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--picker-option-font-size,16px)}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1 1;flex:1 1;width:0}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;background-color:hsla(0,0%,100%,.9);background-color:var(--picker-loading-mask-color,hsla(0,0%,100%,.9))}.van-picker__mask{position:absolute;top:0;left:0;z-index:2;width:100%;height:100%;background-image:linear-gradient(180deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4)),linear-gradient(0deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4));background-repeat:no-repeat;background-position:top,bottom;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;-webkit-transform:translateY(-50%);transform:translateY(-50%);pointer-events:none}.van-tree-select{position:relative;display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;font-size:14px;font-size:var(--tree-select-font-size,14px)}.van-tree-select__nav{-webkit-flex:1;flex:1;background-color:#f7f8fa;background-color:var(--tree-select-nav-background-color,#f7f8fa);--sidebar-padding:12px 8px 12px 12px}.van-tree-select__nav__inner{width:100%!important;height:100%}.van-tree-select__content{-webkit-flex:2;flex:2;background-color:#fff;background-color:var(--tree-select-content-background-color,#fff)}.van-tree-select__item{position:relative;font-weight:700;line-height:44px;line-height:var(--tree-select-item-height,44px)}.van-tree-select__item--active{color:#1989fa;color:var(--tree-select-item-active-color,#1989fa)}.van-tree-select__item--disabled{color:#c8c9cc;color:var(--tree-select-item-disabled-color,#c8c9cc)}.van-tree-select__selected{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:0px;}

21
components/checker/shared.js

@ -0,0 +1,21 @@
export const pickerProps = {
title: String,
loading: Boolean,
showToolbar: Boolean,
cancelButtonText: {
type: String,
value: '取消'
},
confirmButtonText: {
type: String,
value: '确认'
},
visibleItemCount: {
type: Number,
value: 5
},
itemHeight: {
type: Number,
value: 45
}
};

11
components/checker/toolbar.wxml

@ -0,0 +1,11 @@
<template name="toolbar">
<view wx:if="{{ showToolbar }}" class="van-picker__toolbar van-hairline--top-bottom toolbar-class">
<view class="van-picker__cancel" hover-class="van-picker__cancel--hover" hover-stay-time="70" data-type="cancel" bindtap="emit">
{{ cancelButtonText }}
</view>
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{title}}</view>
<view class="van-picker__confirm" hover-class="van-picker__confirm--hover" hover-stay-time="70" data-type="confirm" bindtap="emit">
{{ confirmButtonText }}
</view>
</view>
</template>

15
components/picker/index.js

@ -2,16 +2,20 @@ import { VantComponent } from '../common/component';
import { pickerProps } from './shared';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), { valueKey: {
props: Object.assign(Object.assign({}, pickerProps), {
valueKey: {
type: String,
value: 'text'
}, toolbarPosition: {
},
toolbarPosition: {
type: String,
value: 'top'
}, defaultIndex: {
},
defaultIndex: {
type: Number,
value: 0
}, columns: {
},
columns: {
type: Array,
value: [],
observer(columns = []) {
@ -21,7 +25,8 @@ VantComponent({
this.setColumns().catch(() => { });
}
}
} }),
}
}),
beforeCreate() {
this.children = [];
},

41
components/picker/index.wxml

@ -1,36 +1,23 @@
<import src="./toolbar.wxml" />
<view class="van-picker custom-class">
<template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
<template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}"
data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
<view wx:if="{{ loading }}" class="van-picker__loading">
<loading color="#1989fa"/>
<loading color="#1989fa" />
</view>
<view
class="van-picker__columns"
style="height: {{ itemHeight * visibleItemCount }}px"
catch:touchmove="noop"
>
<picker-column
class="van-picker__column"
wx:for="{{ isSimple(columns) ? [columns] : columns }}"
wx:key="index"
data-index="{{ index }}"
custom-class="column-class"
value-key="{{ valueKey }}"
<view class="van-picker__columns" style="height: {{ itemHeight * visibleItemCount }}px" catch:touchmove="noop">
<picker-column class="van-picker__column" wx:for="{{ isSimple(columns) ? [columns] : columns }}" wx:key="index"
data-index="{{ index }}" custom-class="column-class" value-key="{{ valueKey }}"
initial-options="{{ isSimple(columns) ? item : item.values }}"
default-index="{{ item.defaultIndex || defaultIndex }}"
item-height="{{ itemHeight }}"
visible-item-count="{{ visibleItemCount }}"
active-class="active-class"
bind:change="onChange"
/>
<view class="van-picker__mask" style="background-size: 100% {{ (itemHeight * visibleItemCount - itemHeight) / 2 }}px" />
<view
class="van-picker__frame van-hairline--top-bottom"
style="height: {{ itemHeight }}px"
/>
default-index="{{ item.defaultIndex || defaultIndex }}" item-height="{{ itemHeight }}"
visible-item-count="{{ visibleItemCount }}" active-class="active-class" bind:change="onChange" />
<view class="van-picker__mask"
style="background-size: 100% {{ (itemHeight * visibleItemCount - itemHeight) / 2 }}px" />
<view class="van-picker__frame van-hairline--top-bottom" style="height: {{ itemHeight }}px" />
</view>
<template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
<template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}"
data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
</view>
<wxs module="isSimple">
@ -38,4 +25,4 @@
return columns.length && !columns[0].values;
}
module.exports = isSimple;
</wxs>
</wxs>

27
components/picker/toolbar.wxml

@ -1,28 +1,11 @@
<template name="toolbar">
<view
wx:if="{{ showToolbar }}"
class="van-picker__toolbar van-hairline--top-bottom toolbar-class"
>
<view
class="van-picker__cancel"
hover-class="van-picker__cancel--hover"
hover-stay-time="70"
data-type="cancel"
bindtap="emit"
>
<view wx:if="{{ showToolbar }}" class="van-picker__toolbar van-hairline--top-bottom toolbar-class">
<view class="van-picker__cancel" hover-class="van-picker__cancel--hover" hover-stay-time="70" data-type="cancel" bindtap="emit">
{{ cancelButtonText }}
</view>
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{
title
}}</view>
<view
class="van-picker__confirm"
hover-class="van-picker__confirm--hover"
hover-stay-time="70"
data-type="confirm"
bindtap="emit"
>
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{title}}</view>
<view class="van-picker__confirm" hover-class="van-picker__confirm--hover" hover-stay-time="70" data-type="confirm" bindtap="emit">
{{ confirmButtonText }}
</view>
</view>
</template>
</template>

23
components/radio/index.wxml

@ -1,29 +1,20 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<view class="van-radio custom-class">
<view
wx:if="{{ labelPosition === 'left' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}"
bindtap="onClickLabel"
>
<view wx:if="{{ labelPosition === 'left' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel">
<slot />
</view>
<view class="van-radio__icon-wrap" style="font-size: {{ utils.addUnit(iconSize) }};" bindtap="onChange">
<slot wx:if="{{ useIconSlot }}" name="icon" />
<van-icon
wx:else
name="success"
<van-icon wx:else name="success"
class="{{ utils.bem('radio__icon', [shape, { disabled, checked: value === name }]) }}"
style="font-size: {{ utils.addUnit(iconSize) }};{{ checkedColor && !disabled && value === name ? 'border-color:' + checkedColor + '; background-color:' + checkedColor + ';' : '' }}"
custom-class="icon-class"
custom-style="line-height: {{ utils.addUnit(iconSize) }};font-size: .8em;display: block;"
/>
custom-style="line-height: {{ utils.addUnit(iconSize) }};font-size: .8em;display: block;" />
</view>
<view
wx:if="{{ labelPosition === 'right' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}"
bindtap="onClickLabel"
>
<view wx:if="{{ labelPosition === 'right' }}"
class="label-class {{ utils.bem('radio__label', [labelPosition, { disabled }]) }}" bindtap="onClickLabel">
<slot />
</view>
</view>
</view>

105
pages/home/employee-info/index.js

@ -1,9 +1,9 @@
// pages/home/customer-info/index.js
import Scene from '../../index/scene'
import { getRoleList, editCustomer, saveCustomer} from "../../../api/saas"
import Dialog from '../../../components/dialog/dialog'
import { getRoleList} from "../../../api/saas"
import { editEmploye, deleteEmploye, auditEmploye } from "../../../api/user"
const util = require('../../../utils/util')
const event = require('../../../utils/event')
const app = getApp()
Scene({
/**
@ -22,6 +22,12 @@ Scene({
let channel = this.getOpenerEventChannel()
let that = this
channel.on('onParam', function (data) {
console.log(data)
if(data.enterpriseRoleIds.length){
data.enterpriseRoleIds = data.enterpriseRoleIds.split(',')
} else {
data.enterpriseRoleIds = []
}
that.setData({ form: data })
})
}
@ -33,52 +39,83 @@ Scene({
this.data.form[e.currentTarget.id] = e.detail
},
chooseMethod: function(e){
if(e.currentTarget.id == 'bankName'){
this.setData({ visible: true })
} else {
this.setData({ show: true })
}
},
registCustomer: function(){
wx.navigateTo({ url: `/pages/client/registe/index?id=${this.data.form.id}` })
this.setData({ visible: true })
},
onHide: function() {
this.setData({ visible: false })
},
onConfirm: function({detail}) {
this.setData({ visible: false, ['form.bankName']: detail.value })
var rolename = ''
for (let index = 0; index < this.data.roleList.length; index++) {
const element = this.data.roleList[index]
if(detail.indexOf(element.id) > -1){
if(util.isEmpty(rolename)){
rolename = element.name
} else {
rolename += ',' + element.name
}
}
}
this.setData({ visible: false, ['form.enterpriseRoleIds']: detail, ['form.enterpriseRoleNames']: rolename })
},
onChange: function({detail}) {
this.setData({ ['form.status']: detail })
},
submitForm: function(){
if (util.isEmpty(this.data.form.name)) {
util.showToast('请输入客户姓名')
if (util.isEmpty(this.data.form.enterpriseRoleIds) || !this.data.form.enterpriseRoleIds.length) {
util.showToast('员工角色')
return
}
if (util.isEmpty(this.data.form.defaultPaymentMethod)) {
util.showToast('请选择客户的付款方式')
return
wx.showLoading({ title: '处理中', mask: true })
if(!util.isEmpty(this.data.form.joinAt)){
this.data.form.joinAt = this.data.form.joinAt.substring(0, 10)
}
if (util.isEmpty(this.data.form.defaultPaymentMethod)) {
this.data.form.defaultPaymentMethod = 1
editEmploye(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('修改成功')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
agreeForm: function(){
if (util.isEmpty(this.data.form.enterpriseRoleIds) || !this.data.form.enterpriseRoleIds.length) {
util.showToast('员工角色')
return
}
wx.showLoading({ title: '正在获取', mask: true })
if(this.data.form.id) {
editCustomer(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('修改成功')
event.emit('EventMessage', { what: 102, detail: this.data.form })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
} else {
saveCustomer(this.data.form).then(result => {
wx.showLoading({ title: '处理中', mask: true })
this.data.form.status = 1
auditEmploye(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('员工已经加入')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
refuseform: function(){
wx.showLoading({ title: '处理中', mask: true })
this.data.form.status = 2
auditEmploye(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('员工已经拒绝')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
deleteForm: function(){
Dialog.confirm({ title: '温馨提示', message: '确定删除该员工?' }).then(() => {
wx.showLoading({ title: '处理中', mask: true })
deleteEmploye({idList: [this.data.form.enterpriseMemberId] }).then(result => {
wx.hideLoading()
util.showBackToast('添加成功')
event.emit('EventMessage', { what: 102, detail: this.data.form })
util.showBackToast('员工已经删除')
const channel = this.getOpenerEventChannel()
channel.emit('onCallback', { what: 120, desc: 'PaymentOrder' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
})
}
})

5
pages/home/employee-info/index.json

@ -7,8 +7,11 @@
"van-image": "/components/image/index",
"van-icon": "/components/icon/index",
"van-notice-bar": "/components/notice-bar/index",
"van-picker": "/components/picker/index",
"van-checker": "/components/checker/index",
"van-popup": "/components/popup/index",
"van-radio": "/components/radio/index",
"van-radio-group": "/components/radio-group/index",
"van-dialog": "/components/dialog/index",
"notification": "/pages/message/notification/index"
}
}

42
pages/home/employee-info/index.wxml

@ -2,23 +2,37 @@
<view slot="content">员工资料</view>
</cu-custom>
<view wx:if="{{form}}">
<van-notice-bar color="#1989fa" background="#008AFF" left-icon="info-o" text="{{form.id ? '点击可以修改客户信息' : '添加客户信息'}}" />
<van-field value="{{ form.enterpriseMemberId }}" label="员工编号:" disabled wx:if="{{ form.enterpriseMemberId }}"/>
<van-field id="name" value="{{ form.enterpriseMemberName || form.name }}" label="员工姓名:" placeholder="请输入客户姓名" bind:input="bindInput"/>
<van-field id="mobile" value="{{ form.mobile }}" type="number" label="手机号码:" placeholder="请输入手机号码" bind:input="bindInput"/>
<van-field value="{{ form.defaultPaymentMethod ? form.defaultPaymentMethod == 2 ? '转账' : '现金' : '请选择角色'}}" readonly label="员工角色:" is-link bindtap="chooseMethod" />
<view style="height:32rpx"></view>
<view style="margin-top:20rpx;padding:48rpx 32rpx">
<van-button block type="danger" bind:click="registCustomer">删除</van-button>
<view style="height:36rpx"></view>
<van-button block type="info" bind:click="submitForm">保存</van-button>
<van-notice-bar color="#1989fa" background="#008AFF" left-icon="info-o" text="点击可以修改员工信息" wx:if="{{form.enterpriseMemberId}}" />
<van-field value="{{ form.enterpriseMemberId }}" label="员工编号:" disabled wx:if="{{ form.enterpriseMemberId }}" />
<van-field id="name" value="{{ form.enterpriseMemberName || form.name }}" label="员工姓名:" placeholder="请输入员工姓名" bind:input="bindInput" />
<van-field value="{{ form.mobile }}" type="number" label="手机号码:" disabled placeholder="请输入手机号码" />
<van-field value="{{ form.enterpriseRoleNames || '请选择角色'}}" readonly label="员工角色:" is-link bindtap="chooseMethod" />
<van-cell wx:if="{{!form.apply}}">
<view slot="title" class="flex flex-justify">
<view class="text-black">员工状态:</view>
<van-radio-group value="{{ form.status }}" bind:change="onChange" direction="horizontal">
<view class="flex flex-center">
<van-radio name="{{0}}">启用</van-radio>
<van-radio name="{{1}}" style="margin-left: 32rpx">停用</van-radio>
</view>
</van-radio-group>
</view>
</van-cell>
<view style="height:32rpx"></view>
<view style="margin-top:20rpx;padding:48rpx 32rpx" wx:if="{{ form.enterpriseMemberId }}">
<van-button block type="danger" bind:click="deleteForm">删除</van-button>
<view style="height:36rpx"></view>
<van-button block type="info" bind:click="submitForm">保存</van-button>
</view>
<view style="margin-top:20rpx;padding:48rpx 32rpx" wx:else>
<van-button block type="danger" bind:click="refuseform">拒绝</van-button>
<view style="height:36rpx"></view>
<van-button block type="info" bind:click="agreeForm">同意</van-button>
</view>
<van-dialog id="van-dialog" />
<van-popup position="bottom" show="{{ visible }}" bind:close="onHide" z-index="29">
<van-picker show-toolbar title="选择银行" columns="{{ bankList }}" bind:cancel="onHide" bind:confirm="onConfirm" />
<van-checker show-toolbar title="选择角色" columns="{{ roleList }}" active-id="{{ form.enterpriseRoleIds }}" bind:cancel="onHide" bind:confirm="onConfirm" />
</van-popup>
<notification id="qn-notification"/>
<notification id="qn-notification" />

151
pages/home/employee/index.js

@ -15,7 +15,6 @@ Scene({
loading: true,
checkList: [],
memberList: [],
eemidList: [],
showEmbedded: false,
show: false,
actions: [
@ -28,24 +27,17 @@ Scene({
*/
onLoad: function (options) {
this.setData({ height: app.globalData.fragmentHeight })
wx.showLoading({ title: '加载中', mask: true })
this.fetchMemberList()
},
fetchMemberList: function(){
wx.showLoading({ title: '加载中', mask: true })
getCheckList({enterpriseId: app.userInfo.enterpriseId}).then(result => {
this.setData({ checkList: result.data.records, loading: false})
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
this.data.eemidList = []
getEmployeList({enterpriseId: app.userInfo.enterpriseId, isPassFromBackstage: 1}).then(result => {
for (let index = 0; index < result.data.records.length; index++) {
const element = result.data.records[index]
if(element.position == 'ADMINISTRATOR'){
this.data.eemidList.push(element.id)
}
}
this.setData({ memberList: result.data.records, loading: false })
wx.hideLoading()
}).catch(err => {
@ -57,18 +49,13 @@ Scene({
this.data.nowIndex = e.currentTarget.dataset.index
var item = this.data.memberList[this.data.nowIndex]
item.apply = 0
// if(item.position == 'ADMINISTRATOR'){
// this.setData({ actions: [ { id: 1, name: '删除该员工' } ], show: true })
// } else [
// this.setData({ actions: [ { id: 2, name: '设为管理员' }, { id: 1, name: '删除该员工' } ], show: true })
// ]
wx.navigateTo({
url: `/pages/home/employee-info/index?id=${item.enterpriseMemberId}`,
events: {
onCallback: (data) => {
// if (data.what == 12) {
// that.fetchOrderInfo(that.data.form.id)
// }
if (data.what == 120) {
that.fetchMemberList()
}
}
},
success: function(res) {
@ -76,77 +63,62 @@ Scene({
}
})
},
onClose() {
this.setData({ show: false })
this.data.nowIndex = -1
},
onSelect({detail}) {
if(detail.id === 1){
var item = this.data.memberList[this.data.nowIndex]
this.deleteItem(this.data.nowIndex, item)
this.data.nowIndex = -1
} else if(detail.id === 2){
var item = this.data.memberList[this.data.nowIndex]
this.setAdmin(this.data.nowIndex, item)
this.data.nowIndex = -1
}
},
setAdmin: function(index, item){
wx.showLoading({ title: '加载中', mask: true })
if(item.position == 'ADMINISTRATOR'){
var sindex = -1
for (var i = 0; i < this.data.eemidList.length; i++) {
if (this.data.eemidList[i] == item.id){
sindex = i
break
}
}
this.data.eemidList.splice(sindex, 1)
} else {
if(this.data.eemidList.indexOf(item.id) < 0){
this.data.eemidList.push(item.id)
}
}
adminEmploye({ids: this.data.eemidList }).then(result => {
this.setData({ ['memberList[' + index + '].position'] : item.position == 'ADMINISTRATOR' ? 'ORDINARY' : 'ADMINISTRATOR'})
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
deleteItem: function(index, item){
wx.showLoading({ title: '加载中', mask: true })
deleteEmploye({idList: [item.enterpriseMemberId] }).then(result => {
this.fetchMemberList()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
agreeItem: function(e){
wx.showLoading({ title: '加载中', mask: true })
var item = this.data.checkList[e.currentTarget.dataset.index]
auditEmploye({id: item.id, status: 1 }).then(result => {
this.fetchMemberList()
}).catch(err => {
wx.hideLoading()
console.log(err)
util.showToast(err)
})
},
refuseItem: function(e){
wx.showLoading({ title: '加载中', mask: true })
var item = this.data.checkList[e.currentTarget.dataset.index]
auditEmploye({id: item.id, status: 2 }).then(result => {
this.setData({ ['checkList[' + e.currentTarget.dataset.index + '].status']: 2})
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
console.log(err)
util.showToast(err)
})
},
// setAdmin: function(index, item){
// wx.showLoading({ title: '加载中', mask: true })
// if(item.position == 'ADMINISTRATOR'){
// var sindex = -1
// for (var i = 0; i < this.data.eemidList.length; i++) {
// if (this.data.eemidList[i] == item.id){
// sindex = i
// break
// }
// }
// this.data.eemidList.splice(sindex, 1)
// } else {
// if(this.data.eemidList.indexOf(item.id) < 0){
// this.data.eemidList.push(item.id)
// }
// }
// adminEmploye({ids: this.data.eemidList }).then(result => {
// this.setData({ ['memberList[' + index + '].position'] : item.position == 'ADMINISTRATOR' ? 'ORDINARY' : 'ADMINISTRATOR'})
// wx.hideLoading()
// }).catch(err => {
// wx.hideLoading()
// util.showToast(err)
// })
// },
// deleteItem: function(index, item){
// wx.showLoading({ title: '加载中', mask: true })
// deleteEmploye({idList: [item.enterpriseMemberId] }).then(result => {
// this.fetchMemberList()
// }).catch(err => {
// wx.hideLoading()
// util.showToast(err)
// })
// },
// agreeItem: function(e){
// wx.showLoading({ title: '加载中', mask: true })
// var item = this.data.checkList[e.currentTarget.dataset.index]
// auditEmploye({id: item.id, status: 1 }).then(result => {
// this.fetchMemberList()
// }).catch(err => {
// wx.hideLoading()
// console.log(err)
// util.showToast(err)
// })
// },
// refuseItem: function(e){
// wx.showLoading({ title: '加载中', mask: true })
// var item = this.data.checkList[e.currentTarget.dataset.index]
// auditEmploye({id: item.id, status: 2 }).then(result => {
// this.setData({ ['checkList[' + e.currentTarget.dataset.index + '].status']: 2})
// wx.hideLoading()
// }).catch(err => {
// wx.hideLoading()
// console.log(err)
// util.showToast(err)
// })
// },
onClickHideEmbedded: function(){
this.setData({ showEmbedded: false })
},
@ -186,8 +158,5 @@ Scene({
that.setData({ showEmbedded: false })
}
})
},
noop: function() {
}
})

1
pages/home/employee/index.json

@ -9,7 +9,6 @@
"van-tag": "/components/tag/index",
"van-icon": "/components/icon/index",
"van-overlay": "/components/overlay/index",
"van-action-sheet": "/components/action-sheet/index",
"notification": "/pages/message/notification/index"
}
}

2
pages/home/employee/index.wxml

@ -76,6 +76,4 @@
</view>
</van-overlay>
<van-action-sheet show="{{ show }}" actions="{{ actions }}" bind:cancel="onClose" bind:close="onClose" bind:select="onSelect" cancel-text="取消" z-index="22"/>
<notification id="qn-notification"/>
Loading…
Cancel
Save