Commit 32693b81 by 周田
parents 6471288b 7a675283
...@@ -3,9 +3,16 @@ ...@@ -3,9 +3,16 @@
<div class="container"> <div class="container">
<div class="left"> <div class="left">
<div class="mr-4">协议版本</div> <div class="mr-4">协议版本</div>
<el-select> <el-select v-model="value">
<!-- TODO: 选择协议版本 --> <!-- TODO: 选择协议版本 -->
<el-option :value="option"></el-option> <el-option
v-for="option in options"
:key="option.value"
:label="option.label"
:value="option.value"
>
</el-option>
</el-select> </el-select>
</div> </div>
<div class="right"> <div class="right">
...@@ -68,14 +75,16 @@ ...@@ -68,14 +75,16 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref,onMounted } from 'vue'
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import { GetProtocolVersion,ProtocolInit } from "@/dao/protocol"
import ProtocolTable from "./ProtocolTable.vue"; import ProtocolTable from "./ProtocolTable.vue";
import type { DeviceProtocolResponse, ProtocolCmdResponse } from './types'; import type { DeviceProtocolResponse, ProtocolCmdResponse } from './types';
const addCmd = ref<boolean>(false) const addCmd = ref<boolean>(false)
const option = ref<string>('option') const value = ref('')
const options = ref<Array>([])
const protocol_names = ref<Array>([])
const formLabelWidth = '140px' const formLabelWidth = '140px'
type propsType = { type propsType = {
...@@ -108,6 +117,41 @@ const open = () => { ...@@ -108,6 +117,41 @@ const open = () => {
}) })
}) })
} }
async function getVersion(){
await GetProtocolVersion()
.then((res) => {
for (const item of res){
protocol_names.value.push(item.protocol_name)
if (item.protocol_name === props.name){
let version_paths = JSON.parse(item.version_paths)
for (const item2 of version_paths){
options.value.push({value: item2.version, label: item2.version})
}
}
}
})
.catch((err) => {
console.log(err);
})
}
function Init(){
ProtocolInit({protocol_name: props.name})
.then((res) => {
options.value.push({value: "init", label: "init"})
})
.catch((err) => {
console.log(err);
})
}
onMounted(async () => {
await getVersion()
if (protocol_names.value.indexOf(props.name) === -1){
Init()
}
})
</script> </script>
<style> <style>
......
...@@ -216,6 +216,7 @@ const rules = reactive<FormRules<typeof fields>>({ ...@@ -216,6 +216,7 @@ const rules = reactive<FormRules<typeof fields>>({
const ruleFormRef = ref<typeof ElForm>() const ruleFormRef = ref<typeof ElForm>()
const addField = () => { const addField = () => {
flag.value = true; flag.value = true;
more.value = false more.value = false
...@@ -238,6 +239,7 @@ const addField = () => { ...@@ -238,6 +239,7 @@ const addField = () => {
fields.value.operabo_out = 0 fields.value.operabo_out = 0
dialogVisible.value = true; dialogVisible.value = true;
} }
function editField(data: CmdInfo) { function editField(data: CmdInfo) {
......
import axios from "axios"
const baseURL = 'http://192.168.0.214:8000/op'
export function GetProtocolVersion(){
return axios.get('/api/all_protocol_version/').then(
function (responese){
return responese.data
}
)
}
export function ProtocolInit(protocol_name: any){
return axios.post('api/protocol_version_manage/init/', protocol_name).then(
function (response){
return response.data
}
)
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment