|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="hc-task-form">
|
|
|
+ <div v-loading="isLoading" class="hc-task-form">
|
|
|
<!-- 基础表单 -->
|
|
|
<hc-card-item>
|
|
|
<el-form ref="baseFormRef" :model="baseForm" :rules="baseFormRules" label-position="left" label-width="auto">
|
|
@@ -96,8 +96,8 @@
|
|
|
<template #allMeterTotal="{ row }">
|
|
|
<hc-table-input v-model="row.allMeterTotal" disabled />
|
|
|
</template>
|
|
|
- <template #action="{ index }">
|
|
|
- <el-link type="danger" @click="delAddTableClick(index)">删除</el-link>
|
|
|
+ <template #action="{ row }">
|
|
|
+ <el-link type="danger" @click="delAddTableClick(row)">删除</el-link>
|
|
|
</template>
|
|
|
</hc-table>
|
|
|
</hc-card-item>
|
|
@@ -120,23 +120,28 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { getArrValue } from 'js-fast-way'
|
|
|
-import { onMounted, ref, watch } from 'vue'
|
|
|
+import { getArrValue, getObjVal, getObjValue, isNullES } from 'js-fast-way'
|
|
|
+import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import HcBillBaseModal from '~src/views/debit-pay/admin/components/middlepay/addBillBaseModal.vue'
|
|
|
import middlepayApi from '~api/debit-pay/admin/middlepay'
|
|
|
import mainApi from '~api/tasks/hc-data'
|
|
|
import BigNumber from 'bignumber.js'
|
|
|
import { getHeader } from 'hc-vue3-ui'
|
|
|
+import { isNumberReg } from '~uti/tools'
|
|
|
|
|
|
const props = defineProps({
|
|
|
isEdit: {
|
|
|
type: Boolean,
|
|
|
default: true,
|
|
|
},
|
|
|
- type: {
|
|
|
- type: [String, Number],
|
|
|
- default: '',
|
|
|
+ info: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
+ table: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
},
|
|
|
})
|
|
|
|
|
@@ -144,41 +149,35 @@ const useAppState = useAppStore()
|
|
|
const projectId = ref(useAppState.getProjectId || '')
|
|
|
const contractId = ref(useAppState.getContractId || '')
|
|
|
|
|
|
-//双向绑定
|
|
|
-// eslint-disable-next-line no-undef
|
|
|
-const rowInfo = defineModel('modelValue', {
|
|
|
- default: () => ({}),
|
|
|
-})
|
|
|
-
|
|
|
//监听可否编辑
|
|
|
const isEdits = ref(props.isEdit)
|
|
|
watch(() => props.isEdit, (val) => {
|
|
|
isEdits.value = val
|
|
|
}, { immediate: true, deep: true })
|
|
|
|
|
|
-//监听类型
|
|
|
-const isType = ref(props.type)
|
|
|
-watch(() => props.type, (val) => {
|
|
|
- isType.value = val
|
|
|
-}, { immediate: true, deep: true })
|
|
|
-
|
|
|
//监听数据
|
|
|
-watch(() => rowInfo, (val) => {
|
|
|
- setTaskInfo(val.value)
|
|
|
+watch(() => [
|
|
|
+ props.table,
|
|
|
+ props.info,
|
|
|
+], ([table, row]) => {
|
|
|
+ setTaskInfo(table, row)
|
|
|
}, { deep: true })
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(() => {
|
|
|
- setTaskInfo(rowInfo.value)
|
|
|
+ setTaskInfo(props.table, props.info)
|
|
|
})
|
|
|
|
|
|
//设置任务信息
|
|
|
const taskInfo = ref({})
|
|
|
-const setTaskInfo = (info) => {
|
|
|
- taskInfo.value = info
|
|
|
- console.log(info)
|
|
|
- getAllPeriod()
|
|
|
- getDataDetail()
|
|
|
+const tableInfo = ref({})
|
|
|
+const setTaskInfo = (table, row) => {
|
|
|
+ tableInfo.value = table
|
|
|
+ taskInfo.value = row
|
|
|
+ if (getObjVal(table) && getObjVal(row)) {
|
|
|
+ getAllPeriod()
|
|
|
+ getDataDetail()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//获取合同计量期列表
|
|
@@ -193,11 +192,16 @@ const getAllPeriod = async () => {
|
|
|
}
|
|
|
|
|
|
//获取任务数据信息详情
|
|
|
+const isLoading = ref(false)
|
|
|
const getDataDetail = async () => {
|
|
|
const id = taskInfo.value.id
|
|
|
- /*const { data } = await mainApi.getDetail({
|
|
|
- id: id
|
|
|
- })*/
|
|
|
+ const dataId = tableInfo.value.id
|
|
|
+ const { data } = await mainApi.getDataDetail({ id, dataId })
|
|
|
+ //转换数据
|
|
|
+ const { associatedDataInfoList, attachmentFormTask, basicsInfo } = getObjValue(data)
|
|
|
+ tableData.value = getArrValue(associatedDataInfoList) //清单列表
|
|
|
+ baseForm.value = getObjValue(basicsInfo) //表单信息
|
|
|
+ baseForm.value.fileList = getArrValue(attachmentFormTask) //附件列表
|
|
|
}
|
|
|
|
|
|
//基础表单
|
|
@@ -221,20 +225,56 @@ const tableColumn = ref([
|
|
|
const tableData = ref([])
|
|
|
|
|
|
//清单样式
|
|
|
-const tableRowStyle = () => {
|
|
|
-
|
|
|
+const isCanSave = ref(false)
|
|
|
+const tableRowStyle = ({ row }) => {
|
|
|
+ let allMeterTotal = new BigNumber(row.allMeterTotal) //a 累计计量量
|
|
|
+ let changeTotal = new BigNumber(row.changeTotal) //b 变更后数量
|
|
|
+ //a 大于 b = 1,a 等于 b = 0,a 小于 b = -1, a 或 b 的值异常时 = null
|
|
|
+ const isCompared = allMeterTotal.comparedTo(changeTotal)
|
|
|
+ if (isCompared === 1 || isCompared === null) {
|
|
|
+ isCanSave.value = true
|
|
|
+ return '--el-table-tr-bg-color: #fe0000; --el-table-row-hover-bg-color: #fe0000; color: white;'
|
|
|
+ } else {
|
|
|
+ isCanSave.value = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+//计算本期计量金额
|
|
|
const currentMeterTotalBlur = (row) => {
|
|
|
-
|
|
|
+//如果为空
|
|
|
+ let currentMeterTotal = row.currentMeterTotal
|
|
|
+ const isMeter = isNumberReg(currentMeterTotal)
|
|
|
+ if (isNullES(currentMeterTotal) || !isMeter) {
|
|
|
+ currentMeterTotal = 0
|
|
|
+ }
|
|
|
+ //计算本期计量金额
|
|
|
+ nextTick(() => {
|
|
|
+ row.currentMeterTotal = currentMeterTotal
|
|
|
+ row.currentMeterMoney = (BigNumber(currentMeterTotal).multipliedBy(row.currentPrice)).toString()
|
|
|
+ row.allMeterTotal = (BigNumber(currentMeterTotal).plus(row.otherMeterTotal)).toString()
|
|
|
+ //计算总计量金额
|
|
|
+ let meterMoney = 0, table = tableData.value
|
|
|
+ for (let i = 0; i < table.length; i++) {
|
|
|
+ meterMoney = (BigNumber(meterMoney).plus(table[i].currentMeterMoney)).toString()
|
|
|
+ }
|
|
|
+ baseForm.value.meterMoney = meterMoney
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
+//计算含变更数量
|
|
|
const containChangeTotalBlur = (row) => {
|
|
|
-
|
|
|
+ let val = row.containChangeTotal
|
|
|
+ const isMeter = isNumberReg(val)
|
|
|
+ if (isNullES(val) || !isMeter) {
|
|
|
+ val = 0
|
|
|
+ }
|
|
|
+ nextTick(() => {
|
|
|
+ row.containChangeTotal = val
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//删除清单
|
|
|
-const delAddTableClick = (index) => {
|
|
|
+const delAddTableClick = (row) => {
|
|
|
|
|
|
}
|
|
|
|