|
|
@@ -1,326 +0,0 @@
|
|
|
-<template>
|
|
|
- <div class="modal fade in" role="dialog" aria-labelledby="appModal_title"
|
|
|
- aria-hidden="false" style="display: block;" v-if="appVisible">
|
|
|
- <div class="modal-dialog x-modal-dialog modal-lg" role="document">
|
|
|
- <div class="modal-content">
|
|
|
- <div class="modal-header">
|
|
|
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"
|
|
|
- @click="appVisible = false">
|
|
|
- <span aria-hidden="true">×</span>
|
|
|
- </button>
|
|
|
- <h4 class="modal-title" id="appModal_title">应用</h4>
|
|
|
- </div>
|
|
|
- <div class="modal-body">
|
|
|
- <form class="form-horizontal x-form">
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">唯一标识</label>
|
|
|
- <div class="col-sm-3">
|
|
|
- <input type="text" class="form-control" name="uid" title="uid" required
|
|
|
- v-model="appInfo.uid">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">描述</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="description" title="description" required
|
|
|
- v-model="appInfo.description">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">主页</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="homePage" title="homePage" required
|
|
|
- v-model="appInfo.homePage">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">类型</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <label class="radio-inline">
|
|
|
- <input type="radio" name="type" value="default" v-model="appInfo.type"> 独立应用
|
|
|
- </label>
|
|
|
- <label class="radio-inline">
|
|
|
- <input type="radio" name="type" value="control" v-model="appInfo.type"> 级联应用
|
|
|
- </label>
|
|
|
- <div class="help-block">
|
|
|
- 级联应用是指没有独立企业、用户及权限控制系统的应用,要借助其他应用的资源来达到控制效果
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div id="appModal_type_default" v-show="showDefault">
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">公钥</label>
|
|
|
- <div class="col-sm-10" id="keypair">
|
|
|
- <textarea name="publicKey" title="publicKey" rows="3" class="form-control" readonly
|
|
|
- v-model="appInfo.publicKey"></textarea>
|
|
|
- <ul class="help-block x-menu">
|
|
|
- <li>点击<a class="btn-create" href="javascript:void(0)" @click="generateSecret()">生成密钥对</a></li>
|
|
|
- <li>账户中心只保留公钥用于校验,请将私钥配置到程序中,并妥善保管</li>
|
|
|
- <li v-show="canDownload">
|
|
|
- <a class="btn-download" target="_blank" href="/api/app/private//download">下载私钥</a>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">企业回调</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="backSpaceUrl" required
|
|
|
- v-model="appInfo.backSpaceUrl" placeholder="应用接口,用于企业信息有变化时回调">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">用户回调</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="backUserUrl" required
|
|
|
- v-model="appInfo.backUserUrl" placeholder="应用接口,用于用户信息有变化时回调">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">用户密码回调</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="backUserPwdUrl" required
|
|
|
- v-model="appInfo.backUserPwdUrl" placeholder="应用接口,用于用户密码修改时回调">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">密码加密格式</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="encryFormat" required
|
|
|
- v-model="appInfo.encryFormat" placeholder="用户密码加密的格式">
|
|
|
- <ul class="help-block x-menu">
|
|
|
- <li><code>$password</code>表示密码明文;<code>$salt</code>表示盐值</li>
|
|
|
- <li>可任意组合,例如:<code>$password($salt)</code>;不填写表示不对密码加密</li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">登录回调</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="loginUrl" required
|
|
|
- v-model="appInfo.loginUrl" placeholder="应用接口,用于企业信息有变化时回调">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">登出回调</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <input type="text" class="form-control" name="logoutUrl" required
|
|
|
- v-model="appInfo.logoutUrl" placeholder="应用接口,用于企业信息有变化时回调">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">关联应用</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <textarea name="copyApps" rows="3" class="form-control" v-model="appInfo.copyApps"
|
|
|
- placeholder="填写应用唯一标识,不填表示全部;多个用逗号、分号、空格或回车分隔"></textarea>
|
|
|
- <ul class="help-block x-menu">
|
|
|
- <li>关联应用是指与当前应用有关的应用</li>
|
|
|
- <li>相关联的应用间,任何一方的企业或个人信息有修改,都会通过回调接口同步到其他应用</li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">默认开通</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <label class="radio-inline">
|
|
|
- <!--suppress HtmlUnknownAttribute -->
|
|
|
- <input type="radio" name="defaultUse" value="1" v-model.number="appInfo.defaultUse"> 是
|
|
|
- </label>
|
|
|
- <label class="radio-inline">
|
|
|
- <!--suppress HtmlUnknownAttribute -->
|
|
|
- <input type="radio" name="defaultUse" value="0" v-model.number="appInfo.defaultUse"> 否
|
|
|
- </label>
|
|
|
- <div class="help-block">
|
|
|
- 用户注册的时候,默认为该用户开通此应用
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <!--<div class="form-group">
|
|
|
- <label class="control-label col-sm-2">使用域</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <label class="radio-inline"> <input type="radio" name="scope" value="PUBLIC" checked=""> 开放
|
|
|
- </label> <label class="radio-inline"> <input type="radio" name="scope" value="PROTECTED"> 受保护
|
|
|
- </label> <label class="radio-inline"> <input type="radio" name="scope" value="PRIVATE"> 私有
|
|
|
- </label>
|
|
|
- <div class="help-block">
|
|
|
- 私有应用只能内部使用;受保护应用只能指定用户群使用
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>-->
|
|
|
- <!--<div class="form-group">
|
|
|
- <label class="control-label col-sm-2">应用ID唯一</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <label class="radio-inline"> <input type="radio" name="dialectEnable" value="1" checked=""> 是
|
|
|
- </label> <label class="radio-inline"> <input type="radio" name="dialectEnable" value="0"> 否
|
|
|
- </label>
|
|
|
- <div class="help-block">
|
|
|
- 当ID唯一时,可以使用ID作为账户登录
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>-->
|
|
|
- <!-- 是否支持个人账号 -->
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">支持个人账号</label>
|
|
|
- <div class="col-sm-10">
|
|
|
- <label class="radio-inline">
|
|
|
- <input type="radio" name="personalEnable" value="1" v-model="appInfo.personalEnable"> 是
|
|
|
- </label>
|
|
|
- <label class="radio-inline">
|
|
|
- <input type="radio" name="personalEnable" value="0" v-model="appInfo.personalEnable"> 否
|
|
|
- </label>
|
|
|
- <div class="help-block">
|
|
|
- 用户注册的时候,该应用将根据此选项决定是否开放个人注册页面
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div id="appModal_type_control" v-show="showControl">
|
|
|
- <div class="form-group">
|
|
|
- <label class="control-label col-sm-2">级联应用</label>
|
|
|
- <div class="col-sm-3">
|
|
|
- <input type="text" class="form-control" name="userControl" placeholder="填写应用唯一标识"
|
|
|
- required v-model="appInfo.userControl">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- <div class="modal-footer">
|
|
|
- <button type="button" class="btn btn-blank" data-dismiss="modal" @click="appVisible = false">取消</button>
|
|
|
- <button type="button" class="btn btn-blank btn-del" v-show="!isAdd" @click="deleteAppInfo()">删除</button>
|
|
|
- <button type="button" class="btn btn-default btn-submit" @click="saveAppInfo()">保存</button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-import _ from 'lodash'
|
|
|
-import axios from '@/assets/js/axios'
|
|
|
-
|
|
|
-export default {
|
|
|
- name: 'app-modal',
|
|
|
- props: {
|
|
|
- visible: Boolean,
|
|
|
- data: Object
|
|
|
- },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- appVisible: false,
|
|
|
- isAdd: true,
|
|
|
- appInfo: {},
|
|
|
- canDownload: false
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- visible: function (value) {
|
|
|
- this.appVisible = value
|
|
|
- },
|
|
|
- appVisible: function (value) {
|
|
|
- this.$emit('update:visible', value)
|
|
|
- },
|
|
|
- data: function (value) {
|
|
|
- value = value || {}
|
|
|
-
|
|
|
- this.isAdd = !value.uid
|
|
|
-
|
|
|
- // Set default values for app
|
|
|
- const defaults = { type: value.userControl ? 'control' : 'default' }
|
|
|
-
|
|
|
- // Set default values for new app info
|
|
|
- if (!value.userControl && !value.uid) {
|
|
|
- defaults.defaultUse = '1'
|
|
|
- defaults.personalEnable = 1
|
|
|
- }
|
|
|
-
|
|
|
- // To implement two-way bindings, deep copy data to appInfo, when data changes.
|
|
|
- this.appInfo = _.defaults({}, value, defaults)
|
|
|
- console.log('App type: ', this.appInfo.type)
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- saveAppInfo () {
|
|
|
- // Validation
|
|
|
- if (!this.appInfo.uid) {
|
|
|
- this.showRequiredError({message: '应用唯一标识不能为空'})
|
|
|
- return 0
|
|
|
- } else if (!this.appInfo.description) {
|
|
|
- this.showRequiredError({message: '应用描述不能为空'})
|
|
|
- return 0
|
|
|
- } else if (this.appInfo.type === 'control' && !this.appInfo.userControl) {
|
|
|
- this.appInfo.userControl = this.appInfo.userControl || ' '
|
|
|
- this.showRequiredError({message: '级联应用的唯一标识不能为空'})
|
|
|
- return 0
|
|
|
- }
|
|
|
-
|
|
|
- const appInfo = _.omit(this.appInfo, 'type')
|
|
|
- console.log(appInfo)
|
|
|
-
|
|
|
- const success = () => {
|
|
|
- this.$emit('success')
|
|
|
- this.appVisible = false
|
|
|
- }
|
|
|
- const error = response => { this.showAddError({ message: response }) }
|
|
|
-
|
|
|
- if (!this.isAdd) {
|
|
|
- axios.put('/api/app//updateApp', appInfo).then(success).catch(error)
|
|
|
- } else {
|
|
|
- axios.post('/api/app//addApp', appInfo).then(success).catch(error)
|
|
|
- }
|
|
|
- },
|
|
|
- deleteAppInfo () {
|
|
|
- const uid = this.appInfo.uid || ''
|
|
|
-
|
|
|
- const success = () => {
|
|
|
- this.$emit('success')
|
|
|
- this.appVisible = false
|
|
|
- }
|
|
|
- const error = response => { this.showAddError({ message: response }) }
|
|
|
-
|
|
|
- axios.delete(`/api/app/${uid}/deleteApp`).then(success).catch(error)
|
|
|
- },
|
|
|
- generateSecret () {
|
|
|
- console.log(1)
|
|
|
- const success = (publicKey) => {
|
|
|
- console.log(publicKey)
|
|
|
- if (publicKey) {
|
|
|
- this.canDownload = true
|
|
|
- this.appInfo.publicKey = publicKey
|
|
|
- } else {
|
|
|
- this.canDownload = false
|
|
|
- }
|
|
|
- }
|
|
|
- const error = response => {
|
|
|
- this.canDownload = false
|
|
|
- this.showAddError({ message: response })
|
|
|
- }
|
|
|
-
|
|
|
- axios.get('/api/app/secret//generate').then(success).catch(error)
|
|
|
- }
|
|
|
- },
|
|
|
- computed: {
|
|
|
- showDefault () {
|
|
|
- return this.appInfo.type === 'default'
|
|
|
- },
|
|
|
- showControl () {
|
|
|
- return this.appInfo.type === 'control'
|
|
|
- }
|
|
|
- },
|
|
|
- notifications: {
|
|
|
- showAddError: {
|
|
|
- title: 'Add Failed',
|
|
|
- message: 'Failed to add app info',
|
|
|
- type: 'error'
|
|
|
- },
|
|
|
- showRequiredError: {
|
|
|
- message: 'Required',
|
|
|
- type: 'error'
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</script>
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-
|
|
|
-</style>
|