yxh
4 天以前 48118e7c69c14b86b06abbabb4c910cb59c12cfa
src/views/project/invoice/index.vue
@@ -27,7 +27,7 @@
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报销状态" prop="reimburseState">
      <el-form-item v-if="!selectMode" label="报销状态" prop="reimburseState">
        <el-select
          v-model="queryParams.reimburseState"
          placeholder="请选择报销状态"
@@ -54,7 +54,7 @@
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
      <el-col v-if="!selectMode" :span="1.5">
        <el-button
          type="primary"
          plain
@@ -72,7 +72,7 @@
    </el-row>
    <!-- 手机端:卡片列表 -->
    <div v-if="isMobile" class="invoice-cards" v-loading="loading">
    <div v-if="isMobile && !selectMode" class="invoice-cards" v-loading="loading">
      <div
        v-for="row in invoiceList"
        :key="row.id"
@@ -151,7 +151,21 @@
      </div>
    </div>
    <el-table v-else v-loading="loading" border :data="invoiceList">
    <el-table
      v-else
      v-loading="loading"
      border
      row-key="id"
      :data="invoiceList"
      @selection-change="handleInvoiceSelectionChange"
    >
      <el-table-column
        v-if="selectMode"
        type="selection"
        width="50"
        align="center"
        :reserve-selection="true"
      />
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column label="案例" align="center" prop="caseId"  width="100">
        
@@ -220,28 +234,30 @@
            @click="openPreview(scope.row.invoiceUrl, scope.row.invoiceName)"
            >文件预览</el-button
          >
          <el-button
            v-if="String(scope.row.reimburseState) !== '1'"
            type="text"
            icon="el-icon-check"
            @click="handleReimburse(scope.row)"
            v-hasPermi="['project:invoice:edit']"
            >已报销</el-button
          >
          <el-button
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['project:invoice:edit']"
            >修改</el-button
          >
          <el-button
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['project:invoice:remove']"
            >删除</el-button
          >
          <template v-if="!selectMode">
            <el-button
              v-if="String(scope.row.reimburseState) !== '1'"
              type="text"
              icon="el-icon-check"
              @click="handleReimburse(scope.row)"
              v-hasPermi="['project:invoice:edit']"
              >已报销</el-button
            >
            <el-button
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['project:invoice:edit']"
              >修改</el-button
            >
            <el-button
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['project:invoice:remove']"
              >删除</el-button
            >
          </template>
        </template>
      </el-table-column>
    </el-table>
@@ -253,6 +269,20 @@
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <div v-if="selectMode" class="invoice-select-footer">
      <span class="invoice-select-footer__tip">
        已选择 {{ selectedInvoices.length }} 张发票
      </span>
      <el-button size="mini" @click="$emit('cancel')">取 消</el-button>
      <el-button
        type="primary"
        size="mini"
        :disabled="!selectedInvoices.length"
        @click="confirmSelect"
        >确定选择</el-button
      >
    </div>
    <!-- 上传发票 / 发票信息确认 -->
    <el-dialog
@@ -281,7 +311,11 @@
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="凭证">
                <el-checkbox v-model="uploadForm.voucher">凭证</el-checkbox>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="发票文件">
            <el-upload
@@ -373,10 +407,30 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="发票类型" prop="invoiceType">
              <el-input
              <el-select
                v-model="form.invoiceType"
                placeholder="请输入发票类型"
              />
                placeholder="请选择发票类型"
                filterable
                clearable
                style="width: 100%"
              >
                <el-option
                  v-for="item in invoiceTypeOptions"
                  :key="item"
                  :label="item"
                  :value="item"
                />
                <!-- OCR 识别出的其它类型保留回显,避免直接丢失 -->
                <el-option
                  v-if="
                    form.invoiceType &&
                    invoiceTypeOptions.indexOf(form.invoiceType) === -1
                  "
                  :key="form.invoiceType"
                  :label="form.invoiceType"
                  :value="form.invoiceType"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -554,6 +608,13 @@
export default {
  name: "ServiceInvoice",
  props: {
    // 作为其他单据的发票选择器嵌入时传 true:显示多选列,仅展示未报销发票
    selectMode: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      // 遮罩层
@@ -564,6 +625,8 @@
      total: 0,
      // 发票列表
      invoiceList: [],
      // 选择模式下已勾选的发票
      selectedInvoices: [],
      // 弹窗
      open: false,
      // upload:上传发票;edit:识别结果确认
@@ -579,7 +642,9 @@
      },
      // 上传阶段表单(用户ID取当前登录用户,不在此处编辑)
      uploadForm: {
        caseId: ""
        caseId: "",
        // 勾选后传 voucher=1,后端按“凭证”处理
        voucher: false
      },
      uploadRules: {
       
@@ -588,6 +653,21 @@
      uploadedList: [],
      // 正在上传的文件数,用于判断一批上传是否结束
      uploadingCount: 0,
      // 发票类型下拉选项
      invoiceTypeOptions: [
        "交通费",
        "市内交通费",
        "住宿费",
        "伙食补助",
        "公杂费补助",
        "其他费用",
        "医护团队专家费",
        "评估专家费",
        "转运护理劳务费",
        "获取专家劳务费",
        "伦理审核专家费",
        "凭证"
      ],
      // 识别结果 / 修改表单
      form: {},
      rules: {
@@ -622,7 +702,8 @@
    uploadData() {
      return {
        userId: this.currentUserId,
        caseId: this.uploadForm.caseId
        caseId: this.uploadForm.caseId,
        voucher: this.uploadForm.voucher ? "1" : "0"
      };
    }
  },
@@ -634,7 +715,11 @@
    /** 查询发票列表 */
    getList() {
      this.loading = true;
      this.queryParams.userId=this.currentUserId
      this.queryParams.userId = this.currentUserId;
      // 选择模式只允许引用未报销发票,避免同一张发票重复报销
      if (this.selectMode) {
        this.queryParams.reimburseState = "0";
      }
      listInvoice(this.queryParams)
        .then(response => {
          this.invoiceList = response.rows;
@@ -693,9 +778,24 @@
    resetQuery() {
      this.queryParams.caseId = "";
      this.queryParams.invoiceName = "";
      this.queryParams.reimburseState = "";
      this.queryParams.reimburseState = this.selectMode ? "0" : "";
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 选择模式:记录勾选的发票 */
    handleInvoiceSelectionChange(selection) {
      this.selectedInvoices = selection;
    },
    /** 选择模式:把勾选的发票交给调用方 */
    confirmSelect() {
      if (!this.selectedInvoices.length) {
        this.$modal.msgWarning("请先勾选需要引用的发票");
        return;
      }
      this.$emit(
        "confirm",
        this.selectedInvoices.map(row => Object.assign({}, row))
      );
    },
    /** 上传发票按钮操作 */
    async handleUpload() {
@@ -703,7 +803,8 @@
        await this.getCurrentUser();
      }
      this.uploadForm = {
        caseId: ""
        caseId: "",
        voucher: false
      };
      this.uploadedList = [];
      this.uploadingCount = 0;
@@ -744,6 +845,8 @@
      this.getList();
      if (!invoiceList.length) {
        this.$modal.msgWarning("该文件未识别到发票信息,请确认文件清晰");
      } else if (this.uploadForm.voucher) {
        this.$modal.msgSuccess("凭证上传成功");
      } else {
        this.$modal.msgSuccess(
          "发票上传成功,识别到 " + invoiceList.length + " 张发票"
@@ -786,7 +889,7 @@
        remark: record.remark
      };
      this.mode = "edit";
      this.title = "发票信息确认";
      this.title = record.invoiceType === "凭证" ? "凭证信息确认" : "发票信息确认";
      this.open = true;
      this.refreshThumb();
    },
@@ -1057,6 +1160,19 @@
  color: #909399;
}
.invoice-select-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 0 0;
  &__tip {
    margin-right: 16px;
    font-size: 13px;
    color: #606266;
  }
}
/* 手机端适配 */
@media (max-width: 992px) {
  .app-container {