chenhj
11 小时以前 ed94f308b3fb345eb7238b8836a61d0b8bbaa98c
src/views/salesManagement/salesLedger/index.vue
@@ -46,6 +46,7 @@
              <el-table-column align="center" label="序号" type="index"/>
              <el-table-column label="产品大类" prop="productCategory" />
              <el-table-column label="规格型号" prop="specificationModel" />
              <el-table-column label="批号" prop="batchNo" />
              <el-table-column label="单位" prop="unit" />
                     <el-table-column label="产品状态"
                                              width="100px"
@@ -121,9 +122,10 @@
        <el-table-column label="备注" prop="remarks" width="200" show-overflow-tooltip />
        <el-table-column fixed="right" label="操作" min-width="100" align="center">
          <template #default="scope">
            <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">编辑</el-button>
            <el-button link type="primary" size="small" @click="openForm('edit', scope.row)" :disabled="!scope.row.isEdit">编辑</el-button>
<!--            <el-button link type="primary" size="small" @click="openForm('view', scope.row)">详情</el-button>-->
            <el-button link type="primary" size="small" @click="downLoadFile(scope.row)">附件</el-button>
            <el-button link type="primary" size="small" @click="exportSaleOutbound(scope.row)">打印销售出库单</el-button>
<!--            <el-button link type="primary" size="small" @click="openDeliveryForm(scope.row)">发货</el-button>-->
          </template>
        </el-table-column>
@@ -227,6 +229,8 @@
               <el-table-column align="center" label="序号" type="index" width="60" />
               <el-table-column label="产品大类" prop="productCategory" />
               <el-table-column label="规格型号" prop="specificationModel" />
               <el-table-column label="UID码" prop="uidNo" />
               <el-table-column label="批号" prop="batchNo" />
               <el-table-column label="单位" prop="unit" />
               <el-table-column label="数量" prop="quantity" />
               <el-table-column label="税率(%)" prop="taxRate" />
@@ -243,14 +247,14 @@
            </el-table>
            <el-row :gutter="30">
               <el-col :span="24">
                  <el-form-item label="备注·:" prop="remark">
                     <el-input v-model="form.remark" placeholder="请输入" clearable type="textarea" :rows="2" :disabled="operationType === 'view'" />
                  <el-form-item label="备注:" prop="remarks">
                     <el-input v-model="form.remarks" placeholder="请输入" clearable type="textarea" :rows="2" :disabled="operationType === 'view'" />
                  </el-form-item>
               </el-col>
            </el-row>
            <el-row :gutter="30">
               <el-col :span="24">
                  <el-form-item label="附件材料:" prop="remark">
                  <el-form-item label="附件材料:" prop="salesLedgerFiles">
                     <el-upload v-model:file-list="fileList" :action="upload.url" multiple ref="fileUpload" auto-upload
                                     :headers="upload.headers" :before-upload="handleBeforeUpload" :on-error="handleUploadError"
                                     :on-success="handleUploadSuccess" :on-remove="handleRemove">
@@ -319,6 +323,15 @@
            </el-table-column>
         </el-table>
         
         <pagination
            v-show="quotationPage.total > 0"
            :total="quotationPage.total"
            layout="total, sizes, prev, pager, next, jumper"
            :page="quotationPage.current"
            :limit="quotationPage.size"
            @pagination="quotationPaginationChange"
         />
         <template #footer>
            <el-button @click="quotationDialogVisible = false">关闭</el-button>
         </template>
@@ -352,6 +365,15 @@
                  </el-form-item>
               </el-col>
            </el-row>
        <el-row :gutter="30">
          <el-col :span="24">
            <el-form-item label="批号:" prop="batchNo">
              <el-select v-model="productForm.batchNo" placeholder="请选择" clearable filterable>
                <el-option v-for="item in batchNoOptions" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
            <el-row :gutter="30">
               <el-col :span="12">
                  <el-form-item label="单位:" prop="unit">
@@ -657,20 +679,22 @@
import FormDialog from '@/components/Dialog/FormDialog.vue';
import { getQuotationList } from "@/api/salesManagement/salesQuotation.js";
import {
   ledgerListPage,
   productList,
   customerList,
   addOrUpdateSalesLedger,
   getSalesLedgerWithProducts,
   delLedger,
   addOrUpdateSalesLedgerProduct,
   delProduct,
   delLedgerFile, getProductInventory,
  ledgerListPage,
  productList,
  customerList,
  addOrUpdateSalesLedger,
  getSalesLedgerWithProducts,
  delLedger,
  addOrUpdateSalesLedgerProduct,
  delProduct,
  delLedgerFile, getProductInventory, saleOutboundExport,
} from "@/api/salesManagement/salesLedger.js";
import { modelList, productTreeList } from "@/api/basicData/product.js";
import useFormData from "@/hooks/useFormData.js";
import dayjs from "dayjs";
import { getCurrentDate } from "@/utils/index.js";
import {getProductOrderBatchNoOptions} from "@/api/productionManagement/productionOrder.js";
import {safeTrainingExport} from "@/api/safeProduction/safetyTrainingAssessment.js";
const userStore = useUserStore();
const { proxy } = getCurrentInstance();
@@ -738,10 +762,12 @@
      taxInclusiveTotalPrice: "",
      taxExclusiveTotalPrice: "",
      invoiceType: "",
    batchNo: "",
   },
   productRules: {
      productCategory: [{ required: true, message: "请选择", trigger: "change" }],
      productModelId: [{ required: true, message: "请选择", trigger: "change" }],
    batchNo: [{ required: true, message: "请选择", trigger: "change" }],
      specificationModel: [
         { required: true, message: "请选择", trigger: "change" },
      ],
@@ -780,6 +806,12 @@
const quotationSearchForm = reactive({
   quotationNo: "",
   customer: "",
});
// 报价单弹框分页
const quotationPage = reactive({
   current: 1,
   size: 10,
   total: 0,
});
const selectedQuotation = ref(null);
@@ -1005,6 +1037,7 @@
// 添加表行类名方法
const tableRowClassName = ({ row }) => {
  if (!row.deliveryDate) return '';
  if (row.isFh) return '';
  const diff = row.deliveryDaysDiff;
@@ -1074,6 +1107,8 @@
const openQuotationDialog = async () => {
   if (operationType.value === "view") return;
   quotationDialogVisible.value = true;
   // 打开弹窗时重置分页到第一页
   quotationPage.current = 1;
   // 先确保客户列表已加载,便于后续回填 customerId
   if (!customerOption.value || customerOption.value.length === 0) {
      try {
@@ -1090,14 +1125,15 @@
   quotationLoading.value = true;
   try {
      const params = {
         // 兼容后端分页字段:这里沿用报价页面已有可用的字段命名
         currentPage: 1,
         pageSize: 100,
         // 后端分页字段:current / size
         current: quotationPage.current,
         size: quotationPage.size,
         ...quotationSearchForm,
         status: "通过",
      };
      const res = await getQuotationList(params);
      quotationList.value = res?.data?.records || [];
      quotationPage.total = res?.data?.total || 0;
   } finally {
      quotationLoading.value = false;
   }
@@ -1106,7 +1142,15 @@
const resetQuotationSearch = async () => {
   quotationSearchForm.quotationNo = "";
   quotationSearchForm.customer = "";
   quotationPage.current = 1;
   await fetchQuotationList();
};
// 报价单弹框分页切换
const quotationPaginationChange = (obj) => {
   quotationPage.current = obj.page;
   quotationPage.size = obj.limit;
   fetchQuotationList();
};
// 选中报价单后回填到台账表单
@@ -1217,6 +1261,12 @@
         });
      }
   });
};
const batchNoOptions = ref([]);
const fetchBatchNoOptions = async () => {
   const res = await getProductOrderBatchNoOptions();
   batchNoOptions.value = res.data;
};
// 关闭弹框
const closeDia = () => {
@@ -2155,8 +2205,41 @@
   let res = await userStore.getInfo();
   currentFactoryName.value = res.user.currentFactoryName;
};
const exportSaleOutbound = row => {
  saleOutboundExport({id: row.id})
      .then(res => {
        // 创建Blob对象
        const blob = new Blob([res], {
          type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        });
        // 创建下载链接
        const url = window.URL.createObjectURL(blob);
        const link = document.createElement("a");
        link.href = url;
        link.download = `销售出库单.docx`;
        // 模拟点击下载
        document.body.appendChild(link);
        link.click();
        // 清理临时对象
        setTimeout(() => {
          document.body.removeChild(link);
          window.URL.revokeObjectURL(url);
        }, 100);
        ElMessage.success("导出成功");
      })
      .catch(err => {
        console.error("导出失败:", err);
        ElMessage.error("导出失败,请重试");
      });
};
onMounted(() => {
   getList();
  fetchBatchNoOptions();
   userListNoPage().then(res => {
      userList.value = res.data;
   })