Browse Source

no message

linwenxin 1 year ago
parent
commit
9d7ff6822a
1 changed files with 117 additions and 58 deletions
  1. 117 58
      src/views/workOrder/completedToBeSettled/index.vue

+ 117 - 58
src/views/workOrder/completedToBeSettled/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<template-page ref="pageRef" :getList="getList" :optionsEvensGroup="optionsEvensGroup" :columnParsing="columnParsing"
 		:tableAttributes="tableAttributes" :tableEvents="tableEvents" :moreParameters="moreParameters"
-		:screeningAnalysis="screeningAnalysis" :filterMethod="filterMethod" :replaceOrNotMap="true" :showTable="showTable">
+		:screeningAnalysis="screeningAnalysis" :filterMethod="filterMethod" :replaceOrNotMap="true">
 	</template-page>
 </template>
 
@@ -9,7 +9,9 @@
 import TemplatePage from '@/components/template/template-page-1.vue'
 import import_mixin from '@/components/template/import_mixin.js'
 import operation_mixin from '@/components/template/operation_mixin.js'
-import { orderBaseList2, orderBaseStatusCount2, orderBaseSettleNormDetail2 } from "@/api/workOrderPool.js"
+import { listPageV2 as listPageV3 } from "@/api/workOrder/settlementStandardInstall";
+import { listPageV2 as listPageV2Repair } from "@/api/workOrder/settlementStandardRepair";
+import { orderBaseList2, orderBaseStatusCount2, orderBaseSettleNormDetail2, settleNormInstallQuery, orderBaseSettleNormConfirm, settleNormOtherQuery, orderBaseSettleNormReset } from "@/api/workOrderPool.js"
 import { listPageV2 } from "@/api/workOrder/orderType";
 import ywgdjs from "@/assets/ywgdjs.png"
 import yjs from "@/assets/yjs.png"
@@ -31,7 +33,6 @@ export default {
 			},
 			orderTypeList: [],
 			orderStatusList: [],
-			showTable: true,
 		}
 	},
 	computed: {
@@ -176,32 +177,8 @@ export default {
 					id: row.id,
 					orderProductId: row.pgOrderProductId
 				}).then(res => {
-					var orderChannelId
-					var normList = []
-					var pfuqinid = 0
-					res.data.normList.map((item, index) => {
-						if (!orderChannelId) { orderChannelId = item.orderChannelId }
-						item.settleNum = item.settleNum || ""
-						normList.push({ ...item, pfuqinid: pfuqinid, zijideid: 0, bianji: res.data.settleStatus == 'YJS' ? false : true })
-						item.workerList.map((resdata, ind_) => {
-							if (ind_ !== 0) { normList.push({ pfuqinid: pfuqinid, zijideid: ind_ }) }
-							if (ind_ == item.workerList.length - 1) { pfuqinid += (ind_ + 1) }
-						})
-					})
-					var otherNormList = []
-					var qtpfuqinid = 0
-					res.data.otherNormList.map((item, index) => {
-						item.settleNum = item.settleNum || ""
-						otherNormList.push({ ...item, pfuqinid: qtpfuqinid, zijideid: 0, bianji: res.data.settleStatus == 'YJS' ? false : true })
-						item.workerList.map((resdata, ind_) => {
-							if (ind_ !== 0) { otherNormList.push({ pfuqinid: qtpfuqinid, zijideid: ind_ }) }
-							if (ind_ == item.workerList.length - 1) { qtpfuqinid += (ind_ + 1) }
-						})
-					})
-					row.expandData = res.data ? { ...res.data, normList, otherNormList } : {};
-					this.showTable = false
-					this.$nextTick(() => {
-						this.showTable = true
+					this.zhuzhuang(res.data).then(res => {
+						row.expandData = res
 					})
 				})
 			}
@@ -209,6 +186,7 @@ export default {
 
 		columnExpand(h, { row, column, index }) {
 			var expandDataForm = row.expandData
+			var rowZhu = row
 			return expandDataForm ? (<div style="box-sizing: border-box;padding: 10px 10px 0px 50px;">
 				<zj-form-container form-data={expandDataForm}
 					formAttributes={{ 'label-position': 'top' }}
@@ -252,14 +230,14 @@ export default {
 														row.repairAmount = ""
 														row.settleNormId = ""
 														if (val) {
-															var data = this.classifyListChuLi([], "orderChannelId", "orderChannelText").find(item => item.value == val)
+															var data = this.classifyListChuLi(expandDataForm.classifyList, "orderChannelId", "orderChannelText").find(item => item.value == val)
 															row.channelText = data.label
 														} else {
 															row.channelText = ""
 														}
 													}}
 													placeholder="请选择">
-													{this.classifyListChuLi([], "orderChannelId", "orderChannelText").map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
+													{this.classifyListChuLi(expandDataForm.classifyList, "orderChannelId", "orderChannelText").map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
 												</el-select>
 											</el-form-item>
 										</div> : null
@@ -286,14 +264,14 @@ export default {
 														row.repairAmount = ""
 														row.settleNormId = ""
 														if (val) {
-															var data = this.classifyListChuLi([], "parentCategoryId", "parentCategoryName", (item) => item.orderChannelId == row.channelId).find(item => item.value == val)
+															var data = this.classifyListChuLi(expandDataForm.classifyList, "parentCategoryId", "parentCategoryName", (item) => item.orderChannelId == row.channelId).find(item => item.value == val)
 															row.parentCategoryName = data.label
 														} else {
 															row.parentCategoryName = ""
 														}
 													}}
 													placeholder="请选择">
-													{this.classifyListChuLi([], "parentCategoryId", "parentCategoryName", (item) => item.orderChannelId == row.channelId).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
+													{this.classifyListChuLi(expandDataForm.classifyList, "parentCategoryId", "parentCategoryName", (item) => item.orderChannelId == row.channelId).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
 												</el-select>
 											</el-form-item>
 										</div> : null
@@ -318,14 +296,14 @@ export default {
 														row.repairAmount = ""
 														row.settleNormId = ""
 														if (val) {
-															var data = this.classifyListChuLi([], "categoryId", "categoryName", (item) => item.orderChannelId == row.channelId && item.parentCategoryId == row.parentCategoryId).find(item => item.value == val)
+															var data = this.classifyListChuLi(expandDataForm.classifyList, "categoryId", "categoryName", (item) => item.orderChannelId == row.channelId && item.parentCategoryId == row.parentCategoryId).find(item => item.value == val)
 															row.categoryName = data.label
 														} else {
 															row.categoryName = ""
 														}
 													}}
 													placeholder="请选择">
-													{this.classifyListChuLi([], "categoryId", "categoryName", (item) => item.orderChannelId == row.channelId && item.parentCategoryId == row.parentCategoryId).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
+													{this.classifyListChuLi(expandDataForm.classifyList, "categoryId", "categoryName", (item) => item.orderChannelId == row.channelId && item.parentCategoryId == row.parentCategoryId).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
 												</el-select>
 											</el-form-item>
 										</div> : null
@@ -348,7 +326,7 @@ export default {
 																onInput={(val) => { row[column.columnAttributes.prop] = val }}
 																onChange={(val) => {
 																	if (val) {
-																		var data = this.getflList([], row).find(item => item.label == val)
+																		var data = this.getflList(expandDataForm.gonglv, row).find(item => item.label == val)
 																		row.normAmount = data.normAmount
 																		row.settleNormId = data.id
 																	} else {
@@ -357,7 +335,7 @@ export default {
 																	}
 																}}
 																placeholder="请选择">
-																{this.getflList([], row).map((item, index_) => <el-option key={index_} label={item.label} value={item.label}></el-option>)}
+																{this.getflList(expandDataForm.gonglv, row).map((item, index_) => <el-option key={index_} label={item.label} value={item.label}></el-option>)}
 															</el-select>
 														</el-form-item>
 													</div> : null
@@ -425,7 +403,7 @@ export default {
 																onInput={(val) => { row[column.columnAttributes.prop] = val }}
 																onChange={(val) => {
 																	if (val) {
-																		var data = this.getflList([], row).find(item => item.label == val)
+																		var data = this.getflList(expandDataForm.gonglr, row).find(item => item.label == val)
 																		row.repairAmount = data.repairAmount
 																		row.normAmount = data.normAmount
 																		row.settleNormId = data.id
@@ -436,7 +414,7 @@ export default {
 																	}
 																}}
 																placeholder="请选择">
-																{this.getflList([], row).map((item, index_) => <el-option key={index_} label={({ INSIDE: '保内', OUT: '保外' })[item.label]} value={item.label}></el-option>)}
+																{this.getflList(expandDataForm.gonglr, row).map((item, index_) => <el-option key={index_} label={({ INSIDE: '保内', OUT: '保外' })[item.label]} value={item.label}></el-option>)}
 															</el-select>
 														</el-form-item>
 													</div> : null
@@ -663,14 +641,9 @@ export default {
 											}>平分费用</el-button> : null}
 											{expandDataForm.normList[row.pfuqinid].bianji ? <el-button type="text" onClick={
 												() => {
-													var item = expandDataForm.normList[row.pfuqinid]
-													if ([0, 0, 0, ...item.workerList.map(val => Number(val.settleAmount))].reduce(function (prev, curr, idx, arr) {
-														return prev + curr;
-													}) == Number(item.settleAmount)) {
+													this.itemOrderBaseSettleNormReset(rowZhu, () => {
 														expandDataForm.normList[row.pfuqinid].bianji = false
-													} else {
-														this.$message.warning(`费用信息-${item.channelText}-${item.parentCategoryName}-${item.categoryName}-${item.label}:合计结算总金额与总金额不等`)
-													}
+													})
 												}
 											}>确定</el-button> : null}
 											{!expandDataForm.normList[row.pfuqinid].bianji ? <el-button type="text" onClick={
@@ -735,14 +708,14 @@ export default {
 														row.settleNormId = ""
 														row.settleNum = ""
 														if (val) {
-															var data = this.otherListChuLi([], "orderChannelId", "orderChannelText").find(item => item.value == val)
+															var data = this.otherListChuLi(expandDataForm.otherList, "orderChannelId", "orderChannelText").find(item => item.value == val)
 															row.channelText = data.label
 														} else {
 															row.channelText = ""
 														}
 													}}
 													placeholder="请选择">
-													{this.otherListChuLi([], "orderChannelId", "orderChannelText").map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
+													{this.otherListChuLi(expandDataForm.otherList, "orderChannelId", "orderChannelText").map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
 												</el-select>
 											</el-form-item>
 										</div> : null
@@ -767,7 +740,7 @@ export default {
 														row.settleNum = ""
 													}}
 													placeholder="请选择">
-													{this.otherListChuLi([], "type", "typeName", (item) => item.orderChannelId == row.channelId).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
+													{this.otherListChuLi(expandDataForm.otherList, "type", "typeName", (item) => item.orderChannelId == row.channelId).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
 												</el-select>
 											</el-form-item>
 										</div> : null
@@ -788,7 +761,7 @@ export default {
 													onChange={(val) => {
 														row.settleNum = ""
 														if (val) {
-															var data = this.otherListChuLi([], "label", "label", (item) => { return item.orderChannelId == row.channelId && item.type == row.type }, "normAmount", "id").find(item => item.label == val)
+															var data = this.otherListChuLi(expandDataForm.otherList, "label", "label", (item) => { return item.orderChannelId == row.channelId && item.type == row.type }, "normAmount", "id").find(item => item.label == val)
 															row.normAmount = data.normAmount
 															row.settleNormId = data.id
 														} else {
@@ -797,7 +770,7 @@ export default {
 														}
 													}}
 													placeholder="请选择">
-													{this.otherListChuLi([], "label", "label", (item) => item.orderChannelId == row.channelId && item.type == row.type).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
+													{this.otherListChuLi(expandDataForm.otherList, "label", "label", (item) => item.orderChannelId == row.channelId && item.type == row.type).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
 												</el-select>
 											</el-form-item>
 										</div> : null
@@ -973,14 +946,9 @@ export default {
 											}>平分费用</el-button> : null}
 											{expandDataForm.otherNormList[row.pfuqinid].bianji ? <el-button type="text" onClick={
 												() => {
-													var item = expandDataForm.otherNormList[row.pfuqinid]
-													if ([0, 0, 0, ...item.workerList.map(val => Number(val.settleAmount))].reduce(function (prev, curr, idx, arr) {
-														return prev + curr;
-													}) == Number(item.settleAmount)) {
+													this.itemOrderBaseSettleNormReset(rowZhu, () => {
 														expandDataForm.otherNormList[row.pfuqinid].bianji = false
-													} else {
-														this.$message.warning(`其他费用信息-${item.channelText}-${item.type}-${item.label}:合计结算总金额与总金额不等`)
-													}
+													})
 												}
 											}>确定</el-button> : null}
 											{!expandDataForm.otherNormList[row.pfuqinid].bianji ? <el-button type="text" onClick={
@@ -1020,6 +988,97 @@ export default {
 			</div>) : null
 		},
 
+		itemOrderBaseSettleNormReset(data, cb) {
+			console.log(data, cb)
+			try {
+				data.expandData.normList.filter(item => !!item.id).map(item => {
+					if ([0, 0, 0, ...item.workerList.map(val => Number(val.settleAmount))].reduce(function (prev, curr, idx, arr) {
+						return prev + curr;
+					}) !== Number(item.settleAmount)) {
+						throw new Error(`费用信息-${item.channelText}-${item.parentCategoryName}-${item.categoryName}-${item.label}:合计结算总金额与总金额不等`);
+					}
+				})
+				data.expandData.otherNormList.filter(item => !!item.id).map(item => {
+					if ([0, 0, 0, ...item.workerList.map(val => Number(val.settleAmount))].reduce(function (prev, curr, idx, arr) {
+						return prev + curr;
+					}) !== Number(item.settleAmount)) {
+						throw new Error(`其他费用信息-${item.channelText}-${item.type}-${item.label}:合计结算总金额与总金额不等`);
+					}
+				})
+			} catch (err) {
+				this.$message.warning(err.message)
+				return
+			}
+			var { classifyList, gonglr, gonglv, otherList, ...pam } = data.expandData;
+
+			([orderBaseSettleNormConfirm, orderBaseSettleNormReset])[pam.settleStatus == 'YWG' ? 0 : 1]({
+				...pam,
+				normList: pam.normList.filter(item => !!item.id),
+				otherNormList: pam.otherNormList.filter(item => !!item.id),
+			}).then(res => {
+				orderBaseSettleNormDetail2({
+					id: data.id,
+					orderProductId: data.pgOrderProductId
+				}).then(res => {
+					this.zhuzhuang(res.data).then(res => {
+						data.expandData = res
+					})
+				})
+				cb && cb()
+				this.$message({
+					type: 'success',
+					message: '结算成功'
+				})
+			})
+		},
+
+		zhuzhuang(data) {
+			return new Promise((r, j) => {
+				var orderChannelId
+				var normList = []
+				var pfuqinid = 0
+				data.normList.map((item, index) => {
+					if (!orderChannelId) { orderChannelId = item.orderChannelId }
+					item.settleNum = item.settleNum || ""
+					normList.push({ ...item, pfuqinid: pfuqinid, zijideid: 0, bianji: data.settleStatus == 'YJS' ? false : true })
+					item.workerList.map((resdata, ind_) => {
+						if (ind_ !== 0) { normList.push({ pfuqinid: pfuqinid, zijideid: ind_ }) }
+						if (ind_ == item.workerList.length - 1) { pfuqinid += (ind_ + 1) }
+					})
+				})
+				var otherNormList = []
+				var qtpfuqinid = 0
+				data.otherNormList.map((item, index) => {
+					item.settleNum = item.settleNum || ""
+					otherNormList.push({ ...item, pfuqinid: qtpfuqinid, zijideid: 0, bianji: data.settleStatus == 'YJS' ? false : true })
+					item.workerList.map((resdata, ind_) => {
+						if (ind_ !== 0) { otherNormList.push({ pfuqinid: qtpfuqinid, zijideid: ind_ }) }
+						if (ind_ == item.workerList.length - 1) { qtpfuqinid += (ind_ + 1) }
+					})
+				})
+				Promise.all([
+					listPageV3({ "pageNum": 1, "pageSize": -1 }),
+					listPageV2Repair({ "pageNum": 1, "pageSize": -1 }),
+					settleNormInstallQuery({
+						settleNormType: data.orderType,
+						type: data.orderSmallType
+					}),
+					settleNormOtherQuery()
+				]).then(([res1, res2, res3, res4]) => {
+					r({
+						...data,
+						normList,
+						otherNormList,
+						gonglv: res1.data.records,
+						gonglr: res2.data.records,
+						classifyList: res3.data,
+						otherList: res4.data,
+					})
+
+				}).catch(j)
+			})
+		},
+
 		panfuan(item) {
 			if (!!item.id) {
 				return true