微信小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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