<template>
  <div>
    <el-card shadow="never">
      <el-form ref="queryForm" :model="queryParams" size="small" :inline="true">
        <el-form-item prop="keyword">
          <template slot="label">{{ pubT('queryKeyword') }}</template>
          <el-input
            v-model="queryParams.keyword"
            :placeholder="pubT('queryKeywordPh')"
            clearable
            style="width: 220px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item prop="execStatus">
          <template slot="label">{{ pubT('queryExecStatus') }}</template>
          <el-select v-model="queryParams.execStatus" :placeholder="$t('policy.common.pleaseSelect')" clearable style="width: 140px">
            <el-option v-for="item in execStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item prop="publishStatus">
          <template slot="label">{{ pubT('queryPublishStatus') }}</template>
          <el-select v-model="queryParams.publishStatus" :placeholder="$t('policy.common.pleaseSelect')" clearable style="width: 140px">
            <el-option :label="$t('policy.status.unpublished')" :value="0" />
            <el-option :label="$t('policy.status.published')" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item prop="startDate">
          <template slot="label">{{ pubT('queryStartDate') }}</template>
          <el-date-picker
            v-model="queryParams.startDate"
            type="date"
            value-format="yyyy-MM-dd"
            :placeholder="$t('policy.common.pleaseSelect')"
            clearable
            style="width: 150px"
          />
        </el-form-item>
        <el-form-item prop="endDate">
          <template slot="label">{{ pubT('queryEndDate') }}</template>
          <el-date-picker
            v-model="queryParams.endDate"
            type="date"
            value-format="yyyy-MM-dd"
            :placeholder="$t('policy.common.pleaseSelect')"
            clearable
            style="width: 150px"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('policy.common.search') }}</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('policy.common.reset') }}</el-button>
          <el-button
            v-hasPermi="['industryPolicy:subsidyProject:add']"
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
          >{{ $t('policy.common.add') }}</el-button>
          <el-button
            v-hasPermi="['industryPolicy:subsidyProject:remove']"
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="!ids.length"
            @click="handleDeleteBatch"
          >{{ $t('policy.common.delete') }}</el-button>
          <!-- 导出功能暂未开放
          <el-button
            v-hasPermi="['industryPolicy:subsidyProject:export']"
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
          >{{ $t('policy.common.export') }}</el-button>
          -->
        </el-form-item>
      </el-form>
    </el-card>

    <br />

    <el-card shadow="never">
      <el-table v-loading="loading" :data="tableList" border @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column :label="pubT('colProjectName')" prop="projectName" align="center" min-width="120" :show-overflow-tooltip="true" />
        <el-table-column :label="pubT('colIntro')" prop="introduction" align="center" min-width="100" :show-overflow-tooltip="true" />
        <el-table-column :label="pubT('colAmount')" align="center" width="110">
          <template slot-scope="scope">
            <span>{{ formatAmount(scope.row.investmentAmount) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="pubT('colStartDate')" prop="projectStartDate" align="center" width="110" />
        <el-table-column :label="pubT('colPlannedEnd')" prop="plannedEndDate" align="center" width="110" />
        <el-table-column :label="pubT('colExecStatus')" align="center" width="92">
          <template slot-scope="scope">
            <span>{{ execStatusLabel(scope.row.execStatus) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="pubT('colCover')" align="center" width="80">
          <template slot-scope="scope">
            <image-preview v-if="scope.row.coverFileUrl" :src="scope.row.coverFileUrl" :width="48" :height="48" />
            <span v-else>{{ $t('policy.status.dash') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('policy.common.colShelf')" align="center" width="92">
          <template slot-scope="scope">
            <span>{{ publishStatusText(scope.row.publishStatus) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('policy.common.colPub')" align="center" width="110">
          <template slot-scope="scope">
            <span>{{ scope.row.publishTime ? parseTime(scope.row.publishTime, '{y}-{m}-{d}') : $t('policy.status.dash') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('policy.common.colCreate')" align="center" width="160">
          <template slot-scope="scope">
            <span>{{ scope.row.createTime ? parseTime(scope.row.createTime) : $t('policy.status.dash') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('policy.common.colOp')" align="center" class-name="small-padding fixed-width" width="280">
          <template slot-scope="scope">
            <el-button v-hasPermi="['industryPolicy:subsidyProject:query']" type="text" size="mini" @click="handleView(scope.row)">{{ $t('policy.common.view') }}</el-button>
            <el-button v-hasPermi="['industryPolicy:subsidyProject:edit']" v-if="canEdit(scope.row)" type="text" size="mini" @click="handleEdit(scope.row)">{{ $t('policy.common.edit') }}</el-button>
            <el-button v-hasPermi="['industryPolicy:subsidyProject:remove']" v-if="canDelete(scope.row)" type="text" size="mini" @click="handleDelete(scope.row)">{{ $t('policy.common.delete') }}</el-button>
            <el-button v-hasPermi="['industryPolicy:subsidyProject:publish']" v-if="canPublish(scope.row)" type="text" size="mini" @click="handlePublish(scope.row)">{{ $t('policy.common.publish') }}</el-button>
            <el-button v-hasPermi="['industryPolicy:subsidyProject:offline']" v-if="canOffline(scope.row)" type="text" size="mini" @click="handleOffline(scope.row)">{{ $t('policy.common.offline') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

    <el-dialog :title="dialogTitle" :visible.sync="open" width="640px" append-to-body @close="cancel">
      <el-form :key="formKey" ref="form" :model="form" label-width="120px">
        <el-form-item prop="projectName" :rules="formRules.projectName">
          <template slot="label">{{ pubT('formProjectName') }}</template>
          <el-input v-model="form.projectName" :placeholder="pubT('phProjectName')" maxlength="20" show-word-limit />
        </el-form-item>
        <el-form-item prop="introduction" :rules="formRules.introduction">
          <template slot="label">{{ pubT('formIntro') }}</template>
          <el-input v-model="form.introduction" type="textarea" :rows="2" :placeholder="pubT('phIntro')" maxlength="50" show-word-limit />
        </el-form-item>
        <el-form-item prop="investmentAmount" :rules="formRules.investmentAmount">
          <template slot="label">{{ pubT('formAmount') }}</template>
          <el-input-number v-model="form.investmentAmount" :min="0.01" :precision="2" :step="1000" controls-position="right" style="width: 100%" />
        </el-form-item>
        <el-form-item prop="projectStartDate" :rules="formRules.projectStartDate">
          <template slot="label">{{ pubT('formStartDate') }}</template>
          <el-date-picker v-model="form.projectStartDate" type="date" value-format="yyyy-MM-dd" :placeholder="$t('policy.common.pleaseSelect')" style="width: 100%" />
        </el-form-item>
        <el-form-item prop="plannedEndDate" :rules="formRules.plannedEndDate">
          <template slot="label">{{ pubT('formPlannedEnd') }}</template>
          <el-date-picker v-model="form.plannedEndDate" type="date" value-format="yyyy-MM-dd" :placeholder="$t('policy.common.pleaseSelect')" style="width: 100%" />
        </el-form-item>
        <el-form-item prop="execStatus" :rules="formRules.execStatus">
          <template slot="label">{{ pubT('formExecStatus') }}</template>
          <el-select v-model="form.execStatus" :placeholder="$t('policy.common.pleaseSelect')" style="width: 100%">
            <el-option v-for="item in execStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="form.execStatus === 3" prop="actualEndDate" :rules="formRules.actualEndDate">
          <template slot="label">{{ pubT('formActualEnd') }}</template>
          <el-date-picker
            v-model="form.actualEndDate"
            type="date"
            value-format="yyyy-MM-dd"
            :placeholder="$t('policy.common.pleaseSelect')"
            :picker-options="actualEndPickerOptions"
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item prop="coverFilePath">
          <template slot="label">{{ pubT('formCover') }}</template>
          <el-upload
            list-type="picture-card"
            :class="{ hide: hideCoverUpload }"
            :action="uploadAction"
            :headers="uploadHeaders"
            :before-upload="beforeCoverUpload"
            :on-success="handleCoverUploadSuccess"
            :on-error="handleUploadHttpError"
            :on-remove="handleCoverRemove"
            :limit="1"
            :file-list="coverFileList"
          >
            <i class="el-icon-plus" />
          </el-upload>
          <div class="el-upload__tip">{{ $t('policy.common.tipCover') }}</div>
        </el-form-item>
        <!-- <el-form-item prop="remark">
          <template slot="label">{{ pubT('formRemark') }}</template>
          <el-input v-model="form.remark" type="textarea" :rows="2" maxlength="500" show-word-limit />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">{{ $t('policy.common.ok') }}</el-button>
        <el-button @click="cancel">{{ $t('policy.common.cancel') }}</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="$t('policy.common.viewTitle')" :visible.sync="viewOpen" width="620px" append-to-body>
      <el-form label-width="120px" size="small">
        <el-form-item :label="pubT('formProjectName')"><span>{{ viewRow.projectName }}</span></el-form-item>
        <el-form-item :label="pubT('formIntro')"><span>{{ viewRow.introduction || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('formAmount')"><span>{{ formatAmount(viewRow.investmentAmount) }}</span></el-form-item>
        <el-form-item :label="pubT('formStartDate')"><span>{{ viewRow.projectStartDate || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('formPlannedEnd')"><span>{{ viewRow.plannedEndDate || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('formExecStatus')"><span>{{ execStatusLabel(viewRow.execStatus) }}</span></el-form-item>
        <el-form-item :label="pubT('formActualEnd')"><span>{{ viewRow.actualEndDate || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('formCover')">
          <image-preview v-if="viewRow.coverFileUrl" :src="viewRow.coverFileUrl" :width="200" :height="120" />
          <span v-else>{{ $t('policy.status.dash') }}</span>
        </el-form-item>
        <el-form-item :label="$t('policy.common.colShelf')"><span>{{ publishStatusText(viewRow.publishStatus) }}</span></el-form-item>
        <el-form-item :label="$t('policy.common.viewPubTime')"><span>{{ viewRow.publishTime ? parseTime(viewRow.publishTime) : $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="$t('policy.common.viewOfflineTime')"><span>{{ viewRow.offlineTime ? parseTime(viewRow.offlineTime) : $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('formRemark')"><span>{{ viewRow.remark || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('viewCreateBy')"><span>{{ viewRow.createBy || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="$t('policy.common.colCreate')"><span>{{ viewRow.createTime ? parseTime(viewRow.createTime) : $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('viewUpdateBy')"><span>{{ viewRow.updateBy || $t('policy.status.dash') }}</span></el-form-item>
        <el-form-item :label="pubT('viewUpdateTime')"><span>{{ viewRow.updateTime ? parseTime(viewRow.updateTime) : $t('policy.status.dash') }}</span></el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="viewOpen = false">{{ $t('policy.common.close') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getToken } from "@/utils/auth"
import policyPublicityLocaleMixin from "@/mixins/policyPublicityLocaleMixin"
import {
  listSubsidyProject,
  getSubsidyProject,
  addSubsidyProject,
  updateSubsidyProject,
  delSubsidyProject,
  publishSubsidyProject,
  offlineSubsidyProject
} from "@/api/policy/subsidyProject"

const EXEC_DONE = 3
const PUBLISH_STATUS = { UNPUBLISHED: 0, PUBLISHED: 1 }

export default {
  name: "ProjectSubsidyProjectTab",
  mixins: [policyPublicityLocaleMixin],
  data() {
    return {
      pubNs: "subsidyProject",
      loading: false,
      open: false,
      viewOpen: false,
      viewRow: {},
      dialogEdit: false,
      formKey: 0,
      total: 0,
      tableList: [],
      ids: [],
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        keyword: undefined,
        execStatus: undefined,
        publishStatus: undefined,
        startDate: undefined,
        endDate: undefined
      },
      form: {},
      coverFileExts: ["jpg", "jpeg", "png"]
    }
  },
  computed: {
    dialogTitle() {
      return this.dialogEdit ? this.pubT("dialogEdit") : this.pubT("dialogAdd")
    },
    execStatusOptions() {
      return [1, 2, 3].map((value) => ({ label: this.pubT("execStatus" + value), value }))
    },
    formRules() {
      return {
        projectName: [
          { required: true, message: this.pubT("ruleProjectNameRequired"), trigger: "blur" },
          { min: 1, max: 20, message: this.$t("policy.common.ruleLen120"), trigger: "blur" }
        ],
        introduction: [{ max: 50, message: this.$t("policy.common.ruleIntroMax50"), trigger: "blur" }],
        investmentAmount: [
          { required: true, message: this.pubT("ruleAmountRequired"), trigger: "blur" },
          { validator: this.validateAmount, trigger: "blur" }
        ],
        projectStartDate: [{ required: true, message: this.pubT("ruleStartDateRequired"), trigger: "change" }],
        plannedEndDate: [
          { required: true, message: this.pubT("rulePlannedEndRequired"), trigger: "change" },
          { validator: this.validatePlannedEnd, trigger: "change" }
        ],
        execStatus: [{ required: true, message: this.pubT("ruleExecStatusRequired"), trigger: "change" }],
        actualEndDate: [
          { validator: this.validateActualEnd, trigger: "change" }
        ]
      }
    },
    actualEndPickerOptions() {
      return { disabledDate: (time) => time.getTime() > Date.now() }
    },
    uploadAction() {
      return process.env.VUE_APP_BASE_API + "/common/upload"
    },
    uploadHeaders() {
      return { Authorization: "Bearer " + getToken() }
    },
    coverFileList() {
      if (!this.form.coverFileUrl) {
        return []
      }
      return [{ name: "cover", url: this.form.coverFileUrl }]
    },
    hideCoverUpload() {
      return !!(this.form.coverFilePath || this.form.coverFileUrl)
    }
  },
  created() {
    this.getList()
  },
  methods: {
    execStatusLabel(val) {
      const item = this.execStatusOptions.find((o) => o.value === val)
      return item ? item.label : ""
    },
    formatAmount(val) {
      if (val == null || val === "") {
        return this.$t("policy.status.dash")
      }
      return val + " " + this.pubT("yuan")
    },
    validateAmount(rule, value, callback) {
      if (value == null || value === "" || Number(value) <= 0) {
        callback(new Error(this.pubT("ruleAmountInvalid")))
      } else {
        callback()
      }
    },
    validatePlannedEnd(rule, value, callback) {
      if (!value || !this.form.projectStartDate) {
        callback()
        return
      }
      if (value < this.form.projectStartDate) {
        callback(new Error(this.pubT("rulePlannedEndBeforeStart")))
      } else {
        callback()
      }
    },
    validateActualEnd(rule, value, callback) {
      if (this.form.execStatus !== EXEC_DONE) {
        callback()
        return
      }
      if (!value) {
        callback(new Error(this.pubT("ruleActualEndRequired")))
        return
      }
      const today = new Date()
      today.setHours(23, 59, 59, 999)
      const picked = new Date(String(value).replace(/-/g, "/"))
      if (picked.getTime() > today.getTime()) {
        callback(new Error(this.pubT("ruleActualEndFuture")))
      } else {
        callback()
      }
    },
    checkQueryDateRange() {
      const { startDate, endDate } = this.queryParams
      if (startDate && endDate && startDate > endDate) {
        this.$modal.msgError(this.pubT("ruleDateRangeInvalid"))
        return false
      }
      return true
    },
    getList() {
      if (!this.checkQueryDateRange()) {
        return
      }
      this.loading = true
      listSubsidyProject(this.queryParams)
        .then((res) => {
          this.tableList = res.rows || []
          this.total = res.total != null ? res.total : 0
        })
        .finally(() => {
          this.loading = false
        })
    },
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    resetQuery() {
      this.queryParams.keyword = undefined
      this.queryParams.execStatus = undefined
      this.queryParams.publishStatus = undefined
      this.queryParams.startDate = undefined
      this.queryParams.endDate = undefined
      this.resetForm("queryForm")
      this.handleQuery()
    },
    canEdit(row) {
      return row.publishStatus !== PUBLISH_STATUS.PUBLISHED
    },
    canDelete(row) {
      return row.publishStatus !== PUBLISH_STATUS.PUBLISHED
    },
    canPublish(row) {
      return row.publishStatus !== PUBLISH_STATUS.PUBLISHED
    },
    canOffline(row) {
      return row.publishStatus === PUBLISH_STATUS.PUBLISHED
    },
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id)
    },
    resetFormModel() {
      this.form = {
        id: undefined,
        projectName: undefined,
        introduction: undefined,
        investmentAmount: undefined,
        projectStartDate: undefined,
        plannedEndDate: undefined,
        execStatus: 1,
        actualEndDate: undefined,
        coverFileUrl: undefined,
        coverFilePath: undefined,
        remark: undefined
      }
    },
    handleAdd() {
      this.formKey += 1
      this.resetFormModel()
      this.dialogEdit = false
      this.open = true
      this.$nextTick(() => this.resetForm("form"))
    },
    handleEdit(row) {
      if (!this.canEdit(row)) {
        return
      }
      getSubsidyProject(row.id).then((res) => {
        const data = res.data || {}
        this.formKey += 1
        this.dialogEdit = true
        this.form = {
          id: data.id,
          projectName: data.projectName,
          introduction: data.introduction,
          investmentAmount: data.investmentAmount != null ? Number(data.investmentAmount) : undefined,
          projectStartDate: data.projectStartDate,
          plannedEndDate: data.plannedEndDate,
          execStatus: data.execStatus,
          actualEndDate: data.actualEndDate,
          coverFileUrl: data.coverFileUrl,
          coverFilePath: data.coverFilePath,
          remark: data.remark
        }
        this.open = true
        this.$nextTick(() => {
          if (this.$refs.form) {
            this.$refs.form.clearValidate()
          }
        })
      })
    },
    handleView(row) {
      getSubsidyProject(row.id).then((res) => {
        this.viewRow = res.data || {}
        this.viewOpen = true
      })
    },
    handleDelete(row) {
      this.$modal
        .confirm(this.$t("policy.subsidyProject.confirmDelete", { id: row.id }))
        .then(() => delSubsidyProject(row.id))
        .then(() => {
          this.$modal.msgSuccess(this.$t("policy.common.msgDelOk"))
          this.getList()
        })
        .catch(() => {})
    },
    handlePublish(row) {
      this.$modal
        .confirm(this.pubT("confirmPublish"))
        .then(() => publishSubsidyProject(row.id))
        .then(() => {
          this.$modal.msgSuccess(this.$t("policy.common.msgPubOk"))
          this.getList()
        })
        .catch(() => {})
    },
    handleOffline(row) {
      this.$modal
        .confirm(this.pubT("confirmOffline"))
        .then(() => offlineSubsidyProject(row.id))
        .then(() => {
          this.$modal.msgSuccess(this.$t("policy.common.msgOffOk"))
          this.getList()
        })
        .catch(() => {})
    },
    handleDeleteBatch() {
      if (!this.ids.length) {
        return
      }
      const hasPublished = this.tableList.some((r) => this.ids.includes(r.id) && !this.canDelete(r))
      if (hasPublished) {
        this.$modal.msgError(this.pubT("ruleCannotDeletePublished"))
        return
      }
      this.$modal
        .confirm(this.pubT("confirmDeleteBatch"))
        .then(() => delSubsidyProject(this.ids.join(",")))
        .then(() => {
          this.$modal.msgSuccess(this.$t("policy.common.msgDelOk"))
          this.getList()
        })
        .catch(() => {})
    },
    handleExport() {
      if (!this.checkQueryDateRange()) {
        return
      }
      this.download(
        "industryPolicy/subsidyProject/export",
        { ...this.queryParams },
        `subsidy_project_${new Date().getTime()}.xlsx`
      )
    },
    extOf(fileName) {
      if (!fileName || fileName.lastIndexOf(".") < 0) {
        return ""
      }
      return fileName.slice(fileName.lastIndexOf(".") + 1).toLowerCase()
    },
    beforeCoverUpload(file) {
      const ext = this.extOf(file.name)
      if (!this.coverFileExts.includes(ext)) {
        this.$modal.msgError(this.$t("policy.common.errCoverFmt"))
        return false
      }
      if (file.name.includes(",")) {
        this.$modal.msgError(this.$t("policy.common.errComma"))
        return false
      }
      if (file.size / 1024 / 1024 >= 10) {
        this.$modal.msgError(this.$t("policy.common.errCoverMb"))
        return false
      }
      this.$modal.loading(this.$t("policy.common.uploadingImg"))
      return true
    },
    handleUploadHttpError() {
      this.$modal.closeLoading()
      this.$modal.msgError(this.$t("policy.common.errUploadRetry"))
    },
    handleCoverUploadSuccess(res) {
      this.$modal.closeLoading()
      if (res.code === 200) {
        this.form.coverFileUrl = res.url
        this.form.coverFilePath = res.fileName
      } else {
        this.$modal.msgError(res.msg || this.$t("policy.common.errUploadFail"))
      }
    },
    handleCoverRemove() {
      this.form.coverFileUrl = undefined
      this.form.coverFilePath = undefined
    },
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        const payload = {
          projectName: this.form.projectName,
          introduction: this.form.introduction || undefined,
          investmentAmount: this.form.investmentAmount,
          projectStartDate: this.form.projectStartDate,
          plannedEndDate: this.form.plannedEndDate,
          execStatus: this.form.execStatus,
          coverFileUrl: this.form.coverFileUrl,
          coverFilePath: this.form.coverFilePath,
          remark: this.form.remark || undefined
        }
        if (this.form.execStatus === EXEC_DONE) {
          payload.actualEndDate = this.form.actualEndDate
        } else {
          payload.actualEndDate = undefined
        }
        if (this.dialogEdit) {
          payload.id = this.form.id
          updateSubsidyProject(payload).then(() => {
            this.$modal.msgSuccess(this.$t("policy.common.msgModOk"))
            this.open = false
            this.getList()
          })
        } else {
          addSubsidyProject(payload).then(() => {
            this.$modal.msgSuccess(this.$t("policy.common.msgAddOk"))
            this.open = false
            this.getList()
          })
        }
      })
    },
    cancel() {
      this.open = false
      this.resetFormModel()
    }
  }
}
</script>

<style scoped>
.hide ::v-deep .el-upload--picture-card {
  display: none;
}
</style>
