简单修改一下

dev
RogerWork 3 months ago
parent 3ad2bc10a3
commit f31a304359
  1. BIN
      public/main.jpeg
  2. 24
      src/apis/ec_api.js
  3. 3
      src/components/HelloWorld.vue
  4. 137
      src/components/ec_api/MovieShow.vue
  5. 74
      src/components/ec_api/TabArea.vue

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

@ -99,3 +99,27 @@ export const ec_api_get_suggest = (api_type, api) => {
} }
}) })
} }
export const ec_api_set_user_data = (req_data) => {
return request({
url: 'ec/set_user_data',
method: 'post',
data: {
api: req_data.api,
member_type: req_data.member_type,
format: req_data.format,
user_data: req_data.user_data
}
})
}
export const ec_api_clear_user_data = (req_data) => {
return request({
url: 'ec/clear_user_data',
method: 'post',
data: {
api: req_data['api'],
member_type: req_data['member_type'],
}
})
}

@ -4,7 +4,8 @@
<template> <template>
<div> <div>
<el-text size="large" style="font-size: xxx-large">鼎新工具箱</el-text> <el-text size="large" style="font-size: xxx-large">鼎新工具箱</el-text><br>
<el-image src="public/main.jpeg" style="width: 600px"></el-image>
</div> </div>
</template> </template>

@ -0,0 +1,137 @@
<script setup>
import {defineProps, ref, reactive, computed, watch, onMounted, onBeforeMount} from 'vue'
import {ec_api_set_user_data, ec_api_clear_user_data} from '@/apis/ec_api.js'
import {ElMessage} from "element-plus";
// TabArea
const props = defineProps(['show', 'data'])
//
const selectShow = ref('')
const showList = reactive([])
//
async function handle_set_user_data() {
let selectShowData = {}
props.show.forEach((item)=> {
if (item['id'] === selectShow.value) {
selectShowData = item
}
})
const req_data = {
api: props.data.path,
member_type: props.data.type,
format: props.data.format,
user_data: JSON.stringify(selectShowData)
}
console.log('handle_set_user_data', req_data)
await ec_api_set_user_data(req_data).then(
(req) => {
if (req['result'] === 'success') {
ElMessage({message: '选择的场次已做为后续测试数据!', type: 'success'})
} else {
ElMessage({message: '设置用户选择场次数据失败!', type: 'error'})
}
}
).catch(
(err) => {
console.log(err)
ElMessage({message: '设置用户选择场次数据失败!', type: 'error'})
}
)
}
async function handle_clear_user_data() {
const req_data = {
api: props.data.path,
member_type: props.data.type,
}
console.log('handle_clear_user_data', req_data)
await ec_api_clear_user_data(req_data).then(
(req) => {
if (req['result'] === 'success') {
ElMessage({message: '选择的场次已清除,推荐参数将使用随机值!', type: 'success'})
} else {
ElMessage({message: '清除用户选择场次数据失败!', type: 'error'})
}
}
).catch(
(err) => {
console.log(err)
ElMessage({message: '清除用户选择场次数据失败!', type: 'error'})
}
)
}
onBeforeMount(() => {
//
props.show.forEach((item) => {
showList.push({
key: item.id,
start: item['startTime'],
name: item['movieInfo'][0]['movieName'],
hall: item['hallName'],
data: item
})
})
})
watch(() => selectShow.value, () => {
console.log('selectShow.value', selectShow.value)
handle_set_user_data()
})
</script>
<template>
<hr id="break_line"/>
<div style="font-size: 16px; font-weight: bold; color: #909399; text-align: left; margin-bottom: 10px">选择场次
<el-tooltip
class="box-item"
effect="dark"
content="点击清除选择后会将后台服务器中记录的选择内容清空,其他接口将通过随机获取的方式从此接口返回的数据中模拟参数"
placement="right"
>
<el-button size="small" style="font-weight: bold;color: #909399" @click="handle_clear_user_data">清除选择</el-button>
</el-tooltip>
</div>
<el-form style="max-width: 600px; margin-left: 20px">
<el-form-item>
<el-radio-group v-model="selectShow">
<el-radio-button v-for="s in showList" :label="s.key" :value="s.key" :key="s.key">
<div style="text-align: left">
<span>{{ s.key }}</span> -- <span style="font-weight: bold">{{ s.name }}</span><br>
<span>{{ s.start }}</span><br><span>{{ s.hall }}</span>
</div>
</el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
</template>
<style scoped>
#break_line {
margin-top: 30px;
margin-bottom: 30px;
background-color: rgba(144, 147, 153, 0.5);
height: 1px;
border: none
}
:deep(.el-radio-button) {
margin-bottom: 10px;
margin-right: 15px;
}
:deep(.el-radio-button__inner) {
width: 400px;
height: 60px;
background: #ebebeb;
color: #333;
border: 0 !important;
border-radius: 10px !important;
}
</style>

@ -1,13 +1,14 @@
<script setup> <script setup>
import {ref, reactive, onBeforeMount, onMounted, onUnmounted, watch, watchEffect} from "vue"; import {ref, reactive, onBeforeMount, onMounted, onUnmounted, watch, computed} from "vue";
import Sortable from "sortablejs"; import Sortable from "sortablejs";
import {useStore, mapState} from "vuex"; import {useStore, mapState} from "vuex";
import JsonEditorVue from "json-editor-vue3"; import JsonEditorVue from "json-editor-vue3";
import {ec_api_send_request, get_ec_api_request_url, ec_api_get_suggest} from "@/apis/ec_api.js"; import {ec_api_send_request, get_ec_api_request_url, ec_api_get_suggest} from "@/apis/ec_api.js";
import {Refresh} from "@element-plus/icons-vue"; import {Eleme, Refresh} from "@element-plus/icons-vue";
import "@/VueAceEditor/aceConfig" import "@/VueAceEditor/aceConfig"
import {VAceEditor} from "vue3-ace-editor"; import {VAceEditor} from "vue3-ace-editor";
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
import MovieShow from "@/components/ec_api/MovieShow.vue";
// store // store
@ -25,6 +26,10 @@ const ApiTableRef = ref(null) // 表格的Ref
// //
const UserApiData = ref({api: {}, base_info: {}, tab: {}}) const UserApiData = ref({api: {}, base_info: {}, tab: {}})
// loading
const req_loading = ref(false)
const send_btn = ref('发送')
// //
// //
function handleParamsChange(newCheckedResult) { function handleParamsChange(newCheckedResult) {
@ -129,11 +134,7 @@ function addNewParams() {
// //
function loadDefault(param) { function loadDefault(param) {
console.log(param) console.log(param)
UserApiData.value.api[activeTab.value]['params'].forEach(p => { get_suggest(true)
if (p['param'] === param) {
p['value'] = p['default']
}
})
} }
// //
@ -196,6 +197,12 @@ function handle_request_url() {
// api // api
function send_request() { function send_request() {
//
req_loading.value = true
send_btn.value = '请求中'
console.log('req_loading.value', req_loading.value)
console.log('send_btn.value', send_btn.value)
//
if (UserApiData.value.api[activeTab.value].format === 'json') { if (UserApiData.value.api[activeTab.value].format === 'json') {
UserApiData.value.api[activeTab.value].response = '{"root": "root"}' UserApiData.value.api[activeTab.value].response = '{"root": "root"}'
} }
@ -212,11 +219,17 @@ function send_request() {
const serializer = new XMLSerializer(); const serializer = new XMLSerializer();
UserApiData.value.api[activeTab.value].response = serializer.serializeToString(xmlDoc); UserApiData.value.api[activeTab.value].response = serializer.serializeToString(xmlDoc);
} }
//
req_loading.value = false
send_btn.value = '发送'
console.log('req_loading.value', req_loading.value)
console.log('send_btn.value', send_btn.value)
} }
) )
} }
async function get_suggest() { async function get_suggest(force) {
const api_type = UserApiData.value.api[activeTab.value].type const api_type = UserApiData.value.api[activeTab.value].type
const api = UserApiData.value.api[activeTab.value].path const api = UserApiData.value.api[activeTab.value].path
await ec_api_get_suggest(api_type, api).then( await ec_api_get_suggest(api_type, api).then(
@ -224,10 +237,20 @@ async function get_suggest() {
console.log('get_suggest', api, res) console.log('get_suggest', api, res)
res.forEach((suggest) => { res.forEach((suggest) => {
UserApiData.value.api[activeTab.value].params.forEach((param) => { UserApiData.value.api[activeTab.value].params.forEach((param) => {
if (param.param === suggest.param) { if (force) {
param['value'] = suggest['value'] console.log('get_suggest force')
param['default'] = suggest['value'] if (param.param === suggest.param) {
param['is_checked'] = suggest['is_checked'] param['value'] = suggest['value']
param['default'] = suggest['value']
param['is_checked'] = suggest['is_checked']
}
} else {
console.log('get_suggest else')
if (param.param === suggest.param && param['default'] === null) {
param['value'] = suggest['value']
param['default'] = suggest['value']
param['is_checked'] = suggest['is_checked']
}
} }
}) })
}) })
@ -244,6 +267,20 @@ function test() {
// console.log('activeTab.value', activeTab.value) // console.log('activeTab.value', activeTab.value)
} }
const showList = computed(() => {
const api = UserApiData.value.api[activeTab.value]
if (api.path === 'cinema/plays') {
if (api.format === 'json') {
if (api.response === '{"root": "root"}') {
return []
} else {
return JSON.parse(api.response)['res']['data']
}
}
}
return []
})
// ec_select_api // ec_select_api
watch(() => store.state.ecApiModule.ec_api_data.api, (oldValue, newValue) => { watch(() => store.state.ecApiModule.ec_api_data.api, (oldValue, newValue) => {
console.log('watch store.state.ecApiModule.ec_api_data.api') console.log('watch store.state.ecApiModule.ec_api_data.api')
@ -259,13 +296,14 @@ watch(() => store.state.ecApiModule.ec_api_data.api, (oldValue, newValue) => {
// activeTab // activeTab
watch(activeTab, () => { watch(activeTab, () => {
markIsChecked() markIsChecked()
get_suggest() get_suggest(false)
handle_request_url() handle_request_url()
}) })
// url // url
watch(UserApiData.value, () => { watch(UserApiData.value, () => {
console.log('watch UserApiData', UserApiData.value) console.log('watch UserApiData', UserApiData.value)
console.log('store.state.ecApiModule.ec_api_data', store.state.ecApiModule.ec_api_data)
handle_request_url() handle_request_url()
}, {deep: true, flush: "post"}) }, {deep: true, flush: "post"})
@ -307,7 +345,7 @@ const ace_options = {
showPrintMargin: false, // 线printMarginColumn showPrintMargin: false, // 线printMarginColumn
highlightActiveLine: true, // highlightActiveLine: true, //
highlightSelectedWord: true, // highlightSelectedWord: true, //
tabSize: 4, // tab tabSize: 2, // tab
fontSize: 14, // fontSize: 14, //
wrap: false, // wrap: false, //
readonly: true, // readonly: true, //
@ -345,7 +383,7 @@ const ace_options = {
@blur="changeFormat()"></el-input> @blur="changeFormat()"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="重置" width="80"> <el-table-column label="刷新推荐值" width="100" align="center">
<template v-slot="scope"> <template v-slot="scope">
<el-button @click="loadDefault(scope.row.param)"> <el-button @click="loadDefault(scope.row.param)">
<el-icon> <el-icon>
@ -354,7 +392,7 @@ const ace_options = {
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="必选" width="80"> <el-table-column label="必选" width="80" align="center">
<template v-slot="scope"> <template v-slot="scope">
<span>{{ scope.row.is_request ? '是' : '否' }}</span> <span>{{ scope.row.is_request ? '是' : '否' }}</span>
</template> </template>
@ -373,13 +411,15 @@ const ace_options = {
<el-input type="text" v-model="UserApiData.api[api['id']].url" :style="{'font-size': '18px'}"></el-input> <el-input type="text" v-model="UserApiData.api[api['id']].url" :style="{'font-size': '18px'}"></el-input>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
<el-button type="primary" @click="send_request">发送</el-button> <el-button type="primary" @click="send_request" :loading="req_loading" :disabled="req_loading">{{send_btn}}</el-button>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
</el-col> </el-col>
</el-row> </el-row>
<v-ace-editor v-model:value="UserApiData.api[api['id']].response" :lang="UserApiData.api[api['id']]['format']" <v-ace-editor v-model:value="UserApiData.api[api['id']].response" :lang="UserApiData.api[api['id']]['format']"
theme="chrome" :options="ace_options" class="vue-ace-editor" :wrap="true" style="width: 1200px"/> theme="chrome" :options="ace_options" class="vue-ace-editor" :wrap="true" style="width: 1200px"/>
<MovieShow v-if="showList.length > 0" :show="showList" :data="UserApiData.api[activeTab]"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>

Loading…
Cancel
Save