list.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <a-card size="small" :bordered="false" class="dealerAccountList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="经销商名称">
  9. <a-input id="dealerAccountList-name" v-model.trim="queryParam.org.name" allowClear placeholder="请输入经销商名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="管理员账号">
  14. <a-input id="dealerAccountList-loginName" v-model.trim="queryParam.loginName" allowClear placeholder="请输入管理员账号"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="账号状态">
  19. <v-select code="ENABLE_FLAG" id="dealerAccountList-loginFlag" v-model="queryParam.loginFlag" allowClear placeholder="请选择账号状态"></v-select>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="dealerAccountList-refresh">查询</a-button>
  24. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="dealerAccountList-reset">重置</a-button>
  25. </a-col>
  26. </a-row>
  27. </a-form>
  28. </div>
  29. <!-- 操作按钮 -->
  30. <div class="table-operator">
  31. <a-button id="dealerAccountList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  32. </div>
  33. <!-- 列表 -->
  34. <s-table
  35. class="sTable"
  36. ref="table"
  37. size="default"
  38. :rowKey="(record) => record.id"
  39. :columns="columns"
  40. :data="loadData"
  41. :scroll="{ x: 1310, y: tableHeight }"
  42. bordered>
  43. <!-- 账号状态 -->
  44. <template slot="loginFlag" slot-scope="text, record">
  45. <a-switch
  46. id="dealerAccountList-enable"
  47. checkedChildren="启用"
  48. unCheckedChildren="禁用"
  49. @change="changeStatus(record)"
  50. :checked="record.loginFlag == 1 ? true : false" />
  51. <!-- <span v-else>{{ record.loginFlag==1?'已启用':'已禁用' }}</span> -->
  52. </template>
  53. <!-- 操作 -->
  54. <template slot="action" slot-scope="text, record">
  55. <a-button size="small" type="link" class="button-info" @click="handleEdit(record)" id="dealerAccountList-edit-btn">编辑</a-button>
  56. <a-button size="small" type="link" class="button-success" @click="handleDetail(record)" id="dealerAccountList-detail-btn">详情</a-button>
  57. <a-button
  58. size="small"
  59. type="link"
  60. class="button-warning"
  61. @click="handleReset(record)"
  62. id="dealerAccountList-reset-btn">重置密码</a-button>
  63. </template>
  64. </s-table>
  65. <!-- 新增/编辑 -->
  66. <dealer-account-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="$refs.table.refresh(true)" @close="closeModal" />
  67. <!-- 查看 -->
  68. <dealer-account-detail-modal :openModal="openDetailModal" :itemId="itemId" @close="closeDetailModal" />
  69. </a-card>
  70. </template>
  71. <script>
  72. import { STable, VSelect } from '@/components'
  73. import dealerAccountEditModal from './editModal.vue'
  74. import dealerAccountDetailModal from './detailModal.vue'
  75. import { dealerUserList, dealerUserEnable, dealerUserResetP } from '@/api/dealer'
  76. export default {
  77. components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
  78. data () {
  79. return {
  80. tableHeight: 0,
  81. queryParam: { // 查询条件
  82. org: {
  83. name: ''
  84. },
  85. loginName: '',
  86. loginFlag: undefined
  87. },
  88. disabled: false, // 查询、重置按钮是否可操作
  89. columns: [
  90. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  91. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  92. { title: '经销商名称', dataIndex: 'org.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  93. { title: '管理员姓名', dataIndex: 'name', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  94. { title: '管理员账号', dataIndex: 'loginName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  95. { title: '授权用户数', dataIndex: 'org.childUserMaxNum', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  96. { title: '状态', scopedSlots: { customRender: 'loginFlag' }, width: 150, align: 'center' },
  97. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  98. ],
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. this.disabled = true
  102. if (this.tableHeight == 0) {
  103. this.tableHeight = window.innerHeight - 380
  104. }
  105. return dealerUserList(Object.assign(parameter, this.queryParam)).then(res => {
  106. const data = res.data
  107. const no = (data.pageNo - 1) * data.pageSize
  108. for (var i = 0; i < data.list.length; i++) {
  109. data.list[i].no = no + i + 1
  110. data.list[i].loginFlag = Number(data.list[i].loginFlag)
  111. }
  112. this.disabled = false
  113. return data
  114. })
  115. },
  116. openModal: false, // 新增编辑 弹框
  117. openDetailModal: false, // 详情 弹框
  118. itemId: '', // 当前id
  119. nowData: null, // 当前记录数据
  120. productBrandList: []
  121. }
  122. },
  123. methods: {
  124. // 重置
  125. resetSearchForm () {
  126. this.queryParam.org.name = ''
  127. this.queryParam.loginName = ''
  128. this.queryParam.loginFlag = undefined
  129. this.$refs.table.refresh(true)
  130. },
  131. // 新增/编辑
  132. handleEdit (row) {
  133. this.itemId = row ? row.id : null
  134. this.nowData = row || null
  135. this.openModal = true
  136. },
  137. // 详情
  138. handleDetail (row) {
  139. this.itemId = row ? row.id : null
  140. this.openDetailModal = true
  141. },
  142. // 关闭弹框
  143. closeModal () {
  144. this.itemId = ''
  145. this.nowData = null
  146. this.openModal = false
  147. },
  148. // 关闭详情弹框
  149. closeDetailModal () {
  150. this.itemId = ''
  151. this.openDetailModal = false
  152. },
  153. // 重置密码
  154. handleReset (row) {
  155. const _this = this
  156. this.$confirm({
  157. title: '提示',
  158. content: '重置密码后,新的密码会以短信形式发送到【管理员手机】,确定要重置吗?',
  159. centered: true,
  160. onOk () {
  161. dealerUserResetP({ id: row.id }).then(res => {
  162. if (res.status == 200) {
  163. _this.$message.success(res.message)
  164. _this.$refs.table.refresh()
  165. }
  166. })
  167. }
  168. })
  169. },
  170. // 启用 禁用
  171. changeStatus (record) {
  172. const params = {
  173. id: record.id,
  174. flag: record.loginFlag == 1 ? '0' : '1'
  175. }
  176. dealerUserEnable(params).then(res => {
  177. if (res.status == 200) {
  178. this.$message.success(res.message)
  179. this.$refs.table.refresh()
  180. } else {
  181. this.$refs.table.refresh()
  182. }
  183. })
  184. }
  185. }
  186. }
  187. </script>