list.vue 8.9 KB

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