index.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. <template>
  2. <div>
  3. <d2-container>
  4. <!-- <template slot="header">首页/报警参数</template> -->
  5. <div class="nav">当前所在位置:<a href="#/index">首页</a>>参数设置>定时任务设置</div>
  6. <div class="main">
  7. <div class="left">
  8. <!-- <el-input placeholder="输入关键字进行过滤" v-model="filterText">
  9. </el-input> -->
  10. <div class="leftTitle">
  11. <i class="fa fa-building-o"></i>&emsp;组织机构
  12. </div>
  13. <el-tree
  14. class="filter-tree"
  15. :filter-node-method="filterNode"
  16. v-loading="loading"
  17. :data="leftList"
  18. node-key="id"
  19. :props="defaultProps"
  20. :expand-on-click-node="false"
  21. @node-click="handleNodeClick"
  22. default-expand-all
  23. highlight-current
  24. :default-expanded-keys="this.defaultExpanded"
  25. ref="tree"
  26. >
  27. <span class="custom-tree-node" slot-scope="{ node, data }">
  28. <span v-if="node.level == 1">
  29. <i :class="node.icon"></i>{{ node.label }}
  30. </span>
  31. <span v-if="node.level == 2">
  32. <i :class="node.icon"></i>{{ node.label }}
  33. </span>
  34. <span v-if="node.level == 3">
  35. <i :class="node.icon"></i>{{ node.label }}
  36. </span>
  37. <span v-if="node.level == 4"> <i></i>{{ node.label }} </span>
  38. </span>
  39. </el-tree>
  40. </div>
  41. <div class="right">
  42. <div class="right_main">
  43. <div class="right_title">
  44. <span><i class="fa fa-sliders"></i>&emsp;定时任务列表</span>
  45. </div>
  46. <div class="right_table">
  47. <div class="addBtn">
  48. <el-button size="mini" type="primary" icon="el-icon-plus" @click="addTantou"
  49. >新建定时任务</el-button
  50. >
  51. </div>
  52. <el-table stripe :data="alarmRecord" border style="width: 100%">
  53. <el-table-column
  54. align="center"
  55. label="序号"
  56. type="index"
  57. width="100px"
  58. :index="indexMethod"
  59. ></el-table-column>
  60. <el-table-column
  61. prop="taskName"
  62. label="任务名称"
  63. align="center"
  64. >
  65. </el-table-column>
  66. <el-table-column
  67. prop="detectionDesc"
  68. label="计划检测时间"
  69. align="center"
  70. >
  71. </el-table-column>
  72. <el-table-column prop="eqSum" label="设备数量" align="center">
  73. </el-table-column>
  74. <el-table-column
  75. prop="buildTime"
  76. label="创建时间"
  77. align="center"
  78. >
  79. </el-table-column>
  80. <el-table-column prop="onOrOff" label="是否开启" align="center">
  81. <template slot-scope="scope">
  82. {{scope.row.onOrOff==0?'否':scope.row.onOrOff==1?'是':scope.row.onOrOff}}
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="操作" width="220" align="center">
  86. <template slot-scope="scope">
  87. <el-button
  88. type="primary"
  89. plain
  90. size="mini"
  91. @click="goDetail(scope.row)"
  92. >查看</el-button
  93. >
  94. <el-button
  95. class="editBtn"
  96. size="mini"
  97. plain
  98. @click="goEdit(scope.row)"
  99. >编辑</el-button
  100. >
  101. <el-button type="danger" plain size="mini" @click="del(scope.row)"
  102. >删除</el-button
  103. >
  104. <!-- <el-button @click="delecheck( scope.$index, scope.row)" type="detailbtn" class="fa fa-info-circle" size="mini">查看</el-button> -->
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <el-pagination
  109. @size-change="handleSizeChange"
  110. @current-change="handleCurrentChange"
  111. :current-page="1"
  112. :page-sizes="[10, 20, 30, 40]"
  113. :page-size="pagination.pageSize"
  114. layout="total, sizes, prev, pager, next, jumper"
  115. :total="pagination.total"
  116. >
  117. </el-pagination>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </d2-container>
  123. <!-- //弹框 -->
  124. <el-dialog
  125. :title="title1"
  126. :visible.sync="dialogAlarm"
  127. id="dialogStyle"
  128. width="1080px"
  129. @close="
  130. week = [];
  131. month = [];
  132. addForm = {};
  133. $refs.addForm.resetFields()
  134. yxTableData = [];
  135. "
  136. >
  137. <el-form
  138. :disabled="title1 == '定时任务查看'"
  139. :model="addForm"
  140. label-width="110px"
  141. :inline="true"
  142. :rules="rules"
  143. ref="addForm"
  144. >
  145. <el-form-item label="任务名称:" prop="taskName">
  146. <el-input
  147. style="width: 220px"
  148. placeholder="请输入"
  149. v-model="addForm.taskName"
  150. autocomplete="off"
  151. ></el-input>
  152. </el-form-item>
  153. <el-form-item label="是否开启:" prop="onOrOff">
  154. <el-select v-model="addForm.onOrOff" placeholder="请选择">
  155. <el-option label="是" :value="1"></el-option>
  156. <el-option label="否" :value="0"></el-option>
  157. </el-select>
  158. </el-form-item>
  159. <el-form-item label="产品分类:" prop="productCategoryCode">
  160. <!-- <el-select
  161. v-model="addForm.proCategoryCode"
  162. placeholder="请选择"
  163. ref="selectTree"
  164. >
  165. <el-option
  166. :key="addForm.proCategoryCode"
  167. :value="addForm.proCategoryCode"
  168. :label="addForm.label"
  169. hidden
  170. />
  171. <el-tree
  172. :data="typeLists"
  173. :props="defaultFlProps"
  174. node-key="id"
  175. accordion
  176. highlight-current
  177. @node-click="handleNodeClickFl"
  178. />
  179. </el-select> -->
  180. <el-select
  181. v-model="addForm.productCategoryCode"
  182. placeholder="请选择"
  183. @change="getProCategory"
  184. >
  185. <el-option
  186. v-for="item in typeSonLists"
  187. :key="item.id"
  188. :label="item.productCategoryName"
  189. :value="item.productCategoryCode"
  190. >
  191. </el-option>
  192. </el-select>
  193. </el-form-item>
  194. <el-form-item label="任务触发时间:" prop="timeType">
  195. <el-select
  196. v-model="addForm.timeType"
  197. placeholder="请选择"
  198. :class="
  199. addForm.timeType == '每天' ||
  200. addForm.timeType == '每周' ||
  201. addForm.timeType == '每月' ||
  202. addForm.timeType == '每年'
  203. ? 'shortS'
  204. : ''
  205. "
  206. >
  207. <el-option label="每小时" value="每小时"></el-option>
  208. <el-option label="每天" value="每天"></el-option>
  209. <el-option label="每周" value="每周"></el-option>
  210. <el-option label="每月" value="每月"></el-option>
  211. <el-option label="每年" value="每年"></el-option>
  212. </el-select>
  213. <!-- <el-popover placement="right" v-model="cronPopover">
  214. <cron @change="changeCron" @close="cronPopover=false" i18n="cn"></cron>
  215. <el-input slot="reference" readonly @click="cronPopover=true" v-model="addForm.timeType" placeholder="请输入任务触发时间"></el-input>
  216. </el-popover> -->
  217. </el-form-item>
  218. <el-form-item v-if="addForm.timeType == '每周'" prop="week">
  219. <el-checkbox-group v-model="week">
  220. <el-checkbox
  221. v-for="(item, index) in weekArr"
  222. :key="index"
  223. :label="item"
  224. >
  225. {{ item }}
  226. </el-checkbox>
  227. </el-checkbox-group>
  228. </el-form-item>
  229. <el-form-item v-if="addForm.timeType == '每月'" prop="month">
  230. <el-checkbox-group
  231. style="line-height: 10px; width: 664px"
  232. v-model="month"
  233. >
  234. <el-checkbox v-for="(item, index) in 31" :key="index" :label="item">
  235. {{ item }}
  236. </el-checkbox>
  237. </el-checkbox-group>
  238. </el-form-item>
  239. <el-form-item v-if="addForm.timeType == '每年'" prop="dateTime">
  240. <el-date-picker
  241. popper-class="picker-date"
  242. style="width: 135px"
  243. v-model="addForm.dateTime"
  244. type="date"
  245. value-format="MM-dd"
  246. format="MM-dd"
  247. placeholder="请选择"
  248. >
  249. </el-date-picker>
  250. </el-form-item>
  251. <el-form-item
  252. v-if="
  253. addForm.timeType == '每天' ||
  254. addForm.timeType == '每周' ||
  255. addForm.timeType == '每月' ||
  256. addForm.timeType == '每年'
  257. "
  258. prop="time"
  259. >
  260. <el-time-picker
  261. style="width: 118px"
  262. value-format="HH:mm:ss"
  263. format="HH:mm:ss"
  264. v-model="addForm.time"
  265. placeholder="请选择"
  266. >
  267. </el-time-picker>
  268. </el-form-item>
  269. <el-form-item label="设备标签:" prop="labelCode">
  270. <el-select v-model="addForm.labelCode" placeholder="请选择" >
  271. <el-option v-for="item in tagLists" :key="item.id" :label="item.labelName" :value="item.labelCode">
  272. </el-option>
  273. </el-select>
  274. </el-form-item>
  275. <div style="display: flex; justify-content: space-between">
  276. <el-form-item label="预警设备:" prop="yjsb">
  277. <el-button
  278. v-if="title1 != '定时任务查看'"
  279. type="primary"
  280. icon="el-icon-plus"
  281. @click="
  282. addSbDialog = true;
  283. getSelect();
  284. getSbList();
  285. "
  286. >选择设备</el-button
  287. >
  288. </el-form-item>
  289. <div style="line-height: 40px">
  290. 已选择<span style="color: #008775; padding-top: 13px">{{
  291. yxTableData.length
  292. }}</span
  293. >个
  294. </div>
  295. </div>
  296. </el-form>
  297. <el-table :data="yxTableData" style="width: 100%">
  298. <el-table-column
  299. prop="id"
  300. align="center"
  301. label="设备ID"
  302. show-overflow-tooltip
  303. >
  304. </el-table-column>
  305. <el-table-column prop="eqName" align="center" label="设备名称">
  306. </el-table-column>
  307. <el-table-column
  308. prop="proName"
  309. align="center"
  310. show-overflow-tooltip
  311. min-width="100"
  312. label="所属产品名称"
  313. >
  314. </el-table-column>
  315. <el-table-column prop="labelName" align="center" label="设备标签">
  316. </el-table-column>
  317. <el-table-column
  318. prop="houseCode"
  319. min-width="100"
  320. align="center"
  321. label="所属仓房编码"
  322. >
  323. </el-table-column>
  324. <el-table-column prop="eqStatus" align="center" label="状态">
  325. <template slot-scope="scope">
  326. <el-button
  327. class="online"
  328. v-if="scope.row.eqStatus == 1"
  329. type="primary"
  330. size="mini"
  331. plain
  332. >在线</el-button
  333. >
  334. <el-button
  335. class="downline"
  336. v-if="scope.row.eqStatus == 0"
  337. type="danger"
  338. plain
  339. size="mini"
  340. >离线</el-button
  341. >
  342. <!-- <el-button @click="delecheck( scope.$index, scope.row)" type="detailbtn" class="fa fa-info-circle" size="mini">查看</el-button> -->
  343. </template>
  344. </el-table-column>
  345. <el-table-column label="操作" width="80" align="center">
  346. <template slot-scope="scope">
  347. <el-button type="danger" plain size="mini" @click="del1(scope)"
  348. >删除</el-button
  349. >
  350. <!-- <el-button @click="delecheck( scope.$index, scope.row)" type="detailbtn" class="fa fa-info-circle" size="mini">查看</el-button> -->
  351. </template>
  352. </el-table-column>
  353. </el-table>
  354. <div slot="footer" class="dialog-footer">
  355. <el-button @click="dialogAlarm = false">取 消</el-button>
  356. <el-button type="primary" @click="submitForm('addForm')"
  357. >确 定</el-button
  358. >
  359. </div>
  360. </el-dialog>
  361. <el-dialog
  362. title="添加设备"
  363. width="1100px"
  364. :visible.sync="addSbDialog"
  365. id="dialogStyle"
  366. @close="closeAddSb"
  367. >
  368. <!-- <el-form
  369. :inline="true"
  370. :model="formInline"
  371. class="demo-form-inline"
  372. id="formLabel"
  373. >
  374. <el-form-item label="产品名称:">
  375. <el-select
  376. v-model="formInline.proName"
  377. placeholder="请选择"
  378. size="mini"
  379. >
  380. <el-option
  381. v-for="item in proLists"
  382. :key="item.id"
  383. :label="item.proName"
  384. :value="item.proName"
  385. >
  386. </el-option>
  387. </el-select>
  388. </el-form-item>
  389. <el-form-item label="设备名称:">
  390. <el-select
  391. size="mini"
  392. v-model="formInline.eqName"
  393. placeholder="请选择"
  394. >
  395. <el-option
  396. v-for="item in sbTableData"
  397. :key="item.id"
  398. :label="item.eqName"
  399. :value="item.eqName"
  400. >
  401. </el-option>
  402. </el-select>
  403. </el-form-item>
  404. <el-form-item label="设备标签:">
  405. <el-select
  406. size="mini"
  407. v-model="formInline.labelName"
  408. placeholder="请选择"
  409. >
  410. <el-option
  411. v-for="item in tagLists"
  412. :key="item.id"
  413. :label="item.labelName"
  414. :value="item.labelName"
  415. >
  416. </el-option>
  417. </el-select>
  418. </el-form-item>
  419. <el-form-item>
  420. <el-button
  421. size="mini"
  422. type="primary"
  423. icon="el-icon-search"
  424. @click="search1"
  425. >查询</el-button
  426. >
  427. </el-form-item>
  428. <el-form-item>
  429. <el-button
  430. type="primary"
  431. size="mini"
  432. icon="el-icon-refresh-left"
  433. @click="reset1"
  434. >重置</el-button
  435. >
  436. </el-form-item>
  437. </el-form> -->
  438. <el-table
  439. ref="multipleTable"
  440. :data="sbTableData"
  441. border
  442. style="width: 100%"
  443. @selection-change="handleSelectionChange"
  444. >
  445. <el-table-column type="selection" align="center" width="55">
  446. </el-table-column>
  447. <el-table-column
  448. align="center"
  449. label="序号"
  450. type="index"
  451. width="100px"
  452. :index="indexMethod1"
  453. ></el-table-column>
  454. <el-table-column prop="id" align="center" label="设备ID">
  455. </el-table-column>
  456. <el-table-column prop="eqName" label="设备名称" align="center">
  457. </el-table-column>
  458. <el-table-column prop="proName" label="产品名称" align="center">
  459. </el-table-column>
  460. <el-table-column prop="labelName" label="设备标签" align="center">
  461. </el-table-column>
  462. <el-table-column prop="houseCode" label="所属仓房编码" align="center">
  463. </el-table-column>
  464. </el-table>
  465. <el-pagination
  466. @size-change="handleSizeChange1"
  467. @current-change="handleCurrentChange1"
  468. :current-page="1"
  469. :page-sizes="[10, 20, 30, 40]"
  470. :page-size="pagination1.pageSize"
  471. layout="total, sizes, prev, pager, next, jumper"
  472. :total="pagination1.total"
  473. >
  474. </el-pagination>
  475. <div slot="footer" class="dialog-footer">
  476. <el-button @click="addSbDialog = false">取 消</el-button>
  477. <el-button type="primary" @click="sure">确 定</el-button>
  478. </div>
  479. </el-dialog>
  480. </div>
  481. </template>
  482. <script>
  483. import { cron } from "vue-cron";
  484. import api from "@/api";
  485. import { off } from "process";
  486. export default {
  487. template: "<cron/>",
  488. components: { cron },
  489. name: "hardwareParame",
  490. data() {
  491. return {
  492. typeSonLists:[],
  493. cronPopover: false,
  494. cron: "",
  495. title1: "",
  496. week: [],
  497. typeLists: [],
  498. weekArr: [
  499. "星期一",
  500. "星期二",
  501. "星期三",
  502. "星期四",
  503. "星期五",
  504. "星期六",
  505. "星期日",
  506. ],
  507. month: [],
  508. proLists: [],
  509. bjlxArr: [],
  510. sbTableData: [],
  511. devInfoList: [],
  512. yxTableData: [],
  513. tagLists: [],
  514. defaultFlProps: {
  515. children: "children",
  516. label: "productCategoryName",
  517. },
  518. defaultProps2: {
  519. children: "children",
  520. label: "enumName",
  521. },
  522. formInline: {},
  523. addSbDialog: false,
  524. tableData: [{}],
  525. addForm: {},
  526. rules: {
  527. timeType: [
  528. {
  529. required: true,
  530. message: "请选择任务触发时间",
  531. trigger: ["change", "blur"],
  532. },
  533. ],
  534. week: [{ required: true, message: "请选择", trigger: "blur" }],
  535. month: [{ required: true, message: "请选择", trigger: "blur" }],
  536. time: [{ required: true, message: "请选择", trigger: "blur" }],
  537. dateTime: [{ required: true, message: "请选择", trigger: "blur" }],
  538. productCategoryCode: [
  539. { required: true, message: "请选择产品分类", trigger: "blur" },
  540. ],
  541. onOrOff: [
  542. { required: true, message: "请选择是否开启", trigger: "blur" },
  543. ],
  544. taskName: [
  545. { required: true, message: "请输入任务名称", trigger: "change" },
  546. ],
  547. yjsb: [{ required: true, message: "请选择设备", trigger: "change" }],
  548. labelCode:[
  549. { required: true, message: "请选择设备标签", trigger: "blur" },
  550. ],
  551. },
  552. //表格字段
  553. alarmRecord: [{}],
  554. //分页
  555. pagination: {
  556. // 每页显示的条数
  557. pageSize: 10,
  558. // 当前页
  559. curPage: 1,
  560. // 总数
  561. total: 20,
  562. },
  563. //弹框分页
  564. pagination1: {
  565. // 每页显示的条数
  566. pageSize: 10,
  567. // 当前页
  568. curPage: 1,
  569. // 总数
  570. total: 20,
  571. },
  572. disabled: false,
  573. // label宽度
  574. formLabelWidth: "120px",
  575. // 弹框默认关闭
  576. dialogAlarm: false,
  577. filterText: "",
  578. //默认展开的节点
  579. defaultProps: {
  580. children: "children",
  581. label: "orgName",
  582. },
  583. loading: false,
  584. //默认展开的节点
  585. defaultExpanded: [],
  586. cfbh: "",
  587. //左侧树数据
  588. leftList: [],
  589. // 日期插件
  590. //
  591. formData: {
  592. status: 0,
  593. totalStatus: 0,
  594. totalThreshold: "",
  595. timeThreshold: "",
  596. telephoneNumber1: "",
  597. telephoneNumber2: "",
  598. smsNumber1: "",
  599. smsNumber2: "",
  600. id: "",
  601. },
  602. //弹框字段
  603. dialog: {
  604. name: "",
  605. },
  606. };
  607. },
  608. // watch: {
  609. // filterTest(val) {
  610. // this.$refs.tree.filter(val);
  611. // },
  612. // },
  613. created() {
  614. this.getSelect();
  615. },
  616. methods: {
  617. getProCategory(v){
  618. var arr=this.typeSonLists.filter(item=>{
  619. return item.productCategoryCode==v
  620. })
  621. this.addForm.productCategoryName=arr[0].productCategoryName
  622. },
  623. getCorn() {
  624. // 拼接cron表达式
  625. this.addForm.detectionDesc = "";
  626. let timeType = this.addForm.timeType;
  627. console.log(timeType);
  628. if (timeType != "每小时"&&timeType != undefined) {
  629. if(this.addForm.time){
  630. var HhMmSs = this.addForm.time.split(":"); // 拼接
  631. }
  632. }
  633. if (timeType == "每年") {
  634. // 每年
  635. var month = this.addForm.dateTime.substring(0, 2); // 截取月
  636. var day = this.addForm.dateTime.substring(3); // 截取日
  637. this.addForm.detectionCron =
  638. HhMmSs[2] +
  639. " " +
  640. HhMmSs[1] +
  641. " " +
  642. HhMmSs[0] +
  643. " " +
  644. day +
  645. " " +
  646. month +
  647. " ?";
  648. this.addForm.detectionDesc +=
  649. month + ":" + day + "号" + this.addForm.time + "执行";
  650. } else if (timeType == "每月") {
  651. // 每月
  652. var days = this.month.toString();
  653. this.addForm.detectionCron =
  654. HhMmSs[2] + " " + HhMmSs[1] + " " + HhMmSs[0] + " " + days + " * ?";
  655. this.addForm.detectionDesc += days + "号" + this.addForm.time + "执行";
  656. } else if (timeType == "每周") {
  657. // 每周
  658. var CWeeks = ""; // cron公历周使用
  659. var weeks = ""; // cron公历周使用
  660. this.week.forEach((item, index) => {
  661. if (item == "星期一") {
  662. CWeeks += "2,";
  663. weeks += "1,";
  664. } else if (item == "星期二") {
  665. CWeeks += "3,";
  666. weeks += "2,";
  667. } else if (item == "星期三") {
  668. CWeeks += "4,";
  669. weeks += "3,";
  670. } else if (item == "星期四") {
  671. CWeeks += "5,";
  672. weeks += "4,";
  673. } else if (item == "星期五") {
  674. CWeeks += "6,";
  675. weeks += "5,";
  676. } else if (item == "星期六") {
  677. CWeeks += "7,";
  678. weeks += "6,";
  679. } else if (item == "星期日") {
  680. CWeeks += "1,";
  681. weeks += "7,";
  682. }
  683. });
  684. var subCWeeks = CWeeks.substring(0, CWeeks.length - 1);
  685. // cron
  686. this.addForm.detectionCron =
  687. HhMmSs[2] + " " + HhMmSs[1] + " " + HhMmSs[0] + " ? * " + subCWeeks;
  688. // 计划检测时间描述
  689. var lastWeeks = weeks.substring(0, weeks.length - 1);
  690. this.addForm.detectionDesc +=
  691. lastWeeks + "的" + this.addForm.time + "执行";
  692. } else if (timeType == "每天") {
  693. // 每天
  694. // cron表达式(每天设置时分秒执行一次)
  695. this.addForm.detectionCron =
  696. HhMmSs[2] + " " + HhMmSs[1] + " " + HhMmSs[0] + " * * ?";
  697. // 计划检测时间描述
  698. this.addForm.detectionDesc += this.addForm.time + "执行";
  699. } else {
  700. // 每小时
  701. // cron表达式(每小时执行一次)
  702. this.addForm.detectionCron = "0 0 * * * ?";
  703. // 计划检测时间描述
  704. this.addForm.detectionDesc += "执行";
  705. }
  706. console.log(this.addForm.detectionCron);
  707. console.log(this.addForm.detectionDesc);
  708. },
  709. changeCron(val) {
  710. this.$set(this.addForm, "timeType", val);
  711. // this.addForm.timeType=val
  712. },
  713. //删除
  714. del(row) {
  715. this.$confirm("确认进行删除操作吗?", "删除提示", {
  716. confirmButtonText: "确定",
  717. cancelButtonText: "取消",
  718. type: "warning",
  719. }).then(() => {
  720. api.timingTaskDel(row.id).then((res) => {
  721. if (res.code == 200) {
  722. this.$message({
  723. type: "success",
  724. message: "删除成功",
  725. });
  726. this.getList();
  727. } else {
  728. this.$message({
  729. type: "error",
  730. message: res.msg,
  731. });
  732. }
  733. });
  734. });
  735. },
  736. goDetail(row) {
  737. this.title1 = "定时任务查看";
  738. this.dialogAlarm = true;
  739. this.getBjlxArr();
  740. api.timingTaskDetail(row.id).then((res) => {
  741. if (res.code == 200) {
  742. this.addForm = res.data;
  743. let objTime=JSON.parse(this.addForm.objTime)
  744. if(objTime){
  745. this.$set(this.addForm, "timeType", objTime.timeType);
  746. if(objTime.timeType=='每年'){
  747. this.addForm.dateTime=objTime.dateTime
  748. this.addForm.time=objTime.time
  749. }else if(objTime.timeType=='每月'){
  750. this.month=objTime.month
  751. this.addForm.time=objTime.time
  752. }else if(objTime.timeType=='每周'){
  753. this.week=objTime.week
  754. this.addForm.time=objTime.time
  755. }else if(objTime.timeType=='每天'){
  756. this.week=objTime.week
  757. }
  758. }
  759. this.yxTableData = this.addForm.devInfoList;
  760. } else {
  761. this.$message.error(res.msg);
  762. }
  763. });
  764. },
  765. goEdit(row) {
  766. this.title1 = "定时任务编辑";
  767. this.dialogAlarm = true;
  768. this.getBjlxArr();
  769. api.timingTaskDetail(row.id).then((res) => {
  770. if (res.code == 200) {
  771. this.addForm = res.data;
  772. let objTime=JSON.parse(this.addForm.objTime)
  773. if(objTime){
  774. this.$set(this.addForm, "timeType", objTime.timeType);
  775. if(objTime.timeType=='每年'){
  776. this.addForm.dateTime=objTime.dateTime
  777. this.addForm.time=objTime.time
  778. }else if(objTime.timeType=='每月'){
  779. this.month=objTime.month
  780. this.addForm.time=objTime.time
  781. }else if(objTime.timeType=='每周'){
  782. this.week=objTime.week
  783. this.addForm.time=objTime.time
  784. }else if(objTime.timeType=='每天'){
  785. this.addForm.time=objTime.time
  786. }
  787. }
  788. console.log(this.addForm,990);
  789. this.yxTableData = this.addForm.devInfoList;
  790. } else {
  791. this.$message.error(res.msg);
  792. }
  793. });
  794. },
  795. //删除已选设备
  796. del1(scope) {
  797. this.$confirm("确认进行删除操作吗?", "删除提示", {
  798. confirmButtonText: "确定",
  799. cancelButtonText: "取消",
  800. type: "warning",
  801. }).then(() => {
  802. this.yxTableData.splice(scope.$index, 1);
  803. this.$message({
  804. type: "success",
  805. message: "删除成功",
  806. });
  807. });
  808. },
  809. closeAddSb() {
  810. this.formInline = {};
  811. this.$refs.multipleTable.clearSelection();
  812. },
  813. // 添加设备
  814. sure() {
  815. this.addSbDialog = false;
  816. this.yxTableData = JSON.parse(JSON.stringify(this.devInfoList));
  817. console.log(this.devInfoList);
  818. },
  819. submitForm(formName) {
  820. this.addForm.eqCode = "";
  821. if (this.yxTableData.length > 0) {
  822. this.addForm.proCode = this.yxTableData[0].proCode;
  823. this.yxTableData.forEach((item) => {
  824. this.addForm.eqCode += item.eqCode += ",";
  825. // this.addForm.proCode+=(item.proCode+=',')
  826. });
  827. this.addForm.eqCode = this.addForm.eqCode.substring(
  828. 0,
  829. this.addForm.eqCode.length - 1
  830. );
  831. // this.addForm.proCode=this.addForm.proCode.substring(0, this.addForm.proCode.length - 1)
  832. this.$nextTick(() => {
  833. this.$refs[formName].clearValidate(["yjsb"]);
  834. });
  835. }
  836. this.addForm.week = JSON.parse(JSON.stringify(this.week));
  837. this.addForm.month = JSON.parse(JSON.stringify(this.month));
  838. this.addForm.orgCode = this.orgCode;
  839. this.$refs[formName].validate((valid) => {
  840. console.log(this.addForm);
  841. if (valid) {
  842. this.getCorn();
  843. this.addForm.devInfoList = this.yxTableData;
  844. let data = JSON.parse(JSON.stringify(this.addForm));
  845. // data.label = undefined;
  846. // data.month = undefined;
  847. // data.week = undefined;
  848. // data.timeType = undefined;
  849. console.log(data.dateTime);
  850. var objTime = {
  851. month: data.month,
  852. week: data.week,
  853. timeType: data.timeType,
  854. dateTime: data.dateTime,
  855. time:data.time
  856. };
  857. data.objTime = JSON.stringify(objTime);
  858. if (this.title1 == "新建定时任务") {
  859. api.timingTaskSave(data).then((res) => {
  860. if (res.code == 200) {
  861. this.$message.success("新建成功");
  862. this.getList();
  863. this.dialogAlarm = false;
  864. } else {
  865. this.$message.error(res.msg);
  866. }
  867. });
  868. } else {
  869. api.timingTaskUpdate(data).then((res) => {
  870. if (res.code == 200) {
  871. this.$message.success("编辑成功");
  872. this.getList();
  873. this.dialogAlarm = false;
  874. } else {
  875. this.$message.error(res.msg);
  876. }
  877. });
  878. }
  879. } else {
  880. let str = "";
  881. this.$refs[formName].fields.forEach((item) => {
  882. if(item.validateMessage==undefined){
  883. item.validateMessage=''
  884. }
  885. str += item.validateMessage;
  886. });
  887. console.log(str);
  888. if (this.yxTableData.length > 0 && str == "请选择设备") {
  889. this.getCorn();
  890. this.addForm.devInfoList = this.yxTableData;
  891. let data = JSON.parse(JSON.stringify(this.addForm));
  892. // data.label = undefined;
  893. // data.month = undefined;
  894. // data.week = undefined;
  895. // data.timeType = undefined;
  896. var objTime = {
  897. month: data.month,
  898. week: data.week,
  899. timeType: data.timeType,
  900. dateTime: data.dateTime,
  901. time:data.time
  902. };
  903. data.objTime = JSON.stringify(objTime);
  904. if (this.title1 == "新建定时任务") {
  905. api.timingTaskSave(data).then((res) => {
  906. if (res.code == 200) {
  907. this.$message.success("新建成功");
  908. this.getList();
  909. this.dialogAlarm = false;
  910. } else {
  911. this.$message.error(res.msg);
  912. }
  913. });
  914. } else {
  915. api.timingTaskUpdate(data).then((res) => {
  916. if (res.code == 200) {
  917. this.$message.success("编辑成功");
  918. this.getList();
  919. this.dialogAlarm = false;
  920. } else {
  921. this.$message.error(res.msg);
  922. }
  923. });
  924. }
  925. } else {
  926. return false;
  927. }
  928. }
  929. });
  930. },
  931. handleSelectionChange(val) {
  932. this.devInfoList = val;
  933. },
  934. handleNodeClickFl(data) {
  935. console.log(data);
  936. this.$set(this.addForm, "productCategoryCode", data.productCategoryCode);
  937. this.$set(this.addForm, "productCategoryName", data.productCategoryName);
  938. this.$set(this.addForm, "label", data.productCategoryName);
  939. // 使 input 失去焦点,并隐藏下拉框
  940. this.$refs.selectTree.blur();
  941. },
  942. handleNodeClick2(data) {
  943. console.log(data);
  944. this.$set(this.addForm, "alarmTypeCode", data.enumCode);
  945. this.$set(this.addForm, "alarmTypeName", data.enumName);
  946. this.$set(this.addForm, "label", data.enumName);
  947. // 使 input 失去焦点,并隐藏下拉框
  948. this.$refs.selectTree1.blur();
  949. },
  950. getSelect() {
  951. api
  952. .productCategoryList(localStorage.getItem("orgCode"))
  953. .then((res) => {
  954. if (res.code == 200) {
  955. this.typeLists = res.data;
  956. }
  957. })
  958. .catch((err) => {
  959. console.log(err);
  960. });
  961. api.productGetSonList(localStorage.getItem("orgCode")).then(res=>{
  962. if (res.code == 200) {
  963. this.typeSonLists = res.data;
  964. }
  965. })
  966. api
  967. .productList({ curPage: 1, pageSize: 99999,condition: JSON.stringify({org_code:localStorage.getItem("orgCode")}) })
  968. .then((res) => {
  969. if (res.code == 200) {
  970. this.proLists = res.data.records;
  971. }
  972. })
  973. .catch((err) => {
  974. console.log(err);
  975. });
  976. api
  977. .equipmentTagList({ curPage: 1, pageSize: 99999 })
  978. .then((res) => {
  979. if (res.code == 200) {
  980. this.tagLists = res.data.records;
  981. }
  982. })
  983. .catch((err) => {
  984. console.log(err);
  985. });
  986. },
  987. //获取设备列表数据
  988. getSbList() {
  989. var condition = this.formInline;
  990. condition.labelCode=this.addForm.labelCode;
  991. condition.productCategoryCode=this.addForm.productCategoryCode;
  992. condition.org_code=localStorage.getItem("orgCode");
  993. condition = JSON.stringify(condition);
  994. var data = {
  995. pageIndex: this.pagination1.curPage,
  996. pageSize: this.pagination1.pageSize,
  997. condition: condition,
  998. };
  999. api
  1000. .equipmentList(data)
  1001. .then((res) => {
  1002. if (res.code == 200) {
  1003. this.sbTableData = res.data.records;
  1004. this.pagination1.pageSize = res.data.size;
  1005. this.pagination1.total = res.data.total;
  1006. this.$nextTick(() => {
  1007. this.sbTableData.forEach((row) => {
  1008. this.yxTableData.forEach((row1) => {
  1009. if (row.id == row1.id) {
  1010. this.$refs.multipleTable.toggleRowSelection(row, true);
  1011. }
  1012. });
  1013. });
  1014. });
  1015. }
  1016. })
  1017. .catch((err) => {
  1018. console.log(err);
  1019. });
  1020. },
  1021. // 每页条数改变
  1022. handleSizeChange1(val) {
  1023. this.pagination1.pageSize = val;
  1024. },
  1025. // 当前页改变
  1026. handleCurrentChange1(val) {
  1027. this.pagination1.curPage = val;
  1028. },
  1029. // 每页条数改变
  1030. handleSizeChange(val) {
  1031. this.pagination.pageSize = val;
  1032. this.getList();
  1033. },
  1034. // 当前页改变
  1035. handleCurrentChange(val) {
  1036. this.pagination.curPage = val;
  1037. this.getList();
  1038. },
  1039. // 数字且最多小数点两位
  1040. oninput(num) {
  1041. var str = num;
  1042. var len1 = str.substr(0, 1);
  1043. var len2 = str.substr(1, 1);
  1044. // 如果第一位是0,第二位不是点,就用数字把点替换掉
  1045. if (str.length > 1 && len1 == 0 && len2 != ".") {
  1046. str = str.substr(1, 1);
  1047. }
  1048. // 第一位不能是.
  1049. if (len1 == ".") {
  1050. str = "";
  1051. }
  1052. // 限制只能输入一个小数点
  1053. if (str.indexOf(".") != -1) {
  1054. var str_ = str.substr(str.indexOf(".") + 1);
  1055. if (str_.indexOf(".") != -1) {
  1056. str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
  1057. }
  1058. }
  1059. // 正则替换
  1060. str = str.replace(/[^\d^\.]+/g, ""); // 保留数字和小数点
  1061. str = str.replace(/\.\d\d\d$/, ""); // 小数点后只能输两位
  1062. return str;
  1063. },
  1064. //获取左侧树
  1065. getLeftTree() {
  1066. this.loading = true;
  1067. let params = {
  1068. orgName: this.orgName,
  1069. };
  1070. api
  1071. .leftTree(params)
  1072. .then((res) => {
  1073. if (res.code == 200) {
  1074. console.log(res);
  1075. this.leftList = [];
  1076. if (res.data) {
  1077. this.leftList = res.data;
  1078. // if (res.data[0].id) {
  1079. // this.defaultExpanded.push(res.data[0].id);
  1080. // if (res.data[0].children) {
  1081. // this.defaultExpanded.push(
  1082. // res.data[0].children[0].children[0].id
  1083. // );
  1084. // this.cfbh =
  1085. // res.data[0].children[0].children[0].children[0].id;
  1086. // setTimeout(() => {
  1087. // document.getElementsByClassName("el-tree-node__content")[0].style.display="none"
  1088. // document.getElementsByClassName("el-tree-node__content")[1].style.display="none"
  1089. // this.$refs.tree.setCurrentKey(this.cfbh);
  1090. // this.$refs.tree.setCurrentKey(this.cfbh);
  1091. // }, 100);
  1092. // console.log(this.leftList);
  1093. // this.getList();
  1094. // }
  1095. // }
  1096. var lastLevel = res.data;
  1097. if (lastLevel.length > 0) {
  1098. lastLevel = res.data[0];
  1099. while (lastLevel.children && lastLevel.children.length > 0) {
  1100. lastLevel = lastLevel.children[0];
  1101. }
  1102. this.defaultExpanded.push(lastLevel.id);
  1103. this.cfbh = lastLevel.id;
  1104. this.addForm.orgCode = lastLevel.orgCode;
  1105. this.orgCode = lastLevel.orgCode;
  1106. setTimeout(() => {
  1107. this.$refs.tree.setCurrentKey(this.cfbh);
  1108. }, 200);
  1109. this.getList();
  1110. }
  1111. }
  1112. } else {
  1113. this.$message({
  1114. type: "error",
  1115. message: res.msg,
  1116. });
  1117. }
  1118. this.loading = false;
  1119. })
  1120. .catch((error) => {
  1121. this.loading = false;
  1122. console.log(error);
  1123. });
  1124. },
  1125. //点击左侧树节点
  1126. handleNodeClick(data, node) {
  1127. console.log(data, node);
  1128. // if(node.level ===4){
  1129. // this.cfbh=data.id;
  1130. // console.log( this.cfbh,";;;")
  1131. // }
  1132. // this.getList();
  1133. if (node.childNodes.length === 0) {
  1134. this.cfbh = data.id;
  1135. this.addForm.orgCode = data.orgCode;
  1136. this.orgCode = data.orgCode;
  1137. console.log(this.cfbh, ";;;");
  1138. this.getList();
  1139. }
  1140. },
  1141. filterNode(value, data) {
  1142. if (!value) return true;
  1143. return data.orgName.indexOf(value) !== -1;
  1144. },
  1145. // filterNode(value, data) {
  1146. // if (!value) return true;
  1147. // return data.label.indexOf(value) !== -1;
  1148. // },
  1149. //获取列表数据
  1150. getList() {
  1151. var condition = { orgCode: this.orgCode };
  1152. condition = JSON.stringify(condition);
  1153. var data = {
  1154. pageIndex: this.pagination.curPage,
  1155. pageSize: this.pagination.pageSize,
  1156. condition: condition,
  1157. };
  1158. console.log(api);
  1159. api
  1160. .timingTaskPage(data)
  1161. .then((res) => {
  1162. if (res.code == 200) {
  1163. this.alarmRecord = res.data.records;
  1164. this.pagination.pageSize = res.data.size;
  1165. this.pagination.total = res.data.total;
  1166. } else {
  1167. this.$message.error(res.msg);
  1168. }
  1169. })
  1170. .catch((err) => {
  1171. console.log(err);
  1172. });
  1173. },
  1174. search1() {
  1175. this.getSbList();
  1176. },
  1177. reset1() {
  1178. this.formInline = {};
  1179. },
  1180. search() {
  1181. this.getList();
  1182. },
  1183. reset() {
  1184. this.addForm = {};
  1185. },
  1186. //新增
  1187. addTantou() {
  1188. this.title1 = "新建定时任务";
  1189. this.dialogAlarm = true;
  1190. this.getBjlxArr();
  1191. },
  1192. getBjlxArr() {
  1193. var condition = {
  1194. enumName: "报警类型",
  1195. };
  1196. condition = JSON.stringify(condition);
  1197. var data = {
  1198. condition: condition,
  1199. };
  1200. api
  1201. .dataDic(data)
  1202. .then((res) => {
  1203. if (res.code == 200) {
  1204. this.bjlxArr = res.data;
  1205. }
  1206. })
  1207. .catch((err) => {
  1208. console.log(err);
  1209. });
  1210. },
  1211. //表格序号
  1212. indexMethod(index) {
  1213. return (
  1214. (this.pagination.curPage - 1) * this.pagination.pageSize + index + 1
  1215. );
  1216. },
  1217. //表格序号
  1218. indexMethod1(index) {
  1219. return (
  1220. (this.pagination1.curPage - 1) * this.pagination1.pageSize + index + 1
  1221. );
  1222. },
  1223. //弹框确定按钮
  1224. determine() {},
  1225. },
  1226. mounted() {
  1227. this.getLeftTree();
  1228. },
  1229. };
  1230. </script>
  1231. <style lang="scss" scoped>
  1232. .main {
  1233. height: 100%;
  1234. display: flex;
  1235. .left {
  1236. height: calc(100vh - 140px);
  1237. .leftTitle {
  1238. background: linear-gradient(0deg, #008574 0%, #01a48f 100%);
  1239. border-top-left-radius: 6px;
  1240. border-top-right-radius: 6px;
  1241. padding: 10px;
  1242. font-size: 16px;
  1243. color: #fff;
  1244. font-weight: bold;
  1245. }
  1246. }
  1247. .right {
  1248. margin-left: 20px;
  1249. width: calc(100% - 280px);
  1250. border: 1px solid #dedede;
  1251. background-color: #fff;
  1252. border-radius: 6px;
  1253. .right_main {
  1254. border-top-left-radius: 6px;
  1255. border-top-right-radius: 6px;
  1256. }
  1257. .right_title {
  1258. font-weight: bold;
  1259. font-size: 16px;
  1260. border-bottom: 1px solid #ebeef5;
  1261. background-color: rgba(233, 244, 243, 0.5);
  1262. border-top-left-radius: 6px;
  1263. border-top-right-radius: 6px;
  1264. color: #008775;
  1265. border-bottom: 1px solid rgba(1, 164, 143, 0.3);
  1266. padding-left: 0;
  1267. span {
  1268. padding: 10px;
  1269. padding-bottom: 9px;
  1270. border-bottom: 2px solid #01a48f;
  1271. }
  1272. }
  1273. }
  1274. .addBtn {
  1275. margin-bottom: 10px;
  1276. margin-top: -10px;
  1277. text-align: right;
  1278. }
  1279. h4 {
  1280. font-size: 16px;
  1281. font-weight: 700;
  1282. line-height: 40px;
  1283. // color:#fff;
  1284. }
  1285. p {
  1286. // color: #525357;
  1287. font-size: 14px;
  1288. line-height: 40px;
  1289. position: relative;
  1290. color: #fff;
  1291. }
  1292. }
  1293. .nav {
  1294. padding: 10px 0 10px 10px;
  1295. margin-bottom: 20px;
  1296. // color: #fff;
  1297. font-size: 14px;
  1298. background: #ffffff;
  1299. border: 1px solid #dedede;
  1300. cursor: pointer;
  1301. }
  1302. .shortS {
  1303. width: 93px;
  1304. }
  1305. ::v-deep .el-checkbox__label {
  1306. padding-left: 2px !important;
  1307. }
  1308. ::v-deep .el-checkbox {
  1309. margin-right: 10px !important;
  1310. }
  1311. ::v-deep .online:hover {
  1312. background-color: rgba(7, 115, 94, 0.07) !important;
  1313. color: #008775 !important;
  1314. }
  1315. ::v-deep .downline:hover {
  1316. color: #f56c6c !important;
  1317. background: #fef0f0 !important;
  1318. border-color: #fbc4c4 !important;
  1319. }
  1320. ::v-deep .value {
  1321. display: none;
  1322. }
  1323. ::v-deep .el-tree-node__content{
  1324. border-bottom: 1px solid;
  1325. border-image-source: linear-gradient(to right,#fff, #ABDFD9, #fff);
  1326. border-image-slice: 1;
  1327. }
  1328. ::v-deep .el-tree-node__content:hover {
  1329. background: linear-gradient(to right,#fff, rgba(0, 135, 117, 0.1), #fff) !important;
  1330. }
  1331. ::v-deep .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content{
  1332. background: linear-gradient(to right,#fff, rgba(0, 135, 117, 0.1), #fff) !important;
  1333. }
  1334. </style>