<template>
  <div class="page-wrapper">
    <breadcrumb v-if="!multiPage" :breadcrumb-data="breadcrumbData" />
    <div class="page-container">
      <a-collapse
        v-model="activeKey"
        expand-icon-position="right"
        class="collapse-header-divide"
      >
        <a-collapse-panel key="a" :header="$t('BASE_INFO')">
          <a-form-model
            ref="ruleForm"
            :model="form"
            :rules="rules"
            :label-col="{ span: 7 }"
            :wrapper-col="{ span: 17 }"
          >
            <a-row :gutter="24">
              <a-col :span="8">
                <a-form-model-item
                  :label="$t('CHECK_OBJECT_SOURCE_NAME')"
                  prop="sourceName"
                  allow-clear
                >
                  <a-input
                    v-model="form.sourceName"
                    :placeholder="$t('PLACEENTER')"
                    @change="
                      form.sourceName = form.sourceName.slice(0, 50).trim()
                    "
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  :label="$t('CHECK_OBJECT_SOURCE_TYPE')"
                  prop="sourceType"
                  allow-clear
                >
                  <a-select
                    v-model="form.sourceType"
                    @change="handleChangeType()"
                  >
                    <a-select-option
                      v-for="item in sourceTypeList"
                      :key="item.value"
                      :value="item.value"
                    >
                      {{ item.label }}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col v-if="form.sourceType === 'SINGLE_TABLE'" :span="8">
                <a-form-model-item
                  :label="$t('DATA_TABLE')"
                  prop="tableName"
                  allow-clear
                >
                  <a-select
                    v-model="form.tableName"
                    show-search
                    :placeholder="$t('PLACESELECT')"
                    @change="handleChangeTable()"
                  >
                    <a-select-option
                      v-for="item in allTableList"
                      :key="item.tableName"
                      :value="item.tableName"
                    >
                      {{ item.tableName }}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col v-if="form.sourceType === 'OUT_API'" :span="8">
                <a-form-model-item
                  :label="$t('INTERFACE_ADDRESS')"
                  prop="apiUrl"
                  allow-clear
                >
                  <a-input
                    v-model="form.apiUrl"
                    :placeholder="$t('PLACEENTER')"
                  />
                </a-form-model-item>
              </a-col>
              <a-col v-if="form.sourceType === 'OUT_API'" :span="24">
                <a-form-model
                  v-for="(item, index) in parameterList"
                  :key="index"
                  :ref="`ruleForm${index}`"
                  :model="item"
                  :label-col="{ span: 7 }"
                  :wrapper-col="{ span: 17 }"
                >
                  <a-row :gutter="24">
                    <a-col :span="8">
                      <a-form-model-item
                        :label="$t('PARAMETER_NAME')"
                        prop="key"
                        allow-clear
                        :rules="[
                          {
                            required: true,
                            message: $t('PLACEENTER'),
                            trigger: 'blur',
                          },
                        ]"
                      >
                        <a-input
                          v-model="item.key"
                          :placeholder="$t('PLACEENTER')"
                        />
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-model-item
                        :label="$t('PARAMETER_VALUE')"
                        allow-clear
                        prop="value"
                        :rules="[
                          {
                            required: true,
                            message: $t('PLACEENTER'),
                            trigger: 'blur',
                          },
                        ]"
                      >
                        <a-input
                          v-model="item.value"
                          :placeholder="$t('PLACEENTER')"
                        />
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="8">
                      <div class="flex" style="margin-top: 2px">
                        <div
                          v-if="parameterList.length > 1"
                          class="btn_opearte cursor-pointer flex items-center justify-center"
                          style="margin-right: 10px"
                          @click="handleDeleteItem(index)"
                        >
                          <i class="iconfont icon-jian mr-1" />
                          <span>{{ $t("DELETE") }}</span>
                        </div>
                        <div
                          v-if="index === parameterList.length - 1"
                          class="btn_opearte cursor-pointer flex items-center justify-center"
                          @click="handleAddItem()"
                        >
                          <i class="iconfont icon-jia mr-1" />
                          <span>{{ $t("ADD") }}</span>
                        </div>
                      </div>
                    </a-col>
                  </a-row>
                </a-form-model>
              </a-col>
            </a-row>
          </a-form-model>
        </a-collapse-panel>
      </a-collapse>
      <a-collapse
        v-model="activeKeyB"
        expand-icon-position="right"
        class="collapse-header-divide"
      >
        <a-collapse-panel key="b" :header="$t('OBJECT_DISPLAY_FILED')">
          <MomTable
            row-key="id"
            :columns="columns"
            :data-source="fieldList"
            :action-buttons="actionButtons"
            :show-util-operator="false"
            :auto-adaptive-width="false"
            @delete="handleDelete"
          >
            <a-row slot="toolbar" class="button-top-table">
              <a-button @click="handleAdd">
                <a-icon type="plus" /> {{ $t("ADD") }}
              </a-button>
            </a-row>
            <div slot="columnName" slot-scope="text, row, index">
              <a-input
                v-model="row.columnName"
                allow-clear
                :disabled="index < 2"
                :placeholder="$t('PLACEENTER')"
                @change="row.columnName = row.columnName.slice(0, 50).trim()"
              />
            </div>
            <div slot="i18NCode" slot-scope="text, row, index">
              <a-input
                v-if="index < 2"
                v-model="row.i18NCode"
                allow-clear
                disabled
                :placeholder="$t('PLACEENTER')"
                @change="row.i18NCode = row.i18NCode.slice(0, 50).trim()"
              />
              <a-row v-else :gutter="24" style="display: flex">
                <a-col :span="20">
                  <a-select
                    v-model="row.i18NCode"
                    show-search
                    :filter-option="false"
                    :default-active-first-option="false"
                    :placeholder="() => $t('PLACEENTER')"
                    style="width: 100%"
                    @search="remoteMethod"
                    @change="handChange($event, index)"
                  >
                    <a-select-option
                      v-for="ele in menuNameList"
                      :key="ele.id"
                      :value="ele.i18nCode"
                    >
                      {{ ele.i18nCode }}
                    </a-select-option>
                  </a-select>
                </a-col>
                <a-col :span="4" style="padding: 0">
                  <a-button icon="plus" @click="changeI18n(index)"></a-button>
                </a-col>
              </a-row>
            </div>
            <div slot="tableName" slot-scope="text, row">
              <a-select
                v-model="row.tableName"
                style="width: 100%"
                disabled
                :placeholder="$t('PLACESELECT')"
              >
                <a-select-option
                  v-for="item in allTableList"
                  :key="item.tableName"
                  :value="item.tableName"
                >
                  {{ item.tableName }}
                </a-select-option>
              </a-select>
            </div>
            <div slot="fieldName" slot-scope="text, row">
              <a-select
                v-if="form.sourceType === 'SINGLE_TABLE'"
                v-model="row.fieldName"
                allow-clear
                show-search
                style="width: 100%"
                :placeholder="$t('PLACEENTER')"
              >
                <a-select-option
                  v-for="column in allTableColumnList"
                  :key="column.columnName"
                  :value="column.columnName"
                >
                  {{ column.columnName }} - {{ column.columnComment }}
                </a-select-option>
              </a-select>
              <a-input
                v-else
                v-model="row.fieldName"
                :placeholder="$t('PLACEENTER')"
                @change="row.fieldName = row.fieldName.slice(0, 50).trim()"
              />
            </div>
          </MomTable>
        </a-collapse-panel>
      </a-collapse>
    </div>
    <div class="page-bottom-op">
      <a-button type="primary" :loading="confirmLoading" @click="handleSave">
        <i class="iconfont icon-baocun"></i>
        {{ $t("SAVE") }}
      </a-button>
      <a-button @click="handleCancel">
        <i class="iconfont icon-quxiao"></i>
        {{ $t("CANCEL") }}
      </a-button>
    </div>
    <!-- 国际化选择新增弹框 -->
    <MegaModal
      class="dictDialog"
      :title="$t('I18N_INFO')"
      :visible="i18nDialogVisible"
      :centered="true"
      :mask-closable="false"
      :destroy-on-close="true"
      @cancel="i18nSaveCancel"
    >
      <i-form
        ref="drawerForm"
        :label-width="100"
        :form-item="dialogFormItem"
        :search-form="dialogForm"
        :span="1"
      />
      <template slot="footer">
        <a-button type="primary" @click="i18nSave">
          <i class="iconfont icon-baocun"></i> {{ $t("SAVE") }}
        </a-button>
        <a-button class="iconfont icon-quxiao" @click="i18nSaveCancel">
          <i class="iconfont icon-quxiao"></i> {{ $t("CANCEL") }}
        </a-button>
      </template>
    </MegaModal>
  </div>
</template>

<script>
import { mapState } from "vuex";
import { Modal as MegaModal } from "@mega-design/ui-vue";
import ApiConstant from "@/api/ApiConstant";
import breadcrumb from "@/components/breadcrumb";

export default {
  components: {
    breadcrumb,
    MegaModal,
  },
  data() {
    return {
      breadcrumbData: [
        {
          name: this.$t("CHECK_OBJECT_SOURCES"),
          url: "/eam/basic_setting/check/object_source",
        },
        { name: this.$t("CHECK_OBJECT_SOURCE_ADD"), url: "" },
      ],
      activeKey: "a",
      activeKeyB: "b",
      confirmLoading: false,
      dataSource: [],
      columnsA: [
        {
          dataIndex: "columnName", // 对象展示字段名称
          ellipsis: true,
          title: () => this.$t("COLUMN_NAME"),
          sorter: false,
          scopedSlots: { customRender: "columnName" },
        },
        {
          dataIndex: "i18NCode", // 国际化编码
          ellipsis: true,
          title: () => this.$t("INTERNATIONAL_CODING"),
          sorter: false,
          scopedSlots: { customRender: "i18NCode" },
        },
        {
          dataIndex: "tableName", // 数据表
          ellipsis: true,
          title: () => this.$t("DATA_TABLE"),
          sorter: false,
          scopedSlots: { customRender: "tableName" },
        },
        {
          dataIndex: "fieldName", // 字段名称
          ellipsis: true,
          title: () => this.$t("FIELD_NAME"),
          sorter: false,
          scopedSlots: { customRender: "fieldName" },
        },
      ],
      columnsB: [
        {
          dataIndex: "columnName", // 对象展示字段名称
          ellipsis: true,
          title: () => this.$t("COLUMN_NAME"),
          sorter: false,
          scopedSlots: { customRender: "columnName" },
        },
        {
          dataIndex: "i18NCode", // 国际化编码
          ellipsis: true,
          title: () => this.$t("INTERNATIONAL_CODING"),
          sorter: false,
          scopedSlots: { customRender: "i18NCode" },
        },
        {
          dataIndex: "fieldName", // 字段名称
          ellipsis: true,
          title: () => this.$t("FIELD_NAME"),
          sorter: false,
          scopedSlots: { customRender: "fieldName" },
        },
      ],
      form: {
        sourceName: "", // 名称
        sourceType: "", // 类型
        tableName: "", // 主表名
        apiUrl: "", // 接口地址
        apiParam: "", // 接口参数
        fieldList: [],
        module: "PC", // 点检(PC);保养(PM)
      },
      sourceTypeList: [], // 来源类型列表
      parameterList: [
        // 参数列表
        {
          key: "",
          value: "",
        },
      ], // 接口参数列表
      fieldList: [
        {
          columnName: "code",
          i18NCode: "CODE",
          fieldName: "",
          tableName: "",
        },
        {
          columnName: "name",
          i18NCode: "NAME",
          fieldName: "",
          tableName: "",
        },
      ], // 对象展示字段列表
      fieldOldList: [
        {
          columnName: "code",
          i18NCode: "CODE",
          fieldName: "",
          tableName: "",
        },
        {
          columnName: "name",
          i18NCode: "NAME",
          fieldName: "",
          tableName: "",
        },
      ], // 对象展示字段列表
      actionButtons: [
        (h, { record, index }) =>
          index > 1 && (
            <a-button
              type="link"
              disabled={this.fieldList.length === 1}
              onClick={() => this.handleDelete(record, index)}
            >
              <i
                class="operation-icon iconfont icon-delete"
                style="font-size:18px;color:#d45f5f"
                title={this.$t("DELETE")}
              />
            </a-button>
          ),
      ],
      allTableList: [], // 获取当前系统数据库的所有表
      allTableColumnList: [], // 根据表名获取列信息
      columns: [], // 默认
      i18nDialogVisible: false, // 国际化弹框
      menuNameList: [],
      dialogForm: {
        id: null,
        clientType: "",
        i18nCode: "",
        type: "",
      },
      oldI18nCode: null,
      // 表单的配置项详情
      dialogFormItem: {
        i18nCode: {
          i18n: "CODE", // 编码
          isRequired: true,
          rule: {
            max: 128,
            required: true,
            message: this.$t("PLACEENTER") + 128 + this.$t("LENGTH_TIP"),
            trigger: "blur",
          },
        },
        clientType: {
          itemType: "select",
          isRequired: true,
          i18n: "MOM_VERSION",
          width: 80,
          options: this.momVersionList,
        },
        type: {
          itemType: "select",
          isRequired: true,
          i18n: "TYPE",
          width: 80,
          options: this.typeList,
        },
      },
      momVersionList: [], // mom 版本列表
      typeList: [],
      curIndex: 0,
      detailInfo: {},
    };
  },
  computed: {
    ...mapState("setting", ["multiPage"]),
    rules() {
      return {
        sourceName: [
          {
            required: true,
            max: 50,
            message: () => this.$t("PLACEENTER") + 50 + this.$t("LENGTH_TIP"),
            trigger: "blur",
          },
        ],
        sourceType: [
          {
            required: true,
            message: this.$t("PLACESELECT"),
            trigger: "change",
          },
        ],
        apiUrl: [
          {
            required: true,
            message: this.$t("PLACEENTER"),
            trigger: "blur",
          },
        ],
        tableName: [
          {
            required: true,
            message: this.$t("PLACEENTER"),
            trigger: "blur",
          },
        ],
      };
    },
  },
  watch: {
    momVersionList: {
      handler(newVal, oldVal) {
        if (newVal && newVal.length > 0) {
          this.dialogFormItem.clientType.options = newVal;
        }
      },
      deep: true,
      immediate: true,
    },
    typeList: {
      handler(newVal, oldVal) {
        if (newVal && newVal.length > 0) {
          this.dialogFormItem.type.options = newVal;
        }
      },
      deep: true,
      immediate: true,
    },
  },
  beforeMount() {
    this.$store.state.app.languages.forEach((item) => {
      this.$set(this.dialogFormItem, item.value, {
        inputType: "textarea",
        i18n: item.label,
      });
    });
  },
  mounted() {
    this.columns = this.columnsA;
    // 初始化数据
    this.init();
    this.remoteMethod();
  },
  methods: {
    // 初始化数据
    init() {
      return Promise.all([
        this.$axios.get(
          `${ApiConstant.PREFIX_CORE}/api/sys/dict-data/DIC:EPM:PC_CHECK_OBJECT_SOURCE`
        ), // 来源类型数据字典
        this.$axios.get(
          `${ApiConstant.PREFIX_CORE}/api/epm/pcm/object-source/list-table`,
          {
            id: this.$route.query.id,
          }
        ), // 获取当前系统数据库的所有表
        this.$axios.get(
          `${ApiConstant.PREFIX_CORE}/api/sys/dict-data/DIC:CORE:MOM_VERSION`
        ), // mom版本数据字典
        this.$axios.get(
          `${ApiConstant.PREFIX_CORE}/api/sys/dict-data/DIC:CORE:I18N_TYPE`
        ), // 国际化类型数据字典
        this.$axios.get(
          `${ApiConstant.PREFIX_CORE}/api/epm/pcm/object-source/detail/${this.$route.query.id}`
        ), // 点检对象来源配置详情
      ]).then(
        ([sourceTypeRes, tableRes, momVersionRes, typeRes, detailRes]) => {
          this.sourceTypeList = sourceTypeRes.data?.data;
          this.allTableList = tableRes.data?.data;
          this.momVersionList = momVersionRes.data.data || [];
          this.typeList = typeRes.data?.data;
          const { apiParam, fieldRelList, tableName } = {
            ...detailRes.data?.data,
          };
          this.form = { ...detailRes.data?.data };
          this.detailInfo = { ...detailRes.data?.data };
          if (apiParam) {
            this.parameterList = JSON.parse(apiParam);
          }
          if (fieldRelList && fieldRelList.length > 0) {
            fieldRelList.forEach((item) => {
              // eslint-disable-next-line no-param-reassign
              item.lock = false;
              if (item.tableName !== tableName) {
                // eslint-disable-next-line no-param-reassign
                item.lock = true;
              }
            });
          }
          this.fieldList = [...fieldRelList];
          this.fieldOldList = [...fieldRelList];
          if (tableName) {
            // this.handleChangeTable();
          }
        }
      );
    },
    handleChangeType() {
      const { sourceType } = this.form;
      // eslint-disable-next-line default-case
      switch (sourceType) {
        case "SINGLE_TABLE":
          this.columns = this.columnsA;
          break;
        case "OUT_API":
          this.columns = this.columnsB;
          break;
      }
    },
    handleChangeTable() {
      const { tableName } = this.form;
      this.fieldList.map((item, index) => {
        if (item.lock === false) {
          // eslint-disable-next-line no-param-reassign
          item.tableName = tableName;
        }
        return item;
      });
      const params = {
        tableName,
      };
      this.$axios
        .get(`${ApiConstant.PREFIX_CORE}/api/epm/ebs/table/list-column`, {
          params,
        })
        .then((res) => {
          this.allTableColumnList = { ...res?.data?.data };
        });
    },
    // 增加对象展示字段
    handleAddItem() {
      this.parameterList.push({
        key: "",
        value: "",
      });
    },
    // 删除增加对象展示字段
    handleDeleteItem(index) {
      this.$confirm({
        title: this.$t("DELETE"),
        content: this.$t("DELETE_INFO"),
        okText: this.$t("DELETE"),
        cancelText: this.$t("CANCEL"),
        centered: false,
        icon: "close-circle",
        onOk: () => {
          this.parameterList.splice(index, 1);
          if (this.parameterList.length === 0) {
            this.parameterList = [
              {
                key: "",
                value: "",
              },
            ];
          }
        },
      });
    },
    // 监听对象展示字段新增点击事件
    handleAdd() {
      this.fieldList.push({
        columnName: "",
        i18NCode: "",
        fieldName: "",
        tableName: this.form.tableName,
      });
    },
    handleEdit() {},
    // 监听删除接口参数事件
    handleDelete(item, index) {
      this.$confirm({
        title: this.$t("DELETE"),
        content: this.$t("DELETE_INFO"),
        okText: this.$t("DELETE"),
        cancelText: this.$t("CANCEL"),
        centered: false,
        icon: "close-circle",
        onOk: () => {
          this.fieldList.splice(index, 1);
        },
      });
    },
    handChange(value, index) {
      this.menuNameList.forEach((element) => {
        if (element.id === value) {
          this.fieldList[index].i18NCode = element.i18nCode;
        }
      });
    },
    remoteMethod(val) {
      const params = {
        searchKey: val,
      };
      this.$axios
        .get(`${ApiConstant.PREFIX_CORE}/api/sys/i18n/list-for-select`, {
          params,
        })
        .then((res) => {
          this.menuNameList = res.data.data.filter(
            (item, index) => index < 150
          );
        });
    },
    changeI18n(index) {
      this.curIndex = index;
      this.dialogForm.id = null;
      this.$store.state.app.languages.forEach((item) => {
        this.$store.state.app.languages.forEach((code) => {
          this.dialogForm[code.value] = "";
          this.$set(this.dialogForm, code.value, "");
        });
      });
      this.$set(this.dialogForm, "i18nCode", "");
      this.$set(this.dialogForm, "clientType", this.momVersionList[0].value);
      this.i18nDialogVisible = true;
    },
    i18nSave() {
      const { id, i18nCode, type, clientType } = this.dialogForm;
      const params = {
        i18nCode,
        type,
        clientType,
        items: this.$store.state.app.languages.map((item) => {
          const { label, value } = item;
          return {
            dataValue: this.dialogForm[value],
            i18nCode,
            languageCode: value,
            languageName: label,
          };
        }),
      };
      this.$refs.drawerForm.$refs.iForm.validate((valid) => {
        if (valid) {
          if (this.dialogForm.i18nCode === this.oldI18nCode && id) {
            this.$axios
              .put(`${ApiConstant.PREFIX_CORE}/api/sys/i18n`, {
                id,
                ...params,
              })
              .then(() => {
                this.$message.success(this.$t("EDIT_SUCCESS"));
                // this.$set(this.menuForm, 'menuName', this.dialogForm.i18nCode)
                this.$emit("saveMenuCodeI18n", this.dialogForm.i18nCode);
                this.i18nDialogVisible = false;
                this.$emit("refreshTable");
                this.$parent.handleRefreshI18n();
              });
          } else {
            this.$axios
              .post(`${ApiConstant.PREFIX_CORE}/api/sys/i18n`, params)
              .then((res) => {
                this.$message.success(this.$t("ADD_SUCCESS"));
                this.fieldList[this.curIndex].i18NCode =
                  this.dialogForm.i18nCode;
                this.$forceUpdate();
                this.i18nDialogVisible = false;
              });
          }
        }
      });
    },
    i18nSaveCancel() {
      this.i18nDialogVisible = false;
      this.menuNameList = [];
    },
    // 监听保存按钮点击事件
    handleSave() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          const { id, apiUrl, module, sourceName, sourceType, tableName } =
            this.form;
          if (this.form.sourceType === "SINGLE_TABLE") {
            if (this.fieldList.some((val) => !val.columnName)) {
              this.$message.warning(
                this.$t("PLACEENTER") + this.$t("COLUMN_NAME")
              );
              return;
            }
            if (this.fieldList.some((val) => !val.i18NCode)) {
              this.$message.warning(
                this.$t("PLACESELECT") + this.$t("INTERNATIONAL_CODING")
              );
              return;
            }
            if (this.fieldList.some((val) => !val.fieldName)) {
              this.$message.warning(
                this.$t("PLACESELECT") + this.$t("FIELD_NAME")
              );
              return;
            }
            const ids = this.fieldList.map((item) => item.columnName);
            const idsSet = new Set(ids);
            if (idsSet.size !== ids.length) {
              this.$message.warning(
                `${this.$t("CONTAINS_DUPLICATE")}${this.$t("COLUMN_NAME")}`
              );
              return;
            }
            const params = {
              id,
              sourceName,
              sourceType,
              tableName,
              module,
              fieldRelList: this.fieldList,
            };
            this.$axios
              .put(
                `${ApiConstant.PREFIX_CORE}/api/epm/pcm/object-source`,
                params
              )
              .then(() => {
                this.confirmLoading = false;
                this.$message.success(this.$t("SAVE_SUCCESS"));
                this.handleCancel();
              })
              .catch((e) => {
                this.confirmLoading = false;
              });
          } else {
            const p = this.parameterList.map((item, index) =>
              this.$refs[`ruleForm${index}`][0].validate()
            );
            Promise.all([...p]).then((res) => {
              if (res.every((item) => item)) {
                const ids = this.fieldList.map((item) => item.columnName);
                const idsSet = new Set(ids);
                if (idsSet.size !== ids.length) {
                  this.$message.warning(
                    `${this.$t("CONTAINS_DUPLICATE")}${this.$t("COLUMN_NAME")}`
                  );
                  return;
                }
                if (this.fieldList.some((val) => !val.columnName)) {
                  this.$message.warning(
                    this.$t("PLACEENTER") + this.$t("COLUMN_NAME")
                  );
                  return;
                }
                if (this.fieldList.some((val) => !val.i18NCode)) {
                  this.$message.warning(
                    this.$t("PLACESELECT") + this.$t("INTERNATIONAL_CODING")
                  );
                  return;
                }
                if (this.fieldList.some((val) => !val.fieldName)) {
                  this.$message.warning(
                    this.$t("PLACESELECT") + this.$t("FIELD_NAME")
                  );
                  return;
                }
                this.confirmLoading = true;
                let tempObj;
                const fieldRelList = this.fieldList.map((item) => {
                  tempObj = {
                    columnName: item.columnName,
                    i18NCode: item.i18NCode,
                    fieldName: item.fieldName,
                  };
                  return tempObj;
                });
                const params = {
                  id,
                  apiUrl,
                  sourceName,
                  sourceType,
                  fieldRelList,
                  module,
                  apiParam: JSON.stringify(this.parameterList),
                };
                this.$axios
                  .put(
                    `${ApiConstant.PREFIX_CORE}/api/epm/pcm/object-source`,
                    params
                  )
                  .then(() => {
                    this.confirmLoading = false;
                    this.$message.success(this.$t("SAVE_SUCCESS"));
                    this.handleCancel();
                  })
                  .catch((e) => {
                    this.confirmLoading = false;
                  });
              }
            });
          }
        }
      });
    },
    // 监听取消按钮点击事件
    handleCancel() {
      this.$store.dispatch("tagsView/jumpBeforeView", {
        to: {
          path: "/eam/basic_setting/check/object_source",
        },
        vm: this,
      });
    },
    // 页面埋点
    handleFuncUseRate(data) {
      this.$axios
        .put(`${ApiConstant.PREFIX_CORE}/api/epm/eam/use`, data)
        .then(() => {});
    },
  },
};
</script>
<style lang="less" scoped>
@import "@/assets/css/fault_repair.less";
/deep/ .mega-design-business-table .mega-design-pro-table {
  padding: 0 !important;
  margin-bottom: 24px;
}
/deep/ .ant-form-item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>

<style lang="less">
.icon-bianji2 {
  color: @primary-color !important;
}
</style>
