role.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. <template>
  2. <div class="content-box">
  3. <div class="left">
  4. <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
  5. <span class="cameratxt">角色管理</span>
  6. </div>
  7. <div class="middle">
  8. <div class="filter">
  9. <div class="condition">
  10. <span>角色名称 </span>
  11. <el-input
  12. clearable
  13. v-model="searchInput.name"
  14. @clear="searchBtn"
  15. class="w-50 m-2"
  16. placeholder="请输入角色名称"
  17. style="width: 250px"
  18. />
  19. </div>
  20. <div class="condition">
  21. <span>创建时间 </span>
  22. <el-date-picker
  23. v-model="searchInput.createTime"
  24. type="daterange"
  25. unlink-panels
  26. range-separator="-"
  27. start-placeholder="起始时间"
  28. end-placeholder="截止时间"
  29. format="YYYY-MM-DD"
  30. value-format="YYYY-MM-DD"
  31. :prefix-icon="Calendar"
  32. placeholder="请选择日期"
  33. style="width: 280px"
  34. @change="searchBtn"
  35. />
  36. </div>
  37. <el-button
  38. style="margin-left: 20px"
  39. type="primary"
  40. class="search"
  41. @click="searchBtn"
  42. >查询</el-button
  43. >
  44. <el-button
  45. style="margin-left: 20px"
  46. class="reset"
  47. @click="resetSearchBtn"
  48. >重置</el-button
  49. >
  50. </div>
  51. <!-- 按钮列表 -->
  52. <div class="gongneng">
  53. <el-button @click="addProjectbtn" class="add"
  54. ><el-icon> <CirclePlus /> </el-icon><span>创建角色</span></el-button
  55. >
  56. <el-button @click="projectImportBtn" class="imp"
  57. ><el-icon><Upload /></el-icon><span>批量导入</span></el-button
  58. >
  59. <!-- <el-button @click="projectExportBtn" class="add"
  60. ><el-icon><Download /></el-icon><span>项目导出</span></el-button
  61. > -->
  62. </div>
  63. </div>
  64. <div class="scroll">
  65. <div class="footer" v-loading="loading">
  66. <el-table
  67. :row-class-name="tableRowClassName"
  68. :data="tableData.list"
  69. @selection-change="handleSelectionChange"
  70. style="width: 100%"
  71. :header-cell-style="{
  72. background: 'rgba(240, 243, 247, 1)',
  73. height: '50px',
  74. border: 0,
  75. }"
  76. >
  77. <!-- <el-table-column type="selection" width="55" /> -->
  78. <el-table-column align="center" prop="createTime" label="序号" />
  79. <el-table-column align="center" prop="createTime" label="角色级别" />
  80. <el-table-column align="center" prop="createUser" label="父级角色" />
  81. <el-table-column align="center" prop="createUser" label="角色名称" />
  82. <el-table-column align="center" prop="createTime" label="创建时间" />
  83. <el-table-column align="center" label="操作" width="220">
  84. <template #default="scope">
  85. <div class="options">
  86. <div class="reset" @click="reset(scope.row)">添加</div>
  87. <div class="look" @click="edit(scope.row)">编辑</div>
  88. <el-popconfirm
  89. width="220"
  90. confirm-button-text="确认"
  91. cancel-button-text="取消"
  92. :icon="InfoFilled"
  93. icon-color="#f89626"
  94. title="是否删除此数据?"
  95. @confirm="del(scope.row)"
  96. @cancel="cancelEvent"
  97. >
  98. <template #reference>
  99. <div class="del">删除</div>
  100. </template>
  101. </el-popconfirm>
  102. </div>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <!-- 新增账号 -->
  107. <el-dialog
  108. class="account"
  109. v-model="accountVisible"
  110. :close-on-click-modal="false"
  111. :close-on-press-escape="false"
  112. :title="accountTitle"
  113. align-center
  114. width="600"
  115. :before-close="cancelAccount"
  116. >
  117. <el-form
  118. ref="accountRef"
  119. :model="accountRuleForm"
  120. :rules="accountRules"
  121. class="demo-ruleForm"
  122. label-width="80px"
  123. :size="formSize"
  124. label-position="right"
  125. status-icon
  126. >
  127. <el-form-item label="角色" prop="role">
  128. <el-select
  129. v-model="accountRuleForm.role"
  130. placeholder="请选择"
  131. style="width: 220px"
  132. @change="roleChange"
  133. :disabled="roleId == 2 || roleId == 3 || roleId == 4"
  134. >
  135. <el-option
  136. v-for="item in roleData"
  137. :key="item.id"
  138. :label="item.name"
  139. :value="item.id"
  140. />
  141. </el-select>
  142. </el-form-item>
  143. <el-form-item label="用户名" prop="user">
  144. <el-input
  145. v-model="accountRuleForm.user"
  146. placeholder="建设单位可填写单位名称"
  147. clearable
  148. style="width: 220px"
  149. />
  150. </el-form-item>
  151. <!-- <span class="resetPassword"
  152. >注:建设单位时用户名可填写单位名称</span
  153. > -->
  154. <el-form-item label="联系人" prop="">
  155. <el-input
  156. v-model="accountRuleForm.contacts"
  157. placeholder="请输入联系人"
  158. clearable
  159. />
  160. </el-form-item>
  161. <el-form-item label="联系电话" prop="">
  162. <el-input
  163. v-model="accountRuleForm.phone"
  164. placeholder="请输入联系电话"
  165. clearable
  166. />
  167. </el-form-item>
  168. <el-form-item label="账号" prop="account">
  169. <el-input
  170. v-model="accountRuleForm.account"
  171. placeholder="请输入账号"
  172. clearable
  173. />
  174. </el-form-item>
  175. <span class="resetPassword"
  176. >注:新增账号统一默认密码为JXSJG_123</span
  177. >
  178. <el-form-item class="options">
  179. <el-button
  180. class="queding"
  181. type="primary"
  182. @click="confirmAccount(accountRef)"
  183. >
  184. &nbsp;&nbsp;确认&nbsp;&nbsp;
  185. </el-button>
  186. <el-button class="quxiao" @click="cancelAccount"
  187. >&nbsp;&nbsp;取消&nbsp;&nbsp;</el-button
  188. >
  189. </el-form-item>
  190. </el-form>
  191. </el-dialog>
  192. <!-- 项目导入 -->
  193. <el-dialog
  194. class="projectImport"
  195. v-model="projectImportVisible"
  196. :close-on-click-modal="false"
  197. :close-on-press-escape="false"
  198. title="项目导入"
  199. align-center
  200. width="600"
  201. :before-close="cancelProjectImport"
  202. >
  203. <p class="title">当前只支持项目类型为“非装配式建筑项目”的项目导入</p>
  204. <p class="down">
  205. <span>非装配式建筑项目导入模板</span
  206. ><span @click="templateDown">模板下载</span>
  207. </p>
  208. <el-upload
  209. class="avatar-uploader"
  210. action="#"
  211. :auto-upload="false"
  212. :on-remove="projectImportRemove"
  213. :on-change="projectImportChange"
  214. :before-upload="beforeAvatarProImport"
  215. ref="projectRef"
  216. :limit="1"
  217. :on-exceed="projectImportExceed"
  218. >
  219. <template #trigger>
  220. <el-button class="queding" type="primary">
  221. &nbsp;&nbsp;导入项目&nbsp;&nbsp;
  222. </el-button>
  223. </template>
  224. </el-upload>
  225. <div class="options">
  226. <el-button
  227. color="rgba(9, 101, 98, 1)"
  228. class="queding"
  229. type="primary"
  230. @click="projectImportConfirm(projectRef)"
  231. >
  232. &nbsp;&nbsp;确认导入&nbsp;&nbsp;
  233. </el-button>
  234. <el-button @click="cancelProjectImport"
  235. >&nbsp;&nbsp;取消导入&nbsp;&nbsp;</el-button
  236. >
  237. </div>
  238. </el-dialog>
  239. </div>
  240. <!-- 分页组件 -->
  241. <el-pagination
  242. background
  243. v-model:current-page="currentPage"
  244. v-model:page-size="pageSize"
  245. :page-sizes="[10, 20, 30, 40]"
  246. layout="total,sizes, prev, pager, next, jumper, slot"
  247. :total="total"
  248. @size-change="handleSizeChange"
  249. @current-change="handleCurrentChange"
  250. />
  251. </div>
  252. </div>
  253. </template>
  254. <script setup>
  255. import {
  256. ref,
  257. reactive,
  258. nextTick,
  259. onMounted,
  260. watch,
  261. onBeforeMount,
  262. onUnmounted,
  263. } from "vue";
  264. import COS from "cos-js-sdk-v5";
  265. import { useRouter } from "vue-router";
  266. import { genFileId, ElMessage, ElMessageBox } from "element-plus";
  267. import { Calendar } from "@element-plus/icons-vue";
  268. import { dayjs } from "element-plus";
  269. import lodash, { reduce } from "lodash";
  270. import axios from "axios";
  271. import { useStore } from "vuex";
  272. const store = useStore();
  273. const router = useRouter();
  274. const tableData = reactive({
  275. list: [{}],
  276. });
  277. const searchInput = reactive({
  278. name: "", // 项目名称
  279. createTime: "", // 创建时间
  280. }); // 搜索按钮数据
  281. const currentPage = ref(1); // 当前页
  282. const pageSize = ref(10);
  283. const total = ref(40); // 当前总数
  284. const selectData = reactive({
  285. list: [],
  286. }); // 多选框选择的数据
  287. const api = ref("");
  288. // 新增账号 (--------------------------------------------------------)
  289. const accountVisible = ref(false);
  290. const accountTitle = ref();
  291. const accountRef = ref();
  292. const accountRuleForm = reactive({
  293. role: "", // 角色
  294. user: "", // 用户名
  295. contacts: "", // 联系人
  296. phone: "", // 联系电话
  297. account: "", // 账号
  298. id: "",
  299. });
  300. // 新增账号表单验证
  301. const accountRules = reactive({
  302. role: [{ required: true, message: "角色不能为空", trigger: "blur" }],
  303. user: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
  304. account: [{ required: true, message: "账号不能为空", trigger: "blur" }],
  305. });
  306. // 项目导入
  307. const projectImportVisible = ref(false);
  308. const projectRef = ref();
  309. const projectFile = ref();
  310. // 获取账户列表
  311. const getList = async () => {
  312. loading.value = true;
  313. let data = {
  314. currentPage: currentPage.value, // 当前页
  315. pageCount: pageSize.value, // 一页数据条数
  316. projectName: searchInput.name,
  317. pageType: 1,
  318. permitNum: searchInput.LicenseCode, // 施工许可证编码
  319. projectUnit: searchInput.unit, // 建设单位
  320. projectPurpose: searchInput.purpose, // 项目用途
  321. structureType: searchInput.structureType, // 结构类型
  322. projectType: searchInput.projectType, // 项目类型
  323. };
  324. if (searchInput.createTime) {
  325. data.startDate = searchInput.createTime[0];
  326. data.endDate = searchInput.createTime[1];
  327. }
  328. let res = await axios({
  329. method: "get",
  330. url: api.value + "/jgcloudProject/queryPageJgcloudProject",
  331. headers: {
  332. token: sessionStorage.getItem("token"),
  333. user_head: sessionStorage.getItem("userhead"),
  334. },
  335. params: data,
  336. });
  337. console.log(res, "项目分页数据");
  338. if (res.data.code == 200) {
  339. tableData.list = res.data.data.list;
  340. total.value = res.data.data.totalCount;
  341. loading.value = false;
  342. } else {
  343. loading.value = false;
  344. ElMessage({
  345. type: "error",
  346. showClose: true,
  347. message: res.data.message,
  348. center: true,
  349. });
  350. }
  351. };
  352. // 搜索功能
  353. const searchBtn = lodash.debounce(async () => {
  354. getList();
  355. }, 300);
  356. // 角色新增
  357. const addProjectbtn = () => {
  358. accountVisible.value = true;
  359. accountTitle.value = "角色新增";
  360. };
  361. // 取消角色新增
  362. const cancelAccount = () => {
  363. accountVisible.value = false;
  364. accountRef.value.resetFields();
  365. };
  366. //编辑项目
  367. const edit = (row) => {
  368. accountVisible.value = true;
  369. accountTitle.value = "角色编辑";
  370. console.log(row);
  371. };
  372. // 删除pdf文件 (装配式相关附件)
  373. const pdfDel = (value, uid) => {};
  374. // 导入项目
  375. const projectImportConfirm = async () => {
  376. let data = new FormData();
  377. data.set("file", projectFile.value);
  378. data.set("pageType", 1);
  379. let res = await axios({
  380. method: "POST",
  381. url: api.value + "/jgcloudProject/importExcelProject",
  382. headers: {
  383. token: sessionStorage.getItem("token"),
  384. user_head: sessionStorage.getItem("userhead"),
  385. },
  386. data: data,
  387. });
  388. console.log(res, "导入项目");
  389. if (res.data.code == 200) {
  390. projectImportVisible.value = false;
  391. getList();
  392. if (projectRef.value) {
  393. projectRef.value.clearFiles();
  394. }
  395. ElMessage({
  396. type: "success",
  397. showClose: true,
  398. message: res.data.message,
  399. center: true,
  400. });
  401. } else {
  402. ElMessage({
  403. type: "error",
  404. showClose: true,
  405. message: res.data.message,
  406. center: true,
  407. });
  408. }
  409. };
  410. const cancelProjectImport = () => {
  411. projectRef.value.clearFiles();
  412. projectImportVisible.value = false;
  413. };
  414. // (--------------------------------------------------)
  415. // cos桶中地址栏中中文地址乱码转换为中文
  416. const pdfName = (value) => {
  417. // console.log(decodeURIComponent(value));
  418. // console.log(decodeURIComponent(value).length);
  419. let index = decodeURIComponent(value).lastIndexOf("/") + 1;
  420. let name = decodeURIComponent(value).slice(index, value.length);
  421. console.log(name);
  422. return name;
  423. };
  424. // 多选框功能
  425. const handleSelectionChange = (val) => {
  426. console.log(val);
  427. selectData.list = val;
  428. };
  429. // 表格斑马纹颜色修改
  430. const tableRowClassName = ({ row, rowIndex }) => {
  431. if (rowIndex % 2 === 0) {
  432. return "even";
  433. } else if (rowIndex % 2 !== 0) {
  434. return "odd";
  435. }
  436. return "";
  437. };
  438. // 每页显示条数
  439. const handleSizeChange = (value) => {
  440. console.log(value, "每页显示条数");
  441. pageSize.value = value;
  442. getList();
  443. };
  444. // 分页
  445. const handleCurrentChange = (value) => {
  446. console.log(value, "分页");
  447. currentPage.value = value;
  448. getList();
  449. };
  450. onBeforeMount(() => {
  451. api.value = store.state.user.api;
  452. });
  453. onUnmounted(() => {
  454. // document.removeEventListener("keyup", Enters);
  455. });
  456. </script>
  457. <style scoped lang="scss">
  458. .content-box {
  459. min-width: 1000px;
  460. width: calc(100vw - 260px);
  461. height: calc(100vh - 105px);
  462. margin: 20px auto;
  463. background-color: #fff;
  464. color: #fff;
  465. display: flex;
  466. flex-direction: column;
  467. box-shadow: 0px 3px 10px rgba(0, 97, 255, 0.2);
  468. .left {
  469. // width: calc(100wh - 40px);
  470. display: flex;
  471. align-items: center;
  472. height: 60px;
  473. margin: 0 30px;
  474. border-bottom: 1px solid #ccc;
  475. color: #000;
  476. font-size: 18px;
  477. font-weight: 600;
  478. .cameratxt {
  479. display: block;
  480. height: 60px;
  481. line-height: 60px;
  482. }
  483. }
  484. .middle {
  485. width: calc(100% - 60px);
  486. margin: 0 auto;
  487. color: #000;
  488. // border-bottom: 1px solid rgb(231, 231, 231);
  489. .filter {
  490. display: flex;
  491. flex-wrap: wrap;
  492. align-items: center;
  493. margin: 10px 0 0 0;
  494. .search {
  495. margin-left: 0 !important;
  496. color: #fff;
  497. background: linear-gradient(
  498. 90deg,
  499. rgba(33, 107, 255, 1) 0%,
  500. rgba(102, 182, 255, 1) 100%
  501. );
  502. border: none;
  503. }
  504. .reset {
  505. border: 1px solid rgba(38, 151, 255, 1);
  506. color: rgba(38, 151, 255, 1);
  507. }
  508. .condition {
  509. display: flex;
  510. align-items: center;
  511. margin: 10px 30px 10px 0;
  512. :deep(.el-input .el-input__inner) {
  513. font-size: 14px;
  514. }
  515. span {
  516. margin: 0 10px 0 0;
  517. }
  518. }
  519. }
  520. .gongneng {
  521. margin: 10px 0;
  522. // .el-button {
  523. // color: #fff;
  524. // border: none;
  525. // }
  526. .add {
  527. color: #fff;
  528. border: none;
  529. background: linear-gradient(
  530. 90deg,
  531. rgba(33, 107, 255, 1) 0%,
  532. rgba(102, 182, 255, 1) 100%
  533. );
  534. }
  535. .imp {
  536. border: 1px solid rgba(33, 107, 255, 1);
  537. color: rgba(33, 107, 255, 1);
  538. }
  539. }
  540. }
  541. .scroll {
  542. flex: 1;
  543. overflow: auto;
  544. }
  545. .footer {
  546. width: 96%;
  547. height: calc(100% - 82px);
  548. margin: 10px auto 10px;
  549. .el-table--fit {
  550. height: 100%;
  551. :deep(.el-table__header-wrapper) {
  552. background-color: #000;
  553. font-size: 14px;
  554. color: #000;
  555. .cell {
  556. color: #000;
  557. }
  558. }
  559. :deep(.el-table__row) {
  560. height: 50px;
  561. font-size: 14px;
  562. color: #000;
  563. }
  564. :deep(.el-table__row td) {
  565. padding: 0;
  566. border: 0;
  567. }
  568. .el-button--primary {
  569. margin-left: 5px;
  570. }
  571. :deep(.el-table__body .even) {
  572. background-color: #fff;
  573. }
  574. :deep(.el-table__body .odd) {
  575. background-color: rgba(240, 243, 247, 1);
  576. }
  577. :deep(.options) {
  578. display: flex;
  579. justify-content: center;
  580. align-items: center;
  581. .reset {
  582. margin-right: 15px;
  583. color: rgba(30, 125, 251, 1);
  584. cursor: pointer;
  585. }
  586. .look {
  587. margin-right: 15px;
  588. color: rgba(30, 125, 251, 1);
  589. cursor: pointer;
  590. }
  591. .del {
  592. color: rgba(212, 48, 48, 1);
  593. cursor: pointer;
  594. }
  595. }
  596. }
  597. // 项目新增样式
  598. :deep(.account) {
  599. // height: 300px;
  600. border-radius: 11px;
  601. .el-dialog__header {
  602. border-radius: 11px 11px 0 0;
  603. background: rgba(237, 241, 245, 1);
  604. font-weight: 600;
  605. margin: 0;
  606. height: 32px;
  607. .el-dialog__headerbtn {
  608. outline: none;
  609. }
  610. }
  611. .el-dialog__body {
  612. padding: 30px 30px 0 30px;
  613. .el-form {
  614. .formLi {
  615. width: 100%;
  616. margin-bottom: 5px;
  617. display: flex;
  618. .el-form-item {
  619. .el-input {
  620. width: 120px;
  621. }
  622. &:nth-child(2) {
  623. .el-form-item__label {
  624. display: none;
  625. }
  626. .el-form-item__content {
  627. margin-left: 10px !important;
  628. }
  629. }
  630. &:nth-child(3) {
  631. .el-form-item__label {
  632. display: none;
  633. }
  634. .el-form-item__content {
  635. margin-left: 10px !important;
  636. }
  637. }
  638. }
  639. }
  640. .resetPassword {
  641. color: rgba(43, 151, 252, 1);
  642. padding-left: 40px;
  643. display: inline-block;
  644. margin-bottom: 15px;
  645. }
  646. .options {
  647. margin: 60px 0 40px 0;
  648. .el-form-item__content {
  649. display: flex;
  650. flex-direction: row-reverse;
  651. .queding {
  652. margin-left: 20px;
  653. background: linear-gradient(
  654. 90deg,
  655. rgba(33, 107, 255, 1) 0%,
  656. rgba(102, 182, 255, 1) 100%
  657. );
  658. border: none;
  659. }
  660. .quxiao {
  661. border: 1px solid rgba(43, 151, 252, 1);
  662. color: rgba(43, 151, 252, 1);
  663. }
  664. }
  665. }
  666. }
  667. }
  668. }
  669. }
  670. .el-pagination {
  671. width: calc(100vw - 300px);
  672. margin: 20px auto;
  673. justify-content: flex-end;
  674. :deep(.el-pagination__total) {
  675. color: #000;
  676. }
  677. :deep(.el-pagination__goto) {
  678. color: #000;
  679. }
  680. :deep(.el-pagination__classifier) {
  681. color: #000;
  682. }
  683. :deep(.el-input__wrapper) {
  684. // border: 1px solid rgba(0, 0, 0, 1);
  685. // border-radius: 5px;
  686. // box-shadow: none;
  687. width: 100px;
  688. }
  689. :deep(.el-pager li) {
  690. margin: 0 5px;
  691. border: 1px solid rgba(0, 0, 0, 1);
  692. border-radius: 5px;
  693. background-color: transparent;
  694. }
  695. :deep(.el-pager li.is-active) {
  696. // background-color: rgba(111, 182, 184, 1);
  697. color: rgba(0, 149, 255, 1);
  698. border: 1px solid rgba(0, 149, 255, 1);
  699. }
  700. :deep(.btn-prev) {
  701. margin-right: 5px;
  702. border: 1px solid rgba(0, 0, 0, 1);
  703. border-radius: 5px;
  704. background-color: transparent;
  705. }
  706. :deep(.btn-next) {
  707. margin-left: 5px;
  708. border: 1px solid rgba(0, 0, 0, 1);
  709. border-radius: 5px;
  710. background-color: transparent;
  711. }
  712. }
  713. }
  714. .el-input {
  715. width: 192px;
  716. }
  717. </style>
  718. <style lang="scss">
  719. .usePrefabricate {
  720. height: 488px;
  721. .el-select-dropdown__wrap {
  722. max-height: 100%;
  723. }
  724. }
  725. </style>