yxk_h5_master/pages/daily/daily.vue

432 lines
11 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<view class="uni-flex uni-row">
<sl-filter :ref="'slFilter'" :menuList.sync="menuList" @result="filterConfirm"></sl-filter>
<view class="otherFixed1">
<view class="text " @click="selectOperater">{{userName.name}}</view>
<view class="text " @click="showSinglePicker">{{deptResult.name}}</view>
<view class="text" @click="filterDate">{{timeData.begin==''?'填报时间':(timeData.begin+'~'+timeData.end)}}</view>
</view>
</view>
<view class="mybox" v-if="listCards.length>0">
<view v-for="(item,index) in listCards" :key="index" class="example-box" style="position: relative;" @click="clickDetail(item)">
<repair-block :title="item.title" :titleNumber="item.titleNumber" :note="item.note" :approveState="item.status==148" @remove="remove(item)"
:extra="item.extra" :tagType="item.tagType"
:contentList="item.contentList"></repair-block>
<view class="smallTags" v-if="item.status == '146'">未提交</view>
</view>
<uni-load-more :status="loading_status" ></uni-load-more>
</view>
<view class="mybox" v-else>
<no-record ></no-record>
</view>
<view class="goHome" @click='goMain("dailyInfo")'>
<img src="../../static/img/gohome.png">
</view>
<view class="mysearchlist" style="z-index: 10000;">
<chooseUserSingle ref="mysearchlist"
:showsearch.sync="show_search_user"
:itemInfo_.sync="search_value_user">
</chooseUserSingle>
</view>
<uni-calendar ref="calendar" :lunar="false" :range="true" @confirm="confirmDate" @cancel='cancleData'/>
<lb-picker ref="picker" mode="multiSelector" :level="level" :pickerValueDefault="[0,0]"
@confirm="pickerConfirm" :props="myProps" :list="deptArray"></lb-picker>
</view>
</template>
<script>
import LbPicker from '@/components/lb-picker'
import mpvuePicker from '@/components/mpvue-picker/mpvuePicker.vue';
import slFilter from '@/components/xinsoft-sl-filter/xinsoft-sl-filter.vue';
import repairBlock from '@/components/xinsoft-dev-repair/xinsoft-dev-repair.vue'
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import noRecord from '@/components/xinsoft-no-record/xinsoft-no-record';
import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'
import chooseUserSingle from '@/components/xinsoft-search-list/chooseUserSingle.vue';
export default {
components: {
chooseUserSingle,LbPicker,slFilter,repairBlock,uniLoadMore,noRecord,uniCalendar,mpvuePicker
},
data() {
return {
show_search_user:false,
search_value_user:"",
current_num:2,
deptArray:[],
level:4,
myProps: {
label: 'text',
value: 'id',
children: 'children'
},
menuList: [{
'title': '发给我的',
'isMutiple': false,
'key': 'num',
'detailList': [
{
'title': '我发出的',
'value': 1
},
{
'title': '发给我的',
'value': 2
},
{
'title': '我的团队',
'value': 3
}
],
'defaultSelectedIndex':[1]
},
// {
// 'title': '填报人',
// 'isMutiple': false,
// 'key': 'userName',
// 'detailList': [],
// 'defaultSelectedIndex':[]
// }
],
listCards: [],
//上拉刷新,下拉加载
loading_status: 'more',//moreloading前、loadingloading中、noMore没有更多了
pageSize:5,
page:1,
filter:{},
//日历变量。
timeData:{
begin:"",
end:''
},
deptResult:{
value:'',
name:'部门'
},
userName:{
value:'',
name:'填报人'
},
userInfo:{}
}
},
onLoad() {
var _this = this;
this.userInfo = uni.getStorageSync('userInfo');
this.filter = {
beSentPeopleId :this.userInfo.userId
}
// this.getDept('');
this.getDept(this.userInfo.deptId);
//人员
this.$http.request({
url: '/apis/common/getUsers',
params:{
deptId:this.userInfo.deptId
}
}).then(res=>{
if(res.statusCode == '200'){
_this.menuList[1].detailList = [
{
'title': '不限',
'value': ''
}
];
var useType = res.data.datas;
for (let i = 0; i < useType.length; i++) {
var myVal=
{
'title': useType[i].name,
// 'value': useType[i].id,
'value': useType[i].name
}
_this.menuList[1].detailList.push(myVal);
}
}
}).catch(err=>{
});
//初始化当前列表。
this.dataList();
},
onReachBottom: function() {
//下拉刷新的时候请求一次数据
if(this.loading_status=='noMore'){
return false;
}
this.page++;
this.dataList();
},
onPullDownRefresh: function() {
this.listCards=[];
this.page=1;
this.loading_status="more";
//触底的时候请求数据,即为上拉加载更多
this.dataList();
},
watch:{
search_value_user(newv){
// this.$set(this.dataList[this.currentIndex],'operator',newv.userId);
this.$set(this.userName,'name',newv.NAME);
this.filter.userName = newv.NAME;
this.listCards=[];
this.page=1;
this.loading_status="more";
this.dataList();
},
},
methods: {
remove(val){
this.$http.request({
url: '/apis/dailyReport/batchRemove',
method:'POST',
params:{'ids':val.id},
header: {
// "content-type": 'application/json'
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(res=>{
if(res.data.code==0){
uni.showToast({
title: '操作成功',
duration: 1000,
icon:"none"
});
}else if(res.data.code ==500){
uni.showToast({
title: res.data.msg,
duration: 1000,
icon:"none"
});
}
this.listCards=[];
this.page=1;
this.dataList(this.current_num)
})
},
// 选择填表人
selectOperater(){
this.show_search_user=true;
},
getDept(deptId){
//使用部门
this.$http.request({
url: '/apis/dept/tree',
params:{
deptId:deptId
},
method:'GET',
}).then(res=>{
if(res.statusCode == '200'){
this.deptArray =res.data.data.children
}
}).catch(err=>{
console.log(err);
});
},
filterConfirm(f){
//筛选成功。
var num = f.num;
if(num == 1 || num == ''){
this.filter = {
userId :this.userInfo.userId
}
}else if(num == 2){
this.filter = {
beSentPeopleId:this.userInfo.userId
}
// this.deptResult={
// value:'',
// name:'部门'
// };
// this.getDept('');
}else if(num == 3){
this.filter = {
deptId:this.userInfo.deptId
}
// this.deptResult={
// value:'',
// name:'部门'
// };
// this.getDept(this.userInfo.deptId)
}
this.current_num = num;
// this.filter.userName = f.userName;
this.listCards=[];
this.page=1;
this.loading_status="more";
this.dataList();
},
dataList(){
this.loading_status="loading";
var filterRes = this.filter;
filterRes.pageno = this.page;
filterRes.pagesize = this.pageSize;
filterRes.startTime = this.timeData.begin;
filterRes.endTime = this.timeData.end;
filterRes.deptId = (this.deptResult.value || this.filter.deptId || '' )
this.$http.request({
url: '/apis/dailyReport/list',
params:filterRes,
}).then(res=>{
uni.stopPullDownRefresh();
if(!res.data.data){
this.loading_status="noMore";
}else if(res.data.data.datas.length<this.pagesize){
this.loading_status="noMore";
}else{
this.loading_status="more";
}
if(res.data.code == 0){
if(res.data.data.datas.length>0){
this.listCards = this.listCards.concat(this.formaterData(res.data.data.datas));
}
}
}).catch(err=>{
this.loading_status="noMore";
});
},
clickDetail(item){
//点击详情
if(item.status == '148'){
uni.navigateTo({
url: 'dailyDetail?id='+item.id+'&num='+this.current_num
});
}else{
uni.removeStorageSync('dailyInfo');
//再次编辑。
uni.navigateTo({
url: 'addDaily?id='+item.id
});
}
},
showSinglePicker() {
//关闭之前filter。
// document.getElementById("popupRef").style.display="none";
this.$refs.picker.show()
},
pickerConfirm(e){
var value = e.value;
console.log(value)
var name = ''
this.filter.deptId = ''
if(value[1] == '-') {
name = e.item[0].text
this.deptResult.value = value[0]
} else {
this.deptResult.value = value[2]?value[2]:value[1];
if(value[2]){
// name = name.substring(0,name.length-2);
name = e.item[0].text+'/'+e.item[1].text+'/'+e.item[2].text
} else {
name = e.item[0].text+'/'+e.item[1].text
}
}
console.log(this.deptResult.value)
this.deptResult.name = name;
this.listCards=[];
this.page=1;
this.loading_status="more";
this.dataList();
},
formaterData(data){
var resData = [];
data.forEach((vals,index)=>{
var combineJSON = {
id: vals.id,
title: vals.createTime?(vals.createTime .split(' ')[0]+'工作日志'):'工作日志',
titleNumber:'姓名:'+(vals.userName||'')+' 部门:'+(vals.deptName||''),
contentList: [
{
id:1,
isDouble:false,
labelName:'今日完成工作',
labelContent:vals.comContent
},
{
id:2,
isDouble:false,
labelName:'未完成工作',
labelContent:vals.uncomCOntent||''
},
{
id:3,
isDouble:false,
labelName:'明日必做事项',
labelContent:vals.mustContent||''
},
{
id:4,
isDouble:false,
labelName:'待办事项',
labelContent:vals.waitContent||''
},
],
note: this.setNotes(vals.status),
status:vals.status
}
resData.push(combineJSON);
});
return resData;
},
setNotes(status){
if(status == '148'){
return '详情'
}else{
return '编辑'
}
},
filterDate() {
//关闭之前filter。
// document.getElementById("popupRef").style.display="none";
this.$refs.calendar.open();
},
confirmDate(e){
if(e.range.begin && e.range.end){
this.timeData = {
begin:e.range.begin+' 00:00:00',
end:e.range.end+' 00:00:00'
}
this.listCards=[];
this.page=1;
this.loading_status="more";
this.dataList();
}
}
},
onNavigationBarButtonTap(obj) {
//重置下
uni.removeStorageSync('dailyInfo');
uni.navigateTo({
url: 'addDaily'
});
},
onBackPress(options) { //取消默认的返回事件.
uni.switchTab({
url: "../main/main"
});
return true;
}
}
</script>
<style scoped>
>>>.dev-repair__header{
border-bottom: 1px solid #EDEDED;
}
>>>.select-tab-fixed-top{
left: 0;
width: 50%;
}
>>>.picker-item .lb-picker-column .lb-picker-column-label {
-webkit-transition: all 0.3s;
transition: all 0.3s;
line-height: 3.8 !important;
}
</style>