微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

add.js 8.1 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. orderStatusOptions:[],
  25. orderTypeOptions:[],
  26. showBtn:true,
  27. showStartTime:false,
  28. showEndTime:false,
  29. status:0,
  30. orderTypeindex:0,
  31. orderStatusindex:0
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad(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. 'form.orderType':res.data[0].dictValue
  117. });
  118. }
  119. })
  120. //汇票状态
  121. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_status', {method:'GET'}, {
  122. success: (res) => {
  123. this.setData({
  124. orderStatusOptions:res.data,
  125. 'form.orderStatus':res.data[0].dictValue
  126. });
  127. }
  128. })
  129. },
  130. openBox(even){
  131. console.log(even.currentTarget.dataset.name);
  132. this.setData({
  133. [even.currentTarget.dataset.name]:true
  134. })
  135. },
  136. onChange(event){
  137. console.log(event);
  138. this.setData({
  139. [event.currentTarget.dataset.value]: event.detail,
  140. })
  141. },
  142. closeBox(even){
  143. console.log(even.currentTarget.dataset.name);
  144. this.setData({
  145. [even.currentTarget.dataset.name]:false
  146. })
  147. },
  148. onConfirmorderType (e) {
  149. let obj = e.detail.value;
  150. this.setData({
  151. 'form.orderType':this.data.orderTypeOptions[obj].dictValue,
  152. 'orderTypeindex':obj
  153. })
  154. },
  155. onConfirmorderStatus (e) {
  156. let obj = e.detail.value;
  157. this.setData({
  158. 'form.orderStatus':this.data.orderStatusOptions[obj].dictValue,
  159. 'orderStatusindex':obj
  160. })
  161. },
  162. goSubmit(){
  163. if(this.data.form.orderNum===''||this.data.form.orderNum==null){ //汇票号码
  164. UTIL.showToastNoneIcon('请填写汇票号码!');
  165. return false;
  166. }else if(this.data.form.orderType===''||this.data.form.orderType==null){ //汇票类型
  167. UTIL.showToastNoneIcon('汇票类型不能为空!');
  168. return false;
  169. }else if(this.data.form.orderAmount===''||this.data.form.orderAmount==null){ //出票金额
  170. UTIL.showToastNoneIcon('请输入出票金额!');
  171. return false;
  172. }else if(this.data.form.billPayUnit===''||this.data.form.billPayUnit==null){ //付票单位
  173. UTIL.showToastNoneIcon('请输入付票单位!');
  174. return false;
  175. }else if(this.data.form.billReceiveUnit === ''||this.data.form.billReceiveUnit==null){//收票单位
  176. UTIL.showToastNoneIcon('请输入收票单位!');
  177. return false;
  178. }else if(this.data.form.startTime === ''||this.data.form.startTime==null){//开票日期
  179. UTIL.showToastNoneIcon('请输入开票日期!');
  180. return false;
  181. }else if(this.data.form.endTime === ''||this.data.form.endTime==null){//到期日期
  182. UTIL.showToastNoneIcon('请输入到期日期!');
  183. return false;
  184. }else if(this.data.form.orderStatus === ''||this.data.form.orderStatus==null){//联行号
  185. UTIL.showToastNoneIcon('联行号不能为空!');
  186. return false;
  187. }else if(this.data.form.orderStatus === ''||this.data.form.orderStatus==null){//联行号
  188. UTIL.showToastNoneIcon('联行号不能为空!');
  189. return false;
  190. }else if(this.data.status=='0'){
  191. this.setData({'status':'1'})
  192. var that = this;
  193. that.data.form.method = 'POST';
  194. if(that.data.form.id==""||that.data.form.id==null){
  195. UTIL.httpRequest(API.URL_POST_MONEYORDERADD, that.data.form , {
  196. success: (res) => {
  197. this.setData({'status':0})
  198. if(res.code == 200){
  199. UTIL.showToastNoneIcon('新增成功');
  200. setTimeout(function(){
  201. wx.navigateBack({
  202. delta:1
  203. })
  204. },2000)
  205. }else{
  206. UTIL.showToastNoneIcon('新增失败');
  207. }
  208. }
  209. })
  210. }else{
  211. UTIL.httpRequest(API.URL_POST_MONEYORDERUPDATE, that.data.form , {
  212. success: (res) => {
  213. this.setData({'status':0})
  214. if(res.code == 200){
  215. UTIL.showToastNoneIcon('修改成功');
  216. setTimeout(function(){
  217. wx.navigateBack({
  218. delta:1
  219. })
  220. },2000)
  221. }else{
  222. UTIL.showToastNoneIcon('修改失败');
  223. }
  224. }
  225. })
  226. }
  227. }
  228. },
  229. onConfirmTime(event){
  230. this.setData({
  231. [event.currentTarget.dataset.name]: false,
  232. [event.currentTarget.dataset.value]: UTIL.formatDate(event.detail),
  233. });
  234. },
  235. openBox(even){
  236. console.log(even.currentTarget.dataset.name);
  237. this.setData({
  238. [even.currentTarget.dataset.name]:true
  239. })
  240. },
  241. closeBox(even){
  242. console.log(even.currentTarget.dataset.name);
  243. this.setData({
  244. [even.currentTarget.dataset.name]:false
  245. })
  246. },
  247. back:function(){
  248. wx.navigateBack({
  249. delta: 1
  250. })
  251. },
  252. /**
  253. * 生命周期函数--监听页面隐藏
  254. */
  255. onHide() {
  256. },
  257. /**
  258. * 生命周期函数--监听页面卸载
  259. */
  260. onUnload() {
  261. },
  262. /**
  263. * 页面相关事件处理函数--监听用户下拉动作
  264. */
  265. onPullDownRefresh() {
  266. },
  267. /**
  268. * 页面上拉触底事件的处理函数
  269. */
  270. onReachBottom() {
  271. },
  272. /**
  273. * 用户点击右上角分享
  274. */
  275. onShareAppMessage() {
  276. }
  277. })