
const queryStore = defineStore('query', {
  state: () => ({
    searchPositionParams: null,
    reviseBathParams: null,
    reportPlanParams: null,
    reportParams: null,
    rejectReportParams: null,
    sortRejectParams: null,
    rejectCategoryParams: null,
    rejectDetailParams: null,
    electronicDrawingParams: null
  }),
  actions: {
    setSearchPositionParams(value) {
      this.searchPositionParams = value;
    },
    setReviseBathParams(value) {
      this.reviseBathParams = value
    },
    setReportPlanParams(value) {
      this.reportPlanParams = value
    },
    setReportParams(value) {
      this.reportParams = value
    },
    setRejectReportParams(value) {
      this.rejectReportParams = value
    },
    setSortRejectParams(value) {
      this.sortRejectParams = value
    },
    setRejectCategoryParams(value) {
      this.rejectCategoryParams = value
    },
    setRejectDetailParams(value) {
      // console.log(value)
      this.rejectDetailParams = value
    },
    setElectronicDrawingParams(value) {
      this.electronicDrawingParams = value
    },
    cleanRejectDetailParams() {
      if (this.rejectDetailParams != null) {
        this.rejectDetailParams.code = ''
        this.rejectDetailParams.isAbandoned = null
      }
    },
    setRejectDetailParamsName(name) {
      console.log(this.rejectCategoryParams)
      this.rejectCategoryParams = this.v != null ? { ...this.v, name: name } : { name: name }

    },
    checkClean(obj) {
      console.log(obj.name)
      if (obj.name == 'SearchPosition') {
        this.searchPositionParams = null
      }
      if (obj.name == 'ReviseBath') {
        this.reviseBathParams = null
      }
      if (obj.name == 'ReportPlan') {
        this.reportPlanParams = null
      }
      if (obj.name == 'Report') {
        this.reportParams = null
      }
      if (obj.name == 'RejectReport') {
        this.rejectReportParams = null
      }
      if (obj.name == 'SortReject') {
        this.sortRejectParams = null
      }
      if (obj.name == 'Reject') {
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
      }
      if (obj.name == 'ElectronicDrawings') {
        this.electronicDrawingParams = null
      }
    },
    allClean() {
      this.searchPositionParams = null
      this.reviseBathParams = null
      this.reportPlanParams = null
      this.reportParams = null
      this.rejectReportParams = null
      this.sortRejectParams = null
      this.rejectDetailParams = null
      this.rejectCategoryParams = null
      this.electronicDrawingParams = null
    },
    otherClean(obj) {
      if (obj.name == 'SearchPosition') {
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null

      } else if (obj.name == 'ReviseBath') {
        this.searchPositionParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null
      }
      else if (obj.name == 'ReportPlan') {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null
      }
      else if (obj.name == 'Report') {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null
      }
      else if (obj.name == 'RejectReport') {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null
      }
      else if (obj.name == 'SortReject') {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null
      }
      else if (obj.name == 'Reject') {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.electronicDrawingParams = null
      } else if (obj.name == 'ElectronicDrawings') {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
      } else {
        this.searchPositionParams = null
        this.reviseBathParams = null
        this.reportPlanParams = null
        this.reportParams = null
        this.rejectReportParams = null
        this.sortRejectParams = null
        this.rejectDetailParams = null
        this.rejectCategoryParams = null
        this.electronicDrawingParams = null
      }
    }
  }
})

export default queryStore
