factory_web/src/views/ecm/algos_form.vue

131 lines
2.9 KiB
Vue

<template>
<el-dialog
:title="titleMap[mode]"
v-model="visible"
:width="500"
destroy-on-close
@closed="$emit('closed')"
:draggable="true"
>
<el-form
:model="form"
:rules="rules"
:disabled="mode == 'show'"
ref="dialogForm"
label-width="100px"
>
<el-form-item label="关联算法" prop="algo">
<el-select v-model="form.algo">
<el-option
v-for="item in algooptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="视频" prop="vchannels">
<el-select v-model="form.vchannels" multiple="true">
<el-option
v-for="item in vchanneloptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="始终开启" prop="always_on">
<el-switch v-model="form.always_on"></el-switch>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="visible = false"> </el-button>
<el-button
v-if="mode != 'show'"
type="primary"
:loading="isSaveing"
@click="submit()"
> </el-button
>
</template>
</el-dialog>
</template>
<script>
export default {
emits: ["success", "closed"],
data() {
return {
mode: "add",
titleMap: {
add: "新增",
edit: "编辑",
show: "查看",
},
visible: false,
isSaveing: false,
//表单数据
form: {
algo: "",
vchannels: [],
always_on: false,
},
//验证规则
rules: {
algo: [{ required: true, message: "请选择算法" }],
vchannels: [{ required: true, message: "请选择视频" }],
},
algooptions: [],
vchanneloptions: [],
};
},
mounted() {
this.getEventCate();
this.getVchannel();
},
methods: {
//显示
open(mode = "add") {
this.mode = mode;
this.visible = true;
this.form.algo = this.$parent.chosen_cate;
return this;
},
//事件列表
getEventCate() {
this.$API.ecm.event_cate.list.req({ self_algo:true,page: 0 }).then((res) => {
this.algooptions = res;
});
},
//视频列表
getVchannel() {
this.$API.third.tdevice.list.req({ type: 60, page: 0 }).then((res) => {
this.vchanneloptions = res;
});
},
//表单提交方法
submit() {
this.$API.ecm.vchannel.creates.req(this.form).then((res) => {
this.$message.success("操作成功");
this.visible=false;
return res;
})
},
//表单注入数据
setData(data) {
Object.assign(this.form, data);
debugger;
},
},
};
</script>
<style>
</style>