123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- var app = getApp()
- var that,yearIndex;
- // 设置默认年份
- app.globalData.yearArr.forEach((item,index)=>{
- if(item==app.globalData.year){
- yearIndex=index
- }
- })
- Component({
- mixins: [],
- data: {
- dateIndex: "1",
- year: app.globalData.year,//年
- month: app.globalData.month,//月
- jdYear: app.globalData.year,//季度年
- jdji: 0,//季度季
- jdArr: ['一季度', '二季度', '三季度', '四季度'],
- yearIndex:yearIndex,
- yearArr:app.globalData.yearArr,
- jdYearIndex:yearIndex,
- isShowArr:[true,true,true],
- showSelect:false,
- },
- props: {
- onClose: (data) => console.log(data),
- onConfirm: (data) => console.log(data),
- showSelectP:false,
- dateObj:{
- type:'3',
- date:app.globalData.month
- },
- },
- didMount() {
- this.setData({isShow: this.props.isShow,showSelect:this.props.showSelectP})
- if(this.props.dateObj.type){
- this.setData({
- dateIndex:this.props.dateObj.type,
- })
- if(this.props.dateObj.type==1){
- this.data.yearArr.forEach((item,index)=>{
- if(this.props.dateObj.date==item){
- this.setData({
- yearIndex:index,
- })
- }
- })
- }else if(this.props.dateObj.type==2){
- var data=String(this.props.dateObj.date);
- this.data.yearArr.forEach((item,index)=>{
- if(data.substr(0,4)==item){
- this.setData({
- jdYearIndex:index,
- })
- }
- })
- this.setData({
- jdji:data.substr(data.length-1,1)-1
- })
- }else{
- this.setData({
- month:this.props.dateObj.date,
- })
- }
- }
- },
- didUpdate() { },
- didUnmount() { },
- methods: {
- selectYear2(e) {
- this.setData({
- jdYearIndex: e.detail.value,
- });
- },
- selectYear(e) {
- this.setData({
- yearIndex: e.detail.value,
- });
- },
- setjdji(e) {
- this.setData({
- jdji: e.detail.value,
- });
- },
- onConfirm() {
- var obj;
- switch (this.data.dateIndex) {
- case "1":
- obj = {
- type: this.data.dateIndex,
- date: this.data.yearArr[this.data.yearIndex]
- }
- break
- case "2":
- var year=this.data.yearArr[this.data.jdYearIndex];
- var num=this.data.jdji;
- num++;
- let arrNew=new Array()
- arrNew.push(year)
- arrNew.push(num)
- let strNew=arrNew.join('')
- obj = {
- type: this.data.dateIndex,
- date:parseInt(strNew)
- }
- break
- case "3":
- obj = {
- type: this.data.dateIndex,
- date: this.data.month
- }
- break
- };
- this.props.onConfirm(obj);
- this.props.onClose();
- },
- onClose() {
- this.props.onClose();
- },
- selectDay() {
- dd.datePicker({
- format: 'yyyy',
- currentDate: this.data.jdYear,
- success: (res) => {
- this.setData({
- jdYear: res.date
- })
- },
- });
- },
- selectDay2() {
- },
- selectDate() {
- dd.datePicker({
- format: 'yyyy-MM',
- currentDate: this.data.month,
- success: (res) => {
- this.setData({
- month: res.date
- })
- },
- });
- },
- activeDate(e) {
- this.setData({ dateIndex: e.target.dataset.index })
- },
- },
- });
|