|
@@ -1,5 +1,5 @@
|
|
<template>
|
|
<template>
|
|
- <el-dialog :title="title" :visible.sync="visible" width="380px">
|
|
|
|
|
|
+ <el-dialog :title="title" :visible.sync="visible" width="450px" :before-close="onClose">
|
|
<el-form :model="queryForm" ref="setSecret" :rules="rules">
|
|
<el-form :model="queryForm" ref="setSecret" :rules="rules">
|
|
<el-form-item label="企微ID" prop="originCorpId">
|
|
<el-form-item label="企微ID" prop="originCorpId">
|
|
<el-input v-model.number="queryForm.originCorpId" placeholder="请输入企微ID" clearable size="small" />
|
|
<el-input v-model.number="queryForm.originCorpId" placeholder="请输入企微ID" clearable size="small" />
|
|
@@ -7,9 +7,37 @@
|
|
<el-form-item label="客户密钥" prop="externalUserSecret">
|
|
<el-form-item label="客户密钥" prop="externalUserSecret">
|
|
<el-input v-model="queryForm.externalUserSecret" placeholder="请输入客户密钥" clearable size="small" />
|
|
<el-input v-model="queryForm.externalUserSecret" placeholder="请输入客户密钥" clearable size="small" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="书城应用ID" prop="bookAgentId">
|
|
|
|
|
|
+ <!-- <el-form-item label="书城应用ID" prop="bookAgentId">
|
|
<el-input v-model.number="queryForm.bookAgentId" placeholder="请输入书城应用ID" clearable size="small" />
|
|
<el-input v-model.number="queryForm.bookAgentId" placeholder="请输入书城应用ID" clearable size="small" />
|
|
- </el-form-item>
|
|
|
|
|
|
+ </el-form-item> -->
|
|
|
|
+ <div>
|
|
|
|
+ <el-form :model="item" :rules="rulesBookCityType" ref="bookCityType" label-width="80px" label-position="top"
|
|
|
|
+ v-for="(item, index) in queryPlatformBookCity" :key="index">
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="书城" prop="bookCityId">
|
|
|
|
+ <el-select v-model="item.bookCityId" size="small" placeholder="选择书城" filterable clearable>
|
|
|
|
+ <el-option v-for="item in bookCity" :disabled="item.disabled" :key="item.id" :label="item.platformName"
|
|
|
|
+ :value="item.platformKey" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="12">
|
|
|
|
+ <el-form-item label="书城应用ID" prop="bookAgentId">
|
|
|
|
+ <el-input v-model.number="item.bookAgentId" placeholder="请输入书城应用ID" clearable
|
|
|
|
+ size="small" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ <div style="margin-top: 42px">
|
|
|
|
+ <el-button @click.prevent="removeResource(index)" type="text" icon="el-icon-delete"
|
|
|
|
+ style="color: red; margin-left: 10px"></el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-form>
|
|
|
|
+ <el-button type="text" icon="el-icon-plus" @click="addResource">新增书城</el-button>
|
|
|
|
+ </div>
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input type="textarea" v-model="queryForm.remark" placeholder="请输入备注" clearable size="small" />
|
|
<el-input type="textarea" v-model="queryForm.remark" placeholder="请输入备注" clearable size="small" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -23,6 +51,7 @@
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
import { refreshCorp } from "@/api/accounts/corpWeChat";
|
|
import { refreshCorp } from "@/api/accounts/corpWeChat";
|
|
|
|
+import { getBookPlatInfoAll } from "@/api/accounts/bookCity";
|
|
export default {
|
|
export default {
|
|
name: 'setSecret',
|
|
name: 'setSecret',
|
|
data() {
|
|
data() {
|
|
@@ -38,7 +67,18 @@ export default {
|
|
},
|
|
},
|
|
queryForm: {
|
|
queryForm: {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ queryPlatformBookCity: [],
|
|
|
|
+ rulesBookCityType: {
|
|
|
|
+ bookCityId: [
|
|
|
|
+ { required: true, message: '请选择书城', trigger: 'change' }
|
|
|
|
+ ],
|
|
|
|
+ bookAgentId: [
|
|
|
|
+ { required: true, message: '请输入书城应用ID', trigger: 'change' }
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ bookCity: [],
|
|
|
|
+ bookCityCS: [],
|
|
}
|
|
}
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
@@ -53,48 +93,118 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
|
|
+ visible: {
|
|
|
|
+ handler(val) {
|
|
|
|
+ console.log('11111-->', val)
|
|
|
|
+ },
|
|
|
|
+ immediate: true,
|
|
|
|
+ },
|
|
value: {
|
|
value: {
|
|
handler(val) {
|
|
handler(val) {
|
|
- this.queryForm = val
|
|
|
|
|
|
+ let { bookAgentIdMap, ...data } = val
|
|
|
|
+ this.queryForm = data
|
|
|
|
+ this.queryPlatformBookCity = bookAgentIdMap
|
|
},
|
|
},
|
|
immediate: true,
|
|
immediate: true,
|
|
},
|
|
},
|
|
|
|
+ queryPlatformBookCity: {
|
|
|
|
+ handler(val) {
|
|
|
|
+ if (val.length > 0) {
|
|
|
|
+ let data = this.bookCityCS.map(item => {
|
|
|
|
+ if (val.some(i => i.bookCityId === item.platformKey)) {
|
|
|
|
+ return { ...item, disabled: true }
|
|
|
|
+ }
|
|
|
|
+ return { ...item, disabled: false }
|
|
|
|
+ })
|
|
|
|
+ this.bookCity = data
|
|
|
|
+ } else {
|
|
|
|
+ this.bookCity = this.bookCityCS
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ deep: true,
|
|
|
|
+ immediate: false,
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.getAllData()
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ /** 新增用户 */
|
|
|
|
+ addResource() {
|
|
|
|
+ let oldData = JSON.parse(JSON.stringify(this.queryPlatformBookCity))
|
|
|
|
+ oldData.push({
|
|
|
|
+ bookCityId: null,
|
|
|
|
+ bookAgentId: null
|
|
|
|
+ })
|
|
|
|
+ this.queryPlatformBookCity = oldData
|
|
|
|
+ },
|
|
|
|
+ /** 删除用户 */
|
|
|
|
+ removeResource(index) {
|
|
|
|
+ this.queryPlatformBookCity.splice(index, 1)
|
|
|
|
+ },
|
|
|
|
+ getAllData() {
|
|
|
|
+ // 获取所有书城
|
|
|
|
+ getBookPlatInfoAll().then(res => {
|
|
|
|
+ this.bookCity = res.data
|
|
|
|
+ this.bookCityCS = res.data
|
|
|
|
+ })
|
|
|
|
+ },
|
|
onClose() {
|
|
onClose() {
|
|
this.$emit("close");
|
|
this.$emit("close");
|
|
},
|
|
},
|
|
|
|
+ stateHandle(ref) {
|
|
|
|
+ return new Promise((resolve) => {
|
|
|
|
+ ref.validate(valid => resolve(valid))
|
|
|
|
+ })
|
|
|
|
+ },
|
|
onSubmit() {
|
|
onSubmit() {
|
|
- this.$refs['setSecret'].validate((valid) => {
|
|
|
|
|
|
+ this.$refs['setSecret'].validate(async (valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- console.log('=======>', this.queryForm);
|
|
|
|
- const loading = this.$loading({
|
|
|
|
- lock: true,
|
|
|
|
- text: 'Loading',
|
|
|
|
- spinner: 'el-icon-loading',
|
|
|
|
- background: 'rgba(0, 0, 0, 0.7)'
|
|
|
|
- });
|
|
|
|
- refreshCorp(this.queryForm).then(res => {
|
|
|
|
- const h = this.$createElement;
|
|
|
|
- this.$msgbox({
|
|
|
|
- customClass: 'boxsss',
|
|
|
|
- title: '配置成功',
|
|
|
|
- closeOnPressEscape: false,
|
|
|
|
- closeOnClickModal: false,
|
|
|
|
- closeOnHashChange: false,
|
|
|
|
- showClose: false,
|
|
|
|
- message: h('div', null, [
|
|
|
|
- h('div', { style: { 'overflow': 'hidden' } }, `URL: ${res.data.externalUserCallbackUrl}`),
|
|
|
|
- h('div', null, `AESKey: ${res.data.aesKey}`),
|
|
|
|
- h('div', null, `Token: ${res.data.token}`),
|
|
|
|
- ]),
|
|
|
|
- confirmButtonText: '确定'
|
|
|
|
- }).then(action => {
|
|
|
|
- this.$emit("change");
|
|
|
|
- loading.close()
|
|
|
|
|
|
+ let isOk = true
|
|
|
|
+ if (this.$refs['bookCityType']) {
|
|
|
|
+ let state = this.$refs['bookCityType'].map(async item => {
|
|
|
|
+ return await this.stateHandle(item)
|
|
|
|
+ })
|
|
|
|
+ let okList = await Promise.all(state)
|
|
|
|
+ if (okList.every(item => item)) {
|
|
|
|
+ isOk = true
|
|
|
|
+ } else {
|
|
|
|
+ isOk = false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (isOk) {
|
|
|
|
+ let bookAgentIdMap = {}
|
|
|
|
+ this.queryPlatformBookCity.forEach(item => {
|
|
|
|
+ bookAgentIdMap[item.bookCityId] = item.bookAgentId
|
|
|
|
+ })
|
|
|
|
+ const loading = this.$loading({
|
|
|
|
+ lock: true,
|
|
|
|
+ text: 'Loading',
|
|
|
|
+ spinner: 'el-icon-loading',
|
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)'
|
|
});
|
|
});
|
|
|
|
+ refreshCorp({ ...this.queryForm, bookAgentIdMap }).then(res => {
|
|
|
|
+ const h = this.$createElement;
|
|
|
|
+ this.$msgbox({
|
|
|
|
+ customClass: 'boxsss',
|
|
|
|
+ title: '配置成功',
|
|
|
|
+ closeOnPressEscape: false,
|
|
|
|
+ closeOnClickModal: false,
|
|
|
|
+ closeOnHashChange: false,
|
|
|
|
+ showClose: false,
|
|
|
|
+ message: h('div', null, [
|
|
|
|
+ h('div', { style: { 'overflow': 'hidden' } }, `URL: ${res.data.externalUserCallbackUrl}`),
|
|
|
|
+ h('div', null, `AESKey: ${res.data.aesKey}`),
|
|
|
|
+ h('div', null, `Token: ${res.data.token}`),
|
|
|
|
+ ]),
|
|
|
|
+ confirmButtonText: '确定'
|
|
|
|
+ }).then(action => {
|
|
|
|
+ this.$emit("change");
|
|
|
|
+ loading.close()
|
|
|
|
+ });
|
|
|
|
|
|
- }).catch(() => loading.close())
|
|
|
|
|
|
+ }).catch(() => loading.close())
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -102,7 +212,7 @@ export default {
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<style>
|
|
<style>
|
|
- .boxsss {
|
|
|
|
- width: 600px !important;
|
|
|
|
- }
|
|
|
|
|
|
+.boxsss {
|
|
|
|
+ width: 600px !important;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|