let modules = {};
modules = {
  name: 'wfObjConfigItemEdit',
  props: {
    _dataId: [String, Number],
    formTemplate: Object,
    wfObjConfig: Object
  },
  components: {},
  data() {
    return {
      tabIndex: 0,
      isEdit: false,
      dataId: '',
      wfObjConfigItem: {
        skipFirstTask: true,
        skipAdjacentTask: false,
        toRejectNode: false,
        startMode: 3,
        skipSameUserTask: false,
        enabled: true
      },
      showWfObjConfigDialog: false,
      configServiceId: null,
      showCodeEditor: false
    };
  },
  computed: {
    current_prefix() {
      // return this.configServiceId ? ('/' + this.configServiceId) : ''
      return "/" + this.wfObjConfig.serviceId;
    },
  },
  created() {
    if (this._dataId && !isNaN(this._dataId)) {
      this.dataId = this._dataId;
    } else {
      this.wfObjConfigItem.objConfigId = this.formTemplate.id;
      this.wfObjConfigItem.objTypeCode = this.wfObjConfig.objTypeCode;
      this.wfObjConfigItem.objTypeName = this.wfObjConfig.objTypeName;
    }
    this.configServiceId = this.serviceId || '';
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      if (this.dataId && !isNaN(this.dataId)) {
        this.isEdit = true;
        this.$commonHttp({
          aes:true,
          url: this.current_prefix + `/wf_obj_config_item/get`,
          method: `post`,
          data: {
            id: this.dataId
          },
          isLoading: true,
          modalStrictly: true,
          success: res => {
            this.wfObjConfigItem = res.objx || {};
            this.showCodeEditor = true;
          }
        });
      } else {
        this.showCodeEditor = true;
      }
    },
    saveData() {
      this.$refs.editForm.$baseValidate(valid => {
        if (valid) {
          this.$baseConfirm(this.$t1('您确定要保存吗？')).then(() => {
            var url = this.current_prefix + (this.isEdit ? `/wf_obj_config_item/update` : `/wf_obj_config_item/save`);
            this.$http({
          aes:true,
              url: url,
              method: `post`,
              data: this.wfObjConfigItem,
              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,
                          wfObjConfig: null
                        }
                      });
                    }
                  }
                });
              }
            });
          });
        }
      });
    }
  }
};
export default modules
