zhuoyuan.wang
2024-06-19 15ebe96f28cadec6a726c5324593a40bbf56205f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<template>
  <app-layout-row>
    <app-layout-col :span="24">
      <app-table-search
        v-bind="searchProps"
      />
    </app-layout-col>
    <app-layout-col :span="24" :top="10">
      <app-table-pro v-bind="tableProps">
        <template #table-name="scope">
          <el-link type="primary" @click="onOpenTab(scope.row)">{{ scope.row.name }}</el-link>
        </template>
      </app-table-pro>
    </app-layout-col>
  </app-layout-row>
</template>
 
<script setup>
 
import {useI18n} from 'vue-i18n';
import {modal} from '@/plugins';
 
const {t} = useI18n();
 
import {meta} from "@/hooks";
 
const {useMetaData} = meta;
 
import {dataFilter} from '@/utils/filter.js';
import {useEntityStore} from '@/store/modules';
import {openTab, openJiminTab} from "@/utils/iframe.js";
import {uuid} from "@/utils/tools.js";
 
const props = defineProps({
  subCurrent: {
    type: Function,
    default: () => {
    }
  }
});
 
const tableSearchRef = ref();
const tableProRef = ref();
const entityStore = useEntityStore();
 
const [columns, filters, fields] = useMetaData(
  'affiche',
  async () => {
    tableProps.columns = columns;
    searchProps.formFields = filters;
 
    tableProRef.value.$forceUpdate(tableProps);
    tableSearchRef.value.$forceUpdate(searchProps);
 
    tableProRef.value.getTableData(true);
  }
);
 
const tableProps = {
  ref: tableProRef,
  requestParams: {
    search: {}
  },
  complementHeight: 80,
  subRequest: async (page) => {
    page.orderBy = page.orderBy || 'update_time desc';
    const {search} = tableProps.requestParams;
    const result = await entityStore.getEntitySet({
      dataName: "affiche",
      filter: dataFilter(search, filters),
      ...page
    });
 
    return result;
  },
  subCurrent(row) {
    props.subCurrent(row);
  },
  title: t('views.system.systemNotice.IndexPage.title'),
  columns: []
};
 
const searchProps = {
  ref: tableSearchRef,
  formFields: [],
  subSubmit: (params) => {
    tableProps.requestParams.search = params;
    tableProRef.value.getTableData(true);
  }
}
 
const onDelete = async (row) => {
  await modal.confirm("是否确认删除?");
 
  await entityStore.deleteEntity({
    dataName: 'affiche',
    id: row.id
  });
  tableProRef.value.getTableData(false);
};
 
const onTabForm = async (row) => {
  await openTab({
      icon: 'icon-product',
      id: uuid(),
      sceneCode: "edit",
      text: "公告配置",
      title: "公告编辑",
      path: '/system/systemNotice',
      params: {view: 'form', ...(row.id ? {id: row.id} : {})}
    }
  );
  tableProRef.value.getTableData(false);
}
 
 
const onOpenDetail = async (row) => {
  await openTab({
      icon: 'icon-product',
      id: uuid(),
      sceneCode: "edit",
      text: "公告详情",
      title: "公告详情",
      path: '/system/systemNotice',
      params: {view: 'detail', ...(row.id ? {id: row.id} : {})}
    }
  );
  tableProRef.value.getTableData(false);
}
 
defineExpose({
  onDelete,
  onTabForm,
  onOpenDetail
});
 
</script>