Browse Source

任务管理

ZaiZai 1 year ago
parent
commit
898bd07dce

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "value": "20231227144957"
+  "value": "20231227181809"
 }

+ 8 - 0
src/api/modules/tasks/hc-data.js

@@ -57,4 +57,12 @@ export default {
             data: form,
         }, false)
     },
+    //清单数据新增(添加清单)
+    async tableFormApplyTaskSave(form) {
+        return HcApi({
+            url: '/api/blade-meter/task/data/inventoryFormApplyTask/save',
+            method: 'post',
+            data: form,
+        }, false)
+    },
 }

+ 131 - 0
src/views/tasks/components/hc-data/addBillBase.vue

@@ -0,0 +1,131 @@
+<template>
+    <hc-new-dialog is-table widths="1200px" :show="isShow" title="添加分解清单" @save="modalSave" @close="modalClose">
+        <hc-table
+            :column="tableColumn" :datas="tableData" :loading="tableLoading"
+            is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
+            @selection-change="tableCheckChange"
+        />
+    </hc-new-dialog>
+</template>
+
+<script setup>
+import { ref, watch } from 'vue'
+import { arrToId, getArrValue } from 'js-fast-way'
+import middlepayApi from '~api/debit-pay/admin/middlepay'
+import mainApi from '~api/tasks/hc-data'
+
+const props = defineProps({
+    info: {
+        type: Object,
+        default: () => ({}),
+    },
+    table: {
+        type: Object,
+        default: () => ({}),
+    },
+    ids: {
+        type: [String, Number],
+        default: '',
+    },
+    contractId: {
+        type: [String, Number],
+        default: '',
+    },
+})
+
+//事件
+const emit = defineEmits(['finish', 'close'])
+
+const taskInfo = ref(props.info)
+const tableInfo = ref(props.table)
+const tableIds = ref(props.ids)
+const contractId = ref(props.contractId)
+
+//双向绑定
+// eslint-disable-next-line no-undef
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听
+watch(() => [
+    props.ids,
+    props.contractId,
+], ([ids, cid]) => {
+    tableIds.value = ids
+    contractId.value = cid
+}, { immediate: true, deep: true })
+
+//监听数据
+watch(() => [
+    props.table,
+    props.info,
+], ([table, row]) => {
+    tableInfo.value = table
+    taskInfo.value = row
+}, { deep: true })
+
+//监听
+watch(isShow, (val) => {
+    if (val) {
+        getTableData()
+    }
+})
+
+//表格数据
+const tableLoading = ref(false)
+const tableColumn = [
+    { key: 'formNumber', name: '清单编号' },
+    { key: 'formName', name: '清单名称' },
+    { key: 'currentPrice', name: '单价(元)' },
+    { key: 'contractTotal', name: '合同数量' },
+    { key: 'changeTotal', name: '合同变更后数量' },
+    { key: 'buildChangeTotal', name: '施工图变更后数量' },
+    { key: 'resolveResidueTotal', name: '分解剩余量' },
+]
+const tableData = ref([])
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const { contractPeriodId, contractUnitId } = tableInfo.value
+    const { data } = await middlepayApi.addFormList({
+        contractPeriodId: contractPeriodId,
+        contractId: contractId.value,
+        ids: tableIds.value,
+        nodeId: contractUnitId,
+    })
+    tableData.value = getArrValue(data)
+    tableLoading.value = false
+}
+
+//表格选择
+const checksData = ref([])
+const tableCheckChange = (data) => {
+    checksData.value = data
+}
+
+//确定保存
+const modalSave = async () => {
+    const rows = checksData.value
+    if (rows.length <= 0) {
+        window.$message.warning('请先选择清单')
+        return false
+    }
+    const rowIds = arrToId(rows)
+    /*const { contractPeriodId, contractUnitId } = tableInfo.value
+    const { data } = await mainApi.tableFormApplyTaskSave({
+        contractPeriodId: contractPeriodId.value,
+        contractId: cid.value,
+        nodeId: nodeId.value,
+        ids: rowIds,
+    })
+    emit('finish', getArrValue(data))*/
+    modalClose()
+}
+
+//取消关闭
+const modalClose = () => {
+    isShow.value = false
+    emit('close')
+}
+</script>

+ 45 - 12
src/views/tasks/components/hc-data/middlepay-form.vue

@@ -96,8 +96,8 @@
                 <template #allMeterTotal="{ row }">
                     <hc-table-input v-model="row.allMeterTotal" disabled />
                 </template>
-                <template #action="{ row }">
-                    <el-link type="danger" @click="delAddTableClick(row)">删除</el-link>
+                <template #action="{ row, index }">
+                    <el-link type="danger" @click="delAddTableClick(row, index)">删除</el-link>
                 </template>
             </hc-table>
         </hc-card-item>
@@ -113,22 +113,22 @@
             </el-form>
         </hc-card-item>
         <!-- 添加分解清单 -->
-        <HcBillBaseModal v-model="addBillBaseModalShow" :ids="billBaseIds" :idn="nodeId" :period-id="baseForm.contractPeriodId" :contract-id="cid" @finish="finishChange" />
+        <HcBillBase v-model="addBillBaseShow" :info="taskInfo" :table="tableInfo" :ids="billBaseIds" :contract-id="contractId" @finish="finishChange" />
         <!-- 文件上传组件 -->
         <hc-upload-file ref="uploadFileRef" :echo-params="uploadFileParams" :options="uploadFileOptions" @success="uploadFileSuccess" />
     </div>
 </template>
 
 <script setup>
-import { getArrValue, getObjVal, getObjValue, isNullES } from 'js-fast-way'
+import { arrToId, 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 HcBillBase from './addBillBase.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'
+import { delMessage, isNumberReg } from '~uti/tools'
 
 const props = defineProps({
     isEdit: {
@@ -258,6 +258,17 @@ const currentMeterTotalBlur = (row) => {
             meterMoney = (BigNumber(meterMoney).plus(table[i].currentMeterMoney)).toString()
         }
         baseForm.value.meterMoney = meterMoney
+
+        //计算是否超计
+        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) {
+            console.log('超计了')
+        } else {
+            meterTableUpdate(row)
+        }
     })
 }
 
@@ -270,21 +281,43 @@ const containChangeTotalBlur = (row) => {
     }
     nextTick(() => {
         row.containChangeTotal = val
+        meterTableUpdate(row)
     })
 }
 
-//删除清单
-const delAddTableClick = (row) => {
+//清单数据修改
+const meterTableUpdate = async (form) => {
+    const { error, msg, code } = await mainApi.tableUpdate(form)
+    if (!error && code === 200) {
+        window.$message.success('更新成功')
+    } else {
+        window.$message.error(msg ?? '更新失败')
+    }
+}
 
+//删除清单
+const delAddTableClick = (row, index) => {
+    delMessage(async () => {
+        const dataId = tableInfo.value.id
+        const { code, msg } = await mainApi.remove({
+            id: row.id,
+            dataId,
+        })
+        if (code === 200) {
+            window.$message.success('删除成功')
+            tableData.value.splice(index, 1)
+        } else {
+            window.$message.error(msg ?? '删除失败')
+        }
+    })
 }
 
 //添加计量清单
+const addBillBaseShow = ref(false)
 const billBaseIds = ref('')
-const nodeId = ref('')
-const cid = ref('')
-const addBillBaseModalShow = ref(false)
 const addBillModalClick = () => {
-
+    addBillBaseShow.value = true
+    billBaseIds.value = arrToId(tableData.value)
 }
 
 const finishChange = () => {