// components/handleSubmit/handleSubmit.js import { $wuxActionSheet } from '../../../../dist/index' var api = require("../../../../api/issueDetail") import { BASEURL } from '../../../../utils/config' // var global = require('./config.js') Component({ /** * 组件的属性列表 */ properties: { handleSubmitData: { // 属性名 type: Object, value: {} }, }, /** * 组件的初始数据 */ data: { BASEURL: BASEURL(), userTagKey: wx.getStorageSync('userTagKey'), isBlock: true, focus: false,//默认没获取焦点 viewData: "", selectImage: "../../../../images/select.png", selectNoImage: "../../../../images/selectNo.png", whistlingDeptList: [], // 可吹哨部门 timer: '' }, /** * 组件的方法列表 */ methods: { // 处理操作 showActionSheet() { let buttons = [] // 议题:回应、转项目、关闭 buttons = [{ text: '回应' }, { text: '转项目' }, { text: '关闭' }] const that = this $wuxActionSheet().showSheet({ // titleText: '自定义操作', buttons: buttons, buttonClicked(index, item) { let state = "" const text = item.text // 议题状态:1 回应,2 关闭,4 转项目 if (item.text === "回应") { state = 1 } else if (item.text === "关闭") { state = 2 } else if (item.text === "转项目") { state = 4 } // else if (item.text === '转项目并吹哨') { // state = 6 // that.getIssueWhistlingDeptV2() // } const handleSubmitData = Object.assign(that.data.handleSubmitData, { state: state, text: text }) that.setData({ handleSubmitData }) return true }, cancelText: '取消', cancel() {}, }) }, // 填写意见 bindInputAdvice: function (e) { const handleSubmitData = Object.assign(this.data.handleSubmitData, { advice: e.detail.value }) this.setData({ handleSubmitData, isBlock: true,//失去焦点以后view隐藏 viewData: e.detail.value }) }, // Textarea的显示层级太高导致遮挡,通过点击view代替Textarea显示 clickTextarea() { this.setData({ isBlock: false, focus: true }) }, // 提交居民意见 bindFormSubmit() { if (this.data.handleSubmitData.state == 6) { const isSelect = this.data.whistlingDeptList.some(item => item.selected) if (!isSelect) { wx.showToast({ title: '吹哨部门不能为空', duration: 2000, icon: 'none' }) return false } } const deptResultDTOS = [] this.data.whistlingDeptList.forEach(item => { if (item.selected) { deptResultDTOS.push({ deptId: item.deptId, deptName: item.deptName, typeKey: item.typeKey }) } }) this.data.handleSubmitData = Object.assign(this.data.handleSubmitData, { deptResultDTOS: deptResultDTOS }) clearTimeout(this.data.timer) this.data.timer = setTimeout(() => { this.triggerEvent('bindFormSubmit', this.data.handleSubmitData) // 触发父组件事件 }, 500) }, // 上传图片 onChange(e) { // console.log('onChange', e) const { file } = e.detail if (file.status === 'uploading') { this.setData({ progress: 0, }) wx.showLoading() } else if (file.status === 'done') { this.setData({ imageUrl: file.url, }) } let images = [] e.detail.fileList.forEach((item, index, array) => { if (item.res !== undefined) { const imageUrl = JSON.parse(e.detail.fileList[index].res.data).data images.push(imageUrl) } }) const handleSubmitData = Object.assign(this.data.handleSubmitData, { images: images }) this.setData({ handleSubmitData }) }, onSuccess(e) { // console.log('onSuccess', e) }, onFail(e) { // console.log('onFail', e) }, // 上传完成 onComplete(e) { // console.log('onComplete', e) wx.hideLoading() }, // 点击图片放大 onPreview(e) { // console.log('onPreview', e) const { file, fileList } = e.detail wx.previewImage({ current: file.url, urls: fileList.map((n) => n.url), }) }, // 改变吹哨部门 onChangeDeptResultDTOS(e) { // console.log(e) let temp = 'whistlingDeptList[' + e.currentTarget.dataset.index + '].selected' this.setData({ [temp]: !e.currentTarget.dataset.item.selected }) }, // 获取可吹哨部门v2 getIssueWhistlingDeptV2 () { api.getIssueWhistlingDeptV2().then(res => { console.log(res.data); this.setData({ whistlingDeptList: res.data }) }); }, } })