index.vue 12 KB

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