index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. >
  179. <div class="jiben">基本信息</div>
  180. <el-form
  181. ref="form"
  182. :model="form"
  183. :rules="rules"
  184. label-width="100px"
  185. :inline="true"
  186. >
  187. <el-form-item label="岗位名称" prop="postName">
  188. <el-input v-model="form.postName" placeholder="请输入岗位名称" />
  189. </el-form-item>
  190. <el-form-item label="岗位编码" prop="postCode">
  191. <el-input v-model="form.postCode" placeholder="请输入编码名称" />
  192. </el-form-item>
  193. <el-form-item label="岗位顺序" prop="postSort">
  194. <el-input-number
  195. v-model="form.postSort"
  196. controls-position="right"
  197. :min="0"
  198. />
  199. </el-form-item>
  200. <el-form-item></el-form-item>
  201. <el-form-item label="岗位状态" prop="status">
  202. <el-radio-group v-model="form.status">
  203. <el-radio
  204. v-for="dict in dict.type.sys_normal_disable"
  205. :key="dict.value"
  206. :label="dict.value"
  207. >{{ dict.label }}</el-radio
  208. >
  209. </el-radio-group>
  210. </el-form-item>
  211. <div class="jiben">备注</div>
  212. <el-form-item label="" prop="remark" style="width:100%" class="textareas">
  213. <el-input
  214. v-model="form.remark"
  215. type="textarea"
  216. placeholder="请输入内容"
  217. />
  218. </el-form-item>
  219. </el-form>
  220. <div slot="footer" class="dialog-footer">
  221. <el-button type="primary" @click="submitForm">确 定</el-button>
  222. <el-button @click="cancel">取 消</el-button>
  223. </div>
  224. </el-dialog>
  225. </div>
  226. </template>
  227. <script>
  228. import {
  229. listPost,
  230. getPost,
  231. delPost,
  232. addPost,
  233. updatePost,
  234. exportPost,
  235. } from "@/api/system/post";
  236. export default {
  237. name: "Post",
  238. dicts: ["sys_normal_disable"],
  239. data() {
  240. return {
  241. // 遮罩层
  242. loading: true,
  243. // 导出遮罩层
  244. exportLoading: false,
  245. // 选中数组
  246. ids: [],
  247. // 非单个禁用
  248. single: true,
  249. // 非多个禁用
  250. multiple: true,
  251. // 显示搜索条件
  252. showSearch: true,
  253. // 总条数
  254. total: 0,
  255. // 岗位表格数据
  256. postList: [],
  257. // 弹出层标题
  258. title: "",
  259. // 是否显示弹出层
  260. open: false,
  261. // 查询参数
  262. queryParams: {
  263. pageNum: 1,
  264. pageSize: 10,
  265. postCode: undefined,
  266. postName: undefined,
  267. status: undefined,
  268. },
  269. // 表单参数
  270. form: {},
  271. // 表单校验
  272. rules: {
  273. postName: [
  274. { required: true, message: "岗位名称不能为空", trigger: "blur" },
  275. ],
  276. postCode: [
  277. { required: true, message: "岗位编码不能为空", trigger: "blur" },
  278. ],
  279. postSort: [
  280. { required: true, message: "岗位顺序不能为空", trigger: "blur" },
  281. ],
  282. },
  283. };
  284. },
  285. created() {
  286. this.getList();
  287. },
  288. methods: {
  289. /** 查询岗位列表 */
  290. getList() {
  291. this.loading = true;
  292. listPost(this.queryParams).then((response) => {
  293. this.postList = response.rows;
  294. this.total = response.total;
  295. this.loading = false;
  296. });
  297. },
  298. // 取消按钮
  299. cancel() {
  300. this.open = false;
  301. this.reset();
  302. },
  303. // 表单重置
  304. reset() {
  305. this.form = {
  306. postId: undefined,
  307. postCode: undefined,
  308. postName: undefined,
  309. postSort: 0,
  310. status: "0",
  311. remark: undefined,
  312. };
  313. this.resetForm("form");
  314. },
  315. /** 搜索按钮操作 */
  316. handleQuery() {
  317. this.queryParams.pageNum = 1;
  318. this.getList();
  319. },
  320. /** 重置按钮操作 */
  321. resetQuery() {
  322. this.resetForm("queryForm");
  323. this.handleQuery();
  324. },
  325. // 多选框选中数据
  326. handleSelectionChange(selection) {
  327. this.ids = selection.map((item) => item.postId);
  328. this.single = selection.length != 1;
  329. this.multiple = !selection.length;
  330. },
  331. /** 新增按钮操作 */
  332. handleAdd() {
  333. this.reset();
  334. this.open = true;
  335. this.title = "添加岗位";
  336. },
  337. /** 修改按钮操作 */
  338. handleUpdate(row) {
  339. this.reset();
  340. const postId = row.postId || this.ids;
  341. getPost(postId).then((response) => {
  342. this.form = response.data;
  343. this.open = true;
  344. this.title = "修改岗位";
  345. });
  346. },
  347. /** 提交按钮 */
  348. submitForm: function () {
  349. this.$refs["form"].validate((valid) => {
  350. if (valid) {
  351. if (this.form.postId != undefined) {
  352. updatePost(this.form).then((response) => {
  353. this.$modal.msgSuccess("修改成功");
  354. this.open = false;
  355. this.getList();
  356. });
  357. } else {
  358. addPost(this.form).then((response) => {
  359. this.$modal.msgSuccess("新增成功");
  360. this.open = false;
  361. this.getList();
  362. });
  363. }
  364. }
  365. });
  366. },
  367. /** 删除按钮操作 */
  368. handleDelete(row) {
  369. const postIds = row.postId || this.ids;
  370. this.$modal
  371. .confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?')
  372. .then(function () {
  373. return delPost(postIds);
  374. })
  375. .then(() => {
  376. this.getList();
  377. this.$modal.msgSuccess("删除成功");
  378. })
  379. .catch(() => {});
  380. },
  381. /** 导出按钮操作 */
  382. handleExport() {
  383. const queryParams = this.queryParams;
  384. this.$modal
  385. .confirm("是否确认导出所有岗位数据项?")
  386. .then(() => {
  387. this.exportLoading = true;
  388. return exportPost(queryParams);
  389. })
  390. .then((response) => {
  391. this.$download.name(response.msg);
  392. this.exportLoading = false;
  393. })
  394. .catch(() => {});
  395. },
  396. },
  397. };
  398. </script>
  399. <style scoped>
  400. /* 对话框背景颜色 */
  401. ::v-deep .el-dialog {
  402. background: #004d86 !important;
  403. }
  404. ::v-deep .el-textarea__inner {
  405. width: 930px;
  406. height: 104px;
  407. margin: auto !important;
  408. }
  409. ::v-deep .el-dialog__header {
  410. border-bottom: 1px solid #718a9d;
  411. }
  412. ::v-deep .el-dialog__title {
  413. color: #fff;
  414. font: 18px;
  415. }
  416. ::v-deep .el-dialog__headerbtn .el-dialog__close {
  417. color: #fff;
  418. }
  419. ::v-deep .el-form-item__label {
  420. font: 16px;
  421. color: #fff;
  422. width: 100px !important;
  423. }
  424. ::v-deep .el-input__inner {
  425. /* width: 200px !important;
  426. height: 36px; */
  427. background: transparent;
  428. color: #fff;
  429. }
  430. /* 单位框背景颜色 */
  431. ::v-deep .vue-treeselect__control {
  432. background: #004d86 !important;
  433. }
  434. /* 基本信息背景 */
  435. .jiben {
  436. width: 660px;
  437. height: 32px;
  438. background-image: url(../../../images/小标题底.png);
  439. margin-bottom: 25px;
  440. color: #fff;
  441. padding-left: 16px;
  442. line-height: 32px;
  443. }
  444. /*调整表单间距 */
  445. ::v-deep .el-form-item__content {
  446. width: 200px;
  447. }
  448. .contents {
  449. padding: 0px 40px !important;
  450. }
  451. /* 下拉菜单 */
  452. .el-dropdown-link {
  453. cursor: pointer;
  454. color: #409eff;
  455. }
  456. .el-icon-arrow-down {
  457. font-size: 12px;
  458. }
  459. /* 刷新图标 */
  460. /* .el-icon-refresh {
  461. width: 76px;
  462. height: 36px;
  463. color: #fff;
  464. background-color: #1d96ff !important;
  465. border-radius: 4px;
  466. border: none;
  467. margin-left: 20px;
  468. font-size: 14px;
  469. } */
  470. /* 下拉菜单字体/背景颜色 */
  471. .el-select-dropdown__item.hover,
  472. .el-select-dropdown__item:hover {
  473. background-color: #004d86;
  474. color: #fff;
  475. }
  476. .el-select-dropdown__item {
  477. color: #fff;
  478. }
  479. /* 时间选择 */
  480. ::v-deep .el-input--small .el-input__inner {
  481. width: 200px;
  482. height: 36px;
  483. line-height: 36px;
  484. }
  485. .el-date-editor.el-input {
  486. width: 200px;
  487. height: 36px;
  488. line-height: 36px;
  489. }
  490. ::v-deep .el-date-editor.el-input .el-input__inner {
  491. height: 36px;
  492. line-height: 36px;
  493. }
  494. /* 单位框背景颜色 */
  495. ::v-deep .vue-treeselect__control {
  496. background: #004d86 !important;
  497. color: #fff;
  498. }
  499. /* 单位下拉菜单选中字体颜色 */
  500. ::v-deep .vue-treeselect__single-value {
  501. color: #fff !important;
  502. }
  503. /* 分页按钮 */
  504. ::v-deep .el-pagination.is-background .el-pager li {
  505. background-color: #004d86;
  506. color: #fff;
  507. }
  508. ::v-deep .el-pagination.is-background .btn-next {
  509. background-color: #004d86;
  510. color: #fff;
  511. }
  512. ::v-deep .el-pagination.is-background .btn-prev,
  513. .el-pagination.is-background .btn-next,
  514. .el-pagination.is-background .el-pager li {
  515. background: #004d86 !important;
  516. color: #fff !important;
  517. }
  518. /* 状态 */
  519. .el-radio {
  520. color: rgb(204, 198, 198);
  521. }
  522. /* 计数器按钮 */
  523. ::v-deep .el-input-number__increase {
  524. background-color: transparent !important;
  525. border: none;
  526. color: #cccccc;
  527. border-bottom: none !important;
  528. }
  529. ::v-deep .el-input-number__decrease {
  530. background-color: transparent !important;
  531. border: none !important;
  532. color: #cccccc;
  533. }
  534. /* 备注输入框 */
  535. .textareas ::v-deep .el-form-item__content {
  536. width:100%;
  537. }
  538. ::v-deep .el-textarea__inner {
  539. width: 660px;
  540. height: 104px;
  541. margin: auto !important;
  542. }
  543. </style>