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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<template>
  <view class="production-scheduling">
    <!-- 通用页面头部 -->
    <PageHeader title="生产排产"
                @back="goBack" />
    <!-- 搜索区域 -->
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input class="search-text"
                    placeholder="请输入工单编号"
                    v-model="searchForm.workOrderNo"
                    @confirm="handleQuery"
                    clearable />
        </view>
        <view class="filter-button"
              @click="handleQuery">
          <up-icon name="search"
                   size="24"
                   color="#999"></up-icon>
        </view>
      </view>
    </view>
    <!-- 列表 -->
    <scroll-view scroll-y
                 class="ledger-list"
                 v-if="tableData.length > 0"
                 @scrolltolower="loadMore">
      <view v-for="(item, index) in tableData"
            :key="item.id || index"
            class="ledger-item">
        <view class="item-header">
          <view class="item-left">
            <view class="document-icon">
              <up-icon name="file-text"
                       size="16"
                       color="#ffffff"></up-icon>
            </view>
            <text class="item-id">{{ item.workOrderNo }}</text>
          </view>
          <view class="item-right">
            <up-tag :text="item.workOrderType"
                    size="mini"
                    type="primary"
                    plain></up-tag>
          </view>
        </view>
        <up-divider></up-divider>
        <view class="item-details">
          <view class="detail-row">
            <text class="detail-label">生产订单号</text>
            <text class="detail-value">{{ item.npsNo || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">产品名称</text>
            <text class="detail-value">{{ item.productName || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">规格型号</text>
            <text class="detail-value">{{ item.model || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">单位</text>
            <text class="detail-value">{{ item.unit || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">工序名称</text>
            <text class="detail-value">{{ item.operationName || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">需求数量</text>
            <text class="detail-value">{{ item.planQuantity || 0 }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">完成数量</text>
            <text class="detail-value">{{ item.completeQuantity || 0 }}</text>
          </view>
          <view class="progress-section">
            <text class="detail-label">完成进度</text>
            <view class="progress-bar">
              <up-line-progress :percentage="toProgressPercentage(item.completionStatus)"
                                :activeColor="progressColor(item.completionStatus)"
                                :showText="true"></up-line-progress>
            </view>
          </view>
          <view class="detail-row">
            <text class="detail-label">计划开始</text>
            <text class="detail-value">{{ item.planStartTime || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">计划结束</text>
            <text class="detail-value">{{ item.planEndTime || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">实际开始</text>
            <text class="detail-value">{{ item.actualStartTime || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">实际结束</text>
            <text class="detail-value">{{ item.actualEndTime || '-' }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">指定报工人</text>
            <view class="detail-value tags-box">
              <template v-if="item.userNames">
                <up-tag v-for="(name, idx) in item.userNames.split(',')"
                        :key="idx"
                        :text="name"
                        size="mini"
                        type="info"
                        plain
                        class="user-tag"></up-tag>
              </template>
              <text v-else>-</text>
            </view>
          </view>
        </view>
      </view>
      <up-loadmore :status="loadStatus" />
    </scroll-view>
    <view v-else-if="!loading"
          class="no-data">
      <up-empty mode="data"
                text="暂无数据"></up-empty>
    </view>
  </view>
</template>
 
<script setup>
  import { ref, reactive, toRefs, getCurrentInstance } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import { productWorkOrderPage } from "@/api/productionManagement/workOrder.js";
  import PageHeader from "@/components/PageHeader.vue";
 
  const { proxy } = getCurrentInstance();
 
  const loading = ref(false);
  const tableData = ref([]);
  const loadStatus = ref("loadmore");
 
  const page = reactive({
    current: 1,
    size: 10,
    total: 0,
  });
 
  const data = reactive({
    searchForm: {
      workOrderNo: "",
    },
  });
  const { searchForm } = toRefs(data);
 
  const goBack = () => {
    uni.navigateBack();
  };
 
  const handleQuery = () => {
    page.current = 1;
    tableData.value = [];
    getList();
  };
 
  const getList = () => {
    if (loading.value) return;
    loading.value = true;
 
    const params = {
      ...searchForm.value,
      ...page,
    };
 
    productWorkOrderPage(params)
      .then(res => {
        loading.value = false;
        const records = res.data.records || [];
        tableData.value =
          page.current === 1 ? records : [...tableData.value, ...records];
        page.total = res.data.total;
 
        if (tableData.value.length >= page.total) {
          loadStatus.value = "nomore";
        } else {
          loadStatus.value = "loadmore";
        }
      })
      .catch(() => {
        loading.value = false;
        uni.showToast({ title: "加载失败", icon: "error" });
      });
  };
 
  const loadMore = () => {
    if (loadStatus.value === "nomore" || loading.value) return;
    page.current++;
    getList();
  };
 
  const toProgressPercentage = val => {
    const n = Number(val);
    if (!Number.isFinite(n)) return 0;
    if (n <= 0) return 0;
    if (n >= 100) return 100;
    return Math.round(n);
  };
 
  const progressColor = percentage => {
    const p = toProgressPercentage(percentage);
    if (p < 30) return "#f56c6c";
    if (p < 50) return "#e6a23c";
    if (p < 80) return "#409eff";
    return "#67c23a";
  };
 
  onShow(() => {
    handleQuery();
  });
</script>
 
<style scoped lang="scss">
  @import "@/styles/sales-common.scss";
 
  .production-scheduling {
    padding-bottom: 20rpx;
  }
  .progress-bar {
    margin-top: 20rpx;
    margin-bottom: 20rpx;
  }
 
  .tags-box {
    display: flex;
    flex-wrap: wrap;
    gap: 8rpx;
    justify-content: flex-end;
  }
 
  .user-tag {
    margin-bottom: 4rpx;
  }
</style>