Ver Fonte

feat(purchaseNeedManage): 完善采购需求管理功能

liujt há 6 meses atrás
pai
commit
d9818db15c

+ 161 - 13
pages/home/wt/components/purchaseNeedManage/taskForm.vue

@@ -29,7 +29,6 @@
 					<u--input style="width: 100%;" disabled v-model="form.saleOrderNo"></u--input>
 				</u-form-item>
 				<u-form-item label="是否接受拆单" prop="acceptUnpack" borderBottom>
-
 					<u-tag v-if='form.acceptUnpack==1' text="接受"  size="large" type="success"></u-tag>
 					<u-tag v-else-if='form.acceptUnpack==0' text="不接受"  size="large" type="warning"></u-tag>
 					<u--input v-else style="width: 100%;" disabled v-model="form.acceptUnpack"></u--input>
@@ -38,6 +37,9 @@
 				<u-form-item label="用途" prop="useTo" borderBottom>
 					<u--input style="width: 100%;" disabled v-model="form.useTo"></u--input>
 				</u-form-item>
+				<u-form-item label="附件" prop="fileId" borderBottom>
+					<fileMain type="view" v-model="form.fileId"></fileMain>
+				</u-form-item>
 				<u-form-item label="备注" prop="remark" borderBottom>
 					<u--input style="width: 100%;" disabled v-model="form.remark"></u--input>
 				</u-form-item>
@@ -50,7 +52,17 @@
 					<u-row v-for="(key,index1) in tableField" :key="index1">
 						<u-col :span="12">
 							<u-form-item :label="key.label" prop="categoryName" borderBottom>
-								<u--input style="width: 100%;" :title='item[key.field]' disabled
+								<view v-if="key.field == 'expectReceiveDate'">
+									<view v-if="item.arrivalWay == 2" style="color: #42b983;" @click="settingDate(item, index)">
+										分批时间
+									</view>
+									<u--input v-else style="width: 100%;" :title='item[key.field]' disabled
+									v-model="item[key.field]"></u--input>
+								</view>
+								<view v-else-if="key.field == 'technicalDrawings' || key.field == 'files'">
+									<fileMain type="view" v-model="item[key.field]"></fileMain>
+								</view>
+								<u--input v-else style="width: 100%;" :title='item[key.field]' disabled
 									v-model="item[key.field]"></u--input>
 							</u-form-item>
 						</u-col>
@@ -59,9 +71,8 @@
 				</u--form>
 				<u-gap height="40" bgColor="#f0f0f0"></u-gap>
 			</view>
-
 		</view>
-
+		<timePopup ref="timePopupRef" :isView="true"></timePopup>
 	</view>
 </template>
 
@@ -69,6 +80,10 @@
 	import {
 		getPurchaseRequirementByIdsAPI
 	} from '@/api/wt/index.js'
+	import fileMain from "@/pages/doc/index.vue"
+	import { levelList, lbjtList } from '@/enum/dict'
+	import { getByCode } from '@/api/pda/common.js'
+	import timePopup from '@/pages/purchasingManage/components/timePopup.vue'
 	export default {
 		props: {
 			businessId: {
@@ -78,6 +93,10 @@
 				default: ''
 			},
 		},
+		components: {
+			fileMain,
+			timePopup
+		},
 		data() {
 			return {
 				detailData: {},
@@ -91,20 +110,60 @@
 						field: 'productCode',
 					},
 					{
-						label: '类',
+						label: '类',
 						field: 'productCategoryName',
 					},
 					{
 						label: '数量',
-						field: 'totalCount',
+						field: 'purchaseCountName',
 					},
+					// {
+					// 	label: '单位',
+					// 	field: 'purchaseUnit',
+					// },
 					{
-						label: '单位',
-						field: 'measuringUnit',
+						label: '计量数量',
+						field: 'totalCountName',
 					},
+					// {
+					// 	label: '计量单位',
+					// 	field: 'measuringUnit',
+					// },
 					{
-						label: '品牌',
-						field: 'brand',
+						label: '包装规格',
+						field: 'packingSpecification',
+					},
+					{
+						label: '物品级别',
+						field: 'goodsLevelName',
+					},
+					{
+						label: '库存数量',
+						field: 'availableCountBase',
+					},
+					{
+						label: '已采数量',
+						field: 'doneTotalCount', // measuringUnit
+					},
+					{
+						label: '待采数量',
+						field: 'waitTotalCount', // measuringUnit
+					},
+					{
+						label: '工序',
+						field: 'taskName',
+					},
+					{
+						label: '批次号',
+						field: 'batchNo',
+					},
+					{
+						label: '供应商',
+						field: 'supplierName',
+					},
+					{
+						label: '产地',
+						field: 'provenanceName',
 					},
 					{
 						label: '型号',
@@ -114,23 +173,112 @@
 						label: '规格',
 						field: 'specification',
 					},
-					
+					{
+						label: '品牌',
+						field: 'brand',
+					},
+					{
+						label: '机型',
+						field: 'modelKey',
+					},
+					{
+						label: '颜色',
+						field: 'colorKey',
+					},
+					{
+						label: '到货方式',
+						field: 'arrivalWayName',
+					},
+					{
+						label: '到货日期',
+						field: 'expectReceiveDate',
+					},
+					{
+						label: '属性类型',
+						field: 'produceTypeName',
+					},
+					{
+						label: '图纸附件',
+						field: 'technicalDrawings',
+					},
+					{
+						label: '附件',
+						field: 'files',
+					},
+					{
+						label: '备注',
+						field: 'remark',
+					},
 				],
 				list: ['基本信息', '需求清单'],
-				curNow: 0
+				curNow: 0,
+				arrivalWayList: [
+					{ text: '一次性到货', value: 1 },
+					{ text: '分批到货', value: 2 }
+				],
+				purchase_origin: [],
+				current: {},
+				currentIndex: -1,
 			}
 		},
 		async mounted() {
+			this.getByCode()
 			await this.getDetailData(this.businessId);
 		},
 		methods: {
 			sectionChange(index) {
 				this.curNow = index;
 			},
+			settingDate(item, index) {
+				console.log(item, index)
+				this.current = item;
+				this.currentIndex = index;
+				this.$refs.timePopupRef.open(item, index)
+			},
 			async getDetailData(id) {
 				const data = await getPurchaseRequirementByIdsAPI(id);
 				this.form = data
-			}
+				this.form.fileId = this.form.fileId ? JSON.parse(this.form.fileId) : [];
+				this.form.detailList.forEach(item => {
+					item.purchaseCountName = (item.purchaseCount ? item.purchaseCount : '') + item.purchaseUnit;
+					item.totalCountName = (item.totalCount ? item.totalCount : '') + item.measuringUnit;
+					item.goodsLevelName = levelList.find(i => i.value == item.goodsLevel)?.text || '';
+					item.doneTotalCount = (item.doneTotalCount ? item.doneTotalCount : '') + item.measuringUnit;
+					item.waitTotalCount = (item.waitTotalCount ? item.waitTotalCount : '') + item.measuringUnit;
+					item.arrivalWayName = this.arrivalWayList.find(i => i.value == item.arrivalWay)?.text || '';
+					item.produceTypeName = item.produceType ? item.produceType.map(i => lbjtList[i]).join(',') : '';
+					item.provenanceName = this.getProvenance(item.provenance);
+				})
+				console.log('form~~~', this.form)
+
+			},
+			getProvenance(item) {
+				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(',') : '';
+			},
+			getByCode() {
+				const codeS = ['purchase_origin']
+				codeS.forEach(async (code) => {
+					const codeValue = await getByCode(code);
+					this[code] = codeValue.map(item => {
+						const key = Object.keys(item)[0]
+						return {
+							value: key,
+							text: item[key]
+						}
+					})
+					console.log(code, this[code])
+				})
+			},
 		}
 	}
 </script>

+ 22 - 13
pages/home/wt/components/purchaseNeedManage/taskSubmit.vue

@@ -20,7 +20,8 @@
 
 <script>
 	import {
-		approveTaskWithVariables
+		approveTaskWithVariables,
+		rejectTask
 	} from '@/api/wt/index.js'
 	export default {
 		name: 'taskSubmit',
@@ -69,19 +70,27 @@
 				let variables = {
 					pass: !!status
 				};
-				let res = await approveTaskWithVariables({
-					id: this.taskId,
-					reason: this.form.reason,
-					variables
-				})
-
-				if (res.code != '-1') {
-					this.$emit('handleAudit', {
-						status,
-						title: status === 0 ? '驳回' : ''
-					});
+				const requestApi = status == 1 ? approveTaskWithVariables : rejectTask
+				// console.log('variables~~~', variables)
+				try {
+					let res = await requestApi({
+						id: this.taskId,
+						reason: this.form.reason,
+						variables
+					})
+					// console.log('res~~~', res)
+					this.loading = false
+					if (res.code != '-1') {
+						this.$emit('handleAudit', {
+							status,
+							title: status === 0 ? '驳回' : ''
+						});
+					}
+				} catch (error) {
+					console.log('error~~~', error)
+					this.loading = false
 				}
-				this.loading = false
+				
 			},
 
 			getTableValue() {

+ 3 - 0
pages/home/wt/todo/todo.vue

@@ -78,6 +78,7 @@
 			},
 			//miniHandleRouter
 			handleDetail(item, type) {
+				console.log('111~~~', item)
 				//'pages/home' + this.listData.miniHandleRouter
 				///wt/components/feeApplication/taskSubmit
 				if (type == 'handle') {
@@ -98,6 +99,8 @@
 						let queryParams =
 							`id=${item.processInstance.id}&businessId=${item.businessId}&taskId=${item.id}&taskDefinitionKey=${item.taskDefinitionKey}&miniHandleRouter=${item.miniHandleRouter}&miniViewRouter=${item.miniViewRouter}`
 						let url = '/pages/home' + item.miniHandleRouter.replace('taskForm', 'processTask')
+						
+						console.log('url~~~',`${url}?${queryParams}`)
 						uni.navigateTo({
 							url: `${url}?${queryParams}`
 						})

+ 7 - 3
pages/purchasingManage/components/myCard.vue

@@ -6,6 +6,7 @@
 		<view class="item_box rx-bc" v-for="(_item,i) in columns" :key="i">
 			<view class="perce50" :class="val.className" :style="val.style" v-for="(val) in _item" :key="val.prop">
 				<view class="item_box rx-sc" v-if="val.type=='title'">
+					<text v-if="val.isRequired" style="color: red;">*</text>
 					<view class="round" v-if='index'>{{index}}</view>
 					<view class="orderId" :style="{marginLeft: index?'16rpx':''}" v-if="val.slot">
 						<slot :name="val.slot"> </slot>
@@ -18,7 +19,7 @@
 
 				</view>
 
-				<view class="item_one rx-sc" v-else-if="val.type=='action'">
+				<view class="item_one rx-sc" v-else-if="val.type=='action' && !isDrawer">
 					<view class="lable">{{val.label}}</view>
 					<view class="text">
 						<template v-for="(btn,bI) in btnList">
@@ -30,7 +31,7 @@
 
 				</view>
 				<view class="item_one rx-sc kk" v-else>
-					<view class="lable">{{val.label}}</view>
+					<view class="lable"><text v-if="val.isRequired" style="color: red;">*</text>{{val.label}}</view>
 					<view class="text" v-if="val.formatter">{{val.formatter(item)||''}}</view>
 					<view class="text" v-else-if="val.slot">
 						<slot :name="val.slot"> </slot>
@@ -48,7 +49,10 @@
 <script>
 	export default {
 		props: {
-
+			isDrawer: {
+				type: Boolean,
+				default: false
+			},
 			btnList: {
 				type: Array,
 				default: () => []

+ 20 - 6
pages/purchasingManage/components/produceList.vue

@@ -1,14 +1,14 @@
 <template>
 	<view class="mainBox">
 		<view v-for="(item, index) in tableList" :key="index" style="position: relative;">
-			<myCard :item="item" :btnList="btnList" :index="index+1" :columns="columns" @del="del(index)">
+			<myCard :item="item" :btnList="btnList" :index="index+1" :isDrawer="isDrawer" :columns="columns" @del="del(index)">
 				<view class="slot-box" slot="productName">
 					<u-row>
 						<u-col span="10">
 							<u--input placeholder="请输入" border="surround" disabled v-model="item.productName"></u--input>
 						</u-col>
 						<u-col span="2">
-							<u-button type="primary" size="mini" @click="selectProduct(item, index)" text="选择"></u-button>
+							<u-button v-if="!isDrawer" type="primary" size="mini" @click="selectProduct(item, index)" text="选择"></u-button>
 						</u-col>
 					</u-row>
 				</view>
@@ -31,7 +31,7 @@
 
 				<view slot="goodsLevel">
 					<view v-if="isDrawer">
-						{{ item.goodsLevel }}
+						{{ getGoodsLevelVal(item.goodsLevel) }}
 					</view>
 					<view v-else>
 						<uni-data-picker v-model="item.goodsLevel" placeholder="请选择" :localdata="levelList"></uni-data-picker>
@@ -39,14 +39,17 @@
 				</view>
 
 				<view slot="arrivalWay">
-					<view v-if="isDrawer">{{ item.arrivalWay }}</view>
+					<view v-if="isDrawer">{{ item.arrivalWay == 1 ? '一次性到货' : '分批到货' }}</view>
 					<view v-else>
 						<uni-data-picker v-model="item.arrivalWay" placeholder="请选择" :localdata="arrivalWayList"></uni-data-picker>
 					</view>
 				</view>
 
 				<view slot="expectReceiveDate">
-					<view v-if="isDrawer">{{ item.expectReceiveDate }}</view>
+					<view v-if="isDrawer">
+						<view v-if="item.arrivalWay == 2" style="color: #409eff;" @click="settingDate(item, index)">分批时间</view>
+						<view v-else>{{ item.expectReceiveDate }}</view>
+					</view>
 					<view v-else>
 						<view v-if="item.arrivalWay == 2">
 							<span @click="settingDate(item, index)" style="color: #409eff;">设置分批时间</span>
@@ -158,7 +161,9 @@
 		</view>
 		<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>
+		<timePopup ref="timePopupRef" 
+			:isView="isDrawer"
+		@confirm="handleTimeConfirm"></timePopup>
 		<multipleSelect ref="multipleSelectRef" :range="multipleSelectRange" @confirm="handleMultipleConfirm"></multipleSelect>
 	</view>
 </template>
@@ -223,6 +228,7 @@
 					workHour: '',
 					guaranteePeriodUnitCode: '',
 					technicalDrawings: [],
+					files: [],
 					arrivalWay: 1,
 					modelKey: '',
 					colorKey: ''
@@ -261,6 +267,7 @@
 						slot: 'productName',
 						type: 'title',
 						className: 'perce100',
+						isRequired: true,
 					}],
 					[{
 						label: '编码:',
@@ -274,6 +281,7 @@
 						prop: 'purchaseCount',
 						slot: 'purchaseCount',
 						className: 'perce100',
+						isRequired: true,
 						// formatter: (item) => {
 						// 	if (item.purchaseCount) {
 						// 		return item.purchaseCount + ' ' + (item.purchaseUnit || '');
@@ -378,6 +386,7 @@
 						label: '到货方式:',
 						prop: 'arrivalWay',
 						slot: 'arrivalWay',
+						isRequired: true,
 						// formatter: (item) => {
 						// 	return item.arrivalWay == 1 ? '一次性到货' : '分批到货';
 						// },
@@ -386,6 +395,7 @@
 						label: '到货日期:',
 						prop: 'expectReceiveDate',
 						slot: 'expectReceiveDate',
+						isRequired: true,
 					}, {
 						label: '属性类型:',
 						prop: 'produceType',
@@ -589,6 +599,10 @@
 			openPicker() {
 				this.$refs.treePicker._show()
 			},
+			getGoodsLevelVal(val) {
+				const goodsLevel = this.levelList.find(item => item.value == val)
+				return goodsLevel?.text || ''
+			},
 			getProvenance(item) {
 				console.log('getProvenance~~~~~', item)
 				// try {

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

@@ -3,7 +3,7 @@
         <scroll-view class="scroll-content" scroll-y style="height: 80vh;">
             <view class="popup-title">
                 <text>待分配数量:{{ count }}</text>
-                <u-button class="popup-title-btn" type="primary" @click="handleAddDate" text="新增" ></u-button>
+                <u-button v-if="!isView" class="popup-title-btn" type="primary" @click="handleAddDate" text="新增" ></u-button>
             </view>
             <uni-table ref="table" border stripe emptyText="暂无更多数据">
                 <uni-tr>
@@ -12,16 +12,16 @@
                     <uni-th width="80" align="center">操作</uni-th>
                 </uni-tr>
                 <uni-tr v-for="(item, index) in tableData" :key="index">
-                    <uni-td><uni-number-box v-model="item.arriveCount" :min="0" :max="getCountMax(item)" @change="changeCountValue(index)" /></uni-td>
+                    <uni-td><uni-number-box v-model="item.arriveCount" :disabled="isView" :min="0" :max="getCountMax(item)" @change="(v) =>changeCountValue(v, index)" /></uni-td>
                     <uni-td>
-                        <uni-datetime-picker type="date" v-model="item.arriveDate"></uni-datetime-picker>
+                        <uni-datetime-picker :disabled="isView" type="date" v-model="item.arriveDate"></uni-datetime-picker>
                     </uni-td>
                     <uni-td>
-                        <button class="uni-button" size="mini" type="warn" @click="handleDelDate(index)">删除</button>
+                        <button v-if="!isView" class="uni-button" size="mini" type="warn" @click="handleDelDate(index)">删除</button>
                     </uni-td>
                 </uni-tr>
             </uni-table>
-            <view class="footerButton">
+            <view class="footerButton" v-if="!isView">
                 <u-button type="default" @click="handleClose" text="关闭"></u-button>
                 <u-button type="primary" @click="handleConfirm" text="确认"></u-button>
             </view>
@@ -30,6 +30,11 @@
 </template>
 <script>
 export default {
+    props: {
+        isView: {
+            default: false
+        }
+    },
     data() {
         return {
             count: 0, //待分配数量
@@ -76,20 +81,25 @@ export default {
             this.count += this.tableData[index].arriveCount;
             this.tableData.splice(index, 1);
         },
-        changeCountValue() {
+        changeCountValue(v, index) {
+            if(v !== null && v !== undefined) {
+                this.tableData[index].arriveCount = v;
+            }
+            console.log('列表', v, this.tableData)
             if (this.tableData.length) {
                 let num = this.tableData.reduce((n, item) => {
                     n += item.arriveCount * 1;
                     return n;
                 }, 0);
-                    this.count = this.current.totalCount * 1 - num || 0;
+                this.count = this.current.totalCount * 1 - num || 0;
             } else {
                 this.count = this.current.totalCount * 1 || 0;
             }
         },
         handleConfirm() {
+            console.log('确认', this.count)
             if (this.count != 0) {
-                uni.showToast({ title: '分配数量有误,请检查!'})
+                uni.showToast({ icon: 'none', title: '分配数量有误,请检查!'})
                 return
             }
 
@@ -97,11 +107,12 @@ export default {
             for (let i = 0; i < this.tableData.length; i++) {
                 const item = this.tableData[i];
                 if (item.arriveCount === null || item.arriveCount === undefined || !item.arriveDate) {
-                    return uni.showToast({ title: `第${i + 1}行数据不完整,请检查数量和到货时间!`});
+                    return uni.showToast({ icon: 'none', title: `第${i + 1}行数据不完整,请检查数量和到货时间!`});
                 }
             }
             
             this.$emit('confirm', this.tableData);
+            this.handleClose()
         },
         handleClose() {
             this.$refs.popup.close()

+ 677 - 560
pages/purchasingManage/purchaseNeedManage/add.vue

@@ -1,567 +1,684 @@
 <template>
-	<view class="mainBox">
-		<uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
-			:title="this.form.id?'修改采购需求':'新建采购需求'" @clickLeft="back">
-		</uni-nav-bar>
-		<u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
-		<u-cell-group v-show='current==0'>
-			<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.sourceType" slot="value" placeholder="请选择"
-					:localdata="requirementSourceType" @change="sourceCodeOnchange">
-				</uni-data-picker>
-			</u-cell>
-			<u-cell :title="'需求单名称'" arrow-direction="down">
-				<view slot="title" style="display: flex; align-items: center;">
-					<text class="required-mark">*</text>
-					需求单名称
-				</view>
-				<u--input slot="value" placeholder="请输入" border="surround" v-model="form.requirementName"></u--input>
-			</u-cell>
-			<u-cell :title="'需求部门'" arrow-direction="down">
-				<view slot="title" style="display: flex; align-items: center;">
-					<text class="required-mark">*</text>
-					需求部门
-				</view>
-				<!-- <u--input slot="value" placeholder="请输入" border="surround" v-model="form.requireDeptId"></u--input> -->
-				<u--input slot="value" @click.native="classification" style="flex:1" border="surround"
-					placeholder="请选择需求部门" v-model="form.requireDeptName">
-				</u--input>
-			</u-cell>
-			<u-cell :title="'需求人'" arrow-direction="down">
-				<view slot="title" style="display: flex; align-items: center;">
-					<text class="required-mark">*</text>
-					需求人
-				</view>
-				<!-- <u--input slot="value" placeholder="请输入" border="requireUserId" v-model="form.name"></u--input> -->
-				<u--input slot="value" style="flex:1" border="surround" v-model="form.requireUserName"
-						placeholder="请选择需求人" @click.native="openSelector">
-				</u--input>
-			</u-cell>
-			<u-cell title="销售合同" arrow-direction="down">
-				<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> -->
-				<u--input slot="value" style="flex:1" border="surround" v-model="form.saleOrderNo"
-						placeholder="请选择销售订单" @click.native="slectOrderShow">
-				</u--input>
-			</u-cell>
-			<u-cell title="是否接受拆单" arrow-direction="down">
-				<uni-data-picker v-model="form.acceptUnpack" slot="value" placeholder="请选择"
-					:localdata="acceptUnpackList" @change="sourceCodeOnchange">
-				</uni-data-picker>
-			</u-cell>
-			<u-cell title="'用途" arrow-direction="down">
-				<view slot="title" style="display: flex; align-items: center;">
-					<text class="required-mark">*</text>
-					用途
-				</view>
-				<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;">
-					<fileMain v-model="form.fileId"></fileMain>
-				</view>
-			</u-cell>
-			<u-cell title="备注" arrow-direction="down">
-				<u--textarea slot="value" placeholder="请输入" border="surround" v-model="form.remark"></u--textarea>
-			</u-cell>
-		</u-cell-group>
-
-
-		<view class="footerButton">
-			<u-button type="default" text="返回" @click="back"></u-button>
-			<u-button type="primary" @click="save" text="保存"></u-button>
-		</view>
-		<produceList ref="produceListRef" v-show="current==1"  :isTemporary="true"></produceList>
-		 <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择部门"
-			:selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
-			childrenKey="children" />
-		<search-select ref="selector" v-model="form.requireUserId" :data-list="executorList" title="选择需求人" @change="onClose">
-		</search-select>
-		<u-toast ref="uToast"></u-toast>
-	</view>
+  <view class="mainBox">
+    <uni-nav-bar
+      background-color="#157A2C"
+      color="#fff"
+      fixed="true"
+      statusBar="true"
+      left-icon="back"
+      :title="this.form.id ? '修改采购需求' : '新建采购需求'"
+      @clickLeft="back"
+    >
+    </uni-nav-bar>
+    <u-subsection
+      :list="list"
+      :current="current"
+      @change="sectionChange"
+    ></u-subsection>
+    <u-cell-group v-show="current == 0">
+      <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.sourceType"
+          slot="value"
+          placeholder="请选择"
+          :localdata="requirementSourceType"
+          @change="sourceCodeOnchange"
+        >
+        </uni-data-picker>
+      </u-cell>
+      <u-cell :title="'需求单名称'" arrow-direction="down">
+        <view slot="title" style="display: flex; align-items: center">
+          <text class="required-mark">*</text>
+          需求单名称
+        </view>
+        <u--input
+          slot="value"
+          placeholder="请输入"
+          border="surround"
+          v-model="form.requirementName"
+        ></u--input>
+      </u-cell>
+      <u-cell :title="'需求部门'" arrow-direction="down">
+        <view slot="title" style="display: flex; align-items: center">
+          <text class="required-mark">*</text>
+          需求部门
+        </view>
+        <!-- <u--input slot="value" placeholder="请输入" border="surround" v-model="form.requireDeptId"></u--input> -->
+        <u--input
+          slot="value"
+          @click.native="classification"
+          style="flex: 1"
+          border="surround"
+          placeholder="请选择需求部门"
+          v-model="form.requireDeptName"
+        >
+        </u--input>
+      </u-cell>
+      <u-cell :title="'需求人'" arrow-direction="down">
+        <view slot="title" style="display: flex; align-items: center">
+          <text class="required-mark">*</text>
+          需求人
+        </view>
+        <!-- <u--input slot="value" placeholder="请输入" border="requireUserId" v-model="form.name"></u--input> -->
+        <u--input
+          slot="value"
+          style="flex: 1"
+          border="surround"
+          v-model="form.requireUserName"
+          placeholder="请选择需求人"
+          @click.native="openSelector"
+        >
+        </u--input>
+      </u-cell>
+      <u-cell
+        v-if="form.sourceType == 1"
+        title="销售合同"
+        arrow-direction="down"
+      >
+        <u--input
+          slot="value"
+          style="flex: 1"
+          placeholder="请选择销售合同"
+          border="surround"
+          v-model="form.saleContractNo"
+          @click.native="selectContractShow"
+        ></u--input>
+      </u-cell>
+      <u-cell
+        v-if="form.sourceType == 1"
+        title="销售订单"
+        arrow-direction="down"
+      >
+        <!-- <u--input slot="value" placeholder="请输入" border="requireUserId" v-model="form.name"></u--input> -->
+        <u--input
+          slot="value"
+          style="flex: 1"
+          border="surround"
+          v-model="form.saleOrderNo"
+          placeholder="请选择销售订单"
+          @click.native="slectOrderShow"
+        >
+        </u--input>
+      </u-cell>
+      <u-cell title="是否接受拆单" arrow-direction="down">
+        <uni-data-picker
+          v-model="form.acceptUnpack"
+          slot="value"
+          placeholder="请选择"
+          :localdata="acceptUnpackList"
+        >
+        </uni-data-picker>
+      </u-cell>
+      <u-cell title="'用途" arrow-direction="down">
+        <view slot="title" style="display: flex; align-items: center">
+          <text class="required-mark">*</text>
+          用途
+        </view>
+        <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">
+          <fileMain v-model="form.fileId"></fileMain>
+        </view>
+      </u-cell>
+	  <!-- <u-cell title="附件" arrow-direction="down">
+        <view slot="value" style="display: flex; align-items: center">
+          <fileMain v-model="files"></fileMain>
+        </view>
+      </u-cell> -->
+      <u-cell title="备注" arrow-direction="down">
+        <u--textarea
+          slot="value"
+          placeholder="请输入"
+          border="surround"
+          v-model="form.remark"
+        ></u--textarea>
+      </u-cell>
+    </u-cell-group>
+
+    <view class="footerButton">
+      <u-button type="default" text="返回" @click="back"></u-button>
+      <u-button type="primary" @click="save" text="保存"></u-button>
+    </view>
+    <produceList
+      ref="produceListRef"
+      v-show="current == 1"
+      :isTemporary="true"
+    ></produceList>
+    <ba-tree-picker
+      ref="treePicker"
+      key="verify"
+      :multiple="false"
+      @select-change="confirm"
+      title="选择部门"
+      :selectedData="selectedData"
+      :localdata="classificationList"
+      valueKey="id"
+      textKey="name"
+      childrenKey="children"
+    />
+    <search-select
+      ref="selector"
+      v-model="form.requireUserId"
+      :data-list="executorList"
+      title="选择需求人"
+      @change="onClose"
+    >
+    </search-select>
+    <u-toast ref="uToast"></u-toast>
+  </view>
 </template>
 
 <script>
-	import { getByCode } from '@/api/pda/common.js'
-	import searchSelect from '@/pages/salesServiceManagement/accessory/components/searchSelect.vue';
-	import produceList from '../components/produceList.vue'
-	import fileMain from "@/pages/doc/index.vue"
-	import { requirementSourceType } from '@/enum/dict'
-	import { listOrganizations } from '@/api/salesServiceManagement/workOrder/index.js';
-	import { toTreeData } from '@/utils/utils.js';
-	import { getUserPage } from '@/api/common.js';
-	import { getTableList, getSaleOrderDetail } from '@/api/saleManage/saleorder/index'
-	import {
-		getDetail,
-		addPurchaseNeedManage,
-		UpdateInformation
-	} from '@/api/purchasingManage/purchaseNeedManage.js'
-	import { getInventoryTotal } from '@/api/pda/workOrder'
-	import { contactQueryByCategoryIdsAPI } from '@/api/warehouseManagement/index'
-	export default {
-		components: {
-			produceList,
-			fileMain,
-			searchSelect
-		},
-		data() {
-			return {
-				list: ['基本信息', '需求清单'],
-				acceptUnpackList: [{text: '接受', value: 1}, { text: '不接受', value: 0}],
-				current: 0,
-				show: false,
-				requirementSourceType,
-				classificationList: [],
-				isUpdate: false,
-				purchase_origin: [],
-				form: {
-					id: '',
-					receiveDate: null,
-					remark: null,
-					requireDeptId: '',
-					requireDeptName: '',
-					requireUserId: '',
-					requireUserName: '',
-					sourceCode: '',
-					sourceId: '',
-					sourceType: '',
-					requirementName: '',
-					saleContractName: '',
-					saleContractNo: '',
-					saleContractId: '',
-					saleOrderId: '',
-					saleOrderNo: '',
-					files: [], //附件集合
-					acceptUnpack: 1,
-					fileId: [],
-				},
-				business_opport_code: [],
-				linkList: [],
-				selectedData: [], // 使用部门绑定值
-				executorList: []
-			}
-		},
-
-		created() {
-
-			this.getByCode()
-			//选择合同回调
-			uni.$off('setContractList')
-			uni.$on('setContractList', async (data) => {
-				if (data && data.length > 0) {
-					this.form = Object.assign({}, this.form, {
-						saleContractId: data[0].id,
-						saleContractName: data[0].contractName,
-						saleContractNo: data[0].contractNo,
-					});
-					console.log('ddd~~~', data[0])
-					this.getSaleOrderList(data[0].id);
-				}
-
-			})
-
-			uni.$off('setSaleOrder')
-			uni.$on('setSaleOrder', async (data) => {
-				if(data && data.length > 0) {
-					this.form = Object.assign({}, this.form, {
-						saleContractId: '',
-						saleContractName: '',
-						saleContractNo: '',
-						saleOrderId: data[0].id,
-						saleOrderNo: data[0].orderNo
-					});
-					this.getSaleOrderDetail(this.form.saleOrderId)
-				}
-			})
-
-		},
-		onLoad(data) {
-			this.getTreeList()
-			if (data && data.id) {
-				this.isUpdate = true
-				getDetail(data.id).then(async res => {
-					this.form = res
-					this.form.fileId = JSON.parse(res.fileId)
-					if(this.form.requireDeptId) {
-						this.getUserList(this.form.requireDeptId);
-					}
-					// setTimeout(() => {
-						// this.current = 0
-						this.$nextTick(async () => {
-							// this.$refs.infoRef.init(res)
-							// 获取所有有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
-							// }
-						})
-					// }, 300)
-				})
-			} else {
-				const userInfo = uni.getStorageSync('userInfo')
-				this.$set(this.form, 'requireUserId', userInfo.userId);
-				this.$set(this.form, 'requireUserName', userInfo.name);
-				this.$set(this.form, 'requireDeptId', userInfo.groupId);
-				this.$set(this.form, 'requireDeptName', userInfo.groupName);
-			}
-
-		},
-		onUnload() {
-			uni.$off('setContractList')
-			uni.$off('setSaleOrder')
-		},
-		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,
-				size: 10,
-				contractId
-				});
-				this.form.saleOrderId = res.list[0]?.id;
-				this.form.saleOrderNo = res.list[0]?.orderNo;
-				this.getSaleOrderDetail(this.form.saleOrderId);
-			},
-			async getSaleOrderDetail(id) {
-				const data = await getSaleOrderDetail(id);
-				data.productList.forEach((item) => {
-					item.expectReceiveDate = item.produceDeliveryDeadline;
-					item.arrivalWay = 1;
-					item['packageDispositionList'] = item.packageDispositionList?.map(i => {
-						return {
-							...i,
-							text: i.conversionUnit,
-							value: i.id
-						}
-					}) || []
-
-				});
-
-				this.$nextTick(() => {
-				this.$refs.produceListRef.init(data.productList);
-				});
-			},
-			async getTreeList() {
-				const data = await listOrganizations({});
-				let treeList = toTreeData({
-					data: data || [],
-					idField: 'id',
-					parentIdField: 'parentId'
-				});
-				this.classificationList = treeList;
-			},
-			// 打开部门弹窗
-			classification() {
-				this.$refs.treePicker._show();
-			},
-			// 使用部门选择
-			confirm(id, name) {
-				this.form.requireDeptName = name;
-				this.form.requireDeptId = id[0];
-				this.form.requireUserId = '';
-				this.form.requireUserName = '';
-				this.executorList = [];
-				this.getUserList(id[0]);
-				this.$refs.selector.clearSearchText();
-			},
-			// 打开需求人弹窗
-			openSelector() {
-				this.$refs.selector.open();
-			},
-			// 获取需求人数据
-			async getUserList(id) {
-				let params = {
-					pageNum: 1,
-					size: -1,
-					groupId: id
-				}
-				try {
-					const res = await getUserPage(params);
-					let list = res.list && res.list.map((el) => {
-						return {
-							text: el.name,
-							value: el.id
-						}
-					})
-					this.executorList = list;
-				} catch (error) {
-					this.executorList = [];
-				}
-			},
-			// 需求人选择
-			onClose(item) {
-				this.form.requireUserName = item.text;
-			},
-			//选择合同
-			selectContractShow() {
-				console.log('ddd~~~')
-				uni.navigateTo({
-					url: '/pages/purchasingManage/components/selectContract?isAll=' + 2
-				})
-			},
-			slectOrderShow() {
-				uni.navigateTo({
-					url: '/pages/purchasingManage/components/selectSaleOrder?isAll=' + 2
-				})
-			},
-			getByCode() {
-				const codeS = ['business_opport_code', 'purchase_origin']
-				codeS.forEach(async (code) => {
-					const codeValue = await getByCode(code);
-					this[code] = codeValue.map(item => {
-						const key = Object.keys(item)[0]
-						return {
-							value: key,
-							text: item[key]
-						}
-					})
-				})
-
-			},
-			sourceCodeOnchange(e) {
-				const value = e.detail.value
-				this.form.sourceCode = value.map(item => item.value).toString()
-				this.form.sourceName = value.map(item => item.text).toString()
-			},
-
-			radioChange(e) {
-				this.form.pricingWay = e.detail.value
-				this.$nextTick(() => {
-					this.$refs.produceListRef.getTotalPrice()
-				})
-
-
-			},
-			sectionChange(index) {
-				this.current = index;
-			},
-
-			async save() {
-				try {
-					if (!this.form.sourceType) {
-						this.$refs.uToast.show({
-							type: "error",
-							message: "请选择需求类型",
-						})
-						return
-					}
-					if (!this.form.requirementName) {
-						this.$refs.uToast.show({
-							type: "error",
-							message: "请输入需求名称",
-						})
-						return
-					}
-					if (!this.form.requireDeptName) {
-						this.$refs.uToast.show({
-							type: "error",
-							message: "请选择需求部门",
-						})
-						return
-					}
-
-					if (!this.form.requireUserName) {
-						this.$refs.uToast.show({
-							type: "error",
-							message: "请选择需求人",
-						})
-						return
-					}
-
-					const detailList = this.$refs.produceListRef.getValue();
-
-					if (detailList.length == 0) {
-						this.$refs.uToast.show({
-							type: "error",
-							message: "产品清单不能为空",
-						})
-						return;
-					}
-
-					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({icon: none, title: '请设置分批时间'});
-						return;
-					}
-
-					uni.showLoading({
-						title: '加载中'
-					})
-
-					const data = {
-						...this.form,
-						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
-
-					requestApi(data)
-						.then((res) => {
-							uni.hideLoading()
-							this.back()
-						})
-						.catch((e) => {
-							uni.hideLoading()
-						});
-				} catch (error) {
-					uni.hideLoading()
-					console.log(error, 'error')
-				}
-			},
-
-		}
-	}
+import { getByCode } from "@/api/pda/common.js";
+import searchSelect from "@/pages/salesServiceManagement/accessory/components/searchSelect.vue";
+import produceList from "../components/produceList.vue";
+import fileMain from "@/pages/doc/index.vue";
+import { requirementSourceType } from "@/enum/dict";
+import { listOrganizations } from "@/api/salesServiceManagement/workOrder/index.js";
+import { toTreeData } from "@/utils/utils.js";
+import { getUserPage } from "@/api/common.js";
+import {
+  getTableList,
+  getSaleOrderDetail,
+} from "@/api/saleManage/saleorder/index";
+import {
+  getDetail,
+  addPurchaseNeedManage,
+  UpdateInformation,
+} from "@/api/purchasingManage/purchaseNeedManage.js";
+import { getInventoryTotal } from "@/api/pda/workOrder";
+import { contactQueryByCategoryIdsAPI } from "@/api/warehouseManagement/index";
+export default {
+  components: {
+    produceList,
+    fileMain,
+    searchSelect,
+  },
+  data() {
+    return {
+      list: ["基本信息", "需求清单"],
+      acceptUnpackList: [
+        { text: "接受", value: 1 },
+        { text: "不接受", value: 0 },
+      ],
+      current: 0,
+      show: false,
+      requirementSourceType,
+      classificationList: [],
+      isUpdate: false,
+      purchase_origin: [],
+	  files: [],
+      form: {
+        id: "",
+        receiveDate: null,
+        remark: null,
+        requireDeptId: "",
+        requireDeptName: "",
+        requireUserId: "",
+        requireUserName: "",
+        sourceCode: "",
+        sourceId: "",
+        sourceType: "",
+        sourceTypeName: "",
+        requirementName: "",
+        saleContractName: "",
+        saleContractNo: "",
+        saleContractId: "",
+        saleOrderId: "",
+        saleOrderNo: "",
+        files: [], //附件集合
+        acceptUnpack: 1,
+		detailList: [],
+        fileId: [],
+      },
+      business_opport_code: [],
+      linkList: [],
+      selectedData: [], // 使用部门绑定值
+      executorList: [],
+    };
+  },
+
+  created() {
+    this.getByCode();
+    //选择合同回调
+    uni.$off("setContractList");
+    uni.$on("setContractList", async (data) => {
+      if (data && data.length > 0) {
+        this.form = Object.assign({}, this.form, {
+          saleContractId: data[0].id,
+          saleContractName: data[0].contractName,
+          saleContractNo: data[0].contractNo,
+        });
+        console.log("ddd~~~", data[0]);
+        this.getSaleOrderList(data[0].id);
+      }
+    });
+
+    uni.$off("setSaleOrder");
+    uni.$on("setSaleOrder", async (data) => {
+      if (data && data.length > 0) {
+        this.form = Object.assign({}, this.form, {
+          saleContractId: "",
+          saleContractName: "",
+          saleContractNo: "",
+          saleOrderId: data[0].id,
+          saleOrderNo: data[0].orderNo,
+        });
+        this.getSaleOrderDetail(this.form.saleOrderId);
+      }
+    });
+  },
+  onLoad(data) {
+    this.getTreeList();
+    if (data && data.id) {
+      this.isUpdate = true;
+      getDetail(data.id).then(async (res) => {
+        if (res.fileId) {
+          res.fileId = JSON.parse(res.fileId);
+        } else {
+          res.fileId = [];
+        }
+
+        if (res.requireDeptId) {
+          this.getUserList(res.requireDeptId);
+        }
+        let validItems = res.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 = res.detailList.findIndex(
+              (i) => i.productCode === item.productCode
+            );
+            if (actualIndex !== -1) {
+              this.$set(
+                res.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(
+                res.detailList[actualIndex],
+                "availableCountBase",
+                find.availableCountBase
+              );
+            }
+          });
+        }
+
+        // 处理数据格式
+        res.detailList = res.detailList.map((item) => ({
+          ...item,
+		//   files: item.files || [],
+		//   technicalDrawings: item.technicalDrawings || [],
+          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,
+            })) || [],
+        }));
+        this.$set(this, "form", res);
+        this.$nextTick(() => {
+          
+          this.$refs.produceListRef.init(res.detailList);
+        });
+        // }, 300)
+      });
+    } else {
+      const userInfo = uni.getStorageSync("userInfo");
+      this.$set(this.form, "requireUserId", userInfo.userId);
+      this.$set(this.form, "requireUserName", userInfo.name);
+      this.$set(this.form, "requireDeptId", userInfo.groupId);
+      this.$set(this.form, "requireDeptName", userInfo.groupName);
+    }
+  },
+  onUnload() {
+    uni.$off("setContractList");
+    uni.$off("setSaleOrder");
+  },
+  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,
+        size: 10,
+        contractId,
+      });
+      this.form.saleOrderId = res.list[0]?.id;
+      this.form.saleOrderNo = res.list[0]?.orderNo;
+      this.getSaleOrderDetail(this.form.saleOrderId);
+    },
+    async getSaleOrderDetail(id) {
+      const data = await getSaleOrderDetail(id);
+      data.productList.forEach((item) => {
+        item.expectReceiveDate = item.produceDeliveryDeadline;
+        item.arrivalWay = 1;
+        item["packageDispositionList"] =
+          item.packageDispositionList?.map((i) => {
+            return {
+              ...i,
+              text: i.conversionUnit,
+              value: i.id,
+            };
+          }) || [];
+      });
+
+      this.$nextTick(() => {
+        this.$refs.produceListRef.init(data.productList);
+      });
+    },
+    async getTreeList() {
+      const data = await listOrganizations({});
+      let treeList = toTreeData({
+        data: data || [],
+        idField: "id",
+        parentIdField: "parentId",
+      });
+      this.classificationList = treeList;
+    },
+    // 打开部门弹窗
+    classification() {
+      this.$refs.treePicker._show();
+    },
+    // 使用部门选择
+    confirm(id, name) {
+      this.form.requireDeptName = name;
+      this.form.requireDeptId = id[0];
+      this.form.requireUserId = "";
+      this.form.requireUserName = "";
+      this.executorList = [];
+      this.getUserList(id[0]);
+      this.$refs.selector.clearSearchText();
+    },
+    // 打开需求人弹窗
+    openSelector() {
+      this.$refs.selector.open();
+    },
+    // 获取需求人数据
+    async getUserList(id) {
+      let params = {
+        pageNum: 1,
+        size: -1,
+        groupId: id,
+      };
+      try {
+        const res = await getUserPage(params);
+        let list =
+          res.list &&
+          res.list.map((el) => {
+            return {
+              text: el.name,
+              value: el.id,
+            };
+          });
+        this.executorList = list;
+      } catch (error) {
+        this.executorList = [];
+      }
+    },
+    // 需求人选择
+    onClose(item) {
+      this.form.requireUserName = item.text;
+    },
+    //选择合同
+    selectContractShow() {
+      console.log("ddd~~~");
+      uni.navigateTo({
+        url: "/pages/purchasingManage/components/selectContract?isAll=" + 2,
+      });
+    },
+    slectOrderShow() {
+      uni.navigateTo({
+        url: "/pages/purchasingManage/components/selectSaleOrder?isAll=" + 2,
+      });
+    },
+    getByCode() {
+      const codeS = ["business_opport_code", "purchase_origin"];
+      codeS.forEach(async (code) => {
+        const codeValue = await getByCode(code);
+        this[code] = codeValue.map((item) => {
+          const key = Object.keys(item)[0];
+          return {
+            value: key,
+            text: item[key],
+          };
+        });
+      });
+    },
+    sourceCodeOnchange(e) {
+      const value = e.detail.value;
+      this.form.sourceCode = value.map((item) => item.value).toString();
+      this.form.sourceTypeName = value.map((item) => item.text).toString();
+      this.form.saleOrderId = "";
+      this.form.saleOrderNo = "";
+      this.form.saleContractNo = "";
+      this.form.saleContractId = "";
+      this.form.saleContractName = "";
+    },
+
+    radioChange(e) {
+      this.form.pricingWay = e.detail.value;
+      this.$nextTick(() => {
+        this.$refs.produceListRef.getTotalPrice();
+      });
+    },
+    sectionChange(index) {
+      this.current = index;
+    },
+
+    async save() {
+      try {
+        if (!this.form.sourceType) {
+          this.$refs.uToast.show({
+            type: "error",
+            message: "请选择需求类型",
+          });
+          return;
+        }
+        if (!this.form.requirementName) {
+          this.$refs.uToast.show({
+            type: "error",
+            message: "请输入需求名称",
+          });
+          return;
+        }
+        if (!this.form.requireDeptName) {
+          this.$refs.uToast.show({
+            type: "error",
+            message: "请选择需求部门",
+          });
+          return;
+        }
+
+        if (!this.form.requireUserName) {
+          this.$refs.uToast.show({
+            type: "error",
+            message: "请选择需求人",
+          });
+          return;
+        }
+
+        const detailList = this.$refs.produceListRef.getValue();
+
+        if (detailList.length == 0) {
+          this.$refs.uToast.show({
+            type: "error",
+            message: "产品清单不能为空",
+          });
+          return;
+        }
+
+        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({ icon: "none", title: "请设置分批时间" });
+          return;
+        }
+
+        uni.showLoading({
+          title: "加载中",
+        });
+
+        const data = {
+          ...this.form,
+          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;
+
+        requestApi(data)
+          .then((res) => {
+            uni.hideLoading();
+            this.back();
+          })
+          .catch((e) => {
+            uni.hideLoading();
+          });
+      } catch (error) {
+        uni.hideLoading();
+        console.log(error, "error");
+      }
+    },
+  },
+};
 </script>
 
 <style lang="scss" scoped>
-	.required-mark {
-		color: #FF3333;
-		margin-right: 4rpx;
-	}
-	
-	/deep/.u-cell__body__content {
-		flex: none;
-		margin-right: 16rpx;
-	}
-
-	.mainBox {
-		padding-bottom: 84rpx;
-	}
-
-	.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;
-
-		}
-	}
-
-	// /deep/.u-button {
-	// 	// height: 100%;
-	// }
-
-	/deep/.u-subsection__item__text {
-		font-size: 28rpx !important;
-	}
-	/deep/.uni-input-placeholder {
-		font-size: 28rpx !important;
-	}
-	/deep/.selected-item {
-		font-size: 28rpx !important;
-	}
-	/deep/.uni-input-input {
-		font-size: 28rpx !important;
-	}
-
-	
-</style>
+.required-mark {
+  color: #ff3333;
+  margin-right: 4rpx;
+}
+
+/deep/.u-cell__body__content {
+  flex: none;
+  margin-right: 16rpx;
+}
+
+.mainBox {
+  padding-bottom: 84rpx;
+}
+
+.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;
+  }
+}
+
+// /deep/.u-button {
+// 	// height: 100%;
+// }
+
+/deep/.u-subsection__item__text {
+  font-size: 28rpx !important;
+}
+/deep/.uni-input-placeholder {
+  font-size: 28rpx !important;
+}
+/deep/.selected-item {
+  font-size: 28rpx !important;
+}
+/deep/.uni-input-input {
+  font-size: 28rpx !important;
+}
+</style>