index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <div class="Box">
  3. <el-form
  4. :model="FormData"
  5. :rules="rules"
  6. ref="ruleForm"
  7. label-width="100px"
  8. class="demo-ruleForm"
  9. >
  10. <div class="topBox">
  11. <div class="titleBtn">
  12. <span class="titleStyle">策略信息编辑 </span>
  13. <div>
  14. <el-button @click="save()">保存</el-button>
  15. </div>
  16. </div>
  17. <!-- 第一排 -->
  18. <div class="fristLine">
  19. <div class="inputBox">
  20. <el-form-item label="策略名称" prop="TacName">
  21. <el-input
  22. placeholder="请输入"
  23. v-model.trim="FormData.TacName"
  24. ></el-input>
  25. </el-form-item>
  26. </div>
  27. <div class="inputBox">
  28. <el-form-item label="IP类型" prop="IpType">
  29. <el-select v-model="FormData.IpType" placeholder="请选择类型">
  30. <el-option
  31. v-for="item in options"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value"
  35. >
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. </div>
  40. <div class="block inputBox1">
  41. <el-form-item label="登录日期" prop="Date">
  42. <el-date-picker
  43. v-model="FormData.Date"
  44. type="daterange"
  45. range-separator="至"
  46. start-placeholder="开始日期"
  47. end-placeholder="结束日期"
  48. @change="dataChange"
  49. value-format="yyyy-MM-dd"
  50. >
  51. </el-date-picker>
  52. </el-form-item>
  53. </div>
  54. <div class="block inputBox1">
  55. <el-form-item label="登录时间" prop="Time">
  56. <el-time-picker
  57. is-range
  58. v-model="FormData.Time"
  59. range-separator="至"
  60. start-placeholder="开始时间"
  61. end-placeholder="结束时间"
  62. placeholder="选择时间范围"
  63. @change="timeChange"
  64. value-format="HH:mm:ss"
  65. >
  66. </el-time-picker>
  67. </el-form-item>
  68. </div>
  69. </div>
  70. <!-- 第二排 -->
  71. <div class="fristLine" style="margin-top: 24px">
  72. <div class="inputBox2">
  73. <el-form-item label="IP段" prop="IpList">
  74. <el-input
  75. placeholder="请输入IP,并以‘;’号隔开"
  76. v-model.trim="FormData.IpList"
  77. ></el-input>
  78. </el-form-item>
  79. </div>
  80. <div class="inputBox3">
  81. <el-form-item label="描述" prop="TacDesc">
  82. <el-input
  83. placeholder="请输入"
  84. v-model.trim="FormData.TacDesc"
  85. ></el-input>
  86. </el-form-item>
  87. </div>
  88. </div>
  89. </div>
  90. </el-form>
  91. <div class="centerBox">
  92. <div class="leftB">
  93. <div class="titleBtn">
  94. <span class="titleStyle">已分配职员 </span>
  95. </div>
  96. <div class="center-box fpBox">
  97. <el-row class="scCont" :gutter="16">
  98. <el-col
  99. :span="4"
  100. v-for="(item, index) in FormData.UseList"
  101. :key="index"
  102. >
  103. <el-card class="box-card">
  104. <div class="lineTop"></div>
  105. <div class="text item">
  106. <div class="header-top">
  107. <div class="header-mid">
  108. <span class="title">{{ item.UserName }}</span>
  109. </div>
  110. <el-checkbox-group
  111. v-model="UncheckList"
  112. @change="UnchangeChecked(item, index)"
  113. >
  114. <el-checkbox checked></el-checkbox>
  115. </el-checkbox-group>
  116. </div>
  117. </div>
  118. </el-card>
  119. </el-col>
  120. </el-row>
  121. <el-empty
  122. v-if="FormData.UseList.length == 0"
  123. description="没有选取"
  124. style="margin: 0 auto"
  125. ></el-empty>
  126. </div>
  127. </div>
  128. <div class="rightB">
  129. <div class="titleBtn">
  130. <span class="titleStyle">选择职员 </span>
  131. <div class="searchBox">
  132. <el-input
  133. placeholder="请输入内容"
  134. clearable
  135. @clear="clearData"
  136. v-model.trim="keyWords"
  137. ></el-input>
  138. <el-button @click="queryData()">搜索</el-button>
  139. </div>
  140. </div>
  141. <div class="center-box">
  142. <el-row class="scCont" :gutter="16">
  143. <el-col
  144. :span="6"
  145. v-for="(item, index) in FormData.Unuselist"
  146. :key="index"
  147. >
  148. <el-card class="box-card">
  149. <div class="lineTop"></div>
  150. <div class="text item">
  151. <div class="header-top">
  152. <div class="header-mid">
  153. <span :title="item.UserName" class="title">{{
  154. item.UserName
  155. }}</span>
  156. </div>
  157. <el-checkbox-group
  158. v-model="checkList"
  159. @change="changeChecked(item, index)"
  160. >
  161. <el-checkbox></el-checkbox>
  162. </el-checkbox-group>
  163. </div>
  164. </div>
  165. </el-card>
  166. </el-col>
  167. </el-row>
  168. <el-empty
  169. v-if="FormData.Unuselist.length == 0"
  170. description="没有内容"
  171. style="margin: 0 auto"
  172. ></el-empty>
  173. </div>
  174. </div>
  175. </div>
  176. <!--删除弹框-->
  177. <Dialog :flag="flag">
  178. <div class="airportInfoDialog">
  179. <div class="title1">删除策略</div>
  180. <div class="content">是否确认删除该策略?</div>
  181. <div class="foot right t30">
  182. <el-button
  183. size="medium"
  184. @click="remove(item, index)"
  185. type="danger"
  186. class="r24"
  187. >删除</el-button
  188. >
  189. <el-button size="medium" @click="flag = false">取消</el-button>
  190. </div>
  191. </div>
  192. </Dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import { EditTac, GetTacDetails, DeleteTac } from "@/api/systemConfiguration";
  197. import Dialog from "@/layout/components/Dialog";
  198. import { findarrays } from "@/utils/validate";
  199. import { lengthValidator } from "@/utils/validate";
  200. export default {
  201. data() {
  202. return {
  203. flag: false,
  204. checkList: false,
  205. UncheckList: true,
  206. Unuselist: [],
  207. keyWords: "",
  208. options: [
  209. {
  210. value: 0,
  211. label: "黑名单",
  212. },
  213. {
  214. value: 1,
  215. label: "白名单",
  216. },
  217. ],
  218. boxArr: [],
  219. boxArr1: [],
  220. FormData: {
  221. TacName: "",
  222. TacDesc: "",
  223. DateBegin: "",
  224. DateEnd: "",
  225. TimeBegin: "",
  226. TimeEnd: "",
  227. IpType: 1,
  228. IpList: "",
  229. UseList: [],
  230. Unuselist: [],
  231. Date: [],
  232. Time: [],
  233. },
  234. rules: {
  235. TacName: [
  236. { required: true, message: "请输入策略名称", trigger: "blur" },
  237. {
  238. validator: lengthValidator,
  239. max: 16,
  240. message: "长度在 1 到 16 个字符",
  241. trigger: ["change", "blur"],
  242. },
  243. ],
  244. Date: [
  245. { required: true, message: "请选择登录日期", trigger: "change" },
  246. ],
  247. Time: [
  248. { required: true, message: "请选择登录时间", trigger: "change" },
  249. ],
  250. TacDesc: [
  251. {
  252. validator: lengthValidator,
  253. max: 128,
  254. message: "长度在 1 到 128 个字符",
  255. trigger: ["change", "blur"],
  256. },
  257. ],
  258. },
  259. editId: null,
  260. };
  261. },
  262. created: function () {
  263. this.editId = this.$route.query.TacId;
  264. this.getDetial(this.editId);
  265. },
  266. components: { Dialog },
  267. watch: {
  268. keyWords() {
  269. if (this.keyWords.length == 0) {
  270. this.getDetial(this.editId);
  271. }
  272. },
  273. },
  274. methods: {
  275. queryData() {
  276. this.keyWords = this.keyWords.replace(/\s+/g, "");
  277. const search = this.keyWords;
  278. if (search) {
  279. this.FormData.Unuselist = findarrays(
  280. this.FormData.Unuselist,
  281. "UserName",
  282. search
  283. );
  284. } else {
  285. this.getDetial(this.editId);
  286. // this.getWarningList();
  287. }
  288. // const datas = this.FormData.Unuselist;
  289. // this.FormData.Unuselist = datas.filter(
  290. // (data) =>
  291. // !search || data.UserName.toLowerCase().includes(search.toLowerCase())
  292. // );
  293. },
  294. isValidIP: function (ip) {
  295. let reg =
  296. /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
  297. return reg.test(ip);
  298. },
  299. save() {
  300. let that = this;
  301. let ipArr = [];
  302. if (this.FormData.IpList) {
  303. ipArr = this.FormData.IpList.split(";");
  304. }
  305. let isSave = true;
  306. if (ipArr.length >= 2) {
  307. ipArr.forEach((item) => {
  308. if (this.isValidIP(item) == false) {
  309. this.$message.error("请输入正确IP段,并以;号隔开");
  310. isSave = false;
  311. }
  312. });
  313. } else {
  314. if (this.isValidIP(ipArr[0]) == false && ipArr.length) {
  315. this.$message.error("请输入正确IP段,并以;号隔开");
  316. isSave = false;
  317. }
  318. }
  319. this.$refs["ruleForm"].validate((valid) => {
  320. if (valid && isSave) {
  321. return new Promise((resolve, reject) => {
  322. EditTac(this.FormData)
  323. .then((response) => {
  324. if (response.code === 0) {
  325. this.FormData = {
  326. TacName: "",
  327. TacDesc: "",
  328. DateBegin: "",
  329. DateEnd: "",
  330. TimeBegin: "",
  331. TimeEnd: "",
  332. IpType: 1,
  333. IpList: "",
  334. UseList: [],
  335. Unuselist: [],
  336. Date: [],
  337. Time: [],
  338. };
  339. this.$message.success("编辑成功");
  340. this.$store.dispatch("tagsView/delView", this.$route);
  341. that.$router.push("/LoginPolicy");
  342. }
  343. resolve();
  344. })
  345. .catch((error) => {
  346. reject(error);
  347. });
  348. });
  349. } else {
  350. return false;
  351. }
  352. });
  353. },
  354. getDetial(id) {
  355. let that = this;
  356. return new Promise((resolve, reject) => {
  357. GetTacDetails({ TacId: id })
  358. .then((response) => {
  359. if (response.code === 0) {
  360. const { returnData } = response;
  361. returnData["Date"] = new Array();
  362. returnData["Time"] = new Array();
  363. that.FormData = returnData;
  364. that.FormData["Date"].push(returnData.DateBegin);
  365. that.FormData["Date"].push(returnData.DateEnd);
  366. that.FormData["Time"].push(returnData.TimeBegin);
  367. that.FormData["Time"].push(returnData.TimeEnd);
  368. if (that.FormData.UseList == null) {
  369. that.FormData.UseList = [];
  370. }
  371. if (that.FormData.Unuselist == null) {
  372. that.FormData.Unuselist = [];
  373. }
  374. that.Unuselist = that.FormData.Unuselist;
  375. that.boxArr = _.cloneDeep(that.FormData.Unuselist);
  376. }
  377. resolve();
  378. })
  379. .catch((error) => {
  380. reject(error);
  381. });
  382. });
  383. },
  384. changeChecked(val, index) {
  385. this.checkList = false;
  386. this.FormData.UseList.push(val);
  387. this.FormData.Unuselist.splice(index, 1);
  388. },
  389. UnchangeChecked(val, index) {
  390. this.UncheckList = true;
  391. this.FormData.Unuselist.push(val);
  392. this.FormData.UseList.splice(index, 1);
  393. },
  394. dataChange: function (data) {
  395. if (data && data.length > 1) {
  396. this.FormData.DateBegin = data[0];
  397. this.FormData.DateEnd = data[1];
  398. }
  399. },
  400. timeChange: function (data) {
  401. if (data && data.length > 1) {
  402. this.FormData.TimeBegin = data[0];
  403. this.FormData.TimeEnd = data[1];
  404. }
  405. },
  406. //删除
  407. remove() {
  408. let that = this;
  409. return new Promise((resolve, reject) => {
  410. DeleteTac({ TacId: this.FormData.TacId })
  411. .then((response) => {
  412. if (response.code === 0) {
  413. this.delItem = null;
  414. this.$message.success("删除成功");
  415. this.flag = false;
  416. setTimeout(function () {
  417. that.$router.push("/LoginPolicy");
  418. }, 2000);
  419. }
  420. resolve();
  421. })
  422. .catch((error) => {
  423. reject(error);
  424. });
  425. });
  426. },
  427. clearData() {
  428. this.FormData.Unuselist = this.boxArr;
  429. },
  430. },
  431. };
  432. </script>
  433. <style lang="scss" scoped>
  434. .title1 {
  435. width: 150px;
  436. height: 26px;
  437. font-size: 26px;
  438. margin-bottom: 30px;
  439. font-weight: bold;
  440. color: #303133;
  441. }
  442. ::v-deep .el-row {
  443. width: 100%;
  444. }
  445. .Box {
  446. width: 100%;
  447. height: 100%;
  448. padding: 0 64px;
  449. padding-top: 32px;
  450. }
  451. .topBox {
  452. width: 100%;
  453. height: 240px;
  454. background: #ffffff;
  455. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  456. border-radius: 16px;
  457. }
  458. .fristLine {
  459. display: flex;
  460. margin-left: 33px;
  461. }
  462. .inputBox {
  463. display: flex;
  464. height: 32px;
  465. line-height: 32px;
  466. }
  467. .inputBox1 {
  468. display: flex;
  469. height: 32px;
  470. line-height: 32px;
  471. }
  472. .inputBox2 {
  473. display: flex;
  474. height: 32px;
  475. line-height: 32px;
  476. }
  477. .inputBox3 {
  478. display: flex;
  479. height: 32px;
  480. line-height: 32px;
  481. }
  482. .SystemName {
  483. width: 108px;
  484. height: 14px;
  485. font-size: 14px;
  486. font-weight: 400;
  487. color: #303133;
  488. }
  489. .SystemName1 {
  490. width: 70px;
  491. text-align: right;
  492. margin-left: -10px;
  493. height: 14px;
  494. font-size: 14px;
  495. font-weight: 400;
  496. color: #303133;
  497. cursor: pointer;
  498. }
  499. ::v-deep .topBox {
  500. .el-button--default {
  501. width: 80px;
  502. height: 40px;
  503. background: #6e81bc;
  504. color: #ffffff;
  505. border-radius: 6px;
  506. border: none;
  507. }
  508. .inputBox .el-input__inner {
  509. width: 184px;
  510. height: 40px;
  511. background: #f5f7fa;
  512. border: 1px solid #dcdfe6;
  513. border-radius: 6px;
  514. }
  515. .el-select__caret {
  516. text-align: center;
  517. height: 40px;
  518. line-height: 40px;
  519. }
  520. .inputBox1 .el-date-editor {
  521. width: 322px;
  522. height: 40px;
  523. line-height: 40px;
  524. background: #f5f7fa;
  525. border: 1px solid #dcdfe6;
  526. border-radius: 6px;
  527. .el-range-separator {
  528. height: 40px;
  529. line-height: 40px;
  530. }
  531. .el-range-input {
  532. background: #f5f7fa;
  533. }
  534. }
  535. .inputBox2 .el-input__inner {
  536. width: 468px;
  537. height: 40px;
  538. background: #f5f7fa;
  539. border: 1px solid #dcdfe6;
  540. border-radius: 6px;
  541. }
  542. .inputBox3 .el-input__inner {
  543. width: 500px;
  544. height: 40px;
  545. background: #f5f7fa;
  546. border: 1px solid #dcdfe6;
  547. border-radius: 6px;
  548. }
  549. }
  550. .titleBtn {
  551. display: flex;
  552. justify-content: space-between;
  553. padding: 20px;
  554. }
  555. .titleStyle {
  556. width: 200px;
  557. height: 24px;
  558. font-size: 24px;
  559. font-weight: bold;
  560. color: #303133;
  561. margin-left: 10px;
  562. }
  563. .centerBox {
  564. display: flex;
  565. margin-top: 23px;
  566. position: relative;
  567. }
  568. .leftB {
  569. width: 1242px;
  570. height: 760px;
  571. background: #ffffff;
  572. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  573. border-radius: 4px;
  574. }
  575. .center-box {
  576. // max-height: calc(100% - 105px);
  577. margin-top: 12px;
  578. padding: 24px;
  579. display: flex;
  580. justify-content: flex-start;
  581. flex-wrap: wrap;
  582. // overflow: auto;
  583. }
  584. .fpBox {
  585. display: block;
  586. }
  587. .colorTitle {
  588. margin-top: 20px;
  589. width: 195px;
  590. height: 20px;
  591. display: flex;
  592. justify-content: space-between;
  593. float: left;
  594. }
  595. .box-card {
  596. margin-top: 16px;
  597. height: 80px;
  598. background: #f5f7fa;
  599. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
  600. border-radius: 8px;
  601. }
  602. // .center-box :hover {
  603. // box-shadow: 0 16px 32px 0 rgba(48, 55, 66, 0.15);
  604. // transform: translate(0, -5px);
  605. // transition-delay: 0s !important;
  606. // }
  607. .header-top {
  608. display: flex;
  609. flex-direction: row;
  610. align-items: center;
  611. }
  612. .title {
  613. max-width: 60px;
  614. height: 16px;
  615. font-size: 16px;
  616. font-weight: 400;
  617. color: #303133;
  618. margin-right: 20px;
  619. display: block;
  620. white-space: nowrap;
  621. overflow: hidden;
  622. text-overflow: ellipsis;
  623. }
  624. // .box-card :hover {
  625. // box-shadow: none;
  626. // transform: none;
  627. // }
  628. .rightB {
  629. width: 670px;
  630. height: 760px;
  631. background: #ffffff;
  632. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  633. border-radius: 16px;
  634. margin-left: 40px;
  635. overflow: auto;
  636. > .titleBtn {
  637. width: 610px;
  638. position: absolute;
  639. z-index: 99;
  640. top: 0;
  641. right: 0;
  642. background: #ffffff;
  643. }
  644. > .center-box {
  645. margin-top: 41px;
  646. }
  647. .searchBox {
  648. display: flex;
  649. }
  650. }
  651. ::v-deep .rightB {
  652. .el-input__inner {
  653. width: 200px;
  654. height: 32px;
  655. background: #f5f7fa;
  656. border: 1px solid #c0c4cc;
  657. border-radius: 6px;
  658. }
  659. .el-button--default {
  660. width: 64px;
  661. height: 32px;
  662. line-height: 8px;
  663. background: linear-gradient(0deg, #6983be, #777dba);
  664. border-radius: 6px;
  665. color: #ffffff;
  666. border: none;
  667. margin-left: 10px;
  668. }
  669. }
  670. ::-webkit-scrollbar-track-piece {
  671. background: #d3dce6;
  672. }
  673. ::-webkit-scrollbar {
  674. width: 6px;
  675. }
  676. ::-webkit-scrollbar-thumb {
  677. background: #99a9bf;
  678. border-radius: 20px;
  679. }
  680. </style>