list.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="dealerAccountList-wrap searchBottomSpace">
  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. </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"
  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">编辑</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">详情</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">重置密码</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. import { STable, VSelect } from '@/components'
  104. import dealerAccountEditModal from './editModal.vue'
  105. import dealerAccountDetailModal from './detailModal.vue'
  106. import { dealerUserList, dealerUserEnable, dealerUserResetP } from '@/api/dealer'
  107. export default {
  108. name: 'DealerAccountManagementList',
  109. mixins: [commonMixin],
  110. components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
  111. data () {
  112. return {
  113. spinning: false,
  114. tableHeight: 0,
  115. queryParam: { // 查询条件
  116. org: {
  117. name: ''
  118. },
  119. loginName: '',
  120. loginFlag: undefined
  121. },
  122. disabled: false, // 查询、重置按钮是否可操作
  123. columns: [
  124. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  125. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center' },
  126. { title: '经销商名称', dataIndex: 'org.name', width: '25%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  127. { title: '管理员姓名', dataIndex: 'name', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  128. { title: '管理员账号', dataIndex: 'loginName', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '授权用户数', dataIndex: 'org.childUserMaxNum', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '状态', scopedSlots: { customRender: 'loginFlag' }, width: '9%', align: 'center' },
  131. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  132. ],
  133. // 加载数据方法 必须为 Promise 对象
  134. loadData: parameter => {
  135. this.disabled = true
  136. this.spinning = true
  137. return dealerUserList(Object.assign(parameter, this.queryParam)).then(res => {
  138. let data
  139. if (res.status == 200) {
  140. data = res.data
  141. const no = (data.pageNo - 1) * data.pageSize
  142. for (var i = 0; i < data.list.length; i++) {
  143. data.list[i].no = no + i + 1
  144. data.list[i].loginFlag = Number(data.list[i].loginFlag)
  145. }
  146. this.disabled = false
  147. }
  148. this.spinning = false
  149. return data
  150. })
  151. },
  152. openModal: false, // 新增编辑 弹框
  153. openDetailModal: false, // 详情 弹框
  154. itemId: '', // 当前id
  155. nowData: null, // 当前记录数据
  156. productBrandList: []
  157. }
  158. },
  159. methods: {
  160. // 重置
  161. resetSearchForm () {
  162. this.queryParam.org.name = ''
  163. this.queryParam.loginName = ''
  164. this.queryParam.loginFlag = undefined
  165. this.$refs.table.refresh(true)
  166. },
  167. // 新增/编辑
  168. handleEdit (row) {
  169. this.itemId = row ? row.id : ''
  170. this.nowData = row || null
  171. this.openModal = true
  172. },
  173. // 详情
  174. handleDetail (row) {
  175. this.itemId = row ? row.id : ''
  176. this.openDetailModal = true
  177. },
  178. // 关闭弹框
  179. closeModal () {
  180. this.itemId = ''
  181. this.nowData = null
  182. this.openModal = false
  183. },
  184. // 关闭详情弹框
  185. closeDetailModal () {
  186. this.itemId = ''
  187. this.openDetailModal = false
  188. },
  189. // 重置密码
  190. handleReset (row) {
  191. const _this = this
  192. this.$confirm({
  193. title: '提示',
  194. content: '重置密码后,新的密码会以短信形式发送到【管理员手机】,确定要重置吗?',
  195. centered: true,
  196. onOk () {
  197. _this.spinning = true
  198. dealerUserResetP({ id: row.id }).then(res => {
  199. if (res.status == 200) {
  200. _this.$message.success(res.message)
  201. _this.$refs.table.refresh()
  202. _this.spinning = false
  203. } else {
  204. _this.spinning = false
  205. }
  206. })
  207. }
  208. })
  209. },
  210. // 启用 禁用
  211. changeStatus (record) {
  212. const params = {
  213. id: record.id,
  214. flag: record.loginFlag == 1 ? '0' : '1'
  215. }
  216. this.spinning = true
  217. dealerUserEnable(params).then(res => {
  218. if (res.status == 200) {
  219. this.$message.success(res.message)
  220. this.$refs.table.refresh()
  221. this.spinning = false
  222. } else {
  223. this.$refs.table.refresh()
  224. this.spinning = false
  225. }
  226. })
  227. },
  228. pageInit () {
  229. const _this = this
  230. this.$nextTick(() => { // 页面渲染完成后的回调
  231. _this.setTableH()
  232. })
  233. },
  234. setTableH () {
  235. const tableSearchH = this.$refs.tableSearch.offsetHeight
  236. this.tableHeight = window.innerHeight - tableSearchH - 250
  237. }
  238. },
  239. watch: {
  240. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  241. this.setTableH()
  242. }
  243. },
  244. mounted () {
  245. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  246. this.pageInit()
  247. this.resetSearchForm()
  248. }
  249. },
  250. activated () {
  251. // 如果是新页签打开,则重置当前页面
  252. if (this.$store.state.app.isNewTab) {
  253. this.pageInit()
  254. this.resetSearchForm()
  255. }
  256. // 仅刷新列表,不重置页面
  257. if (this.$store.state.app.updateList) {
  258. this.$refs.table.refresh()
  259. this.pageInit()
  260. }
  261. }
  262. }
  263. </script>