zhangwencui
9 天以前 da7d023c28138245b938e415b14ce9a1f094ad99
新增采购台账录入人显示有误
已修改1个文件
126 ■■■■■ 文件已修改
src/views/procurementManagement/procurementLedger/index.vue 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/procurementLedger/index.vue
@@ -54,7 +54,9 @@
      <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
        <el-button type="primary"
                   @click="openForm('add')">新增台账</el-button>
        <el-button type="primary" plain @click="handleImport">导入</el-button>
        <el-button type="primary"
                   plain
                   @click="handleImport">导入</el-button>
        <el-button @click="handleOut">导出</el-button>
        <el-button type="danger"
                   plain
@@ -96,7 +98,6 @@
                               prop="availableQuality"/>
              <el-table-column label="退货数量"
                               prop="returnQuality"/>
              <el-table-column label="税率(%)"
                               prop="taxRate"/>
              <el-table-column label="含税单价(元)"
@@ -136,8 +137,7 @@
                         width="100"
                         show-overflow-tooltip>
          <template #default="scope">
            <el-tag
                :type="getApprovalStatusType(scope.row.approvalStatus)"
            <el-tag :type="getApprovalStatusType(scope.row.approvalStatus)"
                size="small">
              {{ approvalStatusText[scope.row.approvalStatus] || '未知状态' }}
            </el-tag>
@@ -278,7 +278,15 @@
          <el-col :span="12">
            <el-form-item label="录入人:"
                          prop="recorderId">
              <el-input v-model="form.recorderName" placeholder="自动填充" disabled/>
              <el-select v-model="form.recorderId"
                         placeholder="请选择"
                         clearable
                         filterable>
                <el-option v-for="item in userList"
                           :key="item.userId"
                           :label="item.nickName"
                           :value="item.userId" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -327,8 +335,7 @@
                         :value="item.templateName">
                <div style="display: flex; justify-content: space-between; align-items: center;">
                  <span>{{ item.templateName }}</span>
                  <el-icon
                      v-if="item.id"
                  <el-icon v-if="item.id"
                      class="delete-icon"
                      @click.stop="handleDeleteTemplate(item)"
                      style="cursor: pointer; color: #f56c6c; font-size: 14px; margin-left: 8px;">
@@ -431,16 +438,13 @@
      </el-form>
    </FormDialog>
    <!-- 导入弹窗 -->
    <FormDialog
        v-model="importUpload.open"
    <FormDialog v-model="importUpload.open"
        :title="importUpload.title"
        :width="'600px'"
        @close="importUpload.open = false"
        @confirm="submitImportFile"
        @cancel="importUpload.open = false"
    >
      <el-upload
          ref="importUploadRef"
                @cancel="importUpload.open = false">
      <el-upload ref="importUploadRef"
          :limit="1"
          accept=".xlsx,.xls"
          :action="importUpload.url"
@@ -451,8 +455,7 @@
          :on-progress="importUpload.onProgress"
          :on-change="importUpload.onChange"
          :auto-upload="false"
          drag
      >
                 drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处,或<em>点击上传</em>
@@ -460,7 +463,9 @@
        <template #tip>
          <div class="el-upload__tip">
            仅支持 xls/xlsx,大小不超过 10MB。
            <el-button link type="primary" @click="downloadTemplate">下载导入模板</el-button>
            <el-button link
                       type="primary"
                       @click="downloadTemplate">下载导入模板</el-button>
          </div>
        </template>
      </el-upload>
@@ -526,12 +531,10 @@
                         placeholder="请选择"
                         clearable
                         @change="mathNum">
                <el-option
                  v-for="dict in tax_rate"
                <el-option v-for="dict in tax_rate"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
                           :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
@@ -630,13 +633,16 @@
        </el-row>
      </el-form>
    </FormDialog>
    <FileList v-if="fileListDialogVisible"  v-model:visible="fileListDialogVisible" record-type="purchase_ledger" :record-id="recordId"  />
    <FileList v-if="fileListDialogVisible"
              v-model:visible="fileListDialogVisible"
              record-type="purchase_ledger"
              :record-id="recordId" />
  </div>
</template>
<script setup>
import FormDialog from '@/components/Dialog/FormDialog.vue';
import FileListDialog from '@/components/Dialog/FileListDialog.vue';
  import FormDialog from "@/components/Dialog/FormDialog.vue";
  import FileListDialog from "@/components/Dialog/FileListDialog.vue";
  import { getToken } from "@/utils/auth";
  import pagination from "@/components/PIMTable/Pagination.vue";
  import {
@@ -649,6 +655,7 @@
  } from "vue";
  import { Search, Delete } from "@element-plus/icons-vue";
  import { ElMessageBox, ElMessage } from "element-plus";
  import { userListNoPage } from "@/api/system/user.js";
  import {
    addOrUpdateSalesLedgerProduct,
    delProduct,
@@ -670,7 +677,9 @@
    delPurchaseTemplate,
  } from "@/api/procurementManagement/procurementLedger.js";
  import useFormData from "@/hooks/useFormData.js";
  const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue"));
  const FileList = defineAsyncComponent(() =>
    import("@/components/Dialog/FileList.vue")
  );
const {proxy} = getCurrentInstance();
const { tax_rate } = proxy.useDict("tax_rate");
@@ -679,11 +688,12 @@
const selectedRows = ref([]);
const productSelectedRows = ref([]);
const modelOptions = ref([]);
  const userList = ref([]);
const productOptions = ref([]);
const salesContractList = ref([]);
const supplierList = ref([]);
const tableLoading = ref(false);
const fileListDialogVisible = ref(false)
  const fileListDialogVisible = ref(false);
const page = reactive({
  current: 1,
  size: 100,
@@ -706,7 +716,7 @@
};
// 获取审批状态标签类型
const getApprovalStatusType = (status) => {
  const getApprovalStatusType = status => {
  const typeMap = {
    1: "info",      // 待审核 - 灰色
    2: "warning",   // 审批中 - 橙色
@@ -793,7 +803,8 @@
      form.value.paymentMethod = matchedTemplate.paymentMethod;
    }
    // 模板数据中的产品字段是 productList,需要转换为 productData
    productData.value = matchedTemplate.productList || matchedTemplate.productData || [];
      productData.value =
        matchedTemplate.productList || matchedTemplate.productData || [];
  } else {
    // 未匹配到已有模板,视为新模板
    currentTemplateId.value = null;
@@ -835,7 +846,6 @@
    salesLedgerId: "",
    projectName: "",
    recorderId: "",
    recorderName: "",
    entryDate: "",
    productData: [],
    supplierName: "",
@@ -925,7 +935,7 @@
  url: import.meta.env.VITE_APP_BASE_API + "/purchase/ledger/import",
  headers: {Authorization: "Bearer " + getToken()},
  isUploading: false,
  beforeUpload: (file) => {
    beforeUpload: file => {
    const isExcel = file.name.endsWith(".xlsx") || file.name.endsWith(".xls");
    const isLt10M = file.size / 1024 / 1024 < 10;
    if (!isExcel) {
@@ -974,7 +984,11 @@
// 下载导入模板(如后端路径不同,可在此处调整)
const downloadTemplate = () => {
  proxy.download("/purchase/ledger/exportTemplate", {}, "采购台账导入模板.xlsx");
    proxy.download(
      "/purchase/ledger/exportTemplate",
      {},
      "采购台账导入模板.xlsx"
    );
};
const submitImportFile = () => {
@@ -1039,8 +1053,8 @@
  // 检查是否有产品数据
  if (!productData.value || productData.value.length === 0) {
    ElMessage({
      message: '请先添加产品信息',
      type: 'warning',
        message: "请先添加产品信息",
        type: "warning",
    });
    return;
  }
@@ -1051,11 +1065,15 @@
      supplierId: form.value.supplierId,
      paymentMethod: form.value.paymentMethod,
      recorderId: form.value.recorderId,
      recorderName: form.value.recorderName,
      projectName: form.value.projectName,
      templateName: templateName.value.trim(),
    };
    console.log("template params ===>", params, "currentTemplateId:", currentTemplateId.value);
      console.log(
        "template params ===>",
        params,
        "currentTemplateId:",
        currentTemplateId.value
      );
    // 如果 currentTemplateId 有值,说明当前是“编辑已有模板” → 调用更新接口
    // 否则为“新建模板” → 调用新增接口
@@ -1196,6 +1214,9 @@
  }
  await getTemplateList();
    await userListNoPage().then(res => {
      userList.value = res.data;
    });
  operationType.value = type;
  form.value = {};
  productData.value = [];
@@ -1216,8 +1237,6 @@
        item => item.isWhite === 0
    );
    // 设置默认值
    form.value.recorderName = userStore.nickName;
    form.value.entryDate = getCurrentDate();
    if (type === "add") {
@@ -1385,14 +1404,20 @@
            return nodes[i].value;
          }
          if (nodes[i].children && nodes[i].children.length > 0) {
            const found = findProductIdByCategory(nodes[i].children, categoryName);
              const found = findProductIdByCategory(
                nodes[i].children,
                categoryName
              );
            if (found) return found;
          }
        }
        return null;
      };
      const productId = findProductIdByCategory(productOptions.value, productForm.value.productCategory);
        const productId = findProductIdByCategory(
          productOptions.value,
          productForm.value.productCategory
        );
      if (productId) {
        productForm.value.productId = productId;
        // 获取型号列表并等待完成
@@ -1403,7 +1428,10 @@
        await nextTick();
        // 根据 specificationModel 查找 productModelId
        if (productForm.value.specificationModel && modelOptions.value.length > 0) {
          if (
            productForm.value.specificationModel &&
            modelOptions.value.length > 0
          ) {
          const modelItem = modelOptions.value.find(
              item => item.model === productForm.value.specificationModel
          );
@@ -1550,11 +1578,9 @@
          delProduct(ids).then(res => {
            proxy.$modal.msgSuccess("删除成功");
            closeProductDia();
            getPurchaseById({id: currentId.value, type: 2}).then(
                res => {
            getPurchaseById({ id: currentId.value, type: 2 }).then(res => {
                  productData.value = res.productData;
                }
            );
            });
          });
        })
        .catch(() => {
@@ -1585,7 +1611,9 @@
const handleDelete = () => {
  let ids = [];
  if (selectedRows.value.length > 0) {
    ids = selectedRows.value.filter(item => item.salesLedgerId === null).map(item => item.id);
      ids = selectedRows.value
        .filter(item => item.salesLedgerId === null)
        .map(item => item.id);
  } else {
    proxy.$modal.msgWarning("请选择数据");
    return;
@@ -1756,13 +1784,13 @@
};
// 打开附件弹框
const openFileDialog = async (row) => {
  recordId.value = row.id
  fileListDialogVisible.value = true
}
  const openFileDialog = async row => {
    recordId.value = row.id;
    fileListDialogVisible.value = true;
  };
// 删除模板
const handleDeleteTemplate = async (item) => {
  const handleDeleteTemplate = async item => {
  if (!item.id) {
    proxy.$modal.msgWarning("无法删除该模板");
    return;