微信小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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