Authored by weiqingting

时间控件修改

... ... @@ -7,13 +7,13 @@
</select>
</div>
<div class="panel-col" v-if="params.type==1">
<com-calendar :value.sync="params.reqTime" :placeholder="'选择时间'"></com-calendar>
<com-calendar :value.sync="params.reqTime" :placeholder="'选择时间'" :end="EndDate"></com-calendar>
</div>
<div class="panel-col" v-if="params.type==3">
<com-calendar :format="'yyyy-MM'" :value.sync="params.reqTime" :placeholder="'选择月份'"></com-calendar>
<com-calendar :format="'yyyy-MM'" :value.sync="params.reqTime" :end="EndDate" :placeholder="'选择月份'"></com-calendar>
</div>
<div class="panel-col" v-if="params.type==2">
<com-calendar :value.sync="params.beginTime" :state="'week'" :placeholder="'开始时间'"></com-calendar>
<com-calendar :value.sync="params.beginTime" :state="'week'" :end="EndDate" :placeholder="'开始时间'"></com-calendar>
</div>
<div class="panel-col" v-if="params.type==2">
<input type="text" :value="EndTime" class="form-control" placeholder="结束时间" disabled>
... ... @@ -48,6 +48,10 @@
params: {type: Object, default: {}}
},
computed: {
EndDate(){
let date=new Date()
return [date.getFullYear(),date.getMonth(),date.getDate()-1].join('-');
},
EndTime(){
var date = new Date(this.params.beginTime);//获取开始时间
var day = date.getDay();//获取开始时间的星期值
... ...
<template>
<div class="panel-col">
<calendar :type="'date'" :value.sync="params.beginTime" :placeholder="'开始时间'"></calendar>
<calendar :type="'date'" :value.sync="params.beginTime" :end="EndDate" :placeholder="'开始时间'"></calendar>
</div>
<div class="panel-col">
<calendar :type="'date'" :value.sync="params.endTime" :placeholder="'结束时间'"></calendar>
<calendar :type="'date'" :value.sync="params.endTime" :end="EndDate" :placeholder="'结束时间'"></calendar>
</div>
<div class="panel-col">
<input type="text" class="form-control" placeholder="SKN" v-model="params.productSkn">
... ... @@ -30,6 +30,12 @@
},
props:{
params:{type:Object, default:{}}
},
computed:{
EndDate(){
let date=new Date()
return [date.getFullYear(),date.getMonth(),date.getDate()-1].join('-');
}
}
}
</script>
\ No newline at end of file
... ...
... ... @@ -25,7 +25,7 @@
</template>
<script>
export default {
props:["dateTime","mo","state"],
props:["dateTime","mo","state","end"],
data(){
return {
// date: new Date(this.dateText),
... ... @@ -108,13 +108,31 @@
this.mo="month"
},
isnot(day,index){
if(this.state=="week"){
if(day.day==1){
return false;
if(day.day&&day.day!==32){
if(this.state=="week"){
if(day.day==1){
return false;
}
var a=new Date(day.date.getFullYear(),day.date.getMonth(),day.date.getDate());
a.setDate(a.getDate()+(6-a.getDay()));
if(a>new Date()){
return true;
}
if(index!==0){
return true;
}
// return ! day.day || day.day === 32||index!==0;//||day.day!==1;
}
if(this.end){
var _a=this.end.split('-');
if(day.date>new Date(_a[0],_a[1],_a[2])){
return true;
}
}
return ! day.day || day.day === 32||index!==0;//||day.day!==1;
return false;
}
return ! day.day || day.day === 32;
return true;
}
},
ready() {
... ...
<style type="text/css">
.datepicker table tr td span.disabled{
color: #ccc;
}
</style>
<template>
<div class="datepicker-months vue-show-imo">
<table class=" table-condensed">
... ... @@ -15,7 +20,7 @@
<tbody>
<tr>
<td colspan="7" >
<span class="month" v-for="month in months" v-text="month" @click="selectMonth(month)"></span>
<span :class="{active:month===+m,disabled:isnot(m),month:'month'}" v-for="m in months" v-text="m" @click="selectMonth(m)"></span>
</td>
</tr>
</tbody>
... ... @@ -24,7 +29,7 @@
</template>
<script>
export default {
props:["dateTime","mo"],
props:["dateTime","mo","end"],
data(){
return {
months:['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
... ... @@ -33,6 +38,9 @@ export default {
computed:{
year() {
return this.dateTime.year
},
month(){
return this.dateTime.month+1
}
},
methods:{
... ... @@ -45,9 +53,24 @@ export default {
this.dateTime.year+=1
},
selectMonth(value){
if(this.isnot(value)){
return
}
this.dateTime.month=+value-1
this.mo=''
this.dateTime._hasdefault=true
},
isnot(value){
if(this.end){
var _a=this.end.split('-');
if(this.dateTime.year>_a[0]){
return true;
}
if(+value>_a[1]){
return true;
}
}
return false;
}
},
ready() {
... ...
... ... @@ -23,8 +23,8 @@
<template>
<input type="text" class="form-control" @click="showCalendar" :value="date" :placeholder="placeholder">
<div class="datepicker datepicker-dropdown dropdown-menu vue-show" :style="{'left':x+'px','top':y+'px'}" v-show="isshow">
<date-days :date-time.sync="dateTime" :mo.sync="mo" :state="state" v-show="mo==='day'"></date-days>
<date-months :date-time.sync="dateTime" :mo.sync="mo" v-show="mo==='month'"></date-months>
<date-days :date-time.sync="dateTime" :end="end" :begin="begin" :mo.sync="mo" :state="state" v-show="mo==='day'"></date-days>
<date-months :date-time.sync="dateTime" :end="end" :begin="begin" :mo.sync="mo" v-show="mo==='month'"></date-months>
</div>
</template>
<script>
... ... @@ -47,6 +47,12 @@ import dateMonths from "./dateMonths.vue"
placeholder:{
type:String,
default:'选择时间'
},
end:{
type:String
},
begin:{
type:String
}
},
components:{
... ... @@ -113,13 +119,13 @@ import dateMonths from "./dateMonths.vue"
},
//点击空白处弹层关闭
blindEvent(){
var self = this;
$(document).on("click", function(){
self.mo="";
});
$(".datepicker").on("click", function(event){
event.stopPropagation();//阻止事件向上冒泡
});
// var self = this;
// $(document).on("click", function(){
// self.mo="";
// });
// $(".datepicker").on("click", function(event){
// event.stopPropagation();//阻止事件向上冒泡
// });
}
},
ready(){
... ...
<template>
<div class="pagination-container">
<template v-if="rowsTotal > 0">
<template v-if="pages > 0">
<nav>
<ul class="pagination light-theme simple-pagination">
<li v-bind:class="{'disabled':isFirst}" @click="prev">
<li v-bind:class="{'disabled':currentPage<2}" @click="prev">
<span class="current prev">Prev</span>
</li>
<li v-for="n in pageChunkCurrent" v-bind:class="{'active':isActive[n+1]}" @click="nav( n+1 )">
<a href="javascript:void(0)">{{n + 1}}</a>
<li v-for="n in draw" v-bind:class="{'active':n===currentPage}" @click="nav(n)">
<a href="javascript:void(0)">{{n}}</a>
</li>
<li @click="next" v-bind:class="{'disabled':isLast}">
<li @click="next" v-bind:class="{'disabled':currentPage>pages-1}">
<span class="current next">Next</span>
</li>
</ul>
... ... @@ -17,120 +17,51 @@
</template>
</div>
</template>
<script>
export default {
<script type="text/javascript">
export default {
props: {
pageSize: {
type: Number,
default: 10
},
rowsTotal: {
pages: {
type: Number,
required: true
},
page: {
currentPage: {
type: Number,
required: true
}
},
watch: {
rowsTotal(newVal, oldVal) {
if (newVal !== oldVal) {
// init option when rows changes
this.page = 1
this.isFirst = true
this.isLast = false
computed:{
draw(){
var bll=this,arr=[];
let beginNum = bll.currentPage - 4;
if (beginNum > bll.pages - 8) beginNum = bll.pages - 8;
if (beginNum < 1) beginNum = 1;
let endNum = beginNum + 8;
if (endNum > bll.pages) endNum = bll.pages;
for (let i = beginNum; i <= endNum; i++)
{
arr.push(i);
}
},
pageTotal(newVal, oldVal) {
if (newVal === 1) {
// only one page
this.isFirst = true
this.isLast = true
}
}
},
computed: {
pageChunkCurrent() {
let pageTotal = Math.ceil(this.rowsTotal / this.pageSize)
let pageArr = []
for (let i = 0; i < pageTotal; i++) {
pageArr[i] = i
}
let pageChunk = []
let j = pageArr.length
for (let i = 0; i < j; i += this.pageSize) {
pageChunk.push(pageArr.slice(i, i + this.pageSize))
}
return pageChunk[this.pageChunkIndex]
},
pageTotal() {
let total = Math.ceil(this.rowsTotal / this.pageSize)
if (total === 1) {
this.isLast = true
this.isFirst = true
}
return Math.ceil(this.rowsTotal / this.pageSize)
},
isActive() {
let pageTotal = this.pageTotal
let o = {}
for (let i = 0; i < pageTotal; i++) {
o[i + 1] = 0
}
o['actived'] = this.page
o[this.page] = 1
return o
}
},
data() {
let pageTotal = this.pageTotal
let pageArr = []
for (let i = 0; i < pageTotal; i++) {
pageArr[i] = i
}
let pageChunk = []
let j = pageArr.length
for (let i = 0; i < j; i += this.pageSize) {
pageChunk.push(pageArr.slice(i, i + this.pageSize))
}
return {
pageChunk: pageChunk,
pageChunkIndex: 0,
isLast: false,
isFirst: true
return arr;
}
},
methods: {
nav(n) {
let activeObj = this.isActive
activeObj[activeObj['actived']] = 0
activeObj[n] = 1
activeObj['actived'] = n
n === 1 ? this.isFirst = true : this.isFirst = false
this.pageTotal === n ? this.isLast = true : this.isLast = false
this.page = n
this.$dispatch('page', this.page)
methods:{
nav(n){
this.currentPage=n;
this.$dispatch('page', this.currentPage);
},
next() {
let activeObj = this.isActive
if (activeObj.actived % this.pageSize === 0) {
this.pageChunkIndex += 1
this.pageChunkCurrent = this.pageChunk[this.pageChunkIndex]
}
if (activeObj.actived + 1 <= this.pageTotal) {
this.nav(activeObj.actived + 1)
prev(){
alert(this.currentPage);
if(this.currentPage>0){
this.nav(this.currentPage-1)
}
},
prev() {
let activeObj = this.isActive
if (activeObj.actived - 1 >= 1) {
this.nav(activeObj.actived - 1)
}
if (activeObj.actived % this.pageSize === 0) {
this.pageChunkIndex -= 1
this.pageChunkCurrent = this.pageChunk[this.pageChunkIndex]
next(){
if (this.currentPage < this.pages - 1) {
this.nav(o.currentPage + 1);
}
}
}
... ...
... ... @@ -32,7 +32,7 @@
</table>
</div>
<template v-if="pageAble">
<pagination :page-size="pageSize" :rows-total="rowsTotal" :page.sync="page"></pagination>
<pagination :page-size="pageSize" :pages="rowsTotal" :current-page.sync="page"></pagination>
</template>
</div>
</template>
... ... @@ -99,7 +99,7 @@
me.$dispatch('complete', res.data);
me.data = res.data.list;
me.rowsTotal = res.data.total;
me.rowsTotal = res.data.totalPage;
me.page = res.data.page
},function (response) {
me.rowsTotal=0;
... ... @@ -143,6 +143,7 @@
},
'page':function(page){
this.page=page;
console.log(page);
this.resquest();
}
},
... ...