锦水居民端小程序
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.

359 lines
8.9 KiB

// subpages/heart/pages/myApply/myApply.js
const api = require("../../../../utils/api")
Page({
/**
* 页面的初始数据
*/
data: {
dataForm: {},
violationsCount: 0, //内容审核计数
isConReview: false, //内容审核标志
lock: false, //锁定发布按钮状态,防止连击
treeList: [
// {
// label: '长江路党工委',
// value: '1234085031077498881',
// children: [
// {
// label: '长江路党工委1',
// value: '1234085031077498882',
// },
// {
// label: '长江路党工委2',
// value: '1234085031077498883',
// },
// ],
// },
],
treeChoosedValue: {
title: '请选择',
id: '',
},
treeVlaue: [],
treeId: '',
yearsList: [],
yearChoosedValue: {
label: '请选择年度',
value: '',
},
yearValue: [], //
yearId: '',
yearPickerVisible: false,
quarterList: [],
quarterChoosedValue: {
label: '请选择季度',
value: '',
},
quarterValue: [], //
quarterId: '',
quarterPickerVisible: false,
companyList: [],
companyChoosedValue: {
label: '请选择公司状态',
value: '',
},
companyValue: [], //
companyId: '',
companyPickerVisible: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getGridTree()
this.getYearsList()
this.getFullDictInfo()
},
getGridTree () {
api.getGridTree().then(res => {
this.setData({
treeList: res.data.options
})
})
},
getYearsList (smallYears = 1970) {
let nowYears = new Date().getFullYear()
let Years = nowYears - smallYears
let arrYear = []
let yearsList = []
for (let i = 0; i <= Years; i++) {
arrYear.push(nowYears--)
}
arrYear.forEach(ele => {
yearsList.push({
value: ele.toString(),
label: ele + '年'
})
})
this.setData({
yearsList
})
},
// 获取字典 -
getFullDictInfo () {
api.getFullDictInfo('enterprise_quarter').then(res => {
if (res.code == 0 && res.msg == 'success') {
let quarterList = []
res.data.forEach(item => {
let ob = {
label: item.dictName,
value: item.dictValue
}
quarterList.push(ob)
})
this.setData({
quarterList
})
}
}).catch(err => {
console.log(err)
})
api.getFullDictInfo('enterprise_status').then(res => {
if (res.code == 0 && res.msg == 'success') {
let companyList = []
res.data.forEach(item => {
let ob = {
label: item.dictName,
value: item.dictValue
}
companyList.push(ob)
})
this.setData({
companyList
})
}
}).catch(err => {
console.log(err)
})
},
// 选择所属网格
chooseTreeId(e) {
this.setData({
treeVlaue: e.detail.value,
'treeChoosedValue.title': e.detail.options
.map((n) => n.label)
.join('/'),
// deptId: e.detail.value[e.detail.value.length - 1],
treeId: e.detail.value[e.detail.value.length - 1],
'dataForm.gridId': e.detail.value[e.detail.value.length - 1]
})
},
// 所属年度 start
onShowYearPicker() {
this.setData({
yearPickerVisible: true,
})
},
onCancelYearPicker() {
this.setData({
yearPickerVisible: false,
})
},
onConfirmYearPicker(e) {
console.log(e.detail)
this.setData({
yearPickerVisible: false,
yearValue: e.detail.value,
'yearChoosedValue.label': e.detail.label,
'yearChoosedValue.value': e.detail.value[0],
yearId: e.detail.value[0],
'dataForm.year': e.detail.value[0]
})
},
// 所属年度 end
// 所属季度 start
onShowQuarterPicker() {
this.setData({
quarterPickerVisible: true,
})
},
onCancelQuarterPicker() {
this.setData({
quarterPickerVisible: false,
})
},
onConfirmQuarterPicker(e) {
console.log(e.detail)
this.setData({
quarterPickerVisible: false,
quarterValue: e.detail.value,
'quarterChoosedValue.label': e.detail.label,
'quarterChoosedValue.value': e.detail.value[0],
quarterId: e.detail.value[0],
'dataForm.quarter': e.detail.value[0]
})
},
// 所属季度 end
// 公司经营状态 start
onShowCompanyPicker() {
this.setData({
companyPickerVisible: true,
})
},
onCancelCompanyPicker() {
this.setData({
companyPickerVisible: false,
})
},
onConfirmCompanyPicker(e) {
console.log(e.detail)
this.setData({
companyPickerVisible: false,
companyValue: e.detail.value,
'companyChoosedValue.label': e.detail.label,
'companyChoosedValue.value': e.detail.value[0],
companyId: e.detail.value[0],
'dataForm.enterpriseStatus': e.detail.value[0]
})
},
// 公司经营状态 end
onInputValue (e) {
let key = e.currentTarget.dataset.code
this.data.dataForm[key] = e.detail.value
this.setData({
dataForm: this.data.dataForm
})
},
//提交申请
submitApply () {
if (this.data.lock) {
return false
}
if (!this.data.dataForm.gridId) {
this.showToast("请选择所属网格")
return false
}
if (!this.data.dataForm.year) {
this.showToast("请选择年度")
return false
}
if (!this.data.dataForm.quarter) {
this.showToast("请选择季度")
return false
}
if (!this.data.dataForm.enterpriseName || !this.data.dataForm.enterpriseName.trim('')) {
this.showToast("请填写公司名称")
return false
}
if (this.data.dataForm.enterpriseName.length > 100) {
this.showToast("公司名称不能超过100个字")
return
}
if (!this.data.dataForm.legalPerson || !this.data.dataForm.legalPerson.trim('')) {
this.showToast("请填写法人或联系人")
return false
}
if (this.data.dataForm.legalPerson.length > 20) {
this.showToast("法人姓名不能超过20个字")
return
}
if (!this.data.dataForm.concat || !this.data.dataForm.concat.trim('')) {
this.showToast("请填写联系电话")
return false
}
if (this.data.dataForm.concat.length > 20) {
this.showToast("请输入正确的联系电话")
return
}
if (!this.data.dataForm.enterpriseStatus) {
this.showToast("请选择公司状态")
return false
}
if (!this.data.dataForm.enterpriseIncome) {
this.data.dataForm.enterpriseIncome = '0'
}
if (!this.data.dataForm.enterprisePeopleNum) {
this.data.dataForm.enterprisePeopleNum = '0'
}
if (!this.data.dataForm.question) {
this.data.dataForm.question = '无'
}
wx.showLoading({
title: "加载中",
})
this.setData({
lock: true
})
const para = { ...this.data.dataForm }
// para.isConReview = this.data.isConReview
console.log('submit apply', para)
let that = this
api.addEnterpriseReport(para).then(res => {
wx.hideLoading()
this.setData({
lock: false
})
if(res.code == 0) {
this.setData({
dialogVisible: !this.data.dialogVisible,
'dataForm.gridId': '',
violationsCount: 0,
isConReview: false
})
} else if (res.code == 533) {
this.data.violationsCount++
console.log(this.data.violationsCount)
if (this.data.violationsCount == 1){
wx.showToast({
title: res.msg,
icon: "none",
duration: 2000
})
} else if (this.data.violationsCount == 2) {
wx.showModal({
title: '提示',
content: '您提交的内容再次被判定为违规,您确定是否要提交?',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
that.data.isConReview = true
that.submitApply()
} else if (res.cancel) {
console.log('用户点击取消')
that.setData({
violationsCount: 0,
isConReview: false
})
}
}
})
}
}
}).catch(err => {
console.log('err',err)
wx.hideLoading()
this.setData({
lock: false
})
})
},
//简化提示
showToast (title) {
wx.showToast({
title: title,
icon: "none",
duration: 2000
})
},
//跳转到我填报的列表
toApplyList () {
wx.navigateTo({
url: "/subpages/oneKeyService/pages/companyInformationList/companyInformationList"
})
},
// 关闭弹框
closeDialog () {
wx.navigateBack()
},
// 弹框确定按钮
confirmDialog () {
wx.navigateBack()
}
})