let  modules = {}
modules = {
  name: "logic_paramEdit",
  props: {
    _dataId: [String, Number],
    paramType: {
      type: Number,
      default: 0,
    },
  },
  components: {},
  data() {
    return {
      isEdit: false,
      tabIndex: "first",
      dataId: "",
      logicParam: {
        enabled: true,
        paramValue: null,
        paramType: this.paramType,
      },
      showCodeEditor: false,
      paramTypeMap: {
        0: "逻辑参数",
        1: "操作日志编码",
        2: "上传文件服务",
      },
    };
  },
  created() {
    if (this._dataId && !isNaN(this._dataId)) this.dataId = this._dataId;
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      if (this.dataId && !isNaN(this.dataId)) {
        this.isEdit = true;
        this.$commonHttp({
          url: USER_PREFIX + `/logic_param/get`,
          method: `post`,
          data: {
            id: this.dataId,
          },
          isLoading: true,
          modalStrictly: true,
          success: (res) => {
            this.logicParam = res.objx || {};
            this.showCodeEditor = true;
          },
        });
      } else {
        this.showCodeEditor = true;
      }
    },
    saveData() {
      this.$refs.editForm.$baseValidate((valid) => {
        if (valid) {
          this.$baseConfirm(this.$t1("您确定要保存吗？")).then(() => {
            var url =
              USER_PREFIX + (this.isEdit ? `/logic_param/update` : `/logic_param/save`);
            this.$http({
              url: url,
              method: `post`,
              data: this.logicParam,
              isLoading: true,
              success: (res) => {
                this.$message({
                  message: res.content,
                  type: "success",
                  duration: 500,
                  onClose: (t) => {
                    if (this.isEdit) {
                      this.$baseReload();
                    } else {
                      this.$baseReload({
                        updateParam: {
                          _dataId: res.objx
                        },
                      });
                    }
                  },
                });
              },
            });
          });
        }
      });
    },
  },
};
export default modules
