微信小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

add.js 9.0 KiB

3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. orderTypeindex:0,
  32. orderStatusindex:0,
  33. status:0,
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad(options) {
  39. if(options.id!=null&&options.id!=""){
  40. let that = this
  41. this.setData({id:options.id})
  42. UTIL.httpRequest(API.URL_GET_MONEYORDERDETAIL + this.data.id, {method:'GET'}, {
  43. success: (res) => {
  44. if(res.data.orderStatus!='1'){
  45. this.setData({'showBtn':false});
  46. }
  47. this.setData({'form':res.data})
  48. //汇票类型
  49. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_type', {method:'GET'}, {
  50. success: (r) => {
  51. if(r.data.length>0){
  52. that.setData({
  53. orderTypeOptions:r.data,
  54. })
  55. r.data.map((rr,ind) => {
  56. if(rr.dictValue == res.data.orderType){
  57. that.setData({'orderTypeindex':ind})
  58. }
  59. })
  60. }
  61. }
  62. })
  63. //汇票状态
  64. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_status', {method:'GET'}, {
  65. success: (r) => {
  66. if(r.data.length>0){
  67. that.setData({
  68. orderStatusOptions:r.data,
  69. })
  70. r.data.map((rr,ind) => {
  71. if(rr.dictValue == res.data.orderStatus){
  72. that.setData({'orderStatusindex':ind})
  73. }
  74. })
  75. }
  76. }
  77. })
  78. }
  79. })
  80. }else{
  81. this.onShow()
  82. }
  83. },
  84. onConfirmStartTime(e){
  85. let data = this.getNewDate(new Date(e.detail.value));
  86. this.setData({'form.startTime':data});
  87. },
  88. onConfirmEndTime(e){
  89. let data = this.getNewDate(new Date(e.detail.value));
  90. this.setData({'form.endTime':data});
  91. },
  92. getNewDate(date){
  93. //date是传过来的时间戳,注意需为13位,10位需*1000
  94. //也可以不传,获取的就是当前时间
  95. var time
  96. if(date){
  97. time = new Date(date);
  98. }else{
  99. time = new Date();
  100. }
  101. var year= time.getFullYear() //年
  102. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  103. var day = ("0" + time.getDate()).slice(-2); //日
  104. var mydate = year + "-" + month + "-" + day;
  105. return mydate
  106. },
  107. /**
  108. * 生命周期函数--监听页面初次渲染完成
  109. */
  110. onReady() {
  111. },
  112. /**
  113. * 生命周期函数--监听页面显示
  114. */
  115. onShow() {
  116. let that = this
  117. //汇票类型
  118. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_type', {method:'GET'}, {
  119. success: (res) => {
  120. if(res.data.length>0){
  121. that.setData({
  122. orderTypeOptions:res.data,
  123. 'form.orderType':res.data[0].dictValue
  124. })
  125. }
  126. }
  127. })
  128. //汇票状态
  129. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'order_status', {method:'GET'}, {
  130. success: (res) => {
  131. if(res.data.length>0){
  132. that.setData({
  133. orderStatusOptions:res.data,
  134. 'form.orderStatus':res.data[0].dictValue
  135. })
  136. }
  137. }
  138. })
  139. },
  140. openBox(even){
  141. console.log(even.currentTarget.dataset.name);
  142. this.setData({
  143. [even.currentTarget.dataset.name]:true
  144. })
  145. },
  146. onChange(event){
  147. console.log(event);
  148. this.setData({
  149. [event.currentTarget.dataset.value]: event.detail,
  150. })
  151. },
  152. closeBox(even){
  153. this.setData({
  154. [even.currentTarget.dataset.name]:false
  155. })
  156. },
  157. onConfirmorderType (e) {
  158. let obj = e.detail.value;
  159. this.setData({
  160. 'form.orderType':this.data.orderTypeOptions[obj].dictValue,
  161. 'orderTypeindex':obj
  162. })
  163. },
  164. onConfirmorderStatus (e) {
  165. let obj = e.detail.value;
  166. this.setData({
  167. 'form.orderStatus':this.data.orderStatusOptions[obj].dictValue,
  168. 'orderStatusindex':obj
  169. })
  170. },
  171. goSubmit(){
  172. if(this.data.form.orderNum===''||this.data.form.orderNum==null){ //汇票号码
  173. UTIL.showToastNoneIcon('请填写汇票号码!');
  174. return false;
  175. }else if(this.data.form.orderType===''||this.data.form.orderType==null){ //汇票类型
  176. UTIL.showToastNoneIcon('汇票类型不能为空!');
  177. return false;
  178. }else if(this.data.form.orderAmount===''||this.data.form.orderAmount==null){ //出票金额
  179. UTIL.showToastNoneIcon('请输入出票金额!');
  180. return false;
  181. }else if(this.data.form.billPayUnit===''||this.data.form.billPayUnit==null){ //付飘单位
  182. UTIL.showToastNoneIcon('请输入付飘单位!');
  183. return false;
  184. }else if(this.data.form.billReceiveUnit === ''||this.data.form.billReceiveUnit==null){//收票单位
  185. UTIL.showToastNoneIcon('请输入收票单位!');
  186. return false;
  187. }else if(this.data.form.startTime === ''||this.data.form.startTime==null){//开票日期
  188. UTIL.showToastNoneIcon('请输入开票日期!');
  189. return false;
  190. }else if(this.data.form.endTime === ''||this.data.form.endTime==null){//到期日期
  191. UTIL.showToastNoneIcon('请输入到期日期!');
  192. return false;
  193. }else if(this.data.form.orderStatus === ''||this.data.form.orderStatus==null){//联行号
  194. UTIL.showToastNoneIcon('汇票状态不能为空!');
  195. return false;
  196. }else if(this.data.form.orderStatus === ''||this.data.form.orderStatus==null){//联行号
  197. UTIL.showToastNoneIcon('汇票状态不能为空!');
  198. return false;
  199. }else if(this.data.status=='0'){
  200. this.setData({'status':1})
  201. var that = this;
  202. that.data.form.method = 'POST';
  203. if(that.data.form.id==""||that.data.form.id==null){
  204. UTIL.httpRequest(API.URL_POST_MONEYORDERADD, that.data.form , {
  205. success: (res) => {
  206. wx.showToast({
  207. title: '新增成功',
  208. icon: 'success',
  209. duration: 2000,
  210. complete(){
  211. setTimeout(function(){
  212. that.back();
  213. },2000)
  214. }
  215. })
  216. },
  217. fail: function (response) {
  218. if (typeof fail === FUNCTION_TEXT) {
  219. fail(handleFail(response));
  220. } else {
  221. showToastNoneIcon(API.MSG_FAIL_HTTP);
  222. }
  223. this.setData({'status':0})
  224. },
  225. complete: function (response) {
  226. this.setData({'status':0})
  227. wx.hideNavigationBarLoading();
  228. }
  229. })
  230. }else{
  231. UTIL.httpRequest(API.URL_POST_MONEYORDERUPDATE, that.data.form , {
  232. success: (res) => {
  233. wx.showToast({
  234. title: '修改成功',
  235. icon: 'success',
  236. duration: 2000,
  237. complete(){
  238. setTimeout(function(){
  239. that.back();
  240. },2000)
  241. }
  242. })
  243. },
  244. fail: function (response) {
  245. if (typeof fail === FUNCTION_TEXT) {
  246. fail(handleFail(response));
  247. } else {
  248. showToastNoneIcon(API.MSG_FAIL_HTTP);
  249. }
  250. this.setData({'status':0})
  251. },
  252. complete: function (response) {
  253. this.setData({'status':0})
  254. wx.hideNavigationBarLoading();
  255. }
  256. })
  257. }
  258. }
  259. },
  260. onConfirmTime(event){
  261. this.setData({
  262. [event.currentTarget.dataset.name]: false,
  263. [event.currentTarget.dataset.value]: UTIL.formatDate(event.detail),
  264. });
  265. },
  266. openBox(even){
  267. console.log(even.currentTarget.dataset.name);
  268. this.setData({
  269. [even.currentTarget.dataset.name]:true
  270. })
  271. },
  272. closeBox(even){
  273. console.log(even.currentTarget.dataset.name);
  274. this.setData({
  275. [even.currentTarget.dataset.name]:false
  276. })
  277. },
  278. back:function(){
  279. wx.navigateBack({
  280. delta: 1
  281. })
  282. },
  283. /**
  284. * 生命周期函数--监听页面隐藏
  285. */
  286. onHide() {
  287. },
  288. /**
  289. * 生命周期函数--监听页面卸载
  290. */
  291. onUnload() {
  292. },
  293. /**
  294. * 页面相关事件处理函数--监听用户下拉动作
  295. */
  296. onPullDownRefresh() {
  297. },
  298. /**
  299. * 页面上拉触底事件的处理函数
  300. */
  301. onReachBottom() {
  302. },
  303. /**
  304. * 用户点击右上角分享
  305. */
  306. onShareAppMessage() {
  307. }
  308. })