<template>
  <div class="detail-wrap" style="margin: -6px -8px;">
    <el-form ref="editForm" :model="fileObjNotify">
      <div class="d-header clearfix">
        <div class="fl">
          <i class="el-icon-info"/>
          <!--{{ isEdit ? $t1('查看文件对象通知设置') : $t1('新增文件对象通知设置') }}-->
          {{ $t1('文件操作 - 发系统通知设置') }}
        </div>
        <div class="fr">
          <el-button type="primary" plain class="button-sty" @click="$baseReload()" icon="el-icon-refresh-right">
            {{ $t1('重置') }}
          </el-button>
          <el-button type="primary" class="button-sty" icon="el-icon-check" @click="saveData">{{ $t1('保存') }}
          </el-button>
        </div>
      </div>
      <div class="d-cont" style="height: 470px;">
        <div class="d-item d-i-left">
          <div class="d-i-tit">
            {{ $t1('文件操作，是否发系统通知') }}
          </div>
          <el-form-item prop="toNotify" :rules="[{ required: true, trigger: 'blur' }]">
            <el-radio-group v-model="fileObjNotify.toNotify">
              <div>
                <el-radio :label="0">{{ $t1('不发系统通知') }}</el-radio>
              </div>
              <div>
                <el-radio :label="1">{{ $t1('针对当前文件夹中的文件操作') }}</el-radio>
              </div>
              <div>
                <el-radio :label="2">{{ $t1('当前文件夹与下级所有文件夹的文件进行了操作，发系统通知') }}</el-radio>
              </div>
            </el-radio-group>
          </el-form-item>
        </div>
        <div class="d-item d-i-right">
          <div class="d-i-tit">
            {{ $t1('不同的文件操作类型，设置对应的系统通知模板') }}
          </div>
          <el-form-item prop="addNtCode" :rules="[{ required: false, trigger: 'blur' }]"
                        :label="$t1('新增文件-通知模板编码')">
            <el-input type="text" autocomplete="off" v-model="fileObjNotify.addNtCode" clearable/>
          </el-form-item>
          <el-form-item prop="deleteNtCode" :rules="[{ required: false, trigger: 'blur' }]"
                        :label="$t1('删除文件-通知模板编码')">
            <el-input type="text" autocomplete="off" v-model="fileObjNotify.deleteNtCode" clearable/>
          </el-form-item>
          <el-form-item prop="replaceNtCode" :rules="[{ required: false, trigger: 'blur' }]"
                        :label=" $t1('替换文件-通知模板编码')">
            <el-input type="text" autocomplete="off" v-model="fileObjNotify.replaceNtCode" clearable/>
          </el-form-item>
        </div>
      </div>
      <div class="tips">{{
          $t1('注：删除文件发通知，包括从当前文件夹移动、删除文件。 新增文件发通知，包括上传、复制、移动、从回收站还原文件到当前文件夹下。')
        }}
      </div>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'fileObjNotifyEdit',
  props: {
    _dataId: [String, Number],
    current_prefix: String
  },
  components: {},
  data() {
    return {
      isEdit: false,
      tabIndex: 'first',
      dataId: '',
      fileObjNotify: {
        toNotify: 0,
        fileObjId: this._dataId
      }
    };
  },
  created() {
    if (this._dataId && !isNaN(this._dataId)) this.dataId = this._dataId;
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      if (this.dataId && !isNaN(this.dataId)) {

        this.$commonHttp({
          url: this.current_prefix + `/file_obj_notify/get`,
          method: `post`,
          data: {
            id: this.dataId
          },
          isLoading: true,
          modalStrictly: true,
          success: res => {
            if (res.objx) {
              this.fileObjNotify = res.objx;
              this.isEdit = true;
            }
          }
        });
      }
    },
    saveData() {
      this.$refs.editForm.$baseValidate(valid => {
        if (valid) {
          this.$baseConfirm(this.$t1('您确定要保存吗？')).then(() => {
            var url = this.current_prefix + `/file_obj_notify/save`;
            this.$http({
              url: url,
              method: `post`,
              data: this.fileObjNotify,
              isLoading: true,
              success: res => {
                this.$message({
                  message: res.content,
                  type: 'success',
                  duration: 500,
                  onClose: t => {
                    this.$baseReload();
                  }
                });
              }
            });
          });
        }
      });
    }
  }
};
</script>
<style scoped lang="scss">
.noTr th {
  height: 0px
}

.noTr td {
  height: 0px
}

.d-cont {
  display: flex;
  margin: -11px -12px;

  .d-i-left, .d-i-right {
    border: none !important;
    padding: 24px 18px 24px 14px !important
  }

  .d-i-left {
    width: 420px;
  }

  .d-i-tit {
    background: #f7f7f7;
    line-height: 36px;
    padding: 0 10px;
    margin-bottom: 16px;
    font-size: 13px
  }

  .d-i-right {
    border-left: solid 1px #e9e9e9 !important;
    flex: 1;
    padding-left: 32px !important;

    ::v-deep .el-form-item {
      margin-bottom: 16px;

      .el-form-item__content {
        .el-input {
          width: 360px !important;
        }
      }
    }
  }
}

.tips {
  margin-top: -40px;
  background: #FFF;
  position: relative;
  line-height: 40px;
  border-top: solid 1px #e9e9e9;
  padding-left: 12px;
}
</style>
