list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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-productBrandName" v-model.trim="queryParam.productBrandName" 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-productBrandName" v-model.trim="queryParam.productBrandName" 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-state" v-model="queryParam.state" 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="enableAction" slot-scope="text, record">
  45. <a-switch checkedChildren="启用" unCheckedChildren="禁用" v-model="record.enabledFlag" @change="changeFlagHandle(text, record)"/>
  46. <!-- <span v-else>{{ record.loginFlag==1?'已启用':'已禁用' }}</span> -->
  47. </template>
  48. <!-- 操作 -->
  49. <template slot="action" slot-scope="text, record">
  50. <a-button size="small" type="link" class="button-info" @click="handleEdit(record)" id="dealerAccountList-edit-btn">编辑</a-button>
  51. <a-button size="small" type="link" class="button-success" @click="handleDetail(record)" id="dealerAccountList-detail-btn">详情</a-button>
  52. <a-button
  53. size="small"
  54. type="link"
  55. class="button-warning"
  56. @click="handleReset(record)"
  57. id="dealerAccountList-reset-btn">重置密码</a-button>
  58. </template>
  59. </s-table>
  60. <!-- 新增/编辑 -->
  61. <dealer-account-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="$refs.table.refresh(true)" @close="closeModal" />
  62. <!-- 查看 -->
  63. <dealer-account-detail-modal :openModal="openDetailModal" :itemId="itemId" @close="closeDetailModal" />
  64. </a-card>
  65. </template>
  66. <script>
  67. import { STable, VSelect } from '@/components'
  68. import dealerAccountEditModal from './editModal.vue'
  69. import dealerAccountDetailModal from './detailModal.vue'
  70. import { dealerUserList } from '@/api/dealer'
  71. export default {
  72. components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
  73. data () {
  74. return {
  75. tableHeight: 0,
  76. queryParam: { // 查询条件
  77. // productBrandName: '', // 品牌名称
  78. // enabledFlag: undefined // 状态
  79. },
  80. disabled: false, // 查询、重置按钮是否可操作
  81. columns: [
  82. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  83. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  84. { title: '经销商名称', dataIndex: 'productBrandName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  85. { title: '管理员姓名', dataIndex: 'creatseDate', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  86. { title: '管理员账号', dataIndex: 'producstBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  87. { title: '授权用户数', dataIndex: 'productssBrandName', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '状态', scopedSlots: { customRender: 'enableAction' }, width: 150, align: 'center' },
  89. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  90. ],
  91. // 加载数据方法 必须为 Promise 对象
  92. loadData: parameter => {
  93. this.disabled = true
  94. if (this.tableHeight == 0) {
  95. this.tableHeight = window.innerHeight - 380
  96. }
  97. return dealerUserList(Object.assign(parameter, this.queryParam)).then(res => {
  98. const data = res.data
  99. const no = (data.pageNo - 1) * data.pageSize
  100. for (var i = 0; i < data.list.length; i++) {
  101. data.list[i].no = no + i + 1
  102. }
  103. this.disabled = false
  104. return data
  105. })
  106. },
  107. openModal: false, // 新增编辑 弹框
  108. openDetailModal: false, // 详情 弹框
  109. itemId: '', // 当前id
  110. nowData: null, // 当前记录数据
  111. productBrandList: []
  112. }
  113. },
  114. methods: {
  115. // 重置
  116. resetSearchForm () {
  117. this.queryParam.productBrandName = ''
  118. this.queryParam.enabledFlag = undefined
  119. this.$refs.table.refresh(true)
  120. },
  121. // 新增/编辑
  122. handleEdit (row) {
  123. this.itemId = row ? row.id : null
  124. this.nowData = row || null
  125. this.openModal = true
  126. },
  127. // 详情
  128. handleDetail (row) {
  129. this.itemId = row ? row.id : null
  130. this.openDetailModal = true
  131. },
  132. // 关闭弹框
  133. closeModal () {
  134. this.itemId = ''
  135. this.nowData = null
  136. this.openModal = false
  137. },
  138. // 关闭详情弹框
  139. closeDetailModal () {
  140. this.itemId = ''
  141. this.openDetailModal = false
  142. },
  143. // 重置密码
  144. handleReset (row) {
  145. const _this = this
  146. this.$confirm({
  147. title: '提示',
  148. content: '重置密码后,新的密码会以短信形式发送到【管理员手机】,确定要重置吗?',
  149. centered: true,
  150. onOk () {
  151. // salesDel({ id: row.id }).then(res => {
  152. // if (res.status == 200) {
  153. // _this.$message.success(res.message)
  154. // _this.$refs.table.refresh()
  155. // }
  156. // })
  157. }
  158. })
  159. },
  160. // 修改状态
  161. changeFlagHandle (text, record) {
  162. const _data = {
  163. id: record.id,
  164. flag: record.enabledFlag ? '1' : '0'
  165. }
  166. updateEnableStatus(_data).then(res => {
  167. if (res.status == 200) {
  168. this.$message.success(res.message)
  169. } else {
  170. record.enabledFlag = !record.enabledFlag
  171. }
  172. })
  173. }
  174. }
  175. }
  176. </script>