minusapply.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. // pages/minusapply/minusapply.js
  2. var BASEURL = require('../../utils/wxconstant.js')
  3. var baseUrl = BASEURL.BaseUrl()
  4. var baseutils = require('../../utils/baseUtils.js')
  5. var netUtil = require('../../utils/network.js')
  6. var dateutil = require('../../utils/DateTime.js')
  7. var myInfoData = wx.getStorageSync('myInfoData')
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. isDetails: false, //减分申请详情时状态
  14. minusPerson:'', //扣分人
  15. minusTime:'', //日期
  16. minusName:'', //被扣人
  17. minusPoints:'', //扣得积分
  18. minusNorm:'请选择',
  19. itemPerson:{},
  20. itemNorm: { normItem: '请选择', normScore:'' },//所选规则数据
  21. CotegoryArray: [],
  22. Cotegory: [],
  23. detailsData: {},
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. var that = this
  30. var isDetails = options.getisDetails
  31. var itemdata
  32. if (options.getItemdata) {
  33. itemdata = JSON.parse(options.getItemdata)
  34. that.setData({
  35. isDetails: isDetails
  36. })
  37. }
  38. console.log('itemdata', itemdata)
  39. that.initView(itemdata)
  40. },
  41. minusSubmit: function (event){
  42. var that = this
  43. var object = event.detail.value
  44. console.log(object)
  45. var minusName = object.minusName
  46. var minusPoints = object.minusPoints
  47. var minusReason = object.minusReason
  48. var itemNorm = that.data.itemNorm
  49. var itemPerson = that.data.itemPerson
  50. if (!minusName) {
  51. that.comToast('请选择被扣人')
  52. return
  53. }
  54. if (!minusPoints) {
  55. that.comToast('请选择扣分标准')
  56. return
  57. }
  58. if (!minusReason) {
  59. that.comToast('请输入扣分原由')
  60. return
  61. }
  62. var data = {
  63. openid: wx.getStorageSync('openid'),
  64. reasons: minusReason,
  65. normId: itemNorm.normId,
  66. adviceId: itemPerson.empId
  67. }
  68. var url = baseUrl + BASEURL.getUrl.saveMinusInvoices
  69. netUtil.requestLoading(url, data, '正在加载数据...', 'POST', function (res) {
  70. if (res.data.success) {
  71. that.comToast("提交成功")
  72. setTimeout(function () {
  73. wx.navigateBack({
  74. })
  75. }, 1000)
  76. }
  77. }, function (res) {
  78. wx.showToast({
  79. title: '加载数据失败',
  80. icon: 'none',
  81. duration: 2000
  82. })
  83. })
  84. },
  85. getCotegory: function () {
  86. var that = this
  87. var data = { parentId: 0 }
  88. var url = baseUrl + BASEURL.getUrl.getCotegory
  89. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  90. if (res.data.success && res.data.data) {
  91. that.setData({
  92. Cotegory: res.data.data
  93. })
  94. var array = []
  95. for (var i = 0; i < res.data.data.length; i++) {
  96. array[i] = res.data.data[i].categoryName
  97. if (i == res.data.data.length - 1) {
  98. console.log('array', array)
  99. that.setData({
  100. CotegoryArray: array
  101. })
  102. }
  103. }
  104. }
  105. }, function (res) {
  106. wx.showToast({
  107. title: '加载数据失败',
  108. icon: 'none',
  109. duration: 2000
  110. })
  111. })
  112. },
  113. bindPickerChange: function (e) {
  114. var that = this
  115. console.log('picker发送选择改变,携带值为', e.detail)
  116. var categoryId = that.data.Cotegory[e.detail.value].categoryId
  117. if (categoryId) {
  118. wx.navigateTo({
  119. url: '../selectnorm/selectnorm' + '?getcategoryId=' + categoryId+'&getAddType='+false,
  120. })
  121. }
  122. },
  123. /**
  124. *修改Title
  125. */
  126. changeTitle: function () {
  127. var that = this;
  128. var isDetails = that.data.isDetails
  129. var title
  130. if (isDetails) {
  131. title = '减分详情'
  132. } else {
  133. title = '减分申请'
  134. }
  135. that.setData({
  136. mername: title
  137. })
  138. wx.setNavigationBarTitle({
  139. title: that.data.mername
  140. })
  141. },
  142. /**
  143. * 根据invoicesId 获取加分单据详情数据
  144. */
  145. initDetailsView: function (invoicesId) {
  146. var that = this
  147. var data = { invoicesId: invoicesId }
  148. var url = baseUrl + BASEURL.getUrl.getInvoices
  149. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  150. if (res.data.success && res.data.data) {
  151. that.setData({
  152. detailsData: res.data.data,
  153. minusTime: res.data.data.invoicesDate,
  154. minusName: res.data.data.adviceName,
  155. minusNorm: res.data.data.normName,
  156. minusPoints: res.data.data.score,
  157. minusReason: res.data.data.reasons,
  158. minusPerson: res.data.data.fillName
  159. // applyJob: res.data.data.fillStation
  160. })
  161. }
  162. }, function (res) {
  163. wx.showToast({
  164. title: '加载数据失败',
  165. icon: 'none',
  166. duration: 2000
  167. })
  168. })
  169. },
  170. initView: function (itemdata) {
  171. var that = this;
  172. var isDetails = that.data.isDetails
  173. var title
  174. if (isDetails) {
  175. title = '减分详情'
  176. title = '减分申请详情'
  177. if (itemdata && itemdata.invoicesId) {
  178. // var invoicesStatus = itemdata.invoicesStatus
  179. // var applyStatus
  180. // if (invoicesStatus == 0) {
  181. // applyStatus = '待审批'
  182. // } else if (invoicesStatus == 1) {
  183. // applyStatus = '已审批'
  184. // } else {
  185. // applyStatus = '未通过'
  186. // }
  187. // that.setData({
  188. // applyStatus: applyStatus,
  189. // invoicesStatus: invoicesStatus,
  190. // })
  191. that.initDetailsView(itemdata.invoicesId)
  192. }
  193. } else {
  194. title = '减分申请'
  195. var nowTime = dateutil.getComDate(new Date, 'yy-mm-dd')
  196. that.setData({
  197. minusTime: nowTime
  198. })
  199. that.getCotegory()//获得分类列表
  200. }
  201. wx.setNavigationBarTitle({
  202. title: title
  203. })
  204. // console.log('nowTime', nowTime)
  205. },
  206. comToast: function (title) {
  207. wx.showToast({
  208. title: title,
  209. icon: 'none',
  210. duration: 2000
  211. })
  212. },
  213. /**
  214. * 选择被扣人对象
  215. */
  216. selctMinusPerson:function(){
  217. if (!this.data.isDetails){
  218. wx.navigateTo({
  219. url: '../selectStaff/selectStaff',
  220. })
  221. }
  222. // return
  223. // var that = this
  224. // var data = { }
  225. // var url = baseUrl + BASEURL.getUrl.getAllEmp
  226. // netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  227. // }, function (res) {
  228. // wx.showToast({
  229. // title: '加载数据失败',
  230. // icon: 'none',
  231. // duration: 2000
  232. // })
  233. // })
  234. },
  235. /**
  236. * 生命周期函数--监听页面初次渲染完成
  237. */
  238. onReady: function () {
  239. },
  240. /**
  241. * 生命周期函数--监听页面显示
  242. */
  243. onShow: function () {
  244. var that = this
  245. if (that.data.itemPerson){
  246. that.setData({
  247. minusName: that.data.itemPerson.empName
  248. })
  249. }
  250. if (that.data.itemNorm){
  251. that.setData({
  252. minusNorm: that.data.itemNorm.normItem,
  253. minusPoints: that.data.itemNorm.normScore
  254. })
  255. }
  256. },
  257. /**
  258. * 生命周期函数--监听页面隐藏
  259. */
  260. onHide: function () {
  261. },
  262. /**
  263. * 生命周期函数--监听页面卸载
  264. */
  265. onUnload: function () {
  266. },
  267. /**
  268. * 页面相关事件处理函数--监听用户下拉动作
  269. */
  270. onPullDownRefresh: function () {
  271. },
  272. /**
  273. * 页面上拉触底事件的处理函数
  274. */
  275. onReachBottom: function () {
  276. },
  277. /**
  278. * 用户点击右上角分享
  279. */
  280. onShareAppMessage: function () {
  281. }
  282. })