userManage.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  5. <a-row :gutter="48">
  6. <a-col :md="6" :sm="24">
  7. <a-form-item label="用户名称" :label-col="{ span: 3 }" :wrapper-col="{ span: 12 }">
  8. <a-input
  9. allowClear
  10. v-model.trim="queryParam.name"
  11. placeholder="请输入用户名称"
  12. id="userList-name"
  13. :maxLength="30"
  14. />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="手机号码" :label-col="{ span: 3 }" :wrapper-col="{ span: 12 }">
  19. <a-input
  20. allowClear
  21. v-model.trim="queryParam.phone"
  22. placeholder="请输入手机号码"
  23. :maxLength="11"
  24. id="userList-phone"
  25. />
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="合作商" :label-col="{ span:3 }" :wrapper-col="{ span:12}">
  30. <a-select
  31. placeholder="请选择"
  32. allowClear
  33. v-model="queryParam.orgCode"
  34. :showSearch="true"
  35. option-filter-prop="children"
  36. :filter-option="filterOption"
  37. @focus="handleFocus"
  38. @blur="handleBlur"
  39. @change="handleChange">
  40. <a-select-option v-for="item in optionData" :key="item.orgCode" :value="item.orgCode">{{ item.name }}</a-select-option>
  41. </a-select>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-button type="primary" @click="$refs.table.refresh(true)" id="userList-handSubmit" style="margin-right: 10px;">查询</a-button>
  46. <a-button type="" @click="reset" id="userList-reset">重置</a-button>
  47. </a-col>
  48. </a-row>
  49. <a-row :gutter="48" style="margin-top: 25px;">
  50. <a-col :md="6" :sm="24">
  51. <a-form-item label="用户状态" >
  52. <v-select code="ENABLE_FLAG" v-model="queryParam.loginFlag" allowClear placeholder="请选择状态" id="userList-check-enable-state"></v-select>
  53. </a-form-item>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. </div>
  58. <a-divider />
  59. <div class="table-operator">
  60. <a-button type="primary" icon="plus" @click="openModal" id="userList-openModal">新增</a-button>
  61. </div>
  62. <s-table
  63. ref="table"
  64. size="default"
  65. rowKey="id"
  66. :columns="columns"
  67. :data="loadData"
  68. bordered>
  69. <span slot="status" slot-scope="text, record">
  70. <a-switch
  71. checkedChildren="启用"
  72. unCheckedChildren="禁用"
  73. v-model="record.loginFlag"
  74. @change="changeFlagHandle(text, record)"
  75. id="userList-changeFlagHandle" />
  76. </span>
  77. <span slot="action" slot-scope="text, record">
  78. <a-icon
  79. type="unlock"
  80. title="重置密码"
  81. v-if="record.loginFlag==1"
  82. class="actionBtn icon-orange"
  83. @click="resetPassword(record)" />
  84. <a-icon
  85. type="edit"
  86. title="编辑"
  87. class="actionBtn icon-blues"
  88. @click="handleEdit(record)"
  89. />
  90. <a-icon
  91. type="delete"
  92. title="删除"
  93. class="actionBtn icon-red"
  94. v-if="record.loginFlag==0"
  95. @click="delect(record)"/>
  96. </span>
  97. </s-table>
  98. <userModal :visible="showModal" @refresh="$refs.table.refresh(true)" :itemId="itemId" @close="cancel"></userModal>
  99. </a-card>
  100. </template>
  101. <script>
  102. import {
  103. STable,
  104. VSelect
  105. } from '@/components'
  106. import userModal from './userModal.vue'
  107. import { sellerList, resetPSD, updateEnableStatus, getPowerUserList, delectUserPower } from '@/api/userManage.js'
  108. export default {
  109. name: 'UserManage',
  110. components: {
  111. STable,
  112. VSelect,
  113. userModal
  114. },
  115. data () {
  116. return {
  117. // 查询参数
  118. queryParam: {
  119. name: '',
  120. phone: '',
  121. loginFlag: '',
  122. orgCode: undefined
  123. },
  124. showModal: false,
  125. itemId: null, // 编辑行id
  126. optionData: [],
  127. // 表头
  128. columns: [{
  129. title: '序号',
  130. dataIndex: 'no',
  131. width: 60,
  132. align: 'center'
  133. },
  134. {
  135. title: '创建时间',
  136. dataIndex: 'createDate',
  137. width: 150,
  138. align: 'center'
  139. },
  140. {
  141. title: '用户名称',
  142. dataIndex: 'name',
  143. width: 100,
  144. align: 'center'
  145. },
  146. {
  147. title: '手机号码',
  148. dataIndex: 'phone',
  149. width: 100,
  150. align: 'center'
  151. },
  152. {
  153. title: '合作商',
  154. dataIndex: 'org.name',
  155. width: 100,
  156. align: 'center'
  157. },
  158. // {
  159. // title: '超级管理员',
  160. // width: '100',
  161. // align: 'center',
  162. // scopedSlots: {
  163. // customRender: 'status'
  164. // }
  165. // },
  166. // {
  167. // title: '角色',
  168. // width: '100',
  169. // align: 'center',
  170. // dataIndex: 'roleNames'
  171. // },
  172. {
  173. title: '状态',
  174. width: 100,
  175. align: 'center',
  176. scopedSlots: {
  177. customRender: 'status'
  178. }
  179. },
  180. {
  181. title: '操作',
  182. width: 100,
  183. align: 'center',
  184. scopedSlots: {
  185. customRender: 'action'
  186. }
  187. }
  188. ],
  189. // 加载数据方法 必须为 Promise 对象
  190. loadData: parameter => {
  191. return getPowerUserList(Object.assign(parameter, this.queryParam)).then(res => {
  192. const no = (res.data.pageNo - 1) * res.data.pageSize
  193. for (let i = 0; i < res.data.list.length; i++) {
  194. const _item = res.data.list[i]
  195. _item.no = no + i + 1
  196. _item.loginFlag = _item.loginFlag + '' === '1'
  197. }
  198. return res.data
  199. })
  200. }
  201. }
  202. },
  203. beforeRouteEnter (to, from, next) {
  204. next(vm => {
  205. vm.getSellerList()
  206. })
  207. },
  208. methods: {
  209. handleChange (value) {
  210. console.log(`selected ${value}`)
  211. },
  212. handleBlur () {
  213. console.log('blur')
  214. },
  215. handleFocus () {
  216. console.log('focus')
  217. },
  218. filterOption (input, option) {
  219. return (
  220. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  221. )
  222. },
  223. cancel () {
  224. this.itemId = null
  225. this.showModal = false
  226. },
  227. // 获取合作商数据
  228. getSellerList () {
  229. sellerList().then(res => {
  230. console.log(res, '-----合作商')
  231. if (res.status == 200) {
  232. this.optionData = res.data || []
  233. }
  234. })
  235. },
  236. // 刷新列表
  237. refreshTable () {
  238. this.$refs.table.refresh(true)
  239. },
  240. // 新建
  241. openModal () {
  242. this.showModal = true
  243. this.itemData = {}
  244. },
  245. // 重置
  246. reset () {
  247. this.queryParam.name = ''
  248. this.queryParam.phone = '',
  249. this.queryParam.loginFlag = ''
  250. this.queryParam.orgCode = undefined
  251. this.refreshTable()
  252. },
  253. // 重置密码
  254. resetPassword (row) {
  255. resetPSD({
  256. id: row.id
  257. }).then(res => {
  258. if (res.status == 200) {
  259. this.$message.success(res.message)
  260. }
  261. })
  262. },
  263. // 删除
  264. delect (row) {
  265. const _this = this
  266. this.$confirm({
  267. title: '警告',
  268. centered: true,
  269. content: '删除后无法恢复,确认删除?',
  270. okText: '确定',
  271. cancelText: '取消',
  272. onOk () {
  273. delectUserPower({
  274. id: row.id
  275. }).then(res => {
  276. if (res.status == 200) {
  277. _this.$message.success(res.message)
  278. _this.$refs.table.refresh()
  279. }
  280. })
  281. }
  282. })
  283. },
  284. // getBizStr (storeBizList) {
  285. // const str = []
  286. // storeBizList.forEach(item => {
  287. // str.push(item.bizTypeName)
  288. // })
  289. // return str.join(',')
  290. // },
  291. handleEdit (row) {
  292. console.log(row, 'row')
  293. this.itemId = row.id
  294. this.showModal = true
  295. },
  296. // 修改状态
  297. changeFlagHandle (text, record) {
  298. const _data = {
  299. id: record.id,
  300. flag: record.loginFlag ? '1' : '0'
  301. }
  302. updateEnableStatus(_data).then(res => {
  303. if (res.status + '' === '200') {
  304. this.$message.success(res.message)
  305. } else {
  306. record.loginFlag = !record.loginFlag
  307. }
  308. })
  309. }
  310. }
  311. }
  312. </script>
  313. <style scoped>
  314. .table-page-search-wrapper .ant-form-inline .ant-form-item {
  315. margin-bottom: 0;
  316. }
  317. .action-button {
  318. line-height: 40px;
  319. white-space: nowrap;
  320. padding: 5px 10px;
  321. background-color: #1890ff;
  322. border-radius: 4px;
  323. color: #fff;
  324. margin-right: 5px;
  325. }
  326. .red-text {
  327. background-color: red;
  328. }
  329. .reset-text {
  330. background-color: #31b50b;
  331. }
  332. </style>