Browse Source

删除接口

duy 1 year ago
parent
commit
040b841bd2
1 changed files with 27 additions and 6 deletions
  1. 27 6
      src/views/base/policy.vue

+ 27 - 6
src/views/base/policy.vue

@@ -43,7 +43,7 @@
                 <el-button size="small" type="primary" @click="editRowClick(row)">
                     编辑
                 </el-button>
-                <el-button size="small" type="danger">
+                <el-button size="small" type="danger" @click="delClickRow(row)">
                     删除
                 </el-button>
             </template>
@@ -92,6 +92,7 @@ import policyApi from '~api/base/policy.js'
 import { useAppStore } from '~src/store'
 import { formValidate, getArrValue, getObjValue } from 'js-fast-way'
 import { getAllCounty } from '~api/other'
+import { delMessageV2 } from '~com/message/index.js'
 
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
@@ -210,8 +211,6 @@ const previewPdf = (row) => {
 }
 //编辑
 const editRowClick = (row) => {
-    // formModel.value = row
-    // filename.value=row.pdf
     getDetail(row.id)
     rowModal.value = true
 }
@@ -278,9 +277,6 @@ const formItemClick = async ({ item, index }) => {
 //文件变化
 const formItemChange = (src, index) => {
     formModel.value.list.splice(index, 1)
-  
-
-    // formModel.value.pdfUrl = src
 }
 //文件上传完成
 const UploadFileFinish = ()=>{
@@ -300,4 +296,29 @@ const HcUploadFileSuccess = ({ resData }) => {
     }
    
 }
+//删除
+const delClickRow = (row)=>{
+    delMessageV2(async (action, instance, done) => {
+        if (action === 'confirm') {
+            instance.confirmButtonLoading = true
+             removeRow(row.id)
+            instance.confirmButtonLoading = false
+            done()
+        } else {
+            done()
+        }
+ })
+}
+const removeRow = async (id)=>{
+    const { error, code } = await policyApi.remove({
+        id: id,
+    }, false)
+    //判断状态
+    if (!error && code === 200) {
+        window.$message?.success('删除成功')
+        getTableData()
+    } else {
+        window.$message?.error('删除失败')
+    }
+}
 </script>