index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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="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="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="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. export default {
  200. data() {
  201. return {
  202. flag: false,
  203. checkList: false,
  204. UncheckList: true,
  205. Unuselist: [],
  206. keyWords: "",
  207. options: [
  208. {
  209. value: 0,
  210. label: "黑名单",
  211. },
  212. {
  213. value: 1,
  214. label: "白名单",
  215. },
  216. ],
  217. boxArr: [],
  218. boxArr1: [],
  219. FormData: {
  220. TacName: "",
  221. TacDesc: "",
  222. DateBegin: "",
  223. DateEnd: "",
  224. TimeBegin: "",
  225. TimeEnd: "",
  226. IpType: 1,
  227. IpList: "",
  228. UseList: [],
  229. Unuselist: [],
  230. Date: [],
  231. Time: [],
  232. },
  233. rules: {
  234. TacName: [
  235. { required: true, message: "请输入策略名称", trigger: "blur" },
  236. {
  237. min: 1,
  238. max: 16,
  239. message: "长度在 1 到 16 个字符",
  240. trigger: "blur",
  241. },
  242. ],
  243. Date: [
  244. { required: true, message: "请选择登录日期", trigger: "change" },
  245. ],
  246. Time: [
  247. { required: true, message: "请选择登录时间", trigger: "change" },
  248. ],
  249. TacDesc: [
  250. { min: 0, max: 200, message: "最大200个字", trigger: "blur" },
  251. ],
  252. },
  253. editId: null,
  254. };
  255. },
  256. created: function () {
  257. this.editId = this.$route.query.TacId;
  258. this.getDetial(this.editId);
  259. },
  260. components: { Dialog },
  261. watch: {
  262. keyWords() {
  263. if (this.keyWords.length == 0) {
  264. this.getDetial(this.editId);
  265. }
  266. },
  267. },
  268. methods: {
  269. queryData() {
  270. this.keyWords = this.keyWords.replace(/\s+/g, "");
  271. const search = this.keyWords;
  272. if (search) {
  273. this.FormData.Unuselist = findarrays(
  274. this.FormData.Unuselist,
  275. "UserName",
  276. search
  277. );
  278. } else {
  279. this.getDetial(this.editId);
  280. // this.getWarningList();
  281. }
  282. // const datas = this.FormData.Unuselist;
  283. // this.FormData.Unuselist = datas.filter(
  284. // (data) =>
  285. // !search || data.UserName.toLowerCase().includes(search.toLowerCase())
  286. // );
  287. },
  288. isValidIP: function (ip) {
  289. let reg =
  290. /^(\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])$/;
  291. return reg.test(ip);
  292. },
  293. save() {
  294. let that = this;
  295. let ipArr = [];
  296. if (this.FormData.IpList) {
  297. ipArr = this.FormData.IpList.split(";");
  298. }
  299. let isSave = true;
  300. if (ipArr.length >= 2) {
  301. ipArr.forEach((item) => {
  302. if (this.isValidIP(item) == false) {
  303. this.$message.error("请输入正确IP段,并以;号隔开");
  304. isSave = false;
  305. }
  306. });
  307. }
  308. this.$refs["ruleForm"].validate((valid) => {
  309. if (valid && isSave) {
  310. return new Promise((resolve, reject) => {
  311. EditTac(this.FormData)
  312. .then((response) => {
  313. if (response.code === 0) {
  314. this.FormData = {
  315. TacName: "",
  316. TacDesc: "",
  317. DateBegin: "",
  318. DateEnd: "",
  319. TimeBegin: "",
  320. TimeEnd: "",
  321. IpType: 1,
  322. IpList: "",
  323. UseList: [],
  324. Unuselist: [],
  325. Date: [],
  326. Time: [],
  327. };
  328. this.$message.success("编辑成功");
  329. this.$store.dispatch("tagsView/delView", this.$route);
  330. that.$router.push("/LoginPolicy");
  331. }
  332. resolve();
  333. })
  334. .catch((error) => {
  335. reject(error);
  336. });
  337. });
  338. } else {
  339. return false;
  340. }
  341. });
  342. },
  343. getDetial(id) {
  344. let that = this;
  345. return new Promise((resolve, reject) => {
  346. GetTacDetails({ TacId: id })
  347. .then((response) => {
  348. if (response.code === 0) {
  349. const { returnData } = response;
  350. returnData["Date"] = new Array();
  351. returnData["Time"] = new Array();
  352. that.FormData = returnData;
  353. that.FormData["Date"].push(returnData.DateBegin);
  354. that.FormData["Date"].push(returnData.DateEnd);
  355. that.FormData["Time"].push(returnData.TimeBegin);
  356. that.FormData["Time"].push(returnData.TimeEnd);
  357. if (that.FormData.UseList == null) {
  358. that.FormData.UseList = [];
  359. }
  360. if (that.FormData.Unuselist == null) {
  361. that.FormData.Unuselist = [];
  362. }
  363. that.Unuselist = that.FormData.Unuselist;
  364. that.boxArr = _.cloneDeep(that.FormData.Unuselist);
  365. }
  366. resolve();
  367. })
  368. .catch((error) => {
  369. reject(error);
  370. });
  371. });
  372. },
  373. changeChecked(val, index) {
  374. this.checkList = false;
  375. this.FormData.UseList.push(val);
  376. this.FormData.Unuselist.splice(index, 1);
  377. },
  378. UnchangeChecked(val, index) {
  379. this.UncheckList = true;
  380. this.FormData.Unuselist.push(val);
  381. this.FormData.UseList.splice(index, 1);
  382. },
  383. dataChange: function (data) {
  384. if (data && data.length > 1) {
  385. this.FormData.DateBegin = data[0];
  386. this.FormData.DateEnd = data[1];
  387. }
  388. },
  389. timeChange: function (data) {
  390. if (data && data.length > 1) {
  391. this.FormData.TimeBegin = data[0];
  392. this.FormData.TimeEnd = data[1];
  393. }
  394. },
  395. //删除
  396. remove() {
  397. let that = this;
  398. return new Promise((resolve, reject) => {
  399. DeleteTac({ TacId: this.FormData.TacId })
  400. .then((response) => {
  401. if (response.code === 0) {
  402. this.delItem = null;
  403. this.$message.success("删除成功");
  404. this.flag = false;
  405. setTimeout(function () {
  406. that.$router.push("/LoginPolicy");
  407. }, 2000);
  408. }
  409. resolve();
  410. })
  411. .catch((error) => {
  412. reject(error);
  413. });
  414. });
  415. },
  416. clearData() {
  417. this.FormData.Unuselist = this.boxArr;
  418. },
  419. },
  420. };
  421. </script>
  422. <style lang="scss" scoped>
  423. .title1 {
  424. width: 150px;
  425. height: 26px;
  426. font-size: 26px;
  427. margin-bottom: 30px;
  428. font-weight: bold;
  429. color: #303133;
  430. }
  431. ::v-deep .el-row {
  432. width: 100%;
  433. }
  434. .Box {
  435. width: 100%;
  436. height: 100%;
  437. padding: 0 64px;
  438. padding-top: 32px;
  439. }
  440. .topBox {
  441. width: 100%;
  442. height: 240px;
  443. background: #ffffff;
  444. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  445. border-radius: 16px;
  446. }
  447. .fristLine {
  448. display: flex;
  449. margin-left: 33px;
  450. }
  451. .inputBox {
  452. display: flex;
  453. height: 32px;
  454. line-height: 32px;
  455. }
  456. .inputBox1 {
  457. display: flex;
  458. height: 32px;
  459. line-height: 32px;
  460. }
  461. .inputBox2 {
  462. display: flex;
  463. height: 32px;
  464. line-height: 32px;
  465. }
  466. .inputBox3 {
  467. display: flex;
  468. height: 32px;
  469. line-height: 32px;
  470. }
  471. .SystemName {
  472. width: 108px;
  473. height: 14px;
  474. font-size: 14px;
  475. font-weight: 400;
  476. color: #303133;
  477. }
  478. .SystemName1 {
  479. width: 70px;
  480. text-align: right;
  481. margin-left: -10px;
  482. height: 14px;
  483. font-size: 14px;
  484. font-weight: 400;
  485. color: #303133;
  486. cursor: pointer;
  487. }
  488. ::v-deep .topBox {
  489. .el-button--default {
  490. width: 80px;
  491. height: 40px;
  492. background: #6e81bc;
  493. color: #ffffff;
  494. border-radius: 6px;
  495. border: none;
  496. }
  497. .inputBox .el-input__inner {
  498. width: 184px;
  499. height: 40px;
  500. background: #f5f7fa;
  501. border: 1px solid #dcdfe6;
  502. border-radius: 6px;
  503. }
  504. .el-select__caret {
  505. text-align: center;
  506. height: 40px;
  507. line-height: 40px;
  508. }
  509. .inputBox1 .el-date-editor {
  510. width: 322px;
  511. height: 40px;
  512. line-height: 40px;
  513. background: #f5f7fa;
  514. border: 1px solid #dcdfe6;
  515. border-radius: 6px;
  516. .el-range-separator {
  517. height: 40px;
  518. line-height: 40px;
  519. }
  520. .el-range-input {
  521. background: #f5f7fa;
  522. }
  523. }
  524. .inputBox2 .el-input__inner {
  525. width: 468px;
  526. height: 40px;
  527. background: #f5f7fa;
  528. border: 1px solid #dcdfe6;
  529. border-radius: 6px;
  530. }
  531. .inputBox3 .el-input__inner {
  532. width: 500px;
  533. height: 40px;
  534. background: #f5f7fa;
  535. border: 1px solid #dcdfe6;
  536. border-radius: 6px;
  537. }
  538. }
  539. .titleBtn {
  540. display: flex;
  541. justify-content: space-between;
  542. padding: 20px;
  543. }
  544. .titleStyle {
  545. width: 200px;
  546. height: 24px;
  547. font-size: 24px;
  548. font-weight: bold;
  549. color: #303133;
  550. margin-left: 10px;
  551. }
  552. .centerBox {
  553. display: flex;
  554. margin-top: 23px;
  555. position: relative;
  556. }
  557. .leftB {
  558. width: 1242px;
  559. height: 760px;
  560. background: #ffffff;
  561. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  562. border-radius: 4px;
  563. }
  564. .center-box {
  565. // max-height: calc(100% - 105px);
  566. margin-top: 12px;
  567. padding: 24px;
  568. display: flex;
  569. justify-content: flex-start;
  570. flex-wrap: wrap;
  571. // overflow: auto;
  572. }
  573. .fpBox {
  574. display: block;
  575. }
  576. .colorTitle {
  577. margin-top: 20px;
  578. width: 195px;
  579. height: 20px;
  580. display: flex;
  581. justify-content: space-between;
  582. float: left;
  583. }
  584. .box-card {
  585. margin-top: 16px;
  586. height: 80px;
  587. background: #f5f7fa;
  588. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
  589. border-radius: 8px;
  590. }
  591. // .center-box :hover {
  592. // box-shadow: 0 16px 32px 0 rgba(48, 55, 66, 0.15);
  593. // transform: translate(0, -5px);
  594. // transition-delay: 0s !important;
  595. // }
  596. .header-top {
  597. display: flex;
  598. flex-direction: row;
  599. align-items: center;
  600. }
  601. .title {
  602. max-width: 60px;
  603. height: 16px;
  604. font-size: 16px;
  605. font-weight: 400;
  606. color: #303133;
  607. margin-right: 20px;
  608. display: block;
  609. white-space: nowrap;
  610. overflow: hidden;
  611. text-overflow: ellipsis;
  612. }
  613. // .box-card :hover {
  614. // box-shadow: none;
  615. // transform: none;
  616. // }
  617. .rightB {
  618. width: 670px;
  619. height: 760px;
  620. background: #ffffff;
  621. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  622. border-radius: 16px;
  623. margin-left: 40px;
  624. overflow: auto;
  625. > .titleBtn {
  626. width: 610px;
  627. position: absolute;
  628. z-index: 99;
  629. top: 0;
  630. right: 0;
  631. background: #ffffff;
  632. }
  633. > .center-box {
  634. margin-top: 41px;
  635. }
  636. .searchBox {
  637. display: flex;
  638. }
  639. }
  640. ::v-deep .rightB {
  641. .el-input__inner {
  642. width: 200px;
  643. height: 32px;
  644. background: #f5f7fa;
  645. border: 1px solid #c0c4cc;
  646. border-radius: 6px;
  647. }
  648. .el-button--default {
  649. width: 64px;
  650. height: 32px;
  651. line-height: 8px;
  652. background: linear-gradient(0deg, #6983be, #777dba);
  653. border-radius: 6px;
  654. color: #ffffff;
  655. border: none;
  656. margin-left: 10px;
  657. }
  658. }
  659. ::-webkit-scrollbar-track-piece {
  660. background: #d3dce6;
  661. }
  662. ::-webkit-scrollbar {
  663. width: 6px;
  664. }
  665. ::-webkit-scrollbar-thumb {
  666. background: #99a9bf;
  667. border-radius: 20px;
  668. }
  669. </style>