Pārlūkot izejas kodu

新增删除功能

gongtianxiao 1 mēnesi atpakaļ
vecāks
revīzija
d222cd0900
1 mainītis faili ar 33 papildinājumiem un 11 dzēšanām
  1. 33 11
      src/components/manage/asset/PickAssetModal.vue

+ 33 - 11
src/components/manage/asset/PickAssetModal.vue

@@ -10,7 +10,7 @@
             <input
               v-model="keyword"
               type="search"
-              placeholder="企业 / 编号"
+              placeholder="编号 / 地址"
             />
           </label>
         </div>
@@ -28,7 +28,8 @@
               <span style="width: 140px">编号</span>
               <span style="width: 120px">集团</span>
               <span style="width: 180px">名称</span>
-              <span style="width: 140px">建筑面积㎡</span>
+              <span style="width: 140px">坐落具体地址</span>
+              <span style="width: 140px">操作</span>
             </div>
             <div v-if="loading" class="pick-modal__empty">加载中…</div>
             <div v-else-if="displayRows.length === 0" class="pick-modal__empty">暂无匹配资产</div>
@@ -49,7 +50,10 @@
               <span style="width: 140px">{{ row.code }}</span>
               <span style="width: 120px">{{ row.group }}</span>
               <span style="width: 180px">{{ row.name }}</span>
-              <span style="width: 140px">{{ row.buildArea }}</span>
+              <span style="width: 140px">{{ row.address }}</span>
+              <span style="width: 140px">
+                <BaseButton text="删除" variant="danger" @click="handleDelete(row)" />
+              </span>
             </div>
           </div>
         </div>
@@ -64,12 +68,13 @@
 </template>
 
 <script setup>
-import { showWarning } from '@/utils/message';
-import { computed, ref, watch } from 'vue';
+import { showConfirm, showError, showSuccess, showWarning } from '@/utils/message';
+import { computed, ref, watch, defineProps, defineEmits } from 'vue';
 import BaseButton from '@/components/base/BaseButton.vue';
 import { useEnterpriseStore, REPORT_STATE } from '@/store/enterprise';
 import { assetBelongsToManageScope } from '@/utils/manageContext';
-import { defineProps, defineEmits } from 'vue';
+import { updateAudit } from '@/api/enterpriseList';
+import { COLUMN_ID } from '@/config';
 
 const props = defineProps({
   visible: {
@@ -113,13 +118,11 @@ const pickableList = computed(() => {
   return list;
 });
 
-const formatArea = (val) => Number(val || 0).toLocaleString('zh-CN');
-
 const normalizeCode = (raw) => String(raw ?? '').trim().toLowerCase();
 
 const matchKeyword = (item, kw) => {
   const code = normalizeCode(item.c_bh);
-  const enterprise = String(item.c_qymc ?? item.c_ssjt ?? '').trim().toLowerCase();
+  const address = String(item.c_zljtdz ?? '').trim().toLowerCase();
 
   if (/^\d+$/.test(kw)) {
     if (kw.length === 6) {
@@ -128,7 +131,7 @@ const matchKeyword = (item, kw) => {
     return code.startsWith(kw);
   }
 
-  return code.includes(kw) || enterprise.includes(kw);
+  return code.includes(kw) || address.includes(kw);
 };
 
 const scopedList = computed(() =>
@@ -152,7 +155,7 @@ const displayRows = computed(() => {
         code: item.c_bh || '暂无',
         group: (item.c_ssjt ?? '').trim() || '暂无',
         name: item.c_qymc || '暂无',
-        buildArea: formatArea(item.c_sjjzmj),
+        address: item.c_zljtdz || '暂无',
         raw: item,
         inQueue: props.excludeIds.includes(rowKey),
       };
@@ -182,6 +185,25 @@ const toggleSelectAll = (event) => {
   }
 };
 
+const handleDelete = async (row) => {
+  const confirmed = await showConfirm('确定删除该资产吗?');
+  if (!confirmed) return;
+  try {
+    await updateAudit({
+      id: row.raw.id,
+      columnId: COLUMN_ID,
+      state: 4,
+    });
+    showSuccess('资产已删除');
+    await Promise.all([
+      enterpriseStore.fetchList(true),
+      enterpriseStore.fetchByState(REPORT_STATE.REJECTED, { force: true }),
+    ]);
+  } catch (e) {
+    showError(e?.message || e?.msg || '删除失败,请稍后重试');
+  }
+};
+
 const handleCancel = () => {
   emit('update:visible', false);
 };