duy 1 éve
szülő
commit
64e1521757

+ 14 - 6
src/api/modules/project/project.js

@@ -44,10 +44,18 @@ export default {
     },
     //修改项目完成情况
     async updateProFin(form) {
-    return HcApi({
-        url: '/api/blade-attach/project/update-project-finished',
-        method: 'post',
-        data: form,
-    }, false)
-},
+        return HcApi({
+            url: '/api/blade-attach/project/update-project-finished',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    //删除
+    async del(ids) {
+        return HcApi({
+            url: '/api/blade-attach/project/remove',
+            method: 'post',
+            params: { ids },
+        }, false)
+    },
 }

+ 13 - 5
src/views/project/admin/list.vue

@@ -31,7 +31,7 @@
             <el-button type="warning" class="ml-2" @click="importClick">导入</el-button>
             <el-button v-yes-com:[deriveTableItem] type="primary" class="ml-2" :disabled="tableCheckKeys.length <= 0">批量导出</el-button>
         </template>
-        <HcTableList ref="tableRef" is-admin :datas="tableData" @tap="rowNameClick" @check="tableCheck" />
+        <HcTableList ref="tableRef" is-admin :datas="tableData" @tap="rowNameClick" @check="tableCheck" @change="searchClick" />
         <template #action>
             <div>建设规模:共计 xx 公里</div>
             <hc-pages :pages="searchForm" @change="pageChange" />
@@ -88,7 +88,7 @@
 <script setup>
 import { onMounted, ref } from 'vue'
 import HcTableList from '../modules/project-list.vue'
-import { getArrValue } from 'js-fast-way'
+import { arrToId, getArrValue } from 'js-fast-way'
 import mainApi from '~api/project/project'
 import { getDictionaryData } from '~src/utils/tools'
 
@@ -160,9 +160,17 @@ const rowNameClick = (row) => {
 }
 
 //批量删除
-const delTableItem = (_, resolve) => {
-    tableRef.value?.batchRemove()
-    resolve()
+//批量删除
+const delTableItem = async (_, resolve) => {
+    const ids = arrToId(tableCheckKeys.value)
+    const { error, code, msg } = await mainApi.del(ids)
+    if (!error && code === 200) {
+        window.$message.success('删除成功')
+        resolve()
+        searchClick()
+    } else {
+        window.$message.error(msg ?? '删除失败')
+    }
 }
 
 //批量导出

+ 9 - 7
src/views/project/modules/project-list.vue

@@ -260,7 +260,7 @@ const props = defineProps({
 })
 
 //事件
-const emit = defineEmits(['tap', 'completion', 'examine', 'del', 'export', 'check'])
+const emit = defineEmits(['tap', 'completion', 'examine', 'del', 'export', 'check', 'change'])
 
 //监听权限
 const isAdminAuth = ref(props.isAdmin)
@@ -357,13 +357,15 @@ const getDetailData = async (id) => {
 
 }
 //删除
-const delTableItem = ({ item }, resolve) => {
-    console.log('我被执行了', item)
-    //这里可以写一些操作,下面是模拟3秒关闭
-    setTimeout(() => {
+const delTableItem = async ({ item }, resolve) => {
+    const { error, code, msg } = await mainApi.del(item.id)
+    if (!error && code === 200) {
+        window.$message.success('删除成功')
         resolve()
-        emit('del', item)
-    }, 3000)
+        emit('change')
+    } else {
+        window.$message.error(msg ?? '删除失败')
+    }
 }
 //关闭抽屉
 const drawerCancel = () => {