| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358 |
- <template>
- <div>
- <d2-container>
- <!-- <template slot="header">首页/报警参数</template> -->
- <div class="nav">当前所在位置:<a href="#/index">首页</a>>参数设置>定时任务设置</div>
-
- <div class="main">
- <div class="left">
- <!-- <el-input placeholder="输入关键字进行过滤" v-model="filterText">
- </el-input> -->
- <div class="leftTitle">
- <i class="fa fa-building-o"></i> 组织机构
- </div>
- <el-tree
- class="filter-tree"
- :filter-node-method="filterNode"
- v-loading="loading"
- :data="leftList"
- node-key="id"
- :props="defaultProps"
- :expand-on-click-node="false"
- @node-click="handleNodeClick"
- default-expand-all
- highlight-current
- :default-expanded-keys="this.defaultExpanded"
- ref="tree"
- >
- <span class="custom-tree-node" slot-scope="{ node, data }">
- <span v-if="node.level == 1">
- <i :class="node.icon"></i>{{ node.label }}
- </span>
- <span v-if="node.level == 2">
- <i :class="node.icon"></i>{{ node.label }}
- </span>
- <span v-if="node.level == 3">
- <i :class="node.icon"></i>{{ node.label }}
- </span>
- <span v-if="node.level == 4"> <i></i>{{ node.label }} </span>
- </span>
- </el-tree>
- </div>
- <div class="right">
- <div class="right_main">
- <div class="right_title">
- <span><i class="fa fa-sliders"></i> 定时任务列表</span>
- </div>
- <div class="right_table">
- <div class="addBtn">
- <el-button size="mini" type="primary" icon="el-icon-plus" @click="addTantou"
- >新建定时任务</el-button
- >
- </div>
- <el-table stripe :data="alarmRecord" border style="width: 100%">
- <el-table-column
- align="center"
- label="序号"
- type="index"
- width="100px"
- :index="indexMethod"
- ></el-table-column>
- <el-table-column
- prop="taskName"
- label="任务名称"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="detectionDesc"
- label="计划检测时间"
- align="center"
- >
- </el-table-column>
- <el-table-column prop="eqSum" label="设备数量" align="center">
- </el-table-column>
- <el-table-column
- prop="buildTime"
- label="创建时间"
- align="center"
- >
- </el-table-column>
-
- <el-table-column prop="onOrOff" label="是否开启" align="center">
- <template slot-scope="scope">
- {{scope.row.onOrOff==0?'否':scope.row.onOrOff==1?'是':scope.row.onOrOff}}
- </template>
- </el-table-column>
- <el-table-column label="操作" width="220" align="center">
- <template slot-scope="scope">
- <el-button
- type="primary"
- plain
- size="mini"
- @click="goDetail(scope.row)"
- >查看</el-button
- >
- <el-button
- class="editBtn"
- size="mini"
- plain
- @click="goEdit(scope.row)"
- >编辑</el-button
- >
- <el-button type="danger" plain size="mini" @click="del(scope.row)"
- >删除</el-button
- >
- <!-- <el-button @click="delecheck( scope.$index, scope.row)" type="detailbtn" class="fa fa-info-circle" size="mini">查看</el-button> -->
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="1"
- :page-sizes="[10, 20, 30, 40]"
- :page-size="pagination.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="pagination.total"
- >
- </el-pagination>
- </div>
- </div>
- </div>
- </div>
- </d2-container>
-
- <!-- //弹框 -->
- <el-dialog
- :title="title1"
- :visible.sync="dialogAlarm"
- id="dialogStyle"
- width="1080px"
- @close="
- week = [];
- month = [];
- addForm = {};
- $refs.addForm.resetFields()
- yxTableData = [];
- "
- >
- <el-form
- :disabled="title1 == '定时任务查看'"
- :model="addForm"
- label-width="110px"
- :inline="true"
- :rules="rules"
- ref="addForm"
- >
- <el-form-item label="任务名称:" prop="taskName">
- <el-input
- style="width: 220px"
- placeholder="请输入"
- v-model="addForm.taskName"
- autocomplete="off"
- ></el-input>
- </el-form-item>
- <el-form-item label="是否开启:" prop="onOrOff">
- <el-select v-model="addForm.onOrOff" placeholder="请选择">
- <el-option label="是" :value="1"></el-option>
- <el-option label="否" :value="0"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="产品分类:" prop="productCategoryCode">
- <!-- <el-select
- v-model="addForm.proCategoryCode"
- placeholder="请选择"
- ref="selectTree"
- >
- <el-option
- :key="addForm.proCategoryCode"
- :value="addForm.proCategoryCode"
- :label="addForm.label"
- hidden
- />
- <el-tree
- :data="typeLists"
- :props="defaultFlProps"
- node-key="id"
- accordion
- highlight-current
- @node-click="handleNodeClickFl"
- />
- </el-select> -->
- <el-select
- v-model="addForm.productCategoryCode"
- placeholder="请选择"
- @change="getProCategory"
- >
- <el-option
- v-for="item in typeSonLists"
- :key="item.id"
- :label="item.productCategoryName"
- :value="item.productCategoryCode"
- >
- </el-option>
- </el-select>
- </el-form-item>
-
- <el-form-item label="任务触发时间:" prop="timeType">
- <el-select
- v-model="addForm.timeType"
- placeholder="请选择"
- :class="
- addForm.timeType == '每天' ||
- addForm.timeType == '每周' ||
- addForm.timeType == '每月' ||
- addForm.timeType == '每年'
- ? 'shortS'
- : ''
- "
- >
- <el-option label="每小时" value="每小时"></el-option>
- <el-option label="每天" value="每天"></el-option>
- <el-option label="每周" value="每周"></el-option>
- <el-option label="每月" value="每月"></el-option>
- <el-option label="每年" value="每年"></el-option>
- </el-select>
- <!-- <el-popover placement="right" v-model="cronPopover">
- <cron @change="changeCron" @close="cronPopover=false" i18n="cn"></cron>
- <el-input slot="reference" readonly @click="cronPopover=true" v-model="addForm.timeType" placeholder="请输入任务触发时间"></el-input>
- </el-popover> -->
- </el-form-item>
-
- <el-form-item v-if="addForm.timeType == '每周'" prop="week">
- <el-checkbox-group v-model="week">
- <el-checkbox
- v-for="(item, index) in weekArr"
- :key="index"
- :label="item"
- >
- {{ item }}
- </el-checkbox>
- </el-checkbox-group>
- </el-form-item>
- <el-form-item v-if="addForm.timeType == '每月'" prop="month">
- <el-checkbox-group
- style="line-height: 10px; width: 664px"
- v-model="month"
- >
- <el-checkbox v-for="(item, index) in 31" :key="index" :label="item">
- {{ item }}
- </el-checkbox>
- </el-checkbox-group>
- </el-form-item>
- <el-form-item v-if="addForm.timeType == '每年'" prop="dateTime">
- <el-date-picker
- popper-class="picker-date"
- style="width: 135px"
- v-model="addForm.dateTime"
- type="date"
- value-format="MM-dd"
- format="MM-dd"
- placeholder="请选择"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item
- v-if="
- addForm.timeType == '每天' ||
- addForm.timeType == '每周' ||
- addForm.timeType == '每月' ||
- addForm.timeType == '每年'
- "
- prop="time"
- >
- <el-time-picker
- style="width: 118px"
- value-format="HH:mm:ss"
- format="HH:mm:ss"
- v-model="addForm.time"
- placeholder="请选择"
- >
- </el-time-picker>
- </el-form-item>
- <el-form-item label="设备标签:" prop="labelCode">
- <el-select v-model="addForm.labelCode" placeholder="请选择" >
- <el-option v-for="item in tagLists" :key="item.id" :label="item.labelName" :value="item.labelCode">
- </el-option>
- </el-select>
- </el-form-item>
- <div style="display: flex; justify-content: space-between">
- <el-form-item label="预警设备:" prop="yjsb">
- <el-button
- v-if="title1 != '定时任务查看'"
- type="primary"
- icon="el-icon-plus"
- @click="
- addSbDialog = true;
- getSelect();
- getSbList();
- "
- >选择设备</el-button
- >
- </el-form-item>
- <div style="line-height: 40px">
- 已选择<span style="color: #008775; padding-top: 13px">{{
- yxTableData.length
- }}</span
- >个
- </div>
- </div>
- </el-form>
- <el-table :data="yxTableData" style="width: 100%">
- <el-table-column
- prop="id"
- align="center"
- label="设备ID"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column prop="eqName" align="center" label="设备名称">
- </el-table-column>
- <el-table-column
- prop="proName"
- align="center"
- show-overflow-tooltip
- min-width="100"
- label="所属产品名称"
- >
- </el-table-column>
- <el-table-column prop="labelName" align="center" label="设备标签">
- </el-table-column>
- <el-table-column
- prop="houseCode"
- min-width="100"
- align="center"
- label="所属仓房编码"
- >
- </el-table-column>
- <el-table-column prop="eqStatus" align="center" label="状态">
- <template slot-scope="scope">
- <el-button
- class="online"
- v-if="scope.row.eqStatus == 1"
- type="primary"
- size="mini"
- plain
- >在线</el-button
- >
- <el-button
- class="downline"
- v-if="scope.row.eqStatus == 0"
- type="danger"
- plain
- size="mini"
- >离线</el-button
- >
- <!-- <el-button @click="delecheck( scope.$index, scope.row)" type="detailbtn" class="fa fa-info-circle" size="mini">查看</el-button> -->
- </template>
- </el-table-column>
- <el-table-column label="操作" width="80" align="center">
- <template slot-scope="scope">
- <el-button type="danger" plain size="mini" @click="del1(scope)"
- >删除</el-button
- >
- <!-- <el-button @click="delecheck( scope.$index, scope.row)" type="detailbtn" class="fa fa-info-circle" size="mini">查看</el-button> -->
- </template>
- </el-table-column>
- </el-table>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogAlarm = false">取 消</el-button>
- <el-button type="primary" @click="submitForm('addForm')"
- >确 定</el-button
- >
- </div>
- </el-dialog>
- <el-dialog
- title="添加设备"
- width="1100px"
- :visible.sync="addSbDialog"
- id="dialogStyle"
- @close="closeAddSb"
- >
- <!-- <el-form
- :inline="true"
- :model="formInline"
- class="demo-form-inline"
- id="formLabel"
- >
- <el-form-item label="产品名称:">
- <el-select
- v-model="formInline.proName"
- placeholder="请选择"
- size="mini"
- >
- <el-option
- v-for="item in proLists"
- :key="item.id"
- :label="item.proName"
- :value="item.proName"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="设备名称:">
- <el-select
- size="mini"
- v-model="formInline.eqName"
- placeholder="请选择"
- >
- <el-option
- v-for="item in sbTableData"
- :key="item.id"
- :label="item.eqName"
- :value="item.eqName"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="设备标签:">
- <el-select
- size="mini"
- v-model="formInline.labelName"
- placeholder="请选择"
- >
- <el-option
- v-for="item in tagLists"
- :key="item.id"
- :label="item.labelName"
- :value="item.labelName"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- size="mini"
- type="primary"
- icon="el-icon-search"
- @click="search1"
- >查询</el-button
- >
- </el-form-item>
-
- <el-form-item>
- <el-button
- type="primary"
- size="mini"
- icon="el-icon-refresh-left"
- @click="reset1"
- >重置</el-button
- >
- </el-form-item>
- </el-form> -->
-
- <el-table
- ref="multipleTable"
- :data="sbTableData"
- border
- style="width: 100%"
- @selection-change="handleSelectionChange"
- >
- <el-table-column type="selection" align="center" width="55">
- </el-table-column>
- <el-table-column
- align="center"
- label="序号"
- type="index"
- width="100px"
- :index="indexMethod1"
- ></el-table-column>
- <el-table-column prop="id" align="center" label="设备ID">
- </el-table-column>
- <el-table-column prop="eqName" label="设备名称" align="center">
- </el-table-column>
- <el-table-column prop="proName" label="产品名称" align="center">
- </el-table-column>
- <el-table-column prop="labelName" label="设备标签" align="center">
- </el-table-column>
- <el-table-column prop="houseCode" label="所属仓房编码" align="center">
- </el-table-column>
- </el-table>
- <el-pagination
- @size-change="handleSizeChange1"
- @current-change="handleCurrentChange1"
- :current-page="1"
- :page-sizes="[10, 20, 30, 40]"
- :page-size="pagination1.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="pagination1.total"
- >
- </el-pagination>
- <div slot="footer" class="dialog-footer">
- <el-button @click="addSbDialog = false">取 消</el-button>
- <el-button type="primary" @click="sure">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { cron } from "vue-cron";
- import api from "@/api";
- import { off } from "process";
- export default {
- template: "<cron/>",
- components: { cron },
- name: "hardwareParame",
- data() {
- return {
- typeSonLists:[],
- cronPopover: false,
- cron: "",
- title1: "",
- week: [],
- typeLists: [],
- weekArr: [
- "星期一",
- "星期二",
- "星期三",
- "星期四",
- "星期五",
- "星期六",
- "星期日",
- ],
- month: [],
-
- proLists: [],
- bjlxArr: [],
- sbTableData: [],
- devInfoList: [],
- yxTableData: [],
- tagLists: [],
- defaultFlProps: {
- children: "children",
- label: "productCategoryName",
- },
- defaultProps2: {
- children: "children",
- label: "enumName",
- },
- formInline: {},
- addSbDialog: false,
- tableData: [{}],
- addForm: {},
- rules: {
- timeType: [
- {
- required: true,
- message: "请选择任务触发时间",
- trigger: ["change", "blur"],
- },
- ],
- week: [{ required: true, message: "请选择", trigger: "blur" }],
- month: [{ required: true, message: "请选择", trigger: "blur" }],
- time: [{ required: true, message: "请选择", trigger: "blur" }],
- dateTime: [{ required: true, message: "请选择", trigger: "blur" }],
- productCategoryCode: [
- { required: true, message: "请选择产品分类", trigger: "blur" },
- ],
- onOrOff: [
- { required: true, message: "请选择是否开启", trigger: "blur" },
- ],
- taskName: [
- { required: true, message: "请输入任务名称", trigger: "change" },
- ],
- yjsb: [{ required: true, message: "请选择设备", trigger: "change" }],
- labelCode:[
- { required: true, message: "请选择设备标签", trigger: "blur" },
- ],
- },
- //表格字段
- alarmRecord: [{}],
- //分页
- pagination: {
- // 每页显示的条数
- pageSize: 10,
- // 当前页
- curPage: 1,
- // 总数
- total: 20,
- },
- //弹框分页
- pagination1: {
- // 每页显示的条数
- pageSize: 10,
- // 当前页
- curPage: 1,
- // 总数
- total: 20,
- },
- disabled: false,
- // label宽度
- formLabelWidth: "120px",
- // 弹框默认关闭
- dialogAlarm: false,
- filterText: "",
- //默认展开的节点
- defaultProps: {
- children: "children",
- label: "orgName",
- },
- loading: false,
- //默认展开的节点
- defaultExpanded: [],
- cfbh: "",
- //左侧树数据
- leftList: [],
- // 日期插件
- //
- formData: {
- status: 0,
- totalStatus: 0,
- totalThreshold: "",
- timeThreshold: "",
- telephoneNumber1: "",
- telephoneNumber2: "",
- smsNumber1: "",
- smsNumber2: "",
- id: "",
- },
- //弹框字段
- dialog: {
- name: "",
- },
- };
- },
- // watch: {
- // filterTest(val) {
- // this.$refs.tree.filter(val);
- // },
- // },
- created() {
- this.getSelect();
- },
- methods: {
- getProCategory(v){
- var arr=this.typeSonLists.filter(item=>{
- return item.productCategoryCode==v
- })
- this.addForm.productCategoryName=arr[0].productCategoryName
- },
- getCorn() {
- // 拼接cron表达式
- this.addForm.detectionDesc = "";
- let timeType = this.addForm.timeType;
- console.log(timeType);
- if (timeType != "每小时"&&timeType != undefined) {
- if(this.addForm.time){
- var HhMmSs = this.addForm.time.split(":"); // 拼接
- }
- }
- if (timeType == "每年") {
- // 每年
- var month = this.addForm.dateTime.substring(0, 2); // 截取月
- var day = this.addForm.dateTime.substring(3); // 截取日
- this.addForm.detectionCron =
- HhMmSs[2] +
- " " +
- HhMmSs[1] +
- " " +
- HhMmSs[0] +
- " " +
- day +
- " " +
- month +
- " ?";
- this.addForm.detectionDesc +=
- month + ":" + day + "号" + this.addForm.time + "执行";
- } else if (timeType == "每月") {
- // 每月
- var days = this.month.toString();
- this.addForm.detectionCron =
- HhMmSs[2] + " " + HhMmSs[1] + " " + HhMmSs[0] + " " + days + " * ?";
- this.addForm.detectionDesc += days + "号" + this.addForm.time + "执行";
- } else if (timeType == "每周") {
- // 每周
- var CWeeks = ""; // cron公历周使用
- var weeks = ""; // cron公历周使用
- this.week.forEach((item, index) => {
- if (item == "星期一") {
- CWeeks += "2,";
- weeks += "1,";
- } else if (item == "星期二") {
- CWeeks += "3,";
- weeks += "2,";
- } else if (item == "星期三") {
- CWeeks += "4,";
- weeks += "3,";
- } else if (item == "星期四") {
- CWeeks += "5,";
- weeks += "4,";
- } else if (item == "星期五") {
- CWeeks += "6,";
- weeks += "5,";
- } else if (item == "星期六") {
- CWeeks += "7,";
- weeks += "6,";
- } else if (item == "星期日") {
- CWeeks += "1,";
- weeks += "7,";
- }
- });
- var subCWeeks = CWeeks.substring(0, CWeeks.length - 1);
- // cron
- this.addForm.detectionCron =
- HhMmSs[2] + " " + HhMmSs[1] + " " + HhMmSs[0] + " ? * " + subCWeeks;
- // 计划检测时间描述
- var lastWeeks = weeks.substring(0, weeks.length - 1);
- this.addForm.detectionDesc +=
- lastWeeks + "的" + this.addForm.time + "执行";
- } else if (timeType == "每天") {
- // 每天
- // cron表达式(每天设置时分秒执行一次)
- this.addForm.detectionCron =
- HhMmSs[2] + " " + HhMmSs[1] + " " + HhMmSs[0] + " * * ?";
- // 计划检测时间描述
- this.addForm.detectionDesc += this.addForm.time + "执行";
- } else {
- // 每小时
- // cron表达式(每小时执行一次)
- this.addForm.detectionCron = "0 0 * * * ?";
- // 计划检测时间描述
- this.addForm.detectionDesc += "执行";
- }
-
- console.log(this.addForm.detectionCron);
- console.log(this.addForm.detectionDesc);
- },
-
- changeCron(val) {
- this.$set(this.addForm, "timeType", val);
- // this.addForm.timeType=val
- },
- //删除
- del(row) {
- this.$confirm("确认进行删除操作吗?", "删除提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- api.timingTaskDel(row.id).then((res) => {
- if (res.code == 200) {
- this.$message({
- type: "success",
- message: "删除成功",
- });
- this.getList();
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- });
- },
- goDetail(row) {
- this.title1 = "定时任务查看";
- this.dialogAlarm = true;
- this.getBjlxArr();
- api.timingTaskDetail(row.id).then((res) => {
- if (res.code == 200) {
- this.addForm = res.data;
- let objTime=JSON.parse(this.addForm.objTime)
- if(objTime){
- this.$set(this.addForm, "timeType", objTime.timeType);
-
- if(objTime.timeType=='每年'){
- this.addForm.dateTime=objTime.dateTime
- this.addForm.time=objTime.time
- }else if(objTime.timeType=='每月'){
- this.month=objTime.month
- this.addForm.time=objTime.time
-
- }else if(objTime.timeType=='每周'){
- this.week=objTime.week
- this.addForm.time=objTime.time
- }else if(objTime.timeType=='每天'){
- this.week=objTime.week
- }
- }
- this.yxTableData = this.addForm.devInfoList;
- } else {
- this.$message.error(res.msg);
- }
- });
- },
- goEdit(row) {
- this.title1 = "定时任务编辑";
- this.dialogAlarm = true;
- this.getBjlxArr();
- api.timingTaskDetail(row.id).then((res) => {
- if (res.code == 200) {
- this.addForm = res.data;
- let objTime=JSON.parse(this.addForm.objTime)
- if(objTime){
- this.$set(this.addForm, "timeType", objTime.timeType);
- if(objTime.timeType=='每年'){
- this.addForm.dateTime=objTime.dateTime
- this.addForm.time=objTime.time
- }else if(objTime.timeType=='每月'){
- this.month=objTime.month
- this.addForm.time=objTime.time
-
- }else if(objTime.timeType=='每周'){
- this.week=objTime.week
- this.addForm.time=objTime.time
- }else if(objTime.timeType=='每天'){
- this.addForm.time=objTime.time
- }
- }
- console.log(this.addForm,990);
- this.yxTableData = this.addForm.devInfoList;
- } else {
- this.$message.error(res.msg);
- }
- });
- },
- //删除已选设备
- del1(scope) {
- this.$confirm("确认进行删除操作吗?", "删除提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- this.yxTableData.splice(scope.$index, 1);
- this.$message({
- type: "success",
- message: "删除成功",
- });
- });
- },
- closeAddSb() {
- this.formInline = {};
- this.$refs.multipleTable.clearSelection();
- },
- // 添加设备
- sure() {
- this.addSbDialog = false;
- this.yxTableData = JSON.parse(JSON.stringify(this.devInfoList));
-
- console.log(this.devInfoList);
- },
- submitForm(formName) {
- this.addForm.eqCode = "";
- if (this.yxTableData.length > 0) {
- this.addForm.proCode = this.yxTableData[0].proCode;
-
- this.yxTableData.forEach((item) => {
- this.addForm.eqCode += item.eqCode += ",";
- // this.addForm.proCode+=(item.proCode+=',')
- });
- this.addForm.eqCode = this.addForm.eqCode.substring(
- 0,
- this.addForm.eqCode.length - 1
- );
- // this.addForm.proCode=this.addForm.proCode.substring(0, this.addForm.proCode.length - 1)
- this.$nextTick(() => {
- this.$refs[formName].clearValidate(["yjsb"]);
- });
- }
- this.addForm.week = JSON.parse(JSON.stringify(this.week));
- this.addForm.month = JSON.parse(JSON.stringify(this.month));
- this.addForm.orgCode = this.orgCode;
- this.$refs[formName].validate((valid) => {
- console.log(this.addForm);
-
- if (valid) {
- this.getCorn();
- this.addForm.devInfoList = this.yxTableData;
- let data = JSON.parse(JSON.stringify(this.addForm));
- // data.label = undefined;
- // data.month = undefined;
- // data.week = undefined;
- // data.timeType = undefined;
- console.log(data.dateTime);
- var objTime = {
- month: data.month,
- week: data.week,
- timeType: data.timeType,
- dateTime: data.dateTime,
- time:data.time
- };
- data.objTime = JSON.stringify(objTime);
- if (this.title1 == "新建定时任务") {
- api.timingTaskSave(data).then((res) => {
- if (res.code == 200) {
- this.$message.success("新建成功");
- this.getList();
- this.dialogAlarm = false;
- } else {
- this.$message.error(res.msg);
- }
- });
- } else {
- api.timingTaskUpdate(data).then((res) => {
- if (res.code == 200) {
- this.$message.success("编辑成功");
- this.getList();
- this.dialogAlarm = false;
- } else {
- this.$message.error(res.msg);
- }
- });
- }
- } else {
- let str = "";
- this.$refs[formName].fields.forEach((item) => {
- if(item.validateMessage==undefined){
- item.validateMessage=''
- }
- str += item.validateMessage;
- });
- console.log(str);
- if (this.yxTableData.length > 0 && str == "请选择设备") {
- this.getCorn();
- this.addForm.devInfoList = this.yxTableData;
- let data = JSON.parse(JSON.stringify(this.addForm));
- // data.label = undefined;
- // data.month = undefined;
- // data.week = undefined;
- // data.timeType = undefined;
- var objTime = {
- month: data.month,
- week: data.week,
- timeType: data.timeType,
- dateTime: data.dateTime,
- time:data.time
- };
- data.objTime = JSON.stringify(objTime);
- if (this.title1 == "新建定时任务") {
- api.timingTaskSave(data).then((res) => {
- if (res.code == 200) {
- this.$message.success("新建成功");
- this.getList();
- this.dialogAlarm = false;
- } else {
- this.$message.error(res.msg);
- }
- });
- } else {
- api.timingTaskUpdate(data).then((res) => {
- if (res.code == 200) {
- this.$message.success("编辑成功");
- this.getList();
- this.dialogAlarm = false;
- } else {
- this.$message.error(res.msg);
- }
- });
- }
- } else {
- return false;
- }
- }
- });
- },
- handleSelectionChange(val) {
- this.devInfoList = val;
- },
- handleNodeClickFl(data) {
- console.log(data);
- this.$set(this.addForm, "productCategoryCode", data.productCategoryCode);
- this.$set(this.addForm, "productCategoryName", data.productCategoryName);
- this.$set(this.addForm, "label", data.productCategoryName);
- // 使 input 失去焦点,并隐藏下拉框
- this.$refs.selectTree.blur();
- },
- handleNodeClick2(data) {
- console.log(data);
- this.$set(this.addForm, "alarmTypeCode", data.enumCode);
- this.$set(this.addForm, "alarmTypeName", data.enumName);
- this.$set(this.addForm, "label", data.enumName);
- // 使 input 失去焦点,并隐藏下拉框
- this.$refs.selectTree1.blur();
- },
- getSelect() {
- api
- .productCategoryList(localStorage.getItem("orgCode"))
- .then((res) => {
- if (res.code == 200) {
- this.typeLists = res.data;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- api.productGetSonList(localStorage.getItem("orgCode")).then(res=>{
- if (res.code == 200) {
- this.typeSonLists = res.data;
- }
- })
- api
- .productList({ curPage: 1, pageSize: 99999,condition: JSON.stringify({org_code:localStorage.getItem("orgCode")}) })
- .then((res) => {
- if (res.code == 200) {
- this.proLists = res.data.records;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- api
- .equipmentTagList({ curPage: 1, pageSize: 99999 })
- .then((res) => {
- if (res.code == 200) {
- this.tagLists = res.data.records;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- //获取设备列表数据
- getSbList() {
- var condition = this.formInline;
- condition.labelCode=this.addForm.labelCode;
- condition.productCategoryCode=this.addForm.productCategoryCode;
- condition.org_code=localStorage.getItem("orgCode");
- condition = JSON.stringify(condition);
- var data = {
- pageIndex: this.pagination1.curPage,
- pageSize: this.pagination1.pageSize,
- condition: condition,
- };
- api
- .equipmentList(data)
- .then((res) => {
- if (res.code == 200) {
- this.sbTableData = res.data.records;
- this.pagination1.pageSize = res.data.size;
- this.pagination1.total = res.data.total;
- this.$nextTick(() => {
- this.sbTableData.forEach((row) => {
- this.yxTableData.forEach((row1) => {
- if (row.id == row1.id) {
- this.$refs.multipleTable.toggleRowSelection(row, true);
- }
- });
- });
- });
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- // 每页条数改变
- handleSizeChange1(val) {
- this.pagination1.pageSize = val;
- },
- // 当前页改变
- handleCurrentChange1(val) {
- this.pagination1.curPage = val;
- },
- // 每页条数改变
- handleSizeChange(val) {
- this.pagination.pageSize = val;
- this.getList();
- },
- // 当前页改变
- handleCurrentChange(val) {
- this.pagination.curPage = val;
- this.getList();
- },
- // 数字且最多小数点两位
- oninput(num) {
- var str = num;
- var len1 = str.substr(0, 1);
- var len2 = str.substr(1, 1);
- // 如果第一位是0,第二位不是点,就用数字把点替换掉
- if (str.length > 1 && len1 == 0 && len2 != ".") {
- str = str.substr(1, 1);
- }
- // 第一位不能是.
- if (len1 == ".") {
- str = "";
- }
- // 限制只能输入一个小数点
- if (str.indexOf(".") != -1) {
- var str_ = str.substr(str.indexOf(".") + 1);
- if (str_.indexOf(".") != -1) {
- str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
- }
- }
- // 正则替换
- str = str.replace(/[^\d^\.]+/g, ""); // 保留数字和小数点
- str = str.replace(/\.\d\d\d$/, ""); // 小数点后只能输两位
- return str;
- },
- //获取左侧树
- getLeftTree() {
- this.loading = true;
- let params = {
- orgName: this.orgName,
- };
-
- api
- .leftTree(params)
- .then((res) => {
- if (res.code == 200) {
- console.log(res);
- this.leftList = [];
- if (res.data) {
- this.leftList = res.data;
-
- // if (res.data[0].id) {
- // this.defaultExpanded.push(res.data[0].id);
- // if (res.data[0].children) {
- // this.defaultExpanded.push(
- // res.data[0].children[0].children[0].id
- // );
-
- // this.cfbh =
- // res.data[0].children[0].children[0].children[0].id;
-
- // setTimeout(() => {
- // document.getElementsByClassName("el-tree-node__content")[0].style.display="none"
- // document.getElementsByClassName("el-tree-node__content")[1].style.display="none"
- // this.$refs.tree.setCurrentKey(this.cfbh);
- // this.$refs.tree.setCurrentKey(this.cfbh);
- // }, 100);
- // console.log(this.leftList);
- // this.getList();
- // }
- // }
- var lastLevel = res.data;
- if (lastLevel.length > 0) {
- lastLevel = res.data[0];
- while (lastLevel.children && lastLevel.children.length > 0) {
- lastLevel = lastLevel.children[0];
- }
- this.defaultExpanded.push(lastLevel.id);
- this.cfbh = lastLevel.id;
- this.addForm.orgCode = lastLevel.orgCode;
- this.orgCode = lastLevel.orgCode;
- setTimeout(() => {
- this.$refs.tree.setCurrentKey(this.cfbh);
- }, 200);
- this.getList();
- }
- }
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- this.loading = false;
- })
- .catch((error) => {
- this.loading = false;
- console.log(error);
- });
- },
- //点击左侧树节点
- handleNodeClick(data, node) {
- console.log(data, node);
- // if(node.level ===4){
- // this.cfbh=data.id;
- // console.log( this.cfbh,";;;")
- // }
- // this.getList();
- if (node.childNodes.length === 0) {
- this.cfbh = data.id;
- this.addForm.orgCode = data.orgCode;
- this.orgCode = data.orgCode;
- console.log(this.cfbh, ";;;");
- this.getList();
- }
- },
- filterNode(value, data) {
- if (!value) return true;
- return data.orgName.indexOf(value) !== -1;
- },
- // filterNode(value, data) {
- // if (!value) return true;
- // return data.label.indexOf(value) !== -1;
- // },
- //获取列表数据
- getList() {
- var condition = { orgCode: this.orgCode };
- condition = JSON.stringify(condition);
- var data = {
- pageIndex: this.pagination.curPage,
- pageSize: this.pagination.pageSize,
- condition: condition,
- };
- console.log(api);
- api
- .timingTaskPage(data)
- .then((res) => {
- if (res.code == 200) {
- this.alarmRecord = res.data.records;
- this.pagination.pageSize = res.data.size;
- this.pagination.total = res.data.total;
- } else {
- this.$message.error(res.msg);
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- search1() {
- this.getSbList();
- },
- reset1() {
- this.formInline = {};
- },
- search() {
- this.getList();
- },
- reset() {
- this.addForm = {};
- },
- //新增
- addTantou() {
- this.title1 = "新建定时任务";
- this.dialogAlarm = true;
- this.getBjlxArr();
- },
- getBjlxArr() {
- var condition = {
- enumName: "报警类型",
- };
- condition = JSON.stringify(condition);
- var data = {
- condition: condition,
- };
- api
- .dataDic(data)
- .then((res) => {
- if (res.code == 200) {
- this.bjlxArr = res.data;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- //表格序号
- indexMethod(index) {
- return (
- (this.pagination.curPage - 1) * this.pagination.pageSize + index + 1
- );
- },
-
- //表格序号
- indexMethod1(index) {
- return (
- (this.pagination1.curPage - 1) * this.pagination1.pageSize + index + 1
- );
- },
- //弹框确定按钮
- determine() {},
- },
- mounted() {
- this.getLeftTree();
- },
- };
- </script>
- <style lang="scss" scoped>
- .main {
- height: 100%;
- display: flex;
- .left {
- height: calc(100vh - 140px);
- .leftTitle {
- background: linear-gradient(0deg, #008574 0%, #01a48f 100%);
- border-top-left-radius: 6px;
- border-top-right-radius: 6px;
- padding: 10px;
- font-size: 16px;
- color: #fff;
- font-weight: bold;
- }
- }
- .right {
- margin-left: 20px;
- width: calc(100% - 280px);
-
- border: 1px solid #dedede;
- background-color: #fff;
- border-radius: 6px;
- .right_main {
- border-top-left-radius: 6px;
- border-top-right-radius: 6px;
- }
- .right_title {
- font-weight: bold;
- font-size: 16px;
- border-bottom: 1px solid #ebeef5;
- background-color: rgba(233, 244, 243, 0.5);
- border-top-left-radius: 6px;
- border-top-right-radius: 6px;
- color: #008775;
- border-bottom: 1px solid rgba(1, 164, 143, 0.3);
- padding-left: 0;
- span {
- padding: 10px;
- padding-bottom: 9px;
- border-bottom: 2px solid #01a48f;
- }
- }
- }
- .addBtn {
- margin-bottom: 10px;
- margin-top: -10px;
- text-align: right;
- }
- h4 {
- font-size: 16px;
- font-weight: 700;
- line-height: 40px;
- // color:#fff;
- }
- p {
- // color: #525357;
- font-size: 14px;
- line-height: 40px;
- position: relative;
- color: #fff;
- }
- }
- .nav {
- padding: 10px 0 10px 10px;
- margin-bottom: 20px;
- // color: #fff;
-
- font-size: 14px;
-
- background: #ffffff;
- border: 1px solid #dedede;
- cursor: pointer;
- }
- .shortS {
- width: 93px;
- }
- ::v-deep .el-checkbox__label {
- padding-left: 2px !important;
- }
- ::v-deep .el-checkbox {
- margin-right: 10px !important;
- }
- ::v-deep .online:hover {
- background-color: rgba(7, 115, 94, 0.07) !important;
- color: #008775 !important;
- }
- ::v-deep .downline:hover {
- color: #f56c6c !important;
- background: #fef0f0 !important;
- border-color: #fbc4c4 !important;
- }
- ::v-deep .value {
- display: none;
- }
- ::v-deep .el-tree-node__content{
- border-bottom: 1px solid;
- border-image-source: linear-gradient(to right,#fff, #ABDFD9, #fff);
- border-image-slice: 1;
- }
- ::v-deep .el-tree-node__content:hover {
- background: linear-gradient(to right,#fff, rgba(0, 135, 117, 0.1), #fff) !important;
- }
- ::v-deep .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{
- background: linear-gradient(to right,#fff, rgba(0, 135, 117, 0.1), #fff) !important;
- }
- </style>
|