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

feat:优化采购计划审批

liujt 4 недель назад
Родитель
Сommit
e193c2d618

+ 28 - 6
pages/home/wt/components/purchasePlanManage/taskForm.vue

@@ -24,13 +24,27 @@
 				<u-form-item label="需求人" prop="requireUserName" borderBottom>
 					<u--input style="width: 100%;" disabled v-model="form.requireUserName"></u--input>
 				</u-form-item>
+				<u-form-item label="负责人" prop="responsibleName" borderBottom>
+					<u--input style="width: 100%;" disabled v-model="form.responsibleName"></u--input>
+				</u-form-item>
+				<u-form-item label="是否需要核价" prop="acceptUnpackName" borderBottom>
+					<u--input style="width: 100%;" disabled v-model="form.acceptUnpackName"></u--input>
+				</u-form-item>
+				<u-form-item label="是否自动生成订单" prop="isGenerateOrderName" borderBottom>
+					<u--input style="width: 100%;" disabled v-model="form.isGenerateOrderName"></u--input>
+				</u-form-item>
+				<u-form-item label="是否自动生成合同" prop="isGenerateContractName" borderBottom>
+					<u--input style="width: 100%;" disabled v-model="form.isGenerateContractName"></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>
 				</u-form-item>
-
+				<u-form-item label="完结日期" prop="receiveDate" borderBottom>
+					<u--input style="width: 100%;" disabled v-model="form.receiveDate"></u--input>
+				</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>
@@ -84,20 +98,20 @@
 						field: 'productCode',
 					},
 					{
-						label: '类',
+						label: '类',
 						field: 'productCategoryName',
 					},
 					{
 						label: '数量',
-						field: 'totalCount',
+						field: 'purchaseCount',
 					},
 					{
 						label: '单位',
-						field: 'measuringUnit',
+						field: 'purchaseUnit',
 					},
 					{
-						label: '牌',
-						field: 'brand',
+						label: '牌',
+						field: 'productBrand',
 					},
 					{
 						label: '型号',
@@ -107,6 +121,10 @@
 						label: '规格',
 						field: 'specification',
 					},
+					{
+						label: '包装规格',
+						field: 'packingSpecification',
+					},
 					
 				],
 				list: ['基本信息', '计划清单'],
@@ -122,7 +140,11 @@
 			},
 			async getDetailData(id) {
 				const data = await getPurchasePlanByIdsAPI(id);
+				data.acceptUnpackName = data.acceptUnpack == 1?'是':'否'
+				data.isGenerateOrderName = data.isGenerateOrder == 1?'是':'否'
+				data.isGenerateContractName = data.isGenerateContract == 1?'是':'否'
 				this.form = data
+				
 			}
 		}
 	}

+ 133 - 20
pages/home/wt/components/purchasePlanManage/taskSubmit.vue

@@ -2,9 +2,13 @@
 	<view class="">
 		<u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
 			labelWidth='140rpx'>
-			<u-form-item label="负责人" prop="userName" required>
-				<u--input clearable placeholder="请选择" border="surround" v-model="form.userName"
-					@click.native="showTechnicianPicker"></u--input>
+			<u-form-item v-if="taskDefinitionKey === 'deptLeaderAssign'" label="采购部门" prop="useDeptId">
+				<u--input clearable placeholder="请选择" border="surround" v-model="form.useDeptName"
+					@click.native="openDepartmentPicker"></u--input>
+			</u-form-item>
+			<u-form-item v-if="taskDefinitionKey === 'deptLeaderAssign'" label="采购员" prop="assignList" required>
+				<u--input clearable placeholder="请选择" border="surround" v-model="form.assignListName"
+					@click.native="openPicker"></u--input>
 			</u-form-item>
 			<u-form-item label="审批建议" prop="reason" required>
 				<u--textarea style="width: 100%;" height='120' border='surround' placeholder="请输入审批建议"
@@ -12,18 +16,25 @@
 			</u-form-item>
 		</u--form>
 		<view>
-			<u-button style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
+			<u-button v-if="!['storeManagerApprove'].includes(taskDefinitionKey)" style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
 				text="通过" @click="handleAudit(1)">
 			</u-button>
+			<u-button v-if="['storeManagerApprove'].includes(taskDefinitionKey)" style="width: 100%;margin-bottom: 10rpx;" icon="edit-pen" :loading='loading' type="success"
+				text="申请入库" @click="handleAudit(1)">
+			</u-button>
 			<u-button style="width: 100%;" :loading='loading' type="error" icon="close" text="驳回"
-				@click="handleAudit(0)" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
+				@click="rejectTask" v-if="!['starter'].includes(taskDefinitionKey)"></u-button>
 		</view>
 		<view class="btnConcel">
 			<u-button @click="showAction = true">更多</u-button>
 		</view>
 		<u-action-sheet :actions="actionList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="更多操作" :show="showAction" @close="showAction = false" @select="selectActionClick"></u-action-sheet>
 		<u-picker itemHeight='60' :show="technicianShow" visibleItemCount='10' :columns="userOptions" keyName="name"
-			@confirm='selectTechnicianInfo' @cancel='technicianShow = false' title='选择负责人'></u-picker>
+			@confirm='selectTechnicianInfo' @cancel='technicianShow = false' title='选择采购员'></u-picker>
+		<ba-tree-picker ref="departmentPicker" :multiple="false" @select-change="departmentConfirm" title="选择采购部门"
+			:localdata="departmentOption" valueKey="id" textKey="name" childrenKey="children" />
+		<ba-tree-picker ref="treePicker" :multiple="true" @select-change="confirm" title="选择采购员"
+			:localdata="userOptions" valueKey="id" textKey="name" childrenKey="child" />
 	</view>
 </template>
 
@@ -34,8 +45,13 @@
 		cancelTask
 	} from '@/api/wt/index.js'
 	import {
+		listOrganizations,
+		getUserPage,
 		listAllUserBind
-	} from '@/api/common.js'
+	} from '@/api/common'
+	import {
+		toTreeData
+	} from '@/utils/utils.js'
 	export default {
 		name: 'taskSubmit',
 		props: {
@@ -55,6 +71,7 @@
 
 		data() {
 			return {
+				departmentOption: [],
 				showAction: false,
 				loading: false,
 				actionList: [{
@@ -66,7 +83,11 @@
 				userOptions: [],
 				form: {
 					userId: '',
+					useDeptId: '',
+					useDeptName: '',
 					userName: '',
+					assignListName: '',
+					assignList: [],
 					reason: '',
 				},
 				rules: {
@@ -76,20 +97,70 @@
 						message: '请输入审批建议',
 						trigger: 'blur'
 					},
-					userName: {
+					useDeptId: {
 						type: 'string',
+						required: false,
+						message: '请选择采购部门',
+						trigger: ['blur','change']
+					},
+					assignList: {	
+						type: 'array',
 						required: true,
-						message: '请选择负责人',
+						message: '请选择采购员',
 						trigger: ['blur','change']
 					},
 				}
 			}
 		},
+		created() {
+			this.initDeptData()
+			this.getUserOptions()
+		},
 		mounted() {
 			this.$refs.uForm.setRules(this.rules)
-			this.getUserOptions()
 		},
 		methods: {
+			openPicker() {
+				this.$refs.treePicker._show()
+			},
+			confirm(data, name, allList) {
+				console.log('name-------', data,name, allList)
+				this.form.assignListName = name
+				this.form.assignList = allList
+				this.form.userId = allList.map(item => item.id)?.[0] || ''
+				this.form.userName = allList.map(item => item.name)?.[0] || ''
+			},
+
+			openDepartmentPicker() {
+				this.$refs.departmentPicker._show()
+			},
+			departmentConfirm(data, name, allList) {
+				console.log(data, name, allList)
+				this.form.useDeptId = data
+				this.form.useDeptName = name
+				this.form.userName = ''
+				this.form.userId = ''
+				this.form.assignListName = ''
+				this.form.assignList = []
+				if(!data) {
+					this.getUserOptions()
+				return;
+				}
+				getUserPage({
+					groupId: data,
+					size: 999
+				}).then((data) => {
+				    this.userOptions = data.list;
+				});
+			},
+			async initDeptData() {
+				let deptTreeList = await listOrganizations()
+				this.departmentOption = toTreeData({
+					data: deptTreeList,
+					idField: 'id',
+					parentIdField: 'parentId'
+				})
+			},
 			selectActionClick(item) {
 				console.log('selectActionClick', item)
 				if (item.name == '作废') {
@@ -124,8 +195,8 @@
 			},
 			async getUserOptions() {
 				const data = await listAllUserBind()
-				this.userOptions.push(data)
-				this.$comfi
+				this.userOptions = data
+				console.log('userOptions~~~', this.userOptions)
 			},
 			showTechnicianPicker(val) {
 				if (val.target.nodeName == 'I') {
@@ -140,18 +211,60 @@
 				this.form.userName = e.value[0]?.name
 				this.technicianShow = false
 			},
+			// async handleAudit(status) {
+			// 	if (!!status) await this.$refs.uForm.validate()
+
+			// 	await AssignPurchasePlanUserAPI({
+			// 		userId: this.form.userId,
+			// 		userName: this.form.userName,
+			// 		id: this.taskId,
+			// 		reason: this.form.reason,
+			// 		businessId: this.businessId
+			// 	})
+			// 	this.loading = true
+			// 	await this._approveTaskWithVariables(status);
+			// },
 			async handleAudit(status) {
+				console.log(this.form)
 				if (!!status) await this.$refs.uForm.validate()
-
-				await AssignPurchasePlanUserAPI({
-					userId: this.form.userId,
-					userName: this.form.userName,
+				//主管指派采购员
+				if (this.taskDefinitionKey === 'deptLeaderAssign') {
+					await AssignPurchasePlanUserAPI({
+						userId: this.form.userId,
+						userName: this.form.userName,
+						assignList: this.form.assignList,
+						id: this.taskId,
+						reason: this.form.reason,
+						businessId: this.businessId
+					});
+				}
+				let API = !!status ? approveTaskWithVariables : rejectTask;
+				await API({
+				id: this.taskId,
+				reason: this.form.reason,
+				variables: {
+					// userId: this.form.userId,
+					userId: this.form.assignList.map(item => item.id).join(','),
+					pass: !!status
+				}
+				});
+				this.$emit('handleAudit', {
+				status,
+				title: status === 0 ? '驳回' : ''
+				});
+			},
+			async rejectTask(status) {
+				await rejectTask({
 					id: this.taskId,
 					reason: this.form.reason,
-					businessId: this.businessId
-				})
-				this.loading = true
-				await this._approveTaskWithVariables(status);
+					variables: {
+						pass: !!status
+					}
+					});
+				this.$emit('handleAudit', {
+					status,
+					title: status === 0 ? '驳回' : ''
+				});
 			},
 			async _approveTaskWithVariables(status) {
 				let variables = {