榆山
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

336 lines
8.9 KiB

// components/handleSubmit/handleSubmitItem.js
import {
$wuxActionSheet
} from '../../../../dist/index'
import {
BASEURL
} from '../../../../utils/config'
var api = require("../../../../api/itemDetail.js")
import {
$wuxToast
} from '../../../../dist/index'
Component({
/**
* 组件的属性列表
*/
properties: {
handleSubmitData: {
type: Object,
value: {}
},
itemId: {
type: String,
value: ""
}
},
/**
* 组件的初始数据
*/
data: {
BASEURL: BASEURL(),
// userTagKey: wx.getStorageSync('userTagKey'),
// userTagKey: "grid_party",
state: 0,
whistlingDeptList: [], // 可吹哨部门
evaluationDeptList: [], // 满意度评价部门
value: '1',
selectImage: "../../../../images/select.png",
selectNoImage: "../../../../images/selectNo.png",
isBlock: true,
focus: false,//默认没获取焦点
viewData: "",
_isBlock: true,
_focus: false,//默认没获取焦点
_viewData: ""
},
/**
* 组件的方法列表
*/
methods: {
// 处理操作
showActionSheet() {
// 用户标签key(district_party-区党委, district_dept-区直部门, street_party-街道党工委, street_dept-街道部门, community_party-社区党工委, grid_party-网格党支部)
// 处理结果:0 回应,1 吹哨,5 关闭,10 结案
let buttons = []
let userTagKey = wx.getStorageSync('userTagKey')
if (userTagKey === "grid_party") {
// 网格党支部:回应、吹哨、关闭、结案
buttons = [{
text: '回应'
}, {
text: '吹哨部门'
}, {
text: '关闭'
}, {
text: '结案'
}]
} else if (userTagKey === "street_party") {
// 街道党工委:回应、吹哨
buttons = [{
text: '回应'
}, {
text: '吹哨部门'
}]
} else if (userTagKey === "community_party" || userTagKey === "street_dept" || userTagKey === "district_dept" || userTagKey === "district_party") {
// 社区党工委、街道部门、区直部门、区党委:回应
buttons = [{
text: '回应'
}]
}
const that = this
$wuxActionSheet().showSheet({
// titleText: '自定义操作',
buttons: buttons,
buttonClicked(index, item) {
let state = ""
const text = item.text
// 项目状态:0 回应,1 吹哨,5 关闭,10 结案
if (item.text === "回应") {
state = 0
} else if (item.text === "吹哨部门") {
state = 1
that.getItemWhistlingDept() // 获取可吹哨部门
} else if (item.text === "关闭") {
state = 5
} else if (item.text === "结案") {
state = 10
that.getItemEvaluationDept() // 获取满意度评价部门
}
const handleSubmitData = Object.assign(that.data.handleSubmitData, {
state: state,
text: text
})
that.setData({
handleSubmitData,
state: state
})
return true
},
cancelText: '取消',
cancel() {},
})
},
// 回复居民意见
bindInputOutHandleAdvice: function (e) {
const handleSubmitData = Object.assign(this.data.handleSubmitData, {
outHandleAdvice: e.detail.value
})
this.setData({
handleSubmitData,
isBlock: true,
viewData: e.detail.value
})
},
// Textarea的显示层级太高导致遮挡,通过点击view代替Textarea显示
clickTextarea() {
this.setData({
isBlock: false,
focus: true
})
},
// 项目处理意见
bindInputHandleAdvice: function (e) {
const handleSubmitData = Object.assign(this.data.handleSubmitData, {
handleAdvice: e.detail.value
})
this.setData({
handleSubmitData,
_isBlock: true,
_viewData: e.detail.value
})
},
// Textarea的显示层级太高导致遮挡,通过点击view代替Textarea显示
_clickTextarea() {
this.setData({
_isBlock: false,
_focus: true
})
},
// 提交居民意见
bindFormSubmit() {
// 被吹哨部门
const deptResultDTOS = this.data.whistlingDeptList.filter(item => {
return item.selected === true
})
const handleSubmitData = Object.assign(this.data.handleSubmitData, {
deptResultDTOS: deptResultDTOS
})
this.setData({
handleSubmitData
})
if (this.data.handleSubmitData.state == "10"){//结案
if (this.data.evaluationDeptList.length > 0){//满意度评价有值
if (!this.data.handleSubmitData.evaluateDeptDTOS){ //没有选满意度
$wuxToast().show({
type: 'text',
duration: 3000,
color: '#fff',
text: '请选择满意度评价',
success: () => console.log('')
})
return false
}
}
}
this.triggerEvent('bindFormSubmit', this.data.handleSubmitData) // 触发父组件事件
},
// 上传图片
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)
}
})
let handleSubmitData = {}
if (e.currentTarget.dataset.type == "outHandleImages") {
// 回复居民意见
handleSubmitData = Object.assign(this.data.handleSubmitData, {
outHandleImages: images
})
} else if (e.currentTarget.dataset.type == "handleImages") {
// 项目处理意见
handleSubmitData = Object.assign(this.data.handleSubmitData, {
handleImages: images
})
}
this.setData({
handleSubmitData
})
},
// 上传完成
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),
})
},
// 获取可吹哨部门
getItemWhistlingDept() {
api.getItemWhistlingDept().then(res => {
console.log(res.data);
this.setData({
whistlingDeptList: res.data
})
});
},
// 获取满意度评价部门
getItemEvaluationDept() {
api.getItemEvaluationDept(this.data.itemId).then(res => {
console.log(res.data);
this.setData({
evaluationDeptList: res.data
// evaluationDeptList: [{
// deptId: 1,
// deptName: '九江社区党工委'
// },
// {
// deptId: 2,
// deptName: '九江街道党工委'
// }
// ]
})
});
},
// 改变吹哨部门
onChangeDeptResultDTOS(e) {
// console.log(e)
let temp = 'whistlingDeptList[' + e.currentTarget.dataset.index + '].selected'
this.setData({
[temp]: !e.currentTarget.dataset.item.selected
})
},
// 评价结果:0-不满意,1-基本满意,2-非常满意
showActionSheetEvaluate(e) {
const that = this
$wuxActionSheet().showSheet({
// titleText: '自定义操作',
buttons: [{
text: '非常满意'
},
{
text: '基本满意'
},
{
text: '不满意'
}
],
buttonClicked(index, item) {
let state = ""
const text = item.text
if (item.text === "非常满意") {
state = 2
} else if (item.text === "基本满意") {
state = 1
} else if (item.text === "不满意") {
state = 0
}
let temp = 'evaluationDeptList[' + e.currentTarget.dataset.index + '].evaluationLevel'
let tempName = 'evaluationDeptList[' + e.currentTarget.dataset.index + '].evaluationLevelName'
that.setData({
[temp]: state,
[tempName]: text
})
const handleSubmitData = Object.assign(that.data.handleSubmitData, {
evaluateDeptDTOS: that.data.evaluationDeptList
})
that.setData({
handleSubmitData
})
return true
},
cancelText: '取消',
cancel() {},
})
},
}
})