index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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-form-item label="消费操作" name="consumptionOperate">
  12. <a-select v-model:value="searchFormState.consumptionOperate" placeholder="消费操作查询" :options="consumptionOperateList">
  13. </a-select>
  14. </a-form-item>
  15. </a-col>
  16. <a-col :span="6">
  17. <a-form-item label="消费门店" name="orgId">
  18. <a-tree-select
  19. v-model:value="searchFormState.orgId"
  20. style="width: 100%"
  21. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  22. placeholder="请选择消费门店"
  23. allow-clear
  24. tree-default-expand-all
  25. :tree-data="treeData"
  26. :field-names="{
  27. children: 'children',
  28. label: 'name',
  29. value: 'id'
  30. }"
  31. selectable="false"
  32. tree-line
  33. />
  34. </a-form-item>
  35. </a-col>
  36. <template v-if="advanced">
  37. <a-col :span="6">
  38. <a-form-item label="消费日期:" name="consumptionTime">
  39. <a-range-picker v-model:value="searchFormState.consumptionTime" value-format="YYYY-MM-DD" show-date />
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :span="6">
  44. <a-button type="primary" html-type="submit" @click="tableRef.refresh()">查询</a-button>
  45. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  46. <a @click="toggleAdvanced" style="margin-left: 8px">
  47. {{ advanced ? '收起' : '展开' }}
  48. <component :is="advanced ? 'up-outlined' : 'down-outlined'" />
  49. </a>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. </a-card>
  54. <a-card :bordered="false">
  55. <s-table
  56. ref="tableRef"
  57. :columns="columns"
  58. :data="loadData"
  59. bordered
  60. :row-key="(record) => record.id"
  61. >
  62. <template #operator class="table-operator">
  63. <a-space>
  64. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('consumptionRecordAdd')">
  65. <template #icon><plus-outlined /></template>
  66. 新增
  67. </a-button>
  68. </a-space>
  69. </template>
  70. <template #bodyCell="{ column, record,index }">
  71. <template v-if="column.dataIndex === 'action'">
  72. <a-space>
  73. <a @click="formRef.onOpen(record)" v-if="hasPerm('consumptionRecordEdit')">编辑</a>
  74. <a-divider type="vertical" v-if="hasPerm(['consumptionRecordEdit', 'consumptionRecordDelete'], 'and')" />
  75. <a-popconfirm title="确定要删除吗?" @confirm="deleteConsumptionRecord(record)">
  76. <a-button type="link" danger size="small" v-if="hasPerm('consumptionRecordDelete')">删除</a-button>
  77. </a-popconfirm>
  78. </a-space>
  79. </template>
  80. <template v-if="column.dataIndex === 'consumptionOperate'">
  81. <a-tag
  82. :color="
  83. record.consumptionOperate === '1'
  84. ? 'orange'
  85. : record.consumptionOperate === '2'
  86. ? 'green'
  87. : record.consumptionOperate === '3'
  88. ? 'cyan'
  89. : 'purple'
  90. "
  91. >
  92. {{ $TOOL.dictTypeData('consumption_operate', record.consumptionOperate) }}
  93. </a-tag>
  94. </template>
  95. <template v-if="column.dataIndex === 'serial'">
  96. {{ index + 1 }}
  97. </template>
  98. </template>
  99. </s-table>
  100. </a-card>
  101. <Form ref="formRef" @successful="tableRef.refresh()" />
  102. </template>
  103. <script setup name="consumptionrecord">
  104. import { cloneDeep } from 'lodash-es'
  105. import Form from './form.vue'
  106. import consumptionRecordApi from '@/api/biz/consumptionRecordApi'
  107. import tool from '@/utils/tool'
  108. import bizOrgApi from '@/api/biz/bizOrgApi'
  109. const tableRef = ref()
  110. const formRef = ref()
  111. const searchFormRef = ref()
  112. let searchFormState = reactive({})
  113. // 查询区域显示更多控制
  114. const advanced = ref(false)
  115. const toggleAdvanced = () => {
  116. advanced.value = !advanced.value
  117. }
  118. const consumptionOperateList = tool.dictList('consumption_operate')
  119. const treeData = ref([])
  120. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  121. const columns = [
  122. {
  123. title: '序号',
  124. dataIndex: 'serial',
  125. align: 'center',
  126. width: 50
  127. },
  128. {
  129. title: '会员姓名',
  130. dataIndex: 'userName',
  131. align: 'center',
  132. },
  133. {
  134. title: '会员手机号',
  135. dataIndex: 'phone',
  136. align: 'center',
  137. },
  138. {
  139. title: '消费操作',
  140. dataIndex: 'consumptionOperate',
  141. align: 'center',
  142. },
  143. {
  144. title: '原账户糕点',
  145. dataIndex: 'accountBalance',
  146. align: 'center',
  147. },
  148. {
  149. title: '原账户积分',
  150. dataIndex: 'voucherBalance',
  151. align: 'center',
  152. },
  153. {
  154. title: '消费糕点或积分',
  155. dataIndex: 'consumptionMoney',
  156. align: 'center',
  157. },
  158. {
  159. title: '消费日期',
  160. dataIndex: 'consumptionTime',
  161. align: 'center',
  162. },
  163. {
  164. title: '消费门店',
  165. dataIndex: 'orgName',
  166. align: 'center',
  167. },
  168. {
  169. title: '说明',
  170. dataIndex: 'consumptionRemark',
  171. align: 'center',
  172. },
  173. ]
  174. // 操作栏通过权限判断是否显示
  175. /*if (hasPerm(['consumptionRecordEdit', 'consumptionRecordDelete'])) {
  176. columns.push({
  177. title: '操作',
  178. dataIndex: 'action',
  179. align: 'center',
  180. width: 150
  181. })
  182. }*/
  183. // 获取机构树并加入顶级
  184. bizOrgApi.orgTreeSelector().then((res) => {
  185. treeData.value = res
  186. })
  187. const selectedRowKeys = ref([])
  188. // 列表选择配置
  189. const options = {
  190. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  191. alert: {
  192. show: true,
  193. clear: () => {
  194. selectedRowKeys.value = ref([])
  195. }
  196. },
  197. rowSelection: {
  198. onChange: (selectedRowKey, selectedRows) => {
  199. selectedRowKeys.value = selectedRowKey
  200. }
  201. }
  202. }
  203. const loadData = (parameter) => {
  204. const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
  205. // planTime范围查询条件重载
  206. if (searchFormParam.consumptionTime) {
  207. searchFormParam.consumptionTimeBegin = searchFormParam.consumptionTime[0]
  208. searchFormParam.consumptionTimeEnd = searchFormParam.consumptionTime[1]
  209. delete searchFormParam.consumptionTime
  210. }
  211. return consumptionRecordApi.consumptionRecordPage(Object.assign(parameter, searchFormParam)).then((data) => {
  212. return data
  213. })
  214. }
  215. // 重置
  216. const reset = () => {
  217. searchFormRef.value.resetFields()
  218. tableRef.value.refresh(true)
  219. }
  220. // 删除
  221. const deleteConsumptionRecord = (record) => {
  222. let params = [
  223. {
  224. id: record.id
  225. }
  226. ]
  227. consumptionRecordApi.consumptionRecordDelete(params).then(() => {
  228. tableRef.value.refresh(true)
  229. })
  230. }
  231. // 批量删除
  232. const deleteBatchConsumptionRecord = (params) => {
  233. consumptionRecordApi.consumptionRecordDelete(params).then(() => {
  234. tableRef.value.clearRefreshSelected()
  235. })
  236. }
  237. </script>