83925196146af8bc79497dc711998d87ef6c72ec.svn-base 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="1200"
  5. :visible="visible"
  6. @ok="handleOk"
  7. @cancel="handleCancel"
  8. cancelText="关闭">
  9. <div class="table-page-search-wrapper">
  10. <a-form layout="inline">
  11. <a-row :gutter="24">
  12. <a-col :span="6">
  13. <a-form-item label="账号">
  14. <a-input placeholder="请输入账号" v-model="queryParam.username"></a-input>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="6">
  18. <a-form-item label="性别">
  19. <a-select v-model="queryParam.sex" placeholder="请选择性别">
  20. <a-select-option value="">请选择性别查询</a-select-option>
  21. <a-select-option value="1">男性</a-select-option>
  22. <a-select-option value="2">女性</a-select-option>
  23. </a-select>
  24. </a-form-item>
  25. </a-col>
  26. <template v-if="toggleSearchStatus">
  27. <a-col :span="6">
  28. <a-form-item label="邮箱">
  29. <a-input placeholder="请输入邮箱" v-model="queryParam.email"></a-input>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :span="6">
  33. <a-form-item label="手机号码">
  34. <a-input placeholder="请输入手机号码" v-model="queryParam.phone"></a-input>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :span="6">
  38. <a-form-item label="状态">
  39. <a-select v-model="queryParam.status" placeholder="请选择状态">
  40. <a-select-option value="">请选择状态</a-select-option>
  41. <a-select-option value="1">正常</a-select-option>
  42. <a-select-option value="2">解冻</a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. </a-col>
  46. </template>
  47. <a-col :span="6" >
  48. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  49. <a-button type="primary" @click="searchByquery" icon="search">查询</a-button>
  50. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  51. <a @click="handleToggleSearch" style="margin-left: 8px">
  52. {{ toggleSearchStatus ? '收起' : '展开' }}
  53. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  54. </a>
  55. </span>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. <!-- update-begin author:kangxiaolin date:20190921 for:系统发送通知 用户多选失败 #513 -->
  61. <a-table
  62. ref="table"
  63. rowKey="id"
  64. :columns="columns"
  65. :dataSource="dataSource"
  66. :pagination="ipagination"
  67. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,onSelect:onSelect}"
  68. @change="handleTableChange"
  69. >
  70. <!-- update-end author:kangxiaolin date:20190921 for:系统发送通知 用户多选失败 #513 -->
  71. </a-table>
  72. </a-modal>
  73. </template>
  74. <script>
  75. import { filterObj } from '@/utils/util';
  76. import { getUserList } from '@/api/api'
  77. export default {
  78. name: "SelectUserListModal",
  79. components: {
  80. },
  81. data () {
  82. return {
  83. title:"选择用户",
  84. queryParam: {},
  85. columns: [{
  86. title: '用户账号',
  87. align:"center",
  88. dataIndex: 'username',
  89. fixed:'left',
  90. width:200
  91. },{
  92. title: '用户名称',
  93. align:"center",
  94. dataIndex: 'realname',
  95. },{
  96. title: '性别',
  97. align:"center",
  98. dataIndex: 'sex',
  99. customRender:function (text) {
  100. if(text==1){
  101. return "男";
  102. }else if(text==2){
  103. return "女";
  104. }else{
  105. return text;
  106. }
  107. }
  108. },{
  109. title: '手机号码',
  110. align:"center",
  111. dataIndex: 'phone'
  112. },{
  113. title: '邮箱',
  114. align:"center",
  115. dataIndex: 'email'
  116. },{
  117. title: '状态',
  118. align:"center",
  119. dataIndex: 'status',
  120. customRender:function (text) {
  121. if(text==1){
  122. return "正常";
  123. }else if(text==2){
  124. return "冻结";
  125. }else{
  126. return text;
  127. }
  128. }
  129. }],
  130. dataSource:[],
  131. ipagination:{
  132. current: 1,
  133. pageSize: 5,
  134. pageSizeOptions: ['5', '10', '20'],
  135. showTotal: (total, range) => {
  136. return range[0] + "-" + range[1] + " 共" + total + "条"
  137. },
  138. showQuickJumper: true,
  139. showSizeChanger: true,
  140. total: 0
  141. },
  142. isorter:{
  143. column: 'createTime',
  144. order: 'desc',
  145. },
  146. selectedRowKeys: [],
  147. selectionRows: [],
  148. visible:false,
  149. toggleSearchStatus:false,
  150. }
  151. },
  152. created() {
  153. this.loadData();
  154. },
  155. methods: {
  156. add (selectUser,userIds) {
  157. this.visible = true;
  158. this.edit(selectUser,userIds);
  159. },
  160. edit(selectUser,userIds){
  161. //控制台报错
  162. if(userIds&&userIds.length>0){
  163. this.selectedRowKeys = userIds.split(',');
  164. }else{
  165. this.selectedRowKeys = []
  166. }
  167. if(!selectUser){
  168. this.selectionRows=[]
  169. }else{
  170. var that=this;
  171. that.selectionRows=[];
  172. selectUser.forEach(function(record,index){
  173. console.log(record)
  174. that.selectionRows.push({id: that.selectedRowKeys[index],realname:record.label})
  175. })
  176. // this.selectionRows = selectUser;
  177. }
  178. },
  179. loadData (arg){
  180. if(arg===1){
  181. this.ipagination.current = 1;
  182. }
  183. let params = this.getQueryParams();//查询条件
  184. getUserList(params).then((res)=>{
  185. if(res.success){
  186. this.dataSource = res.result.records;
  187. this.ipagination.total = Number(res.result.total);
  188. }
  189. })
  190. },
  191. getQueryParams(){
  192. let param = Object.assign({}, this.queryParam,this.isorter);
  193. param.field = this.getQueryField();
  194. //--update-begin----author:scott---date:20190818------for:新建公告时指定特定用户翻页错误SelectUserListModal #379----
  195. // param.current = this.ipagination.current;
  196. // param.pageSize = this.ipagination.pageSize;
  197. param.pageNo = this.ipagination.current;
  198. param.pageSize = this.ipagination.pageSize;
  199. //--update-end----author:scott---date:20190818------for:新建公告时指定特定用户翻页错误SelectUserListModal #379---
  200. return filterObj(param);
  201. },
  202. getQueryField(){
  203. let str = "id,";
  204. for(let a = 0;a<this.columns.length;a++){
  205. str+=","+this.columns[a].dataIndex;
  206. }
  207. return str;
  208. },
  209. //--update-begin----author:kangxiaolin---date:20190921------for:系统发送通知 用户多选失败 #513----
  210. onSelectChange (selectedRowKeys) {
  211. this.selectedRowKeys = selectedRowKeys;
  212. },
  213. onSelect(record, selected){
  214. if(selected == true ){
  215. this.selectionRows.push(record);
  216. }else {
  217. this.selectionRows.forEach(function(item,index,arr){
  218. if(item.id == record.id) {
  219. arr.splice(index, 1);
  220. }
  221. })
  222. }
  223. //--update-end----author:kangxiaolin---date:20190921------for:系统发送通知 用户多选失败 #513----
  224. },
  225. searchReset(){
  226. let that = this;
  227. Object.keys(that.queryParam).forEach(function(key){
  228. that.queryParam[key] = '';
  229. });
  230. that.loadData(1);
  231. },
  232. handleTableChange(pagination, filters, sorter){
  233. //TODO 筛选
  234. if (Object.keys(sorter).length>0){
  235. this.isorter.column = sorter.field;
  236. this.isorter.order = "ascend"==sorter.order?"asc":"desc"
  237. }
  238. this.ipagination = pagination;
  239. this.loadData();
  240. },
  241. handleCancel () {
  242. this.selectionRows = [];
  243. this.selectedRowKeys = [];
  244. this.visible = false;
  245. },
  246. handleOk () {
  247. this.$emit("choseUser",this.selectionRows);
  248. this.handleCancel();
  249. },
  250. searchByquery(){
  251. this.loadData(1);
  252. },
  253. handleToggleSearch(){
  254. this.toggleSearchStatus = !this.toggleSearchStatus;
  255. },
  256. }
  257. }
  258. </script>
  259. <style scoped>
  260. .ant-card-body .table-operator{
  261. margin-bottom: 18px;
  262. }
  263. .ant-table-tbody .ant-table-row td{
  264. padding-top:15px;
  265. padding-bottom:15px;
  266. }
  267. .anty-row-operator button{margin: 0 5px}
  268. .ant-btn-danger{background-color: #ffffff}
  269. .ant-modal-cust-warp{height: 100%}
  270. .ant-modal-cust-warp .ant-modal-body{height:calc(100% - 110px) !important;overflow-y: auto}
  271. .ant-modal-cust-warp .ant-modal-content{height:90% !important;overflow-y: hidden}
  272. .anty-img-wrap{height:25px;position: relative;}
  273. .anty-img-wrap > img{max-height:100%;}
  274. </style>