index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <template>
  2. <div class="inform">
  3. <el-card class="box-card" style="width: 1612px; height: 950px">
  4. <div slot="header" class="clearfix">
  5. <div class="inform-title">员工管理</div>
  6. </div>
  7. <div class="inform-body">
  8. <div class="order-top">
  9. <div class="username-inquire">
  10. <el-input
  11. placeholder="请输入手机号码或员工姓名"
  12. style="width: 261px"
  13. v-model="value"
  14. >
  15. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  16. </el-input>
  17. <el-button @click="inquire">查询</el-button>
  18. </div>
  19. <div class="export" @click="addStaff">添加员工</div>
  20. <el-dialog
  21. title="添加员工"
  22. :visible.sync="addStaffShow"
  23. :before-close="addClose"
  24. >
  25. <div class="info">
  26. <div class="user">
  27. <div class="name">员工姓名</div>
  28. <el-input v-model="staffValue"></el-input>
  29. </div>
  30. <div class="user">
  31. <div class="name">手机号码</div>
  32. <el-input v-model="phoneValue"></el-input>
  33. </div>
  34. </div>
  35. <div class="info">
  36. <div class="user">
  37. <div class="name">职位</div>
  38. <el-select v-model="position" placeholder="请选择">
  39. <el-option
  40. v-for="item in options"
  41. :key="item.value"
  42. :label="item.label"
  43. :value="item.label"
  44. >
  45. </el-option>
  46. </el-select>
  47. </div>
  48. </div>
  49. <span slot="footer" class="dialog-footer">
  50. <el-button @click.stop="addStaffShow = false" class="cancel"
  51. >取消</el-button
  52. >
  53. <el-button @click.stop="addSuccess">完成</el-button>
  54. </span>
  55. </el-dialog>
  56. </div>
  57. <div class="inform-table">
  58. <el-table
  59. :data="tableData"
  60. max-height="576"
  61. height="576"
  62. style="width: 1550px"
  63. stripe
  64. :cell-style="rowbg"
  65. :header-cell-style="{
  66. color: ' rgba(0, 0, 0, 1)',
  67. background: 'rgba(240, 243, 247, 1)',
  68. }"
  69. >
  70. <el-table-column
  71. prop="phone"
  72. width="300"
  73. label="手机号码"
  74. align="center"
  75. >
  76. </el-table-column>
  77. <el-table-column prop="username" align="center" label="员工姓名">
  78. </el-table-column>
  79. <el-table-column prop="position" align="center" label="职位">
  80. </el-table-column>
  81. <el-table-column prop="address" align="center" label="操作">
  82. <template slot-scope="scope">
  83. <span
  84. @click="handleEdit(scope.$index, scope.row)"
  85. class="operate"
  86. >
  87. 编辑
  88. </span>
  89. <el-dialog
  90. title="编辑员工"
  91. :visible.sync="editShow"
  92. :before-close="editClose"
  93. >
  94. <div class="info">
  95. <div class="user">
  96. <div class="name">员工姓名</div>
  97. <el-input v-model="staffValue"></el-input>
  98. </div>
  99. <div class="user">
  100. <div class="name">手机号码</div>
  101. <el-input v-model="phoneValue"></el-input>
  102. </div>
  103. </div>
  104. <div class="info">
  105. <div class="user">
  106. <div class="name">职位</div>
  107. <el-select v-model="position" placeholder="请选择">
  108. <el-option
  109. v-for="item in options"
  110. :key="item.value"
  111. :label="item.label"
  112. :value="item.label"
  113. >
  114. </el-option>
  115. </el-select>
  116. </div>
  117. </div>
  118. <span slot="footer" class="dialog-footer">
  119. <el-button @click.stop="editCancel()" class="cancel"
  120. >取消</el-button
  121. >
  122. <el-button @click.stop="editSuccess()">完成</el-button>
  123. </span>
  124. </el-dialog>
  125. <span
  126. @click="handleDelete(scope.$index, scope.row)"
  127. class="operate"
  128. >
  129. 删除
  130. </span>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. </div>
  135. <div class="block">
  136. <el-pagination
  137. background
  138. @current-change="handleCurrentChange"
  139. :current-page="currentPage"
  140. current-page.sync="1"
  141. :page-size="8"
  142. layout="prev, pager, next, jumper"
  143. :total="data.length"
  144. >
  145. </el-pagination>
  146. </div>
  147. </div>
  148. </el-card>
  149. </div>
  150. </template>
  151. <script>
  152. import Cookies from "js-cookie";
  153. import * as rsa from "@/utils/rsa";
  154. export default {
  155. name: "Inform",
  156. data() {
  157. return {
  158. //总数据
  159. data: [],
  160. datas: [],
  161. // 当前页显示的数据
  162. tableData: [],
  163. options: [
  164. {
  165. value: "选项1",
  166. label: "歌星1",
  167. },
  168. {
  169. value: "选项2",
  170. label: "歌星2",
  171. },
  172. {
  173. value: "选项3",
  174. label: "歌星3",
  175. },
  176. {
  177. value: "选项4",
  178. label: "歌星4",
  179. },
  180. {
  181. value: "选项5",
  182. label: "歌星5",
  183. },
  184. ],
  185. currentPage: 1,
  186. state: "",
  187. value: "", //请输入手机号码或员工姓名
  188. // 添加员工
  189. staffValue: "",
  190. phoneValue: "", // 当前的号码
  191. position: "",
  192. phoneVal: "", // 修改前的号码
  193. dialogVisible: false,
  194. waterTable: [
  195. {
  196. start: 36,
  197. end: 36,
  198. flow: 20,
  199. pirce: 2.0,
  200. subsidy: 5,
  201. production: 2,
  202. },
  203. ],
  204. addStaffShow: false,
  205. editShow: false,
  206. };
  207. },
  208. mounted() {
  209. document.getElementsByClassName(
  210. "el-pagination__jump"
  211. )[0].childNodes[0].nodeValue = "跳转到";
  212. let cook = Cookies.get("cook");
  213. this.API.hotelStaff.hotelStaffList(cook).then((res) => {
  214. this.data = res.data.list;
  215. this.datas = JSON.parse(JSON.stringify(this.data));
  216. this.handleCurrentChange(this.currentPage);
  217. });
  218. },
  219. methods: {
  220. allRead($event, index) {
  221. this.className = this.className.map((item) => (item = ""));
  222. this.className[index] = "active";
  223. },
  224. rowbg(row) {
  225. if (row.rowIndex % 2 != 0) {
  226. return { background: "rgba(240, 243, 247, 1)", "border-radius": "5px" };
  227. }
  228. },
  229. handleCurrentChange(val) {
  230. if (this.data.length >= 8) {
  231. this.tableData = this.data.slice((val - 1) * 8, val * 8);
  232. } else {
  233. this.tableData = this.data;
  234. }
  235. this.currentPage = val;
  236. // console.log(`当前页: ${val}`);
  237. },
  238. // 表格操作
  239. handleDelete(index, row) {
  240. this.$confirm("确认删除?")
  241. .then((res) => {
  242. if (res == "confirm") {
  243. this.data = this.data.filter((item) => {
  244. return item.phone !== row.phone && item.username !== row.username;
  245. });
  246. this.datas = this.datas.filter((item) => {
  247. return item.phone !== row.phone && item.username !== row.username;
  248. });
  249. }
  250. if (this.tableData.length <= 1) {
  251. if (this.currentPage == 1) {
  252. this.currentPage = 1;
  253. } else {
  254. this.currentPage = this.currentPage - 1;
  255. }
  256. }
  257. this.handleCurrentChange(this.currentPage);
  258. })
  259. .catch((_) => {});
  260. console.log(this.datas);
  261. },
  262. handleClose(done) {
  263. this.dialogVisible = false;
  264. },
  265. // 查询
  266. inquire() {
  267. this.data = [];
  268. if (this.value === "") {
  269. this.data = JSON.parse(JSON.stringify(this.datas));
  270. } else {
  271. this.datas.forEach((item, index) => {
  272. if (
  273. item.phone.toString().includes(this.value) ||
  274. item.username.includes(this.value)
  275. ) {
  276. this.data.push(item);
  277. }
  278. });
  279. }
  280. this.currentPage = 1;
  281. this.handleCurrentChange(this.currentPage);
  282. },
  283. // 添加员工
  284. addStaff() {
  285. this.addStaffShow = true;
  286. },
  287. addClose(done) {
  288. this.$confirm("确认关闭?")
  289. .then((_) => {
  290. done();
  291. })
  292. .catch((_) => {});
  293. },
  294. addSuccess() {
  295. let reg_tel =
  296. /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
  297. if (reg_tel.test(this.phoneValue)) {
  298. // console.log("电话号码符合要求");
  299. let RepeatNumber = this.datas.some((item) => {
  300. return item.phone == this.phoneValue;
  301. });
  302. if (RepeatNumber) {
  303. this.$message({
  304. message: "当前电话号码已存在,请换个号码输入",
  305. type: "error",
  306. });
  307. } else if (this.staffValue.trim() == "") {
  308. this.$message({ message: "输入的姓名不能为空", type: "error" });
  309. } else if (this.position == "") {
  310. this.$message({ message: "职位不能为空", type: "error" });
  311. } else {
  312. let arr = {
  313. phone: this.phoneValue,
  314. username: this.staffValue,
  315. position: this.position,
  316. cardNumber: "1nqc87",
  317. password: rsa.RSAencrypt("abc1234"),
  318. statu: "1",
  319. };
  320. // console.log(this.position);
  321. this.API.hotelStaff.hotelStaffAdd(arr);
  322. this.data = this.datas;
  323. this.currentPage = Math.ceil(this.data.length / 8);
  324. this.handleCurrentChange(this.currentPage);
  325. this.addStaffShow = false;
  326. this.phoneValue = "";
  327. this.staffValue = "";
  328. this.position = "";
  329. }
  330. } else {
  331. this.$message({ message: "请输入正确的电话号码", type: "error" });
  332. }
  333. },
  334. // 编辑员工
  335. editClose() {
  336. this.$confirm("确认关闭?")
  337. .then((_) => {
  338. this.editShow = false;
  339. this.phoneValue = "";
  340. this.staffValue = "";
  341. this.position = "";
  342. })
  343. .catch((_) => {});
  344. },
  345. editCancel() {
  346. this.editShow = false;
  347. this.phoneValue = "";
  348. this.staffValue = "";
  349. this.position = "";
  350. },
  351. handleEdit(index, row) {
  352. // console.log(row);
  353. this.editShow = true;
  354. this.phoneValue = row.phone;
  355. this.phoneVal = row.phone;
  356. this.staffValue = row.username;
  357. this.position = row.position;
  358. },
  359. editSuccess() {
  360. let reg_tel =
  361. /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
  362. let arrEdit = this.datas.filter((item) => {
  363. return item.phone != this.phoneVal;
  364. });
  365. let editIndex = this.datas.findIndex((item) => {
  366. return item.phone == this.phoneVal;
  367. });
  368. let RepeatNumber = arrEdit.some((item) => {
  369. return item.phone == this.phoneValue;
  370. });
  371. if (RepeatNumber) {
  372. this.$message({
  373. message: "当前电话号码已存在,请换个号码输入",
  374. type: "error",
  375. });
  376. } else if (this.staffValue.trim() == "") {
  377. this.$message({ message: "输入的姓名不能为空", type: "error" });
  378. } else if (this.position == "") {
  379. this.$message({ message: "职位不能为空", type: "error" });
  380. } else {
  381. if (reg_tel.test(this.phoneValue)) {
  382. // console.log("电话号码符合要求");
  383. let arr = {
  384. phone: this.phoneValue,
  385. username: this.staffValue,
  386. position: this.position,
  387. };
  388. this.datas[editIndex] = arr;
  389. this.data = this.datas;
  390. this.handleCurrentChange(this.currentPage);
  391. this.editShow = false;
  392. this.phoneValue = "";
  393. this.staffValue = "";
  394. this.position = "";
  395. } else {
  396. this.$message({ message: "请输入正确的电话号码", type: "error" });
  397. }
  398. }
  399. },
  400. },
  401. };
  402. </script>
  403. <style lang="scss" scoped>
  404. .inform /deep/ .el-card {
  405. width: 1612px;
  406. height: 950px;
  407. box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);
  408. border-radius: 8px;
  409. .clearfix {
  410. height: 96px;
  411. width: 100%;
  412. border-bottom: 1px solid rgba(204, 204, 204, 1);
  413. box-sizing: border-box;
  414. display: flex;
  415. justify-content: space-between;
  416. align-items: center;
  417. .inform-title {
  418. width: 96px;
  419. height: 36px;
  420. color: rgba(0, 0, 0, 1);
  421. font-size: 24px;
  422. font-weight: 500;
  423. margin-left: 33px;
  424. }
  425. .inform-header {
  426. display: flex;
  427. margin-right: 29px;
  428. .el-button {
  429. margin-left: 9px;
  430. background-color: rgba(41, 109, 227, 1);
  431. }
  432. }
  433. }
  434. .inform-body {
  435. .order-top {
  436. display: flex;
  437. align-items: center;
  438. padding: 33px 29px 34px 33px;
  439. font-size: 16px;
  440. justify-content: space-between;
  441. font-weight: 400;
  442. color: #000;
  443. .el-button {
  444. background-color: rgba(41, 109, 227, 1);
  445. color: #fff;
  446. margin-left: 9px;
  447. }
  448. .state {
  449. margin-left: 30px;
  450. }
  451. .export {
  452. width: 94px;
  453. height: 32px;
  454. opacity: 1;
  455. color: #fff;
  456. text-align: center;
  457. line-height: 32px;
  458. background: rgba(41, 109, 227, 1);
  459. cursor: pointer;
  460. border-radius: 3px;
  461. }
  462. .el-dialog__wrapper {
  463. .el-dialog {
  464. width: 555px !important;
  465. height: 377px !important;
  466. margin-top: 352px !important;
  467. .el-dialog__header {
  468. height: 80px;
  469. padding: 0;
  470. display: flex;
  471. align-items: center;
  472. border-bottom: 1px solid rgba(230, 230, 230, 1);
  473. .el-dialog__title {
  474. font-size: 20px;
  475. font-weight: 500;
  476. padding-left: 30px;
  477. color: rgba(0, 0, 0, 1);
  478. }
  479. .el-dialog__headerbtn {
  480. width: 35px;
  481. height: 35px;
  482. .el-dialog__close {
  483. font-size: 28px;
  484. font-weight: 500;
  485. color: #000;
  486. }
  487. }
  488. }
  489. .el-dialog__body {
  490. padding: 0 30px;
  491. .info {
  492. display: flex;
  493. .user {
  494. .name {
  495. text-align: left;
  496. padding: 12px 0;
  497. }
  498. .el-input {
  499. width: 205px;
  500. height: 38px;
  501. opacity: 1;
  502. margin-right: 81px;
  503. .el-input__inner {
  504. color: #000;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. .el-dialog__footer {
  511. padding: 52px 30px 0 0;
  512. .el-button {
  513. width: 67px;
  514. height: 37px;
  515. padding: 0;
  516. }
  517. .cancel {
  518. background-color: #fff;
  519. color: rgba(56, 56, 56, 1);
  520. }
  521. }
  522. }
  523. }
  524. }
  525. .inform-table {
  526. .el-table {
  527. font-weight: 400;
  528. font-size: 16px;
  529. color: rgba(0, 0, 0, 1);
  530. margin: 0 auto;
  531. .el-table__header-wrapper {
  532. border-radius: 5px;
  533. }
  534. tr {
  535. height: 64px;
  536. td {
  537. .cell {
  538. .operate {
  539. color: rgba(41, 109, 227, 1);
  540. cursor: pointer;
  541. font-size: 16px;
  542. font-weight: 400;
  543. padding: 0 5px;
  544. }
  545. .el-dialog__wrapper {
  546. overflow: hidden;
  547. .el-dialog {
  548. width: 555px !important;
  549. height: 377px !important;
  550. margin-top: 352px !important;
  551. opacity: 1;
  552. background: rgba(255, 255, 255, 1);
  553. box-shadow: none;
  554. .el-dialog__header {
  555. height: 83px;
  556. border-bottom: 1px solid rgba(230, 230, 230, 1);
  557. .el-dialog__headerbtn {
  558. top: 29px;
  559. }
  560. span {
  561. float: left;
  562. font-size: 20px;
  563. font-weight: 500;
  564. color: #000;
  565. }
  566. .el-dialog__close {
  567. width: 35px;
  568. height: 35px;
  569. &::before {
  570. font-size: 24px;
  571. color: #000;
  572. }
  573. }
  574. }
  575. .el-dialog__body {
  576. padding: 0 38px;
  577. .userinfo {
  578. font-size: 20px;
  579. font-weight: 500;
  580. color: rgba(0, 0, 0, 1);
  581. text-align: left;
  582. margin-top: 15px;
  583. }
  584. .info {
  585. display: flex;
  586. .user {
  587. .name {
  588. text-align: left;
  589. padding: 12px 0;
  590. }
  591. .el-input {
  592. width: 205px;
  593. height: 38px;
  594. opacity: 1;
  595. margin-right: 81px;
  596. .el-input__inner {
  597. color: #000;
  598. }
  599. }
  600. }
  601. }
  602. .rate {
  603. font-size: 20px;
  604. font-weight: 500;
  605. color: rgba(0, 0, 0, 1);
  606. text-align: left;
  607. margin: 15px 0;
  608. }
  609. .water {
  610. text-align: left;
  611. font-size: 16px;
  612. font-weight: 400;
  613. color: rgba(0, 0, 0, 1);
  614. }
  615. .el-table {
  616. margin: 10px 0;
  617. tr {
  618. height: 48px;
  619. }
  620. .el-table__body-wrapper {
  621. overflow: visible;
  622. }
  623. }
  624. }
  625. .el-dialog__footer {
  626. padding: 52px 30px 0 0;
  627. .el-button {
  628. width: 67px;
  629. height: 37px;
  630. padding: 0;
  631. color: #fff;
  632. background-color: rgba(41, 109, 227, 1);
  633. }
  634. .cancel {
  635. background-color: #fff;
  636. color: rgba(56, 56, 56, 1);
  637. }
  638. }
  639. }
  640. }
  641. .el-dialog__title {
  642. color: rgba(41, 109, 227, 1);
  643. cursor: pointer;
  644. padding: 10px 18px 0 18px;
  645. }
  646. }
  647. }
  648. .el-checkbox__inner {
  649. width: 18px;
  650. height: 18px;
  651. &::after {
  652. transform: rotate(45deg) scaleY(1.5);
  653. top: 3px;
  654. left: 5px;
  655. }
  656. }
  657. }
  658. th {
  659. font-weight: 400;
  660. }
  661. }
  662. }
  663. .block {
  664. height: 36px;
  665. margin: 66px 29px 0 0;
  666. float: right;
  667. .el-pagination {
  668. padding: 0;
  669. button {
  670. width: 36px;
  671. background: #fff;
  672. color: rgba(0, 0, 0, 1);
  673. height: 36px;
  674. font-size: 14px;
  675. border: 1px solid rgba(112, 112, 112, 1);
  676. border-radius: 8px;
  677. }
  678. ul {
  679. .active {
  680. background: #fff;
  681. color: rgba(0, 97, 255, 1);
  682. border: 1px solid rgba(0, 97, 255, 1);
  683. box-sizing: border-box;
  684. }
  685. .el-icon {
  686. border: none;
  687. }
  688. li {
  689. background: #fff;
  690. color: rgba(0, 0, 0, 1);
  691. width: 36px;
  692. height: 36px;
  693. font-size: 14px;
  694. border: 1px solid rgba(112, 112, 112, 1);
  695. border-radius: 8px;
  696. line-height: 36px;
  697. }
  698. }
  699. .el-pagination__jump {
  700. color: rgba(0, 0, 0, 1);
  701. font-size: 16px;
  702. margin-left: 10px;
  703. font-weight: 400;
  704. height: 36px;
  705. .el-input {
  706. width: 65px;
  707. height: 36px;
  708. margin: 0 10px;
  709. input {
  710. width: 65px;
  711. height: 36px;
  712. border: 1px solid rgba(0, 0, 0, 1);
  713. border-radius: 8px;
  714. }
  715. }
  716. }
  717. }
  718. }
  719. }
  720. }
  721. .box-card {
  722. /deep/ .el-card__header {
  723. padding: 0;
  724. }
  725. /deep/ .el-card__body {
  726. padding: 0;
  727. }
  728. }
  729. </style>
  730. <style lang="scss">
  731. .el-message-box__wrapper {
  732. .el-button--primary {
  733. background-color: #296de3 !important;
  734. }
  735. }
  736. </style>