You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
7.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <section>
  3. <el-row class="app-container">
  4. <el-input v-model="filters.key" style="width: 20%;" placeholder="模糊查询"></el-input>
  5. <el-button type="primary" v-loading="load.list" :disabled="load.list==true" v-on:click="searchPosts" icon="el-icon-search"></el-button>
  6. <el-button type="primary" @click="confirmPostSelect" v-loading="load.add==true">确定</el-button>
  7. <el-tooltip class="item" effect="light" content="如果没有查询到岗位,有可能是所有岗位已经加入该部门,可在岗位管理中定义新的岗位,再到此将岗位加入部门" placement="top-start">
  8. <i class="el-icon-question"></i>
  9. </el-tooltip>
  10. </el-row>
  11. <el-row class="app-container">
  12. <!--列表 Post sys_post-->
  13. <el-table :max-height="tableHeight" :data="posts" @sort-change="sortChange" highlight-current-row v-loading="load.list" border @selection-change="selsChange" @row-click="rowClick" style="width: 100%;">
  14. <el-table-column type="selection" width="40"></el-table-column>
  15. <el-table-column type="index" width="60"></el-table-column>
  16. <el-table-column prop="postName" label="岗位名称" min-width="80" show-overflow-tooltip></el-table-column>
  17. <el-table-column prop="remark" label="备注" min-width="80" show-overflow-tooltip></el-table-column>
  18. <el-table-column prop="cdate" label="创建日期" min-width="80" show-overflow-tooltip></el-table-column>
  19. </el-table>
  20. <el-pagination layout="total, sizes, prev, pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange" :page-sizes="[10,20, 50, 100, 500]" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total" style="float:right;"></el-pagination>
  21. </el-row>
  22. </section>
  23. </template>
  24. <script>
  25. import util from '@/common/js/util';//全局公共库
  26. //import Sticky from '@/components/Sticky' // 粘性header组件
  27. //import { listOption } from '@/api/mdp/meta/itemOption';//下拉框数据查询
  28. import { listPost, delPost, batchDelPost,listPostNotInDeptid } from '@/api/mdp/sys/post/post';
  29. import { mapGetters } from 'vuex'
  30. export default {
  31. props:['branchId','deptid','visible'],
  32. watch: {
  33. 'visible':function(visible) {
  34. if(visible==true){
  35. this.searchPosts()
  36. }
  37. }
  38. },
  39. computed: {
  40. ...mapGetters([
  41. 'userInfo'
  42. ])
  43. },
  44. data() {
  45. return {
  46. filters: {
  47. key: ''
  48. },
  49. posts: [],//查询结果
  50. pageInfo:{//分页数据
  51. total:0,//服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算。
  52. pageSize:10,//每页数据
  53. count:false,//是否需要重新计算总记录数
  54. pageNum:1,//当前页码、从1开始计算
  55. orderFields:[],//排序列 如 ['sex','student_id'],必须为数据库字段
  56. orderDirs:[]//升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']
  57. },
  58. load:{ list: false, edit: false, del: false, add: false },//查询中...
  59. sels: [],//列表选中数据
  60. options:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  61. addFormVisible: false,//新增post界面是否显示
  62. //新增post界面初始化数据
  63. addForm: {
  64. id:'',postName:'',remark:'',branchId:'',cdate:''
  65. },
  66. postRoleMngVisible: false,//显示岗位角色关系界面
  67. editFormVisible: false,//编辑界面是否显示
  68. //编辑post界面初始化数据
  69. editForm: {
  70. id:'',postName:'',remark:'',branchId:'',cdate:''
  71. },
  72. tableHeight:500,
  73. /**begin 自定义属性请在下面加 请加备注**/
  74. /**end 自定义属性请在上面加 请加备注**/
  75. }
  76. },//end data
  77. methods: {
  78. handleSizeChange(pageSize) {
  79. this.pageInfo.pageSize=pageSize;
  80. this.getPosts();
  81. },
  82. handleCurrentChange(pageNum) {
  83. this.pageInfo.pageNum = pageNum;
  84. this.getPosts();
  85. },
  86. // 表格排序 obj.order=ascending/descending,需转化为 asc/desc ; obj.prop=表格中的排序字段,字段驼峰命名
  87. sortChange( obj ){
  88. var dir='asc';
  89. if(obj.order=='ascending'){
  90. dir='asc'
  91. }else{
  92. dir='desc';
  93. }
  94. if(obj.prop=='xxx'){
  95. this.pageInfo.orderFields=['xxx'];
  96. this.pageInfo.orderDirs=[dir];
  97. }
  98. this.getPosts();
  99. },
  100. searchPosts(){
  101. this.pageInfo.count=true;
  102. this.getPosts();
  103. },
  104. //获取列表 Post sys_post
  105. getPosts() {
  106. let params = {
  107. pageSize: this.pageInfo.pageSize,
  108. pageNum: this.pageInfo.pageNum,
  109. total: this.pageInfo.total,
  110. count:this.pageInfo.count
  111. };
  112. if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){
  113. let orderBys=[];
  114. for(var i=0;i<this.pageInfo.orderFields.length;i++){
  115. orderBys.push(this.pageInfo.orderFields[i]+" "+this.pageInfo.orderDirs[i])
  116. }
  117. params.orderBy= orderBys.join(",")
  118. }
  119. if(this.filters.key!==""){
  120. //params.key="%"+this.filters.key+"%"
  121. }else{
  122. //params.xxx=xxxxx
  123. }
  124. params.deptid=this.deptid
  125. params.branchId=this.branchId
  126. this.load.list = true;
  127. listPost(params).then((res) => {
  128. var tips=res.data.tips;
  129. if(tips.isOk){
  130. this.pageInfo.total = res.data.total;
  131. this.pageInfo.count=false;
  132. this.posts = res.data.data;
  133. }else{
  134. this.$notify({ message: tips.msg, type: 'error' });
  135. }
  136. this.load.list = false;
  137. }).catch( err => this.load.list = false );
  138. },
  139. //显示编辑界面 Post sys_post
  140. showEdit: function ( row,index ) {
  141. this.editFormVisible = true;
  142. this.editForm = Object.assign({}, row);
  143. },
  144. //显示编辑界面 岗位角色关系维护界面
  145. showPostRoleMng: function ( row,index ) {
  146. this.postRoleMngVisible = true;
  147. this.editForm = Object.assign({}, row);
  148. },
  149. //显示新增界面 Post sys_post
  150. showAdd: function () {
  151. this.addFormVisible = true;
  152. //this.addForm=Object.assign({}, this.editForm);
  153. },
  154. afterAddSubmit(){
  155. this.addFormVisible=false;
  156. this.pageInfo.count=true;
  157. this.getPosts();
  158. },
  159. afterEditSubmit(){
  160. this.editFormVisible=false;
  161. },
  162. //选择行post
  163. selsChange: function (sels) {
  164. this.sels = sels;
  165. },
  166. rowClick: function(row, event, column){
  167. this.$emit('row-click',row, event, column);// @row-click="rowClick"
  168. },
  169. /**begin 自定义函数请在下面加**/
  170. confirmPostSelect(){
  171. if(this.sels.length<=0){
  172. this.$notify({ message:'请选择角色', type: 'error'});
  173. return;
  174. }
  175. this.load.add=true;
  176. this.$emit('select',this.sels);// @select="afterConfirmPostSelect"
  177. this.load.add=false;
  178. }
  179. /**end 自定义函数请在上面加**/
  180. },//end methods
  181. components: {
  182. //在下面添加其它组件
  183. },
  184. mounted() {
  185. this.$nextTick(() => {
  186. this.tableHeight = window.innerHeight - 250;
  187. });
  188. this.$nextTick(() => {
  189. this.getPosts();
  190. });
  191. }
  192. }
  193. </script>
  194. <style scoped>
  195. </style>