From dfe413e25a9684a2d0efedbf26603bc0e48da9bb Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 13 八月 2025 13:20:24 +0800
Subject: [PATCH] 1.销售台账模块开发联调
---
src/pages.json | 7 +
src/pages/sales/salesAccount/view.vue | 311 ++++++++++++++++++++++++++++++++++++++++++++
src/pages/sales/salesAccount/detail.vue | 16 +
src/config.js | 4
src/pages/sales/salesAccount/index.vue | 71 ++++++---
5 files changed, 377 insertions(+), 32 deletions(-)
diff --git a/src/config.js b/src/config.js
index 47daed0..65baaa4 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,7 +1,7 @@
// 搴旂敤鍏ㄥ眬閰嶇疆
const config = {
- // baseUrl: 'http://114.132.189.42:8089', // 娴嬭瘯搴�
- baseUrl: 'http://192.168.1.147:7003', // 鏈湴鑱旇皟
+ baseUrl: 'http://114.132.189.42:8089', // 娴嬭瘯搴�
+ // baseUrl: 'http://192.168.1.147:7003', // 鏈湴鑱旇皟
//cloud鍚庡彴缃戝叧鍦板潃
// baseUrl: 'http://192.168.10.3:8080',
// 搴旂敤淇℃伅
diff --git a/src/pages.json b/src/pages.json
index ef5ee74..491f7f1 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -59,6 +59,13 @@
{
"path": "pages/sales/salesAccount/detail",
"style": {
+ "navigationBarTitleText": "淇敼鍙拌处",
+ "navigationStyle": "custom"
+ }
+ },
+ {
+ "path": "pages/sales/salesAccount/view",
+ "style": {
"navigationBarTitleText": "鍙拌处璇︽儏",
"navigationStyle": "custom"
}
diff --git a/src/pages/sales/salesAccount/detail.vue b/src/pages/sales/salesAccount/detail.vue
index 56c92a9..d5b2522 100644
--- a/src/pages/sales/salesAccount/detail.vue
+++ b/src/pages/sales/salesAccount/detail.vue
@@ -58,9 +58,9 @@
</van-popup>
<van-field label="浠樻鏂瑰紡" name="paymentMethod" borderBottom="true" v-model="form.paymentMethod" placeholder="璇疯緭鍏ヤ粯娆炬柟寮�">
</van-field>
- <van-field label="褰曞叆浜�" name="entryPersonName" borderBottom="true" v-model="form.entryPersonName" placeholder="璇疯緭鍏�" readonly>
+ <van-field label="褰曞叆浜�" name="entryPersonName" borderBottom="true" v-model="form.entryPersonName" placeholder="璇疯緭鍏�" disabled>
</van-field>
- <van-field label="褰曞叆鏃ユ湡" name="entryDate" borderBottom="true" v-model="form.entryDate" placeholder="璇疯緭鍏�" readonly>
+ <van-field label="褰曞叆鏃ユ湡" name="entryDate" borderBottom="true" v-model="form.entryDate" placeholder="璇疯緭鍏�" disabled>
</van-field>
<van-popup v-model:show="showPicker" destroy-on-close position="bottom">
<van-picker
@@ -129,7 +129,7 @@
<view class="product-section">
<view class="section-header">
<text class="section-title">浜у搧淇℃伅</text>
- <van-button type="primary" size="small" @click="addProduct" class="add-btn" icon="plus">鏂板</van-button>
+ <van-button type="primary" size="small" @click="addProduct" class="add-btn" icon="plus" v-if="operationType !== 'view'">鏂板</van-button>
</view>
<view class="product-card" v-for="(product, idx) in productData" :key="idx">
<!-- 浜у搧绫� -->
@@ -139,7 +139,7 @@
<text class="product-productCategory">浜у搧 {{ idx + 1 }}</text>
</view>
<!-- 鎿嶄綔鎸夐挳 -->
- <view class="product-actions">
+ <view class="product-actions" v-if="operationType !== 'view'">
<van-button type="danger" size="mini" @click="removeProduct(idx)" class="del-btn" icon="delete">鍒犻櫎</van-button>
</view>
</view>
@@ -258,7 +258,7 @@
</view>
</view>
</view>
- <view class="footer-btns">
+ <view class="footer-btns" v-if="operationType !== 'view'">
<van-button class="cancel-btn" @click="goBack">鍙栨秷</van-button>
<van-button class="save-btn" native-type="submit" form-type="submit">淇濆瓨</van-button>
</view>
@@ -343,6 +343,9 @@
]);
const addProduct = () => {
+ if (productData.value === null) {
+ productData.value = []
+ }
productData.value.push({
productCategory: '',
specificationModel: '',
@@ -596,6 +599,7 @@
title: '璇锋坊鍔犱骇鍝佷俊鎭�',
icon: 'none'
});
+ return
}
form.value.type = 1;
addOrUpdateSalesLedger(form.value).then((res) => {
@@ -724,7 +728,7 @@
try {
editData.value = JSON.parse(editDataStr);
// 濡傛灉鏄紪杈戞ā寮忥紝绛夊緟鏁版嵁鍔犺浇瀹屾垚鍚庡~鍏呰〃鍗曟暟鎹�
- if (operationType.value === 'edit' && editData.value) {
+ if (operationType.value !== 'add' && editData.value) {
// 浣跨敤 nextTick 纭繚鏁版嵁鍔犺浇瀹屾垚鍚庡啀濉厖
setTimeout(() => {
fillFormData();
diff --git a/src/pages/sales/salesAccount/index.vue b/src/pages/sales/salesAccount/index.vue
index 7f93241..336e593 100644
--- a/src/pages/sales/salesAccount/index.vue
+++ b/src/pages/sales/salesAccount/index.vue
@@ -102,6 +102,8 @@
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import {ledgerListPage} from "@/api/salesManagement/salesLedger";
+import useUserStore from "@/store/modules/user";
+const userStore = useUserStore()
// 鎼滅储鍏抽敭璇�
const searchKeyword = ref('');
@@ -127,33 +129,54 @@
// tableLoading.value = false;
});
};
-// 鏄剧ず绛涢�夐�夐」
-const showFilterOptions = () => {
- uni.showActionSheet({
- itemList: ['鎸夋棩鏈熺瓫閫�', '鎸夌姸鎬佺瓫閫�', '鎸夐噾棰濈瓫閫�'],
- success: (res) => {
- console.log('閫夋嫨浜嗙瓫閫夐�夐」:', res.tapIndex);
- }
- });
-};
-// 鐐瑰嚮鍒楄〃椤�
-const handleItemClick = (item) => {
- uni.showToast({
- title: `鏌ョ湅鍚堝悓: ${item.contractId}`,
- icon: 'none'
- });
-};
-
-// 娣诲姞鏂拌褰�
+// 澶勭悊鍙拌处淇℃伅鎿嶄綔锛堟煡鐪�/缂栬緫/鏂板锛�
const handleInfo = (type, row) => {
- uni.setStorageSync('operationType', type);
- if (row) {
- uni.setStorageSync('editData', JSON.stringify(row));
+ try {
+ // 璁剧疆鎿嶄綔绫诲瀷
+ uni.setStorageSync('operationType', type);
+
+ // 濡傛灉鏄煡鐪嬫垨缂栬緫鎿嶄綔
+ if (type !== 'add') {
+ // 楠岃瘉琛屾暟鎹槸鍚﹀瓨鍦�
+ if (!row) {
+ uni.showToast({
+ title: '鏁版嵁涓嶅瓨鍦�',
+ icon: 'error'
+ });
+ return;
+ }
+
+ // 妫�鏌ユ潈闄愶細鍙湁褰曞叆浜烘墠鑳界紪杈�
+ if (row.entryPerson !== userStore.id) {
+ // 闈炲綍鍏ヤ汉璺宠浆鍒板彧璇昏鎯呴〉闈�
+ uni.setStorageSync('editData', JSON.stringify(row));
+ uni.navigateTo({
+ url: '/pages/sales/salesAccount/view'
+ });
+ return;
+ }
+
+ // 褰曞叆浜虹紪杈戯細瀛樺偍鏁版嵁骞惰烦杞埌缂栬緫椤甸潰
+ uni.setStorageSync('editData', JSON.stringify(row));
+ uni.navigateTo({
+ url: '/pages/sales/salesAccount/detail'
+ });
+ return;
+ }
+
+ // 鏂板鎿嶄綔锛氱洿鎺ヨ烦杞埌缂栬緫椤甸潰
+ uni.navigateTo({
+ url: '/pages/sales/salesAccount/detail'
+ });
+
+ } catch (error) {
+ console.error('澶勭悊鍙拌处淇℃伅鎿嶄綔澶辫触:', error);
+ uni.showToast({
+ title: '鎿嶄綔澶辫触锛岃閲嶈瘯',
+ icon: 'error'
+ });
}
- uni.navigateTo({
- url: '/pages/sales/salesAccount/detail'
- });
};
onShow(() => {
diff --git a/src/pages/sales/salesAccount/view.vue b/src/pages/sales/salesAccount/view.vue
new file mode 100644
index 0000000..99a76b2
--- /dev/null
+++ b/src/pages/sales/salesAccount/view.vue
@@ -0,0 +1,311 @@
+<template>
+ <view class="account-view">
+ <!-- 椤堕儴鏍囬鏍� -->
+ <view class="header">
+ <up-icon name="arrow-left" size="20" color="#333" @click="goBack" />
+ <text class="title">鍙拌处璇︽儏</text>
+ </view>
+
+ <!-- 鍩烘湰淇℃伅灞曠ず -->
+ <view class="info-section">
+ <view class="section-title">鍩烘湰淇℃伅</view>
+ <view class="info-grid">
+ <view class="info-item">
+ <text class="info-label">閿�鍞悎鍚屽彿</text>
+ <text class="info-value">{{ form.salesContractNo }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">瀹㈡埛鍚堝悓鍙�</text>
+ <text class="info-value highlight">{{ form.customerContractNo }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">瀹㈡埛鍚嶇О</text>
+ <text class="info-value">{{ form.customerName }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">涓氬姟鍛�</text>
+ <text class="info-value">{{ form.salesman }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">椤圭洰鍚嶇О</text>
+ <text class="info-value">{{ form.projectName }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">绛捐鏃ユ湡</text>
+ <text class="info-value">{{ form.executionDate }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">浠樻鏂瑰紡</text>
+ <text class="info-value">{{ form.paymentMethod }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">褰曞叆浜�</text>
+ <text class="info-value">{{ form.entryPersonName }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">褰曞叆鏃ユ湡</text>
+ <text class="info-value">{{ form.entryDate }}</text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 浜у搧淇℃伅灞曠ず -->
+ <view class="product-section" v-if="productData && productData.length > 0">
+ <view class="section-title">浜у搧淇℃伅</view>
+ <view class="product-card" v-for="(product, idx) in productData" :key="idx">
+ <view class="product-header">
+ <view class="product-title">
+ <van-icon name="description" color="#2979ff" size="15" />
+ <text class="product-productCategory">浜у搧 {{ idx + 1 }}</text>
+ </view>
+ </view>
+
+ <view class="product-info">
+ <view class="info-grid">
+ <view class="info-item">
+ <text class="info-label">浜у搧澶х被</text>
+ <text class="info-value">{{ product.productCategory }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">瑙勬牸鍨嬪彿</text>
+ <text class="info-value">{{ product.specificationModel }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">鍗曚綅</text>
+ <text class="info-value">{{ product.unit }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">绋庣巼(%)</text>
+ <text class="info-value">{{ product.taxRate }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">鍚◣鍗曚环(鍏�)</text>
+ <text class="info-value highlight">{{ product.taxInclusiveUnitPrice }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">鏁伴噺</text>
+ <text class="info-value highlight">{{ product.quantity }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">鍚◣鎬讳环(鍏�)</text>
+ <text class="info-value highlight">{{ product.taxInclusiveTotalPrice }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">涓嶅惈绋庢�讳环(鍏�)</text>
+ <text class="info-value highlight">{{ product.taxExclusiveTotalPrice }}</text>
+ </view>
+ <view class="info-item">
+ <text class="info-label">鍙戠エ绫诲瀷</text>
+ <text class="info-value">{{ product.invoiceType }}</text>
+ </view>
+ </view>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鏃犱骇鍝佷俊鎭彁绀� -->
+ <view class="no-product" v-else>
+ <text>鏆傛棤浜у搧淇℃伅</text>
+ </view>
+ </view>
+</template>
+
+<script setup>
+import { onMounted, ref } from 'vue';
+import { getSalesLedgerWithProducts } from "@/api/salesManagement/salesLedger";
+
+// 琛ㄥ崟鏁版嵁
+const form = ref({
+ id: '',
+ salesContractNo: '',
+ customerContractNo: '',
+ customerId: '',
+ customerName: '',
+ projectName: '',
+ executionDate: '',
+ paymentMethod: '',
+ entryPerson: '',
+ entryPersonName: '',
+ entryDate: '',
+ salesman: ''
+});
+
+// 浜у搧鏁版嵁
+const productData = ref([]);
+
+// 缂栬緫鏁版嵁
+const editData = ref(null);
+
+// 杩斿洖涓婁竴椤�
+const goBack = () => {
+ // 娓呯悊鏈湴瀛樺偍鐨勬暟鎹�
+ uni.removeStorageSync('editData');
+ uni.navigateBack();
+};
+
+// 濉厖琛ㄥ崟鏁版嵁
+const fillFormData = () => {
+ if (!editData.value) return;
+
+ // 鑾峰彇瀹屾暣鐨勪骇鍝佷俊鎭�
+ getSalesLedgerWithProducts({ id: editData.value.id, type: 1 }).then((res) => {
+ productData.value = res.productData || [];
+ });
+
+ // 濉厖鍩烘湰淇℃伅
+ form.value.salesContractNo = editData.value.salesContractNo || '';
+ form.value.customerContractNo = editData.value.customerContractNo || '';
+ form.value.customerName = editData.value.customerName || '';
+ form.value.projectName = editData.value.projectName || '';
+ form.value.executionDate = editData.value.executionDate || '';
+ form.value.paymentMethod = editData.value.paymentMethod || '';
+ form.value.salesman = editData.value.salesman || '';
+ form.value.entryPerson = editData.value.entryPerson || '';
+ form.value.entryPersonName = editData.value.entryPersonName || '';
+ form.value.entryDate = editData.value.entryDate || '';
+ form.value.id = editData.value.id || '';
+ form.value.customerId = editData.value.customerId || '';
+};
+
+onMounted(() => {
+ // 鑾峰彇缂栬緫鏁版嵁骞跺~鍏呰〃鍗�
+ const editDataStr = uni.getStorageSync('editData');
+ if (editDataStr) {
+ try {
+ editData.value = JSON.parse(editDataStr);
+ // 浣跨敤 nextTick 纭繚鏁版嵁鍔犺浇瀹屾垚鍚庡啀濉厖
+ setTimeout(() => {
+ fillFormData();
+ }, 100);
+ } catch (error) {
+ console.error('瑙f瀽缂栬緫鏁版嵁澶辫触:', error);
+ }
+ }
+});
+</script>
+
+<style scoped lang="scss">
+.account-view {
+ min-height: 100vh;
+ background: #f8f9fa;
+ padding-bottom: 2rem;
+}
+
+.header {
+ display: flex;
+ align-items: center;
+ background: #fff;
+ padding: 1rem 1.25rem;
+ border-bottom: 0.0625rem solid #f0f0f0;
+ position: sticky;
+ top: 0;
+ z-index: 100;
+ /* 鍏煎 iOS 鍒樻捣/鐏靛姩宀涘畨鍏ㄥ尯 */
+ padding-top: env(safe-area-inset-top);
+}
+
+.title {
+ flex: 1;
+ text-align: center;
+ font-size: 1.125rem;
+ font-weight: 600;
+ color: #333;
+}
+
+.info-section {
+ background: #fff;
+ margin: 1rem;
+ padding: 1rem;
+ border-radius: 0.5rem;
+ box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.04);
+}
+
+.section-title {
+ font-size: 1rem;
+ font-weight: 600;
+ color: #333;
+ margin-bottom: 1rem;
+ padding-bottom: 1rem;
+ border-bottom: 0.0625rem solid #e8e8e8;
+}
+
+.info-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 0.75rem;
+}
+
+.info-item {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+}
+
+.info-label {
+ font-size: 0.75rem;
+ color: #666;
+ font-weight: 400;
+}
+
+.info-value {
+ font-size: 0.875rem;
+ color: #333;
+ font-weight: 500;
+}
+
+.info-value.highlight {
+ color: #2979ff;
+ font-weight: 600;
+}
+
+.product-section {
+ background: #fff;
+ margin: 1rem;
+ padding: 1rem;
+ border-radius: 0.5rem;
+ box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.04);
+}
+
+.product-card {
+ background: #f8f9fa;
+ border-radius: 0.5rem;
+ padding: 1rem;
+ margin-bottom: 1rem;
+}
+
+.product-card:last-child {
+ margin-bottom: 0;
+}
+
+.product-header {
+ display: flex;
+ align-items: center;
+ padding-bottom: 0.75rem;
+ border-bottom: 0.0625rem solid #e8e8e8;
+ margin-bottom: 1rem;
+}
+
+.product-title {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+}
+
+.product-productCategory {
+ font-size: 0.875rem;
+ font-weight: 500;
+ color: #333;
+}
+
+.product-info .info-grid {
+ grid-template-columns: 1fr 1fr;
+ gap: 0.5rem;
+}
+
+.no-product {
+ text-align: center;
+ padding: 2rem;
+ color: #999;
+ font-size: 0.875rem;
+}
+</style>
--
Gitblit v1.9.3