gaoluyang
2025-11-15 47e1cecb6f5cd01c029ff1a2f1658326a33025f4
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
<template>
  <view class="prod-reporting">
    <PageHeader title="生产报工" />
 
    <view class="search_form">
      <u-form>
        <view class="form-row">
          <u-form-item label="客户名称" label-width="80">
            <up-input v-model="searchForm.customerName" placeholder="请输入" clearable @change="handleQuery" />
          </u-form-item>
          <u-form-item label="项目名称" label-width="80">
            <up-input v-model="searchForm.projectName" placeholder="请输入" clearable @change="handleQuery" />
          </u-form-item>
        </view>
        <view class="form-row">
          <u-form-item label="状态" label-width="80">
            <up-input v-model="statusDisplay" placeholder="请选择状态" readonly @click="showStatusPicker = true" />
          </u-form-item>
        </view>
        <view class="form-actions">
          <u-button type="primary" size="small" @click="handleQuery">搜索</u-button>
        </view>
      </u-form>
    </view>
 
    <view class="list_container">
      <u-loading-icon v-if="tableLoading" text="加载中..." />
      <view v-else>
        <view v-if="!tableData || tableData.length === 0" class="empty">暂无数据</view>
        <view v-else class="card_list">
          <view v-for="item in tableData" :key="item.id" class="card_item">
            <view class="card_header">
              <u-tag :type="statusType(item.status)" size="mini">{{ statusText(item.status) }}</u-tag>
              <text class="card_title">{{ item.projectName }}</text>
            </view>
            <view class="card_body">
              <view class="row"><text class="label">排产日期</text><text class="value">{{ item.schedulingDate }}</text></view>
              <view class="row"><text class="label">排产人</text><text class="value">{{ item.schedulingUserName }}</text></view>
              <view class="row"><text class="label">合同号</text><text class="value">{{ item.salesContractNo }}</text></view>
              <view class="row"><text class="label">客户合同号</text><text class="value">{{ item.customerContractNo }}</text></view>
              <view class="row"><text class="label">客户名称</text><text class="value">{{ item.customerName }}</text></view>
              <view class="row"><text class="label">产品大类</text><text class="value">{{ item.productCategory }}</text></view>
              <view class="row"><text class="label">规格型号</text><text class="value">{{ item.specificationModel }}</text></view>
              <view class="row inline">
                <view class="col"><text class="label">单位</text><text class="value">{{ item.unit }}</text></view>
                <view class="col"><text class="label">排产数量</text><text class="value">{{ item.schedulingNum }}</text></view>
                <view class="col"><text class="label">生产数量</text><text class="value">{{ item.finishedNum }}</text></view>
                <view class="col"><text class="label">待生产数量</text><text class="value">{{ item.pendingFinishNum }}</text></view>
              </view>
            </view>
            <view class="card_actions">
              <u-button type="primary" size="small" @click="openForm('add', item)" :disabled="item.pendingFinishNum == 0">生产报工</u-button>
            </view>
          </view>
        </view>
 
        
      </view>
    </view>
 
    <form-dia ref="formDia" @close="handleQuery"></form-dia>
 
    <!-- 状态选择器 -->
    <up-action-sheet :show="showStatusPicker" :actions="statusActions" title="选择状态" @select="onStatusSelect" @close="showStatusPicker = false" />
  </view>
</template>
 
<script setup>
import { onMounted, ref, reactive, toRefs, nextTick, computed } from "vue";
import PageHeader from '@/components/PageHeader.vue'
import FormDia from './components/formDia.vue'
import { workListPage } from "@/api/productionManagement/productionReporting.js";
const data = reactive({
  searchForm: {
    customerName: "",
    projectName: "",
    status: undefined,
  },
});
const { searchForm } = toRefs(data);
const showStatusPicker = ref(false)
const statusOptions = ref([
  { label: '待生产', value: 1 },
  { label: '生产中', value: 2 },
  { label: '已报工', value: 3 },
])
const statusActions = computed(() => statusOptions.value.map(o => ({ name: o.label, value: o.value })))
const statusDisplay = ref('')
const tableData = ref([]);
const tableLoading = ref(false);
const page = reactive({
  current: -1,
  size: -1,
});
const formDia = ref()
 
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
  page.current = -1;
  page.size = -1;
  getList();
};
const getList = () => {
  tableLoading.value = true;
  const params = { ...searchForm.value, ...page };
  workListPage(params).then(res => {
    tableLoading.value = false;
    tableData.value = res.data.records.map(item => ({
      ...item,
      pendingFinishNum: (Number(item.schedulingNum) || 0) - (Number(item.finishedNum) || 0)
    }));
  }).catch(err => {
    tableLoading.value = false;
  })
};
// 状态选择
const onStatusSelect = (item) => {
  searchForm.value.status = item?.value
  statusDisplay.value = item?.name || ''
  showStatusPicker.value = false
  handleQuery()
}
// 打开弹框
const openForm = (type, row) => {
  if (!row) return
  if ((Number(row.pendingFinishNum) || 0) === 0) {
    uni.showToast({ title: '无需再报工', icon: 'none' })
    return
  }
  nextTick(() => { formDia.value?.openDialog(type, row) })
};
 
// 状态文本/类型
const statusText = (s) => {
  if (s == 3) return '已报工'
  if (s == 1) return '待生产'
  return '生产中'
}
const statusType = (s) => {
  if (s == 3) return 'success'
  if (s == 1) return 'primary'
  return 'warning'
}
 
// 无分页
 
// 明细人员/日期选择
const openChildUserPicker = (index) => {
  if (!expandData.value[index]?.editType) return
  childUserPicker.value.index = index
  childUserPicker.value.show = true
}
const onChildUserSelect = (item) => {
  if (item && childUserPicker.value.index > -1) {
    const row = expandData.value[childUserPicker.value.index]
    row.schedulingUserId = item.value
    row.schedulingUserName = item.name
  }
  childUserPicker.value.show = false
}
const openChildDatePicker = (index) => {
  if (!expandData.value[index]?.editType) return
  childDatePicker.value.index = index
  childDatePicker.value.value = Date.now()
  childDatePicker.value.show = true
}
const onChildDateConfirm = (e) => {
  const d = new Date(e.value)
  const y = d.getFullYear(); const m = String(d.getMonth()+1).padStart(2, '0'); const day = String(d.getDate()).padStart(2, '0')
  const str = `${y}-${m}-${day}`
  if (childDatePicker.value.index > -1) {
    expandData.value[childDatePicker.value.index].schedulingDate = str
  }
  childDatePicker.value.show = false
}
 
onMounted(() => {
  getList();
});
</script>
 
<style scoped lang="scss">
.prod-reporting { padding-bottom: 12px; }
.search_form { margin: 12px; background: #fff; border-radius: 8px; padding: 10px; }
.form-row { display: flex; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; }
.list_container { padding: 0 12px; }
.empty { text-align: center; color: #888; padding: 20px 0; }
.card_list { display: flex; flex-direction: column; gap: 10px; }
.card_item { background: #fff; border-radius: 10px; padding: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.card_header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card_title { font-weight: 500; color: #333; margin-left: auto; }
.card_body .row { display: flex; justify-content: space-between; padding: 4px 0; }
.card_body .row.inline { display: flex; gap: 10px; flex-wrap: wrap; }
.card_body .row.inline .col { min-width: 45%; display: flex; justify-content: space-between; }
.label { color: #666; font-size: 12px; }
.value { color: #333; font-size: 12px; }
.card_actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.ml8 { margin-left: 8px; }
 
</style>