微信小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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