From 4b65c83845208972c85ede0ea1a632fc8e2fc41c Mon Sep 17 00:00:00 2001
From: Admin <978517621@qq.com>
Date: 星期三, 28 九月 2022 17:53:30 +0800
Subject: [PATCH] Default Changelist

---
 src/views/specialWorkSystem/workTicket/workApply/components/plate.vue |  153 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 151 insertions(+), 2 deletions(-)

diff --git a/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue b/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
index 6bb7136..2f09dd7 100644
--- a/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
+++ b/src/views/specialWorkSystem/workTicket/workApply/components/plate.vue
@@ -194,8 +194,43 @@
 					</el-form-item>
 				</el-col>
 			</el-row>
+			<el-row>
+				<el-col :span="12">
+					<el-form-item label="选择关联物资">
+						<el-button type="primary" @click="getMaList">选择物资标准</el-button>
+					</el-form-item>
+				</el-col>
+			</el-row>
 			</div>
 		</el-form>
+		<el-dialog v-model="equipmentDialog" title="关联物资标准" width="40%" center @close="closeMaterial">
+			<el-tabs tab-position="left" class="demo-tabs" type="border-card">
+				<el-tab-pane v-for="(item,index) in materialList" :label="item.materialTypeName" :key="index">
+					<div style="margin-bottom: 20px">
+						<el-form label-width="150px" label-position="top">
+							<div v-if="item.mustList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">必选</div>
+							<el-form-item v-if="item.mustList.length>0" class="tab-i" v-for="(i,x) in item.mustList" :key="x" :label="item.mustList[x].materialName + ':'" prop="defaultVal" :rules="[{ type: 'defaultVal', required: true, message: '该内容不能为空', trigger: 'blur'}]">
+								<el-input size="default" type="number" v-model="item.mustList[x].value" placeholder="请输入配置数量,空值默认为0">
+									<template #append>{{'库存:' + item.mustList[x].stock}}</template>
+								</el-input>
+							</el-form-item>
+							<div v-if="item.unList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">其他</div>
+							<el-form-item v-if="item.unList.length>0" class="tab-i" v-for="(i,x) in item.unList" :key="x" :label="item.unList[x].materialName + ':'">
+								<el-input size="default" type="number" v-model="item.unList[x].value" placeholder="请输入配置数量,空值默认为0">
+									<template #append>{{'库存:' + item.unList[x].stock}}</template>
+								</el-input>
+							</el-form-item>
+						</el-form>
+					</div>
+				</el-tab-pane>
+			</el-tabs>
+			<template #footer>
+			<span class="dialog-footer">
+				<el-button @click="equipmentDialog = false" size="default">取消</el-button>
+				<el-button type="primary" @click="conFirmDevices" size="default">确认</el-button>
+			</span>
+			</template>
+		</el-dialog>
 		<div class="applyBtn">
 			<el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button>
 		</div>
@@ -228,19 +263,23 @@
 		dialogVisible: Boolean,
 		dialogImageUrl: string | null,
 		imgLimit: number,
-		isOverSize: boolean
+		isOverSize: boolean,
+		equipmentDialog: boolean,
+		materialList: Array<any>
 	}
 	interface file {
 		url: string;
 	}
 	export default defineComponent({
-		name: 'brokenForm',
+		name: 'plateForm',
 		components: {},
 		props:['workerList'],
 		setup() {
 			const userInfo = useUserInfo()
 			const { userInfos } = storeToRefs(userInfo);
 			const state  = reactive<stateType>({
+				equipmentDialog: false,
+				materialList: [],
 				form: {
 					operatorUids: [],
 					workType: 8,
@@ -262,6 +301,7 @@
 						uninstallBpTime: '',
 						otherSpecialWork: []
 					},
+					wmAddReqDTOList: [],
 					workTimeLine: [],
 					expStartTime: '',
 					expEndTime: ''
@@ -366,6 +406,24 @@
 				if (!formEl) return
 				await formEl.validate(async (valid, fields) => {
 					if (valid) {
+						for(let i in state.materialList){
+							state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{
+								const obj = {
+									defaultVal: item.value,
+									id: item.id
+								}
+								return {...obj}
+							})
+							state.materialList[i].unList = state.materialList[i].unList.map((item:any)=>{
+								const obj = {
+									defaultVal: item.value,
+									id: item.id
+								}
+								return {...obj}
+							})
+							state.materialList[i].postList = [...state.materialList[i].mustList,...state.materialList[i].unList]
+							state.form.wmAddReqDTOList = [...state.form.wmAddReqDTOList,...state.materialList[i].postList]
+						}
 						state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0]
 						state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1]
 						state.form.workDetail.installBpTime = JSON.parse(JSON.stringify(state.form.workDetail.installLine))[0]
@@ -386,6 +444,7 @@
 								formEl.resetFields()
 								state.form.workDetail.bpLocationMapPath = []
 								state.fileList = []
+								state.materialList = []
 						} else {
 							ElMessage({
 								type: 'warning',
@@ -504,6 +563,93 @@
 				});
 			}
 
+			// 确认物资标准
+			const getMaList = async() =>{
+				if(state.materialList.length == 0){
+					const data = {workType: 8,workLevel: state.form.workLevel}
+					const res = await workApplyApi().getMaterial(data)
+					if (res.data.code === '200') {
+						state.materialList = JSON.parse(JSON.stringify(res.data.data.materialTypeList))
+						for(let i in state.materialList){
+							state.materialList[i].mustList = []
+							state.materialList[i].unList = []
+							state.materialList[i].mdList = state.materialList[i].mdList?.map((item:any) => {
+								if(item.configurationLevel == 0){
+									state.materialList[i].mustList.push(item)
+									return
+								}else{
+									state.materialList[i].unList.push(item)
+									return
+								}
+							})
+							state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{
+								const obj = {
+									value: item.defaultVal,
+									materialName: item.materialName,
+									configurationLevel: item.configurationLevel,
+									id: item.id,
+									stock: item.stock
+								}
+								return {...obj}
+							})
+							state.materialList[i].unList = state.materialList[i].unList.map((item:any)=>{
+								const obj = {
+									value: item.defaultVal,
+									materialName: item.materialName,
+									configurationLevel: item.configurationLevel,
+									id: item.id,
+									stock: item.stock
+								}
+								return {...obj}
+							})
+						}
+						state.equipmentDialog = true
+					} else {
+						ElMessage({
+							type: 'warning',
+							message: res.data.msg
+						});
+					}
+				}else{
+					state.materialList = state.materialList
+					state.equipmentDialog = true
+				}
+			}
+			const conFirmDevices = ()=>{
+				for(let i in state.materialList){
+					for(let j in state.materialList[i].mustList){
+						if(state.materialList[i].mustList[j].value>state.materialList[i].mustList[j].stock){
+							ElMessage({
+								type: 'warning',
+								message: '部分物资库存不足,请重新配置数量。'
+							});
+							return
+						}
+					}
+					for(let j in state.materialList[i].unList){
+						if(state.materialList[i].unList[j].value>state.materialList[i].unList[j].stock){
+							ElMessage({
+								type: 'warning',
+								message: '部分物资库存不足,请重新配置数量。'
+							});
+							return
+						}
+					}
+
+				}
+				ElMessageBox.confirm('是否确认物资及数量配置?')
+						.then(() => {
+							state.equipmentDialog = false
+						})
+						.catch(() => {
+							// catch error
+						})
+			}
+
+			const closeMaterial = ()=>{
+
+			}
+
 			// 折线图
 			const renderMenu = async (value: string) => {
 				Session.set('projectId',value)
@@ -515,6 +661,9 @@
 				Search,
 				ruleFormRef,
 				applyRules,
+				getMaList,
+				conFirmDevices,
+				closeMaterial,
 				handlePreview,
 				getUploadUrl,
 				beforeRemove,

--
Gitblit v1.9.2