Commit 005fb4fc authored by Facius's avatar Facius

Merge branch 'lyf-shouchang'

parents 00d9b67e c0fdb186
......@@ -351,6 +351,15 @@
"enablePullDownRefresh": false,
"disableScroll": true
}
}, {
"path": "charges",
"name": "charges",
"style": {
"navigationBarTitleText": "收费项",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
}, {
"path": "detail",
"name": "maintain-bill-detail",
......
<template>
<view class="charges-view">
<NavbarRight title="收费项" />
<view class="tabs-view">
<u-tabs height="62" activeColor="#02A074" inactive-color="#333333" bg-color="#F6F7FA" bar-height="4"
bar-width="40" :bar-style="{ 'background-color': '#02A074' }" :list="tabs" :page="current" @change="change"
font-size="32" bold></u-tabs>
</view>
<view class="title-view">
<view class="left-view">项目名称</view>
<view class="right-view">单位</view>
</view>
<view class="content-view">
<scroll-view scroll-y style="height: 100%; width: 100%" @scrolltolower="reachBottom" scroll-anchoring
refresher-enabled="true" :refresher-triggered="triggered" :refresher-threshold="100"
refresher-background="#F6F7FA" @refresherrefresh="onRefresh" @refresherrestore="onRestore" enable-back-to-top>
<view class="list-view" v-if="charges && charges.length > 0">
<view v-for="(item, index) in charges" :key="index" class="item-view">
<CellCharge :info="item" @select="handleSelect" @collect="handleCollect" />
</view>
<view class="load-more-view" v-show="(page == 1 && !loading) || page > 1">
<u-loadmore :status="loadStatus" bgColor="#F6F7FA"></u-loadmore>
</view>
</view>
<NoData v-else-if="!loading" customStyle="margin-top:100rpx" :image="noData.image" :text="noData.text" />
</scroll-view>
</view>
<view class="loading-view" v-if="loading && !freshing">
<u-loading mode="flower"></u-loading>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import NavbarRight from '@/components/navbar-right';
import CellCharge from './components/cell-charge';
import NoData from '@/components/no-data';
import { getChargeList, updateCharge } from '@/api/project/index.js';
export default {
components: {
NavbarRight,
CellCharge,
NoData
},
data () {
return {
charges: [],
loading: true,
loadStatus: 'loading',
triggered: true,
freshing: false,
current: 0,
page: 1,
size: 15,
};
},
computed: {
baseUrl () {
return process.uniEnv.qn_base_url;
},
tabs () {
return [{
name: '最近使用'
}, {
name: '我的收藏'
}]
},
noData () {
return {
image: this.baseUrl + 'wuweixiuzhangdan@3x.png',
text: '当前暂无相关信息'
};
},
},
onLoad (options) {
this.freshing = false;
this.reloadList();
},
methods: {
reloadList () {
this.page = 1;
this.loadStatus = 'loading';
this.getChargeList();
},
getChargeList () {
if (this.page == 1) {
this.loading = true;
}
// getChargeList({
// page: this.page,
// collect: this.current,
// size: this.size,
// })
// .then(res => {
var res = {
data: {
records: [
{
id: '1',
name: '服务',
collect: true,
unit: '米',
},
{
id: '2',
name: '线缆',
collect: false,
unit: '米',
},
{
id: '3',
name: '螺丝',
collect: true,
unit: '个',
}
]
}
}
let data = res.data;
if (this.page == 1) {
this.charges = [];
}
if (data.records) {
this.charges.push(...data.records);
this.loadStatus = data.total > this.charges.length ? 'loadmore' : 'nomore';
} else {
this.loadStatus = 'nomore'
}
this.$nextTick(() => {
if (this.freshing) {
this.triggered = false;
this.freshing = false;
}
});
this.loading = false;
// })
// .catch(err => {
// this.loading = false;
// console.log(err);
// });
},
change () {
this.current = index
this.reloadList()
},
onRefresh () {
if (this.freshing) return;
this.freshing = true;
this.reloadList();
},
onRestore () {
this.triggered = 'restore'; // 需要重置
},
// 滚动底部
reachBottom (e) {
if (this.loadStatus != 'loadmore') return;
this.page += 1;
this.loadStatus == 'loading';
this.getChargeList();
},
handleCollect (id, collect) {
for (var item of this.charges) {
if (item.id == id) {
item.collect = collect
// this.updateCharge(id)
this.$refs.uToast.show({
title: collect ? '收藏成功' : '取消成功',
type: 'success',
duration: 1500,
callback: () => {
}
});
break
}
}
},
updateCharge (id) {
updateCharge({
id: id
})
.then(res => {
let data = res.data;
if (data) {
}
})
.catch(err => {
for (var item of this.employees) {
if (item.id == id) {
item.collect = !item.collect
break
}
}
console.log(err);
});
},
handleSelect (item) {
uni.$emit('charge-selected', JSON.stringify(item))
this.$u.route({
type: 'navigateBack',
params: {
}
});
},
}
};
</script>
<style scoped lang="scss">
.charges-view {
display: flex;
flex-direction: column;
height: 100vh;
background-color: #f6f7fa;
.tabs-view {
display: flex;
justify-content: center;
align-items: center;
}
.title-view {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #8D8D8D;
margin: 32rpx 24rpx 24rpx 24rpx;
.left-view {
margin-left: 24rpx;
}
.right-view {
width: 168rpx;
text-align: left;
}
}
.content-view {
height: 100%;
padding: 0rpx 24rpx;
overflow: auto;
.list-view {
.item-view {
margin: 0 0 24rpx 0;
}
}
.load-more-view {
padding-bottom: 44rpx;
}
}
.loading-view {
width: 100%;
background-color: transparent;
display: flex;
align-items: center;
justify-content: center;
top: 50%;
left: 0;
position: fixed;
}
}
</style>
<template>
<view class="cell-charge" @click="$u.throttle(handleClickCell, 500)">
<view class="left-view">{{ info.name }}</view>
<view class="right-view">
<view class="unit-view">{{info.unit}}</view>
<view class="collect-view" @click.stop="$u.throttle(handleSelect, 500)" hover-class="u-hover-class">
<image :src="collectImage" class="collect-image"></image>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
info: {
type: Object,
default () {
return {
id: '',
name: '',
collect: '',
unit: '',
}
},
}
},
data () {
return {}
},
computed: {
baseUrl () {
return process.uniEnv.qn_base_url
},
collectImage () {
return this.baseUrl + (this.info.collect ? 'dianjishoucang1@3x.png' : 'shoucangshoufei0@3x.png')
},
},
created () { },
methods: {
handleSelect () {
this.info.collect = !this.info.collect
this.$emit('collect', this.info.id, this.info.collect)
},
handleClickCell () {
this.$emit('select', { ...this.info })
}
},
}
</script>
<style scoped lang="scss">
.cell-charge {
display: flex;
justify-content: space-between;
align-items: center;
font-weight: bold;
color: #333333;
font-size: 28rpx;
padding: 0 0 0 24rpx;
min-height: 112rpx;
border-radius: 16rpx;
background-color: #ffffff;
.left-view {
min-width: 440rpx;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.right-view {
display: flex;
justify-content: flex-end;
align-items: center;
.unit-view {}
.collect-view {
margin-left: 56rpx;
width: 80rpx;
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
.collect-image {
width: 32rpx;
height: 32rpx;
}
}
}
}
</style>
......@@ -9,9 +9,10 @@
<view class="part-view">
<view class="item-view">
<view class="label-view">收费项</view>
<view class="value-view">
<view class="value-view charge-view">
<u-input type="text" :clearable="false" :custom-style="customStyle" cursor-spacing='50' :placeholder-style="placeholderStyle" v-model="form.name" placeholder="填写费用名称" @blur="leaveInput"
@focus="getHeight" />
<ab-button content="常用" :customStyle="customStyleUnit" @click="chooseCharge"></ab-button>
</view>
</view>
<view class="line-view"></view>
......@@ -118,9 +119,11 @@ export default {
'margin-left': '24rpx',
width: '72rpx',
height: '40rpx',
'font-size': '24rpx',
background: '#02A074',
'border-radius': '8rpx'
'font-size': '20rpx',
background: 'transparent',
'border-radius':' 8rpx',
border:' 2rpx solid #02A074',
color: '#02A074',
},
customStyleSubmit:{
width: '240rpx',
......@@ -164,6 +167,16 @@ export default {
return flag;
}
},
created() {
uni.$on('charge-selected', res => {
var form = JSON.parse(res || {})
this.form.unit = form.unit
this.form.name = form.name
});
},
destroyed() {
uni.$off('charge-selected')
},
methods: {
open(detail) {
if(detail&&detail.uid){
......@@ -228,6 +241,14 @@ export default {
chooseUnit() {
this.$refs['unit-popup'].open()
},
chooseCharge() {
this.$u.route({
url: '/pages/maintain-bill/charges',
type: 'navigateTo',
params: {
}
});
},
handleChangeUnit(e){
this.form.unit=e
}
......@@ -283,6 +304,11 @@ export default {
color: #333333;
text-align: right;
}
.charge-view {
display: flex;
justify-content: flex-end;
align-items: center;
}
.number-view{
display: flex;
align-items: center;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment