海川开心:
1.销售管理、仓储物流一些字段赋默认值
2.生产报工改成可以多个报工
已修改5个文件
329 ■■■■■ 文件已修改
src/views/inventoryManagement/issueManagement/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inventoryManagement/receiptManagement/components/formDiaManual.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionReporting/components/formDia.vue 295 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionReporting/index.vue 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/salesLedger/index.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/inventoryManagement/issueManagement/index.vue
@@ -301,9 +301,9 @@
    if (activeTab.value === 'production') {
      defaultPersonName = '邓莹莹'
    } else if (activeTab.value === 'purchase') {
      defaultPersonName = '吴玉梅'
      defaultPersonName = '何琼华' // 原料出库默认发料人
    } else if (activeTab.value === 'manual') {
      defaultPersonName = '何琼华'
      defaultPersonName = '吴玉梅' // 材料出库默认发料人
    }
    
    // 查找对应的用户ID
src/views/inventoryManagement/receiptManagement/components/formDiaManual.vue
@@ -164,7 +164,7 @@
    id: null,
    productCategory: '',
    specificationModel: '',
    unit: '',
    unit: '个',
    supplierName: form.value.supplierName || '',
    itemType: '物料',
    inboundNum: 0,
src/views/productionManagement/productionReporting/components/formDia.vue
@@ -7,81 +7,97 @@
                draggable
        @close="closeDia"
    >
      <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="排产数量:" prop="schedulingNum">
              <el-input v-model="form.schedulingNum" placeholder="请输入" clearable disabled/>
            </el-form-item>
          </el-col>
                    <el-col :span="12">
                        <el-form-item label="待生产数量:" prop="pendingNum">
                            <el-input v-model="form.pendingNum" placeholder="请输入" clearable disabled/>
                        </el-form-item>
                    </el-col>
        </el-row>
        <el-row :gutter="30">
                    <el-col :span="12">
                        <el-form-item label="本次生产数量:" prop="finishedNum">
                            <el-input-number
                                v-model="form.finishedNum"
                                placeholder="请输入"
                                :min="0"
                                :step="0.1"
                                :precision="2"
                                clearable
                                style="width: 100%"
                                @change="changeNum"
                            />
                        </el-form-item>
                    </el-col>
          <el-col :span="12">
            <el-form-item label="单价(元):" prop="unitPrice">
              <el-input v-model="form.unitPrice" placeholder="请输入" clearable @input="calculateTotalPrice"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="总价(元):" prop="totalPrice">
              <el-input v-model="form.totalPrice" placeholder="请输入" clearable disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
                    <el-col :span="12">
                        <el-form-item label="生产人:" prop="schedulingUserId">
                            <el-select
                                v-model="form.schedulingUserId"
                                placeholder="选择人员"
                                style="width: 100%;"
      <el-form label-width="140px" label-position="top" :rules="rules" ref="formRef">
        <el-table
          :data="reportList"
          border
          style="width: 100%"
        >
          <el-table-column
            align="center"
            label="序号"
            type="index"
            width="60"
          />
          <el-table-column label="合同号" prop="salesContractNo" width="150" />
          <el-table-column label="产品大类" prop="productCategory" width="120" />
          <el-table-column label="规格型号" prop="specificationModel" width="150" />
          <el-table-column label="排产数量" prop="schedulingNum" width="100">
            <template #default="scope">
              <span>{{ scope.row.schedulingNum }}</span>
            </template>
          </el-table-column>
          <el-table-column label="待生产数量" prop="pendingNum" width="100">
            <template #default="scope">
              <span>{{ scope.row.pendingNum }}</span>
            </template>
          </el-table-column>
          <el-table-column label="本次生产数量" prop="finishedNum" width="150">
            <template #default="scope">
              <el-input-number
                v-model="scope.row.finishedNum"
                placeholder="请输入"
                :min="0"
                :step="0.1"
                :precision="2"
                clearable
                style="width: 100%"
                @change="(val) => changeNum(scope.row, val)"
              />
            </template>
          </el-table-column>
          <el-table-column label="单价(元)" prop="unitPrice" width="120">
            <template #default="scope">
              <el-input-number
                v-model="scope.row.unitPrice"
                placeholder="请输入"
                :min="0"
                :step="0.01"
                :precision="2"
                clearable
                style="width: 100%"
                @change="() => calculateTotalPrice(scope.row)"
              />
            </template>
          </el-table-column>
          <el-table-column label="总价(元)" prop="totalPrice" width="120">
            <template #default="scope">
              <span>{{ scope.row.totalPrice || '0.00' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="生产人" prop="schedulingUserId" width="150">
            <template #default="scope">
              <el-select
                v-model="scope.row.schedulingUserId"
                placeholder="选择人员"
                style="width: 100%;"
                filterable
                default-first-option
                :reserve-keyword="false"
                            >
                                <el-option
                                    v-for="user in userList"
                                    :key="user.userId"
                                    :label="user.nickName"
                                    :value="user.userId"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
          <el-col :span="12">
            <el-form-item label="生产日期:" prop="schedulingDate">
              >
                <el-option
                  v-for="user in userList"
                  :key="user.userId"
                  :label="user.nickName"
                  :value="user.userId"
                />
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="生产日期" prop="schedulingDate" width="150">
            <template #default="scope">
              <el-date-picker
                  v-model="form.schedulingDate"
                  type="date"
                  placeholder="请选择日期"
                  value-format="YYYY-MM-DD"
                  format="YYYY-MM-DD"
                  clearable
                  style="width: 100%"
                v-model="scope.row.schedulingDate"
                type="date"
                placeholder="请选择日期"
                value-format="YYYY-MM-DD"
                format="YYYY-MM-DD"
                clearable
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
@@ -94,7 +110,7 @@
</template>
<script setup>
import {ref} from "vue";
import {ref, reactive, toRefs, getCurrentInstance} from "vue";
import {getStaffJoinInfo, staffJoinAdd, staffJoinUpdate} from "@/api/personnelManagement/onboarding.js";
import {userListNoPageByTenantId} from "@/api/system/user.js";
import {productionReport, productionReportUpdate} from "@/api/productionManagement/productionReporting.js";
@@ -104,83 +120,128 @@
const userList = ref([])
const dialogFormVisible = ref(false);
const operationType = ref('')
const reportList = ref([])
const data = reactive({
  form: {
        successNum: "",
        schedulingNum: "",
    pendingNum: "",
        finishedNum: "",
        schedulingUserId: "",
        schedulingDate: "",
        unitPrice: "",
        totalPrice: "",
  },
  rules: {
        schedulingNum: [{ required: true, message: "请输入", trigger: "blur" },],
  },
});
const { form, rules } = toRefs(data);
const { rules } = toRefs(data);
// 打开弹框
const openDialog = (type, row) => {
const openDialog = (type, rows) => {
  operationType.value = type;
  dialogFormVisible.value = true;
    userListNoPageByTenantId().then((res) => {
        userList.value = res.data;
    });
    form.value = {...row}
  const total = Number(row?.schedulingNum ?? 0);
  const pendingFinish = Number(row?.pendingFinishNum ?? 0);
  const autoFill = pendingFinish > 0 ? Math.min(pendingFinish, total) : total;
  form.value.finishedNum = autoFill;
  form.value.pendingNum = Math.max(total - autoFill, 0);
  changeNum(form.value.finishedNum);
    // 处理多条数据
    const rowsArray = Array.isArray(rows) ? rows : [rows];
    reportList.value = rowsArray.map(row => {
        const total = Number(row?.schedulingNum ?? 0);
        const pendingFinish = Number(row?.pendingFinishNum ?? 0);
        const autoFill = pendingFinish > 0 ? Math.min(pendingFinish, total) : total;
        const unitPrice = row?.unitPrice ? Number(row.unitPrice) : 0.33;
        return {
            id: row?.id ?? null,
            salesContractNo: row?.salesContractNo ?? '',
            productCategory: row?.productCategory ?? '',
            specificationModel: row?.specificationModel ?? '',
            schedulingNum: total,
            pendingNum: Math.max(total - autoFill, 0),
            finishedNum: autoFill,
            unitPrice: unitPrice,
            totalPrice: (autoFill * unitPrice).toFixed(2),
            schedulingUserId: row?.schedulingUserId ?? '',
            schedulingDate: row?.schedulingDate ?? '',
        };
    });
}
const changeNum = (value) => {
    if (value > form.value.schedulingNum) {
        form.value.finishedNum = form.value.schedulingNum;
const changeNum = (row, value) => {
    if (value > row.schedulingNum) {
        row.finishedNum = row.schedulingNum;
        proxy.$modal.msgWarning('本次生产数量不可大于排产数量')
    }
    form.value.pendingNum = form.value.schedulingNum - form.value.finishedNum;
    calculateTotalPrice();
    row.pendingNum = row.schedulingNum - row.finishedNum;
    calculateTotalPrice(row);
}
// 计算总价
const calculateTotalPrice = () => {
    const quantity = Number(form.value.finishedNum ?? 0);
    const unitPrice = Number(form.value.unitPrice ?? 0);
const calculateTotalPrice = (row) => {
    const quantity = Number(row.finishedNum ?? 0);
    const unitPrice = Number(row.unitPrice ?? 0);
    
    if (quantity > 0 && unitPrice > 0) {
        form.value.totalPrice = (quantity * unitPrice).toFixed(2);
        row.totalPrice = (quantity * unitPrice).toFixed(2);
    } else {
        form.value.totalPrice = '0.00';
        row.totalPrice = '0.00';
    }
}
// 提交产品表单
const submitForm = () => {
  proxy.$refs.formRef.validate(valid => {
    if (valid) {
      form.value.staffState = 1
      if (operationType.value === "add") {
                productionReport(form.value).then(res => {
          proxy.$modal.msgSuccess("提交成功");
          closeDia();
        })
      } else {
                productionReportUpdate(form.value).then(res => {
          proxy.$modal.msgSuccess("提交成功");
          closeDia();
        })
      }
    }
  })
    // 验证数据
    for (let i = 0; i < reportList.value.length; i++) {
        const item = reportList.value[i];
        if (!item.finishedNum || item.finishedNum <= 0) {
            proxy.$modal.msgError(`第${i + 1}行本次生产数量需大于0`);
            return;
        }
        if (item.finishedNum > item.schedulingNum) {
            proxy.$modal.msgError(`第${i + 1}行本次生产数量不可大于排产数量`);
            return;
        }
        if (!item.schedulingUserId) {
            proxy.$modal.msgError(`第${i + 1}行请选择生产人`);
            return;
        }
        if (!item.schedulingDate) {
            proxy.$modal.msgError(`第${i + 1}行请选择生产日期`);
            return;
        }
    }
    // 构建提交数据数组
    const payloadList = reportList.value.map(item => ({
        id: item.id,
        finishedNum: Number(item.finishedNum),
        unitPrice: Number(item.unitPrice || 0.33),
        totalPrice: Number(item.totalPrice || 0),
        schedulingUserId: item.schedulingUserId,
        schedulingDate: item.schedulingDate,
    }));
    if (operationType.value === "add") {
        productionReport(payloadList).then(res => {
            proxy.$modal.msgSuccess("提交成功");
            closeDia();
        }).catch(err => {
            console.error('提交失败:', err);
        })
    } else {
        // 编辑模式,逐条更新
        Promise.all(payloadList.map(item => productionReportUpdate(item)))
            .then(() => {
                proxy.$modal.msgSuccess("提交成功");
                closeDia();
            })
            .catch(err => {
                console.error('提交失败:', err);
                proxy.$modal.msgError('提交失败,请重试');
            });
    }
}
// 关闭弹框
const closeDia = () => {
  proxy.resetForm("formRef");
  if (proxy.$refs.formRef) {
    proxy.resetForm("formRef");
  }
  dialogFormVisible.value = false;
  reportList.value = [];
  emit('close')
};
defineExpose({
src/views/productionManagement/productionReporting/index.vue
@@ -139,7 +139,7 @@
</template>
<script setup>
import {onMounted, ref} from "vue";
import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
import FormDia from "@/views/productionManagement/productionReporting/components/formDia.vue";
import {staffJoinDel, staffJoinListPage} from "@/api/personnelManagement/onboarding.js";
import {ElMessageBox} from "element-plus";
@@ -400,16 +400,21 @@
};
// 打开弹框
const openForm = (type, row) => {
    if (selectedRows.value.length !== 1) {
        proxy.$message.error("请选择一条数据");
    if (selectedRows.value.length === 0) {
        proxy.$message.error("请至少选择一条数据");
        return;
    }
    if (selectedRows.value[0].pendingFinishNum == 0) {
        proxy.$message.warning("无需再报工");
    // 过滤掉待报工数量为0的数据
    const validRows = selectedRows.value.filter(item => item.pendingFinishNum > 0);
    if (validRows.length === 0) {
        proxy.$message.warning("所选数据均无需再报工");
        return;
    }
    if (validRows.length < selectedRows.value.length) {
        proxy.$message.warning(`已过滤 ${selectedRows.value.length - validRows.length} 条无需报工的数据`);
    }
    nextTick(() => {
        const rowInfo = type === 'add' ? selectedRows.value[0] : row
        const rowInfo = type === 'add' ? validRows : (row ? [row] : [])
        formDia.value?.openDialog(type, rowInfo)
    })
};
src/views/salesManagement/salesLedger/index.vue
@@ -778,6 +778,13 @@
  if (type === "add") {
    // 新增时设置录入日期为当天
    form.value.entryDate = getCurrentDate();
    // 业务员默认为许红峰(从下拉框选项中查找)
    const xuHongFeng = userList.value.find(item => item.nickName === "许红峰");
    if (xuHongFeng) {
      form.value.salesman = xuHongFeng.nickName;
    }
    // 签订日期默认为当天
    form.value.executionDate = getCurrentDate();
  } else {
    currentId.value = row.id;
    getSalesLedgerWithProducts({ id: row.id, type: 1 }).then((res) => {
@@ -875,6 +882,10 @@
  if (type === "edit") {
    productForm.value = { ...row };
    productIndex.value = index;
  } else {
    // 新增时设置默认值
    productForm.value.taxRate = "13"; // 税率默认为13%
    productForm.value.invoiceType = "增专票"; // 发票类型默认为增专票
  }
  productFormVisible.value = true;
  getProductOptions();