You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
4.0 KiB
Vue

2 years ago
<template>
<el-dialog
2 years ago
class="adddeviceDialog"
:title="title"
:visible.sync="isShow"
:close-on-click-modal="false"
2 years ago
width="670px"
2 years ago
>
<el-form
label-position="left"
ref="formInfo"
2 years ago
label-width="auto"
2 years ago
:model="ruleForm"
>
2 years ago
<el-form-item label="名称" prop="name">
2 years ago
<el-input v-model="ruleForm.name" autocomplete="off"></el-input>
</el-form-item>
2 years ago
<div class="addtimeBox" ref="timescrollref">
<div
class="timeBoxArr"
v-for="(item, index) in ruleForm.formList"
:key="index"
>
<el-form-item label="时间" :prop="'formList.' + index + '.time'">
<el-time-picker
is-range
v-model="item.time"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
value-format="HH:mm:ss"
>
</el-time-picker>
</el-form-item>
<el-form-item
label="间隔(分)"
:prop="'formList.' + index + '.span'"
2 years ago
>
2 years ago
<!-- <el-input v-model="formdata.span" autocomplete="off" type="number"></el-input> -->
<el-input-number v-model="item.span" :min="1"></el-input-number>
</el-form-item>
<div class="btngrop">
<el-button
v-if="index !== 0"
type="danger"
icon="el-icon-minus"
@click="deleteModule(item, index)"
></el-button>
<el-button
icon="el-icon-plus"
type="primary"
@click="addModule()"
v-if="index + 1 == ruleForm.formList.length"
></el-button>
</div>
</div>
2 years ago
</div>
<el-form-item label="备注" prop="remark">
2 years ago
<el-input v-model="ruleForm.remark" autocomplete="off"></el-input>
</el-form-item>
</el-form>
2 years ago
<div slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button>
2 years ago
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</template>
<script>
2 years ago
//import { addScheduleRulel, updateScheduleRulel } from "@/utils/api/index";
2 years ago
export default {
props: {
title: String,
},
2 years ago
data() {
return {
isShow: false,
2 years ago
ruleForm: {
name: "",
formList: [
{
time: "",
span: "",
},
],
remark: "",
},
};
2 years ago
},
methods: {
2 years ago
addModule() {
//新增一行
this.ruleForm.formList.push({
time: "",
span: "",
});
console.log(this.$refs.timescrollref);
this.$nextTick(() => {
console.log(this.$refs.timescrollref);
if (this.$refs.timescrollref) {
console.log(this.$refs.timescrollref.scrollHeight);
this.$refs.timescrollref.scrollTop =
this.$refs.timescrollref.scrollHeight;
}
});
},
deleteModule(item, index) {
console.log(item, index);
const itemList = this.ruleForm.formList.indexOf(item);
if (itemList !== -1) {
this.ruleForm.formList.splice(index, 1);
}
},
2 years ago
//判断
2 years ago
// 保存确定操作
submitForm() {
this.$refs.formInfo.validate((valid) => {
if (valid) {
2 years ago
console.log(valid);
} else {
console.log("error submit!!");
return false;
}
});
},
display() {
this.isShow = true;
},
hide() {
this.isShow = false;
},
2 years ago
},
mounted() {},
2 years ago
};
</script>
2 years ago
<style lang="less">
.adddeviceDialog {
.el-form {
2 years ago
.addtimeBox {
max-height: 205px;
overflow: auto;
}
2 years ago
.timeBoxArr {
display: flex;
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
width: 226px;
margin-right: 16px;
}
2 years ago
.btngrop {
margin-bottom: 16px;
margin-left: 16px;
height: 32px;
.el-button--small {
padding: 9px 8px;
}
}
2 years ago
}
}
}
</style>