index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="68px"
  9. >
  10. <el-form-item label="岗位编码" prop="postCode">
  11. <el-input
  12. v-model="queryParams.postCode"
  13. placeholder="请输入岗位编码"
  14. clearable
  15. size="small"
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="岗位名称" prop="postName">
  20. <el-input
  21. v-model="queryParams.postName"
  22. placeholder="请输入岗位名称"
  23. clearable
  24. size="small"
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="状态" prop="status">
  29. <el-select
  30. v-model="queryParams.status"
  31. placeholder="岗位状态"
  32. clearable
  33. size="small"
  34. >
  35. <el-option
  36. v-for="dict in dict.type.sys_normal_disable"
  37. :key="dict.value"
  38. :label="dict.label"
  39. :value="dict.value"
  40. class="input_xiala"
  41. />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button
  46. icon="el-icon-search"
  47. size="btn"
  48. @click="handleQuery"
  49. >搜索</el-button
  50. >
  51. <el-button
  52. icon="el-icon-refresh"
  53. size="btr"
  54. @click="resetQuery"
  55. >重置</el-button
  56. >
  57. </el-form-item>
  58. </el-form>
  59. <el-row :gutter="10" class="mb8">
  60. <el-col :span="1.5">
  61. <el-button
  62. type="primary"
  63. plain
  64. icon="el-icon-plus"
  65. size="mini"
  66. @click="handleAdd"
  67. v-hasPermi="['system:post:add']"
  68. >新增</el-button
  69. >
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. type="success"
  74. plain
  75. icon="el-icon-edit"
  76. size="mini"
  77. :disabled="single"
  78. @click="handleUpdate"
  79. v-hasPermi="['system:post:edit']"
  80. >修改</el-button
  81. >
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="danger"
  86. plain
  87. icon="el-icon-delete"
  88. size="mini"
  89. :disabled="multiple"
  90. @click="handleDelete"
  91. v-hasPermi="['system:post:remove']"
  92. >删除</el-button
  93. >
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-button
  97. type="warning"
  98. plain
  99. icon="el-icon-download"
  100. size="mini"
  101. :loading="exportLoading"
  102. @click="handleExport"
  103. v-hasPermi="['system:post:export']"
  104. >导出</el-button
  105. >
  106. </el-col>
  107. <right-toolbar
  108. :showSearch.sync="showSearch"
  109. @queryTable="getList"
  110. ></right-toolbar>
  111. </el-row>
  112. <el-table
  113. v-loading="loading"
  114. :data="postList"
  115. @selection-change="handleSelectionChange"
  116. :header-cell-style="{ background: '#003C69', color: 'white' }"
  117. >
  118. <el-table-column type="selection" width="55" align="center" />
  119. <el-table-column label="岗位编号" align="center" prop="postId" />
  120. <el-table-column label="岗位编码" align="center" prop="postCode" />
  121. <el-table-column label="岗位名称" align="center" prop="postName" />
  122. <el-table-column label="岗位排序" align="center" prop="postSort" />
  123. <el-table-column label="状态" align="center" prop="status">
  124. <template slot-scope="scope">
  125. <dict-tag
  126. :options="dict.type.sys_normal_disable"
  127. :value="scope.row.status"
  128. />
  129. </template>
  130. </el-table-column>
  131. <el-table-column
  132. label="创建时间"
  133. align="center"
  134. prop="createTime"
  135. width="180"
  136. >
  137. <template slot-scope="scope">
  138. <span>{{ parseTime(scope.row.createTime) }}</span>
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. label="操作"
  143. align="center"
  144. class-name="small-padding fixed-width"
  145. >
  146. <template slot-scope="scope">
  147. <el-button
  148. size="btu"
  149. type="text"
  150. @click="handleUpdate(scope.row)"
  151. v-hasPermi="['system:post:edit']"
  152. >
  153. <span class="edit">修改</span></el-button
  154. >
  155. <el-button
  156. size="btd"
  157. type="text"
  158. @click="handleDelete(scope.row)"
  159. v-hasPermi="['system:post:remove']"
  160. ><span class="delete">删除</span></el-button
  161. >
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <pagination
  166. v-show="total > 0"
  167. :total="total"
  168. :page.sync="queryParams.pageNum"
  169. :limit.sync="queryParams.pageSize"
  170. @pagination="getList"
  171. />
  172. <!-- 添加或修改岗位对话框 -->
  173. <el-dialog
  174. :title="title"
  175. :visible.sync="open"
  176. width="700px"
  177. append-to-body
  178. :closeOnClickModal="false"
  179. :expand-on-click-node="false"
  180. >
  181. <div class="jiben">基本信息</div>
  182. <el-form
  183. ref="form"
  184. :model="form"
  185. :rules="rules"
  186. label-width="100px"
  187. :inline="true"
  188. >
  189. <el-form-item label="岗位名称" prop="postName">
  190. <el-input v-model="form.postName" placeholder="请输入岗位名称" />
  191. </el-form-item>
  192. <el-form-item label="岗位编码" prop="postCode">
  193. <el-input v-model="form.postCode" placeholder="请输入编码名称" />
  194. </el-form-item>
  195. <el-form-item label="岗位顺序" prop="postSort">
  196. <el-input-number
  197. v-model="form.postSort"
  198. controls-position="right"
  199. :min="0"
  200. />
  201. </el-form-item>
  202. <el-form-item></el-form-item>
  203. <el-form-item label="岗位状态" prop="status">
  204. <el-radio-group v-model="form.status">
  205. <el-radio
  206. v-for="dict in dict.type.sys_normal_disable"
  207. :key="dict.value"
  208. :label="dict.value"
  209. >{{ dict.label }}</el-radio
  210. >
  211. </el-radio-group>
  212. </el-form-item>
  213. <div class="jiben">备注</div>
  214. <el-form-item label="" prop="remark" style="width:100%" class="textareas">
  215. <el-input
  216. v-model="form.remark"
  217. type="textarea"
  218. placeholder="请输入内容"
  219. />
  220. </el-form-item>
  221. </el-form>
  222. <div slot="footer" class="dialog-footer">
  223. <el-button type="primary" @click="submitForm">确 定</el-button>
  224. <el-button @click="cancel">取 消</el-button>
  225. </div>
  226. </el-dialog>
  227. </div>
  228. </template>
  229. <script>
  230. import {
  231. listPost,
  232. getPost,
  233. delPost,
  234. addPost,
  235. updatePost,
  236. exportPost,
  237. } from "@/api/system/post";
  238. export default {
  239. name: "Post",
  240. dicts: ["sys_normal_disable"],
  241. data() {
  242. return {
  243. // 遮罩层
  244. loading: true,
  245. // 导出遮罩层
  246. exportLoading: false,
  247. // 选中数组
  248. ids: [],
  249. // 非单个禁用
  250. single: true,
  251. // 非多个禁用
  252. multiple: true,
  253. // 显示搜索条件
  254. showSearch: true,
  255. // 总条数
  256. total: 0,
  257. // 岗位表格数据
  258. postList: [],
  259. // 弹出层标题
  260. title: "",
  261. // 是否显示弹出层
  262. open: false,
  263. // 查询参数
  264. queryParams: {
  265. pageNum: 1,
  266. pageSize: 10,
  267. postCode: undefined,
  268. postName: undefined,
  269. status: undefined,
  270. },
  271. // 表单参数
  272. form: {},
  273. // 表单校验
  274. rules: {
  275. postName: [
  276. { required: true, message: "岗位名称不能为空", trigger: "blur" },
  277. ],
  278. postCode: [
  279. { required: true, message: "岗位编码不能为空", trigger: "blur" },
  280. ],
  281. postSort: [
  282. { required: true, message: "岗位顺序不能为空", trigger: "blur" },
  283. ],
  284. },
  285. };
  286. },
  287. created() {
  288. this.getList();
  289. },
  290. methods: {
  291. /** 查询岗位列表 */
  292. getList() {
  293. this.loading = true;
  294. listPost(this.queryParams).then((response) => {
  295. this.postList = response.rows;
  296. this.total = response.total;
  297. this.loading = false;
  298. });
  299. },
  300. // 取消按钮
  301. cancel() {
  302. this.open = false;
  303. this.reset();
  304. },
  305. // 表单重置
  306. reset() {
  307. this.form = {
  308. postId: undefined,
  309. postCode: undefined,
  310. postName: undefined,
  311. postSort: 0,
  312. status: "0",
  313. remark: undefined,
  314. };
  315. this.resetForm("form");
  316. },
  317. /** 搜索按钮操作 */
  318. handleQuery() {
  319. this.queryParams.pageNum = 1;
  320. this.getList();
  321. },
  322. /** 重置按钮操作 */
  323. resetQuery() {
  324. this.resetForm("queryForm");
  325. this.handleQuery();
  326. },
  327. // 多选框选中数据
  328. handleSelectionChange(selection) {
  329. this.ids = selection.map((item) => item.postId);
  330. this.single = selection.length != 1;
  331. this.multiple = !selection.length;
  332. },
  333. /** 新增按钮操作 */
  334. handleAdd() {
  335. this.reset();
  336. this.open = true;
  337. this.title = "添加岗位";
  338. },
  339. /** 修改按钮操作 */
  340. handleUpdate(row) {
  341. this.reset();
  342. const postId = row.postId || this.ids;
  343. getPost(postId).then((response) => {
  344. this.form = response.data;
  345. this.open = true;
  346. this.title = "修改岗位";
  347. });
  348. },
  349. /** 提交按钮 */
  350. submitForm: function () {
  351. this.$refs["form"].validate((valid) => {
  352. if (valid) {
  353. if (this.form.postId != undefined) {
  354. updatePost(this.form).then((response) => {
  355. this.$modal.msgSuccess("修改成功");
  356. this.open = false;
  357. this.getList();
  358. });
  359. } else {
  360. addPost(this.form).then((response) => {
  361. this.$modal.msgSuccess("新增成功");
  362. this.open = false;
  363. this.getList();
  364. });
  365. }
  366. }
  367. });
  368. },
  369. /** 删除按钮操作 */
  370. handleDelete(row) {
  371. const postIds = row.postId || this.ids;
  372. this.$modal
  373. .confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?')
  374. .then(function () {
  375. return delPost(postIds);
  376. })
  377. .then(() => {
  378. this.getList();
  379. this.$modal.msgSuccess("删除成功");
  380. })
  381. .catch(() => {});
  382. },
  383. /** 导出按钮操作 */
  384. handleExport() {
  385. const queryParams = this.queryParams;
  386. this.$modal
  387. .confirm("是否确认导出所有岗位数据项?")
  388. .then(() => {
  389. this.exportLoading = true;
  390. return exportPost(queryParams);
  391. })
  392. .then((response) => {
  393. this.$download.name(response.msg);
  394. this.exportLoading = false;
  395. })
  396. .catch(() => {});
  397. },
  398. },
  399. };
  400. </script>
  401. <style scoped>
  402. /* 对话框背景颜色 */
  403. ::v-deep .el-dialog {
  404. background: #004d86 !important;
  405. }
  406. ::v-deep .el-textarea__inner {
  407. width: 930px;
  408. height: 104px;
  409. margin: auto !important;
  410. }
  411. ::v-deep .el-dialog__header {
  412. border-bottom: 1px solid #718a9d;
  413. }
  414. ::v-deep .el-dialog__title {
  415. color: #fff;
  416. font: 18px;
  417. }
  418. ::v-deep .el-dialog__headerbtn .el-dialog__close {
  419. color: #fff;
  420. }
  421. ::v-deep .el-form-item__label {
  422. font: 16px;
  423. color: #fff;
  424. width: 100px !important;
  425. }
  426. ::v-deep .el-input__inner {
  427. /* width: 200px !important;
  428. height: 36px; */
  429. background: transparent;
  430. color: #fff;
  431. }
  432. /* 单位框背景颜色 */
  433. ::v-deep .vue-treeselect__control {
  434. background: #004d86 !important;
  435. }
  436. /* 基本信息背景 */
  437. .jiben {
  438. width: 660px;
  439. height: 32px;
  440. background-image: url(../../../images/小标题底.png);
  441. margin-bottom: 25px;
  442. color: #fff;
  443. padding-left: 16px;
  444. line-height: 32px;
  445. }
  446. /*调整表单间距 */
  447. ::v-deep .el-form-item__content {
  448. width: 200px;
  449. }
  450. .contents {
  451. padding: 0px 40px !important;
  452. }
  453. /* 下拉菜单 */
  454. .el-dropdown-link {
  455. cursor: pointer;
  456. color: #409eff;
  457. }
  458. .el-icon-arrow-down {
  459. font-size: 12px;
  460. }
  461. /* 刷新图标 */
  462. /* .el-icon-refresh {
  463. width: 76px;
  464. height: 36px;
  465. color: #fff;
  466. background-color: #1d96ff !important;
  467. border-radius: 4px;
  468. border: none;
  469. margin-left: 20px;
  470. font-size: 14px;
  471. } */
  472. /* 下拉菜单字体/背景颜色 */
  473. .el-select-dropdown__item.hover,
  474. .el-select-dropdown__item:hover {
  475. background-color: #004d86;
  476. color: #fff;
  477. }
  478. .el-select-dropdown__item {
  479. color: #fff;
  480. }
  481. /* 时间选择 */
  482. ::v-deep .el-input--small .el-input__inner {
  483. width: 200px;
  484. height: 36px;
  485. line-height: 36px;
  486. }
  487. .el-date-editor.el-input {
  488. width: 200px;
  489. height: 36px;
  490. line-height: 36px;
  491. }
  492. ::v-deep .el-date-editor.el-input .el-input__inner {
  493. height: 36px;
  494. line-height: 36px;
  495. }
  496. /* 单位框背景颜色 */
  497. ::v-deep .vue-treeselect__control {
  498. background: #004d86 !important;
  499. color: #fff;
  500. }
  501. /* 单位下拉菜单选中字体颜色 */
  502. ::v-deep .vue-treeselect__single-value {
  503. color: #fff !important;
  504. }
  505. /* 分页按钮 */
  506. ::v-deep .el-pagination.is-background .el-pager li {
  507. background-color: #004d86;
  508. color: #fff;
  509. }
  510. ::v-deep .el-pagination.is-background .btn-next {
  511. background-color: #004d86;
  512. color: #fff;
  513. }
  514. ::v-deep .el-pagination.is-background .btn-prev,
  515. .el-pagination.is-background .btn-next,
  516. .el-pagination.is-background .el-pager li {
  517. background: #004d86 !important;
  518. color: #fff !important;
  519. }
  520. /* 状态 */
  521. .el-radio {
  522. color: rgb(204, 198, 198);
  523. }
  524. /* 计数器按钮 */
  525. ::v-deep .el-input-number__increase {
  526. background-color: transparent !important;
  527. border: none;
  528. color: #cccccc;
  529. border-bottom: none !important;
  530. }
  531. ::v-deep .el-input-number__decrease {
  532. background-color: transparent !important;
  533. border: none !important;
  534. color: #cccccc;
  535. }
  536. /* 备注输入框 */
  537. .textareas ::v-deep .el-form-item__content {
  538. width:100%;
  539. }
  540. ::v-deep .el-textarea__inner {
  541. width: 660px;
  542. height: 104px;
  543. margin: auto !important;
  544. }
  545. /* 调整输入框提示文字颜色 */
  546. ::v-deep .vue-treeselect__placeholder {
  547. color: #bdbdbd4f !important;
  548. }
  549. ::v-deep input::-webkit-input-placeholder {
  550. color: #bdbdbd4f !important;
  551. }
  552. ::v-deep input:-moz-placeholder {
  553. color: #bdbdbd4f !important;
  554. }
  555. </style>