|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- // pages/Bookkeeping/Bookkeeping.js
- import * as UTIL from '../../utils/util.js';
- import * as API from '../../utils/API.js';
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- isIPX: app.globalData.isIPX,
- result:[],
- result2:[],
- showGroup:true,
- flowList:[],
- showProjectFundType:false,
- checkedStatusText:'未提交',
- checkedStatus:'1'
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- var that = this;
-
- UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'checked_status', {method:'GET'}, {
- success: (res) => {
- that.setData({
- capitalExpenditureTypeOptions:res.data,
- })
- }
- })
- UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_type', {method:'GET'}, {
- success: (res) => {
- that.setData({
- incomeTypeOptions:res.data,
- })
- }
- })
- UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, {
- success: (res) => {
- that.setData({
- expenditureTypeOptions:res.data,
- })
- }
- })
-
- that.SRSelect();
- that.ZCSelect();
- },
- SRSelect(){
- var that = this;
- //收入事项
- let data = {
- pageNum:'1',
- pageSize:'999',
- accountType:'',
- checkedStatus:'1',
- incomeExpensesType:'1',
- }
- UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- let list = res.rows;
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
- list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
- }
- this.setData({
- flowListSR:list,
- flowListSRNum:res.total
- });
- }
- }
- })
- },
- ZCSelect(){
- var that = this;
- //支出事项
- let data2 = {
- pageNum:'1',
- pageSize:'999',
- accountType:'',
- checkedStatus:'1',
- incomeExpensesType:'2',
- }
- UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- let list = res.rows;
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
- list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions);
- }
- this.setData({
- flowListZC:list,
- flowListZCNum:res.total
- });
- }
- }
- })
- },
- onChange(event) {
- this.setData({result:event.detail})
- },
- onChange2(event) {
- this.setData({result2:event.detail})
- },
- switchTab(e){
- var that = this;
- this.setData({showGroup:e.currentTarget.dataset.gid})
- if(e.currentTarget.dataset.gid){
- //收入事项
- let data = {
- pageNum:'1',
- pageSize:'999',
- accountType:'',
- checkedStatus:this.data.checkedStatus,
- incomeExpensesType:'1',
- }
- UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- let list = res.rows;
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
- list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
- }
- this.setData({
- flowListSR:list,
- flowListSRNum:res.total
- });
- }
- }
- })
- }else{
- let data2 = {
- pageNum:'1',
- pageSize:'999',
- accountType:'',
- checkedStatus:this.data.checkedStatus,
- incomeExpensesType:'2',
- }
- UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- let list = res.rows;
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
- list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions);
- }
- this.setData({
- flowListZC:list,
- flowListZCNum:res.total
- });
- }
- }
- })
- }
-
- },
- back:function(){
- wx.navigateBack({
- delta: 1
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
-
- },
- openPopup(even){
- this.setData({
- showProjectFundType:true
- })
- },
- onConfirmPick(event){
- var that = this;
- this.setData({
- [event.currentTarget.dataset.name]: false,
- checkedStatus: event.detail.value.dictValue,
- checkedStatusText: event.detail.value.dictLabel,
- });
- let data = {
- pageNum:'1',
- pageSize:'999',
- accountType:'',
- checkedStatus:event.detail.value.dictValue,
- incomeExpensesType:'1',
- }
- UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- let list = res.rows;
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
- element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
- }
- this.setData({
- flowListSR:list,
- flowListSRNum:res.total
- });
- }
- }
- })
- let data2 = {
- pageNum:'1',
- pageSize:'999',
- accountType:'',
- checkedStatus:event.detail.value.dictValue,
- incomeExpensesType:'2',
- }
- UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- let list = res.rows;
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
- }
- this.setData({
- flowListZC:list,
- flowListZCNum:res.total
- });
- }
- }
- })
-
- },
- closeBox(even){
- console.log(even.currentTarget.dataset.name);
- this.setData({
- [even.currentTarget.dataset.name]:false
- })
- },
- goSubmit(){
- var that = this ;
- console.log(that.data.showGroup);
- if(that.data.showGroup){
- if(that.data.result.length==0){
- UTIL.showToastNoneIcon('至少选择一个收入事项!');
- return;
- }
- let url = API.URL_GET_GETBOOKKEEP
- wx.request({
- url,
- method:"POST",
- timeout: 60000,
- data:that.data.result,
- header: {
- 'Authorization':'Bearer '+getApp().globalData.userInfo.token
- },
- success: function (response) {
- wx.showToast({
- title: "提交成功!",
- duration: 2000,
- icon:"success"
- })
- that.setData({
- result:[]
- })
- that.SRSelect();
- }
- })
- }else{
- if(that.data.result2.length==0){
- UTIL.showToastNoneIcon('至少选择一个支出事项!');
- return;
- }
- let url = API.URL_GET_GETBOOKKEEP
- wx.request({
- url,
- method:"POST",
- timeout: 60000,
- data:that.data.result2,
- header: {
- 'Authorization':'Bearer '+getApp().globalData.userInfo.token
- },
- success: function (response) {
- wx.showToast({
- title: "提交成功!",
- duration: 2000,
- icon:"success"
- })
- that.setData({
- result2:[]
- })
- that.ZCSelect();
- }
- })
- }
-
- },
- goUpdate(event){
- wx.navigateTo({
- url: '/pages/Bookkeeping/update/update?id='+event.currentTarget.dataset.id,
- })
- },
- goUpdateZC(event){
- wx.navigateTo({
- url: '/pages/Bookkeeping/updateZC/update?id='+event.currentTarget.dataset.id,
- })
- },
- delete(e){
- console.log(e);
- var that = this;
- UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- that.data.flowListSR.splice(e.currentTarget.dataset.index, 1);
- wx.showToast({
- title: '删除成功!',
- icon: 'success',
- duration: 2000
- })
- that.setData({
- flowListSR : that.data.flowListSR,
- flowListSRNum:that.data.flowListSRNum-1
- })
- }
- }
- })
- },
- delete2(e){
- console.log(e);
- var that = this;
- UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
- success: (res) => {
- if (res.code == API.SUCCESS_CODE) {
- that.data.flowListZC.splice(e.currentTarget.dataset.index, 1);
- wx.showToast({
- title: '删除成功!',
- icon: 'success',
- duration: 2000
- })
- that.setData({
- flowListZC : that.data.flowListZC,
- flowListZCNum:that.data.flowListZCNum-1
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
|