index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <div class="wrap">
  4. <Minheader :is-auth="true" :is-statuser="true" @addForm="addForm">
  5. <template #header>
  6. <div class="status flex-wrap">
  7. <div class="manageTitle">登录策略</div>
  8. </div>
  9. </template></Minheader
  10. >
  11. <div class="app-containers">
  12. <el-table
  13. :data="tableData"
  14. style="width: 100%"
  15. :row-style="rowStyle"
  16. :row-class-name="tableRowClassName"
  17. :cell-class-name="cellClassName"
  18. :row-key="
  19. props.tableProperty.rowKey
  20. ? props.tableProperty.rowKey
  21. : tablePropertyDefault.rowKey
  22. "
  23. :height="
  24. props.tableProperty.height
  25. ? props.tableProperty.height
  26. : tablePropertyDefault.height
  27. "
  28. :max-height="
  29. props.tableProperty.maxHeight
  30. ? props.tableProperty.maxHeight
  31. : tablePropertyDefault.maxHeight
  32. "
  33. :stripe="
  34. props.tableProperty.stripe
  35. ? props.tableProperty.stripe
  36. : tablePropertyDefault.stripe
  37. "
  38. :border="
  39. props.tableProperty.border
  40. ? props.tableProperty.border
  41. : tablePropertyDefault.border
  42. "
  43. :highlight-current-row="
  44. props.tableProperty.highlightCurrentRow
  45. ? props.tableProperty.highlightCurrentRow
  46. : tablePropertyDefault.highlightCurrentRow
  47. "
  48. :header-cell-class-name="
  49. props.tableProperty.headerRowClassName
  50. ? props.tableProperty.headerRowClassName
  51. : tablePropertyDefault.headerRowClassName
  52. "
  53. :tooltip-effect="
  54. props.tableProperty.tooltipEffect
  55. ? props.tableProperty.tooltipEffect
  56. : tablePropertyDefault.tooltipEffect
  57. "
  58. :show-summary="
  59. props.tableProperty.showSummary
  60. ? props.tableProperty.showSummary
  61. : tablePropertyDefault.showSummary
  62. "
  63. >
  64. <el-table-column
  65. prop="name"
  66. label="名称"
  67. class="infinite-list-item"
  68. />
  69. <el-table-column label="有效日期" class="infinite-list-item">
  70. <el-table-column
  71. prop="china"
  72. label="开始日期"
  73. class="infinite-list-item"
  74. />
  75. <el-table-column
  76. prop="englin"
  77. label="结束日期"
  78. class="infinite-list-item"
  79. />
  80. </el-table-column>
  81. <el-table-column label="有效时间" class="infinite-list-item">
  82. <el-table-column
  83. prop="china"
  84. label="开始时间"
  85. class="infinite-list-item"
  86. />
  87. <el-table-column
  88. prop="englin"
  89. label="结束时间"
  90. class="infinite-list-item"
  91. />
  92. </el-table-column>
  93. <el-table-column
  94. prop="name"
  95. label="黑名单"
  96. class="infinite-list-item"
  97. />
  98. <el-table-column
  99. prop="name"
  100. label="白名单"
  101. class="infinite-list-item"
  102. />
  103. <el-table-column
  104. prop="name"
  105. label="描述"
  106. class="infinite-list-item"
  107. />
  108. <el-table-column
  109. v-if="tableBtnGroup.length"
  110. label="操作"
  111. :align="props.tableColumnProperty.align"
  112. >
  113. <template #default="scope">
  114. <el-button
  115. v-for="(btn, index) in tableBtnGroup"
  116. :key="index"
  117. size="small"
  118. @click="handleClick(scope.$index, scope.row, btn.param)"
  119. :class="btn.className"
  120. >{{ btn.name }}</el-button
  121. >
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <!-- <DataTable
  126. :tableHeader="state.list"
  127. :tableData="tableData"
  128. :tableBtnGroup="tableBtnGroup"
  129. :tableProperty="{ rowKey: 'ID' }"
  130. @btnClick="btnClick"
  131. /> -->
  132. </div>
  133. <Dialog
  134. width="628px"
  135. :flag="flag"
  136. :type="type"
  137. :msgTitle="msgTitle"
  138. @resetForm="resetForm"
  139. @delRest="delRest"
  140. >
  141. <div class="diacont">
  142. <el-form :model="tableForm">
  143. <el-row :gutter="24">
  144. <el-col>
  145. <el-form-item label="策略名称" size="default">
  146. <el-input
  147. v-model="tableForm.name"
  148. placeholder="请输入策略名称"
  149. />
  150. </el-form-item>
  151. </el-col>
  152. <el-col>
  153. <el-form-item label="有效日期" size="default">
  154. <el-date-picker
  155. v-model="tableForm.china"
  156. type="date"
  157. placeholder="选择日期"
  158. >
  159. </el-date-picker>
  160. <el-date-picker
  161. style="margin-left: 40px"
  162. v-model="tableForm.englin"
  163. type="date"
  164. placeholder="选择日期"
  165. >
  166. </el-date-picker>
  167. </el-form-item>
  168. </el-col>
  169. <el-col>
  170. <el-form-item label="有效时间" size="default">
  171. <el-time-select
  172. v-model="tableForm.two"
  173. :picker-options="{
  174. start: '08:30',
  175. step: '00:15',
  176. end: '18:30',
  177. }"
  178. placeholder="选择时间"
  179. >
  180. </el-time-select>
  181. <el-time-select
  182. style="margin-left: 8px"
  183. v-model="tableForm.three"
  184. :picker-options="{
  185. start: '08:30',
  186. step: '00:15',
  187. end: '18:30',
  188. }"
  189. placeholder="选择时间"
  190. >
  191. </el-time-select>
  192. </el-form-item>
  193. </el-col>
  194. <el-col>
  195. <el-form-item label="黑名单" size="default">
  196. <div class="father_box">
  197. <!-- 生成的标签 -->
  198. <div
  199. v-for="(item, index) in TagsAll"
  200. :key="index"
  201. class="spanbox"
  202. >
  203. <span class="tagspan">{{ item }}</span>
  204. <i class="span_close" @click="removeTag(index, item)"></i>
  205. </div>
  206. <!-- 输入框 -->
  207. <el-input
  208. style="width: 100%"
  209. placeholder="请输入黑名单"
  210. v-model="currentval"
  211. @keyup.enter="addTags"
  212. @keyup.delete="deleteTags"
  213. class="inputTag"
  214. ref="inputTag"
  215. type="text"
  216. />
  217. </div>
  218. </el-form-item>
  219. </el-col>
  220. <el-col>
  221. <el-form-item label="白名单" size="default">
  222. <div class="father_box">
  223. <!-- 生成的标签 -->
  224. <div
  225. v-for="(item, index) in TagsAlls"
  226. :key="index"
  227. class="spanbox"
  228. >
  229. <span class="tagspan">{{ item }}</span>
  230. <i
  231. class="span_close"
  232. @click="removeTags(index, item)"
  233. ></i>
  234. </div>
  235. <!-- 输入框 -->
  236. <el-input
  237. style="width: 100%"
  238. placeholder="请输入白名单"
  239. v-model="currentvals"
  240. @keyup.enter="addTagss"
  241. @keyup.delete="deleteTagss"
  242. class="inputTag"
  243. ref="inputTag"
  244. type="text"
  245. />
  246. </div>
  247. </el-form-item>
  248. </el-col>
  249. <el-col>
  250. <el-form-item label="描述" size="default">
  251. <el-input
  252. type="textarea"
  253. v-model="tableForm.text"
  254. placeholder="请输入描述"
  255. />
  256. </el-form-item>
  257. </el-col>
  258. </el-row>
  259. </el-form>
  260. </div>
  261. </Dialog>
  262. </div>
  263. </div>
  264. </template>
  265. <script setup lang="ts">
  266. import DataTable from "@/components/tableTemp/index.vue";
  267. import Minheader from "@/components/minheader/index.vue";
  268. import Dialog from "@/components/dialog/index.vue";
  269. const router = useRouter();
  270. const props = defineProps({
  271. //表格参数
  272. tableProperty: {
  273. type: Object,
  274. default: {
  275. height: "100%",
  276. maxHeight: "100%",
  277. stripe: true,
  278. border: true,
  279. highlightCurrentRow: false,
  280. rowClassName: "rowClass",
  281. headerRowClassName: "headerRowClass",
  282. tooltipEffect: "light",
  283. showSummary: false,
  284. rowKey: "",
  285. },
  286. },
  287. //公共表头参数
  288. tableColumnProperty: {
  289. type: Object,
  290. default: {
  291. width: "",
  292. fixed: "",
  293. sortable: false,
  294. showOverflowTooltip: false,
  295. align: "center",
  296. headerAlign: "",
  297. },
  298. },
  299. });
  300. //表格参数
  301. const tablePropertyDefault = {
  302. height: "100%",
  303. maxHeight: "100%",
  304. stripe: true,
  305. border: true,
  306. highlightCurrentRow: false,
  307. rowClassName: "rowClass",
  308. headerRowClassName: "headerRowClass",
  309. tooltipEffect: "light",
  310. showSummary: false,
  311. rowKey: "",
  312. };
  313. const flag = ref<Boolean>(false); //弹窗开关
  314. const type = ref<String>(""); //判断是否删除
  315. const TagsAll = ref<Array>([]);
  316. const currentval = ref<String>("");
  317. const TagsAlls = ref<Array>([]);
  318. const currentvals = ref<String>("");
  319. const msgTitle = ref<String>("新增登录策略"); //弹窗标题
  320. const tableColsCopys = reactive<Object>({}); //弹窗
  321. const tableForm = reactive({
  322. name: "",
  323. china: "",
  324. englin: "",
  325. two: "",
  326. three: "",
  327. text: "",
  328. }); //弹窗内容
  329. //列表
  330. const tableData = ref([
  331. {
  332. name: "中国国际航空",
  333. china: "国航",
  334. englin: "AIRCHINA",
  335. two: "CA",
  336. three: "CCA",
  337. text: "CA国航",
  338. },
  339. {
  340. name: "中国国际航空",
  341. china: "国航",
  342. englin: "AIRCHINA",
  343. two: "CA",
  344. three: "CCA",
  345. text: "CA国航",
  346. },
  347. {
  348. name: "中国国际航空",
  349. china: "国航",
  350. englin: "AIRCHINA",
  351. two: "CA",
  352. three: "CCA",
  353. text: "CA国航",
  354. },
  355. ]);
  356. //表头
  357. const state = reactive({
  358. list: [
  359. { label: "名称", key: "name" },
  360. { label: "有效日期", key: "china" },
  361. { label: "有效时间", key: "englin" },
  362. { label: "黑名单", key: "two" },
  363. { label: "白名单", key: "three" },
  364. { label: "描述", key: "text" },
  365. ],
  366. listLoading: true,
  367. });
  368. const tableBtnGroup = ref([
  369. {
  370. name: "编辑",
  371. className: "editBtn",
  372. param: 2,
  373. },
  374. {
  375. name: "删除",
  376. className: "delBtn",
  377. param: 3,
  378. },
  379. ]);
  380. //新增
  381. const addForm = () => {
  382. msgTitle.value = "新增登录策略";
  383. flag.value = true;
  384. type.value = "";
  385. };
  386. //取消
  387. const resetForm = () => {
  388. flag.value = false;
  389. tableForm.name = "";
  390. tableForm.china = "";
  391. tableForm.englin = "";
  392. tableForm.two = "";
  393. tableForm.three = "";
  394. tableForm.text = "";
  395. TagsAll.value = [];
  396. TagsAlls.value = [];
  397. };
  398. //编辑
  399. // const editDialog = (data) => {
  400. // msgTitle.value = "编辑航司信息维护";
  401. // flag.value = true;
  402. // type.value = "";
  403. // tableForm.name = data.name;
  404. // tableForm.china = data.china;
  405. // tableForm.englin = data.englin;
  406. // tableForm.two = data.two;
  407. // tableForm.three = data.three;
  408. // tableForm.text = data.text;
  409. // };
  410. //编辑-删除
  411. const btnClick = (row, index, param) => {
  412. if (param === 2) {
  413. router.push({ path: "/systemSettings/securityPolicyedit" });
  414. // msgTitle.value = "编辑登录策略";
  415. // flag.value = true;
  416. // type.value = "";
  417. // tableForm.name = index.name;
  418. // tableForm.china = index.china;
  419. // tableForm.englin = index.englin;
  420. // tableForm.two = index.two;
  421. // tableForm.three = index.three;
  422. // tableForm.text = index.text;
  423. } else if (param === 3) {
  424. msgTitle.value = "删除航司信息维护";
  425. flag.value = true;
  426. type.value = "del";
  427. } else if (param === 4) {
  428. }
  429. };
  430. //删除
  431. const eleDialog = () => {
  432. msgTitle.value = "删除登录策略";
  433. flag.value = true;
  434. type.value = "del";
  435. };
  436. //删除
  437. const delRest = () => {
  438. flag.value = false;
  439. };
  440. //按钮点击index为当前行序号 row 为当前行 param按钮类型判断参数由父组件传过来
  441. const handleClick = (index: number, row: Object, param: number) => {
  442. if (param === 2) {
  443. router.push({ path: "/systemSettings/securityPolicyedit" });
  444. } else if (param === 3) {
  445. msgTitle.value = "删除航司信息维护";
  446. flag.value = true;
  447. type.value = "del";
  448. }
  449. };
  450. //行公共样式
  451. const rowStyle = (row: Object, rowIndex: number) => {
  452. let styleJson: Object = {
  453. height: "50px",
  454. fontSize: "14px",
  455. color: "#101116",
  456. };
  457. return styleJson;
  458. };
  459. //表格行class样式 可通过父组件直接传class名称修改当前行样式
  460. const tableRowClassName = (row: Object, rowIndex: number) => {
  461. if (row.row.rowClass) {
  462. return row.row.rowClass;
  463. }
  464. return "";
  465. };
  466. //向父组件传参 btnClick:点击按钮后 load 触发下拉加载 cellClass 修改某一行class的触发条件
  467. const emit = defineEmits(["btnClick", "load", "cellClass"]);
  468. //给某一格加class
  469. const cellClass = ref("");
  470. const cellClassName = (row: Object) => {
  471. emit("cellClass", row);
  472. return cellClass.value;
  473. };
  474. const removeTag = (index) => {
  475. TagsAll.value.splice(index, 1);
  476. };
  477. const addTags = () => {
  478. if (currentval) {
  479. TagsAll.value.push(currentval.value);
  480. currentval.value = "";
  481. }
  482. };
  483. const deleteTags = () => {
  484. TagsAlls.value.pop();
  485. };
  486. const removeTags = (index) => {
  487. TagsAlls.value.splice(index, 1);
  488. };
  489. const addTagss = () => {
  490. if (currentvals) {
  491. TagsAlls.value.push(currentvals.value);
  492. currentvals.value = "";
  493. }
  494. };
  495. const deleteTagss = () => {
  496. TagsAlls.value.pop();
  497. };
  498. // const inputStyle = () => {
  499. // let style = {};
  500. // style.width = `${inputLength}px`;
  501. // return style;
  502. // };
  503. defineExpose({
  504. cellClass,
  505. });
  506. </script>
  507. <style lang="scss" scoped>
  508. ::v-deep .el-form-item__label {
  509. width: 100px;
  510. }
  511. .app-containers {
  512. height: calc(100vh - 180px);
  513. }
  514. .infinite-list {
  515. height: 300px;
  516. padding: 0;
  517. margin: 0;
  518. list-style: none;
  519. }
  520. .infinite-list .infinite-list-item {
  521. display: flex;
  522. align-items: center;
  523. justify-content: center;
  524. height: 50px;
  525. background: var(--el-color-primary-light-9);
  526. margin: 10px;
  527. color: var(--el-color-primary);
  528. }
  529. .infinite-list .infinite-list-item + .list-item {
  530. margin-top: 10px;
  531. }
  532. ::v-deep.el-table .rowClass {
  533. height: 40px;
  534. font-size: 14px;
  535. color: #101116;
  536. }
  537. ::v-deep.el-table .headerRowClass {
  538. height: 40px;
  539. background: #ffffff;
  540. font-size: 14px;
  541. font-weight: bold;
  542. color: #101116;
  543. }
  544. ::v-deep.el-table .editBtn {
  545. background: #ffffff;
  546. border: 1px solid #f79ec6;
  547. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  548. border-radius: 4px;
  549. font-size: 12px;
  550. font-weight: 400;
  551. color: #ac014d;
  552. }
  553. ::v-deep.el-table .delBtn {
  554. background: #eb2f3b;
  555. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.06);
  556. border-radius: 4px;
  557. font-size: 12px;
  558. font-weight: 400;
  559. color: #ffffff;
  560. border: none;
  561. }
  562. ::v-deep.el-table--striped
  563. .el-table__body
  564. tr.el-table__row--striped
  565. td.el-table__cell {
  566. background-color: #f0f3f7;
  567. }
  568. ::v-deep.el-table thead.is-group th.el-table__cell {
  569. background: #fff;
  570. }
  571. .father_box {
  572. width: 100%;
  573. /* width: 300px; */
  574. box-sizing: border-box;
  575. background-color: white;
  576. border: 1px solid #dcdee2;
  577. border-radius: 4px;
  578. font-size: 12px;
  579. text-align: left;
  580. padding-left: 5px;
  581. word-wrap: break-word;
  582. overflow: hidden;
  583. }
  584. /* 标签 */
  585. .spanbox {
  586. display: inline-block;
  587. font-size: 14px;
  588. margin: 0px 4px 0px 0;
  589. // background-color: rgb(229, 229, 229);
  590. border: 1px solid #e8eaec;
  591. border-radius: 3px;
  592. }
  593. .tagspan {
  594. height: 24px;
  595. line-height: 22px;
  596. max-width: 99%;
  597. position: relative;
  598. display: inline-block;
  599. padding-left: 8px;
  600. color: #495060;
  601. font-size: 14px;
  602. cursor: pointer;
  603. opacity: 1;
  604. vertical-align: middle;
  605. overflow: hidden;
  606. transition: 0.25s linear;
  607. color: rgb(26, 26, 26);
  608. font-weight: 600;
  609. }
  610. .span_close {
  611. padding: 0 4px 0 4px;
  612. opacity: 1;
  613. -webkit-filter: none;
  614. filter: none;
  615. color: rgb(26, 26, 26);
  616. font-weight: 600;
  617. }
  618. .span_close:after {
  619. content: "\00D7";
  620. -webkit-font-smoothing: antialiased;
  621. -moz-osx-font-smoothing: grayscale;
  622. /* line-height: 27px; */
  623. transition: 0.3s, color 0s;
  624. }
  625. /* input */
  626. .inputTag {
  627. font-size: 16px;
  628. border: none;
  629. box-shadow: none;
  630. outline: none;
  631. background-color: transparent;
  632. padding: 0;
  633. width: auto;
  634. min-width: 250px;
  635. vertical-align: top;
  636. height: 32px;
  637. color: #495060;
  638. line-height: 32px;
  639. }
  640. </style>