123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <template>
- <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
- <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
- <a-row :gutter="24">
- <a-col :span="6">
- <a-form-item label="会员姓名" name="userName">
- <a-input v-model:value="searchFormState.userName" placeholder="会员姓名查询" allow-clear />
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item label="消费操作" name="consumptionOperate">
- <a-select v-model:value="searchFormState.consumptionOperate" placeholder="消费操作查询" :options="consumptionOperateList">
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :span="6">
- <a-form-item label="消费门店" name="orgId">
- <a-tree-select
- v-model:value="searchFormState.orgId"
- style="width: 100%"
- :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
- placeholder="请选择消费门店"
- allow-clear
- tree-default-expand-all
- :tree-data="treeData"
- :field-names="{
- children: 'children',
- label: 'name',
- value: 'id'
- }"
- selectable="false"
- tree-line
- />
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :span="6">
- <a-form-item label="消费日期:" name="consumptionTime">
- <a-range-picker v-model:value="searchFormState.consumptionTime" value-format="YYYY-MM-DD" show-date />
- </a-form-item>
- </a-col>
- </template>
- <a-col :span="6">
- <a-button type="primary" html-type="submit" @click="tableRef.refresh()">查询</a-button>
- <a-button style="margin: 0 8px" @click="reset">重置</a-button>
- <a @click="toggleAdvanced" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <component :is="advanced ? 'up-outlined' : 'down-outlined'" />
- </a>
- </a-col>
- </a-row>
- </a-form>
- </a-card>
- <a-card :bordered="false">
- <s-table
- ref="tableRef"
- :columns="columns"
- :data="loadData"
- bordered
- :row-key="(record) => record.id"
- >
- <template #operator class="table-operator">
- <a-space>
- <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('consumptionRecordAdd')">
- <template #icon><plus-outlined /></template>
- 新增
- </a-button>
- </a-space>
- </template>
- <template #bodyCell="{ column, record,index }">
- <template v-if="column.dataIndex === 'action'">
- <a-space>
- <a @click="formRef.onOpen(record)" v-if="hasPerm('consumptionRecordEdit')">编辑</a>
- <a-divider type="vertical" v-if="hasPerm(['consumptionRecordEdit', 'consumptionRecordDelete'], 'and')" />
- <a-popconfirm title="确定要删除吗?" @confirm="deleteConsumptionRecord(record)">
- <a-button type="link" danger size="small" v-if="hasPerm('consumptionRecordDelete')">删除</a-button>
- </a-popconfirm>
- </a-space>
- </template>
- <template v-if="column.dataIndex === 'consumptionOperate'">
- <a-tag
- :color="
- record.consumptionOperate === '1'
- ? 'orange'
- : record.consumptionOperate === '2'
- ? 'green'
- : record.consumptionOperate === '3'
- ? 'cyan'
- : 'purple'
- "
- >
- {{ $TOOL.dictTypeData('consumption_operate', record.consumptionOperate) }}
- </a-tag>
- </template>
- <template v-if="column.dataIndex === 'serial'">
- {{ index + 1 }}
- </template>
- </template>
- </s-table>
- </a-card>
- <Form ref="formRef" @successful="tableRef.refresh()" />
- </template>
- <script setup name="consumptionrecord">
- import { cloneDeep } from 'lodash-es'
- import Form from './form.vue'
- import consumptionRecordApi from '@/api/biz/consumptionRecordApi'
- import tool from '@/utils/tool'
- import bizOrgApi from '@/api/biz/bizOrgApi'
- const tableRef = ref()
- const formRef = ref()
- const searchFormRef = ref()
- let searchFormState = reactive({})
- // 查询区域显示更多控制
- const advanced = ref(false)
- const toggleAdvanced = () => {
- advanced.value = !advanced.value
- }
- const consumptionOperateList = tool.dictList('consumption_operate')
- const treeData = ref([])
- const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
- const columns = [
- {
- title: '序号',
- dataIndex: 'serial',
- align: 'center',
- width: 50
- },
- {
- title: '会员姓名',
- dataIndex: 'userName',
- align: 'center',
- },
- {
- title: '会员手机号',
- dataIndex: 'phone',
- align: 'center',
- },
- {
- title: '消费操作',
- dataIndex: 'consumptionOperate',
- align: 'center',
- },
- {
- title: '原账户糕点',
- dataIndex: 'accountBalance',
- align: 'center',
- },
- {
- title: '原账户积分',
- dataIndex: 'voucherBalance',
- align: 'center',
- },
- {
- title: '消费糕点或积分',
- dataIndex: 'consumptionMoney',
- align: 'center',
- },
- {
- title: '消费日期',
- dataIndex: 'consumptionTime',
- align: 'center',
- },
- {
- title: '消费门店',
- dataIndex: 'orgName',
- align: 'center',
- },
- {
- title: '说明',
- dataIndex: 'consumptionRemark',
- align: 'center',
- },
- ]
- // 操作栏通过权限判断是否显示
- /*if (hasPerm(['consumptionRecordEdit', 'consumptionRecordDelete'])) {
- columns.push({
- title: '操作',
- dataIndex: 'action',
- align: 'center',
- width: 150
- })
- }*/
- // 获取机构树并加入顶级
- bizOrgApi.orgTreeSelector().then((res) => {
- treeData.value = res
- })
- const selectedRowKeys = ref([])
- // 列表选择配置
- const options = {
- // columns数字类型字段加入 needTotal: true 可以勾选自动算账
- alert: {
- show: true,
- clear: () => {
- selectedRowKeys.value = ref([])
- }
- },
- rowSelection: {
- onChange: (selectedRowKey, selectedRows) => {
- selectedRowKeys.value = selectedRowKey
- }
- }
- }
- const loadData = (parameter) => {
- const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
- // planTime范围查询条件重载
- if (searchFormParam.consumptionTime) {
- searchFormParam.consumptionTimeBegin = searchFormParam.consumptionTime[0]
- searchFormParam.consumptionTimeEnd = searchFormParam.consumptionTime[1]
- delete searchFormParam.consumptionTime
- }
- return consumptionRecordApi.consumptionRecordPage(Object.assign(parameter, searchFormParam)).then((data) => {
- return data
- })
- }
- // 重置
- const reset = () => {
- searchFormRef.value.resetFields()
- tableRef.value.refresh(true)
- }
- // 删除
- const deleteConsumptionRecord = (record) => {
- let params = [
- {
- id: record.id
- }
- ]
- consumptionRecordApi.consumptionRecordDelete(params).then(() => {
- tableRef.value.refresh(true)
- })
- }
- // 批量删除
- const deleteBatchConsumptionRecord = (params) => {
- consumptionRecordApi.consumptionRecordDelete(params).then(() => {
- tableRef.value.clearRefreshSelected()
- })
- }
- </script>
|