index.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <el-row>
  3. <el-col :span="4" v-if="departdata[0].childlist.length>1">
  4. <el-card shadow="never" style="width: 95%;">
  5. <el-input placeholder="请输入部门名称" v-model="search" @input="handleSearch">
  6. <template #prepend>
  7. <i class="fa fa-search"></i>
  8. </template>
  9. </el-input>
  10. <el-scrollbar height="calc(100vh)">
  11. <el-tree
  12. style="margin-top: 15px"
  13. ref="elTree"
  14. :data='departdata'
  15. :expand-on-click-node="false"
  16. :default-expand-all="true"
  17. :filter-node-method="filterNode"
  18. :props='{label:"name",children:"childlist",value:"id"}'
  19. @node-click="handleNodeClick"
  20. >
  21. </el-tree>
  22. </el-scrollbar>
  23. </el-card>
  24. </el-col>
  25. <el-col :span="departdata[0].childlist.length>1?20:24">
  26. <el-card shadow="never">
  27. <yun-table
  28. :columns="columns"
  29. toolbar="refresh,add,del"
  30. ref="yuntable"
  31. order="asc"
  32. :auth="{
  33. add:{:$auth->check('app\\admin\\controller\\auth\\Admin','add')},
  34. edit:{:$auth->check('app\\admin\\controller\\auth\\Admin','edit')},
  35. del:{:$auth->check('app\\admin\\controller\\auth\\Admin','del')},
  36. multi:{:$auth->check('app\\admin\\controller\\auth\\Admin','multi')},
  37. }"
  38. :extend="extend">
  39. <template #formatter="{field,rows}">
  40. <div v-if="field=='groupids'">
  41. <template v-for="item in rows.groupids">
  42. <el-tag :type="item.status=='normal'?'primary':'info'" effect="dark" style="margin-right: 5px;">{{item.name}}</el-tag>
  43. </template>
  44. </div>
  45. {if $thirdLogin}
  46. <div v-if="field=='third'">
  47. <el-tag effect="dark" v-if="rows.third" style="margin-right: 5px;">{{rows.third.openname}}</el-tag>
  48. </div>
  49. {/if}
  50. </template>
  51. </yun-table>
  52. </el-card>
  53. </el-col>
  54. </el-row>
  55. </template>
  56. <script>
  57. import table from "@components/Table.js";
  58. import {inArray} from "@util.js";
  59. export default{
  60. components:{'YunTable':table},
  61. data:{
  62. search:'',
  63. departdata:Yunqi.data.departdata,
  64. extend:{
  65. index_url: 'auth/admin/index',
  66. add_url: 'auth/admin/add',
  67. edit_url: 'auth/admin/edit',
  68. del_url: 'auth/admin/del',
  69. multi_url: 'auth/admin/multi'
  70. },
  71. columns:[
  72. {checkbox: true,selectable:function (row,index){
  73. let r=true;
  74. for(let i in row.groupids){
  75. if(inArray(Yunqi.data.groupids,row.groupids[i].id)){
  76. r=false;
  77. }
  78. }
  79. if(Yunqi.data.isSuperAdmin){
  80. r=true;
  81. }
  82. if(row.id==1){
  83. r=false;
  84. }
  85. return r;
  86. }},
  87. {field: 'id',title: __('ID'),width:80,operate:false},
  88. {field: 'username', title: __('用户名'),operate:'like'},
  89. {field: 'nickname', title: __('昵称'),operate:'like'},
  90. {field: 'third', title: __('绑定微信'),operate:false,visible:Yunqi.data.thirdLogin?true:'none',formatter: Yunqi.formatter.slot},
  91. {field: 'mobile', title: __('手机号')},
  92. {
  93. field: 'groupids',
  94. title: __('所属组别'),
  95. formatter:Yunqi.formatter.slot,
  96. operate:false
  97. },
  98. {
  99. field: 'depart',
  100. formatter: function (data){
  101. return data?data.name:'';
  102. },
  103. title: __('所属部门'),
  104. operate: {form:'input',type:'hidden',filter:false}
  105. },
  106. {field: 'status', title: __('状态'),operate:false, searchList: {'normal': __('正常'),'hidden': __('隐藏')},formatter:function(data,row){
  107. let sw=Yunqi.formatter.switch;
  108. sw.activeValue='normal';
  109. sw.inactiveValue='hidden';
  110. sw.value=row.status;
  111. sw.disabled=false;
  112. for(let i in row.groupids){
  113. if(inArray(Yunqi.data.groupids,row.groupids[i].id)){
  114. sw.disabled=true;
  115. }
  116. }
  117. if(Yunqi.data.isSuperAdmin){
  118. sw.disabled=false;
  119. }
  120. if(row.id==1){
  121. sw.disabled=true;
  122. }
  123. return sw;
  124. }},
  125. {
  126. field: 'operate',
  127. title: __('操作'),
  128. width:100,
  129. action:{
  130. edit:function(row){
  131. if(Yunqi.data.isSuperAdmin){
  132. return true;
  133. }
  134. for(let i in row.groupids){
  135. if(inArray(Yunqi.data.groupids,row.groupids[i].id)){
  136. return false;
  137. }
  138. }
  139. return true;
  140. },
  141. del:function(row){
  142. if(row.id==1){
  143. return false;
  144. }
  145. if(Yunqi.data.isSuperAdmin){
  146. return true;
  147. }
  148. for(let i in row.groupids){
  149. if(inArray(Yunqi.data.groupids,row.groupids[i].id)){
  150. return false;
  151. }
  152. }
  153. return true;
  154. }
  155. }
  156. }
  157. ]
  158. },
  159. methods: {
  160. handleSearch:function (e){
  161. this.$refs.elTree.filter();
  162. },
  163. filterNode:function (value,data){
  164. return data.name.indexOf(this.search) !== -1;
  165. },
  166. handleNodeClick:function (e){
  167. let columns=this.columns;
  168. for(let i in columns){
  169. if(columns[i].field=='depart'){
  170. columns[i].operate.value=e.id;
  171. }
  172. }
  173. this.$refs.yuntable.reset();
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. </style>