微信小程序
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.

274 lines
6.1 KiB

  1. // pages/billUse/flowAdd/flowAdd.js
  2. import * as UTIL from '../../../utils/util.js';
  3. import * as API from '../../../utils/API.js';
  4. let EVN_CONFIG = require('../../../env/env');
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. isIPX: app.globalData.isIPX,
  12. formData:{
  13. listId: '', //票据ID
  14. billNum: '', //票据编号 必填
  15. billType: '4', //票据状态
  16. bookId: '', //账套ID
  17. deptId: '', //系统机构代码
  18. billDate: '', //开票日期 必填
  19. accountSummary: '',//摘要 必填
  20. incomeExpensesType: "1", //收支类型
  21. settleStyle: '', //结算方式
  22. jieAmount: '', //收入金额
  23. daiAmount: '', //支出金额
  24. preparedBy: '', //经办人 必填
  25. payee: '', //收款方 必填
  26. payer: '', //付款方 必填
  27. accountId: '', //出纳账户ID
  28. accountName: '', //出纳账户
  29. accountType: '', //账户类型 字典account_type
  30. cashierFlowId: '' //出纳流水ID
  31. },
  32. //收入时间弹窗显隐
  33. srShow:false,
  34. minDate:new Date().getTime() - 180* 24 * 60 * 60 * 1000,
  35. maxDate:new Date().getTime() + 180* 24 * 60 * 60 * 1000,
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad(options) {
  41. var that = this ;
  42. this.setData({
  43. ["formData.billDate"]:this.getNewDate(new Date())
  44. })
  45. // 结算方式字典查询
  46. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'settle_style', {method:'GET'}, {
  47. success: (res) => {
  48. that.setData({
  49. jsfsOptions:res.data,
  50. })
  51. }
  52. })
  53. UTIL.httpRequest(API.URL_GET_GETLISTQUERY, {method:'GET'}, {
  54. success: (res) => {
  55. that.setData({
  56. pjbhOptions:res.rows,
  57. })
  58. }
  59. })
  60. UTIL.httpRequest(API.URL_GET_SUBJECTLIST , {method:'GET'}, {
  61. success: (res2) => {
  62. that.setData({
  63. subjectOptions:res2.rows,
  64. })
  65. }
  66. })
  67. //出纳账户
  68. var sendData = {
  69. pageNum:'1',
  70. pageSize:'100',
  71. accountName:'',
  72. bankAccountNumber:'',
  73. status:'N',
  74. method:'GET',
  75. accountType:102
  76. }
  77. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData,{
  78. success: (res) => {
  79. console.log(res.rows)
  80. that.setData({
  81. accountList:res.rows
  82. })
  83. }
  84. })
  85. },
  86. back:function(){
  87. wx.navigateBack({
  88. delta: 1
  89. })
  90. },
  91. onsrDate(){
  92. this.setData({srShow:true})
  93. },
  94. onClose(){
  95. this.setData({srShow:false})
  96. },
  97. onConfirm(e){
  98. console.log(e);
  99. let data = this.getNewDate(new Date(e.detail));
  100. console.log(data);
  101. this.setData({'formData.billDate':data})
  102. this.setData({srShow:false})
  103. },
  104. getNewDate(date){
  105. //date是传过来的时间戳,注意需为13位,10位需*1000
  106. //也可以不传,获取的就是当前时间
  107. var time = new Date(date);
  108. var year= time.getFullYear() //年
  109. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  110. var day = ("0" + time.getDate()).slice(-2); //日
  111. var mydate = year + "-" + month + "-" + day;
  112. return mydate
  113. },
  114. onpjbhShow(){
  115. this.setData({pjbhShow:true})
  116. },
  117. onjsfsShow(){
  118. this.setData({jsfsShow:true})
  119. },
  120. oncnzhShow(){
  121. this.setData({cnzhShow:true})
  122. },
  123. onCancelcrzh(){
  124. this.setData({crzhShow:false})
  125. },
  126. onCancelcrlx(){
  127. this.setData({pjbhShow:false,})
  128. },
  129. onCanceljsfs(){
  130. this.setData({jsfsShow:false,})
  131. },
  132. onCancelcrcnzh(){
  133. this.setData({cnzhShow:false,})
  134. },
  135. bindPickerChange (e) {
  136. console.log(e);
  137. let obj = e.detail.value;
  138. this.setData({
  139. pjbhShow:false,
  140. ["formData.billNum"]:obj.billNum,
  141. ["formData.listId"]:obj.id,
  142. })
  143. },
  144. bindPickerChangeJsfs (e) {
  145. console.log(e);
  146. let obj = e.detail.value;
  147. this.setData({
  148. jsfsShow:false,
  149. ["formData.settleStyle"]:obj.dictValue,
  150. ["formData.settleStyleText"]:obj.dictLabel,
  151. })
  152. },
  153. bindPickerChangeCnzh (e) {
  154. console.log(e);
  155. let obj = e.detail.value;
  156. this.setData({
  157. cnzhShow:false,
  158. ["formData.accountName"]:obj.accountName,
  159. ["formData.accountId"]:obj.accountId,
  160. })
  161. },
  162. swichAccounting:function(e){
  163. var that = this;
  164. let data = this.data.formData;
  165. if(data.billNum == ''){
  166. UTIL.showToastNoneIcon('请选择票据编号!');
  167. }
  168. if(data.billDate == ''){
  169. UTIL.showToastNoneIcon('请选择开票日期!');
  170. }
  171. if(data.payee == ''){
  172. UTIL.showToastNoneIcon('请填写收款方!');
  173. }
  174. if(data.payer == ''){
  175. UTIL.showToastNoneIcon('请填写付款方!');
  176. }
  177. if(data.accountSummary == ''){
  178. UTIL.showToastNoneIcon('请填写结算事项!');
  179. }
  180. if(data.settleStyle == ''){
  181. UTIL.showToastNoneIcon('请选择结算方式!');
  182. }
  183. if(data.accountName == ''){
  184. UTIL.showToastNoneIcon('请选择出纳账户!');
  185. }
  186. data.method = "POST";
  187. UTIL.httpRequest(API.URL_GET_GETBILLADD, data, {
  188. success: (res) => {
  189. if (res.code == API.SUCCESS_CODE) {
  190. wx.showToast({
  191. title: '新增成功',
  192. icon: 'success',
  193. duration: 2000,
  194. })
  195. setTimeout(function(){
  196. that.back();
  197. },2000)
  198. }else{
  199. UTIL.showToastNoneIcon(res.msg);
  200. }
  201. }
  202. })
  203. },
  204. inputChange(e){
  205. var that = this ;
  206. var obj = e.detail;
  207. var name = e.currentTarget.dataset.name;
  208. that.setData({
  209. [name] : obj.value
  210. })
  211. },
  212. onChange(e){
  213. console.log(e);
  214. this.setData({
  215. ["formData.incomeExpensesType"] : e.detail,
  216. ["formData.jieAmount"]:'',
  217. ["formData.daiAmount"]:'',
  218. })
  219. },
  220. /**
  221. * 生命周期函数--监听页面初次渲染完成
  222. */
  223. onReady() {
  224. },
  225. /**
  226. * 生命周期函数--监听页面显示
  227. */
  228. onShow() {
  229. },
  230. /**
  231. * 生命周期函数--监听页面隐藏
  232. */
  233. onHide() {
  234. },
  235. /**
  236. * 生命周期函数--监听页面卸载
  237. */
  238. onUnload() {
  239. },
  240. /**
  241. * 页面相关事件处理函数--监听用户下拉动作
  242. */
  243. onPullDownRefresh() {
  244. },
  245. /**
  246. * 页面上拉触底事件的处理函数
  247. */
  248. onReachBottom() {
  249. },
  250. /**
  251. * 用户点击右上角分享
  252. */
  253. onShareAppMessage() {
  254. }
  255. })