123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import {
- getDate,
- getWaterDrop,
- } from '../../../utils/index/index'
- import {
- visitorReportPageList,
- visitorSignOut
- } from '../../../utils/api/api'
- const app = getApp()
- Page({
- data: {
- formPath: null, //从哪个页面来
- tableList: [],
- searchForm: {
- data: {
- name: '',
- phone: '',
- idNumber: '',
- company: '',// 来访单位
- visiteeXm: '',// 来访人
- visiteeBm: '',// 来访人部门
- carno: '',
- startTime: '',
- endTime: '',
- signOutStartTime: '',
- signOutEndTime: '',
- reason: '', // 事由
- sn: '',
- },
- pageNum: 1,
- pageSize: 9,
- },
- total: null,
- allPageNum: 0,
- notDesensitizedColumn: [],
- signOutList: [{
- id: true,
- name: '已签离'
- },
- {
- id: false,
- name: '未签离'
- },
- ],
- causeMatterList: []
- },
- onLoad(e) {
- my.hideBackHome();
- let visitReasonList = (app.globalData.snDisposition.visitReason || '业务拜访/会议邀请/施工单位/其他事项').split('/');
- this.setData({
- causeMatterList: visitReasonList,
- formPath: e.formPath || null,
- notDesensitizedColumn: app.globalData.snDisposition.notDesensitizedColumn
- })
- this.data.searchFormCopy = JSON.parse(JSON.stringify(this.data.searchForm));
- this.getTable()
- },
- async getTable() {
- let {
- searchForm,
- } = this.data;
- searchForm.data.sn = app.globalData.sn
- my.showLoading()
- try {
- let res = await visitorReportPageList(searchForm)
- this.setData({
- tableList: res.data.list,
- total: res.data.total,
- allPageNum: Math.ceil(res.data.total / searchForm.pageSize)
- })
- my.hideLoading();
- } catch (error) {
- my.hideLoading();
- }
- },
- clickAudio() {
- getWaterDrop()
- },
- //签离
- async signOff(e) {
- let item = e.currentTarget.dataset.item
- let data = {
- sn: app.globalData.sn,
- userVisitorListDetailId: item.userVisitorListDetailId,
- }
- let res = await visitorSignOut(data)
- my.showToast({
- content: '签离成功',
- duration: 2000
- });
- this.getTable()
- },
- getVal(e) {
- let key = e.currentTarget.dataset.key
- let key1 = `searchForm.data[${key}]`
- let signOutList = this.data.signOutList
- let causeMatterList = this.data.causeMatterList
- console.log(e.detail.value, causeMatterList[e.detail.value])
- switch (key) {
- case 'reason':
- this.setData({
- 'searchForm.data.reason': causeMatterList[e.detail.value],
- })
- break;
- case 'isSignOut':
- this.setData({
- 'searchForm.data.isSignOut': signOutList[e.detail.value].id,
- 'searchForm.data.isSignOutName': signOutList[e.detail.value].name,
- })
- break;
- default:
- this.setData({
- [key1]: e.detail.value
- })
- break;
- }
- },
- // 获取日期
- datePicker(e) {
- my.datePicker({
- format: 'yyyy-MM-dd HH:mm:ss', //返回的日期格式
- currentDate: getDate(), //初始选择的日期时间,默认当前时间
- startDate: '2012-01-01 11:11:11', //最小日期时间
- endDate: getDate(), //最大日期时间
- success: res => {
- let key = e.currentTarget.dataset.key
- this.setData({
- [`searchForm.data.${key}`]: res.date
- });
- },
- });
- },
- //清空
- clearFun() {
- let searchForm = JSON.parse(JSON.stringify(this.data.searchFormCopy));
- this.setData({
- searchForm
- })
- this.getTable()
- },
- // 上一页
- previousFun() {
- let {
- searchForm,
- } = this.data
- if (searchForm.pageNum <= 1) {
- return
- }
- this.setData({
- 'searchForm.pageNum': searchForm.pageNum - 1,
- })
- this.getTable()
- },
- // 下一页
- nextFun() {
- let {
- searchForm,
- allPageNum,
- } = this.data
- if (searchForm.pageNum >= allPageNum) {
- return
- }
- this.setData({
- 'searchForm.pageNum': searchForm.pageNum + 1,
- })
- this.getTable()
- },
- // 关闭
- closeFun() {
- let url = this.data.formPath ? '/pages/home/index' : '/pages/settings/index/index'
- my.reLaunch({
- url: url
- });
- },
- });
|