微信小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

278 líneas
7.8 KiB

  1. // pages/bankDraft/add/add.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. showOrderType:false,
  12. showOrderStatus:false,
  13. form:{
  14. orderNum: "", //汇票号码 必填
  15. orderType: "", //汇票类型 必填
  16. orderAmount: "",//汇票金额 必填
  17. billPayUnit: "", //付票单位 必填
  18. billReceiveUnit: "", // 收票单位 必填
  19. startTime: "2020-01-01", //开票日期 必填
  20. endTime: "2020-01-01", //到期日期 必填
  21. orderStatus: "", //汇票状态 必填 1在库 2转付中 3转付 4承兑
  22. remark: "",
  23. },
  24. minDate: new Date(2020, 5, 1).getTime(),
  25. maxDate: new Date(2030, 0, 31).getTime(),
  26. orderStatusOptions:[],
  27. orderTypeOptions:[],
  28. showBtn:true,
  29. showStartTime:false,
  30. showEndTime:false,
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad(options) {
  36. console.log(options)
  37. if(options.id!=null&&options.id!=""){
  38. let that = this
  39. this.setData({id:options.id})
  40. UTIL.httpRequest(API.URL_GET_MONEYORDERDETAIL + this.data.id, {method:'GET'}, {
  41. success: (res) => {
  42. if(res.data.orderStatus!='1'){
  43. this.setData({'showBtn':false});
  44. }
  45. //汇票类型
  46. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_type', {method:'GET'}, {
  47. success: (rr) => {
  48. this.setData({
  49. orderTypeOptions:rr.data
  50. });
  51. this.data.orderTypeOptions.map(r => {
  52. if(r.dictValue == res.data.orderType){
  53. res.data.orderTypeText = r.dictLabel
  54. that.setData({'form':res.data});
  55. }
  56. })
  57. }
  58. })
  59. //汇票状态
  60. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_status', {method:'GET'}, {
  61. success: (rr) => {
  62. this.setData({
  63. orderStatusOptions:rr.data
  64. });
  65. this.data.orderStatusOptions.map(r => {
  66. if(r.dictValue == res.data.orderStatus){
  67. res.data.orderStatusText = r.dictLabel
  68. that.setData({'form':res.data});
  69. }
  70. })
  71. }
  72. })
  73. }
  74. })
  75. }else{
  76. this.onShow()
  77. }
  78. },
  79. onConfirmStartTime(e){
  80. let data = this.getNewDate(new Date(e.detail.value));
  81. this.setData({'form.startTime':data});
  82. },
  83. onConfirmEndTime(e){
  84. let data = this.getNewDate(new Date(e.detail.value));
  85. this.setData({'form.endTime':data});
  86. },
  87. getNewDate(date){
  88. //date是传过来的时间戳,注意需为13位,10位需*1000
  89. //也可以不传,获取的就是当前时间
  90. var time
  91. if(date){
  92. time = new Date(date);
  93. }else{
  94. time = new Date();
  95. }
  96. var year= time.getFullYear() //年
  97. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  98. var day = ("0" + time.getDate()).slice(-2); //日
  99. var mydate = year + "-" + month + "-" + day;
  100. return mydate
  101. },
  102. /**
  103. * 生命周期函数--监听页面初次渲染完成
  104. */
  105. onReady() {
  106. },
  107. /**
  108. * 生命周期函数--监听页面显示
  109. */
  110. onShow() {
  111. //汇票类型
  112. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_type', {method:'GET'}, {
  113. success: (res) => {
  114. this.setData({
  115. orderTypeOptions:res.data
  116. });
  117. }
  118. })
  119. //汇票状态
  120. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_status', {method:'GET'}, {
  121. success: (res) => {
  122. this.setData({
  123. orderStatusOptions:res.data
  124. });
  125. }
  126. })
  127. },
  128. openBox(even){
  129. console.log(even.currentTarget.dataset.name);
  130. this.setData({
  131. [even.currentTarget.dataset.name]:true
  132. })
  133. },
  134. onChange(event){
  135. console.log(event);
  136. this.setData({
  137. [event.currentTarget.dataset.value]: event.detail,
  138. })
  139. },
  140. closeBox(even){
  141. console.log(even.currentTarget.dataset.name);
  142. this.setData({
  143. [even.currentTarget.dataset.name]:false
  144. })
  145. },
  146. onConfirmOrderType(event) {
  147. this.setData({
  148. [event.currentTarget.dataset.name]: false,
  149. [event.currentTarget.dataset.value]: event.detail.value.dictValue,
  150. [event.currentTarget.dataset.value+'Text']: event.detail.value.dictLabel,
  151. });
  152. },
  153. goSubmit(){
  154. if(this.data.form.orderNum===''||this.data.form.orderNum==null){ //汇票号码
  155. UTIL.showToastNoneIcon('请填写汇票号码!');
  156. return false;
  157. }else if(this.data.form.orderType===''||this.data.form.orderType==null){ //汇票类型
  158. UTIL.showToastNoneIcon('汇票类型不能为空!');
  159. return false;
  160. }else if(this.data.form.orderAmount===''||this.data.form.orderAmount==null){ //出票金额
  161. UTIL.showToastNoneIcon('请输入出票金额!');
  162. return false;
  163. }else if(this.data.form.billPayUnit===''||this.data.form.billPayUnit==null){ //付飘单位
  164. UTIL.showToastNoneIcon('请输入付飘单位!');
  165. return false;
  166. }else if(this.data.form.billReceiveUnit === ''||this.data.form.billReceiveUnit==null){//收票单位
  167. UTIL.showToastNoneIcon('请输入收票单位!');
  168. return false;
  169. }else if(this.data.form.startTime === ''||this.data.form.startTime==null){//开票日期
  170. UTIL.showToastNoneIcon('请输入开票日期!');
  171. return false;
  172. }else if(this.data.form.endTime === ''||this.data.form.endTime==null){//到期日期
  173. UTIL.showToastNoneIcon('请输入到期日期!');
  174. return false;
  175. }else if(this.data.form.orderStatus === ''||this.data.form.orderStatus==null){//联行号
  176. UTIL.showToastNoneIcon('汇票状态不能为空!');
  177. return false;
  178. }else if(this.data.form.orderStatus === ''||this.data.form.orderStatus==null){//联行号
  179. UTIL.showToastNoneIcon('汇票状态不能为空!');
  180. return false;
  181. }else{
  182. var that = this;
  183. that.data.form.method = 'POST';
  184. if(that.data.form.id==""||that.data.form.id==null){
  185. UTIL.httpRequest(API.URL_POST_MONEYORDERADD, that.data.form , {
  186. success: (res) => {
  187. wx.showToast({
  188. title: '新增成功',
  189. icon: 'success',
  190. duration: 2000,
  191. complete(){
  192. setTimeout(function(){
  193. that.back();
  194. },2000)
  195. }
  196. })
  197. }
  198. })
  199. }else{
  200. UTIL.httpRequest(API.URL_POST_MONEYORDERUPDATE, that.data.form , {
  201. success: (res) => {
  202. wx.showToast({
  203. title: '修改成功',
  204. icon: 'success',
  205. duration: 2000,
  206. complete(){
  207. setTimeout(function(){
  208. that.back();
  209. },2000)
  210. }
  211. })
  212. }
  213. })
  214. }
  215. }
  216. },
  217. onConfirmTime(event){
  218. this.setData({
  219. [event.currentTarget.dataset.name]: false,
  220. [event.currentTarget.dataset.value]: UTIL.formatDate(event.detail),
  221. });
  222. },
  223. openBox(even){
  224. console.log(even.currentTarget.dataset.name);
  225. this.setData({
  226. [even.currentTarget.dataset.name]:true
  227. })
  228. },
  229. closeBox(even){
  230. console.log(even.currentTarget.dataset.name);
  231. this.setData({
  232. [even.currentTarget.dataset.name]:false
  233. })
  234. },
  235. back:function(){
  236. wx.navigateBack({
  237. delta: 1
  238. })
  239. },
  240. /**
  241. * 生命周期函数--监听页面隐藏
  242. */
  243. onHide() {
  244. },
  245. /**
  246. * 生命周期函数--监听页面卸载
  247. */
  248. onUnload() {
  249. },
  250. /**
  251. * 页面相关事件处理函数--监听用户下拉动作
  252. */
  253. onPullDownRefresh() {
  254. },
  255. /**
  256. * 页面上拉触底事件的处理函数
  257. */
  258. onReachBottom() {
  259. },
  260. /**
  261. * 用户点击右上角分享
  262. */
  263. onShareAppMessage() {
  264. }
  265. })