|
@@ -62,6 +62,35 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
|
+ <!-- 中间件配置(仅card服务商) -->
|
|
|
|
|
+ <template v-if="props.row.provider === 'card'">
|
|
|
|
|
+ <el-divider content-position="left" style="margin:16px 0 8px">中间件配置</el-divider>
|
|
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
|
+ <el-button type="success" plain icon="el-icon-plus" size="mini" @click="handleAddMiddleware(props.row)">新增中间件</el-button>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ <el-table :data="middlewareMap[props.row.apiId] || []" border size="mini" v-loading="mwLoading">
|
|
|
|
|
+ <el-table-column label="ID" align="center" prop="id" width="60" />
|
|
|
|
|
+ <el-table-column label="名称" align="center" prop="middlewareName" min-width="120" />
|
|
|
|
|
+ <el-table-column label="下发URL" align="center" prop="callbackUrl" min-width="180" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column label="心跳URL" align="center" prop="heartbeatUrl" min-width="180" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column label="Token" align="center" prop="authToken" width="120" show-overflow-tooltip />
|
|
|
|
|
+ <el-table-column label="重试次数" align="center" prop="maxRetry" width="80" />
|
|
|
|
|
+ <el-table-column label="超时(秒)" align="center" prop="timeoutSeconds" width="80" />
|
|
|
|
|
+ <el-table-column label="状态" align="center" prop="status" width="70">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'" size="mini">{{ scope.row.status === 1 ? '正常' : '禁用' }}</el-tag>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="操作" align="center" width="120">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-button size="mini" type="text" @click="handleEditMiddleware(scope.row, props.row)">修改</el-button>
|
|
|
|
|
+ <el-button size="mini" type="text" style="color:#f56c6c" @click="handleDelMiddleware(scope.row, props.row)">删除</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+ </template>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -232,12 +261,49 @@
|
|
|
<el-button @click="portDialogVisible = false">取 消</el-button>
|
|
<el-button @click="portDialogVisible = false">取 消</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 中间件弹窗 -->
|
|
|
|
|
+ <el-dialog :title="mwDialogTitle" :visible.sync="mwDialogVisible" width="580px" append-to-body>
|
|
|
|
|
+ <el-form ref="mwForm" :model="mwForm" :rules="mwRules" label-width="100px" size="small">
|
|
|
|
|
+ <el-form-item label="中间件名称" prop="middlewareName">
|
|
|
|
|
+ <el-input v-model="mwForm.middlewareName" placeholder="如:红米Note12中间件" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="下发任务URL" prop="callbackUrl">
|
|
|
|
|
+ <el-input v-model="mwForm.callbackUrl" placeholder="http://192.168.1.100:8080/sms/send" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="心跳上报URL">
|
|
|
|
|
+ <el-input v-model="mwForm.heartbeatUrl" placeholder="http://192.168.1.100:8080/sms/heartbeat" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="鉴权Token">
|
|
|
|
|
+ <el-input v-model="mwForm.authToken" placeholder="Bearer token" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
|
+ <el-col :span="12">
|
|
|
|
|
+ <el-form-item label="最大重试次数">
|
|
|
|
|
+ <el-input-number v-model="mwForm.maxRetry" :min="0" :max="10" style="width:100%" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="12">
|
|
|
|
|
+ <el-form-item label="超时秒数">
|
|
|
|
|
+ <el-input-number v-model="mwForm.timeoutSeconds" :min="1" :max="300" style="width:100%" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ <el-form-item label="状态">
|
|
|
|
|
+ <el-switch v-model="mwForm.status" :active-value="1" :inactive-value="0" active-text="正常" inactive-text="禁用" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <div slot="footer">
|
|
|
|
|
+ <el-button type="primary" @click="submitMwForm">确 定</el-button>
|
|
|
|
|
+ <el-button @click="mwDialogVisible = false">取 消</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import { listSmsApi, getSmsApi, addSmsApi, updateSmsApi, delSmsApi } from '@/api/system/smsApi'
|
|
import { listSmsApi, getSmsApi, addSmsApi, updateSmsApi, delSmsApi } from '@/api/system/smsApi'
|
|
|
-import { listPortByApi, addPort, updatePort, delPort } from '@/api/system/smsPort'
|
|
|
|
|
|
|
+import { listPortByApi, addPort, updatePort, delPort, listMiddleware, getMiddlewareByApi, addMiddleware, updateMiddleware, delMiddleware } from '@/api/system/smsPort'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'AdminSmsApi',
|
|
name: 'AdminSmsApi',
|
|
@@ -247,6 +313,8 @@ export default {
|
|
|
portLoading: false,
|
|
portLoading: false,
|
|
|
apiList: [],
|
|
apiList: [],
|
|
|
portMap: {},
|
|
portMap: {},
|
|
|
|
|
+ middlewareMap: {},
|
|
|
|
|
+ mwLoading: false,
|
|
|
dialogVisible: false,
|
|
dialogVisible: false,
|
|
|
dialogTitle: '',
|
|
dialogTitle: '',
|
|
|
portDialogVisible: false,
|
|
portDialogVisible: false,
|
|
@@ -270,6 +338,13 @@ export default {
|
|
|
portRules: {
|
|
portRules: {
|
|
|
portName: [{ required: true, message: '端口名称不能为空', trigger: 'blur' }],
|
|
portName: [{ required: true, message: '端口名称不能为空', trigger: 'blur' }],
|
|
|
portNo: [{ required: true, message: '端口号不能为空', trigger: 'blur' }]
|
|
portNo: [{ required: true, message: '端口号不能为空', trigger: 'blur' }]
|
|
|
|
|
+ },
|
|
|
|
|
+ mwDialogVisible: false,
|
|
|
|
|
+ mwDialogTitle: '',
|
|
|
|
|
+ mwForm: {},
|
|
|
|
|
+ mwRules: {
|
|
|
|
|
+ middlewareName: [{ required: true, message: '中间件名称不能为空', trigger: 'blur' }],
|
|
|
|
|
+ callbackUrl: [{ required: true, message: '下发任务URL不能为空', trigger: 'blur' }]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -345,10 +420,6 @@ export default {
|
|
|
}).catch(() => {})
|
|
}).catch(() => {})
|
|
|
},
|
|
},
|
|
|
// ========== 端口池 ==========
|
|
// ========== 端口池 ==========
|
|
|
- handleExpand(row, expandedRows) {
|
|
|
|
|
- if (this.portMap[row.apiId]) return
|
|
|
|
|
- this.loadPorts(row.apiId)
|
|
|
|
|
- },
|
|
|
|
|
loadPorts(apiId) {
|
|
loadPorts(apiId) {
|
|
|
this.portLoading = true
|
|
this.portLoading = true
|
|
|
listPortByApi(apiId).then(res => {
|
|
listPortByApi(apiId).then(res => {
|
|
@@ -401,6 +472,62 @@ export default {
|
|
|
this.loadPorts(row.apiId)
|
|
this.loadPorts(row.apiId)
|
|
|
})
|
|
})
|
|
|
}).catch(() => {})
|
|
}).catch(() => {})
|
|
|
|
|
+ },
|
|
|
|
|
+ // ========== 中间件管理 ==========
|
|
|
|
|
+ handleExpand(row, expandedRows) {
|
|
|
|
|
+ if (!this.portMap[row.apiId]) this.loadPorts(row.apiId)
|
|
|
|
|
+ if (row.provider === 'card' && !this.middlewareMap[row.apiId]) this.loadMiddleware(row.apiId)
|
|
|
|
|
+ },
|
|
|
|
|
+ loadMiddleware(apiId) {
|
|
|
|
|
+ this.mwLoading = true
|
|
|
|
|
+ getMiddlewareByApi(apiId).then(res => {
|
|
|
|
|
+ this.$set(this.middlewareMap, apiId, res.data || [])
|
|
|
|
|
+ }).finally(() => { this.mwLoading = false })
|
|
|
|
|
+ },
|
|
|
|
|
+ resetMwForm() {
|
|
|
|
|
+ this.mwForm = { id: undefined, apiId: null, middlewareName: '', callbackUrl: '', heartbeatUrl: '', authToken: '', maxRetry: 3, timeoutSeconds: 30, status: 1 }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleAddMiddleware(apiRow) {
|
|
|
|
|
+ this.resetMwForm()
|
|
|
|
|
+ this.currentApiId = apiRow.apiId
|
|
|
|
|
+ this.mwForm.apiId = apiRow.apiId
|
|
|
|
|
+ this.mwDialogTitle = '新增中间件 - ' + apiRow.apiName
|
|
|
|
|
+ this.mwDialogVisible = true
|
|
|
|
|
+ },
|
|
|
|
|
+ handleEditMiddleware(mwRow, apiRow) {
|
|
|
|
|
+ this.resetMwForm()
|
|
|
|
|
+ this.currentApiId = apiRow.apiId
|
|
|
|
|
+ this.mwForm = { ...mwRow }
|
|
|
|
|
+ this.mwDialogTitle = '修改中间件'
|
|
|
|
|
+ this.mwDialogVisible = true
|
|
|
|
|
+ },
|
|
|
|
|
+ submitMwForm() {
|
|
|
|
|
+ this.$refs.mwForm.validate(valid => {
|
|
|
|
|
+ if (!valid) return
|
|
|
|
|
+ if (this.mwForm.id) {
|
|
|
|
|
+ updateMiddleware(this.mwForm).then(() => {
|
|
|
|
|
+ this.$message.success('修改成功')
|
|
|
|
|
+ this.mwDialogVisible = false
|
|
|
|
|
+ this.loadMiddleware(this.currentApiId)
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ addMiddleware(this.mwForm).then(() => {
|
|
|
|
|
+ this.$message.success('新增成功')
|
|
|
|
|
+ this.mwDialogVisible = false
|
|
|
|
|
+ this.loadMiddleware(this.currentApiId)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ handleDelMiddleware(row, apiRow) {
|
|
|
|
|
+ this.$confirm('确认删除中间件"' + row.middlewareName + '"?', '提示', {
|
|
|
|
|
+ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ delMiddleware(row.id).then(() => {
|
|
|
|
|
+ this.$message.success('删除成功')
|
|
|
|
|
+ this.loadMiddleware(apiRow.apiId)
|
|
|
|
|
+ })
|
|
|
|
|
+ }).catch(() => {})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|