Browse Source

变更令

ZaiZai 1 year ago
parent
commit
ea79b80268
1 changed files with 80 additions and 19 deletions
  1. 80 19
      src/views/alter/admin/components/order/addModal.vue

+ 80 - 19
src/views/alter/admin/components/order/addModal.vue

@@ -119,8 +119,8 @@
                                 <el-table-column label="数量" align="center">
                                 <el-table-column label="数量" align="center">
                                     <el-table-column prop="contractTotal" label="变更前" />
                                     <el-table-column prop="contractTotal" label="变更前" />
                                     <el-table-column prop="currentChangeTotal" label="变更增减">
                                     <el-table-column prop="currentChangeTotal" label="变更增减">
-                                        <template #default="scope">
-                                            <hc-table-input v-model="scope.row.currentChangeTotal" />
+                                        <template #default="{ row }">
+                                            <hc-table-input v-model="row.currentChangeTotal" @blur="currentChangeTotalBlur($event, row)" />
                                         </template>
                                         </template>
                                     </el-table-column>
                                     </el-table-column>
                                     <el-table-column prop="changeTotal" label="变更后" />
                                     <el-table-column prop="changeTotal" label="变更后" />
@@ -138,13 +138,16 @@
                             </el-table>
                             </el-table>
                         </div>
                         </div>
                     </hc-card-item>
                     </hc-card-item>
+                    <!-- 附件列表 -->
                     <hc-card-item class="mt-3" title="附件列表">
                     <hc-card-item class="mt-3" title="附件列表">
-                        <hc-table is-new :column="tableColumn2" :datas="tableData2">
-                            <template #action="{ row }">
-                                <el-link type="primary">选择文件</el-link>
-                                <el-link type="danger">清除</el-link>
-                            </template>
-                        </hc-table>
+                        <template #extra>
+                            <span class="text-orange font-400">可上传 图片(png、jpg、jpeg)、Excel(xls、xlsx)、PDF、Word(doc、docx)文件</span>
+                        </template>
+                        <el-form :model="baseForm" label-position="left" label-width="auto">
+                            <el-form-item label="上传附件">
+                                <hc-form-upload type="list" :src="baseForm.fileList" :h-props="uploadFormProps" @upload="attachmentUpload" @change="attachmentUploadChange" />
+                            </el-form-item>
+                        </el-form>
                     </hc-card-item>
                     </hc-card-item>
                 </el-scrollbar>
                 </el-scrollbar>
             </div>
             </div>
@@ -152,6 +155,9 @@
 
 
         <!-- 变更申请清单 -->
         <!-- 变更申请清单 -->
         <ChangeRequest v-model="isChangeShow" :ids="changeIds" :tree-id="changeNodeItem.id" :contract-id="contractId" @finish="changeNodeFinish" />
         <ChangeRequest v-model="isChangeShow" :ids="changeIds" :tree-id="changeNodeItem.id" :contract-id="contractId" @finish="changeNodeFinish" />
+
+        <!-- 文件上传组件 -->
+        <hc-upload-file ref="uploadFileRef" :options="uploadFileOptions" @success="uploadFileSuccess" />
     </hc-new-dialog>
     </hc-new-dialog>
 </template>
 </template>
 
 
@@ -159,10 +165,12 @@
 import { nextTick, ref, watch } from 'vue'
 import { nextTick, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { useAppStore } from '~src/store'
 import { getDictionaryData } from '~uti/tools'
 import { getDictionaryData } from '~uti/tools'
-import { arrToKey, getArrValue, getObjValue, isArray, isNullES } from 'js-fast-way'
+import { arrToKey, deepClone, getArrValue, getObjValue, isArray, isNullES } from 'js-fast-way'
 import ChangeRequest from './changeRequest.vue'
 import ChangeRequest from './changeRequest.vue'
 import unitApi from '~api/project/debit/contract/unit'
 import unitApi from '~api/project/debit/contract/unit'
 import mainApi from '~api/alter/admin/order'
 import mainApi from '~api/alter/admin/order'
+import { getHeader } from 'hc-vue3-ui'
+import BigNumber from 'bignumber.js'
 
 
 const props = defineProps({
 const props = defineProps({
     ids: {
     ids: {
@@ -327,6 +335,7 @@ const rowChangeNodeClick = ({ row, index }) => {
 //删除变更申请清单
 //删除变更申请清单
 const tableFormListDel = (index) => {
 const tableFormListDel = (index) => {
     tableData.value[tableIndex.value].formList.splice(index, 1)
     tableData.value[tableIndex.value].formList.splice(index, 1)
+    getFormList()
 }
 }
 
 
 //变更清单的添加弹窗
 //变更清单的添加弹窗
@@ -344,18 +353,70 @@ const changeShowClick = () => {
 //确认选择完成
 //确认选择完成
 const changeNodeFinish = (data) => {
 const changeNodeFinish = (data) => {
     tableData.value[tableIndex.value].formList.push(...data)
     tableData.value[tableIndex.value].formList.push(...data)
+    getFormList()
 }
 }
 
 
-//附件列表
-const tableColumn2 = ref([
-    { key: 'key1', name: '文件名称', width: 200 },
-    { key: 'key2', name: '必须上传', width: 100 },
-    { key: 'key3', name: '附件列表' },
-    { key: 'action', name: '操作', width: 120 },
-])
-const tableData2 = ref([
-    { key1: '工程设计变更申请单', key2: '是', key3: '文件名称' },
-])
+//变更清单增减
+const currentChangeTotalBlur = (event, row) => {
+    //计算数量
+    const changeNum = (BigNumber(row.contractTotal).plus(row.currentChangeTotal)).toNumber()
+    if (changeNum < 0) {
+        window.$message.warning('变更增减数量不能小于变更前数量')
+        row.currentChangeTotal = '-' + row.contractTotal
+    }
+    row.changeTotal = changeNum
+
+    //计算金额
+    row.currentChangeMoney = (BigNumber(row.currentChangeTotal).multipliedBy(row.currentPrice)).toNumber()
+    row.changeMoney = (BigNumber(changeNum).multipliedBy(row.currentPrice)).toNumber()
+    getFormList()
+}
+
+//获取变更清单总额
+const getFormList = () => {
+    let total = 0, table = deepClone(tableData.value)
+    for (let i = 0; i < table.length; i++) {
+        const item = table[i]
+        for (let j = 0; j < item.formList.length; j++) {
+            const form = item.formList[j]
+            total = (BigNumber(total).plus(form.currentChangeMoney)).toNumber()
+        }
+    }
+    tableData.value = []
+    tableData.value = table
+}
+
+
+//附件上传
+const uploadFormProps = {
+    url: 'fileUrl',
+    name: 'fileName',
+}
+
+const attachmentUpload = () => {
+    uploadFileRef.value?.selectFile()
+}
+const attachmentUploadChange = (a, b, fileList) => {
+    baseForm.value.fileList = getArrValue(fileList)
+}
+
+//文件上传
+const uploadFileRef = ref(null)
+const uploadFileOptions = ref({
+    headers: getHeader(),
+    multiple: false,
+})
+
+// 文件上传成功的回调
+const uploadFileSuccess = ({ resData }) => {
+    baseForm.value.fileList.push({
+        contractId: contractId.value,
+        fileName: resData.originalName ?? '',
+        filePdfUrl: resData.pdfUrl ?? '',
+        fileUrl: resData.link ?? '',
+    })
+    uploadFileRef.value?.setModalShow(false)
+}
 
 
 
 
 //保存
 //保存