index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="姓名" name="userName">
  7. <a-input v-model:value="searchFormState.userName" placeholder="姓名查询" allow-clear />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-button type="primary" html-type="submit" @click="tableRef.refresh()">查询</a-button>
  12. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  13. <!-- <a @click="toggleAdvanced" style="margin-left: 8px">
  14. {{ advanced ? '收起' : '展开' }}
  15. <component :is="advanced ? 'up-outlined' : 'down-outlined'" />
  16. </a>-->
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </a-card>
  21. <a-card :bordered="false">
  22. <s-table
  23. ref="tableRef"
  24. :columns="columns"
  25. :data="loadData"
  26. bordered
  27. :row-key="(record) => record.id"
  28. >
  29. <template #operator class="table-operator">
  30. <a-space>
  31. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('consumptionRecordAdd')">
  32. <template #icon><plus-outlined /></template>
  33. 新增
  34. </a-button>
  35. </a-space>
  36. </template>
  37. <template #bodyCell="{ column, record,index }">
  38. <template v-if="column.dataIndex === 'action'">
  39. <a-space>
  40. <a @click="detailForm.onOpen(record)" v-if="hasPerm('warnDetail')">详情</a>
  41. </a-space>
  42. </template>
  43. <template v-if="column.dataIndex === 'consumptionOperate'">
  44. <a-tag
  45. :color="
  46. record.consumptionOperate === '1'
  47. ? 'orange'
  48. : record.consumptionOperate === '2'
  49. ? 'green'
  50. : record.consumptionOperate === '3'
  51. ? 'cyan'
  52. : 'purple'
  53. "
  54. >
  55. {{ $TOOL.dictTypeData('consumption_operate', record.consumptionOperate) }}
  56. </a-tag>
  57. </template>
  58. <template v-if="column.dataIndex === 'serial'">
  59. {{ index + 1 }}
  60. </template>
  61. <template v-if="column.dataIndex === 'userStatus'">
  62. <a-switch
  63. :loading="loading"
  64. :checked="record.userStatus === 'ENABLE'"
  65. @change="editStatus(record)"
  66. v-if="hasPerm('bizUserUpdataStatus')"
  67. />
  68. <a-tag v-else :color="record.userStatus === 'ENABLE' ? 'blue' : 'pink'">{{
  69. $TOOL.dictTypeData('COMMON_STATUS', record.userStatus)
  70. }}</a-tag>
  71. <!-- <span v-else>{{ $TOOL.dictTypeData('COMMON_STATUS', record.userStatus) }}</span>-->
  72. </template>
  73. </template>
  74. </s-table>
  75. </a-card>
  76. <DetailForm ref="detailForm" @successful="tableRef.refresh()" />
  77. </template>
  78. <script setup name="consumptionrecord">
  79. import { cloneDeep } from 'lodash-es'
  80. import consumptionRecordApi from '@/api/biz/consumptionRecordApi'
  81. import tool from '@/utils/tool'
  82. import bizOrgApi from '@/api/biz/bizOrgApi'
  83. import DetailForm from './detail.vue'
  84. import Consumption from "@/views/biz/member/consumption.vue";
  85. import bizUserApi from '@/api/biz/bizUserApi'
  86. const tableRef = ref()
  87. const formRef = ref()
  88. const detailForm = ref()
  89. const searchFormRef = ref()
  90. let searchFormState = reactive({})
  91. // 查询区域显示更多控制
  92. const advanced = ref(false)
  93. const toggleAdvanced = () => {
  94. advanced.value = !advanced.value
  95. }
  96. const loading = ref(false)
  97. const consumptionOperateList = tool.dictList('consumption_operate')
  98. const treeData = ref([])
  99. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  100. const columns = [
  101. {
  102. title: '序号',
  103. dataIndex: 'serial',
  104. align: 'center',
  105. width: 50
  106. },
  107. {
  108. title: '推荐人姓名',
  109. dataIndex: 'name',
  110. align: 'center',
  111. },
  112. {
  113. title: '账号',
  114. dataIndex: 'account',
  115. align: 'center',
  116. },
  117. {
  118. title: '手机号',
  119. dataIndex: 'phone',
  120. align: 'center',
  121. },
  122. {
  123. title: '退款次数',
  124. dataIndex: 'count',
  125. align: 'center',
  126. },
  127. {
  128. title: '状态',
  129. dataIndex: 'userStatus',
  130. align: 'center',
  131. },
  132. {
  133. title: '操作',
  134. dataIndex: 'action',
  135. align: 'center',
  136. },
  137. ]
  138. // 操作栏通过权限判断是否显示
  139. /*if (hasPerm(['consumptionRecordEdit', 'consumptionRecordDelete'])) {
  140. columns.push({
  141. title: '操作',
  142. dataIndex: 'action',
  143. align: 'center',
  144. width: 150
  145. })
  146. }*/
  147. // 获取机构树并加入顶级
  148. bizOrgApi.orgTreeSelector().then((res) => {
  149. treeData.value = res
  150. })
  151. const selectedRowKeys = ref([])
  152. // 列表选择配置
  153. const options = {
  154. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  155. alert: {
  156. show: true,
  157. clear: () => {
  158. selectedRowKeys.value = ref([])
  159. }
  160. },
  161. rowSelection: {
  162. onChange: (selectedRowKey, selectedRows) => {
  163. selectedRowKeys.value = selectedRowKey
  164. }
  165. }
  166. }
  167. const loadData = (parameter) => {
  168. const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
  169. // planTime范围查询条件重载
  170. if (searchFormParam.consumptionTime) {
  171. searchFormParam.consumptionTimeBegin = searchFormParam.consumptionTime[0]
  172. searchFormParam.consumptionTimeEnd = searchFormParam.consumptionTime[1]
  173. delete searchFormParam.consumptionTime
  174. }
  175. return consumptionRecordApi.warnPage(Object.assign(parameter, searchFormParam)).then((data) => {
  176. return data
  177. })
  178. }
  179. // 重置
  180. const reset = () => {
  181. searchFormRef.value.resetFields()
  182. tableRef.value.refresh(true)
  183. }
  184. // 删除
  185. const deleteConsumptionRecord = (record) => {
  186. let params = [
  187. {
  188. id: record.id
  189. }
  190. ]
  191. consumptionRecordApi.consumptionRecordDelete(params).then(() => {
  192. tableRef.value.refresh(true)
  193. })
  194. }
  195. // 批量删除
  196. const deleteBatchConsumptionRecord = (params) => {
  197. consumptionRecordApi.consumptionRecordDelete(params).then(() => {
  198. tableRef.value.clearRefreshSelected()
  199. })
  200. }
  201. // 修改状态
  202. const editStatus = (record) => {
  203. loading.value = true
  204. if (record.userStatus === 'ENABLE') {
  205. bizUserApi
  206. .userDisableUser(record)
  207. .then(() => {
  208. tableRef.value.refresh()
  209. })
  210. .finally(() => {
  211. loading.value = false
  212. })
  213. } else {
  214. bizUserApi
  215. .userEnableUser(record)
  216. .then(() => {
  217. tableRef.value.refresh()
  218. })
  219. .finally(() => {
  220. loading.value = false
  221. })
  222. }
  223. }
  224. </script>