src/views/financialManagement/payable/paymentApply.vue
@@ -73,7 +73,7 @@
        <template #operation="{ row }">
          <el-button type="primary" link @click="view(row)">查看</el-button>
          <el-button type="primary" link @click="edit(row)" v-if="isPendingStatus(row.status)">编辑</el-button>
          <el-button type="success" link @click="handleAudit(row)" v-if="isPendingStatus(row.status)">审核</el-button>
          <el-button type="success" link :disabled="!canAudit(row)" @click="handleAudit(row)" v-if="isPendingStatus(row.status)">审核</el-button>
          <el-button type="warning" link @click="openPaymentDialog(row)" v-if="isApprovedStatus(row.status)">付款</el-button>
          <el-button type="danger" link @click="handleDelete(row)" v-if="isPendingStatus(row.status)">删除</el-button>
        </template>
@@ -213,6 +213,52 @@
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注" :disabled="isView" />
        </el-form-item>
        <div class="form-section-title">创建采购付款</div>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="款项用途" prop="paymentPurpose">
              <el-select v-model="form.paymentPurpose" placeholder="请选择款项用途" clearable style="width: 100%" :disabled="isView">
                <el-option label="采购货款" value="采购货款" />
                <el-option label="运费" value="运费" />
                <el-option label="押金" value="押金" />
                <el-option label="服务费" value="服务费" />
                <el-option label="其他" value="其他" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="projectName">
              <el-input v-model="form.projectName" placeholder="请输入项目名称" clearable :disabled="isView" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="经办人" prop="operatorName">
              <el-input v-model="form.operatorName" placeholder="请输入经办人" clearable :disabled="isView" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="财务审核" prop="financeAuditorId">
              <el-select
                v-model="form.financeAuditorId"
                placeholder="请选择审核人员"
                clearable
                filterable
                style="width: 100%"
                :disabled="isView"
                @change="handleFinanceAuditorChange"
              >
                <el-option
                  v-for="item in userList"
                  :key="item.userId"
                  :label="item.nickName"
                  :value="item.userId"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template v-if="!isView" #footer>
        <el-button type="primary" :loading="submitLoading" @click="submitForm">确定</el-button>
@@ -368,6 +414,8 @@
  deleteAccountPaymentApplication,
} from "@/api/financialManagement/accountPaymentApplication.js";
import { addAccountPurchasePayment } from "@/api/financialManagement/accountPurchasePayment.js";
import { userListNoPageByTenantId } from "@/api/system/user.js";
import useUserStore from "@/store/modules/user";
defineOptions({
  name: "付款申请",
@@ -375,6 +423,7 @@
const { proxy } = getCurrentInstance();
const { checkout_payment } = proxy.useDict("checkout_payment");
const userStore = useUserStore();
const filters = reactive({
  invoiceApplicationNo: "",
@@ -395,6 +444,8 @@
  { label: "付款金额", prop: "amount", dataType: "slot", slot: "amount" },
  { label: "付款方式", prop: "paymentMethod", dataType: "slot", slot: "paymentMethod", width: "120" },
  { label: "申请日期", prop: "applyDate", width: "120" },
  { label: "款项用途", prop: "paymentPurpose", width: "120" },
  { label: "财务审核", prop: "financeAuditor", width: "120" },
  { label: "状态", prop: "status", dataType: "slot", slot: "status", width: "100" },
  { label: "操作", prop: "operation", dataType: "slot", slot: "operation", width: "260", fixed: "right" },
];
@@ -409,6 +460,7 @@
const submitLoading = ref(false);
const currentId = ref(null);
const supplierList = ref([]);
const userList = ref([]);
const inboundBatchList = ref([]);
const inboundBatchOptions = ref([]);
@@ -457,6 +509,11 @@
  inboundBatches: "",
  status: 0,
  createTime: "",
  paymentPurpose: "",
  projectName: "",
  operatorName: "",
  financeAuditor: "",
  financeAuditorId: null,
});
const formCreateTimeDate = computed({
  get: () => (form.createTime ? String(form.createTime).split(" ")[0] : ""),
@@ -477,6 +534,10 @@
  paymentAmount: [{ required: true, message: "请输入付款金额", trigger: "blur" }],
  paymentMethod: [{ required: true, message: "请选择付款方式", trigger: "change" }],
  applyDate: [{ required: true, message: "请选择申请日期", trigger: "change" }],
  paymentPurpose: [{ required: true, message: "请选择款项用途", trigger: "change" }],
  projectName: [{ required: true, message: "请输入项目名称", trigger: "blur" }],
  operatorName: [{ required: true, message: "请输入经办人", trigger: "blur" }],
  financeAuditorId: [{ required: true, message: "请选择财务审核人员", trigger: "change" }],
};
const getSummaries = ({ columns, data }) => {
@@ -509,6 +570,15 @@
};
const isPendingStatus = (status) => normalizeStatus(status) === 0;
// 审核权限:指定了财务审核人时仅本人可审核;未指定时保持原逻辑(谁都能审)
const canAudit = (row) => {
  const auditorId = row.financeAuditorId;
  if (auditorId == null || auditorId === "") {
    return true;
  }
  return Number(userStore.id) === Number(auditorId);
};
const isApprovedStatus = (status) => normalizeStatus(status) === 1;
@@ -610,6 +680,11 @@
const fillFormFromRow = (row) => {
  const stockInRecordIds = parseStockInRecordIds(row.stockInRecordIds);
  // 审核人已不在用户列表时,用已保存的姓名补进下拉,保证查看/编辑显示名字而非裸ID
  const auditorId = row.financeAuditorId ?? null;
  if (auditorId != null && !userList.value.some((u) => u.userId === auditorId)) {
    userList.value.push({ userId: auditorId, nickName: row.financeAuditor ?? `用户${auditorId}` });
  }
  Object.assign(form, {
    invoiceApplicationNo: row.invoiceApplicationNo ?? row.applyCode ?? "",
    supplierId: row.supplierId,
@@ -622,6 +697,11 @@
    inboundBatches: formatInboundBatches(row.inboundBatches),
    status: normalizeStatus(row.status),
    createTime: row.createTime ?? "",
    paymentPurpose: row.paymentPurpose ?? "",
    projectName: row.projectName ?? "",
    operatorName: row.operatorName ?? "",
    financeAuditor: row.financeAuditor ?? "",
    financeAuditorId: row.financeAuditorId ?? null,
  });
};
@@ -654,6 +734,11 @@
    status: 0,
    paymentAmount: form.paymentAmount,
    createTime: form.createTime,
    paymentPurpose: form.paymentPurpose || "",
    projectName: form.projectName || "",
    operatorName: form.operatorName || "",
    financeAuditor: form.financeAuditor || "",
    financeAuditorId: form.financeAuditorId ?? null,
  };
  if (forUpdate) {
    payload.id = currentId.value;
@@ -666,6 +751,18 @@
    if (res.code === 200) {
      supplierList.value = res.data ?? [];
    }
  });
};
// 财务审核人员选择:绑定系统用户,选中后带出姓名
const handleFinanceAuditorChange = (userId) => {
  const user = userList.value.find((item) => item.userId === userId);
  form.financeAuditor = user?.nickName ?? "";
};
const getUserList = () => {
  userListNoPageByTenantId().then((res) => {
    userList.value = res.data ?? [];
  });
};
@@ -765,6 +862,11 @@
    inboundBatches: "",
    status: 0,
    createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
    paymentPurpose: "",
    projectName: "",
    operatorName: "",
    financeAuditor: "",
    financeAuditorId: null,
  });
  inboundBatchList.value = [];
  inboundBatchOptions.value = [];
@@ -1058,11 +1160,23 @@
onMounted(() => {
  getSupplierList();
  getUserList();
  getTableData();
});
</script>
<style lang="scss" scoped>
.form-section-title {
  margin: 18px 0 14px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #1d6fd8;
  background: linear-gradient(90deg, rgba(64, 158, 255, 0.14), rgba(64, 158, 255, 0.02));
  border-left: 4px solid #409eff;
  border-radius: 3px;
}
.actions {
  display: flex;
  justify-content: space-between;