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

edit.js 6.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. console.log(options);
  43. var detail = JSON.parse(options.detail);
  44. console.log(detail);
  45. // 结算方式字典查询
  46. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'settle_style', {method:'GET'}, {
  47. success: (res) => {
  48. that.setData({
  49. jsfsOptions:res.data,
  50. })
  51. detail.settleStyleText = UTIL.getTransform(detail.settleStyle,res.data);
  52. this.setData({
  53. formData:detail
  54. })
  55. }
  56. })
  57. UTIL.httpRequest(API.URL_GET_GETLISTQUERY, {method:'GET'}, {
  58. success: (res) => {
  59. that.setData({
  60. pjbhOptions:res.rows,
  61. })
  62. }
  63. })
  64. UTIL.httpRequest(API.URL_GET_SUBJECTLIST , {method:'GET'}, {
  65. success: (res2) => {
  66. that.setData({
  67. subjectOptions:res2.rows,
  68. })
  69. }
  70. })
  71. //出纳账户
  72. var sendData = {
  73. pageNum:'1',
  74. pageSize:'100',
  75. accountName:'',
  76. bankAccountNumber:'',
  77. status:'N',
  78. method:'GET',
  79. accountType:102
  80. }
  81. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData,{
  82. success: (res) => {
  83. console.log(res.rows)
  84. that.setData({
  85. accountList:res.rows
  86. })
  87. }
  88. })
  89. this.setData({
  90. formData:detail
  91. })
  92. },
  93. back:function(){
  94. wx.navigateBack({
  95. delta: 1
  96. })
  97. },
  98. onsrDate(){
  99. this.setData({srShow:true})
  100. },
  101. onClose(){
  102. this.setData({srShow:false})
  103. },
  104. onConfirm(e){
  105. console.log(e);
  106. let data = this.getNewDate(new Date(e.detail));
  107. console.log(data);
  108. this.setData({'formData.billDate':data})
  109. this.setData({srShow:false})
  110. },
  111. getNewDate(date){
  112. //date是传过来的时间戳,注意需为13位,10位需*1000
  113. //也可以不传,获取的就是当前时间
  114. var time = new Date(date);
  115. var year= time.getFullYear() //年
  116. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  117. var day = ("0" + time.getDate()).slice(-2); //日
  118. var mydate = year + "-" + month + "-" + day;
  119. return mydate
  120. },
  121. onpjbhShow(){
  122. this.setData({pjbhShow:true})
  123. },
  124. onjsfsShow(){
  125. this.setData({jsfsShow:true})
  126. },
  127. oncnzhShow(){
  128. this.setData({cnzhShow:true})
  129. },
  130. onCancelcrzh(){
  131. this.setData({crzhShow:false})
  132. },
  133. onCancelcrlx(){
  134. this.setData({crlxShow:false,})
  135. },
  136. onCanceljsfs(){
  137. this.setData({jsfsShow:false,})
  138. },
  139. onCancelcrcnzh(){
  140. this.setData({cnzhShow:false,})
  141. },
  142. bindPickerChange (e) {
  143. console.log(e);
  144. let obj = e.detail.value;
  145. this.setData({
  146. pjbhShow:false,
  147. ["formData.billNum"]:obj.billNum,
  148. ["formData.listId"]:obj.id,
  149. })
  150. },
  151. bindPickerChangeJsfs (e) {
  152. console.log(e);
  153. let obj = e.detail.value;
  154. this.setData({
  155. jsfsShow:false,
  156. ["formData.settleStyle"]:obj.dictValue,
  157. ["formData.settleStyleText"]:obj.dictLabel,
  158. })
  159. },
  160. bindPickerChangeCnzh (e) {
  161. console.log(e);
  162. let obj = e.detail.value;
  163. this.setData({
  164. cnzhShow:false,
  165. ["formData.accountName"]:obj.accountName,
  166. ["formData.accountId"]:obj.accountId,
  167. })
  168. },
  169. swichAccounting:function(e){
  170. var that = this;
  171. let data = this.data.formData;
  172. if(data.billNum == ''){
  173. UTIL.showToastNoneIcon('请选择票据编号!');
  174. }
  175. if(data.billDate == ''){
  176. UTIL.showToastNoneIcon('请选择开票日期!');
  177. }
  178. if(data.payee == ''){
  179. UTIL.showToastNoneIcon('请填写收款方!');
  180. }
  181. if(data.payer == ''){
  182. UTIL.showToastNoneIcon('请填写付款方!');
  183. }
  184. if(data.accountSummary == ''){
  185. UTIL.showToastNoneIcon('请填写结算事项!');
  186. }
  187. if(data.settleStyle == ''){
  188. UTIL.showToastNoneIcon('请选择结算方式!');
  189. }
  190. if(data.accountName == ''){
  191. UTIL.showToastNoneIcon('请选择出纳账户!');
  192. }
  193. data.method = "POST";
  194. console.log(data);
  195. UTIL.httpRequest(API.URL_GET_GETBILLEDIT, data, {
  196. success: (res) => {
  197. if (res.code == API.SUCCESS_CODE) {
  198. wx.showToast({
  199. title: '修改成功',
  200. icon: 'success',
  201. duration: 2000,
  202. })
  203. setTimeout(function(){
  204. that.back();
  205. },2000)
  206. }else{
  207. UTIL.showToastNoneIcon(res.msg);
  208. }
  209. }
  210. })
  211. },
  212. inputChange(e){
  213. var that = this ;
  214. var obj = e.detail;
  215. var name = e.currentTarget.dataset.name;
  216. that.setData({
  217. [name] : obj.value
  218. })
  219. },
  220. onChange(e){
  221. this.setData({
  222. ["formData.incomeExpensesType"] : e.detail,
  223. ["formData.jieAmount"]:'0.00',
  224. ["formData.daiAmount"]:'0.00',
  225. })
  226. },
  227. /**
  228. * 生命周期函数--监听页面初次渲染完成
  229. */
  230. onReady() {
  231. },
  232. /**
  233. * 生命周期函数--监听页面显示
  234. */
  235. onShow() {
  236. },
  237. /**
  238. * 生命周期函数--监听页面隐藏
  239. */
  240. onHide() {
  241. },
  242. /**
  243. * 生命周期函数--监听页面卸载
  244. */
  245. onUnload() {
  246. },
  247. /**
  248. * 页面相关事件处理函数--监听用户下拉动作
  249. */
  250. onPullDownRefresh() {
  251. },
  252. /**
  253. * 页面上拉触底事件的处理函数
  254. */
  255. onReachBottom() {
  256. },
  257. /**
  258. * 用户点击右上角分享
  259. */
  260. onShareAppMessage() {
  261. }
  262. })