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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<template>
  <view class="sales-account">
    <PageHeader title="工序管理"
                @back="goBack" />
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
          <up-input class="search-text"
                    v-model="queryParams.name"
                    placeholder="请输入工序名称"
                    clearable
                    @change="handleSearch" />
        </view>
        <view class="filter-button"
              @click="handleSearch">
          <up-icon name="search"
                   size="24"
                   color="#999999"></up-icon>
        </view>
      </view>
    </view>
    <view v-if="list.length > 0"
          class="ledger-list">
      <view v-for="item in list"
            :key="item.id"
            class="ledger-item">
        <view class="item-header">
          <view class="item-left">
            <view class="document-icon">
              <up-icon name="list-dot"
                       size="16"
                       color="#ffffff"></up-icon>
            </view>
            <text class="item-id">{{ item.name || "-" }}</text>
          </view>
          <text class="item-index">{{ item.no || "-" }}</text>
        </view>
        <up-divider></up-divider>
        <view class="item-details">
          <view class="detail-row">
            <text class="detail-label">关联设备</text>
            <text class="detail-value">{{ getDeviceName(item.deviceLedgerId) }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">工资定额</text>
            <text class="detail-value highlight">¥{{ item.salaryQuota || 0 }}</text>
          </view>
          <view class="detail-row">
            <text class="detail-label">工序状态</text>
            <view class="detail-value">
              <up-tag :text="item.isQuality ? '质检' : '非质检'"
                      :type="item.isQuality ? 'warning' : 'info'"
                      size="mini"
                      style="margin-left: 8rpx" />
              <up-tag :text="item.isProduction ? '生产' : '不生产'"
                      :type="item.isProduction ? 'warning' : 'info'"
                      size="mini"
                      style="margin-left: 8rpx" />
              <up-tag v-if="item.type !== null && item.type !== undefined"
                      :text="item.type == 0 ? '计时' : '计件'"
                      :type="item.type == 1 ? 'primary' : 'success'"
                      size="mini"
                      style="margin-left: 8rpx" />
            </view>
          </view>
          <view class="detail-row">
            <text class="detail-label">备注</text>
            <text class="detail-value">{{ item.remark || "-" }}</text>
          </view>
        </view>
        <view class="action-buttons">
          <up-button class="action-btn"
                     size="small"
                     type="primary"
                     @click="goEdit(item)">编辑</up-button>
          <up-button class="action-btn"
                     size="small"
                     type="warning"
                     @click="goParams(item)">参数配置</up-button>
          <up-button class="action-btn"
                     size="small"
                     type="error"
                     @click="handleDelete(item)">删除</up-button>
        </view>
      </view>
      <up-loadmore :status="pageStatus" />
    </view>
    <view v-else
          class="no-data">
      <text>暂无工序数据</text>
    </view>
    <view class="fab-button"
          @click="goAdd">
      <up-icon name="plus"
               size="28"
               color="#ffffff"></up-icon>
    </view>
  </view>
</template>
 
<script setup>
  import { reactive, ref } from "vue";
  import { onReachBottom, onShow } from "@dcloudio/uni-app";
  import {
    getProcessList,
    del,
    getDeviceLedger,
  } from "@/api/productionManagement/processManagement";
 
  const queryParams = reactive({
    name: "",
  });
  const list = ref([]);
  const deviceOptions = ref([]);
  const pageStatus = ref("loadmore");
 
  const page = reactive({
    current: 1,
    size: 10,
    total: 0,
  });
 
  const goBack = () => {
    uni.navigateBack();
  };
 
  const getDeviceName = deviceId => {
    if (!deviceId) return "未关联";
    const device = deviceOptions.value.find(item => item.id === Number(deviceId));
    return device?.deviceName || "未关联";
  };
 
  const loadDevices = async () => {
    try {
      const { data } = await getDeviceLedger();
      deviceOptions.value = data || [];
    } catch (error) {
      console.error("加载设备列表失败", error);
    }
  };
 
  const handleSearch = () => {
    page.current = 1;
    pageStatus.value = "loadmore";
    list.value = [];
    getList();
  };
 
  const getList = () => {
    if (pageStatus.value === "loading" || pageStatus.value === "nomore") return;
 
    pageStatus.value = "loading";
    getProcessList({
      current: page.current,
      size: page.size,
      name: queryParams.name,
    })
      .then(res => {
        const records = res?.data?.records || res?.records || [];
        const total = res?.data?.total || res?.total || 0;
 
        if (page.current === 1) {
          list.value = records;
        } else {
          list.value = [...list.value, ...records];
        }
 
        page.total = total;
        if (list.value.length >= total) {
          pageStatus.value = "nomore";
        } else {
          pageStatus.value = "loadmore";
          page.current++;
        }
      })
      .catch(() => {
        uni.showToast({ title: "查询失败", icon: "error" });
        pageStatus.value = "loadmore";
      });
  };
 
  const goAdd = () => {
    uni.navigateTo({ url: "/pages/productionDesign/processManagement/edit" });
  };
 
  const goEdit = item => {
    uni.navigateTo({
      url: `/pages/productionDesign/processManagement/edit?item=${encodeURIComponent(
        JSON.stringify(item)
      )}`,
    });
  };
 
  const goParams = item => {
    uni.navigateTo({
      url: `/pages/productionDesign/processManagement/params?id=${item.id}&name=${encodeURIComponent(item.name)}`,
    });
  };
 
  const handleDelete = item => {
    uni.showModal({
      title: "提示",
      content: "确定要删除该工序吗?",
      success: res => {
        if (res.confirm) {
          del([item.id]).then(() => {
            uni.showToast({ title: "删除成功" });
            handleSearch();
          });
        }
      },
    });
  };
 
  onReachBottom(() => {
    getList();
  });
 
  onShow(async () => {
    await loadDevices();
    handleSearch();
  });
</script>
 
<style scoped lang="scss">
  @import "@/styles/procurement-common.scss";
 
  .no-data {
    padding-top: 100rpx;
    text-align: center;
    color: #999;
    font-size: 28rpx;
  }
 
  .action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 20rpx;
    padding-bottom: 30rpx;
  }
 
  .action-btn {
    flex: 1;
    margin: 0 !important;
  }
 
  .fab-button {
    position: fixed;
    right: 40rpx;
    bottom: 60rpx;
    width: 100rpx;
    height: 100rpx;
    background: #2979ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.4);
    z-index: 100;
  }
</style>