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

3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. // pages/apply/index.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. bookName:'', //付款单位
  12. formData:{
  13. accountType:'', //账户类型
  14. accountDate:'', //收入时间
  15. jieAmount:'', //收入金额
  16. accountName:'', //存入账户
  17. incomeType:'', //收入类型
  18. billNum:'', //单据编码
  19. accountSummary:'', //备注说明
  20. contractionId:'', //合同编码
  21. incomeExpensesType:1, //收支类别
  22. isBill:0
  23. },
  24. incomeTypeOptions:[], //收入类型选项
  25. incomeTypeText:'222', //收入类型显示文字
  26. contractionOptions:[], //付款人合同信息列表接口
  27. showHt:false,
  28. payerText:'', //付款人
  29. sjPics:[], //收据图片列表数据
  30. fpPics:[], //发票图片列表数据
  31. qtPics:[], //其他图片列表数据
  32. //收入时间弹窗显隐
  33. srShow:false,
  34. minDate: new Date(2018, 0, 1).getTime(),
  35. maxDate: new Date(2025, 0, 31).getTime(),
  36. crzhShow:false,
  37. accountListOptions:[] //存入账户类型选项
  38. },
  39. onCancelcrzh(){
  40. this.setData({crzhShow:false})
  41. },
  42. oncrzhShow(){ this.setData({crzhShow:true})},
  43. onConfirmcrzh(e){
  44. let data = e.detail.value;
  45. this.setData({
  46. crzhShow:false,
  47. 'formData.accountName':data.accountName,
  48. 'formData.accountId':data.id,
  49. 'formData.accountType':data.accountType
  50. })
  51. },
  52. onsrDate(){
  53. this.setData({srShow:true})
  54. },
  55. onClose(){ this.setData({srShow:false})},
  56. onConfirm(e){
  57. let data = this.getNewDate(new Date(e.detail));
  58. this.setData({'formData.accountDate':data})
  59. this.setData({srShow:false})
  60. },
  61. closeBox(){
  62. this.setData({showHt:false})
  63. },
  64. getNewDate(date){
  65. //date是传过来的时间戳,注意需为13位,10位需*1000
  66. //也可以不传,获取的就是当前时间
  67. var time = new Date(date);
  68. var year= time.getFullYear() //年
  69. var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
  70. var day = ("0" + time.getDate()).slice(-2); //日
  71. var mydate = year + "-" + month + "-" + day;
  72. return mydate
  73. },
  74. onConfirmContraction(value){
  75. let obj = value.detail.value;
  76. this.setData({
  77. payerText:obj.name,
  78. showHt:false,
  79. 'formData.contractionId':obj.code,
  80. })
  81. },
  82. selectContraction(){
  83. this.setData({showHt:true})
  84. },
  85. bindPickerChange (e) {
  86. let obj = this.data.incomeTypeOptions[e.detail.value];
  87. this.setData({
  88. 'formData.incomeType':obj.dictValue,
  89. incomeTypeText:obj.dictLabel
  90. })
  91. },
  92. inputChange(e){
  93. this.setData({
  94. [e.currentTarget.dataset.prop]: e.detail.value
  95. })
  96. },
  97. /**
  98. * 生命周期函数--监听页面加载
  99. */
  100. onShow: function (options) {
  101. },
  102. /**
  103. * 生命周期函数--监听页面初次渲染完成
  104. */
  105. onLoad: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面显示
  109. */
  110. onReady: function () {
  111. let that = this;
  112. //初始化收入时间
  113. this.setData({
  114. 'formData.accountDate':UTIL.formatDate(new Date())
  115. })
  116. //获取收入单位
  117. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  118. success: (res) => {
  119. if (res.code == API.SUCCESS_CODE) {
  120. this.setData({bookName:res.user.bookName})
  121. }
  122. }
  123. })
  124. //获取收入类型状态
  125. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_type', {method:'GET'}, {
  126. success: (res) => {
  127. if(res.data.length>0){
  128. that.setData({
  129. incomeTypeOptions:res.data,
  130. incomeTypeText:res.data[0].dictLabel,
  131. 'formData.incomeType':res.data[0].dictValue
  132. })
  133. }
  134. }
  135. })
  136. // 获取合同信息列表
  137. UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET'}, {
  138. success: (res) => {
  139. that.setData({
  140. contractionOptions:res.rows,
  141. })
  142. }
  143. })
  144. //获取当前账套付款账户列表
  145. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , {method:'GET'}, {
  146. success: (res) => {
  147. that.setData({
  148. accountListOptions:res.rows,
  149. })
  150. }
  151. })
  152. },
  153. deleteimg:function(e){
  154. let oData = e.currentTarget.dataset;
  155. let file = this.data[oData.status];
  156. file.splice(oData.id,1)
  157. this.setData({
  158. [oData.status]:file
  159. })
  160. },
  161. back:function(){
  162. wx.navigateBack({
  163. delta: 1
  164. })
  165. },
  166. uploadSjPics: function (e) { //这里是选取图片的方法
  167. var that = this;
  168. var detailPics = that.data.sjPics;
  169. if (detailPics.length >= that.data.count) {
  170. wx.showToast({
  171. title: '最多选择' + that.data.count + '张!',
  172. })
  173. return;
  174. }
  175. wx.chooseImage({
  176. count: that.data.count, // 最多可以选择的图片张数,默认9
  177. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  178. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  179. success: function (res) {
  180. let fileForm = that.data.sjPics
  181. res.tempFilePaths.forEach(item => {
  182. fileForm.push({
  183. file: item,
  184. fileType:'1',
  185. bizPath:'cashier',
  186. tableName:'t_cashier_account_flow',
  187. tableId:''
  188. })
  189. })
  190. that.setData({
  191. sjPics:fileForm
  192. })
  193. },
  194. })
  195. },
  196. uploadFpPics: function (e) { //这里是选取图片的方法
  197. var that = this;
  198. var pics = [];
  199. var detailPics = that.data.fpPics;
  200. if (detailPics.length >= that.data.count) {
  201. wx.showToast({
  202. title: '最多选择' + that.data.count + '张!',
  203. })
  204. return;
  205. }
  206. wx.chooseImage({
  207. count: that.data.count, // 最多可以选择的图片张数,默认9
  208. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  209. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  210. success: function (res) {
  211. let fileForm = that.data.fpPics
  212. res.tempFilePaths.forEach(item => {
  213. fileForm.push({
  214. file: item,
  215. fileType:'2',
  216. bizPath:'cashier',
  217. tableName:'t_cashier_account_flow',
  218. tableId:''
  219. })
  220. })
  221. that.setData({
  222. fpPics:fileForm
  223. })
  224. },
  225. })
  226. },
  227. uploadQtPics: function (e) { //这里是选取图片的方法
  228. var that = this;
  229. var pics = [];
  230. var detailPics = that.data.qtPics;
  231. if (detailPics.length >= that.data.count) {
  232. wx.showToast({
  233. title: '最多选择' + that.data.count + '张!',
  234. })
  235. return;
  236. }
  237. wx.chooseImage({
  238. count: that.data.count, // 最多可以选择的图片张数,默认9
  239. sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
  240. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  241. success: function (res) {
  242. let fileForm = that.data.qtPics
  243. res.tempFilePaths.forEach(item => {
  244. fileForm.push({
  245. file: item,
  246. fileType:'3',
  247. bizPath:'cashier',
  248. tableName:'t_cashier_account_flow',
  249. tableId:''
  250. })
  251. })
  252. that.setData({
  253. qtPics:fileForm
  254. })
  255. },
  256. })
  257. },
  258. swichAccounting:function(e){
  259. let codeStr = e.currentTarget.dataset.code;
  260. let formDataObj = this.data.formData;
  261. if(formDataObj.jieAmount==''){ //收入金额
  262. UTIL.showToastNoneIcon('请填写收入金额!');
  263. return false;
  264. }else if(formDataObj.accountName==''){ //存入账户
  265. UTIL.showToastNoneIcon('请选择存入账户!');
  266. return false;
  267. }else if(formDataObj.billNum==''){ //单据编码
  268. UTIL.showToastNoneIcon('请输入单据编码!');
  269. return false;
  270. }else if(formDataObj.accountSummary==''){ //备注说明
  271. UTIL.showToastNoneIcon('请输入备注说明!');
  272. return false;
  273. }else if(formDataObj.incomeType == '2' && formDataObj.contractionId==''){
  274. UTIL.showToastNoneIcon('收入类型为发包收入,必须选择关联合同!');
  275. return false;
  276. }
  277. let data = this.data.formData;
  278. data.method = "POST";
  279. data.checkedStatus = codeStr;
  280. UTIL.httpRequest(API.URL_POST_GERFLOWADD,data,{
  281. success: (res) => {
  282. if(res.code == 200){
  283. let vouerId = res.data;
  284. // let vouerId = 1;
  285. let updataList = [...this.data.sjPics,...this.data.fpPics,...this.data.qtPics];
  286. for(let i=0; i<updataList.length; i++){
  287. let arrData=updataList[i];
  288. arrData.tableId = vouerId;
  289. wx.uploadFile({
  290. url: API.URL_GET_UPLOAD,
  291. filePath: arrData.file,
  292. name: 'file',
  293. header: {
  294. "Content-Type": "multipart/form-data",//记得设置
  295. "chartset":"utf-8",
  296. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  297. },
  298. formData:arrData,
  299. success (response){
  300. console.log(response);
  301. },
  302. fail(res){
  303. console.log(response)
  304. }
  305. })
  306. }
  307. wx.redirectTo({
  308. url: '/pages/index/index'
  309. })
  310. }else{
  311. UTIL.showToastNoneIcon(res.msg);
  312. }
  313. }
  314. })
  315. },
  316. imgPreviewImage(e){
  317. let currentImgList = e.currentTarget.dataset;
  318. //获取当前附件列表
  319. let currentStatus = this.data[currentImgList.status];
  320. //当前选中图片index
  321. let currentIndex = currentImgList.id;
  322. let imgList = []
  323. for(let i = 0; i<currentStatus.length; i++){
  324. imgList.push(currentStatus[i].file)
  325. }
  326. wx.previewImage({
  327. current: imgList[currentIndex], // 当前显示图片的http链接
  328. urls: imgList // 需要预览的图片http链接列表
  329. })
  330. },
  331. /**
  332. * 生命周期函数--监听页面隐藏
  333. */
  334. onHide: function () {
  335. },
  336. /**
  337. * 生命周期函数--监听页面卸载
  338. */
  339. onUnload: function () {
  340. },
  341. /**
  342. * 页面相关事件处理函数--监听用户下拉动作
  343. */
  344. onPullDownRefresh: function () {
  345. },
  346. /**
  347. * 页面上拉触底事件的处理函数
  348. */
  349. onReachBottom: function () {
  350. },
  351. /**
  352. * 用户点击右上角分享
  353. */
  354. onShareAppMessage: function () {
  355. }
  356. })