shish 1 месяц назад
Родитель
Сommit
0be922c0f9

+ 362 - 0
ghsApp/src/admin/ghs/balanceChange.vue

@@ -0,0 +1,362 @@
+<template>
+	<view class="bc-page">
+		<view v-if="hasList" class="bc-sheet">
+			<view class="bc-head">
+				<text class="bc-th bc-th--time">时间</text>
+				<text class="bc-th bc-th--event">事项</text>
+				<text class="bc-th bc-th--amt">变动</text>
+				<text class="bc-th bc-th--bal">余额</text>
+			</view>
+			<view class="bc-body">
+				<view
+					v-for="(item, index) in list.data"
+					:key="index"
+					class="bc-item"
+					:class="{ 'bc-item--alt': index % 2 === 1 }"
+				>
+					<view
+						class="bc-row-main"
+						:class="{ 'bc-row-main--with-extra': item.showExtraRow }"
+						@click="goDetail(item)"
+					>
+						<view class="bc-td bc-td--time">
+							<text class="bc-date">{{ item.dateText }}</text>
+							<text class="bc-clock">{{ item.timeLine }}</text>
+						</view>
+						<view class="bc-td bc-td--event">
+							<text class="bc-event">{{ item.event }}</text>
+							<text v-if="item.showStaff" class="bc-meta">{{ item.staffName }}</text>
+							<text v-if="item.showRemark" class="bc-meta bc-meta--remark">{{ item.remark }}</text>
+						</view>
+						<view class="bc-td bc-td--amt">
+							<text class="bc-amount" :class="item.amountClassName">{{ item.amount }}</text>
+						</view>
+						<view class="bc-td bc-td--bal">
+							<text class="bc-balance">{{ item.balanceText }}</text>
+						</view>
+					</view>
+					<view v-if="item.showExtraRow" class="bc-row-extra" @click.stop>
+						<view class="bc-tags-row">
+							<text
+								v-if="item.showClearLink"
+								class="bc-tag bc-tag--link"
+								@click.stop="goClear(item)"
+							>{{ item.clearLinkText }}</text>
+						</view>
+					</view>
+				</view>
+			</view>
+		</view>
+		<AppWrapperEmpty v-else title="暂无数据" :is-empty="listEmpty" />
+	</view>
+</template>
+<script>
+import AppWrapperEmpty from '@/components/app-wrapper-empty'
+import { balanceChangeList } from '@/api/ghs'
+import list from '@/mixins/list'
+
+export default {
+	name: 'ghsBalanceChange',
+	components: {
+		AppWrapperEmpty
+	},
+	mixins: [list],
+	computed: {
+		hasList() {
+			return this.list.data && this.list.data.length > 0
+		},
+		listEmpty() {
+			return !this.hasList
+		}
+	},
+	methods: {
+		formatMoney(val) {
+			const n = parseFloat(val)
+			return isNaN(n) ? '0' : String(n)
+		},
+		hasText(val) {
+			return val !== undefined && val !== null && String(val).trim() !== ''
+		},
+		isPurchaseClearRow(row) {
+			const event = String(row.event || '')
+			return Number(row.relateId) > 0 && event.indexOf('采购单结账') === 0
+		},
+		mapListItem(item, amountDisplay) {
+			const row = Object.assign({}, item)
+			row.amount = amountDisplay
+			const text = String(amountDisplay || '')
+			row.amountClassName = (text.indexOf('+') === 0 || Number(row.io) === 1) ? 'bc-amount--in' : 'bc-amount--out'
+			const addTime = row.addTime || ''
+			if (addTime.length >= 16) {
+				row.dateText = addTime.substr(5, 5)
+				row.timeLine = addTime.substr(11, 5)
+			} else if (addTime.length >= 11) {
+				row.dateText = addTime.substr(0, 10)
+				row.timeLine = addTime.substr(11)
+			} else {
+				row.dateText = addTime
+				row.timeLine = ''
+			}
+			row.balanceText = this.formatMoney(row.balance)
+			row.showClearLink = this.isPurchaseClearRow(row)
+			row.clearLinkText = row.showClearLink ? '查看结账单' : ''
+			row.showStaff = this.hasText(row.staffName)
+			row.showRemark = this.hasText(row.remark)
+			row.showExtraRow = row.showClearLink
+			return row
+		},
+		async init() {
+			const res = await balanceChangeList({
+				page: this.list.page,
+				ghsId: this.option.ghsId
+			})
+			if (this.$util.isEmpty(res.data.list)) {
+				this.completes(res)
+				return
+			}
+			const rows = []
+			res.data.list.forEach((item) => {
+				const amountDisplay = item.io == 0 ? '-' + parseFloat(item.amount) : '+' + parseFloat(item.amount)
+				rows.push(this.mapListItem(item, amountDisplay))
+			})
+			res.data.list = rows
+			this.completes(res)
+		},
+		goDetail(item) {
+			if (this.isPurchaseClearRow(item)) {
+				this.$util.pageTo({ url: '/admin/clear/info?id=' + item.relateId })
+			}
+		},
+		goClear(item) {
+			if (Number(item.relateId) > 0) {
+				this.$util.pageTo({ url: '/admin/clear/info?id=' + item.relateId })
+			}
+		}
+	},
+	async onPullDownRefresh() {
+		this.resetList()
+		await this.init()
+		uni.stopPullDownRefresh()
+	},
+	async onReachBottom() {
+		if (!this.list.finished) {
+			await this.init()
+		}
+		uni.stopPullDownRefresh()
+	}
+}
+</script>
+<style lang="scss" scoped>
+.bc-page {
+	min-height: 100vh;
+	background: #fff;
+	box-sizing: border-box;
+}
+
+.bc-sheet {
+	width: 100%;
+	background: #fff;
+}
+
+.bc-head {
+	display: flex;
+	align-items: center;
+	padding: 22upx 0;
+	background: #f8f9fb;
+	border-bottom: 1upx solid #eceef2;
+}
+
+.bc-th {
+	font-size: 28upx;
+	color: #8c8c8c;
+	font-weight: 500;
+	line-height: 1.2;
+}
+
+.bc-th--time {
+	width: 100upx;
+	flex-shrink: 0;
+	padding-left: 8upx;
+	box-sizing: border-box;
+}
+
+.bc-th--event {
+	flex: 1;
+	min-width: 0;
+	padding-right: 12upx;
+}
+
+.bc-th--amt {
+	width: 118upx;
+	flex-shrink: 0;
+	text-align: right;
+}
+
+.bc-th--bal {
+	width: 140upx;
+	flex-shrink: 0;
+	padding-right: 8upx;
+	text-align: right;
+	box-sizing: border-box;
+}
+
+.bc-item {
+	border-bottom: 1upx solid #f2f3f5;
+	box-sizing: border-box;
+}
+
+.bc-item:last-child {
+	border-bottom: none;
+}
+
+.bc-item--alt {
+	background: #fafbfc;
+}
+
+.bc-row-main {
+	display: flex;
+	align-items: flex-start;
+	padding: 24upx 0;
+	box-sizing: border-box;
+}
+
+.bc-row-main--with-extra {
+	padding-bottom: 0;
+}
+
+.bc-item:active .bc-row-main,
+.bc-item:active .bc-row-extra {
+	background: #f0f4ff;
+}
+
+.bc-row-extra {
+	width: 100%;
+	padding: 12upx 0 20upx;
+	box-sizing: border-box;
+}
+
+.bc-tags-row {
+	display: flex;
+	flex-direction: row;
+	flex-wrap: wrap;
+	align-items: flex-start;
+	width: 100%;
+	padding-left: 8upx;
+	padding-right: 8upx;
+	box-sizing: border-box;
+}
+
+.bc-td--time {
+	width: 100upx;
+	flex-shrink: 0;
+	padding-left: 8upx;
+	display: flex;
+	flex-direction: column;
+	align-items: flex-start;
+	justify-content: center;
+	box-sizing: border-box;
+}
+
+.bc-td--event {
+	flex: 1;
+	min-width: 0;
+	padding-right: 12upx;
+}
+
+.bc-td--amt {
+	width: 118upx;
+	flex-shrink: 0;
+	padding-right: 8upx;
+	display: flex;
+	justify-content: flex-end;
+	box-sizing: border-box;
+}
+
+.bc-td--bal {
+	width: 140upx;
+	flex-shrink: 0;
+	padding-right: 8upx;
+	display: flex;
+	justify-content: flex-end;
+	box-sizing: border-box;
+}
+
+.bc-date {
+	font-size: 28upx;
+	color: #2c2c2c;
+	line-height: 1.35;
+}
+
+.bc-clock {
+	margin-top: 4upx;
+	font-size: 28upx;
+	color: #2c2c2c;
+	line-height: 1.35;
+}
+
+.bc-event {
+	display: block;
+	font-size: 28upx;
+	color: #1a1a1a;
+	font-weight: 500;
+	line-height: 1.45;
+	word-break: break-all;
+}
+
+.bc-meta {
+	display: block;
+	margin-top: 8upx;
+	font-size: 22upx;
+	color: #999;
+	line-height: 1.4;
+	word-break: break-all;
+}
+
+.bc-meta--remark {
+	color: #b3b3b3;
+}
+
+.bc-tag {
+	display: block;
+	max-width: 100%;
+	padding: 6upx 14upx;
+	margin-top: 10upx;
+	margin-right: 12upx;
+	font-size: 28upx;
+	line-height: 1.4;
+	border-radius: 8upx;
+	word-break: break-all;
+	box-sizing: border-box;
+}
+
+.bc-tags-row .bc-tag:first-child {
+	margin-top: 0;
+}
+
+.bc-tag--link {
+	color: #969aa0;
+	background: #eef4ff;
+}
+
+.bc-amount {
+	font-size: 28upx;
+	font-weight: 600;
+	line-height: 1.35;
+	font-variant-numeric: tabular-nums;
+}
+
+.bc-amount--in {
+	color: #07a84c;
+}
+
+.bc-amount--out {
+	color: #e62e45;
+}
+
+.bc-balance {
+	font-size: 28upx;
+	color: #131212;
+	line-height: 1.35;
+	font-variant-numeric: tabular-nums;
+}
+</style>

+ 4 - 0
ghsApp/src/api/ghs/index.js

@@ -29,4 +29,8 @@ export const getList = data => {
 
 export const getGhsDebtRecord = data => {
 	return https.get('/ghs-debt-record/list', data)
+}
+
+export const balanceChangeList = data => {
+	return https.get('/ghs-balance-change/list', data)
 }

+ 2 - 1
ghsApp/src/pages.json

@@ -163,7 +163,8 @@
 			"root": "admin/ghs",
 			"pages": [
 				{"path": "shop","style": {"navigationBarTitleText": "供货商"}},
-				{"path": "debtChange","style": {"navigationBarTitleText": "挂账变动明细"}}
+				{"path": "debtChange","style": {"navigationBarTitleText": "挂账变动明细"}},
+				{"path": "balanceChange","style": {"navigationBarTitleText": "余额变动明细","enablePullDownRefresh": false}}
 			]
 		},
 		{

+ 14 - 3
ghsApp/src/pagesPurchase/supplier.vue

@@ -47,6 +47,10 @@
               </view>
               <!-- 下拉菜单内容 -->
               <view class="more-dropdown" v-if="activeMenuId === item.id">
+                <view class="dropdown-item" hover-class="none" @click.stop="handleDebtChangeFromMenu(item)">
+                  <text class="dropdown-icon">📋</text>
+                  <text class="dropdown-text">挂账变动明细</text>
+                </view>
                 <view class="dropdown-item" hover-class="none" @click.stop="handleDeleteFromMenu(item)">
                   <text class="dropdown-icon">🗑</text>
                   <text class="dropdown-text">删除供货商</text>
@@ -72,7 +76,7 @@
           <view class="record-section" v-if="tabs[tabIndex].delStatus === 0">
             <view class="record-buttons">
               <view class="record-btn" hover-class="none" @click.stop="pageTo({ url: '/admin/clear/list?ghsId='+item.id})">结账记录</view>
-              <view class="record-btn" hover-class="none" @click.stop="getDebtList(item)">挂账变动明细</view>
+              <view class="record-btn" hover-class="none" @click.stop="getBalanceList(item)">余额变动明细</view>
               <view class="record-btn" hover-class="none" @click.stop="cgList(item)">采购记录</view>
             </view>
           </view>
@@ -237,8 +241,15 @@ export default {
 		addGhs(){
 			this.pageTo({url:'/pagesPurchase/suppAdd'})
 		},
-    getDebtList(item){
-      this.pageTo({url:'/admin/ghs/debtChange?ghsId='+item.id})
+    getBalanceList(item) {
+      this.pageTo({ url: '/admin/ghs/balanceChange?ghsId=' + item.id })
+    },
+    getDebtList(item) {
+      this.pageTo({ url: '/admin/ghs/debtChange?ghsId=' + item.id })
+    },
+    handleDebtChangeFromMenu(item) {
+      this.activeMenuId = null
+      this.getDebtList(item)
     },
     init() {
       this.getGhsList()