Przeglądaj źródła

采购对接调整

zhengxin 5 lat temu
rodzic
commit
7680d251f6

+ 42 - 10
ghs/src/pagesPurchase/add.vue

@@ -49,7 +49,6 @@
 				</div>
 			</scroll-view>
 			<scroll-view scroll-y class="right-box" :scroll-into-view="scrollClassId">
-				<!--内容部分 start -->
 				<!--内容部分 start -->
 				<block v-if="!$util.isEmpty(filterProductInfo)">
 					<view
@@ -105,7 +104,12 @@
 							<view class="kc">
 								价格
 							</view>
-							<input type="number" placeholder="请填写采购总价" />元
+							<input
+								:value="customData.itemPrice"
+								@change="changePriceEvent"
+								type="number"
+								placeholder="请填写采购总价"
+							/>元
 						</view>
 					</view>
 					<view class="select-cmd_bx">
@@ -113,8 +117,12 @@
 							<view class="kc">
 								数量
 							</view>
-							<input type="number" />扎
-							<input type="number" style="margin-left:24upx" />支
+							<input v-model="customData.bigCount" type="number" focus />扎
+							<input
+								v-model="customData.smallCount"
+								type="number"
+								style="margin-left:24upx"
+							/>支
 						</view>
 					</view>
 				</view>
@@ -163,24 +171,32 @@ export default {
 			pageType: "purchase",
 
 			isModel: false,
-			showSubmitModel: false
+			showSubmitModel: false,
+			customData: {
+				bigCount: 0,
+				smallCount: 0,
+				itemPrice: null
+			}
 		};
 	},
-	onLoad() {
-		this.resetSelectInfoByType(this.pageType);
-	},
+	onLoad() {},
 	methods: {
 		//自定义数量
-		customNum() {
+		customNum(info) {
 			this.isModel = true;
+			this.customData = info;
 		},
 		modalCancel() {
 			this.isModel = false;
+			this.customData = {};
 		}, // 取消 确认
 		affirm(val) {
 			if (val.index === 0) {
 				this.modalCancel();
 			} else {
+				//超过库存时 设置为库存最大值
+				this.updateItemEvent(this.customData);
+				this.modalCancel();
 			}
 		},
 		cancelEvent() {},
@@ -197,13 +213,29 @@ export default {
 		},
 		confirmSelectEvent() {
 			if (this.selectList.length > 0) {
-				console.log(444, this.selectList);
 				uni.navigateTo({
 					url: "/pagesPurchase/details"
 				});
 				this.cancelEvent();
 			}
 		},
+		changePriceEvent(e) {
+			const {
+				detail: { value }
+			} = e;
+			const maxPrice = Number(value);
+			this.customData.itemPrice = maxPrice;
+
+			if (maxPrice > 0) {
+				const { smallPrice, ratio } = this.customData;
+				const ratioNum = Number(ratio);
+
+				const num = Math.floor(maxPrice / Number(smallPrice));
+
+				this.customData.bigCount = Math.floor(num / ratioNum);
+				this.customData.smallCount = Math.floor(num % ratioNum);
+			}
+		},
 
 		searchFn() {},
 		scrollTop() {}

+ 173 - 134
ghs/src/pagesPurchase/details.vue

@@ -11,7 +11,11 @@
 								v-for="(item, index) in selectList"
 								:key="index"
 							>
-								<image class="item-icon" :src="item.cover" alt="商品图" />
+								<image
+									class="item-icon"
+									:src="item.itemCover || item.cover"
+									alt="商品图"
+								/>
 
 								<view class="item-info">
 									<view class="info-line">
@@ -19,7 +23,9 @@
 										<text class="item-price">
 											<text class="unit">¥</text>
 
-											<text class="price">{{ getSelectItemPrice(item) }}</text>
+											<text class="price">{{
+												item.itemPrice || getSelectItemPrice(item)
+											}}</text>
 										</text>
 									</view>
 									<view class="info-line">
@@ -51,13 +57,14 @@
 				<!-- <view class="prompt-text">注: 请先关注公众号,绑定后可以在移动端自动登录</view> -->
 
 				<view class="module-com input-line-wrap">
-					<tui-list-cell class="line-cell" :hover="false" :arrow="true">
+					<tui-list-cell class="line-cell" :hover="false" :arrow="false">
 						<view class="tui-title ">供应商</view>
 						<text>
-							茗星花卉 欠款:91658.00
+							{{ detailsInfo.supplierName || "" }}
+							<!-- 欠款:91658.00  -->
 						</text>
 					</tui-list-cell>
-					<tui-list-cell class="line-cell" :hover="false">
+					<!-- <tui-list-cell class="line-cell" :hover="false">
 						<view class="tui-title "></view>
 
 						<view class="tag-list">
@@ -71,24 +78,36 @@
 								盛丰
 							</view>
 						</view>
-					</tui-list-cell>
+					</tui-list-cell> -->
 				</view>
 				<view class="module-com input-line-wrap">
 					<tui-list-cell class="line-cell" :hover="false">
 						<view class="tui-title ">打包费</view>
 						<input
-							v-model="form.floor"
+							:disabled="!canIEdit"
+							v-model="form.packingCharge"
+							placeholder-class="phcolor"
+							class="tui-input"
+							name="floor"
+							placeholder="请填写,留空没有费用"
+						/>
+					</tui-list-cell>
+					<tui-list-cell class="line-cell" :hover="false">
+						<view class="tui-title ">短途运费</view>
+						<input
+							:disabled="!canIEdit"
+							v-model="form.shortCharge"
 							placeholder-class="phcolor"
 							class="tui-input"
 							name="floor"
 							placeholder="请填写,留空没有费用"
 						/>
 					</tui-list-cell>
-
 					<tui-list-cell class="line-cell" :hover="false">
 						<view class="tui-title ">包机(长途运费)</view>
 						<input
-							v-model="form.floor"
+							:disabled="!canIEdit"
+							v-model="form.longCharge"
 							placeholder-class="phcolor"
 							class="tui-input"
 							name="floor"
@@ -98,7 +117,8 @@
 					<tui-list-cell class="line-cell" :hover="false">
 						<view class="tui-title ">提货费</view>
 						<input
-							v-model="form.floor"
+							:disabled="!canIEdit"
+							v-model="form.pickCharge"
 							placeholder-class="phcolor"
 							class="tui-input"
 							name="floor"
@@ -108,51 +128,41 @@
 					<tui-list-cell class="line-cell" :hover="false">
 						<view class="tui-title ">本地运费</view>
 						<input
-							v-model="form.floor"
+							:disabled="!canIEdit"
+							v-model="form.localCharge"
 							placeholder-class="phcolor"
 							class="tui-input"
 							name="floor"
 							placeholder="请填写,留空没有费用"
 						/>
 					</tui-list-cell>
-					<tui-list-cell
-						class="line-cell"
-						:hover="false"
-						:arrow="true"
-						@click="openAddres"
-					>
+					<tui-list-cell class="line-cell" :hover="false" :arrow="true">
 						<view class="tui-title ">入库日期</view>
-						<view class="tui-input" v-if="form.province || form.city">
+						<!-- <view class="tui-input" v-if="form.province || form.city">
 							{{ form.province + "-" + form.city }}
-						</view>
-						<view class="tui-placeholder" v-else>请选择</view>
-						<input v-model="form.province" name="province" hidden />
-					</tui-list-cell>
-					<tui-list-cell
-						class="line-cell"
-						:hover="false"
-						:arrow="true"
-						@click="openAddres"
-					>
-						<view class="tui-title ">仓库</view>
-						<view class="tui-input" v-if="form.province || form.city">
-							{{ form.province + "-" + form.city }}
-						</view>
-						<view class="tui-placeholder" v-else>请选择仓库</view>
-						<input v-model="form.province" name="province" hidden />
+						</view> -->
+						<!-- <view class="tui-placeholder" v-else>请选择</view>
+						<input v-model="form.province" name="province" hidden /> -->
+						<AppDatePicker
+							v-if="canIEdit"
+							:dateVal="form.entryTime"
+							:placeholder="'请选择日期'"
+						/>
+						<view v-else>{{ form.entryTime || "" }}</view>
 					</tui-list-cell>
 
-					<!-- <tui-list-cell class="line-cell remark-wrap" :hover="false">
-						<view class="tui-title">简介</view>
+					<tui-list-cell class="line-cell remark-wrap" :hover="false">
+						<view class="tui-title">备注</view>
 						<view class="tui-input">
 							<textarea
+								:disabled="!canIEdit"
 								v-model="form.introduction"
 								class="tui-textarea remark"
 								placeholder-class="phcolor"
-								placeholder="请输入简介"
+								placeholder="请输入备注"
 							/>
 						</view>
-					</tui-list-cell> -->
+					</tui-list-cell>
 				</view>
 			</form>
 		</view>
@@ -163,22 +173,15 @@
 					¥ <text class="large">{{ allPrice }}</text>
 				</text>
 			</view>
-			<button class="admin-button-com blue middle" @click="formSubmit">
+			<button
+				class="admin-button-com blue middle"
+				v-if="canIEdit"
+				@click="formSubmit"
+			>
 				确认
 			</button>
 		</view>
-		<!-- 选择地区 -->
-		<app-area-sel
-			:show.sync="showRegion"
-			@change="changeAreaFn"
-			:city="form.city"
-		/>
-		<!-- 省市联动 -->
-		<simple-address
-			ref="simpleAddress"
-			:pickerValueDefault="cityPickerValueDefault"
-			@onConfirm="onCityConfirm"
-		></simple-address>
+
 		<!-- 选择客户 -->
 		<AppCustomerSel
 			:show.sync="showCustomer"
@@ -189,53 +192,79 @@
 </template>
 
 <script>
+import { mapGetters, mapActions } from "vuex";
 import TuiListCell from "@/components/plugin/list-cell";
 import AppAvatarModule from "@/components/module/app-avatar";
-import SimpleAddress from "@/components/plugin/simple-address";
-import AppAreaSel from "@/components/app-area-sel";
 import AppCustomerSel from "@/components/app-customer-sel";
 const form = require("@/utils/formValidation.js");
 import productMins from "@/mixins/product";
+import {
+	getPurchaseDetailApi,
+	createPurchaseOrderApi
+} from "@/api/purchase/index";
+import { PURCHASE_ORDER_STATUS } from "@/utils/declare";
+
+import AppDatePicker from "@/components/app-date-picker";
 
 export default {
 	// 采购详情
 	components: {
 		TuiListCell,
 		AppAvatarModule,
-		SimpleAddress,
-		AppAreaSel,
-		AppCustomerSel
+		AppCustomerSel,
+		AppDatePicker
 	},
 	mixins: [productMins],
 	data() {
 		return {
+			PURCHASE_ORDER_STATUS,
 			autoLoad: false,
 			pageType: "purchase",
 
 			form: {
-				shopName: "",
-				province: "",
-				city: "",
-				address: "",
-				floor: "",
-				openTime: "8:00 - 22:00",
-				introduction: "",
-				telephone: "",
-				customer: ""
+				packingCharge: "", //打包费
+				shortCharge: "",
+				longCharge: "",
+				pickCharge: "",
+				localCharge: "",
+
+				entryTime: "",
+				supplierId: null
 			},
-			// 详细地址
-			showRegion: false,
 			showCustomer: false,
-			region: {
-				lat: 0,
-				long: 0
-			},
-			// 省市联动
-			regionData: [],
-			cityPickerValueDefault: [0, 0]
+			detailsInfo: {}
 		};
 	},
+	onLoad() {
+		this.initData();
+	},
+	computed: {
+		...mapGetters(["getMerchantInfo", "getLoginInfo"]),
+		allPrice() {
+			let price = 0;
+
+			if (this.selectList) {
+				for (const item of this.selectList) {
+					if (item.itemPrice) {
+						price += Number(item.itemPrice);
+					} else {
+						price += this.getSelectItemPrice(item);
+					}
+				}
+			}
+			return Math.round(price * 100) / 100;
+		},
+		canIEdit() {
+			const { orderSn } = this.option || {};
+
+			if (!orderSn || this.detailsInfo.status == PURCHASE_ORDER_STATUS.CONFIRM) {
+				return true;
+			}
+			return false;
+		}
+	},
 	methods: {
+		...mapActions(["initMerchantInfo"]),
 		init() {
 			this._getDet();
 		},
@@ -249,88 +278,95 @@ export default {
 				// }
 			});
 		},
-		// option
-		// 选择地址
-		selRegionFn() {
-			if (!this.form.city) {
-				this.$msg("请先选择城市!");
-				return false;
+
+		async initData() {
+			try {
+				const { orderSn } = this.option;
+				if (!orderSn) {
+					return;
+				}
+
+				const { data } = await getPurchaseDetailApi(orderSn);
+				console.log(11111, data);
+				Object.keys(this.form).forEach((i, index) => {
+					// if (i != 'password') {
+					this.form[i] = data[i];
+					// }
+				});
+
+				this.detailsInfo = data;
+
+				if (data.itemInfo) {
+					let list = data.itemInfo;
+					list.forEach(element => {
+						element.bigCount = element.bigNum;
+						element.smallCount = element.smallNum;
+					});
+					this.setSelectInfoByType({ type: this.pageType, info: list });
+				}
+
+				if (!this.getMerchantInfo) {
+					await this.initMerchantInfo();
+				}
+				console.log(66666, this.getMerchantInfo);
+			} catch (error) {
+				console.log(4444, error);
 			}
-			this.showRegion = true;
-		},
-		changeAreaFn(e) {
-			console.log("changeAreaFn", e);
-			this.form.address = e.address;
-			this.region.lat = e.location.lat;
-			this.region.long = e.location.lng;
 		},
+
 		changeCustomerFn(e) {
 			console.log("changeCustomerFn", e);
 			this.form.address = e.address;
 			this.form.lat = e.location.lat;
 			this.form.long = e.location.lng;
 		},
-		// 省市联动
-		openAddres() {
-			this.$refs.simpleAddress.open();
-		},
+
 		onCityConfirm(e) {
 			// this.form.receiveAddress = e.label
 			this.form.province = e.provinceName;
 			this.form.city = e.cityName;
 			// this.pickerText = JSON.stringify(e)
 		},
-		confirmFn() {
-			let hostFn = this.option.id ? update : add;
-			if (this.option.id) {
-				this.form.id = this.option.id;
-			}
-			hostFn(this.form).then(res => {
-				let promptText = this.option.id ? "修改成功!" : "添加成功!";
-				this.$msg(promptText);
-				// uni.removeStorageSync("modifyShopB");
-				// setTimeout(() => {
-				// 	this.$util.pageTo("/admin/shop/list");
-				// }, 1000);
-			});
+		async confirmFn() {
+			try {
+				const { orderSn } = this.option;
+				let formData = this.form;
+				if (orderSn) {
+					formData.orderSn = orderSn;
+				}
+				const itemInfo = this.selectList.map(ele => {
+					return {
+						productId: ele.id,
+						bigNum: ele.bigCount,
+						smallNum: ele.smallCount,
+						itemPrice: ele.itemPrice || this.getSelectItemPrice(ele)
+					};
+				});
+				formData.itemInfo = JSON.stringify(itemInfo);
+				if (!this.getMerchantInfo) {
+					await this.initMerchantInfo();
+				}
+				formData.supplierId = this.getMerchantInfo.id;
+				await createPurchaseOrderApi(formData);
+				this.$msg("确认成功!");
+
+				this.resetSelectInfoByType(this.pageType);
+				this.$util.pageTo({ url: "/pagesPurchase/result", type: 2 });
+			} catch (error) {}
 		},
 		// 表单验证
 		formSubmit(e) {
 			// 表单规则
 			let rules = [
 				{
-					name: "shopName",
-					rule: [""],
-					msg: ["请输入名称"]
-				},
-				{
-					name: "openTime",
-					rule: [""],
-					msg: ["请输入营业时间"]
-				},
-				{
-					name: "telephone",
-					rule: [""],
-					msg: ["请输入联系电话"]
-				},
-				{
-					name: "province",
-					rule: [""],
-					msg: ["请选择地址"]
-				},
-				{
-					name: "address",
-					rule: [""],
-					msg: ["请填写详细地址"]
-				},
-				{
-					name: "floor",
-					rule: [""],
-					msg: ["请输入门牌号"]
+					name: "itemInfo",
+					rule: ["minLength", 1],
+					msg: ["请选择花材"]
 				}
 			];
 			// 进行表单检查
 			let formData = this.form;
+			formData.itemInfo = this.selectList;
 			let checkRes = form.validation(formData, rules);
 			// 验证通过!
 			if (!checkRes) {
@@ -340,8 +376,11 @@ export default {
 			}
 		},
 		gobackEvent() {
-			uni.navigateBack({
-				delta: 1
+			uni.navigateTo({
+				url: "/pagesPurchase/add",
+				success: result => {},
+				fail: () => {},
+				complete: () => {}
 			});
 		}
 	}

+ 15 - 17
ghs/src/pagesPurchase/order.vue

@@ -10,6 +10,9 @@
 				:currentTab="tabIndex"
 				@change="changeTabEvent"
 				itemWidth="20%"
+				@add="addEvent"
+				:isAdd="true"
+				addText="新增"
 			></Tabs>
 		</view>
 		<scroll-view scroll-y class="order-list">
@@ -26,13 +29,13 @@
 				<AppWrapperEmpty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
 			</block>
 		</scroll-view>
-		<view class="bar-view">
+		<!-- <view class="bar-view">
 			<view class="btn-view">
 				<button class="admin-button-com middle blue" @click="addEvent">
 					新增
 				</button>
 			</view>
-		</view>
+		</view> -->
 	</view>
 </template>
 <script>
@@ -164,21 +167,15 @@ export default {
 			});
 		},
 		gotoDetails(item) {
-			if (item.status == PURCHASE_ORDER_STATUS.CONFIRM) {
-				uni.navigateTo({
-					url: `/pagesPurchase/details?orderSn=${item.orderSn}`,
-					success: result => {},
-					fail: () => {},
-					complete: () => {}
-				});
-			} else {
-				uni.navigateTo({
-					url: `/pagesPurchase/details?orderSn=${item.orderSn}`,
-					success: result => {},
-					fail: () => {},
-					complete: () => {}
-				});
-			}
+			// if (item.status == PURCHASE_ORDER_STATUS.CONFIRM) {
+
+			// }
+			uni.navigateTo({
+				url: `/pagesPurchase/details?orderSn=${item.orderSn}`,
+				success: result => {},
+				fail: () => {},
+				complete: () => {}
+			});
 		}
 	}
 };
@@ -248,6 +245,7 @@ export default {
 		}
 	}
 	.bar-view {
+		flex-shrink: 0;
 		display: flex;
 		justify-content: flex-end;
 		align-items: center;

+ 6 - 1
ghs/src/pagesPurchase/orderItem.vue

@@ -9,7 +9,7 @@
 			</view>
 			<view class="status">{{ getStatusName }} </view>
 		</view>
-		<view class="item-main">
+		<view class="item-main" @click="clickItemEvent">
 			<view class="item-info">
 				<view class="info-row">
 					<text class="info-label"> 日期:</text>
@@ -67,6 +67,11 @@ export default {
 			}
 			return statusName;
 		}
+	},
+	methods: {
+		clickItemEvent() {
+			this.$emit("click", this.info);
+		}
 	}
 };
 </script>

+ 10 - 2
ghs/src/pagesPurchase/result.vue

@@ -1,7 +1,7 @@
 <template>
 	<appResult :title="'入库成功'">
-		<button class="admin-button-com blue big">继续入库</button>
-		<button class="admin-button-com big">关闭</button>
+		<button class="admin-button-com blue big" @click="goOn">继续入库</button>
+		<button class="admin-button-com big" @click="goClose">关闭</button>
 	</appResult>
 </template>
 
@@ -11,6 +11,14 @@ export default {
 	name: "BillingResult", // 开单结果
 	components: {
 		appResult
+	},
+	methods: {
+		goOn() {
+			this.$util.pageTo({ url: "/pagesPurchase/add", type: 2 });
+		},
+		goClose() {
+			this.$util.pageTo({ url: "/pagesPurchase/order", type: 2 });
+		}
 	}
 };
 </script>