{"version":3,"file":"form-base2.mjs","names":[],"sources":["../../../../../../packages/components/form-base/src/form-base.vue"],"sourcesContent":["<template>\n  <div :class=\"[ns.b()]\">\n    <div\n      v-if=\"props.noSearchForm\"\n      class=\"el-form-base-head el-form-base-search\"\n    >\n      <div class=\"el-form-base-inline-box\">\n        <el-form\n          v-if=\"props.noSearchFormLeft\"\n          ref=\"formInlineRef\"\n          :inline=\"true\"\n          :model=\"props.formInline\"\n          label-suffix=\"\"\n          :is-search=\"true\"\n          @submit.prevent\n        >\n          <template v-if=\"searchConditionArr.length === 0\">\n            <slot name=\"searchForm\" :form-inline=\"props.formInline\" />\n          </template>\n          <template v-if=\"searchConditionArr.length > 0\">\n            <el-form-item\n              v-for=\"(item, index) in searchConditionArr\"\n              :key=\"index\"\n              :label=\"item.label\"\n              :prop=\"item.prop\"\n            >\n              <component\n                :is=\"item.searchType\"\n                v-model=\"props.formInline[item.prop]\"\n                :code=\"item.searchValue\"\n              />\n            </el-form-item>\n          </template>\n          <el-form-item v-if=\"props.hasFlow\" label=\"流程状态\">\n            <el-select\n              v-model=\"approvalStatus\"\n              :style=\"getFlowWidth\"\n              :clearable=\"true\"\n              @change=\"handleChangeFlowStatus\"\n            >\n              <el-option\n                v-for=\"item in getFlowStatus\"\n                :key=\"item.value\"\n                :value=\"item.value\"\n                :label=\"item.label\"\n              />\n            </el-select>\n          </el-form-item>\n          <el-form-item v-if=\"props.noFormInlineBtn\">\n            <slot name=\"searchLeft\" />\n            <el-button\n              v-if=\"props.noSearch\"\n              :type=\"searchTypeStr\"\n              :icon=\"Search\"\n              native-type=\"submit\"\n              @click=\"search\"\n              >{{ localeSearchBtnText }}</el-button\n            >\n            <el-button\n              v-if=\"props.noClear\"\n              :type=\"clearTypeStr\"\n              :icon=\"Delete\"\n              @click=\"clear\"\n              >{{ localeClearBtnText }}</el-button\n            >\n            <slot name=\"searchRight\" />\n          </el-form-item>\n        </el-form>\n      </div>\n      <div\n        v-if=\"props.noOperation && !isButtonAreaType\"\n        class=\"el-form-base-inline-operation\"\n      >\n        <el-button\n          v-if=\"hiddenAddBtn\"\n          :icon=\"Plus\"\n          :type=\"addTypeStr\"\n          @click=\"add\"\n          >{{ localeAddBtnText }}</el-button\n        >\n        <el-button\n          v-if=\"hiddenEditBtn\"\n          :icon=\"EditPen\"\n          :type=\"updateTypeStr\"\n          @click=\"update\"\n          >{{ localeEditBtnText }}</el-button\n        >\n        <el-button\n          v-if=\"hiddenDelBtn\"\n          :icon=\"Delete\"\n          :type=\"deleteTypeStr\"\n          @click=\"del\"\n          >{{ localeDelBtnText }}</el-button\n        >\n        <slot name=\"toolbar\" />\n        <el-button\n          v-if=\"hiddenBatchBtn\"\n          :icon=\"Delete\"\n          :type=\"batchDelTypeStr\"\n          @click=\"batchDel\"\n          >{{ localeBatchBtnText }}</el-button\n        >\n        <template v-if=\"props.noExpandsBtn\">\n          <el-button\n            v-show=\"props.rowKey && !tableDefaultExpandAll\"\n            class=\"el-form-base-expand-btn\"\n            :type=\"expandTypeStr\"\n            :icon=\"DArrowRight\"\n            @click=\"handleToggleExpand\"\n          >\n            {{ localeExpandBtnText }}\n          </el-button>\n          <el-button\n            v-show=\"props.rowKey && tableDefaultExpandAll\"\n            :type=\"expandTypeStr\"\n            class=\"el-form-base-fold-btn\"\n            :icon=\"DArrowRight\"\n            @click=\"handleToggleExpand\"\n          >\n            {{ localeFoldBtnText }}\n          </el-button>\n        </template>\n      </div>\n    </div>\n    <slot name=\"tabList\" />\n    <div class=\"el-form-base-body\">\n      <div\n        v-if=\"props.noOperation && isButtonAreaType\"\n        class=\"el-form-base-operation\"\n      >\n        <div class=\"el-form-base-operation-left\">\n          <el-button v-if=\"hiddenAddBtn\" :type=\"addTypeStr\" :icon=\"Plus\">{{\n            localeAddBtnText\n          }}</el-button>\n          <el-button\n            v-if=\"hiddenEditBtn\"\n            :type=\"updateTypeStr\"\n            :icon=\"EditPen\"\n            >{{ localeEditBtnText }}</el-button\n          >\n          <el-button v-if=\"hiddenDelBtn\" :type=\"deleteTypeStr\" :icon=\"Delete\">{{\n            localeDelBtnText\n          }}</el-button>\n          <slot name=\"toolbar\" />\n          <el-button\n            v-if=\"hiddenBatchBtn\"\n            :type=\"batchDelTypeStr\"\n            :icon=\"Delete\"\n            >{{ localeBatchBtnText }}</el-button\n          >\n        </div>\n        <div v-if=\"props.noRefreshBtn\" class=\"el-form-base-operation-right\" />\n      </div>\n      <slot name=\"table\">\n        <form-base-table\n          ref=\"peTable\"\n          v-if=\"isShowDataTable\"\n          v-loading=\"tableLoading\"\n          element-loading-text=\"正在加载中...\"\n          :row-key=\"props.rowKey\"\n          :primary-key=\"props.primaryKey\"\n          :row-single=\"props.rowSingle\"\n          :columns=\"getColumns\"\n          :table-data=\"tableData\"\n          :pagination=\"pagination\"\n          :no-batch-btn=\"props.noBatchBtn\"\n          :no-pagination=\"props.noPagination\"\n          :no-table-index=\"props.noTableIndex\"\n          :table-lazy=\"props.tableLazy\"\n          :is-virtually-table=\"props.isVirtuallyTable\"\n          :table-transform=\"props.tableTransform\"\n          :selection-width=\"props.selectionWidth\"\n          :selection-align=\"props.selectionAlign\"\n          :selection-fixed=\"props.selectionFixed\"\n          :index-width=\"props.indexWidth\"\n          :index-align=\"props.indexAlign\"\n          :index-fixed=\"props.indexFixed\"\n          :span-method=\"props.spanMethod\"\n          :default-expand-all=\"tableDefaultExpandAll\"\n          :table-load=\"handleTableLoad\"\n          :row-class-name=\"props.rowClassName\"\n          :cell-class-name=\"props.cellClassName\"\n          @size-change=\"handleSizeChange\"\n          @current-change=\"handleCurrentChange\"\n          @table-current-change=\"handleTableCurrentChange\"\n          @table-selection-change=\"handleTableSelectionChange\"\n          @table-row-dblclick=\"handleRowDblclick\"\n          @click-info=\"handleClickInfo\"\n          @table-sort-change=\"handleTableSortChange\"\n        >\n          <template #tableWarp>\n            <slot name=\"tableWarp\" />\n          </template>\n        </form-base-table>\n      </slot>\n    </div>\n\n    <template v-if=\"props.dialogType === 'dialog'\">\n      <el-dialog\n        v-model=\"dialogVisible\"\n        :title=\"dialogTitle\"\n        :close-on-click-modal=\"false\"\n        :width=\"props.dialogWidth\"\n        :before-close=\"beforeClose\"\n        modal-class=\"form-base-dialog\"\n        draggable\n      >\n        <slot name=\"addWarp\">\n          <el-form\n            ref=\"addFormRef\"\n            :model=\"cloneAddForm\"\n            :rules=\"props.rules\"\n            :label-width=\"props.labelWidth\"\n            status-icon\n            :disabled=\"addFormDisabled\"\n            :validateOnRuleChange=\"props.validateOnRuleChange\"\n          >\n            <slot name=\"add\" :add-form=\"cloneAddForm\" />\n          </el-form>\n        </slot>\n        <template #footer>\n          <span class=\"dialog-footer\">\n            <slot name=\"dialog-footer-left\" />\n            <el-button\n              v-if=\"props.noCancelBtn\"\n              :type=\"cancelTypeStr\"\n              @click=\"beforeClose()\"\n              >{{ t('el.formBase.cancel') }}</el-button\n            >\n            <slot name=\"dialog-footer-center\" />\n            <template v-if=\"!hasFlow\">\n              <el-button\n                v-if=\"!addFormDisabled && props.noConfirmBtn\"\n                :type=\"saveTypeStr\"\n                :loading=\"formBtnLoading\"\n                @click=\"save(addFormRef)\"\n              >\n                {{ localeConfirmBtnText }}\n              </el-button>\n            </template>\n            <template v-else>\n              <el-button\n                v-if=\"props.noStorageBtn\"\n                type=\"colour-10\"\n                :loading=\"storageBtnLoading\"\n                @click=\"storage\"\n                >{{ localeStorageBtnText }}</el-button\n              >\n              <el-button\n                v-if=\"!draftBtnDisabled && props.noDraftBtn\"\n                :type=\"draftBtnTypeStr\"\n                :loading=\"draftBtnLoading\"\n                @click=\"draft(addFormRef)\"\n                >{{ localeDraftBtnText }}</el-button\n              >\n              <el-button\n                v-if=\"!initiateProcessBtnDisabled && props.noInitiateProcessBtn\"\n                :type=\"initiateProcessBtnTypeStr\"\n                :loading=\"initiateProcessBtnLoading\"\n                @click=\"startProcess(addFormRef)\"\n                >{{ localeInitiateProcessBtnText }}</el-button\n              >\n              <pit-view-process\n                v-if=\"props.operatingTypeProps != 'info' && props.hasFlow\"\n                :flow-code=\"props.flowCode\"\n                :bid-id=\"cloneAddForm.bidId\"\n              />\n            </template>\n            <slot name=\"dialog-footer-right\" />\n          </span>\n        </template>\n      </el-dialog>\n    </template>\n    <template v-else>\n      <el-dialog-header\n        v-model=\"dialogHeaderVisible\"\n        :title=\"dialogTitle\"\n        :width=\"props.dialogWidth\"\n        :before-close=\"beforeClose\"\n        :close-on-click-modal=\"false\"\n        :no-cancel-btn=\"props.noCancelBtn\"\n        modal-class=\"form-base-dialog-header\"\n      >\n        <slot name=\"addWarp\">\n          <el-form\n            ref=\"addFormRef\"\n            :model=\"cloneAddForm\"\n            :rules=\"props.rules\"\n            :label-width=\"props.labelWidth\"\n            status-icon\n            :disabled=\"addFormDisabled\"\n            :validateOnRuleChange=\"props.validateOnRuleChange\"\n          >\n            <slot name=\"add\" :add-form=\"cloneAddForm\" />\n          </el-form>\n        </slot>\n        <template #footer-right>\n          <slot name=\"dialog-footer-left\" />\n          <slot name=\"dialog-footer-center\" />\n          <template v-if=\"!hasFlow\">\n            <el-button\n              v-if=\"!addFormDisabled && props.noConfirmBtn\"\n              :type=\"saveTypeStr\"\n              :loading=\"formBtnLoading\"\n              @click=\"save(addFormRef)\"\n            >\n              {{ localeConfirmBtnText }}\n            </el-button>\n          </template>\n          <template v-else>\n            <el-button\n              v-if=\"props.noStorageBtn\"\n              type=\"colour-10\"\n              :loading=\"storageBtnLoading\"\n              @click=\"storage\"\n              >{{ localeStorageBtnText }}</el-button\n            >\n            <el-button\n              v-if=\"!draftBtnDisabled && props.noDraftBtn\"\n              :type=\"draftBtnTypeStr\"\n              :loading=\"draftBtnLoading\"\n              @click=\"draft(addFormRef)\"\n              >{{ localeDraftBtnText }}</el-button\n            >\n            <el-button\n              v-if=\"!initiateProcessBtnDisabled && props.noInitiateProcessBtn\"\n              :type=\"initiateProcessBtnTypeStr\"\n              :loading=\"initiateProcessBtnLoading\"\n              @click=\"startProcess(addFormRef)\"\n              >{{ localeInitiateProcessBtnText }}</el-button\n            >\n            <pit-view-process\n              v-if=\"props.operatingTypeProps != 'info' && props.hasFlow\"\n              :flow-code=\"props.flowCode\"\n              :bid-id=\"cloneAddForm.bidId\"\n            />\n          </template>\n          <slot name=\"dialog-footer-right\" />\n        </template>\n      </el-dialog-header>\n    </template>\n\n    <component\n      :is=\"customSetUpRender\"\n      v-if=\"props.isSetUpRender\"\n      @click=\"setupClick\"\n    />\n  </div>\n</template>\n\n<script setup lang=\"tsx\">\nimport {\n  computed,\n  getCurrentInstance,\n  nextTick,\n  onMounted,\n  provide,\n  reactive,\n  ref,\n  toRefs,\n  watch,\n} from 'vue'\nimport { DArrowRight, Delete, EditPen, Plus, Search } from 'pit-element-icons'\nimport { cloneDeep } from 'lodash-unified'\nimport {\n  useGlobalProperties,\n  useLocale,\n  useNamespace,\n} from '@pit-element-plus/hooks'\nimport { getObjectValue, renderTemplate } from '@pit-element-plus/utils'\nimport { ElMessage, ElMessageBox } from '@pit-element-plus/components'\nimport { formBaseEmits, formBaseProps } from './form-base'\nimport formBaseTable from './form-base-table.vue'\nimport useFormBase from './use-form-base'\nimport useFormBaseLocale from './use-form-base-locale'\nimport { formBaseContextKey } from './constants'\nimport type { FormBaseColumnsItem } from './form-base'\nimport type { FormInstance } from '@pit-element-plus/components/form'\nimport type { FormBaseContext } from './types'\n\ndefineOptions({\n  name: 'ElFormBase',\n})\n\nconst ns = useNamespace('form-base')\nconst { t } = useLocale()\nconst global = useGlobalProperties()\nconst props = defineProps(formBaseProps)\nconst emit = defineEmits(formBaseEmits)\n\nconst {\n  pageSize,\n  pageNum,\n  hiddenAddBtn,\n  hiddenEditBtn,\n  hiddenDelBtn,\n  hiddenBatchBtn,\n  isButtonAreaType,\n  searchTypeStr,\n  clearTypeStr,\n  addTypeStr,\n  updateTypeStr,\n  deleteTypeStr,\n  batchDelTypeStr,\n  expandTypeStr,\n  saveTypeStr,\n  cancelTypeStr,\n  paginationTotal,\n  draftBtnTypeStr,\n  initiateProcessBtnTypeStr,\n  columnsStr,\n  flowStatusData,\n  defaultFlowStatus,\n  flowStatusWidth,\n  customSetUpRender,\n  customSetUpCallback,\n  paginationPageSizeStr,\n  paginationPageNumStr,\n} = useFormBase(props)\n\nconst {\n  localeAddBtnText,\n  localeEditBtnText,\n  localeDelBtnText,\n  localeBatchBtnText,\n  localeExpandBtnText,\n  localeFoldBtnText,\n  localeSearchBtnText,\n  localeClearBtnText,\n  localeConfirmBtnText,\n  localeTextAddSuccess,\n  localeTextEditSuccess,\n  localeTextDelSuccess,\n  localeTextDelStr,\n  localeTextEmptyOption,\n  localeTextEmptyOptionOne,\n  localeStorageBtnText,\n  localeDraftBtnText,\n  localeInitiateProcessBtnText,\n  localeTextDraftSuccess,\n  localeTextProcessSuccess,\n} = useFormBaseLocale(props)\n\nconst tableData: any = ref([])\nconst tableLoading = ref(false)\nconst isShowDataTable = ref(true)\nconst pagination = ref({\n  pageSize: pageSize.value,\n  pageNum: pageNum.value,\n  total: 0,\n})\n\nconst formInlineRef = ref<FormInstance>()\nconst addFormRef = ref<FormInstance>()\nconst dialogVisible = ref(false)\nconst dialogHeaderVisible = ref(false)\nconst formBtnLoading = ref(false)\nconst operatingType = ref('add')\nconst dialogTitle = ref(t('el.formBase.addBtnText'))\nconst cloneAddForm = reactive(JSON.parse(JSON.stringify(props.addForm || {})))\nconst addFormDisabled = ref(false)\n\nconst tableDefaultExpandAll = ref(props.defaultExpandAll)\n\nconst draftBtnLoading = ref(false)\nconst initiateProcessBtnLoading = ref(false)\nconst draftBtnDisabled = ref(false)\nconst initiateProcessBtnDisabled = ref(false)\nconst storageBtnLoading = ref(false)\n\nconst approvalStatus = ref(defaultFlowStatus.value)\n\nconst peTable = ref()\nconst currentRow = ref(null)\nconst multipleSelection = ref([])\n\nconst orderArray: any = ref([])\n\nconst searchConditionArr: Record<string, any> = ref([])\n\nwatch(\n  () => props.addForm,\n  (val) => {\n    Object.assign(cloneAddForm, cloneDeep(val))\n  },\n  { deep: true, immediate: true }\n)\n\nwatch(\n  () => dialogVisible.value,\n  (val: boolean) => {\n    emit('update:isDialogVisible', val)\n  }\n)\n\nwatch(\n  () => dialogHeaderVisible.value,\n  (val: boolean) => {\n    emit('update:isDialogVisible', val)\n  }\n)\n\nlet vm: any\n\nonMounted(() => {\n  vm = getCurrentInstance()\n  if (props.isDefaultQuery) {\n    query()\n  }\n})\n\nconst getColumns = computed(() => {\n  const route = global.$route?.meta?.menuListData\n  const sortEncoding = global.$route?.meta?.sortEncoding\n  const columns: any = cloneDeep(props.columns)\n  let routerColumns: any = []\n  let searchCondition: any = []\n  if (props.isSetUpRender && route && route.length > 0) {\n    route.forEach((item: any) => {\n      const findColumn = columns.find((k: any) => k.prop === item.prop)\n      const obj = {\n        ...findColumn,\n        prop: item.prop,\n        label: item.label,\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'isDetails')) {\n        obj.isDetails = item.isDetails\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'width')) {\n        obj.width = item.width\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'align')) {\n        obj.align = item.align\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'showOverflow')) {\n        obj.showOverflow = item.showOverflow\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'hidden')) {\n        obj.hidden = item.hidden\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'resizable')) {\n        obj.resizable = item.resizable\n      }\n      if (Object.prototype.hasOwnProperty.call(item, 'sortable')) {\n        obj.sortable = item.sortable\n      }\n      routerColumns.push(obj)\n      // 处理搜索条件\n      if (item.isSearch) {\n        let searchItem = {\n          prop: item.prop,\n          label: item.label,\n          searchType: item.searchType,\n          searchValue: item.searchValue,\n        }\n        searchCondition.push(searchItem)\n      }\n    })\n    searchConditionArr.value = searchCondition\n  } else {\n    // 配置了排序编码则去匹配规则\n    if (sortEncoding) {\n      const allSort = global.$pinia?.state?.value?.base?.allSort || {}\n      const sortArr = allSort[sortEncoding] || []\n      sortArr.forEach((item: any) => {\n        const obj = columns.find((i: any) => i.prop === item.value)\n        if (obj) {\n          obj.sortable = item.defaultOption\n        }\n      })\n    }\n    routerColumns = columns\n  }\n  if (props.hasFlow) {\n    const flowStatus = routerColumns.filter(\n      (item: any) => item.label === '流程状态'\n    )\n    if (flowStatus.length === 0) {\n      const index: number = routerColumns.length - 1\n      routerColumns.splice(index, 0, {\n        prop: 'approvalStatus',\n        label: '流程状态',\n        align: global.$TABLE_SIZE.FLOW_STATUS_ALIGN,\n        width: props.tableFlowStatusWidth,\n        render: (_params: any) => (\n          <pit-flow-table-status\n            status={_params.approvalStatus}\n            row={_params}\n            rowKey={props.flowVersion}\n          />\n        ),\n        showOverflow: true,\n      })\n    }\n  }\n  if (columnsStr.value && columnsStr.value.length > 0) {\n    routerColumns = routerColumns.map((item: any) => {\n      // @ts-ignore\n      const newItem: any = columnsStr.value.find((k) => k.label === item.label)\n      if (newItem) {\n        item.width = newItem.width\n        item.align = newItem.align\n        item.showOverflow = newItem.showOverflow\n        item.dateFormatter = newItem.dateFormatter\n        item.renderTooltip = newItem.renderTooltip\n        item.hidden = newItem.hidden\n      }\n      return item\n    })\n  }\n  return routerColumns\n})\n\nconst getFlowWidth = computed(() => {\n  if (props.flowStatusWidth) {\n    return { width: `${props.flowStatusWidth}px` }\n  }\n  if (flowStatusWidth.value) {\n    return { width: `${flowStatusWidth.value}px` }\n  }\n  return {}\n})\n\nconst getFlowStatus = computed((): any => {\n  return flowStatusData.value\n})\n\nconst clear = () => {\n  if (props.clearCallback) {\n    props.clearCallback()\n    clearFn()\n  } else if (props.clearPreventCallback) {\n    props.clearPreventCallback()\n  } else {\n    clearFn()\n  }\n}\n\nconst clearFn = () => {\n  approvalStatus.value = defaultFlowStatus.value\n  formInlineRef.value?.resetFields()\n  multipleSelection.value = []\n  nextTick(() => {\n    query()\n  })\n}\n\nconst query: FormBaseContext['query'] = () => {\n  const fn = (params?: any) => {\n    tableLoading.value = true\n    peTable?.value?.setRefreshTable(false)\n    if (props.queryInterface) {\n      const url = renderTemplate(props.queryInterface, props.formInline)\n      if (props.hasFlow) {\n        props!.formInline!.approvalStatus = approvalStatus.value\n      }\n      let orderBy = ''\n      if (orderArray.value && orderArray.value.length > 0) {\n        orderArray.value.forEach((item: any) => {\n          orderBy += `${item.prop} ${\n            item.order === 'ascending' ? 'asc' : 'desc'\n          }, `\n        })\n        orderBy = orderBy.slice(0, Math.max(0, orderBy.length - 2))\n      }\n      const paginationPageSize: string = paginationPageSizeStr.value as string\n      const paginationPageNum: string= paginationPageNumStr.value as string\n      global.$http\n        .request({\n          url,\n          method: props.queryInterfaceMethod,\n          [props.queryInterfaceMethod === 'GET' ? 'params' : 'data']: {\n            [paginationPageSize]: pagination.value.pageSize,\n            [paginationPageNum]: pagination.value.pageNum,\n            orderBy,\n            ...props.formInline,\n            ...params,\n          },\n        })\n        .then((res: any) => {\n          if (res.data && res.data.list) {\n            tableData.value = res.data.list\n            pagination.value.total = getObjectValue(\n              res.data,\n              paginationTotal.value,\n              0\n            )\n          } else {\n            tableData.value = []\n            pagination.value.total = 0\n          }\n          if (res.data.length > 0) {\n            tableData.value = res.data\n            pagination.value.total = 0\n          } else {\n            tableData.value = res.data.list\n            pagination.value.total = getObjectValue(\n              res.data,\n              paginationTotal.value,\n              0\n            )\n          }\n          emit('result-table-back', tableData.value, res)\n        })\n        .finally(() => {\n          tableLoading.value = false\n          peTable?.value?.setRefreshTable(true)\n        })\n    } else {\n      tableLoading.value = false\n    }\n  }\n  if (props.searchBeforeCallbackPrevent) {\n    props.searchBeforeCallbackPrevent(vm).then((params: any) => {\n      fn(params)\n    })\n  } else {\n    fn()\n  }\n}\n\nconst search: FormBaseContext['search'] = () => {\n  pagination.value.pageNum = 1\n  multipleSelection.value = []\n  if (props.searchBeforeCallback) {\n    const next = props.searchBeforeCallback()\n    if (next) {\n      query()\n    }\n  } else {\n    query()\n  }\n}\n\nconst handleTableLoad = (tree: any) => {\n  return new Promise((resolve, reject) => {\n    if (props.queryInterface) {\n      const params = {\n        ...props.formInline,\n      }\n      params[props.lazyKey] = tree[props.lazyKey]\n      const url = renderTemplate(props.queryInterface, params)\n      global.$http\n        .request({\n          url,\n          method: props.queryInterfaceMethod,\n          [props.queryInterfaceMethod === 'GET' ? 'params' : 'data']: {\n            pageSize: pagination.value.pageSize,\n            pageNumber: pagination.value.pageNum,\n            ...params,\n          },\n        })\n        .then((res: any) => {\n          if (res.data.length > 0) {\n            resolve(res['data'])\n          }\n        })\n        .catch((e: any) => {\n          reject(e)\n        })\n    }\n  })\n}\n\nconst add: FormBaseContext['add'] = () => {\n  if (props.addBeforeCallback) {\n    const next = props.addBeforeCallback()\n    if (next) {\n      operatingType.value = 'add'\n      const addTitle =\n        props.customizeDialogTitle && props.customizeDialogTitle.addTitle\n      dialogTitle.value = addTitle ? addTitle : t('el.formBase.addBtnText')\n      emit('update:operatingTypeProps', 'add')\n      // 判断是弹窗还是全屏弹窗\n      if (props.dialogType === 'dialog') {\n        dialogVisible.value = true\n      } else {\n        dialogHeaderVisible.value = true\n      }\n    }\n  } else if (props.addBeforeAsyncCallback) {\n    props.addBeforeAsyncCallback().then((next: boolean) => {\n      if (next) {\n        operatingType.value = 'add'\n        const addTitle =\n          props.customizeDialogTitle && props.customizeDialogTitle.addTitle\n        dialogTitle.value = addTitle ? addTitle : t('el.formBase.addBtnText')\n        emit('update:operatingTypeProps', 'add')\n        // 判断是弹窗还是全屏弹窗\n        if (props.dialogType === 'dialog') {\n          dialogVisible.value = true\n        } else {\n          dialogHeaderVisible.value = true\n        }\n      }\n    })\n  } else {\n    operatingType.value = 'add'\n    const addTitle =\n      props.customizeDialogTitle && props.customizeDialogTitle.addTitle\n    dialogTitle.value = addTitle ? addTitle : t('el.formBase.addBtnText')\n    emit('update:operatingTypeProps', 'add')\n    // 判断是弹窗还是全屏弹窗\n    if (props.dialogType === 'dialog') {\n      dialogVisible.value = true\n    } else {\n      dialogHeaderVisible.value = true\n    }\n  }\n}\n\nconst update = () => {\n  let selection: string | any[] = []\n  if (props.rowSingle) {\n    selection = multipleSelection.value\n  } else {\n    selection = currentRow.value ? [currentRow.value] : []\n  }\n  if (selection.length === 0) {\n    ElMessage({\n      type: 'warning',\n      message: localeTextEmptyOption.value,\n      duration: props.duration,\n    })\n  } else if (selection.length >= 2) {\n    ElMessage({\n      type: 'warning',\n      message: localeTextEmptyOptionOne.value,\n      duration: props.duration,\n    })\n  } else {\n    info(selection[0][props.primaryKey ? props.primaryKey : ''])\n  }\n}\n\nconst info: FormBaseContext['info'] = (primaryKey: string, data?: any) => {\n  if (props.infoBeforeCallback) {\n    const next = props.infoBeforeCallback()\n    if (next) {\n      infoFn(primaryKey, data)\n    }\n  } else {\n    infoFn(primaryKey, data)\n  }\n}\n\nconst infoFn = (primaryKey: string, data?: any) => {\n  emit('update:operatingTypeProps', 'edit')\n  const originalUrl = `${props.queryOneInterface}/${primaryKey}`\n  const url = renderTemplate(originalUrl, props.formInline)\n  global.$http\n    .request({\n      url,\n      method: props.queryOneInterfaceMethod,\n      data,\n    })\n    .then((res: any) => {\n      operatingType.value = 'edit'\n      const editTitle = props.customizeDialogTitle?.editTitle\n      dialogTitle.value = editTitle ? editTitle : t('el.formBase.editBtnText')\n      Object.assign(cloneAddForm, cloneDeep(res['data']))\n      // 判断是弹窗还是全屏弹窗\n      if (props.dialogType === 'dialog') {\n        dialogVisible.value = true\n      } else {\n        dialogHeaderVisible.value = true\n      }\n      if (props.infoControllerCallback) {\n        props.infoControllerCallback(res['data'])\n      }\n    })\n}\n\nconst details: FormBaseContext['info'] = (primaryKey: string, data?: any) => {\n  addFormDisabled.value = true\n  draftBtnDisabled.value = true\n  initiateProcessBtnDisabled.value = true\n  if (props.infoBeforeCallback) {\n    const next = props.infoBeforeCallback()\n    if (next) {\n      detailsFn(primaryKey, data)\n    }\n  } else {\n    detailsFn(primaryKey, data)\n  }\n}\n\nconst detailsFn = (primaryKey: string, data: any) => {\n  emit('update:operatingTypeProps', 'info')\n  const originalUrl = `${props.queryOneInterface}/${primaryKey}`\n  const url = renderTemplate(originalUrl, props.formInline)\n  global.$http\n    .request({\n      url,\n      method: props.queryOneInterfaceMethod,\n      data,\n    })\n    .then((res: any) => {\n      operatingType.value = 'info'\n      const infoTitle =\n        props.customizeDialogTitle && props.customizeDialogTitle.infoTitle\n      dialogTitle.value = infoTitle ? infoTitle : t('el.formBase.infoText')\n      Object.assign(cloneAddForm, cloneDeep(res['data']))\n      // 判断是弹窗还是全屏弹窗\n      if (props.dialogType === 'dialog') {\n        dialogVisible.value = true\n      } else {\n        dialogHeaderVisible.value = true\n      }\n      if (props.infoControllerCallback) {\n        props.infoControllerCallback(res['data'])\n      }\n    })\n    .catch(() => {\n      beforeCloseFn()\n    })\n}\n\nconst del = () => {\n  let selection: string | any[] = []\n  if (props.rowSingle) {\n    selection = multipleSelection.value\n  } else {\n    selection = currentRow.value ? [currentRow.value] : []\n  }\n  if (selection.length === 0) {\n    ElMessage({\n      type: 'warning',\n      message: localeTextEmptyOption.value,\n      duration: props.duration,\n    })\n  } else if (selection.length >= 2) {\n    ElMessage({\n      type: 'warning',\n      message: localeTextEmptyOptionOne.value,\n      duration: props.duration,\n    })\n  } else {\n    const id = selection[0][props.primaryKey ? props.primaryKey : '']\n    if (props.delBeforeCallback) {\n      props.delBeforeCallback(id).then((res) => {\n        if (res) {\n          deleteRow(id)\n        }\n      })\n    } else {\n      deleteRow(id)\n    }\n  }\n}\n\nconst batchDel = () => {\n  const selection = multipleSelection.value\n  if (selection.length === 0) {\n    ElMessage({\n      type: 'warning',\n      message: localeTextEmptyOption.value,\n      duration: props.duration,\n    })\n  } else {\n    const ids = selection.map((item) => item[props.primaryKey])\n    if (props.delBeforeCallback) {\n      props.delBeforeCallback(ids).then((res) => {\n        if (res) {\n          deleteRow(ids)\n        }\n      })\n    } else {\n      deleteRow(ids)\n    }\n  }\n}\n\nconst deleteRow: FormBaseContext['deleteRow'] = (ids: any) => {\n  if (typeof ids === 'string') {\n    ids = [ids]\n  }\n  ElMessageBox.confirm(localeTextDelStr.value, t('el.formBase.title'), {\n    confirmButtonText: t('el.formBase.confirm'),\n    cancelButtonText: t('el.formBase.cancel'),\n    type: 'warning',\n  })\n    .then(() => {\n      if (!props.isBatchDelete) {\n        global.$http\n          .request({\n            url: props.deleteInterface,\n            method: props.deleteInterfaceMethod,\n            data: ids,\n          })\n          .then((res: any) => {\n            if (res.code === global.is_OK) {\n              setTimeout(() => {\n                ElMessage({\n                  type: 'success',\n                  message: localeTextDelSuccess.value,\n                  duration: props.duration,\n                })\n                query()\n              }, 500)\n              if (props.delControllerCallback) {\n                props.delControllerCallback()\n              }\n            }\n          })\n      } else {\n        global.$http\n          .request({\n            url: `${props.deleteInterface}/${ids[0]}`,\n            method: props.deleteInterfaceMethod,\n          })\n          .then((res: any) => {\n            if (res.code === global.is_OK) {\n              setTimeout(() => {\n                ElMessage({\n                  type: 'success',\n                  message: localeTextDelSuccess.value,\n                  duration: props.duration,\n                })\n                query()\n              }, 500)\n              if (props.delControllerCallback) {\n                props.delControllerCallback()\n              }\n            }\n          })\n      }\n    })\n    .catch(() => {\n      // eslint-disable-next-line no-console\n      console.log('取消')\n    })\n}\n\nconst save = async (formEl: FormInstance | undefined) => {\n  if (!formEl) return\n  await formEl.validate((valid, fields): any => {\n    if (valid) {\n      if (props.addParamControllerCallback) {\n        props.addParamControllerCallback().then(() => {\n          submit()\n        })\n      } else if (props.addParamPromiseControllerCallback) {\n        props.addParamPromiseControllerCallback(vm).then((res: any) => {\n          if (res) {\n            submit()\n          }\n        })\n      } else if (props.addParamControllerPreventCallback) {\n        props.addParamControllerPreventCallback()\n      } else {\n        submit()\n      }\n    } else {\n      // eslint-disable-next-line no-console\n      console.log('error submit!', fields)\n      return false\n    }\n  })\n}\n\nconst submit: FormBaseContext['submit'] = (params?: any) => {\n  formBtnLoading.value = true\n  if (operatingType.value === 'add') {\n    const url = renderTemplate(props.saveInterface || '', cloneAddForm)\n    global.$http\n      .request({\n        url,\n        method: props.saveInterfaceMethod,\n        data: params ? params : cloneAddForm,\n      })\n      .then((res: any) => {\n        if (res.code === global.is_OK) {\n          setTimeout(() => {\n            ElMessage({\n              type: 'success',\n              message: localeTextAddSuccess.value,\n              duration: props.duration,\n            })\n            beforeClose()\n            query()\n          }, 500)\n          if (props.addControllerCallback) {\n            props.addControllerCallback(res)\n          }\n        }\n        formBtnLoading.value = false\n      })\n      .finally(() => {\n        formBtnLoading.value = false\n      })\n      .catch(() => {\n        formBtnLoading.value = false\n      })\n  } else {\n    const url = renderTemplate(props.updateInterface || '', cloneAddForm)\n    global.$http\n      .request({\n        url,\n        method: props.updateInterfaceMethod,\n        data: params ? params : cloneAddForm,\n      })\n      .then((res: any) => {\n        if (res.code === global.is_OK) {\n          setTimeout(() => {\n            ElMessage({\n              type: 'success',\n              message: localeTextEditSuccess.value,\n              duration: props.duration,\n            })\n            beforeClose()\n            query()\n          }, 500)\n          if (props.addControllerCallback) {\n            props.addControllerCallback(res)\n          }\n        }\n        formBtnLoading.value = false\n      })\n      .finally(() => {\n        formBtnLoading.value = false\n      })\n      .catch(() => {\n        formBtnLoading.value = false\n      })\n  }\n}\n\nconst beforeClose = () => {\n  if (props.dialogBeforeClose) {\n    props.dialogBeforeClose()\n  } else {\n    beforeCloseFn()\n  }\n}\n\nconst beforeCloseFn: FormBaseContext['beforeCloseFn'] = () => {\n  addFormRef.value?.resetFields()\n  Object.keys(cloneAddForm).forEach((key) => {\n    delete cloneAddForm[key]\n  })\n  Object.assign(cloneAddForm, JSON.parse(JSON.stringify(props.addForm)))\n  dialogVisible.value = false\n  dialogHeaderVisible.value = false\n  operatingType.value = 'add'\n  addFormDisabled.value = false\n  const addTitle = props.customizeDialogTitle?.addTitle\n  formBtnLoading.value = false\n  draftBtnLoading.value = false\n  initiateProcessBtnLoading.value = false\n  draftBtnDisabled.value = false\n  initiateProcessBtnDisabled.value = false\n  storageBtnLoading.value = false\n  dialogTitle.value = addTitle ? addTitle : t('el.formBase.addBtnText')\n}\n\n// 保存草稿事件\nconst draft = async (formEl: FormInstance | undefined) => {\n  if (!formEl) return\n  await formEl.validate((valid, fields): any => {\n    if (valid) {\n      if (props.draftParamControllerCallback) {\n        // this\n        props.draftParamControllerCallback().then(() => {\n          draftSubmit()\n        })\n      } else if (props.draftParamPromiseControllerCallback) {\n        // this\n        props.draftParamPromiseControllerCallback().then((res) => {\n          if (res) {\n            draftSubmit()\n          }\n        })\n      } else if (props.draftParamControllerPreventCallback) {\n        // this\n        props.draftParamControllerPreventCallback()\n      } else {\n        draftSubmit()\n      }\n    } else {\n      // eslint-disable-next-line no-console\n      console.log('error submit!', fields)\n      return false\n    }\n  })\n}\n\nconst draftSubmit: FormBaseContext['draftSubmit'] = (params?: any) => {\n  draftBtnLoading.value = true\n  initiateProcessBtnLoading.value = true\n  storageBtnLoading.value = true\n  const url = renderTemplate(props.draftInterface || '', cloneAddForm)\n  global.$http\n    .request({\n      url,\n      method: props.draftInterfaceMethod,\n      data: params ? params : cloneAddForm,\n    })\n    .then((res: any) => {\n      if (res.code === global.is_OK) {\n        setTimeout(() => {\n          ElMessage({\n            type: 'success',\n            message: localeTextDraftSuccess.value,\n            duration: props.duration,\n          })\n          beforeClose()\n          query()\n          draftBtnLoading.value = false\n          initiateProcessBtnLoading.value = false\n          storageBtnLoading.value = false\n        }, 500)\n        if (props.addControllerCallback) {\n          props.addControllerCallback(res)\n        }\n      }\n      draftBtnLoading.value = false\n      initiateProcessBtnLoading.value = false\n      storageBtnLoading.value = false\n    })\n    .finally(() => {\n      draftBtnLoading.value = false\n      initiateProcessBtnLoading.value = false\n      storageBtnLoading.value = false\n    })\n    .catch(() => {\n      draftBtnLoading.value = false\n      initiateProcessBtnLoading.value = false\n      storageBtnLoading.value = false\n      if (props.draftControllerErrorCallback) {\n        props.draftControllerErrorCallback()\n      }\n    })\n}\n\n// 发起流程事件\nconst startProcess = async (formEl: FormInstance | undefined) => {\n  if (!formEl) return\n  await formEl.validate((valid, fields): any => {\n    if (valid) {\n      if (props.processParamControllerCallback) {\n        // this\n        props.processParamControllerCallback().then(() => {\n          processSubmit()\n        })\n      } else if (props.processParamPromiseControllerCallback) {\n        // this\n        props.processParamPromiseControllerCallback().then((res) => {\n          if (res) {\n            processSubmit()\n          }\n        })\n      } else if (props.processParamControllerPreventCallback) {\n        // this\n        props.processParamControllerPreventCallback()\n      } else {\n        processSubmit()\n      }\n    } else {\n      // eslint-disable-next-line no-console\n      console.log('error submit!', fields)\n      return false\n    }\n  })\n}\n\nconst processSubmit: FormBaseContext['processSubmit'] = (params?: any) => {\n  draftBtnLoading.value = true\n  initiateProcessBtnLoading.value = true\n  storageBtnLoading.value = true\n  global.$openRunFlow({\n    handleId: cloneAddForm.handleId,\n    bidId: cloneAddForm.bidId,\n    bpmKey: cloneAddForm.bpmKey || '',\n    peFormBase: vm,\n    success(flowDialogForm: any, app: any) {\n      const fn = (newFlowDialogForm: any) => {\n        let dataParams = {\n          ...newFlowDialogForm,\n          ...(params ? params : cloneAddForm),\n        }\n        if (props.processRunFlowParamsControllerCallback) {\n          dataParams = props.processRunFlowParamsControllerCallback(dataParams)\n        }\n        const url = renderTemplate(props.processInterface || '', cloneAddForm)\n        global.$http\n          .request({\n            url,\n            method: props.processInterfaceMethod,\n            data: dataParams,\n          })\n          .then((res: any) => {\n            if (res['code'] === global.is_OK) {\n              setTimeout(() => {\n                ElMessage({\n                  type: 'success',\n                  message: localeTextProcessSuccess.value,\n                  duration: props.duration,\n                })\n                app.close()\n                beforeClose()\n                query()\n                draftBtnLoading.value = false\n                initiateProcessBtnLoading.value = false\n                storageBtnLoading.value = false\n              }, 500)\n              if (props.processControllerCallback) {\n                props.processControllerCallback(res)\n              }\n            } else {\n              draftBtnLoading.value = false\n              initiateProcessBtnLoading.value = false\n              storageBtnLoading.value = false\n              app.callback((config: any) => {\n                fn(config)\n              }, res)\n            }\n          })\n          .catch((err: any) => {\n            draftBtnLoading.value = false\n            initiateProcessBtnLoading.value = false\n            storageBtnLoading.value = false\n            app.callback((config: any) => {\n              fn(config)\n            }, err)\n            if (props.processControllerErrorCallback) {\n              props.processControllerErrorCallback()\n            }\n          })\n      }\n      fn(flowDialogForm)\n    },\n    error(app: any) {\n      draftBtnLoading.value = false\n      initiateProcessBtnLoading.value = false\n      storageBtnLoading.value = false\n      app.close()\n    },\n  })\n}\n\n// 暂存按钮事件\nconst storage = () => {\n  draftBtnLoading.value = true\n  initiateProcessBtnLoading.value = true\n  storageBtnLoading.value = true\n  if (props.storageCallback) {\n    props.storageCallback().then(() => {\n      setTimeout(() => {\n        ElMessage({\n          type: 'success',\n          message: localeTextEditSuccess.value,\n          duration: props.duration,\n        })\n        beforeClose()\n        query()\n        draftBtnLoading.value = false\n        initiateProcessBtnLoading.value = false\n        storageBtnLoading.value = false\n      }, 500)\n    })\n  }\n  if (props.storageControllerPreventCallback) {\n    props.storageControllerPreventCallback().then((res: any) => {\n      if (res) {\n        setTimeout(() => {\n          ElMessage({\n            type: 'success',\n            message: localeTextEditSuccess.value,\n            duration: props.duration,\n          })\n          beforeClose()\n          query()\n          draftBtnLoading.value = false\n          initiateProcessBtnLoading.value = false\n          storageBtnLoading.value = false\n        }, 500)\n      } else {\n        setTimeout(() => {\n          draftBtnLoading.value = false\n          initiateProcessBtnLoading.value = false\n          storageBtnLoading.value = false\n        }, 500)\n      }\n    })\n  }\n}\n\nconst handleSizeChange = (val: number) => {\n  pagination.value.pageSize = val\n  pagination.value.pageNum = 1\n  query()\n}\n\nconst handleCurrentChange = (val: number) => {\n  pagination.value.pageNum = val\n  query()\n}\n\nconst handleChangeFlowStatus = () => {\n  query()\n}\n\nconst handleRowDblclick = (row: any) => {\n  if (props.isDoubleClickDetails) {\n    if (props.hasFlow) {\n      if (row.formUrl && row.procInstId) {\n        // 默认打开流程详情是无法进行操作\n        row.optionType = 'end'\n        global.$openFlowBox({\n          row,\n          peFormBase: vm,\n        })\n      } else {\n        details(row[props.primaryKey])\n      }\n    } else {\n      details(row[props.primaryKey])\n    }\n  } else {\n    emit('table-row-dblclick', row)\n  }\n}\n\nconst handleTableCurrentChange = (row: any) => {\n  currentRow.value = row\n  emit('table-current-change', row)\n}\n\nconst handleTableSelectionChange = (row: any) => {\n  multipleSelection.value = row\n  emit('table-selection-change', row)\n}\n\nconst handleClickInfo = (columns: FormBaseColumnsItem, row: any) => {\n  if (columns.isDetails) {\n    if (props.hasFlow) {\n      if (row.formUrl && row.procInstId) {\n        // 默认打开流程详情是无法进行操作\n        row.optionType = 'end'\n        global.$openFlowBox({\n          row,\n          peFormBase: vm,\n        })\n      } else {\n        details(row[props.primaryKey])\n      }\n    } else {\n      details(row[props.primaryKey])\n    }\n  }\n}\n\nconst handleTableSortChange = (sort: any) => {\n  orderArray.value = sort\n  query()\n}\n\nconst setData: FormBaseContext['setData'] = (data: any) => {\n  tableData.value = data\n}\n\nconst doLayout: FormBaseContext['doLayout'] = () => {\n  peTable?.value?.doLayout()\n}\n\nconst validate: FormBaseContext['validate'] = (callback?: any) => {\n  return addFormRef.value?.validate(callback)\n}\n\nconst setFormBtnLoading: FormBaseContext['setFormBtnLoading'] = (\n  val: boolean\n) => {\n  formBtnLoading.value = val\n}\n\nconst setAddFormDisabled: FormBaseContext['setAddFormDisabled'] = (\n  val: boolean\n) => {\n  addFormDisabled.value = val\n}\n\nconst reloadTable: FormBaseContext['reloadTable'] = () => {\n  isShowDataTable.value = false\n  nextTick(() => {\n    isShowDataTable.value = true\n  })\n}\n\nconst setupClick = () => {\n  if (customSetUpCallback.value) {\n    customSetUpCallback.value(vm)\n  }\n}\n\nconst handleToggleExpand = () => {\n  if (props.isVirtuallyTable) {\n    tableDefaultExpandAll.value = !tableDefaultExpandAll.value\n    peTable?.value?.dataTableRef().setAllTreeExpand(tableDefaultExpandAll.value)\n    peTable?.value?.dataTableRef().refreshColumn()\n  } else {\n    peTable?.value?.setRefreshTable(false)\n    tableDefaultExpandAll.value = !tableDefaultExpandAll.value\n    nextTick(() => {\n      peTable?.value?.setRefreshTable(true)\n    })\n  }\n}\n\nprovide(formBaseContextKey, {\n  ...toRefs(props),\n  query,\n  search,\n  add,\n  info,\n  deleteRow,\n  details,\n  setData,\n  submit,\n  draftSubmit,\n  processSubmit,\n  beforeCloseFn,\n  doLayout,\n  validate,\n  setFormBtnLoading,\n  setAddFormDisabled,\n})\n\ndefineExpose({\n  /**\n   * @description pagination\n   */\n  pagination,\n  /**\n   * @description addFormDisabled\n   */\n  addFormDisabled,\n  /**\n   * @description formBtnLoading\n   */\n  formBtnLoading,\n  /**\n   * @description tableData\n   */\n  tableData,\n  /**\n   * @description cloneAddForm\n   */\n  cloneAddForm,\n  /**\n   * @description currentRow\n   */\n  currentRow,\n  /**\n   * @description multipleSelection\n   */\n  multipleSelection,\n  /**\n   * @description peTable\n   */\n  peTable,\n  /**\n   * @description query\n   */\n  query,\n  /**\n   * @description search\n   */\n  search,\n  /**\n   * @description add\n   */\n  add,\n  /**\n   * @description info\n   */\n  info,\n  /**\n   * @description deleteRow\n   */\n  deleteRow,\n  /**\n   * @description details\n   */\n  details,\n  /**\n   * @description setData\n   */\n  setData,\n  /**\n   * @description submit\n   */\n  submit,\n  /**\n   * @description draftSubmit\n   */\n  draftSubmit,\n  /**\n   * @description processSubmit\n   */\n  processSubmit,\n  /**\n   * @description beforeCloseFn\n   */\n  beforeCloseFn,\n  /**\n   * @description doLayout\n   */\n  doLayout,\n  /**\n   * @description validate\n   */\n  validate,\n  /**\n   * @description setFormBtnLoading\n   */\n  setFormBtnLoading,\n  /**\n   * @description setAddFormDisabled\n   */\n  setAddFormDisabled,\n  /**\n   * @description draftBtnLoading\n   */\n  draftBtnLoading,\n  /**\n   * @description initiateProcessBtnLoading\n   */\n  initiateProcessBtnLoading,\n  /**\n   * @description draftBtnDisabled\n   */\n  draftBtnDisabled,\n  /**\n   * @description initiateProcessBtnDisabled\n   */\n  initiateProcessBtnDisabled,\n  /**\n   * @description storageBtnLoading\n   */\n  storageBtnLoading,\n  /**\n   * @description reloadTable\n   */\n  reloadTable,\n})\n</script>\n"],"mappings":""}