index.vue 5.83 KB
<!--
 * @Author: your name
 * @Date: 2022-03-02 18:28:20
 * @LastEditTime: 2022-03-14 18:24:08
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \scrm-micro-settings\src\views\approvalConfig\index.vue
-->
<template>
  <div>
    <div class="page-tips">
      <img src="../../../src/assets/img/Shape.png" alt="" />
      <span>企微管理员通过在企微后台创建审批模板,设置好审批人员后,将对应审批模板的ID复制到下方需要调用该审批的模块,该模块即可调用审批。</span>
    </div>
    <div class="config-page" :style="{ 'min-height': clientHeight + 'px' }">
      <div class="page-title">
        审批配置
        <GLButton type="text" class="guide-btn" @click="jumpGuide" fn="审批模板创建指引">查看创建审批模板指引</GLButton>
        <!-- <el-button type="text" class="guide-btn" @click="jumpGuide">查看创建审批模板指引></el-button> -->
      </div>
      <div class="config-list">
        <div class="config-item" v-for="(item, index) in configList" :key="item.id">
          <div class="config-title">
            <span>{{ item.title }}</span>
          </div>
          <div class="config-content">
            <span class="config-label">{{ item.name }}</span>
            <el-input class="config-input" :placeholder="item.placeholder" :disabled="item.disabled" :size="size" v-model="config[item.model]" clearable></el-input>
            <el-button-group class="config-btn" v-if="!item.disabled">
              <el-button type="text" @click="cancel(item.model, index)">取消</el-button>
              <el-button type="text" @click="submit(item.model, index)">确定</el-button>
            </el-button-group>
            <el-button-group v-else class="config-btn">
              <el-button type="text" @click="edit(index)">编辑</el-button>
            </el-button-group>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import util from '@/utils/util'
export default {
  name: 'ApprovalConfig',
  data() {
    return {
      input: '',
      config: {
        approveTemplateId: ''
        // input1: '3'
      },
      oldConfig: {},
      configList: [
        {
          id: 1,
          title: '定向礼包',
          name: '审批模板ID:',
          model: 'approveTemplateId',
          placeholder: '请将模板ID粘贴到此处,不填写则不调用审批',
          disabled: true
          // },
          // {
          //   id: 2,
          //   title: '定向礼包',
          //   name: '审批模板ID:',
          //   model: 'input1',
          //   placeholder: '请将模板ID粘贴到此处,不填写则不调用审批',
          //   disabled: true
        }
      ],
      clientHeight: 500
    }
  },
  created() {
    this.getApprove()
  },
  mounted() {
    this.clientHeight = document.documentElement.scrollHeight - 140
  },
  methods: {
    // 编辑
    edit(index) {
      this.configList[index].disabled = false
    },
    // 提交
    submit(model, index) {
      this.oldConfig[model] = this.config[model]
      this.configList[index].disabled = true
      const params = {
        merchantId: this.$globalState.session.merchantId,
        approveTemplateId: this.config.approveTemplateId
      }
      this.$apis.approvalConfig.saveApprove(params).then(res => {
        if (res) {
          this.$message({
            type: 'success',
            message: '操作成功'
          })
        } else {
          this.$message({
            type: 'error',
            message: '操作失败'
          })
        }
      })
    },
    // 取消
    cancel(model, index) {
      console.log(this.oldConfig[model])
      this.config[model] = this.oldConfig[model]
      this.configList[index].disabled = true
    },
    // 调整环审批模板指引
    jumpGuide() {
      this.$router.push({ path: '/approvalConfig/createGuide' })
    },
    getApprove() {
      const merchantId = this.$globalState.session.merchantId
      // const merchantId = 44209572
      this.$apis.approvalConfig.getApproveDetail({ merchantId }).then(res => {
        this.config.approveTemplateId = res
        this.oldConfig = util.deepClone(this.config)
      })
    }
  }
}
</script>

<style scoped lang="scss">
.page-tips {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  padding: 10px 16px;
  border: 1px solid #5850ff;
  border-radius: 4px;
  background-color: #e6e9ff;
  margin-bottom: 10px;
  img {
    width: 14px;
    height: 14px;
    margin-right: 8px;
  }
}
.config-page {
  background-color: #fff;
  .page-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    padding: 15px 20px;
    border-bottom: 1px solid #d8d8d8;
    .guide-btn {
      text-decoration: underline;
      margin-left: 16px;
    }
  }
  .config-list {
    padding: 32px 20px;
    .config-item {
      margin-bottom: 20px;
    }
    .config-title {
      font-size: 14px;
      font-weight: 500;
      color: #333;
      margin-bottom: 16px;
      span {
        position: relative;
        display: inline-block;
        width: 76px;
        text-align: center;
        z-index: 0;
        &::after {
          content: '';
          display: inline-block;
          position: absolute;
          width: 100%;
          height: 9px;
          background-color: #e6e5ff;
          left: 0;
          bottom: 0;
          z-index: -1;
        }
      }
    }
    .config-content {
      .config-label {
        display: inline-block;
        width: 118px;
        font-size: 14px;
        font-weight: 400;
        color: #333333;
        text-align: right;
      }
      .config-input {
        width: 415px;
      }
      .config-btn {
        .el-button {
          margin-left: 12px;
        }
      }
    }
  }
}
</style>