123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- <template>
- <div class="Box">
- <el-form
- :model="FormData"
- :rules="rules"
- ref="ruleForm"
- label-width="100px"
- class="demo-ruleForm"
- >
- <div class="topBox">
- <div class="titleBtn">
- <span class="titleStyle">策略信息编辑 </span>
- <div>
- <el-button @click="save()">保存</el-button>
- </div>
- </div>
- <!-- 第一排 -->
- <div class="fristLine">
- <div class="inputBox">
- <el-form-item label="策略名称" prop="TacName">
- <el-input
- placeholder="请输入"
- v-model="FormData.TacName"
- ></el-input>
- </el-form-item>
- </div>
- <div class="inputBox">
- <el-form-item label="IP类型" prop="IpType">
- <el-select v-model="FormData.IpType" placeholder="请选择类型">
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </div>
- <div class="block inputBox1">
- <el-form-item label="登录日期" prop="Date">
- <el-date-picker
- v-model="FormData.Date"
- type="daterange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- @change="dataChange"
- value-format="yyyy-MM-dd"
- >
- </el-date-picker>
- </el-form-item>
- </div>
- <div class="block inputBox1">
- <el-form-item label="登录时间" prop="Time">
- <el-time-picker
- is-range
- v-model="FormData.Time"
- range-separator="至"
- start-placeholder="开始时间"
- end-placeholder="结束时间"
- placeholder="选择时间范围"
- @change="timeChange"
- value-format="HH:mm:ss"
- >
- </el-time-picker>
- </el-form-item>
- </div>
- </div>
- <!-- 第二排 -->
- <div class="fristLine" style="margin-top: 24px">
- <div class="inputBox2">
- <el-form-item label="IP段" prop="IpList">
- <el-input
- placeholder="请输入IP,并以‘;’号隔开"
- v-model="FormData.IpList"
- ></el-input>
- </el-form-item>
- </div>
- <div class="inputBox3">
- <el-form-item label="描述" prop="TacDesc">
- <el-input
- placeholder="请输入"
- v-model="FormData.TacDesc"
- ></el-input>
- </el-form-item>
- </div>
- </div>
- </div>
- </el-form>
- <div class="centerBox">
- <div class="leftB">
- <div class="titleBtn">
- <span class="titleStyle">已分配职员 </span>
- </div>
- <div class="center-box fpBox">
- <el-row class="scCont" :gutter="16">
- <el-col
- :span="4"
- v-for="(item, index) in FormData.UseList"
- :key="index"
- >
- <el-card class="box-card">
- <div class="lineTop"></div>
- <div class="text item">
- <div class="header-top">
- <div class="header-mid">
- <span class="title">{{ item.UserName }}</span>
- </div>
- <el-checkbox-group
- v-model="UncheckList"
- @change="UnchangeChecked(item, index)"
- >
- <el-checkbox checked></el-checkbox>
- </el-checkbox-group>
- </div>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <el-empty
- v-if="FormData.UseList.length == 0"
- description="没有选取"
- style="margin: 0 auto"
- ></el-empty>
- </div>
- </div>
- <div class="rightB">
- <div class="titleBtn">
- <span class="titleStyle">选择职员 </span>
- <div class="searchBox">
- <el-input
- placeholder="请输入内容"
- clearable
- @clear="clearData"
- v-model.trim="keyWords"
- ></el-input>
- <el-button @click="queryData()">搜索</el-button>
- </div>
- </div>
- <div class="center-box">
- <el-row class="scCont" :gutter="16">
- <el-col
- :span="6"
- v-for="(item, index) in FormData.Unuselist"
- :key="index"
- >
- <el-card class="box-card">
- <div class="lineTop"></div>
- <div class="text item">
- <div class="header-top">
- <div class="header-mid">
- <span :title="item.UserName" class="title">{{
- item.UserName
- }}</span>
- </div>
- <el-checkbox-group
- v-model="checkList"
- @change="changeChecked(item, index)"
- >
- <el-checkbox></el-checkbox>
- </el-checkbox-group>
- </div>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <el-empty
- v-if="FormData.Unuselist.length == 0"
- description="没有内容"
- style="margin: 0 auto"
- ></el-empty>
- </div>
- </div>
- </div>
- <!--删除弹框-->
- <Dialog :flag="flag">
- <div class="airportInfoDialog">
- <div class="title1">删除策略</div>
- <div class="content">是否确认删除该策略?</div>
- <div class="foot right t30">
- <el-button
- size="medium"
- @click="remove(item, index)"
- type="danger"
- class="r24"
- >删除</el-button
- >
- <el-button size="medium" @click="flag = false">取消</el-button>
- </div>
- </div>
- </Dialog>
- </div>
- </template>
- <script>
- import { EditTac, GetTacDetails, DeleteTac } from "@/api/systemConfiguration";
- import Dialog from "@/layout/components/Dialog";
- import { findarrays } from "@/utils/validate";
- export default {
- data() {
- return {
- flag: false,
- checkList: false,
- UncheckList: true,
- Unuselist: [],
- keyWords: "",
- options: [
- {
- value: 0,
- label: "黑名单",
- },
- {
- value: 1,
- label: "白名单",
- },
- ],
- boxArr: [],
- boxArr1: [],
- FormData: {
- TacName: "",
- TacDesc: "",
- DateBegin: "",
- DateEnd: "",
- TimeBegin: "",
- TimeEnd: "",
- IpType: 1,
- IpList: "",
- UseList: [],
- Unuselist: [],
- Date: [],
- Time: [],
- },
- rules: {
- TacName: [
- { required: true, message: "请输入策略名称", trigger: "blur" },
- {
- min: 1,
- max: 16,
- message: "长度在 1 到 16 个字符",
- trigger: "blur",
- },
- ],
- Date: [
- { required: true, message: "请选择登录日期", trigger: "change" },
- ],
- Time: [
- { required: true, message: "请选择登录时间", trigger: "change" },
- ],
- TacDesc: [
- { min: 0, max: 200, message: "最大200个字", trigger: "blur" },
- ],
- },
- editId: null,
- };
- },
- created: function () {
- this.editId = this.$route.query.TacId;
- this.getDetial(this.editId);
- },
- components: { Dialog },
- watch: {
- keyWords() {
- if (this.keyWords.length == 0) {
- this.getDetial(this.editId);
- }
- },
- },
- methods: {
- queryData() {
- this.keyWords = this.keyWords.replace(/\s+/g, "");
- const search = this.keyWords;
- if (search) {
- this.FormData.Unuselist = findarrays(
- this.FormData.Unuselist,
- "UserName",
- search
- );
- } else {
- this.getDetial(this.editId);
- // this.getWarningList();
- }
- // const datas = this.FormData.Unuselist;
- // this.FormData.Unuselist = datas.filter(
- // (data) =>
- // !search || data.UserName.toLowerCase().includes(search.toLowerCase())
- // );
- },
- isValidIP: function (ip) {
- let reg =
- /^(\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])$/;
- return reg.test(ip);
- },
- save() {
- let that = this;
- let ipArr = [];
- if (this.FormData.IpList) {
- ipArr = this.FormData.IpList.split(";");
- }
- let isSave = true;
- if (ipArr.length >= 2) {
- ipArr.forEach((item) => {
- if (this.isValidIP(item) == false) {
- this.$message.error("请输入正确IP段,并以;号隔开");
- isSave = false;
- }
- });
- }
- this.$refs["ruleForm"].validate((valid) => {
- if (valid && isSave) {
- return new Promise((resolve, reject) => {
- EditTac(this.FormData)
- .then((response) => {
- if (response.code === 0) {
- this.FormData = {
- TacName: "",
- TacDesc: "",
- DateBegin: "",
- DateEnd: "",
- TimeBegin: "",
- TimeEnd: "",
- IpType: 1,
- IpList: "",
- UseList: [],
- Unuselist: [],
- Date: [],
- Time: [],
- };
- this.$message.success("编辑成功");
- this.$store.dispatch("tagsView/delView", this.$route);
- that.$router.push("/LoginPolicy");
- }
- resolve();
- })
- .catch((error) => {
- reject(error);
- });
- });
- } else {
- return false;
- }
- });
- },
- getDetial(id) {
- let that = this;
- return new Promise((resolve, reject) => {
- GetTacDetails({ TacId: id })
- .then((response) => {
- if (response.code === 0) {
- const { returnData } = response;
- returnData["Date"] = new Array();
- returnData["Time"] = new Array();
- that.FormData = returnData;
- that.FormData["Date"].push(returnData.DateBegin);
- that.FormData["Date"].push(returnData.DateEnd);
- that.FormData["Time"].push(returnData.TimeBegin);
- that.FormData["Time"].push(returnData.TimeEnd);
- if (that.FormData.UseList == null) {
- that.FormData.UseList = [];
- }
- if (that.FormData.Unuselist == null) {
- that.FormData.Unuselist = [];
- }
- that.Unuselist = that.FormData.Unuselist;
- that.boxArr = _.cloneDeep(that.FormData.Unuselist);
- }
- resolve();
- })
- .catch((error) => {
- reject(error);
- });
- });
- },
- changeChecked(val, index) {
- this.checkList = false;
- this.FormData.UseList.push(val);
- this.FormData.Unuselist.splice(index, 1);
- },
- UnchangeChecked(val, index) {
- this.UncheckList = true;
- this.FormData.Unuselist.push(val);
- this.FormData.UseList.splice(index, 1);
- },
- dataChange: function (data) {
- if (data && data.length > 1) {
- this.FormData.DateBegin = data[0];
- this.FormData.DateEnd = data[1];
- }
- },
- timeChange: function (data) {
- if (data && data.length > 1) {
- this.FormData.TimeBegin = data[0];
- this.FormData.TimeEnd = data[1];
- }
- },
- //删除
- remove() {
- let that = this;
- return new Promise((resolve, reject) => {
- DeleteTac({ TacId: this.FormData.TacId })
- .then((response) => {
- if (response.code === 0) {
- this.delItem = null;
- this.$message.success("删除成功");
- this.flag = false;
- setTimeout(function () {
- that.$router.push("/LoginPolicy");
- }, 2000);
- }
- resolve();
- })
- .catch((error) => {
- reject(error);
- });
- });
- },
- clearData() {
- this.FormData.Unuselist = this.boxArr;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .title1 {
- width: 150px;
- height: 26px;
- font-size: 26px;
- margin-bottom: 30px;
- font-weight: bold;
- color: #303133;
- }
- ::v-deep .el-row {
- width: 100%;
- }
- .Box {
- width: 100%;
- height: 100%;
- padding: 0 64px;
- padding-top: 32px;
- }
- .topBox {
- width: 100%;
- height: 240px;
- background: #ffffff;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 16px;
- }
- .fristLine {
- display: flex;
- margin-left: 33px;
- }
- .inputBox {
- display: flex;
- height: 32px;
- line-height: 32px;
- }
- .inputBox1 {
- display: flex;
- height: 32px;
- line-height: 32px;
- }
- .inputBox2 {
- display: flex;
- height: 32px;
- line-height: 32px;
- }
- .inputBox3 {
- display: flex;
- height: 32px;
- line-height: 32px;
- }
- .SystemName {
- width: 108px;
- height: 14px;
- font-size: 14px;
- font-weight: 400;
- color: #303133;
- }
- .SystemName1 {
- width: 70px;
- text-align: right;
- margin-left: -10px;
- height: 14px;
- font-size: 14px;
- font-weight: 400;
- color: #303133;
- cursor: pointer;
- }
- ::v-deep .topBox {
- .el-button--default {
- width: 80px;
- height: 40px;
- background: #6e81bc;
- color: #ffffff;
- border-radius: 6px;
- border: none;
- }
- .inputBox .el-input__inner {
- width: 184px;
- height: 40px;
- background: #f5f7fa;
- border: 1px solid #dcdfe6;
- border-radius: 6px;
- }
- .el-select__caret {
- text-align: center;
- height: 40px;
- line-height: 40px;
- }
- .inputBox1 .el-date-editor {
- width: 322px;
- height: 40px;
- line-height: 40px;
- background: #f5f7fa;
- border: 1px solid #dcdfe6;
- border-radius: 6px;
- .el-range-separator {
- height: 40px;
- line-height: 40px;
- }
- .el-range-input {
- background: #f5f7fa;
- }
- }
- .inputBox2 .el-input__inner {
- width: 468px;
- height: 40px;
- background: #f5f7fa;
- border: 1px solid #dcdfe6;
- border-radius: 6px;
- }
- .inputBox3 .el-input__inner {
- width: 500px;
- height: 40px;
- background: #f5f7fa;
- border: 1px solid #dcdfe6;
- border-radius: 6px;
- }
- }
- .titleBtn {
- display: flex;
- justify-content: space-between;
- padding: 20px;
- }
- .titleStyle {
- width: 200px;
- height: 24px;
- font-size: 24px;
- font-weight: bold;
- color: #303133;
- margin-left: 10px;
- }
- .centerBox {
- display: flex;
- margin-top: 23px;
- position: relative;
- }
- .leftB {
- width: 1242px;
- height: 760px;
- background: #ffffff;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 4px;
- }
- .center-box {
- // max-height: calc(100% - 105px);
- margin-top: 12px;
- padding: 24px;
- display: flex;
- justify-content: flex-start;
- flex-wrap: wrap;
- // overflow: auto;
- }
- .fpBox {
- display: block;
- }
- .colorTitle {
- margin-top: 20px;
- width: 195px;
- height: 20px;
- display: flex;
- justify-content: space-between;
- float: left;
- }
- .box-card {
- margin-top: 16px;
- height: 80px;
- background: #f5f7fa;
- box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
- border-radius: 8px;
- }
- // .center-box :hover {
- // box-shadow: 0 16px 32px 0 rgba(48, 55, 66, 0.15);
- // transform: translate(0, -5px);
- // transition-delay: 0s !important;
- // }
- .header-top {
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .title {
- max-width: 60px;
- height: 16px;
- font-size: 16px;
- font-weight: 400;
- color: #303133;
- margin-right: 20px;
- display: block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- // .box-card :hover {
- // box-shadow: none;
- // transform: none;
- // }
- .rightB {
- width: 670px;
- height: 760px;
- background: #ffffff;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 16px;
- margin-left: 40px;
- overflow: auto;
- > .titleBtn {
- width: 610px;
- position: absolute;
- z-index: 99;
- top: 0;
- right: 0;
- background: #ffffff;
- }
- > .center-box {
- margin-top: 41px;
- }
- .searchBox {
- display: flex;
- }
- }
- ::v-deep .rightB {
- .el-input__inner {
- width: 200px;
- height: 32px;
- background: #f5f7fa;
- border: 1px solid #c0c4cc;
- border-radius: 6px;
- }
- .el-button--default {
- width: 64px;
- height: 32px;
- line-height: 8px;
- background: linear-gradient(0deg, #6983be, #777dba);
- border-radius: 6px;
- color: #ffffff;
- border: none;
- margin-left: 10px;
- }
- }
- ::-webkit-scrollbar-track-piece {
- background: #d3dce6;
- }
- ::-webkit-scrollbar {
- width: 6px;
- }
- ::-webkit-scrollbar-thumb {
- background: #99a9bf;
- border-radius: 20px;
- }
- </style>
|