yyb
2026-05-22 552ec6b7d8ccc56c379da195fc6c9c74312b1070
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<template>
  <view class="oa-page sales-account">
    <PageHeader :title="pageConfig.title"
                @back="goBack" />
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input v-model="keyword"
                    class="search-text"
                    :placeholder="`搜索${pageConfig.title}`"
                    clearable
                    @change="handleSearch" />
        </view>
        <view class="filter-button"
              @click="handleSearch">
          <up-icon name="search"
                   size="24"
                   color="#999" />
        </view>
      </view>
    </view>
 
    <scroll-view class="list-scroll"
                 scroll-y
                 :show-scrollbar="false">
      <view v-if="displayList.length"
            class="ledger-list">
        <view v-for="item in displayList"
              :key="item.id"
              class="ledger-item"
              @click="openDetail(item)">
          <view class="item-header">
            <view class="item-left">
              <view class="document-icon">
                <up-icon name="file-text"
                         size="16"
                         color="#ffffff" />
              </view>
              <text class="item-id">{{ item.summary || item.applicantName || pageConfig.title }}</text>
            </view>
            <u-tag :type="getStatusMeta(item.status).type"
                   :text="getStatusMeta(item.status).text" />
          </view>
          <up-divider />
          <view class="item-details">
            <view v-for="field in pageConfig.fields"
                  :key="field.prop"
                  class="detail-row">
              <text class="detail-label">{{ field.label }}</text>
              <text class="detail-value">{{ item[field.prop] || "-" }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">申请人</text>
              <text class="detail-value">{{ item.applicantName || "-" }}</text>
            </view>
            <view class="detail-row">
              <text class="detail-label">申请时间</text>
              <text class="detail-value">{{ item.createTime || "-" }}</text>
            </view>
          </view>
        </view>
      </view>
      <view v-else
            class="empty-wrap">
        <up-empty mode="list"
                  :text="`暂无${pageConfig.title}数据`" />
      </view>
    </scroll-view>
 
    <view class="footer-add">
      <up-button type="primary"
                 text="新增"
                 @click="handleAdd" />
    </view>
  </view>
</template>
 
<script setup>
  import { computed, ref } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import { ensureList, saveList } from "../_utils/oaStorage.js";
  import { getStatusMeta } from "../_utils/oaPageRegistry.js";
  import { showToast } from "../_utils/oaUi.js";
 
  const props = defineProps({
    pageKey: {
      type: String,
      required: true,
    },
    pageConfig: {
      type: Object,
      required: true,
    },
  });
 
  const keyword = ref("");
  const list = ref([]);
 
  const displayList = computed(() => {
    const kw = keyword.value.trim();
    if (!kw) return list.value;
    return list.value.filter(item => {
      const text = [
        item.summary,
        item.applicantName,
        item.deptName,
        ...props.pageConfig.fields.map(f => item[f.prop]),
      ]
        .filter(Boolean)
        .join(" ");
      return text.includes(kw);
    });
  });
 
  const loadData = () => {
    list.value = ensureList(
      props.pageConfig.storageKey,
      props.pageConfig.mockRows || []
    );
  };
 
  const handleSearch = () => {
    /* 关键字由 computed 过滤 */
  };
 
  const goBack = () => {
    uni.navigateBack();
  };
 
  const openDetail = item => {
    showToast(`查看:${item.summary || props.pageConfig.title}`);
  };
 
  const handleAdd = () => {
    const row = {
      ...(props.pageConfig.mockRows?.[0] || {}),
      id: `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
      applicantName: "当前用户",
      status: "pending",
      createTime: new Date().toISOString().slice(0, 19).replace("T", " "),
      summary: `新建${props.pageConfig.title}`,
    };
    list.value = [row, ...list.value];
    saveList(props.pageConfig.storageKey, list.value);
    showToast("已新增(本地示例)", "success");
  };
 
  onShow(() => {
    loadData();
  });
</script>
 
<style scoped lang="scss">
  @import "@/styles/sales-common.scss";
 
  .oa-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
 
  .list-scroll {
    flex: 1;
    height: 0;
    padding-bottom: 80px;
  }
 
  .empty-wrap {
    padding: 48px 20px;
  }
 
  .footer-add {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  }
</style>