Просмотр исходного кода

feat(采购需求管理): 新增PBom选择功能及优化采购需求流程

liujt 6 месяцев назад
Родитель
Сommit
9f2e7db5f2

+ 13 - 5
api/purchasingManage/purchaseNeedManage.js

@@ -52,7 +52,7 @@ export async function producetask(params) {
  * 更新信息
  */
 export async function UpdateInformation(data) {
-  const res = await put(Vue.prototype.apiUrl + `/eom/purchaserequirement/update`, data);
+  const res = await putJ(Vue.prototype.apiUrl + `/eom/purchaserequirement/update`, data);
   if (res.code == 0) {
     return res.data;
   }
@@ -63,9 +63,17 @@ export async function UpdateInformation(data) {
  * 新增信息
  */
 export async function addPurchaseNeedManage(data) {
-  const res = await post(Vue.prototype.apiUrl + `/eom/purchaserequirement/save`, data);
-  if (res.data.code == 0) {
-    return res.data.data;
+  const res = await postJ(Vue.prototype.apiUrl + `/eom/purchaserequirement/save`, data);
+  if (res.code == 0) {
+    return res.data;
   }
-  return Promise.reject(new Error(res.data.message));
+  return Promise.reject(new Error(res.message));
 }
+
+export async function getCBomAPI(params) {
+  const res = await get(Vue.prototype.apiUrl + '/main/bomCategory/cBom', params);
+  if (res.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.message));
+}

+ 7 - 7
api/saleManage/contact/index.js

@@ -250,13 +250,13 @@ export async function queryContactIdCount(id) {
 /**
  * 通过产品查供应商
  */
-export async function contactQueryByCategoryIdsAPI(data) {
-  const res = await request.post('/eom/contact/queryByCategoryIds', data);
-  if (res.data.code == 0) {
-    return res.data.data;
-  }
-  return Promise.reject(new Error(res.data.message));
-}
+// export async function contactQueryByCategoryIdsAPI(data) {
+//   const res = await request.post('/eom/contact/queryByCategoryIds', data);
+//   if (res.data.code == 0) {
+//     return res.data.data;
+//   }
+//   return Promise.reject(new Error(res.data.message));
+// }
 
 // /**
 //  * 发布动态

+ 24 - 0
pages.json

@@ -2098,6 +2098,14 @@
 				"navigationBarTextStyle": "white"
 			}
 		},
+		{
+			"path": "pages/purchasingManage/components/selectContract",
+			"style": {
+				"navigationBarTitleText": "选择合同",
+				"navigationStyle": "custom",
+				"navigationBarTextStyle": "white"
+			}
+		},
 		{
 			"path": "pages/purchasingManage/components/selectSaleOrder",
 			"style": {
@@ -2106,6 +2114,14 @@
 				"navigationBarTextStyle": "white"
 			}
 		}, 
+		{
+			"path": "pages/purchasingManage/components/selectProduce",
+			"style": {
+				"navigationBarTitleText": "选择产品",
+				"navigationStyle": "custom",
+				"navigationBarTextStyle": "white"
+			}
+		}, 
 		{
 			"path": "pages/purchasingManage/components/selectTaskName",
 			"style": {
@@ -2114,6 +2130,14 @@
 				"navigationBarTextStyle": "white"
 			}
 		},
+		{
+			"path": "pages/purchasingManage/components/selectPBom",
+			"style": {
+				"navigationBarTitleText": "选择PBom",
+				"navigationStyle": "custom",
+				"navigationBarTextStyle": "white"
+			}
+		},
 		{
 			"path": "pages/saleManage/components/selectUser",
 			"style": {

+ 97 - 0
pages/purchasingManage/components/multipleSelect.vue

@@ -0,0 +1,97 @@
+<template>
+    <uni-popup ref="popup" :showClose="true" background-color="#fff" @change="change">
+        <scroll-view class="scroll-content" scroll-y style="height: 80vh;">
+            <view class="popup-title">
+                <text>选择</text>
+            </view>
+            
+            <!-- 选择列表 -->
+            <uni-data-checkbox multiple wrap v-model="value" :localdata="range" @change="change"></uni-data-checkbox>
+            
+            <view class="footerButton">
+                <u-button type="default" @click="handleClose" text="关闭"></u-button>
+                <u-button type="primary" @click="handleConfirm" text="确认"></u-button>
+            </view>
+        </scroll-view>
+    </uni-popup>
+</template>
+<script>
+export default {
+    props: {
+        range: {
+            type: Array,
+            default: () => []
+        }
+    },
+    data() {
+        return {
+            // range: [{"value": 0,"text": "篮球"	},{"value": 1,"text": "足球"},{"value": 2,"text": "游泳"}],
+            value: [],
+            key: ''
+        }
+    },
+    computed: {
+    
+    },
+    methods: {
+        open(current, index, key) {
+            this.current = current;
+            this.currentIndex = index;
+            this.key = key
+            this.$refs.popup.open('bottom');
+            if(current[key]) {
+                if(typeof current[key] == 'string') {
+                    this.value = current[key].split(',')
+                } else {
+                    this.value = current[key]
+                }
+            } else {
+                this.value = []
+            }
+        },
+        change(e) {
+            console.log('当前模式:' + e.type + ',状态:' + e.show);
+        },
+   
+        handleConfirm() {
+            this.$emit('confirm', this.value.join(','), this.key );
+            this.handleClose()
+        },
+        handleClose() {
+            this.$refs.popup.close()
+        },
+    }
+}
+</script>
+<style scoped lang="scss">
+    .footerButton {
+		width: 100%;
+		height: 84rpx;
+		display: flex;
+		position: fixed;
+		bottom: 0;
+		z-index: 10;
+		background-color: #fff;
+
+		/deep/.u-button {
+			height: 100%;
+		}
+
+		>view {
+			flex: 1;
+
+		}
+	}
+    .scroll-content {
+        padding: 20rpx;
+    }
+    .popup-title {
+		display: flex;
+		align-items: center;
+		padding: 20rpx;
+	}
+	.popup-title-btn {
+		width: 100rpx;
+		margin-right: 20rpx;
+	}
+</style>

+ 187 - 66
pages/purchasingManage/components/produceList.vue

@@ -20,10 +20,10 @@
 					<view v-else>
 						<u-row>
 							<u-col span="6">
-								<u--input placeholder="请输入" type="number" border="surround" v-model="item.purchaseCount"></u--input @input="changeCount(item, index)">
+								<u--input placeholder="请输入" type="number" border="surround" v-model="item.purchaseCount"  @input="changeCount(item, index)"></u--input>
 							</u-col>
 							<u-col span="6">
-								<uni-data-picker v-model="item.purchaseUnit" placeholder="请选择" :localdata="item.packageDispositionList" @change="changeCount(item, index)"></uni-data-picker>
+								<uni-data-picker v-model="item.purchaseUnitId" placeholder="请选择" :localdata="item.packageDispositionList" @change="changeCount(item, index)"></uni-data-picker>
 							</u-col>
 						</u-row>
 					</view>
@@ -48,13 +48,12 @@
 				<view slot="expectReceiveDate">
 					<view v-if="isDrawer">{{ item.expectReceiveDate }}</view>
 					<view v-else>
-						<view v-if="item.arrivalWay == 1">
-							<uni-datetime-picker type="date" v-model="item.expectReceiveDate"></uni-datetime-picker>
+						<view v-if="item.arrivalWay == 2">
+							<span @click="settingDate(item, index)" style="color: #409eff;">设置分批时间</span>
 						</view>
 						<view v-else>
-							<span @click="settingDate(item, index)" style="color: #409eff;">设置分批时间</span>
+							<uni-datetime-picker type="date" v-model="item.expectReceiveDate"></uni-datetime-picker>
 						</view>
-						
 					</view>
 				</view>
 
@@ -63,7 +62,7 @@
 					<view v-else>
 						<u-row>
 							<u-col span="10">
-								<u--input placeholder="" disabled border="surround" v-model="item.taskName"></u--input @input="changeCount(item, index)">
+								<u--input placeholder="" disabled border="surround" v-model="item.taskName"></u--input>
 							</u-col>
 							<u-col span="2">
 								<u-button type="primary" size="mini" @click="selectTaskName(item, index)" text="选择"></u-button>
@@ -75,14 +74,15 @@
 				<view slot="supplierName">
 					<view v-if="isDrawer">{{ item.supplierName }}</view>
 					<view v-else>
-						<uni-data-picker v-model="item.supplierName" placeholder="请选择" :localdata="arrivalWayList"></uni-data-picker>
+						<uni-data-picker v-model="item.supplierId" placeholder="请选择" :localdata="item.supplierList"></uni-data-picker>
 					</view>
 				</view>
 
 				<view slot="provenance">
-					<view v-if="isDrawer">{{ item.provenance }}</view>
+					<view v-if="isDrawer">{{ getProvenance(item.provenance) }}</view>
 					<view v-else>
-						<uni-data-picker v-model="item.provenance" placeholder="请选择" :localdata="purchase_origin"></uni-data-picker>
+						<!-- <uni-data-picker v-model="item.provenance" placeholder="请选择" :localdata="purchase_origin"></uni-data-picker> -->
+						 <u--input placeholder="请输入" border="surround" v-model="item.provenanceName" @click.native="changeMultiple(item, index, 'provenance', purchase_origin)"></u--input>
 					</view>
 				</view>
 
@@ -96,29 +96,48 @@
 				<view slot="modelKey">
 					<view v-if="isDrawer">{{ item.modelKey }}</view>
 					<view v-else>
-						<!-- <u--input placeholder="请输入" border="surround" disabled v-model="item.modelKey"></u--input> -->
-						<uni-data-select
-							multiple
+						<u--input placeholder="请输入" border="surround" v-model="item.modelKey" @click.native="changeMultiple(item, index, 'modelKey', product_model_key)"></u--input>
+						<!-- <uni-data-select
+							
+							:localdata="product_model_key"
+							v-model="item.modelKey"
+							 @change="change"
+						></uni-data-select> -->
+						<!-- <zxz-uni-data-select
 							:localdata="product_model_key"
 							v-model="item.modelKey"
-						></uni-data-select>
+							dataValue="value"
+							format="{text}"
+							dataKey="text"
+							:clear="false"
+							multiple
+						></zxz-uni-data-select> -->
 					</view>
 				</view>
 
 				<view slot="colorKey">
 					<view v-if="isDrawer">{{ item.colorKey }}</view>
 					<view v-else>
-						<!-- <u--input placeholder="请输入" border="surround" disabled v-model="item.colorKey"></u--input> -->
-						<uni-data-select
+						<u--input placeholder="请输入" border="surround" v-model="item.colorKey" @click.native="changeMultiple(item, index, 'colorKey', product_color_key)"></u--input>
+						<!-- <uni-data-select
 							multiple
 							:localdata="product_color_key"
 							v-model="item.colorKey"
-						></uni-data-select>
+						></uni-data-select> -->
+						<!-- <zxz-uni-data-select
+							:localdata="product_color_key"
+							v-model="item.colorKey"
+							dataValue="value"
+							format="{text}"
+							dataKey="text"
+							:clear="false"
+							multiple
+						></zxz-uni-data-select> -->
 					</view>
 				</view>
 
 				<view slot="remark">
-					<view v-if="isDrawer">{{ item.colorKey }}</view>
+					<view v-if="isDrawer">{{ item.remark }}</view>
 					<view v-else>
 						<u--input placeholder="请输入" border="surround" v-model="item.remark"></u--input>
 					</view>
@@ -127,43 +146,6 @@
 				<fileMain slot="technicalDrawings" :type="isDrawer ? 'view' : ''" v-model="item.technicalDrawings"></fileMain>
 				<fileMain slot="files" :type="isDrawer ? 'view' : ''" v-model="item.files"></fileMain>
 
-				
-				<u--input :disabled="!!contractId" slot="singleWeight" @input="singleWeightChange(item,index)"
-					type="number" placeholder="请输入" border="surround" v-model="item.singleWeight"></u--input>
-				<u--input :disabled="!!contractId" slot="singlePrice" style="flex:none;width: 50%;"
-					@input="getTotalPrice()" type="number" placeholder="请输入" border="surround"
-					v-model="item.singlePrice">
-					<template slot="suffix">元</template>
-				</u--input>
-				<uni-datetime-picker :disabled="!!contractId" type="date" slot="customerExpectDeliveryDeadline"
-					v-model="item.customerExpectDeliveryDeadline">
-				</uni-datetime-picker>
-				<u--input :disabled="!!contractId" slot="guaranteePeriod" placeholder="请输入" border="surround"
-					v-model="item.guaranteePeriod"></u--input>
-				<uni-data-picker :readonly="!!contractId" slot="guaranteePeriodUnitCode"
-					v-model="item.guaranteePeriodUnitCode" placeholder="请选择" :localdata="date_unit">
-				</uni-data-picker>
-				<u--input slot="customerMark" placeholder="请输入" border="surround" v-model="item.customerMark">
-
-				</u--input>
-				<u--input slot="productBrand" placeholder="请输入" border="surround" :disabled="item.productCode"
-					v-model="item.productBrand">
-				</u--input>
-				<u--input slot="specification" placeholder="请输入" border="surround" :disabled="item.productCode"
-					v-model="item.specification">
-
-				</u--input>
-				<!-- <u--input slot="goodsLevel" placeholder="请输入" border="surround" :disabled="item.productCode"
-					v-model="item.goodsLevel">
-				</u--input> -->
-				<u--input slot="modelType" placeholder="请输入" border="surround" :disabled="item.productCode"
-					v-model="item.modelType">
-				</u--input>
-
-				<!-- <u--input slot="productName" placeholder="请输入" border="surround" :disabled="item.productCode"
-					v-model="item.productName">
-				</u--input> -->
-				
 			</myCard>
 		</view>
 
@@ -177,9 +159,10 @@
 		<u-action-sheet :actions="addList" :show="show" :closeOnClickOverlay="true" :closeOnClickAction="true"
 			@close="show=false" @select='select'> </u-action-sheet>
 		<timePopup ref="timePopupRef" @confirm="handleTimeConfirm"></timePopup>
+		<multipleSelect ref="multipleSelectRef" :range="multipleSelectRange" @confirm="handleMultipleConfirm"></multipleSelect>
 	</view>
 </template>
-<!-- 名称,数量,单位,到货方式,到货日期 -->
+<!-- 名称,数量,到货方式,到货日期 -->
 <script>
 	import {
 		getByCode
@@ -190,12 +173,14 @@
 	import fileMain from "@/pages/doc/index.vue"
 	import { changeCount } from '@/utils/setProduct.js';
 	import timePopup from './timePopup.vue'
-		
-	export default {
+	import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
+	import multipleSelect from './multipleSelect.vue'
 
+	export default {
 		data() {
 			return {
 				tableList: [],
+				multipleSelectRange: [],
 				addList: [
 					{ name: '选择物品清单', },
 					{ name: '新增临时产品', }
@@ -219,7 +204,15 @@
 					btnType: 'error ',
 					type: '2',
 					pageUrl: '',
-
+					judge: [{
+						authorities: '',
+					}, {
+						// key: 'status',
+						// value: [0, 3],
+						fn: (row) => {
+								return !this.isDrawer
+							},
+					}],
 				}],
 				defaultForm: {
 					key: null,
@@ -230,7 +223,9 @@
 					workHour: '',
 					guaranteePeriodUnitCode: '',
 					technicalDrawings: [],
-					arrivalWay: 1
+					arrivalWay: 1,
+					modelKey: '',
+					colorKey: ''
 				},
 				levelList
 			}
@@ -252,7 +247,9 @@
 		components: {
 			myCard,
 			fileMain,
-			timePopup
+			timePopup,
+			baTreePicker,
+			multipleSelect
 		},
 		computed: {
 			...mapGetters(['dict', 'getDict', 'getDictValue']),
@@ -414,6 +411,7 @@
 					[{
 						label: '备注:',
 						prop: 'remark',
+						slot: 'remark',
 						className: 'perce100',
 					}],
 					[{
@@ -495,17 +493,137 @@
 						this.current = {};
 				}
 			})
+
+			uni.$off('setPBomList')
+			uni.$on('setPBomList', (data, idx = -1) => {
+				console.log('setPBomList~~', data)
+				data.forEach((item, index) => {
+					let i = idx == -1 ? index : idx;
+					let row = JSON.parse(JSON.stringify(this.defaultForm));
+					row.key = this.tableList.length + 1;
+					let parasm = idx == -1 ? row : this.tableList[i];
+					this.$set(parasm, 'productId', item.id);
+					// this.$set(parasm, 'id', item.id);
+					this.$set(parasm, 'categoryName', item.name);
+					this.$set(parasm, 'productCategoryId', item.categoryLevelId);
+					this.$set(parasm, 'productBrand', item.brandNum);
+					this.$set(
+						parasm,
+						'productCategoryName',
+						item.category.categoryLevelPath
+					);
+					this.$set(parasm, 'totalCount', item.dosage);
+					this.$set(parasm, 'productCode', item.code);
+					this.$set(parasm, 'productName', item.name);
+					this.$set(parasm, 'availableCountBase', item.availableCountBase);
+					this.$set(parasm, 'modelType', item.modelType);
+					this.$set(parasm, 'weightUnit', item.unit);
+					this.$set(parasm, 'measuringUnit', item.unit);
+					this.$set(parasm, 'specification', item.specification);
+					this.$set(parasm, 'remark', '');
+					this.$set(parasm, 'imgCode', item.imgCode);
+					this.$set(parasm, 'produceType', item.componentAttribute);
+					this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
+					this.$set(parasm, 'goodsLevel', item.goodsLevel);
+					this.$set(parasm, 'supplierList', item.supplierList);
+					this.$set(parasm, 'supplierCode', item.supplierCode);
+					this.$set(parasm, 'supplierId', item.supplierId);
+					this.$set(parasm, 'supplierName', item.supplierName);
+					// if (item.modelKey) {
+					// 	this.$set(parasm, 'modelKey', item.modelKey.split(','));
+					// }
+					// if (item.colorKey) {
+					// 	this.$set(parasm, 'colorKey', item.colorKey.split(','));
+					// }
+					this.$set(
+						parasm,
+						'packageDispositionList',
+						item.packageDispositionList?.map(i => {
+							return {
+								...i,
+								text: i.conversionUnit,
+								value: i.id
+							}
+						}) || []
+					);
+					if (item.packageDispositionList?.length) {
+						this.$set(
+						parasm,
+						'purchaseUnitId',
+						item.packageDispositionList[0].id
+						);
+						this.$set(
+						parasm,
+						'purchaseUnit',
+						item.packageDispositionList[0].conversionUnit
+						);
+					}
+					this.$set(
+						parasm,
+						'packingSpecification',
+						item.extField?.packingSpecification
+					);
+					this.$set(parasm, 'provenance', item.purchaseOrigins || '');
+					this.$set(parasm, 'provenanceName', this.getProvenance(item.provenance));
+
+					if (idx == -1) {
+						this.tableList.push(row);
+					}
+				});
+			})
+		},
+		onUnload() {
+			uni.$off('setProduceList')
+			uni.$off('setTaskName')
+			uni.$off('setPBomList')
 		},
 		watch: {
 			contractId(val) {
 				if (val) {
 					this.btnList = []
 				}
-
 			}
 		},
 		methods: {
 			...mapActions('dict', ['requestDict']),
+			openPicker() {
+				this.$refs.treePicker._show()
+			},
+			getProvenance(item) {
+				console.log('getProvenance~~~~~', item)
+				// try {
+					// 检查item和provenance是否存在
+					if (!item) {
+						return '';
+					}
+
+					let arr = item;
+
+					if(!Array.isArray(arr)) {
+						console.log('arr is not array, convert to array')
+						arr = arr.split(',');
+					}
+
+				    return arr && arr.length ? arr.map((i) => {
+						return this.purchase_origin.find(p => p.value == i)?.text
+					}).join(',') : '';
+			},
+			changeMultiple(item, index, key, range) {
+				console.log(item, index)
+				this.current = item;
+				this.currentIndex = index;
+				this.multipleSelectRange = range
+				this.$refs.multipleSelectRef.open(item, index, key)
+			},
+			handleMultipleConfirm(data, key) {
+				this.$set(this.tableList[this.currentIndex], key, data)
+				if(key == 'provenance'){
+					this.$set(this.tableList[this.currentIndex], 'provenanceName', this.getProvenance(data))
+				}
+			},
+			change(e){
+				console.log('e:',e);
+			},
 			settingDate(item, index) {
 				console.log(item, index)
 				this.current = item;
@@ -516,11 +634,14 @@
 				this.$set(this.tableList[this.currentIndex], 'arrivalBatch', data)
 			},
 			add() {
+				this.currentIndex = -1;
+				this.current = {};
+				this.c
 				if (this.isTemporary) {
 					this.show = true
 				} else {
 					uni.navigateTo({
-						url: '/pages/saleManage/components/selectProduce?isAll=' + 1
+						url: '/pages/purchasingManage/components/selectProduce?isAll=' + 1
 					})
 				}
 			},
@@ -529,7 +650,7 @@
 			}) {
 				if (name == '选择物品清单') {
 					uni.navigateTo({
-						url: '/pages/saleManage/components/selectProduce?isAll=' + 1
+						url: '/pages/purchasingManage/components/selectProduce?isAll=' + 1
 					})
 				} else {
 					this.handlAdd()
@@ -539,7 +660,7 @@
 				this.current = item;
 				this.currentIndex = index;
 				uni.navigateTo({
-					url: '/pages/saleManage/components/selectProduce?isAll=' + 2
+					url: '/pages/purchasingManage/components/selectProduce?isAll=' + 2
 				})
 			},
 			selectTaskName(item, index) {
@@ -559,7 +680,7 @@
 			init(list) {
 				if (list) {
 					this.tableList = JSON.parse(JSON.stringify(list))
-					this.getTotalPrice(list)
+					// this.getTotalPrice(list)
 				}
 			},
 			getValue() {

+ 454 - 0
pages/purchasingManage/components/selectPBom.vue

@@ -0,0 +1,454 @@
+<template>
+	<view class="mainBox">
+		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择" @clickLeft="backAdd">
+
+		</uni-nav-bar>
+		<view class="searchBox">
+			<input v-model="searchVal" placeholder="请输入名称" class="searchInput" />
+			<u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" data-icon="Search" class="searchBtn">
+				<view class="iconfont icon-sousuo"></view>
+				<view class="text">搜索</view>
+			</u-button>
+		</view>
+		<view class="wrapper">
+			<u-list @scrolltolower="scrolltolower" class="listContent">
+				<checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
+					<label>
+						<view class="listBox">
+							<view class="listBox-sel">
+								<checkbox :value="item.code" color="#fff" :disabled="item.disabled"
+									:checked="item.checked" />
+							</view>
+							<view class="listBox-con">
+								<view class="listBox-top">
+									<view class="listBox-name">
+										{{ item.name }}
+									</view>
+									<view class="listBox-code">
+										{{ item.code }}
+									</view>
+								</view>
+								<view class="listBox-bottom">
+									<view>分类:{{ item.category.categoryLevelPath }}</view>
+									<view>牌号:{{ item.category.brandNum }}</view>
+									<view>型号:{{ item.category.modelType }}</view>
+									<view>规格:{{ item.category.specification }}</view>
+									<view>用量:{{ item.dosage }}</view>
+									<view>单位:{{ item.category.measuringUnit }}</view>
+									<view>版本:{{ item.versions?'V'+item.versions+'.0':'' }}</view>
+								</view>
+							</view>
+						</view>
+					</label>
+				</checkbox-group>
+				<u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
+			</u-list>
+		</view>
+
+		<view class="footer">
+			<view class="bottom" v-if="this.isAll==1">
+				<checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
+				<checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
+				</checkbox>
+			</view>
+			<u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
+				<view class="selBtn">选择( {{ checkListLen }} )</view>
+			</u-button>
+		</view>
+		<ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择部门"
+			:localdata="classificationList" valueKey="id" textKey="name" />
+	</view>
+</template>
+
+<script>
+	import {
+		getCBomAPI,
+	} from '@/api/purchasingManage/purchaseNeedManage.js'
+	import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
+	import { getInventoryTotal } from '@/api/pda/workOrder'
+	export default {
+		components: {
+			baTreePicker
+		},
+		props: {
+			/*是否需要获取仓库产品数量*/
+			isGetInventoryTotal: {
+				type: Boolean,
+				default: false
+			}
+		},
+		data() {
+			return {
+				page: 1,
+				size: 10,
+				isEnd: false,
+				searchVal: '',
+				pickTabIndex: 1,
+				popupShow: false, //右侧搜索窗
+				typeIndex: 1,
+				listData: [], //列表数据
+				classificationList: [], //分类数据
+				seletedAll: false, //全选状态,
+				isAll: '',
+				currentId: ''
+			}
+		},
+		//选择的列表长度
+		computed: {
+			checkListLen() {
+				return this.listData.filter(el => el.checked).length
+			},
+
+		},
+		onShow() {
+			this.isEnd = false
+			this.page = 1
+			this.getList()
+		},
+		onLoad({
+			isAll, id
+		}) {
+			this.isAll = isAll //1多选 2单选
+			this.currentId = id;
+			this.getList()
+		},
+		onShow() {},
+		methods: {
+			scrolltolower() {
+				this.getList()
+			},
+			//列表数据
+			getList() {
+				if (this.isEnd) {
+					return
+				}
+
+				uni.showLoading({
+					title: '加载中'
+				})
+
+				let params = {
+					pageNum: this.page,
+					size: this.size,
+					name: this.searchVal,
+					categoryId: this.currentId,
+					bomType: 1
+				}
+
+				getCBomAPI(params).then(res => {
+					this.listData = res
+					// if (this.page === 1) {
+					// 	this.listData = res.list
+					// } else {
+					// 	this.listData.push(...res.list)
+					// }
+					// this.page += 1
+					// this.isEnd = this.listData.length >= res.count
+				}).then(() => {
+					uni.hideLoading()
+				})
+
+
+
+				// this.isEnd = false
+				// this._getClassifyList()
+			},
+			async _getClassifyList() {
+				uni.showLoading({
+					title: '数据加载中'
+				})
+				const params = {
+					pageNum: 1,
+					size: this.size,
+					name: this.searchVal,
+					categoryId: this.currentId,
+					bomType: 1
+				}
+
+				getCBomAPI(params).then(res => {
+					uni.hideLoading()
+					this.listData = res
+					// if (this.page == 1) {
+					// 	this.listData = []
+					// }
+					// this.listData = this.listData.concat(res.list)
+					// this.isEnd = this.listData.length >= res.count
+				})
+			},
+			confirm([id]) {
+				this.categoryLevelId = id
+				this.page = 1
+				this.getList()
+			},
+			async getClassify() {
+				listOrganizations(1).then(res => {
+					this.classificationList = res
+					this.page = 1
+					this.getList()
+				});
+			},
+			doSearch() {
+				this.isEnd = false
+				this.page = 1
+				this.getList()
+			},
+			//勾选
+			selectVal(e, val, index) {
+
+				this.$set(this.listData[index], 'checked', !this.listData[index].checked)
+
+				if (this.isAll != 1) {
+					this.listData.forEach((item, i) => {
+						if (item.id != val.id) {
+							this.$set(this.listData[i], 'checked', false)
+						}
+					})
+				} else {
+
+					this.seletedAll = !this.listData.some(item => !item.checked)
+				}
+
+			},
+			//全选按钮
+			_seletedAll() {
+				if (!this.seletedAll) {
+					this.seletedAll = true
+					this.listData.map(item => {
+						this.$set(item, 'checked', true)
+					})
+				} else {
+					this.seletedAll = false
+					this.listData.map(item => {
+						this.$set(item, 'checked', false)
+					})
+				}
+			},
+			//跳转回添加页面
+			async jumpAdd() {
+				const list = this.listData.filter(item => item.checked);
+				//获取仓库库存
+				let codeList = [];
+				if (this.isGetInventoryTotal) {
+					codeList = list.map((item) => item.code);
+					let inventoryTotalList = await getInventoryTotal(codeList);
+					list.forEach((item) => {
+						let find =
+						inventoryTotalList.find((key) => key.code == item.code) || {};
+						item.availableCountBase = find.availableCountBase;
+					});
+				}
+				uni.$emit('setPBom', list)
+				uni.navigateBack();
+				// uni.$emit(
+				// 	'setProduceList',
+				// 	this.listData.filter(item => item.checked)
+				// )
+
+				// uni.navigateBack({
+				// 	delta: 2
+				// });
+			},
+			//返回添加页
+			backAdd() {
+				uni.navigateBack({
+					delta: 2
+				});
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.mainBox {
+		height: 100vh;
+		display: flex;
+		flex-direction: column;
+
+		.wrapper {
+			flex: 1;
+			overflow: hidden;
+		}
+
+		.searchBox {
+			padding: 10rpx 0;
+			box-sizing: border-box;
+			background-color: #dedede;
+			height: 90rpx;
+			width: 100%;
+			line-height: 90rpx;
+			display: flex;
+			justify-content: space-around;
+			align-items: center;
+
+			input {
+				height: 78rpx;
+				width: 65%;
+				background: #f9f9f9 !important;
+				margin: 0 10rpx;
+				padding: 0 10rpx;
+				box-sizing: border-box;
+				border-radius: 5rpx;
+			}
+
+			.searchBtn {
+				height: 80rpx;
+				background: #f9f9f9 !important;
+				color: #676767;
+				font-size: 28rpx;
+				padding: 0 42rpx;
+				box-sizing: border-box;
+				outline: none;
+				border: none;
+				width: 260rpx;
+
+				.icon-sousuo {
+					font-size: 22px;
+				}
+
+				.text {
+					font-size: 16px;
+					margin-left: 10px;
+				}
+			}
+		}
+
+		.tab-title {
+			position: fixed;
+			top: 190rpx;
+			z-index: 99;
+			width: 100%;
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			height: $tab-height;
+			line-height: $tab-height;
+			background-color: #ffffff;
+			border-bottom: 2rpx solid #f2f2f2;
+			box-sizing: border-box;
+
+			.tab-item {
+				width: 25%;
+				text-align: center;
+				font-size: 32rpx;
+				color: $uni-text-color-grey;
+			}
+
+			.tab-item.active {
+				color: $j-primary-border-green;
+				border-bottom: 1px solid $j-primary-border-green;
+				font-weight: bold;
+			}
+
+			.tab-item.filter {
+				flex: 1;
+				padding: 0px 30rpx;
+
+				.uni-icons {
+					display: flex;
+					padding-top: 5px;
+				}
+			}
+
+			.screenIcon {
+				display: flex;
+				width: 80px;
+				justify-content: center;
+
+				.screenText {
+					font-size: 32rpx;
+					color: $uni-text-color-grey;
+				}
+			}
+		}
+
+		.listContent {
+			height: 100% !important;
+
+			.listBox {
+				display: flex;
+				// height: 180rpx;
+				padding: 20rpx 0;
+				border-bottom: 2rpx solid #e5e5e5;
+
+				.listBox-sel {
+					height: 90rpx;
+					width: 80rpx;
+					// line-height: 90rpx;
+					text-align: center;
+
+					checkbox {
+						transform: scale(1.2);
+					}
+				}
+
+				.listBox-con {
+					width: 100%;
+					// display: flex;
+					// flex-wrap: wrap;
+					// justify-content: space-between;
+					align-items: center;
+					padding: 0 18rpx 0 0;
+
+					.listBox-top {
+						width: 100%;
+						display: flex;
+						justify-content: space-between;
+						padding-bottom: 10rpx;
+
+						.listBox-name,
+						.listBox-code {
+							display: inline-block;
+							font-size: $uni-font-size-sm;
+							font-weight: bold;
+						}
+					}
+
+					.listBox-bottom {
+						width: 100%;
+						display: flex;
+						justify-content: space-between;
+						font-size: $uni-font-size-sm;
+						flex-wrap: wrap;
+
+						>view {
+							width: 50%;
+							overflow: hidden;
+							white-space: nowrap;
+							text-overflow: ellipsis;
+						}
+					}
+				}
+			}
+
+			.noDate {
+				height: 100%;
+			}
+		}
+
+		//底部按钮
+		.footer {
+			height: 90rpx;
+			position: relative;
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			bottom: 0;
+			width: 100%;
+			height: 100rpx;
+			border-top: 1rpx solid #eeecec;
+			background-color: #ffffff;
+			z-index: 999;
+
+			.bottom {
+				margin-left: 10rpx;
+			}
+
+			.u-reset-button {
+				position: absolute;
+				right: 10rpx;
+				top: 20rpx;
+				width: 150rpx;
+			}
+		}
+	}
+</style>

+ 118 - 7
pages/purchasingManage/components/selectProduce.vue

@@ -39,6 +39,9 @@
 									<view>计量单位:{{ item.measuringUnit }}</view>
 									<view>包装单位:{{ item.packingUnit }}</view>
 									<view>重量单位:{{ item.weightUnit }}</view>
+									<view>操作:
+										<u-button :plain="true" :hairline="true" size='mini' type="primary" text="选择PBom" @click="action(item)"></u-button>
+									</view>
 								</view>
 							</view>
 						</view>
@@ -70,11 +73,12 @@
 		getCategoryPackageDisposition
 	} from '@/api/warehouseManagement'
 	import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
+	import { contactQueryByCategoryIdsAPI } from '@/api/warehouseManagement/index'
+	import { getInventoryTotal } from '@/api/pda/workOrder'
 	export default {
 		components: {
 			baTreePicker
 		},
-
 		data() {
 			return {
 				page: 1,
@@ -93,13 +97,45 @@
 		},
 		//选择的列表长度
 		computed: {
-
 			checkListLen() {
-
 				return this.listData.filter(el => el.checked).length
 			},
 
 		},
+		created() {
+			uni.$off('setPBom');
+			uni.$on('setPBom', async (data) => {
+				let list = data;
+				//获取供应商
+				// if (this.isSupplier) {
+					let supplierList = await this.getSupplierObj(list, 'categoryId');
+					list.forEach((item) => {
+						item['supplierList'] = supplierList[item.categoryId]?.map(i => {
+							return {
+								...i,
+								text: i.name,
+								value: i.id
+							}
+						}) || [];
+						// item['entrustedEnterpriseIdList'] = supplierList[item.categoryId];
+						if (supplierList[item.categoryId]?.length) {
+							// item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
+							item['supplierCode'] = supplierList[item.categoryId][0].code;
+							item['supplierId'] = supplierList[item.categoryId][0].id;
+							item['supplierName'] = supplierList[item.categoryId][0].name;
+						}
+					});
+				// }
+				uni.$emit(
+					'setPBomList',
+					list
+				)
+				uni.navigateBack()
+			})
+		},
+		onUnload() {
+			uni.$off('setPBom')
+		},
 		onLoad({
 			isAll
 		}) {
@@ -108,6 +144,22 @@
 		},
 		onShow() {},
 		methods: {
+			async getSupplierObj(productList, queryName) {
+				try {
+					let categoryIds = productList
+						.filter((item) => item[queryName])
+						.map((item) => item[queryName]);
+					if (categoryIds.length > 0) {
+						return await contactQueryByCategoryIdsAPI({
+						categoryIds
+						});
+					} else {
+						return Promise.resolve({});
+					}
+				} catch (e) {
+					return Promise.resolve({});
+				}
+			},
 			scrolltolower() {
 				if (this.isEnd) {
 					return
@@ -164,9 +216,7 @@
 			},
 			//勾选
 			selectVal(e, val, index) {
-
 				this.$set(this.listData[index], 'checked', !this.listData[index].checked)
-
 				if (this.isAll != 1) {
 					this.listData.forEach((item, i) => {
 						if (item.id != val.id) {
@@ -197,16 +247,69 @@
 			async jumpAdd() {
 				let list = this.listData.filter(item => item.checked)
 
+				let codeList = list.map((item) => item.code);
+				let idList = list.map((item) => item.id);
+
+				//获取仓库库存
+				// if (this.isGetInventoryTotal) {
+					let inventoryTotalList = await getInventoryTotal(codeList);
+					list.forEach((item) => {
+						let find =
+						inventoryTotalList.find((key) => key.code == item.code) || {};
+						item.availableCountBase = find.availableCountBase;
+					});
+				// }
+				//获取供应商
+				// if (this.isSupplier) {
+					let supplierList = await this.getSupplierObj(list, 'id');
+					list.forEach((item) => {
+						item['supplierList'] = supplierList[item.id]?.map(i => {
+							return {
+								...i,
+								text: i.name,
+								value: i.id
+							}
+						}) || [];
+						item['entrustedEnterpriseIdList'] = supplierList[item.id]?.map(i => {
+							return {
+								...i,
+								text: i.name,
+								value: i.id
+							}
+						}) || [];
+						if (supplierList[item.id]?.length) {
+							item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
+							item['supplierCode'] = supplierList[item.id][0].code;
+							item['supplierId'] = supplierList[item.id][0].id;
+							item['supplierName'] = supplierList[item.id][0].name;
+						}
+					});
+				// }
 				// 获取包装规格
 				let packingSpecification = await getCategoryPackageDisposition({
-					categoryIds: list.map(item => item.id)
+					categoryIds: idList
 				});
 				list.forEach((item) => {
 					item['packageDispositionList'] = packingSpecification
 						.filter((ite) => item.id == ite.categoryId && ite.conversionUnit)
 						.sort((a, b) => a.sort - b.sort);
+					if (item.level) {
+						item['goodsLevel'] = levelList.find(
+						(val) => val.label == item.level
+						)?.value;
+					}
 				});
 
+				// 获取包装规格
+				// let packingSpecification = await getCategoryPackageDisposition({
+				// 	categoryIds: list.map(item => item.id)
+				// });
+				// list.forEach((item) => {
+				// 	item['packageDispositionList'] = packingSpecification
+				// 		.filter((ite) => item.id == ite.categoryId && ite.conversionUnit)
+				// 		.sort((a, b) => a.sort - b.sort);
+				// });
+
 
 				uni.$emit(
 					'setProduceList',
@@ -218,7 +321,12 @@
 			//返回添加页
 			backAdd() {
 				uni.navigateBack()
-			}
+			},
+			action(item) {
+				uni.navigateTo({
+					url: '/pages/purchasingManage/components/selectPBom?isAll=' + 2 + '&id=' + item.id
+				})
+			},
 		}
 	}
 </script>
@@ -415,5 +523,8 @@
 				width: 150rpx;
 			}
 		}
+		.text-color {
+			color: #409eff;
+		}
 	}
 </style>

+ 20 - 2
pages/purchasingManage/components/timePopup.vue

@@ -22,8 +22,8 @@
                 </uni-tr>
             </uni-table>
             <view class="footerButton">
-                <u-button type="primary" @click="handleConfirm" text="确认"></u-button>
                 <u-button type="default" @click="handleClose" text="关闭"></u-button>
+                <u-button type="primary" @click="handleConfirm" text="确认"></u-button>
             </view>
         </scroll-view>
     </uni-popup>
@@ -109,7 +109,25 @@ export default {
     }
 }
 </script>
-<style scoped>
+<style scoped lang="scss">
+    .footerButton {
+		width: 100%;
+		height: 84rpx;
+		display: flex;
+		position: fixed;
+		bottom: 0;
+		z-index: 10;
+		background-color: #fff;
+
+		/deep/.u-button {
+			height: 100%;
+		}
+
+		>view {
+			flex: 1;
+
+		}
+	}
     .scroll-content {
         padding: 20rpx;
     }

+ 117 - 62
pages/purchasingManage/purchaseNeedManage/add.vue

@@ -42,8 +42,7 @@
 				</u--input>
 			</u-cell>
 			<u-cell title="销售合同" arrow-direction="down">
-				<u--input slot="value" placeholder="请选择" border="surround" v-model="form.saleContractNo"
-					@click.native="selectContractShow"></u--input>
+				<u--input slot="value" style="flex:1" placeholder="请选择销售合同" border="surround" v-model="form.saleContractNo" @click.native="selectContractShow"></u--input>
 			</u-cell>
 			<u-cell title="销售订单" arrow-direction="down">
 				<!-- <u--input slot="value" placeholder="请输入" border="requireUserId" v-model="form.name"></u--input> -->
@@ -55,36 +54,16 @@
 				<uni-data-picker v-model="form.acceptUnpack" slot="value" placeholder="请选择"
 					:localdata="acceptUnpackList" @change="sourceCodeOnchange">
 				</uni-data-picker>
-				<!-- <u--input slot="value" :disabled="true" placeholder="请输入" border="surround"
-					v-model="form.responsibleName"></u--input> -->
-				<!-- <u-radio-group
-					v-model="form.acceptUnpack"
-					placement="column"
-					@change="groupChange"
-				>
-					<u-radio
-						:customStyle="{marginBottom: '8px'}"
-						v-for="(item, index) in radiolist1"
-						:key="index"
-						:label="item.name"
-						:name="item.name"
-						@change="radioChange"
-					>
-					</u-radio>
-				</u-radio-group> -->
 			</u-cell>
 			<u-cell title="'用途" arrow-direction="down">
 				<view slot="title" style="display: flex; align-items: center;">
 					<text class="required-mark">*</text>
 					用途
 				</view>
-				<!-- <uni-data-picker v-model="form.useTo" slot="value" placeholder="请选择"
-					:localdata="business_opport_code" @change="sourceCodeOnchange">
-				</uni-data-picker> -->
 				<u--textarea slot="value" placeholder="请输入" border="surround" v-model="form.useTo"></u--textarea>
 			</u-cell>
 			<u-cell title="附件" arrow-direction="down">
-				<view slot="value" style="display: flex;align-items: center;width: 100%;">
+				<view slot="value" style="display: flex;align-items: center;">
 					<fileMain v-model="form.fileId"></fileMain>
 				</view>
 			</u-cell>
@@ -110,7 +89,6 @@
 
 <script>
 	import { getByCode } from '@/api/pda/common.js'
-	import { contactDetail } from '@/api/saleManage/contact/index.js'
 	import searchSelect from '@/pages/salesServiceManagement/accessory/components/searchSelect.vue';
 	import produceList from '../components/produceList.vue'
 	import fileMain from "@/pages/doc/index.vue"
@@ -124,6 +102,8 @@
 		addPurchaseNeedManage,
 		UpdateInformation
 	} from '@/api/purchasingManage/purchaseNeedManage.js'
+	import { getInventoryTotal } from '@/api/pda/workOrder'
+	import { contactQueryByCategoryIdsAPI } from '@/api/warehouseManagement/index'
 	export default {
 		components: {
 			produceList,
@@ -139,6 +119,7 @@
 				requirementSourceType,
 				classificationList: [],
 				isUpdate: false,
+				purchase_origin: [],
 				form: {
 					id: '',
 					receiveDate: null,
@@ -156,9 +137,9 @@
 					saleContractId: '',
 					saleOrderId: '',
 					saleOrderNo: '',
-					files: [],
+					files: [], //附件集合
 					acceptUnpack: 1,
-					fileId: [] //附件集合
+					fileId: [],
 				},
 				business_opport_code: [],
 				linkList: [],
@@ -179,6 +160,7 @@
 						saleContractName: data[0].contractName,
 						saleContractNo: data[0].contractNo,
 					});
+					console.log('ddd~~~', data[0])
 					this.getSaleOrderList(data[0].id);
 				}
 
@@ -198,18 +180,6 @@
 				}
 			})
 
-			// uni.$off('setSelectList')
-			// uni.$on('setSelectList', async (data) => {
-			// 	if (data && data.length > 0) {
-			// 		const {
-			// 			linkList
-			// 		} = await contactDetail(data[0].id)
-			// 		this.linkList = linkList
-			// 		this.$set(this.form, 'contactId', data[0].id);
-			// 		this.$set(this.form, 'contactName', data[0].name);
-			// 	}
-
-			// })
 		},
 		onLoad(data) {
 			this.getTreeList()
@@ -223,20 +193,61 @@
 					}
 					// setTimeout(() => {
 						// this.current = 0
-						this.$nextTick(() => {
+						this.$nextTick(async () => {
 							// this.$refs.infoRef.init(res)
-							const tempData = res.detailList.map(item => {
-								return {
-									...item,
-									packageDispositionList: item.packageDispositionList.map(i => {
-										return {
-											...i,
-											text: i.conversionUnit,
-											value: i.id
-										}
-									})
-								}
-							})
+							// 获取所有有productCode的产品ID和编码
+							let validItems = this.form.detailList.filter(item => item.productCode);
+							let productIds = validItems.map(item => item.productId);
+							let productCodes = validItems.map(item => item.productCode);
+							
+							// 批量获取库存和供应商信息
+							let inventoryTotalList = [];
+							let supplierObj = {};
+							if (productIds.length > 0) {
+								inventoryTotalList = await getInventoryTotal(productCodes);
+								supplierObj = await contactQueryByCategoryIdsAPI({
+									categoryIds: productIds
+								});
+								
+								// 更新每个产品的供应商和库存信息
+								validItems.forEach((item, index) => {
+									// 找到对应的索引位置
+									let actualIndex = this.form.detailList.findIndex(i => i.productCode === item.productCode);
+									if (actualIndex !== -1) {
+										this.$set(
+											this.form.detailList[actualIndex],
+											'supplierList',
+											supplierObj[item.productId]?.map(i => ({
+												...i,
+												text: i.name,
+												value: i.id
+											})) || []
+										);
+										
+										let find = inventoryTotalList.find(key => key.code == item.productCode) || {};
+										this.$set(
+											this.form.detailList[actualIndex],
+											'availableCountBase',
+											find.availableCountBase
+										);
+									}
+								});
+							}
+							
+							// 处理数据格式
+							const tempData = this.form.detailList.map(item => ({
+								...item,
+								provenanceName: item.provenance ? this.getProvenance(item.provenance) : '',
+								// modelKey: item.modelKey?.split(',') || [],
+								// colorKey: item.colorKey?.split(',') || [],
+								packageDispositionList: item.packageDispositionList?.map(i => ({
+									...i,
+									text: i.conversionUnit,
+									value: i.id
+								})) || []
+							}));
+							
+							console.log('tempData~~~', tempData)
 							this.$refs.produceListRef.init(tempData)
 							// if (data.current) {
 							// 	this.current = +data.current
@@ -247,17 +258,36 @@
 			} else {
 				const userInfo = uni.getStorageSync('userInfo')
 				this.$set(this.form, 'requireUserId', userInfo.userId);
-				this.$set(this.form, 'requirementName', userInfo.name);
+				this.$set(this.form, 'requireUserName', userInfo.name);
+				this.$set(this.form, 'requireDeptId', userInfo.groupId);
+				this.$set(this.form, 'requireDeptName', userInfo.groupName);
 			}
 
 		},
 		onUnload() {
-			// uni.$off('setSelectList')
 			uni.$off('setContractList')
 			uni.$off('setSaleOrder')
-			// uni.$off('updatelinkList')
 		},
 		methods: {
+			getProvenance(item) {
+				console.log('getProvenance~~~~~', item)
+				// try {
+					// 检查item和provenance是否存在
+					if (!item) {
+						return '';
+					}
+
+					let arr = item;
+
+					if(!Array.isArray(arr)) {
+						console.log('arr is not array, convert to array')
+						arr = arr.split(',');
+					}
+
+				    return arr && arr.length ? arr.map((i) => {
+						return this.purchase_origin.find(p => p.value == i)?.text
+					}).join(',') : '';
+			},
 			async getSaleOrderList(contractId) {
 				let res = await getTableList({
 				pageNum: 1,
@@ -271,8 +301,16 @@
 			async getSaleOrderDetail(id) {
 				const data = await getSaleOrderDetail(id);
 				data.productList.forEach((item) => {
-				item.expectReceiveDate = item.produceDeliveryDeadline;
-				item.arrivalWay = 1;
+					item.expectReceiveDate = item.produceDeliveryDeadline;
+					item.arrivalWay = 1;
+					item['packageDispositionList'] = item.packageDispositionList?.map(i => {
+						return {
+							...i,
+							text: i.conversionUnit,
+							value: i.id
+						}
+					}) || []
+
 				});
 
 				this.$nextTick(() => {
@@ -302,11 +340,11 @@
 				this.getUserList(id[0]);
 				this.$refs.selector.clearSearchText();
 			},
-			// 打开使用人弹窗
+			// 打开需求人弹窗
 			openSelector() {
 				this.$refs.selector.open();
 			},
-			// 获取使用人数据
+			// 获取需求人数据
 			async getUserList(id) {
 				let params = {
 					pageNum: 1,
@@ -326,14 +364,15 @@
 					this.executorList = [];
 				}
 			},
-			// 使用人选择
+			// 需求人选择
 			onClose(item) {
 				this.form.requireUserName = item.text;
 			},
 			//选择合同
 			selectContractShow() {
+				console.log('ddd~~~')
 				uni.navigateTo({
-					url: '/pages/saleManage/components/selectContract?isAll=' + 2
+					url: '/pages/purchasingManage/components/selectContract?isAll=' + 2
 				})
 			},
 			slectOrderShow() {
@@ -342,7 +381,7 @@
 				})
 			},
 			getByCode() {
-				const codeS = ['business_opport_code']
+				const codeS = ['business_opport_code', 'purchase_origin']
 				codeS.forEach(async (code) => {
 					const codeValue = await getByCode(code);
 					this[code] = codeValue.map(item => {
@@ -416,13 +455,21 @@
 					}
 
 					let isArrivalBatch = false;
+					let isError = false;
 					detailList.forEach((v) => {
 						if (v.arrivalWay == 2 && (!v.arrivalBatch || v.arrivalBatch.length == 0) ) {
 							isArrivalBatch = true;
 						}
+						if (!v.purchaseCount || !v.productName || !v.arrivalWay || (!v.expectReceiveDate && v.arrivalWay == 1)) {
+							isError = true;
+						}
 					});
+					if (isError) {
+						uni.showToast({icon: none, title: '请完善产品信息'});
+						return;
+					}
 					if (isArrivalBatch) {
-						uni.showToast({title: '请设置分批时间'});
+						uni.showToast({icon: none, title: '请设置分批时间'});
 						return;
 					}
 
@@ -435,6 +482,14 @@
 						detailList: detailList
 					};
 
+					data.fileId = JSON.stringify(data.fileId)
+
+					data.detailList.forEach((item) => {
+						if(item.provenance && typeof item.provenance == 'string') {
+							item.provenance = item.provenance.split(',')
+						}
+					})
+
 					console.log('data~~~', data)
 
 					const requestApi = this.isUpdate ? UpdateInformation : addPurchaseNeedManage

+ 0 - 18
pages/purchasingManage/purchaseNeedManage/components/drawer.vue

@@ -4,24 +4,7 @@
 			@clickLeft="back">
 		</uni-nav-bar>
 		<myCard :item="form" :columns="columns"></myCard>
-		<!-- <view class="item">
-			<view class="card">
 
-				<view>
-					<view class="lable">预算</view>
-					<view>{{form.budget||''}} 万元</view>
-				</view>
-				<view>
-					<view class="lable">赢单率</view>
-					<view>{{form.winRate||''}} %</view>
-				</view>
-				<view>
-					<view class="lable">预计结单日期</view>
-					<view>{{form.expectedClosingDate||''}}</view>
-				</view>
-
-			</view>
-		</view> -->
 
 		<!-- <u-sticky bgColor="#fff" :customNavHeight="88"> -->
 		<u-tabs :list="list1" @change="change" :current="current"></u-tabs>
@@ -44,7 +27,6 @@
 	export default {
 		components: {
 			produceList,
-			followList,
 			info,
 			myCard
 		},

+ 8 - 6
pages/purchasingManage/purchaseNeedManage/components/info.vue

@@ -46,17 +46,17 @@
 					{{form.remark||''}}
 				</text>
 			</u-cell>
-			<!-- <u-cell title="附件" arrow-direction="down">
+			<u-cell title="附件" arrow-direction="down">
 				<text slot="value">
-					{{form.createUsername||''}}
+					<fileMain v-model="form.fileId" type="view"></fileMain>
 				</text>
-			</u-cell> -->
+			</u-cell>
 		</u-cell-group>
 	</view>
 </template>
 
 <script>
-	
+	import fileMain from "@/pages/doc/index.vue"
 	export default {
 		data() {
 			return {
@@ -64,7 +64,9 @@
 				form: {},
 			}
 		},
-
+		components: {
+			fileMain
+		},
 		created() {
 
 		},
@@ -73,7 +75,7 @@
 				console.log(data,'datasss')
 				if (data) {
 					this.form = data
-		
+					this.form.fileId = JSON.parse(this.form.fileId)
 				}
 			},
 

+ 47 - 59
pages/purchasingManage/purchaseNeedManage/index.vue

@@ -18,7 +18,7 @@
 		<view class="wrapper">
 			<u-list @scrolltolower="scrolltolower" class="listContent">
 				<view v-for="(item, index) in tableList" :key="index" style="position: relative;">
-					<myCard @del="del(item)" :item="item" :index="index+1" :columns="columns" :btnList="btnList">
+					<myCard :item="item" :index="index+1" :columns="columns" :btnList="btnList" @del="del(item)" @handleAudit="handleAudit(item)">
 					</myCard>
 				</view>
 			</u-list>
@@ -33,27 +33,6 @@
 
 		
 		<u-toast ref="uToast"></u-toast>
-		<u-modal @confirm="handleSubmit" ref="popup" type="center" :show="modalShow" @cancel="modalShow=false"
-			:showCancelButton="true" :closeOnClickOverlay="true">
-			<view class="popup-content">
-
-				<form>
-					<view class="form-item">
-						<label class="form-label">*部门</label>
-						<u--input placeholder="部门" @click.native="showPicker"
-							v-model="addForm.planExecuteGroupName"></u--input>
-					</view>
-					<view class="form-item">
-						<label class="form-label">*计划执行人</label>
-
-						<uni-data-picker v-model="addForm.planExecuteUserId" placeholder="请选择" :localdata="userList"
-							@change="industryOnchange">
-						</uni-data-picker>
-					</view>
-
-				</form>
-			</view>
-		</u-modal>
 
 	</view>
 </template>
@@ -65,7 +44,10 @@
 	} from '@/api/purchasingManage/purchaseNeedManage.js'
 	import myCard from '../components/myCard.vue'
     import { reviewStatusEnum } from "@/enum/dict";
-	import { auditSalesDemand } from '@/api/salesServiceManagement/demandList/index.js'
+	import {
+		processInstanceCreateAPI,
+		processInstancePage
+	} from '@/api/wt/index.js'
 	export default {
 		components: {
 			myCard,
@@ -80,6 +62,13 @@
 				isEnd: false,
 				modalShow: false,
 				current: {},
+				addForm: {
+					planExecuteUserId: '',
+					planExecuteUserName: '',
+					planExecuteGroupId: '',
+					planExecuteGroupName: '',
+					id: ''
+				},
 				btnList: [{
 					name: '详情',
 					apiName: '',
@@ -111,16 +100,9 @@
 					judge: [{
 						authorities: '',
 					}, {
-						fn: (row) => {
-							if (row?.afterSalesType == 3) {
-								return (
-									(row?.approvalResult == 0 || row?.approvalResult == 3) &&
-									row?.demandStatus != 2
-								);
-							} else {
-								return row?.demandStatus == 0;
-							}
-						},
+						key: 'status',
+						value: [0, 3],
+
 					}],
 				},
                 {
@@ -227,43 +209,49 @@
 			},
 			handleAudit(row) {
 				this.current = row
-				if(row.afterSalesType==3){
-					this.listSubmit()
-				}else{
-					this.modalShow = true
-				}
-				
+				this.listSubmit()
 				console.log(this.modalShow, 'dsds')
 			},
-			handleSubmit() {
-				auditSalesDemand({
-						...this.addForm,
-						submitSource: 3,
-						id: this.current.id
+			async listSubmit() {
+				try {
+					//后台不提供接口
+					let list = await processInstancePage({
+						pageNo: 1,
+						pageSize: 1,
+						reset: true,
+						key: 'purchase_requirement_approve_tg'
 					})
-					.then((res) => {
-						if (res) {
-							this.modalShow = false
-							this.$refs.uToast.show({
-								type: "success",
-								message: "操作成功",
-							})
-							this.doSearch();
+					let params = {
+						businessId: this.current.id,
+						businessKey: 'purchase_requirement_approve_tg',
+						formCreateUserId: this.current.createUserId,
+						processDefinitionId: list?.list[0]?.processDefinition.id,
+						variables: {
+							businessCode: this.current.requirementCode,
+							businessName: this.current.requirementName,
+							businessType: this.current.sourceTypeName,
+						},
+					}
+
+					await processInstanceCreateAPI(params)
+					uni.showModal({
+						title: `提交成功`,
+						content: '',
+						confirmText: '确认',
+						showCancel: false, // 是否显示取消按钮,默认为 true
+						success: () => {
+							this.doSearch()
 						}
 					})
-					.catch((err) => {
-						this.modalShow = false
-					});
+				} catch {
+
+				}
 			},
 			add() {
 				uni.navigateTo({
 					url: '/pages/purchasingManage/purchaseNeedManage/add'
 				})
 
-			},
-
-			view() {
-
 			},
 			del(item) {
                 uni.showModal({

+ 1 - 0
utils/setProduct.js

@@ -2,6 +2,7 @@ import Vue from 'vue';
 
 //改变数量
 export function changeCount(row, countObj, noDiscountSingle) {
+  console.log(row, countObj, noDiscountSingle);
   let total = row[countObj.countKey] || 0;
   let data = row;
   if (row.packageDispositionList) {