From 67ff1c675d2f97619349ed234a56fa0ea3ab33b8 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 14 一月 2026 13:30:41 +0800
Subject: [PATCH] 新生产报工

---
 src/pages/productionManagement/productionReporting/index.vue |  348 +++++++++++++++++++++++++--------------------------------
 1 files changed, 151 insertions(+), 197 deletions(-)

diff --git a/src/pages/productionManagement/productionReporting/index.vue b/src/pages/productionManagement/productionReporting/index.vue
index 28e3f55..ea9d7dd 100644
--- a/src/pages/productionManagement/productionReporting/index.vue
+++ b/src/pages/productionManagement/productionReporting/index.vue
@@ -1,214 +1,168 @@
 <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>
-        </view>
-        <view class="form-row">
-          <u-form-item label="鐘舵��" label-width="80" style="flex:1">
-        	<uni-data-select v-model="searchForm.status" :localdata="statusList"></uni-data-select>
-            <!-- <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 class="invoice-add">
+    <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
+    <PageHeader title="鐢熶骇鎶ュ伐"
+                @back="goBack" />
+    <!-- 琛ㄥ崟鍐呭 -->
+    <u-form @submit="submitForm"
+            ref="formRef"
+            label-width="110"
+            input-align="right"
+            error-message-align="right">
+      <!-- 鍩烘湰淇℃伅 -->
+      <view class="form-section">
+        <u-form-item label="寰呯敓浜ф暟閲�"
+                     prop="planQuantity"
+                     required>
+          <u-input v-model="form.planQuantity"
+                   placeholder="鑷姩濉厖"
+                   disabled />
+        </u-form-item>
+        <u-form-item label="鏈鐢熶骇鏁伴噺"
+                     prop="quantity"
+                     required>
+          <u-input v-model="form.quantity"
+                   placeholder="璇疯緭鍏�"
+                   type="number" />
+          <!-- <u-number-box v-model="form.quantity"
+                        step="0.1"
+                        bgColor="#fff"
+                        decimal-length="1"
+                        :min="0"></u-number-box> -->
+        </u-form-item>
+        <u-form-item label="鐝粍淇℃伅"
+                     prop="schedulingUserId"
+                     required>
+          <u-input v-model="form.userName"
+                   placeholder="璇烽�夋嫨鐢熶骇浜�"
+                   readonly />
+        </u-form-item>
       </view>
-    </view>
-
-    <form-dia ref="formDia" @close="handleQuery"></form-dia>
-
-    <!-- 鐘舵�侀�夋嫨鍣� -->
-    <up-action-sheet :show="showStatusPicker" :actions="statusActions" title="閫夋嫨鐘舵��" @select="onStatusSelect" @close="showStatusPicker = false" />
+      <!-- 浣跨敤FooterButtons缁勪欢 -->
+      <FooterButtons @cancel="goBack"
+                     @confirm="submitForm"
+                     :loading="submitting" />
+      <!-- 涓哄簳閮ㄦ寜閽暀鍑虹┖闂� -->
+      <view style="height: 80px;"></view>
+    </u-form>
+    <!-- 鐢熶骇浜洪�夋嫨鍣� -->
+    <up-action-sheet :show="showProducerPicker"
+                     :actions="producerList"
+                     title="閫夋嫨鐢熶骇浜�"
+                     @select="onProducerConfirm"
+                     @close="showProducerPicker = 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";
+  import { ref, onMounted } from "vue";
+  import { onLoad } from "@dcloudio/uni-app";
+  import FooterButtons from "@/components/FooterButtons.vue";
+  import modal from "@/plugins/modal";
 
-const statusList = reactive([{
-	text:'寰呮姤宸�',
-	value: 1
-},{
-	text:'鎺掍骇涓�',
-	value: 2
-},
-// {
-// 	text:'鐢熶骇涓�',
-// 	value: 3
-// },
-])
+  const showToast = message => {
+    uni.showToast({
+      title: message,
+      icon: "none",
+    });
+  };
+  import { addProductMain } from "@/api/productionManagement/productionReporting";
+  import { getInfo } from "@/api/login";
 
-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 formRef = 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) })
-};
+  // 琛ㄥ崟鏁版嵁
+  let form = ref({
+    planQuantity: 0,
+    quantity: 0,
+    userName: "",
+    workOrderId: "",
+    reportWork: "",
+    productProcessRouteItemId: "",
+    userId: "",
+    productMainId: null,
+  });
+  let schedulingUserName = ref("");
 
-// 鐘舵�佹枃鏈�/绫诲瀷
-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 showEnterDatePicker = ref(false);
+  const enterDateValue = ref(Date.now());
 
-// 鏃犲垎椤�
+  // 鐢熶骇浜洪�夋嫨鍣ㄧ姸鎬�
+  const showProducerPicker = ref(false);
+  const producerList = ref([]);
 
-// 鏄庣粏浜哄憳/鏃ユ湡閫夋嫨
-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
-}
+  // 鐢熶骇浜洪�夋嫨纭
+  const onProducerConfirm = e => {
+    form.value.schedulingUserId = e.value;
+    schedulingUserName.value = e.name;
+    showProducerPicker.value = false;
+  };
 
-onMounted(() => {
-  getList();
-});
+  // 鎻愪氦鐘舵��
+  const submitting = ref(false);
+
+  // 杩斿洖涓婁竴椤�
+  const goBack = () => {
+    uni.navigateBack();
+  };
+  // 鎻愪氦琛ㄥ崟
+  const submitForm = async () => {
+    submitting.value = true;
+    // 鏍¢獙琛ㄥ崟
+    if (!form.value.quantity) {
+      submitting.value = false;
+      showToast("璇疯緭鍏ユ湰娆$敓浜ф暟閲�");
+      return;
+    }
+    if (form.value.quantity > form.value.planQuantity) {
+      submitting.value = false;
+      showToast("鏈鐢熶骇鏁伴噺涓嶈兘澶т簬寰呯敓浜ф暟閲�");
+      return;
+    }
+    console.log(form.value, "form.value");
+
+    addProductMain(form.value).then(res => {
+      if (res.code === 200) {
+        showToast("鎶ュ伐鎴愬姛");
+        submitting.value = false;
+        setTimeout(() => {
+          goBack();
+        }, 1000);
+      } else {
+        showToast(res.msg || "鎶ュ伐澶辫触");
+        submitting.value = false;
+      }
+    });
+  };
+
+  // 椤甸潰鍔犺浇鏃跺垵濮嬪寲鏁版嵁
+  onLoad(options => {
+    console.log(options, "options");
+    try {
+      const orderRow = JSON.parse(options.orderRow);
+      console.log(orderRow, "orderRow======########");
+      form.value.planQuantity = orderRow.planQuantity;
+      form.value.quantity = orderRow.quantity;
+      form.value.productProcessRouteItemId = orderRow.productProcessRouteItemId;
+      form.value.workOrderId = orderRow.id;
+      form.value.reportWork = orderRow.reportWork;
+      form.value.productMainId = orderRow.productMainId;
+      getInfo().then(res => {
+        form.value.userId = res.user.userId;
+        form.value.userName = res.user.userName;
+      });
+    } catch (error) {
+      modal.msgError("璁㈠崟瑙f瀽澶辫触");
+      goBack();
+      return;
+    }
+  });
 </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; }
-
+  @import "@/static/scss/form-common.scss";
 </style>
+
+

--
Gitblit v1.9.3