| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- // pages/pointapply/pointapply.js
- var BASEURL = require('../../utils/wxconstant.js')
- var baseUrl = BASEURL.BaseUrl()
- var baseutils = require('../../utils/baseUtils.js')
- var netUtil = require('../../utils/network.js')
- var dateutil = require('../../utils/DateTime.js')
- var myInfoData = wx.getStorageSync('myInfoData')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- applyJob:'',
- applyName:'',
- applyStatus:'',
- applyTime:'',
- addPoints:'',
- itemNorm: { normItem: '请选择', normScore:'' },//所选规则数据
- applyReason:'',
- CotegoryArray:[],
- Cotegory:[],
- invoicesStatus: 1,//单据状态1:待审批,2:已审批,3:不同意?
- isDetails: false, //加分申请详情时状态
- applyNorm:'',
- detailsData:{} ,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this
- var isDetails = options.getisDetails
- var itemdata
- if (options.getItemdata){
- itemdata = JSON.parse(options.getItemdata)
- that.setData({
- isDetails: isDetails
- })
- }
- console.log('itemdata', itemdata)
- that.initView(itemdata) //修改标题
- // that.getDept()//获取公司部门列表
- },
- bindPickerChange: function (e) {
- var that = this
- console.log('picker发送选择改变,携带值为', e.detail)
- var categoryId = that.data.Cotegory[e.detail.value].categoryId
- if (categoryId){
- wx.navigateTo({
- url: '../selectnorm/selectnorm' + '?getcategoryId=' + categoryId + '&getAddType=' + true,
- })
- }
- },
- getDept:function(){
- var that = this
- var data = { parentId:0}
- var url = baseUrl + BASEURL.getUrl.getDept
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- getCotegory:function(){
- var that = this
- var data = { parentId: 0 }
- var url = baseUrl + BASEURL.getUrl.getCotegory
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if(res.data.success && res.data.data){
- that.setData({
- Cotegory:res.data.data
- })
- var array = []
- for (var i = 0; i < res.data.data.length; i++){
- array[i] = res.data.data[i].categoryName
- if (i == res.data.data.length-1){
- console.log('array', array)
- that.setData({
- CotegoryArray:array
- })
- }
- }
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- initView: function (itemdata){
- var that = this;
- var isDetails = that.data.isDetails
- var title
- if (isDetails) {
- title = '加分申请详情'
- if (itemdata && itemdata.invoicesId){
- var invoicesStatus = itemdata.invoicesStatus
- var applyStatus
- if (invoicesStatus == 1){
- applyStatus = '待审批'
- } else if (invoicesStatus == 2){
- applyStatus = '已审批'
- }else{
- applyStatus = '未通过'
- }
- that.setData({
- applyStatus: applyStatus,
- invoicesStatus: invoicesStatus,
- })
- that.initDetailsView(itemdata.invoicesId)
- }
- } else {
- that.getCotegory()//获得分类列表
- title = '积分申请'
- that.setData({
- applyJob: myInfoData.station,
- applyName: myInfoData.empName
- })
- }
- that.setData({
- mername: title
- })
- wx.setNavigationBarTitle({
- title: that.data.mername
- })
- var nowTime = dateutil.getComDate(new Date,'yy-mm-dd')
- that.setData({
- applyTime: nowTime
- })
- // console.log('nowTime', nowTime)
- },
- /**
- * 提交申请
- */
- applySubmit: function (event) {
- var that = this
- var object = event.detail.value
- console.log(object)
- var applyName = object.applyName
- var applyJob = object.applyJob
- var itemNorm = that.data.itemNorm
- var applyReason = object.applyReason
- var applyName = object.applyName
- if (!itemNorm.normId) {
- that.comToast('请选择申请标准')
- return
- }
- if (!applyReason){
- that.comToast('请输入申请事由')
- return
- }
- var data = {
- openid: wx.getStorageSync('openid'),
- reasons: applyReason,
- normId: itemNorm.normId
- }
- var url = baseUrl + BASEURL.getUrl.saveAddInvoices
- netUtil.requestLoading(url, data, '正在加载数据...', 'POST', function (res) {
- if(res.data.success){
- that.comToast("提交成功")
- setTimeout(function(){
- wx.navigateBack({
- })
- },1000)
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- comToast: function (title) {
- wx.showToast({
- title: title,
- icon: 'none',
- duration: 2000
- })
- },
- /**
- * 根据invoicesId 获取加分单据详情数据
- */
- initDetailsView: function (invoicesId){
- var that =this
- var data = { invoicesId: invoicesId}
- var url = baseUrl + BASEURL.getUrl.getInvoices
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if (res.data.success && res.data.data){
- that.setData({
- detailsData: res.data.data,
- applyTime: res.data.data.invoicesDate,
- applyName: res.data.data.fillName,
- applyNorm: res.data.data.normName,
- applyReason: res.data.data.reasons,
- applyJob: res.data.data.fillStation,
- addPoints: res.data.data.score
- })
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- /**
- * 撤回 : 目前做的是删除单据操作
- */
- cancelApply:function(){
- var that = this
- var data = { invoicesId: that.data.detailsData.invoicesId }
- var url = baseUrl + BASEURL.getUrl.withdrawInvoices
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if(res.data.success && res.data.data){
- that.comToast(res.data.data)
- setTimeout(function () {
- wx.navigateBack({
- })
- }, 1000)
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- var that = this
- that.setData({
- applyNorm:that.data.itemNorm.normItem,
- addPoints: that.data.itemNorm.normScore
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|