index.vue 20 KB

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