123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- var util = require('../../../utils/util.js')
- Page({
- data: {
- orderId: null,
- noData: '../../../images/noData.png',
- dataListTips: '暂无数据',
- // 初始日期范围
- form: {
- beginDate: util.get7daysAgo(),
- endDate: util.getRealToday(),
- orderId: null,
- staffId: '',
- },
- serviceStaffname: '',
- records: [],
- installerList: [],
- },
- onLoad(options) {
- const id = options.id
- this.setData({
- orderId: id,
- ['form.orderId']: id,
- })
- this.getDetail()
- // this.getinstallerList()
- },
- getDetail() {
- var send_data = [
- { name: 'getInstallationDailyDetailByOrderId', returntype: 'Map', parammaps: this.data.form },
- ]
- util.getDataByNames(send_data, this.handleDetail)
- },
- handleDetail(res) {
- var data = res.data
- if (data.getInstallationDailyDetailByOrderId.list != null) {
- var list = data.getInstallationDailyDetailByOrderId.list
- var service = list.map((item, indexx) => {
- const obj = {
- name: item.installUserName,
- id: item.installUserId,
- }
- return obj
- })
- const uniqueData = service.filter((item, index, self) => {
- return index === self.findIndex((t) => t.id === item.id)
- })
- console.log(uniqueData, 'service')
- this.setData({
- records: data.getInstallationDailyDetailByOrderId.list,
- installerList: uniqueData,
- })
- } else {
- this.setData({
- records: [],
- })
- }
- },
- onInstallerChange: function (e) {
- console.log(e, 'eee')
- this.setData({
- serviceStaffname: this.data.installerList[e.detail.value].name,
- ['form.staffId']: this.data.installerList[e.detail.value].id,
- })
- },
- onInputChangeClear(e) {
- this.setData({
- serviceStaffname: '',
- ['form.staffId']: '',
- })
- },
- // 服务人员
- getinstallerList() {
- var send_data = [
- {
- name: 'getUsersSelect',
- offset: 0,
- pagecount: 0,
- parammaps: {
- enable: '1',
- orderId: this.data.orderId,
- },
- },
- ]
- util.getDataByNames(send_data, this.handleInstallerList)
- },
- handleInstallerList(res) {
- const obj = res.data
- if (obj.getUsersSelect) {
- this.setData({
- installerList: obj.getUsersSelect.list,
- })
- }
- },
- onStaffChange(e) {
- this.setData({
- serverPerson: this.data.serviceList[e.detail.value],
- })
- },
- onContactChange(e) {
- this.setData({
- serverPerson: e.detail.value,
- })
- },
- onDateChange(e) {
- this.setData({
- 'formObj.acceptanceDate': e.detail.value,
- })
- },
- onSelectPerson(event) {
- this.setData({
- 'formObj.serverPerson': this.data.serviceList[event.detail.value],
- })
- },
- onBack() {
- wx.navigateBack()
- },
- uploadReceipt() {
- // 上传验收单的逻辑
- const that = this
- wx.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- that.setData({
- 'formObj.acceptanceFile': res.tempFilePaths[0],
- 'errors.acceptanceFile': '',
- })
- },
- })
- },
- validateForm() {
- const { serverPerson, acceptanceDate, acceptanceFile } = this.data.formObj
- if (!serverPerson) {
- wx.showToast({ title: '请填写服务人员', icon: 'none' })
- return false
- }
- if (!acceptanceDate) {
- wx.showToast({ title: '请选择验收日期', icon: 'none' })
- return false
- }
- if (!acceptanceFile) {
- wx.showToast({ title: '请上传验收单', icon: 'none' })
- return false
- }
- return true
- },
- formSubmit(e) {
- console.log('this.data.formObj:', this.data.formObj)
- wx.showToast({ title: '提交成功', icon: 'success' })
- if (!this.validateForm()) return
- },
- formReset(e) {
- console.log('form发生了reset事件,携带数据为:', e.detail.value)
- this.setData({
- chosen: '',
- })
- },
- goBack() {
- wx.navigateBack()
- },
- //日期1
- bindDateChange1: function (e) {
- this.setData({
- ['form.beginDate']: e.detail.value,
- })
- },
- //日期2
- bindDateChange2: function (e) {
- this.setData({
- ['form.endDate']: e.detail.value,
- })
- },
- viewHistory() {
- // 查看历史记录
- wx.navigateTo({
- url: '/pages/workbench/historyRecord/historyRecord',
- })
- },
- // 更新今日完成量
- updateTodayQuantity(e) {
- const value = parseInt(e.detail.value) || 0
- const remaining = this.data.totalQuantity - this.data.completedQuantity - value
- this.setData({
- todayQuantity: value,
- remainingQuantity: remaining >= 0 ? remaining : 0,
- })
- },
- // 保存记录
- saveRecord() {
- wx.showLoading({
- title: '保存中...',
- })
- // 这里添加保存逻辑
- setTimeout(() => {
- wx.hideLoading()
- wx.showToast({
- title: '保存成功',
- icon: 'success',
- })
- }, 1500)
- },
- })
|