list.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <a-card size="small" :bordered="false" class="dealerAccountList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @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. <!-- 操作按钮 -->
  31. <div class="table-operator">
  32. <a-button id="dealerAccountList-add" type="primary" v-if="$hasPermissions('B_dealerAccount_add')" class="button-error" @click="handleEdit()">新增</a-button>
  33. </div>
  34. <!-- 列表 -->
  35. <s-table
  36. class="sTable fixPagination"
  37. ref="table"
  38. :style="{ height: tableHeight+84.5+'px' }"
  39. size="small"
  40. :rowKey="(record) => record.id"
  41. :columns="columns"
  42. :data="loadData"
  43. :scroll="{ x: 1030, y: tableHeight }"
  44. bordered>
  45. <!-- 账号状态 -->
  46. <template slot="loginFlag" slot-scope="text, record">
  47. <a-switch
  48. id="dealerAccountList-enable"
  49. v-if="$hasPermissions('B_dealerAccount_enable')"
  50. checkedChildren="启用"
  51. unCheckedChildren="禁用"
  52. @change="changeStatus(record)"
  53. :checked="record.loginFlag == 1 ? true : false" />
  54. <span v-else :style="{color:(record.loginFlag==1?'#00aa00':'#999')}"> {{ record.loginFlag==1? '已启用': '已禁用' }} </span>
  55. </template>
  56. <!-- 操作 -->
  57. <template slot="action" slot-scope="text, record">
  58. <a-button
  59. size="small"
  60. type="link"
  61. v-if="$hasPermissions('B_dealerAccount_edit')"
  62. class="button-info"
  63. @click="handleEdit(record)"
  64. id="dealerAccountList-edit-btn">编辑</a-button>
  65. <a-button
  66. size="small"
  67. type="link"
  68. v-if="$hasPermissions('B_dealerAccount_detail')"
  69. class="button-success"
  70. @click="handleDetail(record)"
  71. id="dealerAccountList-detail-btn">详情</a-button>
  72. <a-button
  73. size="small"
  74. type="link"
  75. v-if="$hasPermissions('B_dealerAccount_reset')"
  76. class="button-warning"
  77. @click="handleReset(record)"
  78. id="dealerAccountList-reset-btn">重置密码</a-button>
  79. <span v-if="!$hasPermissions('B_dealerAccount_edit') && !$hasPermissions('B_dealerAccount_detail') && !$hasPermissions('B_dealerAccount_reset')">--</span>
  80. </template>
  81. </s-table>
  82. </a-spin>
  83. <!-- 新增/编辑 -->
  84. <dealer-account-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="$refs.table.refresh(true)" @close="closeModal" />
  85. <!-- 查看 -->
  86. <dealer-account-detail-modal :openModal="openDetailModal" :itemId="itemId" @close="closeDetailModal" />
  87. </a-card>
  88. </template>
  89. <script>
  90. import { STable, VSelect } from '@/components'
  91. import dealerAccountEditModal from './editModal.vue'
  92. import dealerAccountDetailModal from './detailModal.vue'
  93. import { dealerUserList, dealerUserEnable, dealerUserResetP } from '@/api/dealer'
  94. export default {
  95. components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
  96. data () {
  97. return {
  98. spinning: false,
  99. tableHeight: 0,
  100. queryParam: { // 查询条件
  101. org: {
  102. name: ''
  103. },
  104. loginName: '',
  105. loginFlag: undefined
  106. },
  107. disabled: false, // 查询、重置按钮是否可操作
  108. columns: [
  109. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  110. { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center' },
  111. { title: '经销商名称', dataIndex: 'org.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  112. { title: '管理员姓名', dataIndex: 'name', width: 180, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  113. { title: '管理员账号', dataIndex: 'loginName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  114. { title: '授权用户数', dataIndex: 'org.childUserMaxNum', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  115. { title: '状态', scopedSlots: { customRender: 'loginFlag' }, width: 100, align: 'center' },
  116. { title: '操作', scopedSlots: { customRender: 'action' }, width: 160, align: 'center', fixed: 'right' }
  117. ],
  118. // 加载数据方法 必须为 Promise 对象
  119. loadData: parameter => {
  120. this.disabled = true
  121. this.spinning = true
  122. return dealerUserList(Object.assign(parameter, this.queryParam)).then(res => {
  123. const data = res.data
  124. const no = (data.pageNo - 1) * data.pageSize
  125. for (var i = 0; i < data.list.length; i++) {
  126. data.list[i].no = no + i + 1
  127. data.list[i].loginFlag = Number(data.list[i].loginFlag)
  128. }
  129. this.disabled = false
  130. this.spinning = false
  131. return data
  132. })
  133. },
  134. openModal: false, // 新增编辑 弹框
  135. openDetailModal: false, // 详情 弹框
  136. itemId: '', // 当前id
  137. nowData: null, // 当前记录数据
  138. productBrandList: []
  139. }
  140. },
  141. methods: {
  142. // 重置
  143. resetSearchForm () {
  144. this.queryParam.org.name = ''
  145. this.queryParam.loginName = ''
  146. this.queryParam.loginFlag = undefined
  147. this.$refs.table.refresh(true)
  148. },
  149. // 新增/编辑
  150. handleEdit (row) {
  151. this.itemId = row ? row.id : ''
  152. this.nowData = row || null
  153. this.openModal = true
  154. },
  155. // 详情
  156. handleDetail (row) {
  157. this.itemId = row ? row.id : ''
  158. this.openDetailModal = true
  159. },
  160. // 关闭弹框
  161. closeModal () {
  162. this.itemId = ''
  163. this.nowData = null
  164. this.openModal = false
  165. },
  166. // 关闭详情弹框
  167. closeDetailModal () {
  168. this.itemId = ''
  169. this.openDetailModal = false
  170. },
  171. // 重置密码
  172. handleReset (row) {
  173. const _this = this
  174. this.$confirm({
  175. title: '提示',
  176. content: '重置密码后,新的密码会以短信形式发送到【管理员手机】,确定要重置吗?',
  177. centered: true,
  178. onOk () {
  179. _this.spinning = true
  180. dealerUserResetP({ id: row.id }).then(res => {
  181. if (res.status == 200) {
  182. _this.$message.success(res.message)
  183. _this.$refs.table.refresh()
  184. _this.spinning = false
  185. } else {
  186. _this.spinning = false
  187. }
  188. })
  189. }
  190. })
  191. },
  192. // 启用 禁用
  193. changeStatus (record) {
  194. const params = {
  195. id: record.id,
  196. flag: record.loginFlag == 1 ? '0' : '1'
  197. }
  198. this.spinning = true
  199. dealerUserEnable(params).then(res => {
  200. if (res.status == 200) {
  201. this.$message.success(res.message)
  202. this.$refs.table.refresh()
  203. this.spinning = false
  204. } else {
  205. this.$refs.table.refresh()
  206. this.spinning = false
  207. }
  208. })
  209. },
  210. setTableH () {
  211. const tableSearchH = this.$refs.tableSearch.offsetHeight
  212. this.tableHeight = window.innerHeight - tableSearchH - 235
  213. }
  214. },
  215. activated () {
  216. // 如果是新页签打开,则重置当前页面
  217. if (this.$store.state.app.isNewTab) {
  218. this.resetSearchForm()
  219. }
  220. },
  221. mounted () {
  222. const _this = this
  223. this.$nextTick(() => { // 页面渲染完成后的回调
  224. _this.setTableH()
  225. })
  226. }
  227. }
  228. </script>