index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="app-container post-page">
  3. <div class="post-page-min" v-if="pageType == 1">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" >
  5. <el-form-item label="关键字" prop="searchValue">
  6. <el-input
  7. v-model="queryParams.searchValue"
  8. placeholder="请输入职位编码"
  9. clearable
  10. size="small"
  11. />
  12. </el-form-item>
  13. <el-form-item label="状态" prop="status">
  14. <el-select v-model="queryParams.status" placeholder="职位状态" clearable size="small">
  15. <el-option
  16. v-for="dict in statusOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item style="float: right;">
  24. <el-col :span="1.5" style="margin-right:20px">
  25. <p class="add-button-one-120"
  26. @click="handleAdd"
  27. v-hasPermi="['system:post:add']"
  28. ><i class="el-icon-plus"></i>新增</p>
  29. </el-col>
  30. </el-form-item>
  31. <el-form-item>
  32. <p class="inquire-button-one" @click="handleQuery">查询</p>
  33. <p class="reset-button-one" @click="resetQuery">重置</p>
  34. </el-form-item>
  35. </el-form>
  36. <el-table v-loading="loading" border :data="postList" @selection-change="handleSelectionChange">
  37. <el-table-column type="selection" width="55" align="center" />
  38. <!--<el-table-column label="职位编号" align="left" prop="postId" />-->
  39. <el-table-column label="职位编码" align="left" prop="postCode" />
  40. <el-table-column label="职位名称" align="left" prop="postName" />
  41. <el-table-column label="职位排序" align="left" prop="postSort" />
  42. <el-table-column label="状态" align="left" prop="status" :formatter="statusFormat" />
  43. <el-table-column label="创建时间" align="left" prop="createTime" width="180">
  44. <template slot-scope="scope">
  45. <span>{{ parseTime(scope.row.createTime) }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="240">
  49. <template slot-scope="scope">
  50. <div class="table-button-box">
  51. <p class="table-button-null"></p>
  52. <p class="table-button-p"
  53. @click="handleAuthUser(scope.row)"
  54. >分配用户</p>
  55. <p class="table-button-p"
  56. @click="handleUpdate(scope.row)"
  57. v-hasPermiAnd="['system:post:query','system:post:edit']"
  58. >编辑</p>
  59. <p class="table-button-p"
  60. @click="handleDelete(scope.row)"
  61. v-hasPermi="['system:post:remove']"
  62. >删除</p>
  63. <p class="table-button-null"></p>
  64. </div>
  65. </template>
  66. <!--<template slot-scope="scope">-->
  67. <!--<el-button-->
  68. <!--size="mini"-->
  69. <!--type="text"-->
  70. <!--icon="el-icon-edit"-->
  71. <!--@click="handleUpdate(scope.row)"-->
  72. <!--v-hasPermi="['system:post:edit']"-->
  73. <!--&gt;分配职位</el-button>-->
  74. <!--<el-button-->
  75. <!--size="mini"-->
  76. <!--type="text"-->
  77. <!--icon="el-icon-edit"-->
  78. <!--@click="handleUpdate(scope.row)"-->
  79. <!--v-hasPermi="['system:post:edit']"-->
  80. <!--&gt;修改</el-button>-->
  81. <!--<el-button-->
  82. <!--size="mini"-->
  83. <!--type="text"-->
  84. <!--icon="el-icon-delete"-->
  85. <!--@click="handleDelete(scope.row)"-->
  86. <!--v-hasPermi="['system:post:remove']"-->
  87. <!--&gt;删除</el-button>-->
  88. <!--</template>-->
  89. </el-table-column>
  90. </el-table>
  91. <pagination :page-sizes="[20, 30, 40, 50]"
  92. v-show="total>0"
  93. :total="total"
  94. layout="total, prev, pager, next, sizes, jumper"
  95. :page.sync="queryParams.pageNum"
  96. :limit.sync="queryParams.pageSize"
  97. @pagination="getList"
  98. />
  99. </div>
  100. <!-- 添加或修改职位对话框 -->
  101. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body
  102. :close-on-click-modal="false">
  103. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  104. <el-form-item label="职位名称" prop="postName">
  105. <el-input v-model="form.postName" placeholder="请输入职位名称" maxlength="10" />
  106. </el-form-item>
  107. <el-form-item label="职位编码" prop="postCode">
  108. <el-input v-model="form.postCode" placeholder="请输入编码名称" maxlength="10" />
  109. </el-form-item>
  110. <el-form-item label="职位顺序" prop="postSort">
  111. <el-input-number v-model="form.postSort" controls-position="right" :min="0" style="width: 380px"/>
  112. </el-form-item>
  113. <el-form-item label="职位状态" prop="status">
  114. <el-radio-group v-model="form.status">
  115. <el-radio
  116. v-for="dict in statusOptions"
  117. :key="dict.dictValue"
  118. :label="dict.dictValue"
  119. >{{dict.dictLabel}}</el-radio>
  120. </el-radio-group>
  121. </el-form-item>
  122. <el-form-item label="备注" prop="remark">
  123. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  124. </el-form-item>
  125. </el-form>
  126. <div slot="footer" class="dialog-footer">
  127. <el-button @click="cancel">取 消</el-button>
  128. <el-button type="primary" @click="submitForm">确 定</el-button>
  129. </div>
  130. </el-dialog>
  131. <!--分配用户-->
  132. <auth-user :postId="postId" v-if="pageType == 2"></auth-user>
  133. </div>
  134. </template>
  135. <script>
  136. import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post";
  137. import authUser from "./authUser.vue";
  138. export default {
  139. components: {
  140. authUser,
  141. },
  142. name: "Post",
  143. data() {
  144. return {
  145. isShow:true,
  146. // 遮罩层
  147. loading: true,
  148. // 选中数组
  149. ids: [],
  150. // 非单个禁用
  151. single: true,
  152. // 非多个禁用
  153. multiple: true,
  154. // 显示搜索条件
  155. showSearch: true,
  156. // 总条数
  157. total: 0,
  158. // 职位表格数据
  159. postList: [],
  160. // 弹出层标题
  161. title: "",
  162. // 是否显示弹出层
  163. open: false,
  164. // 状态数据字典
  165. statusOptions: [],
  166. // 查询参数
  167. queryParams: {
  168. pageNum: 1,
  169. pageSize:20,
  170. searchValue: null,
  171. postCode: undefined,
  172. postName: undefined,
  173. status: undefined
  174. },
  175. // 表单参数
  176. form: {},
  177. pageType:1,
  178. postId:"",
  179. // 表单校验
  180. rules: {
  181. postName: [
  182. { required: true, message: "职位名称不能为空", trigger: "blur" },
  183. { required: true, message: "职位名称不能为空", validator: this.spaceJudgment, trigger: "blur" }
  184. ],
  185. postCode: [
  186. { required: true, message: "职位编码不能为空", trigger: "blur" },
  187. { required: true, message: "职位编码不能为空", validator: this.spaceJudgment, trigger: "blur" }
  188. ],
  189. postSort: [
  190. { required: true, message: "职位顺序不能为空", trigger: "blur" },
  191. { required: true, message: "职位顺序不能为空", validator: this.spaceJudgment, trigger: "blur" }
  192. ]
  193. }
  194. };
  195. },
  196. created() {
  197. this.getList();
  198. this.getDicts("sys_normal_disable").then(response => {
  199. this.statusOptions = response.data;
  200. });
  201. },
  202. methods: {
  203. clickPage(type){
  204. if(this.pageType != type){
  205. this.pageType = type;
  206. }
  207. },
  208. /** 查询职位列表 */
  209. getList() {
  210. this.loading = true;
  211. listPost(this.queryParams).then(response => {
  212. this.postList = response.rows;
  213. this.total = response.total;
  214. this.loading = false;
  215. });
  216. },
  217. // 职位状态字典翻译
  218. statusFormat(row, column) {
  219. return this.selectDictLabel(this.statusOptions, row.status);
  220. },
  221. // 取消按钮
  222. cancel() {
  223. this.open = false;
  224. this.reset();
  225. },
  226. // 表单重置
  227. reset() {
  228. this.form = {
  229. postId: undefined,
  230. postCode: undefined,
  231. postName: undefined,
  232. postSort: 0,
  233. status: "0",
  234. remark: undefined
  235. };
  236. this.resetForm("form");
  237. },
  238. /** 搜索按钮操作 */
  239. handleQuery() {
  240. this.queryParams.pageNum = 1;
  241. this.getList();
  242. },
  243. /** 重置按钮操作 */
  244. resetQuery() {
  245. this.queryParams.searchValue='';
  246. // this.resetForm("queryForm");
  247. this.$set(this,'queryParams',{
  248. pageNum: 1,
  249. pageSize:20,
  250. searchValue:"",
  251. status:"",
  252. });
  253. this.handleQuery();
  254. },
  255. /** 分配用户操作 */
  256. handleAuthUser: function(row) {
  257. this.postId=row.postId;
  258. this.pageType=2;
  259. },
  260. // 多选框选中数据
  261. handleSelectionChange(selection) {
  262. this.ids = selection.map(item => item.postId)
  263. this.single = selection.length!=1
  264. this.multiple = !selection.length
  265. },
  266. /** 新增按钮操作 */
  267. handleAdd() {
  268. this.reset();
  269. this.open = true;
  270. this.title = "添加职位";
  271. },
  272. /** 修改按钮操作 */
  273. handleUpdate(row) {
  274. this.reset();
  275. const postId = row.postId || this.ids
  276. getPost(postId).then(response => {
  277. this.form = response.data;
  278. this.open = true;
  279. this.title = "修改职位";
  280. });
  281. },
  282. /** 提交按钮 */
  283. submitForm: function() {
  284. this.$refs["form"].validate(valid => {
  285. if (valid) {
  286. if (this.form.postId != undefined) {
  287. updatePost(this.form).then(response => {
  288. this.msgSuccess("修改成功");
  289. this.open = false;
  290. this.getList();
  291. });
  292. } else {
  293. addPost(this.form).then(response => {
  294. this.msgSuccess("新增成功");
  295. this.open = false;
  296. this.getList();
  297. });
  298. }
  299. }
  300. });
  301. },
  302. /** 删除按钮操作 */
  303. handleDelete(row) {
  304. const postIds = row.postId || this.ids;
  305. this.$confirm('是否确认删除职位?', "警告", {
  306. confirmButtonText: "确定",
  307. cancelButtonText: "取消",
  308. type: "warning"
  309. }).then(function() {
  310. return delPost(postIds);
  311. }).then(() => {
  312. this.getList();
  313. this.msgSuccess("删除成功");
  314. }).catch(() => {});
  315. },
  316. /** 导出按钮操作 */
  317. handleExport() {
  318. this.download('system/post/export', {
  319. ...this.queryParams
  320. }, `post_${new Date().getTime()}.xlsx`)
  321. }
  322. }
  323. };
  324. </script>
  325. <style scoped lang="scss">
  326. .post-page{
  327. display: flex!important;
  328. flex-direction: column;
  329. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  330. padding:11px 20px 20px!important;
  331. .post-page-min{
  332. flex:1;
  333. display: flex!important;
  334. flex-direction: column;
  335. .button-box{
  336. width:340px;
  337. display: flex;
  338. }
  339. }
  340. }
  341. </style>