From 831c1b25791fd670357d0a55d0db923f4ce7e720 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期五, 16 十二月 2022 13:10:17 +0800 Subject: [PATCH] Default Changelist --- src/views/specialWorkSystem/workTicket/wdsq/components/spaceLog.vue | 16 src/views/specialWorkSystem/workTicket/zysq/components/broken.vue | 219 +---- src/views/specialWorkSystem/workTicket/zysq/components/height.vue | 214 +---- src/views/specialWorkSystem/workTicket/zysq/components/plate.vue | 216 +---- src/views/specialWorkSystem/workTicket/zysq/components/space.vue | 210 ---- src/api/specialWorkSystem/material/index.ts | 2 src/views/specialWorkSystem/workTicket/wdsq/components/hoistLog.vue | 16 src/views/specialWorkSystem/workTicket/zysq/components/hoist.vue | 216 +---- src/views/specialWorkSystem/foundationSet/goods/index.vue | 129 +-- src/views/specialWorkSystem/workTicket/zysq/components/ground.vue | 218 +---- src/views/specialWorkSystem/workTicket/wdsq/components/fireLog.vue | 8 src/views/specialWorkSystem/workTicket/wdsq/components/heightLog.vue | 16 src/views/specialWorkSystem/workTicket/zysq/components/fire.vue | 230 +---- src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue | 241 ++++++ src/views/specialWorkSystem/workTicket/wdsq/components/plateLog.vue | 16 src/views/specialWorkSystem/workTicket/wdsq/components/powerLog.vue | 16 src/views/specialWorkSystem/workTicket/zysq/components/power.vue | 214 +---- src/views/specialWorkSystem/workTicket/wdsq/components/groundLog.vue | 16 src/views/specialWorkSystem/workTicket/wdsq/components/brokenLog.vue | 16 19 files changed, 688 insertions(+), 1,541 deletions(-) diff --git a/src/api/specialWorkSystem/material/index.ts b/src/api/specialWorkSystem/material/index.ts index 74452ab..5133881 100644 --- a/src/api/specialWorkSystem/material/index.ts +++ b/src/api/specialWorkSystem/material/index.ts @@ -15,7 +15,7 @@ //物资列表 getRecordList: () => { return request({ - url: import.meta.env.VITE_API_URL + `/specialWork/material/emegency/materials`, + url: import.meta.env.VITE_API_URL + `/specialWork/material/equipment/materialClassify`, method: 'post' }); }, diff --git a/src/views/specialWorkSystem/foundationSet/goods/index.vue b/src/views/specialWorkSystem/foundationSet/goods/index.vue index 558de0c..ee1493b 100644 --- a/src/views/specialWorkSystem/foundationSet/goods/index.vue +++ b/src/views/specialWorkSystem/foundationSet/goods/index.vue @@ -93,7 +93,7 @@ <el-table-column property="workLevel" label="关联作业等级" align="center" :formatter="toLevel" :show-overflow-tooltip="true"/> <el-table-column property="createUname" label="创建人" align="center"/> <el-table-column property="gmtCreate" label="创建时间" align="center"/> - <el-table-column property="gmtModified" label="更新时间" align="center"/> +<!-- <el-table-column property="gmtModified" label="更新时间" align="center"/>--> <el-table-column fixed="right" label="操作" align="center" width="250"> <template #default="scope"> <el-button link type="primary" size="small" :icon="View" @click="viewRecord(scope.row)">查看</el-button> @@ -121,33 +121,11 @@ </el-form-item> <el-form-item label="作业物资汇总"> <div class="materials"> - <div class="maList"> - <div>必选</div> + <div class="maList" v-for="item in details.clList"> + <div>{{item.configurationLevelName}}</div> <div> - <div v-if="mustList.length>0" v-for="(i,index) in mustList" :key="index"> - {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'非耗材'}} - </div> - <div v-else> - 无 - </div> - </div> - </div> - <div class="maList"> - <div>可选</div> - <div> - <div v-if="chooseList.length>0" v-for="(i,index) in chooseList" :key="index"> - {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'非耗材'}} - </div> - <div v-else> - 无 - </div> - </div> - </div> - <div class="maList"> - <div>高配</div> - <div> - <div v-if="highList.length>0" v-for="(i,index) in highList" :key="index"> - {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'非耗材'}} + <div v-if="item.mdList.length>0" v-for="i in item.mdList"> + {{i.materialName}}({{i.bigClassifyName }}):标准值:{{i.standVal }} </div> <div v-else> 无 @@ -165,9 +143,9 @@ <el-form-item label="创建时间"> <el-input v-model="details.gmtCreate" readonly /> </el-form-item> - <el-form-item label="更新时间"> - <el-input v-model="details.gmtModified" readonly /> - </el-form-item> +<!-- <el-form-item label="更新时间">--> +<!-- <el-input v-model="details.gmtModified" readonly />--> +<!-- </el-form-item>--> <el-form-item> <el-button type="primary" @click="dialogDetails = false" size="default">确认</el-button> </el-form-item> @@ -225,26 +203,22 @@ </el-form-item> <el-form-item label="物资标准配置"> <el-tabs tab-position="left" class="demo-tabs" type="border-card"> - <el-tab-pane v-for="(item,index) in allList" :label="item.materialTypeName" :key="index"> - <div class="tab-i" v-for="(i,x) in item.list" :key="x" v-if="item.list && item.list.length>0"> - <el-checkbox :label="i.materialName" v-model="checkData[index].list[x].checked"> - </el-checkbox> - <el-form v-if="checkData[index].list[x].checked" :model="checkData[index].list[x]" label-width="100px" ref="addListRef" :rules="addListRules"> - <el-form-item label="配置级别" prop="configurationLevel"> - <el-select v-model="checkData[index].list[x].configurationLevel"> - <el-option key="0" label="必选" value="0"/> - <el-option key="1" label="可选" value="1"/> - <el-option key="2" label="高配" value="2"/> - </el-select> - </el-form-item> - <el-form-item v-if="checkData[index].list[x].configurationLevel==0" label="默认值" prop="defaultVal"><el-input v-model="checkData[index].list[x].defaultVal"/></el-form-item> - <el-form-item label="是否耗材" prop="consumables"> - <el-radio-group v-model="checkData[index].list[x].consumables"> - <el-radio :label=true>是</el-radio> - <el-radio :label=false>否</el-radio> - </el-radio-group> - </el-form-item> - </el-form> + <el-tab-pane v-for="(item,index) in allList" :label="item.materialClassifyName" :key="index"> + <div class="tab-i" v-if="item.childList && item.childList.length>0"> + <div v-for="(i,x) in item.childList" :key="x"> + <el-checkbox :label="i.materialClassifyName" v-model="checkData[index].childList[x].checked"> + </el-checkbox> + <el-form v-if="checkData[index].childList[x].checked" :model="checkData[index].childList[x]" label-width="100px" ref="addListRef" :rules="addListRules"> + <el-form-item label="配置级别" prop="configurationLevel"> + <el-select v-model="checkData[index].childList[x].configurationLevel"> + <el-option key="0" label="必选" :value="0"/> + <el-option key="1" label="可选" :value="1"/> + <el-option key="2" label="高配" :value="2"/> + </el-select> + </el-form-item> + <el-form-item label="标准值" prop="standVal"><el-input type="number" v-model.number="checkData[index].childList[x].standVal"/></el-form-item> + </el-form> + </div> </div> <div v-else>暂无物资配置数据</div> </el-tab-pane> @@ -537,9 +511,8 @@ workLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); const addListRules = reactive<FormRules>({ - defaultVal: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], - configurationLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], - consumables: [{ required: true, message: '该内容不能为空', trigger: 'blur' }] + standVal: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], + configurationLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); // 页面载入时执行方法 @@ -572,16 +545,13 @@ if (res.data.code === '200') { state.allList = JSON.parse(JSON.stringify(res.data.data)) for(let i in state.allList){ - state.allList[i].list = state.allList[i].list?.map((item:any) => { + state.allList[i].childList = state.allList[i].childList?.map((item:any) => { const obj = { checked: false, - materialName: item.name, - consumables: null, - defaultVal: 0, + materialClassifyName: item.materialClassifyName, + standVal: 0, configurationLevel: null, - materialType: item.materialType, - materialTypeName: item.materialTypeName, - emergencyMaterialId: item.id + smallClassifyId: item.id } return {...obj} }) @@ -676,7 +646,6 @@ const editRecordBtn = async (index, row) => { getList() state.addRecord = JSON.parse(JSON.stringify(row)); - console.log(state.addRecord,'state.addRecord') state.dialogAddRecord = true; state.chosenIndex = index; }; @@ -704,12 +673,12 @@ if (valid) { state.addRecord.materialDetailList = [] for(let i in state.checkData){ - if(state.checkData[i].list && state.checkData[i].list.length>0){ - for(let j=0;j<state.checkData[i].list.length;j++){ - if(state.checkData[i].list[j].checked){ + if(state.checkData[i].childList && state.checkData[i].childList.length>0){ + for(let j=0;j<state.checkData[i].childList.length;j++){ + if(state.checkData[i].childList[j].checked){ // delete state.checkData[i].list[j].checked // state.checkData[i].list[j].checked - let { checked,...checkObj } = state.checkData[i].list[j] + let { checked,materialClassifyName,...checkObj } = state.checkData[i].childList[j] state.addRecord.materialDetailList.push(checkObj) } } @@ -722,14 +691,20 @@ info: state.addRecord.info, materialDetailList: state.addRecord.materialDetailList }; - console.log(data.materialDetailList,'data.materialDetailList') - if(data.materialDetailList.length==0 || data.materialDetailList.some((e) => e.configurationLevel == null) || data.materialDetailList.some((e) => e.consumables == null)){ + if(data.materialDetailList.length==0 || data.materialDetailList.some((e) => e.configurationLevel == null)){ ElMessage({ type: 'warning', message: '请选择物资配置并完善必填数据' }); return } + if(data.materialDetailList.some((e) => e.configurationLevel == 0 && e.standVal <= 0)){ + ElMessage({ + type: 'warning', + message: '必选物资标准值须大于0' + }); + return + } if (state.chosenIndex == null) { await addRecord(data); } else { @@ -818,26 +793,6 @@ state.details = JSON.parse(JSON.stringify(row)); state.details.workType = toType(state.details) state.details.workLevel = toLevel(state.details) - if(state.details.materialTypeList && state.details.materialTypeList.length>0){ - const allList = JSON.parse(JSON.stringify(state.details.materialTypeList)) - for(let i = 0;i < allList.length; i++){ - if(allList[i].mdList && allList[i].mdList.length>0){ - allList[i].mdList.map((item)=>{ - if(item.configurationLevel == 0){ - state.mustList.push(item) - return - }else if(item.configurationLevel == 1){ - state.chooseList.push(item) - return - }else{ - state.highList.push(item) - return - } - }) - } - - } - } state.dialogDetails = true; }; diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/brokenLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/brokenLog.vue index 70b06f9..3666db3 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/brokenLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/brokenLog.vue @@ -42,14 +42,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="期望开始时间"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/fireLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/fireLog.vue index feb4040..c5059b7 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/fireLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/fireLog.vue @@ -30,14 +30,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} </template> </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/groundLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/groundLog.vue index 5e1f2c7..07a65c4 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/groundLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/groundLog.vue @@ -36,14 +36,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/heightLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/heightLog.vue index ba57c56..96f5a45 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/heightLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/heightLog.vue @@ -33,14 +33,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/hoistLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/hoistLog.vue index fb95a14..84f4994 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/hoistLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/hoistLog.vue @@ -33,14 +33,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/plateLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/plateLog.vue index 3cf73c9..94854dc 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/plateLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/plateLog.vue @@ -54,14 +54,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/powerLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/powerLog.vue index c83eb3d..acce54f 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/powerLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/powerLog.vue @@ -36,14 +36,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/wdsq/components/spaceLog.vue b/src/views/specialWorkSystem/workTicket/wdsq/components/spaceLog.vue index 3cc4206..f08f3d3 100644 --- a/src/views/specialWorkSystem/workTicket/wdsq/components/spaceLog.vue +++ b/src/views/specialWorkSystem/workTicket/wdsq/components/spaceLog.vue @@ -36,14 +36,14 @@ </el-form-item> <el-form-item label="关联物资"> <el-table :data="details.workMaterial" style="width: 100%" border> - <el-table-column prop="materialTypeName" label="物资类型" align="center"/> - <el-table-column prop="materialName" label="物资名称" align="center"/> - <el-table-column prop="consumables" label="是否耗材" align="center"> - <template #default="scope"> - {{scope.row.consumables?'耗材':'非耗材'}} - </template> - </el-table-column> - <el-table-column prop="defaultVal" label="配置数量" align="center"/> + <el-table-column prop="bigClassifyName" label="物资类型" align="center"/> + <el-table-column prop="materialName" label="物资名称" align="center"/> + <el-table-column prop="configurationLevel" label="配置级别" align="center"> + <template #default="scope"> + {{scope.row.configurationLevel == 0?'必选':(scope.row.configurationLevel == 1? '可选':'高配')}} + </template> + </el-table-column> + <el-table-column prop="useCount" label="配置数量" align="center"/> </el-table> </el-form-item> <el-form-item label="关联其他作业"> diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/broken.vue b/src/views/specialWorkSystem/workTicket/zysq/components/broken.vue index 17a7dcb..8378a7c 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/broken.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/broken.vue @@ -120,40 +120,13 @@ <el-row> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -177,7 +150,6 @@ import axios from 'axios'; interface stateType { - equipmentDialog: boolean, form: Object, csDepList: Array<any>, fileList: Array<file>, @@ -188,27 +160,28 @@ casProps: {}, casProps2: {}, isOverSize: boolean, - materialList: Array<any> } interface file { url: string; } export default defineComponent({ name: 'brokenForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList','departList'], setup() { const userInfo = useUserInfo() const { userInfos } = storeToRefs(userInfo); const state = reactive<stateType>({ - equipmentDialog: false, form: { operatorUids: [], workType: 5, - workLevel: 0, + workLevel: null, workContent: '', workLocation: '', hazardIdentification: '', + maId: null, workDetail:{ operationDepId: null, bcReason: '', @@ -221,7 +194,6 @@ expStartTime: '', expEndTime: '' }, - materialList: [], isOverSize: false, fileList: [], imgLimit: 3, @@ -269,6 +241,7 @@ checkStrictly: true } }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -284,52 +257,42 @@ "workDetail.involvedDepIds": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + + const openMaList = ()=>{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] - } + // if (state.form.wmAddReqDTOList == null || state.form.wmAddReqDTOList.length == 0){ + // ElMessage({ + // type: 'warning', + // message: '请确认关联物资的配置' + // }); + // return + // } state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0] state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -350,7 +313,8 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } @@ -465,100 +429,6 @@ }); } - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 5,workLevel: null} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) @@ -570,10 +440,9 @@ Search, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + conFirmMaterials, + openMaList, handlePreview, getUploadUrl, beforeRemove, diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/fire.vue b/src/views/specialWorkSystem/workTicket/zysq/components/fire.vue index a62a7ec..b31069e 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/fire.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/fire.vue @@ -102,40 +102,13 @@ <el-row> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -153,31 +126,30 @@ import { ElMessage, ElMessageBox } from 'element-plus' import type { FormInstance, FormRules } from 'element-plus' import { workApplyApi } from '/@/api/specialWorkSystem/workApply'; - - interface stateType { form: Object, workLevelList: Array<any>, otherWorkList: Array<any>, - equipmentDialog: boolean, - materialList: Array<any> + equipmentDialog: boolean } export default defineComponent({ name: 'fireForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList'], setup() { const userInfo = useUserInfo() const { userInfos } = storeToRefs(userInfo); const state = reactive<stateType>({ equipmentDialog: false, - materialList: [], form: { operatorUids: [], workType: 1, workLevel: null, workContent: '', workLocation: '', + maId: null, hazardIdentification: '', workDetail:{ hotMethod: '', @@ -237,6 +209,7 @@ } ] }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -253,58 +226,46 @@ onMounted(() => { }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + const openMaList = ()=>{ + if(state.form.workLevel == null){ + ElMessage({ + type: 'warning', + message: '请先选择作业等级再获取相应物资配置' + }); + }else{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - if (state.materialList.length == 0){ - ElMessage({ - type: 'warning', - message: '请确认关联物资的配置' - }); - return - } - 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 - } - } - 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] - } + // if (state.form.wmAddReqDTOList == null || state.form.wmAddReqDTOList.length == 0){ + // ElMessage({ + // type: 'warning', + // message: '请确认关联物资的配置' + // }); + // return + // } state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0] state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -322,106 +283,14 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } }) } - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 1,workLevel: state.form.workLevel} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) @@ -431,12 +300,11 @@ return { renderMenu, Search, + material, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + openMaList, + conFirmMaterials, submitForm, ...toRefs(state), }; diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/ground.vue b/src/views/specialWorkSystem/workTicket/zysq/components/ground.vue index fa98456..9b16ea0 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/ground.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/ground.vue @@ -122,40 +122,13 @@ <el-row> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -190,15 +163,16 @@ dialogImageUrl: string | null, imgLimit: number, casProps: {}, - isOverSize: Boolean, - materialList: Array<any> + isOverSize: Boolean } interface file { url: string; } export default { name: 'groundForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList','departList'], setup(props: any, context: any) { const userInfo = useUserInfo() @@ -208,10 +182,11 @@ form: { operatorUids: [], workType: 4, - workLevel: 0, + workLevel: null, workContent: '', workLocation: '', hazardIdentification: '', + maId: null, workDetail:{ operationDepId: null, gbScope: '', @@ -226,7 +201,6 @@ }, isOverSize: false, fileList: [], - materialList: [], imgLimit: 3, uploadUrl: '', dialogVisible: false, @@ -300,6 +274,7 @@ checkStrictly: true } }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -313,51 +288,41 @@ "workDetail.gbMethod": [{ required: true, message: '该内容不能为空', trigger: 'blur' }], "workDetail.gbPath": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + + const openMaList = ()=>{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } + const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] - } + // if (state.form.wmAddReqDTOList == null || state.form.wmAddReqDTOList.length == 0){ + // ElMessage({ + // type: 'warning', + // message: '请确认关联物资的配置' + // }); + // return + // } state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0] state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -378,7 +343,8 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } @@ -495,99 +461,6 @@ // console.log('2111111111111') // }; - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 4,workLevel: null} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) @@ -600,10 +473,9 @@ Plus, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + openMaList, + conFirmMaterials, handlePreview, getUploadUrl, beforeRemove, diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/height.vue b/src/views/specialWorkSystem/workTicket/zysq/components/height.vue index cc25b8e..eed8f97 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/height.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/height.vue @@ -116,40 +116,13 @@ </el-col> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -176,12 +149,13 @@ workLevelList: Array<any>, heDepList: Array<any>, otherWorkList: Array<any>, - casProps:{}, - materialList: Array<any> + casProps:{} } export default defineComponent({ name: 'heightForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList','departList'], setup() { const userInfo = useUserInfo() @@ -195,6 +169,7 @@ workContent: '', workLocation: '', hazardIdentification: '', + maId: null, workDetail:{ operationDepId: '', operationHeight: null, @@ -231,7 +206,6 @@ value: 6 } ], - materialList: [], casProps: { emitPath: false, value: 'depId', @@ -303,6 +277,7 @@ } ] }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -316,52 +291,40 @@ "workDetail.operationHeight": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + const openMaList = ()=>{ + if(state.form.workLevel == null){ + ElMessage({ + type: 'warning', + message: '请先选择作业等级再获取相应物资配置' + }); + }else{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -379,106 +342,14 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } }) } - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 6,workLevel: state.form.workLevel} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) => { @@ -491,10 +362,9 @@ Search, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + openMaList, + conFirmMaterials, submitForm, ...toRefs(state), }; diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/hoist.vue b/src/views/specialWorkSystem/workTicket/zysq/components/hoist.vue index c781918..188beab 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/hoist.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/hoist.vue @@ -101,40 +101,13 @@ <el-row> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -157,12 +130,13 @@ interface stateType { equipmentDialog: boolean, form: Object, - workLevelList: Array<any>, - materialList: Array<any> + workLevelList: Array<any> } export default defineComponent({ name: 'hoistForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList'], setup() { const userInfo = useUserInfo() @@ -175,6 +149,7 @@ workLevel: null, workContent: '', workLocation: '', + maId: null, hazardIdentification: '', workDetail:{ hoistingToolName: '', @@ -185,7 +160,6 @@ expStartTime: '', expEndTime: '' }, - materialList: [], workLevelList: [ { label: "一级吊装作业", @@ -201,6 +175,7 @@ } ] }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -214,52 +189,39 @@ "workDetail.weightMass": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } - + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + const openMaList = ()=>{ + if(state.form.workLevel == null){ + ElMessage({ + type: 'warning', + message: '请先选择作业等级再获取相应物资配置' + }); + }else{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -277,105 +239,12 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } }) - } - - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 3,workLevel: state.form.workLevel} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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 = ()=>{ - } // 折线图 @@ -389,10 +258,9 @@ Search, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + openMaList, + conFirmMaterials, submitForm, ...toRefs(state), }; diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue b/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue new file mode 100644 index 0000000..3dbb18e --- /dev/null +++ b/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue @@ -0,0 +1,241 @@ +<template> + <el-dialog v-model="equipmentDialog" title="关联物资标准" width="40%" center @close="closeMaterial"> + <div class="standard" v-for="item in materialList"> + <div>{{ item.name }}</div> + <el-button @click="openList(item)" type="success">选用</el-button> + </div> + + <el-dialog v-model="equipDetailDialog" title="物资标准详情" width="40%" center @open="openDetail" > + <table class="table"> + <tr> + <th class="w-20">物资名称</th> + <th class="w-20">出库部门(仓库)</th> + <th class="w-15">对应库存</th> + <th class="w-15">标准值</th> + <th class="w-15">级别</th> + <th class="w-15">实际使用</th> + </tr> + <tr v-for="(item,index) in materialDetail"> + <td class="w-20">{{item.materialName}}</td> + <td class="w-20"> + <el-select v-model="addList[index].depId" @change="changeDep($event,index)"> + <el-option + v-for="i in item.msList" + :key="i.depId" + :label="i.depName" + :value="i.depId" + /> + </el-select> + </td> + <td class="w-15"> + {{stockCount[index]}} + </td> + <td class="w-15">{{item.standVal}}</td> + <td class="w-15">{{item.configurationLevelName}}</td> + <td class="w-15"> + <el-input type="number" v-model.number="addList[index].useCount"/> + </td> + </tr> + </table> + <template #footer> + <span class="dialog-footer"> + <el-button @click="closeChoose()" size="default">取消</el-button> + <el-button type="primary" @click="submitMaterials" size="default">确认</el-button> + </span> + </template> + </el-dialog> + </el-dialog> +</template> + +<script lang="ts"> +import {workApplyApi} from "/@/api/specialWorkSystem/workApply"; + +interface stateType { + equipmentDialog:boolean + materialList: Array<any> + equipDetailDialog: boolean + materialDetail: Array<any> + stockCount: Array<number> + addList: Array<any> + chosenId: number | null +} + + +import { reactive, toRefs, ref } from 'vue'; +import { approveBasicApi } from '/@/api/specialWorkSystem/approveBasic'; +import {ElMessage, ElMessageBox} from 'element-plus'; +import {useUserInfo} from "/@/stores/userInfo"; +import {storeToRefs} from "pinia"; +export default { + name: 'materialDialog', + setup(props,context) { + const userInfo = useUserInfo() + const { userInfos } = storeToRefs(userInfo); + const approveBasicFormRef = ref(); + const state = reactive<stateType>({ + chosenId: null, + equipmentDialog: false, + materialList: [], + equipDetailDialog: false, + materialDetail: [], + stockCount: [], + addList: [] + }); + + // 确认物资标准 + const getMaList = async(type:number,level:number) =>{ + const data = {workType: type,workLevel: level} + const res = await workApplyApi().getMaterial(data) + if (res.data.code === '200') { + if(res.data.data && res.data.data.length>0){ + state.materialList = JSON.parse(JSON.stringify(res.data.data)) + }else{ + ElMessage({ + type: 'warning', + message: '暂时查询不到物资标准信息' + }); + state.equipmentDialog = false + } + } else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); + state.equipmentDialog = false + } + } + const openList =(item:object)=>{ + state.chosenId = item.id + state.addList = [] + state.stockCount = [] + if(item.mcList && item.mcList.length>0){ + for(let j in item.mcList){ + if(item.mcList[j].msList == null || item.mcList[j].msList.length==0){ + item.mcList.splice(j,1) + } + } + state.materialDetail = item.mcList + for(let i in state.materialDetail){ + state.addList.push( + { + materialId: state.materialDetail[i].materialId, + depId: null, + depName: '', + useCount: null + } + ) + for(let x in state.materialDetail[i].msList){ + if(state.materialDetail[i].msList[x].depId == userInfos.value.depId){ + state.addList[i].depId = userInfos.value.depId + state.addList[i].depName = state.materialDetail[i].msList[x].depName + state.stockCount[i] = state.materialDetail[i].msList.find((e) => e.depId == state.addList[i].depId).stockCount + } + } + } + } + state.equipDetailDialog = true + } + + const openDetail = ()=>{ + console.log(state.addList,'打开弹窗') + } + + const changeDep = (val:number,index:number)=>{ + state.addList[index].depName = state.materialDetail[index].msList.find((i) => i.depId == val).depName + state.stockCount[index] = state.materialDetail[index].msList.find((i) => i.depId == val).stockCount + } + const submitMaterials = ()=>{ + if(state.addList.length > 0 && (state.addList.some((e) => e.depId == null && e.useCount != null ) || state.addList.some((e) => e.useCount == null && e.depId != null))){ + ElMessage({ + type: 'warning', + message: '出库部门或实际使用值不可为空' + }); + return + } + for(let i in state.materialDetail){ + if(state.materialDetail[i].configurationLevelName == '必选' && state.addList[i].depId != null && state.addList[i].useCount <= 0){ + ElMessage({ + type: 'warning', + message: '必选物资数量不能小于等于0' + }); + return + } + if((state.stockCount[i] !=null && state.addList[i].useCount !=null) && (state.stockCount[i] < state.addList[i].useCount)){ + ElMessage({ + type: 'warning', + message: '物资配置数量超出库存量,请重新配置' + }); + return + } + } + // if(state.addList.length > 0){ + // for(let n in state.addList){ + // if(state.addList[n].depId == null && state.addList[n].useCount == null){ + // state.addList.splice(n,1) + // } + // } + // } + console.log(state.addList,state.chosenId,'666666666') + context.emit('conFirmMaterials',state.addList,state.chosenId) + state.equipDetailDialog = false + state.equipmentDialog = false + } + + const closeMaterial = ()=>{ + + } + const closeChoose = () =>{ + state.equipDetailDialog = false + state.equipmentDialog = false + } + return { + ...toRefs(state), + changeDep, + getMaList, + openList, + openDetail, + closeChoose, + closeMaterial, + submitMaterials + }; + } +}; +</script> + +<style lang="scss" scoped> + .standard{ + width: 100%; + display: flex; + margin-bottom: 20px; + align-items: center; + justify-content: space-between; + } + + .table{ + width: 100%; + border-collapse: collapse; + tr{ + width: 100%; + border: 1px solid #ccc; + th,td{ + border-left: 1px solid #ccc; + &:first-of-type{ + border-left: none; + } + } + th{ + padding: 10px 0; + font-weight: bolder; + } + + .w-15{ + width: 15%; + text-align: center; + } + .w-20{ + width: 20%; + text-align: center; + } + } + } +</style> diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/plate.vue b/src/views/specialWorkSystem/workTicket/zysq/components/plate.vue index efde56e..46e0656 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/plate.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/plate.vue @@ -197,40 +197,13 @@ <el-row> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -264,28 +237,29 @@ dialogImageUrl: string | null, imgLimit: number, isOverSize: boolean, - equipmentDialog: boolean, - materialList: Array<any> + equipmentDialog: boolean } interface file { url: string; } export default defineComponent({ name: 'plateForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList'], setup() { const userInfo = useUserInfo() const { userInfos } = storeToRefs(userInfo); const state = reactive<stateType>({ equipmentDialog: false, - materialList: [], form: { operatorUids: [], workType: 8, workLevel: null, workContent: '', workLocation: '', + maId: null, hazardIdentification: '', workDetail:{ bpCode: '', @@ -383,6 +357,7 @@ } ] }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -403,52 +378,39 @@ "workDetail.bpLocationMapPath": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } - + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + const openMaList = ()=>{ + if(state.form.workLevel == null){ + ElMessage({ + type: 'warning', + message: '请先选择作业等级再获取相应物资配置' + }); + }else{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] @@ -475,7 +437,8 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } @@ -588,100 +551,6 @@ }); } - // 确认物资标准 - 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') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) @@ -693,10 +562,9 @@ Search, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + openMaList, + conFirmMaterials, handlePreview, getUploadUrl, beforeRemove, diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/power.vue b/src/views/specialWorkSystem/workTicket/zysq/components/power.vue index b44371b..8f4d84e 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/power.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/power.vue @@ -99,40 +99,13 @@ </el-col> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -155,25 +128,26 @@ interface stateType { form: Object, workLevelList: Array<any>, - equipmentDialog: boolean, - materialList: Array<any> + equipmentDialog: boolean } export default defineComponent({ name: 'powerForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList'], setup() { const userInfo = useUserInfo() const { userInfos } = storeToRefs(userInfo); const state = reactive<stateType>({ equipmentDialog: false, - materialList: [], form: { operatorUids: [], workType: 7, workLevel: 0, workContent: '', workLocation: '', + maId: null, hazardIdentification: '', workDetail:{ powerAccessPoint: '', @@ -200,6 +174,7 @@ } ] }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -214,52 +189,41 @@ "workDetail.equipmentAndPower": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + + const openMaList = ()=>{ + if(state.form.workLevel == null){ + ElMessage({ + type: 'warning', + message: '请先选择作业等级再获取相应物资配置' + }); + }else{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -277,105 +241,14 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } }) } - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 7,workLevel: null} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) @@ -387,10 +260,9 @@ Search, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + openMaList, + conFirmMaterials, submitForm, ...toRefs(state), }; diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/space.vue b/src/views/specialWorkSystem/workTicket/zysq/components/space.vue index 5bc5bba..73b9e4f 100644 --- a/src/views/specialWorkSystem/workTicket/zysq/components/space.vue +++ b/src/views/specialWorkSystem/workTicket/zysq/components/space.vue @@ -110,40 +110,13 @@ <el-row> <el-col :span="12"> <el-form-item label="选择关联物资"> - <el-button type="primary" @click="getMaList">选择物资标准</el-button> + <el-button type="primary" @click="openMaList">选择物资标准</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" @change="(val)=>toZero(val,index,'mustList',x)" 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" @change="(val)=>toZero(val,index,'unList',x)" 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> + <material-dialog ref="material" @conFirmMaterials="conFirmMaterials"></material-dialog> <div class="applyBtn"> <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button> </div> @@ -168,25 +141,26 @@ csDepList: Array<any>, otherWorkList: Array<any>, casProps: {}, - equipmentDialog: boolean, - materialList: Array<any> + equipmentDialog: boolean } export default defineComponent({ name: 'spaceForm', - components: {}, + components: { + materialDialog: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue')), + }, props:['workerList','departList'], setup() { const userInfo = useUserInfo() const { userInfos } = storeToRefs(userInfo); const state = reactive<stateType>({ equipmentDialog: false, - materialList: [], form: { operatorUids: [], workType: 2, - workLevel: 0, + workLevel: null, workContent: '', workLocation: '', + maId: null, hazardIdentification: '', workDetail:{ csDepId: null, @@ -268,6 +242,7 @@ } ] }); + const material = ref() const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], @@ -281,52 +256,34 @@ "workDetail.csOriginalName": [{ required: true, message: '该内容不能为空', trigger: 'blur' }] }); - const toZero = (value: string | number,index: number,name: string,x:number) =>{ - if(!value){ - state.materialList[index][name][x].value = 0 - } - } + // const toZero = (value: string | number,index: number,name: string,x:number) =>{ + // if(!value){ + // state.materialList[index][name][x].value = 0 + // } + // } + + const openMaList = ()=>{ + material.value.equipmentDialog = true + material.value.getMaList(state.form.workType,state.form.workLevel) + } + const conFirmMaterials = (addList: Array<any>,chosenId: number) =>{ + state.form.maId = null + state.form.wmAddReqDTOList = [] + if(addList.length > 0){ + for(let i in addList){ + if(addList[i].depId != null && addList[i].useCount != null){ + state.form.wmAddReqDTOList.push(addList[i]) + } + } + } + // state.form.wmAddReqDTOList = addList + state.form.maId = chosenId + } const submitForm = async (formEl: FormInstance | undefined) => { if (!formEl) return await formEl.validate(async (valid, fields) => { if (valid) { - 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 - } - } - 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] let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form)) @@ -345,106 +302,14 @@ message: res.data.msg }); } - state.materialList = [] + state.form.maId = null + state.form.wmAddReqDTOList = [] } else { console.log('error submit!', fields) } }) } - // 确认物资标准 - const getMaList = async() =>{ - if(state.materialList.length == 0){ - const data = {workType: 2,workLevel: null} - const res = await workApplyApi().getMaterial(data) - if (res.data.code === '200') { - if(res.data.data.materialTypeList && res.data.data.materialTypeList!=null&&res.data.data.materialTypeList.length>0){ - 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: '暂时查询不到物资标准信息' - }); - } - } 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) => { @@ -457,10 +322,9 @@ Search, ruleFormRef, applyRules, - toZero, - getMaList, - conFirmDevices, - closeMaterial, + material, + openMaList, + conFirmMaterials, submitForm, ...toRefs(state), }; -- Gitblit v1.9.2