瀏覽代碼

合同材料

ZaiZai 10 月之前
父節點
當前提交
e15034e48d
共有 1 個文件被更改,包括 54 次插入7 次删除
  1. 54 7
      src/views/debit-pay/material/components/material/dataModal.vue

+ 54 - 7
src/views/debit-pay/material/components/material/dataModal.vue

@@ -108,7 +108,7 @@
             <div v-if="tab_key === '材料明细'" class="table-body">
                 <hc-table :column="tableColumn1" :datas="tableData1" :index-style="{ width: 60 }" :loading="tableLoading1">
                     <template #changeTotal="{ row }">
-                        <el-input v-model="row.changeTotal" />
+                        <el-input v-model="row.changeTotal" @blur="changeTotalBlur(row)" />
                     </template>
                 </hc-table>
             </div>
@@ -118,9 +118,9 @@
                 </div>
                 <div class="table-upload">
                     <hc-table :column="tableColumn2" :datas="tableData2" :index-style="{ width: 60 }" :loading="tableLoading2">
-                        <template #action="{ row }">
-                            <el-link type="primary">预览</el-link>
-                            <el-link type="danger">删除</el-link>
+                        <template #action="{ row, index }">
+                            <el-link type="primary" @click="previewFile(row)">预览</el-link>
+                            <el-link type="danger" @click="delFile(index)">删除</el-link>
                         </template>
                     </hc-table>
                 </div>
@@ -164,7 +164,7 @@ import { ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { isNumberReg } from '~uti/tools'
 import mainApi from '~api/debit-pay/material/material'
-import { formValidate, getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import { formValidate, getArrValue, getObjValue, isNullES, newWindow } from 'js-fast-way'
 
 const props = defineProps({
     ids: {
@@ -386,6 +386,18 @@ const getMaterialDetail = async () => {
     }
 }
 
+//可调量失去焦点
+const changeTotalBlur = (row) => {
+    const { meterTotal, changeTotal } = row
+    if (!isNumberReg(changeTotal)) {
+        row.changeTotal = meterTotal
+        window.$message.warning('请输入正确的可调量')
+    } else if (changeTotal > meterTotal) {
+        row.changeTotal = meterTotal
+        window.$message.warning('只能小于等于计量数量')
+    }
+}
+
 //上传附件
 const tableColumn2 = [
     { key: 'fileName', name: '文件名称' },
@@ -438,14 +450,49 @@ const attachmentClose = () => {
     formUploadFile.value = []
 }
 
+//预览附件
+const previewFile = ({ fileUrl }) => {
+    if (isNullES(fileUrl)) {
+        window.$message.warning('此文件已不存在,请删除后,重新上传')
+        return
+    }
+    newWindow(fileUrl)
+}
+
+//预览附件
+const delFile = (index) => {
+    tableData2.value.splice(index, 1)
+}
 
 //保存
 const saveLoaing = ref(false)
 const modalSave = async () => {
     const isForm = await formValidate(formRef.value)
     if (!isForm) return
-    modalClose()
-    emit('finish')
+    const form = formModel.value
+    form.details = tableData1.value
+    form.files = tableData2.value
+    form.projectId = projectId.value
+    form.contractId = contractId.value
+    if (isNullES(form.id)) {//新增
+        const { code, msg } = mainApi.add(form)
+        if (code === 200) {
+            window.$message.success('保存成功')
+            modalClose()
+            emit('finish')
+        } else {
+            window.$message.error(msg ?? '保存失败')
+        }
+    } else {
+        const { code, msg } = mainApi.update(form)
+        if (code === 200) {
+            window.$message.success('保存成功')
+            modalClose()
+            emit('finish')
+        } else {
+            window.$message.error(msg ?? '保存失败')
+        }
+    }
 }
 
 //关闭弹窗