list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="dealerAccountList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" id="dealerAccountList-form" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="经销商名称">
  10. <a-input id="dealerAccountList-name" v-model.trim="queryParam.org.name" allowClear placeholder="请输入经销商名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="管理员账号">
  15. <a-input id="dealerAccountList-loginName" v-model.trim="queryParam.loginName" allowClear placeholder="请输入管理员账号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="账号状态">
  20. <v-select code="ENABLE_FLAG" id="dealerAccountList-loginFlag" v-model="queryParam.loginFlag" allowClear placeholder="请选择账号状态"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="dealerAccountList-refresh">查询</a-button>
  25. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="dealerAccountList-reset">重置</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. </a-card>
  31. <a-card size="small" :bordered="false">
  32. <a-spin :spinning="spinning" tip="Loading...">
  33. <!-- 操作按钮 -->
  34. <div class="table-operator">
  35. <a-button id="dealerAccountList-add" type="primary" v-if="$hasPermissions('B_dealerAccount_add')" @click="handleEdit()">新增</a-button>
  36. </div>
  37. <!-- 列表 -->
  38. <s-table
  39. class="sTable fixPagination"
  40. ref="table"
  41. :style="{ height: tableHeight+70+'px' }"
  42. size="small"
  43. :rowKey="(record) => record.id"
  44. :columns="columns"
  45. :data="loadData"
  46. :pageSize="30"
  47. :scroll="{ y: tableHeight }"
  48. :defaultLoadData="false"
  49. bordered>
  50. <!-- 账号状态 -->
  51. <template slot="loginFlag" slot-scope="text, record">
  52. <a-switch
  53. :id="'dealerAccountList-enable'+record.id"
  54. v-if="$hasPermissions('B_dealerAccount_enable')"
  55. checkedChildren="启用"
  56. unCheckedChildren="禁用"
  57. @change="changeStatus(record)"
  58. :checked="record.loginFlag == 1 ? true : false" />
  59. <span v-else :style="{color:(record.loginFlag==1?'#00aa00':'#999')}"> {{ record.loginFlag==1? '已启用': '已禁用' }} </span>
  60. </template>
  61. <!-- 操作 -->
  62. <template slot="action" slot-scope="text, record">
  63. <a-button
  64. size="small"
  65. type="link"
  66. v-if="$hasPermissions('B_dealerAccount_edit')"
  67. class="button-info"
  68. @click="handleEdit(record)"
  69. :id="'dealerAccountList-edit-btn'+record.id">编辑</a-button>
  70. <a-button
  71. size="small"
  72. type="link"
  73. v-if="$hasPermissions('B_dealerAccount_detail')"
  74. class="button-success"
  75. @click="handleDetail(record)"
  76. :id="'dealerAccountList-detail-btn'+record.id">详情</a-button>
  77. <a-button
  78. size="small"
  79. type="link"
  80. v-if="$hasPermissions('B_dealerAccount_reset')"
  81. class="button-warning"
  82. @click="handleReset(record)"
  83. :id="'dealerAccountList-reset-btn'+record.id">重置密码</a-button>
  84. <span v-if="!$hasPermissions('B_dealerAccount_edit') && !$hasPermissions('B_dealerAccount_detail') && !$hasPermissions('B_dealerAccount_reset')">--</span>
  85. </template>
  86. </s-table>
  87. </a-spin>
  88. <!-- 新增/编辑 -->
  89. <dealer-account-edit-modal
  90. v-drag
  91. :openModal="openModal"
  92. :nowData="nowData"
  93. :itemId="itemId"
  94. @ok="$refs.table.refresh(true)"
  95. @close="closeModal" />
  96. <!-- 查看 -->
  97. <dealer-account-detail-modal v-drag :openModal="openDetailModal" :itemId="itemId" @close="closeDetailModal" />
  98. </a-card>
  99. </div>
  100. </template>
  101. <script>
  102. import { commonMixin } from '@/utils/mixin'
  103. // 组件
  104. import { STable, VSelect } from '@/components'
  105. import dealerAccountEditModal from './editModal.vue'
  106. import dealerAccountDetailModal from './detailModal.vue'
  107. // 接口
  108. import { dealerUserList, dealerUserEnable, dealerUserResetP } from '@/api/dealer'
  109. export default {
  110. name: 'DealerAccountManagementList',
  111. mixins: [commonMixin],
  112. components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
  113. data () {
  114. return {
  115. spinning: false,
  116. tableHeight: 0, // 表格高度
  117. disabled: false, // 查询、重置按钮是否可操作
  118. queryParam: { // 查询条件
  119. org: {
  120. name: ''// 经销商名称
  121. },
  122. loginName: '', // 管理员账号
  123. loginFlag: undefined// 状态
  124. },
  125. columns: [
  126. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  127. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center' },
  128. { title: '经销商名称', dataIndex: 'org.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  129. { title: '管理员姓名', dataIndex: 'name', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  130. { title: '管理员账号', dataIndex: 'loginName', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '授权用户数', dataIndex: 'org.childUserMaxNum', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '状态', scopedSlots: { customRender: 'loginFlag' }, width: '9%', align: 'center' },
  133. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  134. ],
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. this.disabled = true
  138. this.spinning = true
  139. return dealerUserList(Object.assign(parameter, this.queryParam)).then(res => {
  140. let data
  141. if (res.status == 200) {
  142. data = res.data
  143. // 计算表格序号
  144. const no = (data.pageNo - 1) * data.pageSize
  145. for (var i = 0; i < data.list.length; i++) {
  146. data.list[i].no = no + i + 1
  147. data.list[i].loginFlag = Number(data.list[i].loginFlag)
  148. }
  149. this.disabled = false
  150. }
  151. this.spinning = false
  152. return data
  153. })
  154. },
  155. openModal: false, // 新增编辑 弹框
  156. openDetailModal: false, // 详情 弹框
  157. itemId: '', // 当前id
  158. nowData: null // 当前记录数据
  159. }
  160. },
  161. methods: {
  162. // 重置
  163. resetSearchForm () {
  164. this.queryParam.org.name = ''
  165. this.queryParam.loginName = ''
  166. this.queryParam.loginFlag = undefined
  167. this.$refs.table.refresh(true)
  168. },
  169. // 新增/编辑
  170. handleEdit (row) {
  171. this.itemId = row ? row.id : ''
  172. this.nowData = row || null
  173. this.openModal = true
  174. },
  175. // 详情
  176. handleDetail (row) {
  177. this.itemId = row ? row.id : ''
  178. this.openDetailModal = true
  179. },
  180. // 关闭弹框
  181. closeModal () {
  182. this.itemId = ''
  183. this.nowData = null
  184. this.openModal = false
  185. },
  186. // 关闭详情弹框
  187. closeDetailModal () {
  188. this.itemId = ''
  189. this.openDetailModal = false
  190. },
  191. // 重置密码
  192. handleReset (row) {
  193. const _this = this
  194. this.$confirm({
  195. title: '提示',
  196. content: '重置密码后,新的密码会以短信形式发送到【管理员手机】,确定要重置吗?',
  197. centered: true,
  198. onOk () {
  199. _this.spinning = true
  200. dealerUserResetP({ id: row.id }).then(res => {
  201. if (res.status == 200) {
  202. _this.$message.success(res.message)
  203. _this.$refs.table.refresh()
  204. _this.spinning = false
  205. } else {
  206. _this.spinning = false
  207. }
  208. })
  209. }
  210. })
  211. },
  212. // 启用 禁用
  213. changeStatus (record) {
  214. const params = {
  215. id: record.id,
  216. flag: record.loginFlag == 1 ? '0' : '1'
  217. }
  218. this.spinning = true
  219. dealerUserEnable(params).then(res => {
  220. if (res.status == 200) {
  221. this.$message.success(res.message)
  222. this.$refs.table.refresh()
  223. this.spinning = false
  224. } else {
  225. this.$refs.table.refresh()
  226. this.spinning = false
  227. }
  228. })
  229. },
  230. // 初始化
  231. pageInit () {
  232. const _this = this
  233. this.$nextTick(() => { // 页面渲染完成后的回调
  234. _this.setTableH()
  235. })
  236. },
  237. // 计算表格高度
  238. setTableH () {
  239. const tableSearchH = this.$refs.tableSearch.offsetHeight
  240. this.tableHeight = window.innerHeight - tableSearchH - 240
  241. }
  242. },
  243. watch: {
  244. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  245. this.setTableH()
  246. }
  247. },
  248. mounted () {
  249. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  250. this.pageInit()
  251. this.resetSearchForm()
  252. }
  253. },
  254. activated () {
  255. // 如果是新页签打开,则重置当前页面
  256. if (this.$store.state.app.isNewTab) {
  257. this.pageInit()
  258. this.resetSearchForm()
  259. }
  260. // 仅刷新列表,不重置页面
  261. if (this.$store.state.app.updateList) {
  262. this.$refs.table.refresh()
  263. this.pageInit()
  264. }
  265. }
  266. }
  267. </script>