Browse Source

政策法规接口

duy 1 year ago
parent
commit
a59a1b1e61
1 changed files with 26 additions and 11 deletions
  1. 26 11
      src/views/base/policy.vue

+ 26 - 11
src/views/base/policy.vue

@@ -30,12 +30,12 @@
                 <HcIcon name="add" />
                 <span>新增</span>
             </el-button>
-            <el-button size="large" type="danger" hc-btn>
+            <el-button size="large" type="danger" hc-btn @click="batchClick">
                 <HcIcon name="delete-bin" />
                 <span>删除</span>
             </el-button>
         </template>
-        <HcTable :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check @selection-change="tableSelectionChange">
+        <HcTable ref="tableListRef" :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check @selection-change="tableSelectionChange">
             <template #action="{ row, index }">
                 <el-button size="small" type="warning" @click="previewPdf(row)">
                     查看附件
@@ -90,7 +90,7 @@ import { onActivated, onMounted, ref } from 'vue'
 import { getTokenHeader } from '~src/api/request/header'
 import policyApi from '~api/base/policy.js'
 import { useAppStore } from '~src/store'
-import { formValidate, getArrValue, getObjValue } from 'js-fast-way'
+import { arrToId, formValidate, getArrValue, getObjValue } from 'js-fast-way'
 import { getAllCounty } from '~api/other'
 import { delMessageV2 } from '~com/message/index.js'
 
@@ -174,11 +174,14 @@ const getTableData = async () => {
     }
 }
 
-//多选事件
+//多选
+const tableListRef = ref(null)
+const tableCheckedKeys = ref([])
 const tableSelectionChange = (rows) => {
-    console.log(rows)
+    tableCheckedKeys.value = rows.filter((item) => {
+        return (item ?? '') !== ''
+    })
 }
-
 //弹窗
 const rowModal = ref(false)
 const formRef = ref(null)
@@ -285,7 +288,6 @@ const UploadFileFinish = ()=>{
 const filename = ref('')
 // 文件上传成功的回调
 const HcUploadFileSuccess = ({ resData }) => {
-    console.log(resData, 'resData')
     formModel.value.list.push(resData)
     const { name } = resData
     if (filename.value) {
@@ -301,7 +303,7 @@ const delClickRow = (row)=>{
     delMessageV2(async (action, instance, done) => {
         if (action === 'confirm') {
             instance.confirmButtonLoading = true
-             removeRow(row.id)
+             removeRow([row.id])
             instance.confirmButtonLoading = false
             done()
         } else {
@@ -310,9 +312,7 @@ const delClickRow = (row)=>{
  })
 }
 const removeRow = async (id)=>{
-    const { error, code } = await policyApi.remove({
-        id: id,
-    }, false)
+    const { error, code } = await policyApi.remove( id, false)
     //判断状态
     if (!error && code === 200) {
         window.$message?.success('删除成功')
@@ -321,4 +321,19 @@ const removeRow = async (id)=>{
         window.$message?.error('删除失败')
     }
 }
+
+const batchClick = ()=>{
+    const rows = tableCheckedKeys.value
+    const ids = arrToId(rows).split(',')
+    delMessageV2(async (action, instance, done) => {
+        if (action === 'confirm') {
+            instance.confirmButtonLoading = true
+             removeRow(ids)
+            instance.confirmButtonLoading = false
+            done()
+        } else {
+            done()
+        }
+ })
+}
 </script>