123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- // pages/minusapply/minusapply.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: {
- isDetails: false, //减分申请详情时状态
- minusPerson:'', //扣分人
- minusTime:'', //日期
- minusName:'', //被扣人
- minusPoints:'', //扣得积分
- minusNorm:'请选择',
- itemPerson:{},
- itemNorm: { normItem: '请选择', normScore:'' },//所选规则数据
- CotegoryArray: [],
- Cotegory: [],
- 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)
- },
- minusSubmit: function (event){
- var that = this
- var object = event.detail.value
- console.log(object)
- var minusName = object.minusName
- var minusPoints = object.minusPoints
- var minusReason = object.minusReason
- var itemNorm = that.data.itemNorm
- var itemPerson = that.data.itemPerson
- if (!minusName) {
- that.comToast('请选择被扣人')
- return
- }
- if (!minusPoints) {
- that.comToast('请选择扣分标准')
- return
- }
- if (!minusReason) {
- that.comToast('请输入扣分原由')
- return
- }
- var data = {
- openid: wx.getStorageSync('openid'),
- reasons: minusReason,
- normId: itemNorm.normId,
- adviceId: itemPerson.empId
- }
- var url = baseUrl + BASEURL.getUrl.saveMinusInvoices
- 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
- })
- })
- },
- 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
- })
- })
- },
- 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='+false,
- })
- }
- },
- /**
- *修改Title
- */
- changeTitle: function () {
- var that = this;
- var isDetails = that.data.isDetails
- var title
- if (isDetails) {
- title = '减分详情'
- } else {
- title = '减分申请'
- }
- that.setData({
- mername: title
- })
- wx.setNavigationBarTitle({
- title: that.data.mername
- })
- },
- /**
- * 根据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,
- minusTime: res.data.data.invoicesDate,
- minusName: res.data.data.adviceName,
- minusNorm: res.data.data.normName,
- minusPoints: res.data.data.score,
- minusReason: res.data.data.reasons,
- minusPerson: res.data.data.fillName
- // applyJob: res.data.data.fillStation
- })
- }
- }, 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 = '减分详情'
- title = '减分申请详情'
- if (itemdata && itemdata.invoicesId) {
- // var invoicesStatus = itemdata.invoicesStatus
- // var applyStatus
- // if (invoicesStatus == 0) {
- // applyStatus = '待审批'
- // } else if (invoicesStatus == 1) {
- // applyStatus = '已审批'
- // } else {
- // applyStatus = '未通过'
- // }
- // that.setData({
- // applyStatus: applyStatus,
- // invoicesStatus: invoicesStatus,
- // })
- that.initDetailsView(itemdata.invoicesId)
- }
- } else {
- title = '减分申请'
- var nowTime = dateutil.getComDate(new Date, 'yy-mm-dd')
- that.setData({
- minusTime: nowTime
- })
- that.getCotegory()//获得分类列表
- }
- wx.setNavigationBarTitle({
- title: title
- })
-
- // console.log('nowTime', nowTime)
- },
- comToast: function (title) {
- wx.showToast({
- title: title,
- icon: 'none',
- duration: 2000
- })
- },
- /**
- * 选择被扣人对象
- */
- selctMinusPerson:function(){
- if (!this.data.isDetails){
- wx.navigateTo({
- url: '../selectStaff/selectStaff',
- })
- }
- // return
- // var that = this
- // var data = { }
- // var url = baseUrl + BASEURL.getUrl.getAllEmp
- // netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- // }, function (res) {
- // wx.showToast({
- // title: '加载数据失败',
- // icon: 'none',
- // duration: 2000
- // })
- // })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- var that = this
- if (that.data.itemPerson){
- that.setData({
- minusName: that.data.itemPerson.empName
- })
- }
- if (that.data.itemNorm){
- that.setData({
- minusNorm: that.data.itemNorm.normItem,
- minusPoints: that.data.itemNorm.normScore
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|