chenrui
2025-06-09 bf6d13fdf5ba7dd4dd2533e62f95f529b272a31e
src/views/salesManagement/invoiceLedger/index.vue
@@ -42,7 +42,7 @@
        <el-table-column label="产品大类" prop="productCategory" />
        <el-table-column label="规格型号" prop="specificationModel" />
        <el-table-column label="发票号" prop="invoiceNo" show-overflow-tooltip/>
        <el-table-column label="发票金额(元)" prop="invoiceTotal" show-overflow-tooltip/>
        <el-table-column label="发票金额(元)" prop="invoiceTotal" show-overflow-tooltip :formatter="formattedNumber"/>
        <el-table-column label="税率" prop="taxRate" show-overflow-tooltip/>
        <el-table-column label="开票人" prop="invoicePerson" show-overflow-tooltip/>
        <el-table-column label="开票日期" prop="invoiceDate" show-overflow-tooltip/>
@@ -90,7 +90,7 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="开票人:" prop="invoicePerson">
              <el-input v-model="form.invoicePerson" placeholder="请输入" clearable/>
              <el-input v-model="form.invoicePerson" placeholder="请输入" clearable disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -103,6 +103,7 @@
                  type="date"
                  placeholder="请选择"
                  clearable
                  disabled
              />
            </el-form-item>
          </el-col>
@@ -143,7 +144,7 @@
        </div>
      </template>
    </el-dialog>
    <el-dialog title="上传弹窗" width="20%" v-model="uploadModal">
    <el-dialog title="上传弹窗" width="50%" v-model="uploadModal">
      <el-row :gutter="30">
        <el-col :span="24">
          <el-form-item label="附件材料:" prop="remark">
@@ -156,6 +157,7 @@
                :headers="upload.headers"
                accept=".pdf"
                :limit="1"
                style="width: 100%"
                :on-exceed="handleExceed"
                :before-upload="handleBeforeUpload"
                :on-error="handleUploadError"
@@ -194,6 +196,7 @@
  commitFile,
  registrationProductPage
} from "../../../api/salesManagement/invoiceLedger.js";
import useUserStore from "@/store/modules/user.js";
const { proxy } = getCurrentInstance()
const tableData = ref([])
const productData = ref([])
@@ -201,7 +204,7 @@
const tableLoading = ref(false)
const page = reactive({
  current: 1,
  size: 10,
  size: 100,
})
const total = ref(0)
const fileList = ref([])
@@ -235,6 +238,7 @@
})
const { searchForm, form, rules } = toRefs(data)
const currentId = ref('')
const userStore = useUserStore()
const upload = reactive({
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/invoiceLedger/uploadFile",
@@ -243,15 +247,18 @@
})
const matchFileType = ref(['pdf'])
const uploadModal = ref(false)
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
};
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
  page.current = 1
  getList()
}
const paginationChange = ({ current, limit }) => {
  page.current = current;
  page.size = limit;
const paginationChange = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
  getList()
}
const getList = () => {
@@ -268,26 +275,10 @@
}
// 主表合计方法
const summarizeMainTable = (param) => {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = '合计';
      return;
    }
    const prop = column.property;
    if (['invoiceAmount'].includes(prop)) {
      const values = data.map(item => Number(item[prop]));
      if (!values.every(value => isNaN(value))) {
        sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0);
      } else {
        sums[index] = '';
      }
    } else {
      sums[index] = '';
    }
  })
  return sums;
  return proxy.summarizeTable(param, ['invoiceTotal'], {
    ticketsNum: { noDecimal: true }, // 不保留小数
    futureTickets: { noDecimal: true }, // 不保留小数
  });
};
// 打开弹框
const openForm = (row) => {
@@ -295,9 +286,17 @@
  productData.value = []
  fileList.value = []
  currentId.value = row.id;
  invoiceLedgerProductInfo({id: row.id}).then(res => {
    form.value = {...res.data}
    fileList.value = res.data.fileList;
    if(!form.value.invoicePerson){
      form.value.invoicePerson = userStore.nickName
      form.value.entryDate = getCurrentDate();
    }
    if(!form.value.invoiceDate){
      form.value.invoiceDate = getCurrentDate();
    }
  })
  dialogFormVisible.value = true
}
@@ -408,6 +407,15 @@
}
// 获取当前日期并格式化为 YYYY-MM-DD
function getCurrentDate() {
  const today = new Date();
  const year = today.getFullYear();
  const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始
  const day = String(today.getDate()).padStart(2, '0');
  return `${year}-${month}-${day}`;
}
getList()
</script>