<template> <div class="consumptionOrder"> <div class="searchBox"> <div class="choosePeople" @click="choosePeople" style="width: 120px">选择消费人</div> <a-input style="width: 120px;margin-right: 20px;" placeholder="经办人" v-model="searchSource.agentName"/> <!-- <a-select placeholder="经办人" :allowClear="true" style="width: 120px;margin-right: 20px;" @change="selectAgent"> <a-select-option v-for="(item, index) in agentList" :key="index" :value="item.ddUserId">{{ item.name }}</a-select-option> </a-select> --> <a-select placeholder="状态" :allowClear="true" style="width: 120px;margin-right: 20px;" @change="selectHandlestatus"> <a-select-option value="SUCCESS">已消费</a-select-option> <a-select-option value="REFUND_SUCCESS">已退款</a-select-option> </a-select> <a-button type="primary" @click="search()">查询</a-button> </div> <div class="searchUserMessage" v-if="searchSource.UserMessage.emplId"> <div class="positionDiv"></div> <div class="clearUserMessage"><a href="javascript:;" @click="clearUserMessage">清除</a></div> <div class="userListBox"> <div> <img v-if="searchSource.UserMessage.avatar" :src="searchSource.UserMessage.avatar" :alt="searchSource.UserMessage.name"/> <img v-else :src="this.avatarCanvasFn(searchSource.UserMessage.name)" :alt="searchSource.UserMessage.name"> <span>{{ searchSource.UserMessage.name }}</span> </div> </div> </div> <a-table :columns="columns" :dataSource="OrderList" :pagination="pagination" @change="handleTableChange" rowKey="orderId"> <span slot="buyerName">姓名</span> <span slot="buyerSysDeptNameList" slot-scope="buyerSysDeptNameList, record"> <div v-if="buyerSysDeptNameList && buyerSysDeptNameList.length > 0"> <a-popover v-for="(item,indexOf) in buyerSysDeptNameList" :key="indexOf"> <template slot="content"> <p>{{record.buyerParentSysDeptList[indexOf].sysParentName}}</p> </template> <span class="deptModel">{{item}}</span> </a-popover> </div> </span> <span slot="agentName">经办人</span> <span slot="orderAmount" slot-scope="orderAmount"> {{ orderAmount.toFixed(2) }} </span> <span slot="mingPayOrderDetailList" slot-scope="mingPayOrderDetailList"> <a-popover> <template slot="content"> <div class="mingPayOrderDetailItem" v-for="item in mingPayOrderDetailList" :key="item.orderDetailId"> <div><img :src="item.productIcon" /></div> <div> <div>{{ item.productName }}</div> <div>X{{ item.productQuantity }}</div> </div> <div> ¥{{ item.productPrice.toFixed(2) }} </div> </div> </template> <span class="deptModel">{{mingPayOrderDetailList[0].productName}} ···</span> </a-popover> </span> <span slot="orderStatus" slot-scope="orderStatus"> <a-badge v-if="orderStatus === 'SUCCESS'" status="success" text="已消费" /> <a-badge v-else-if="orderStatus === 'REFUND_SUCCESS'" status="error" text="已退款" /> </span> <span slot="createTime">时间</span> </a-table> </div> </template> <script> import { config } from './../../../api/config.js' import { $http } from './../../../api/axios.js' export default { name: 'consumptionOrder', data () { return { searchSource: { UserMessage: { avatar: '', emplId: '', name: '' }, payStatus: '', agentName: '' }, agentList: [], pagination: { current: 1, defaultCurrent: 10, defaultPageSize: 10, hideOnSinglePage: true, total: 0 }, columns: [{ title: '消费人', dataIndex: 'buyerName' }, { title: '部门', dataIndex: 'buyerSysDeptNameList', scopedSlots: { customRender: 'buyerSysDeptNameList' }, width: '15%' }, { title: '经办人', dataIndex: 'agentName' }, { title: '消费总额(元)', dataIndex: 'orderAmount', scopedSlots: { customRender: 'orderAmount' } }, { title: '消费菜品', dataIndex: 'mingPayOrderDetailList', scopedSlots: { customRender: 'mingPayOrderDetailList' } }, { title: '状态', dataIndex: 'orderStatus', scopedSlots: { customRender: 'orderStatus' } }, { title: '时间', dataIndex: 'createTime' }], OrderList: [] } }, created: function () { // this.getAgentList() this.queryOrderList() }, methods: { handleTableChange (pagination, filters, sorter) { this.pagination.current = pagination.current this.queryOrderList() }, // 获取收银员列表 // getAgentList () { // let AgentData = { // userType: '1' // } // $http.get(`/mingpay/v1/isv/cashier/list_cashier_all`, AgentData).then((res) => { // this.agentList = res.data.data // }) // }, // 选人组件调用 choosePeople () { const _that = this config.ddready('ddchooseOne').then((res) => { this.searchSource.UserMessage = res[0] _that.queryOrderList() }) }, // 清理选择帅选人list clearUserMessage () { this.searchSource.UserMessage = { avatar: '', emplId: '', name: '' } }, // 用户头像处理 avatarCanvasFn (name) { let canvas = document.createElement('canvas') let con = canvas.getContext('2d') let ratio = this.getPixelRatio(con) canvas.style.width = 40 + 'px' canvas.style.height = 40 + 'px' canvas.width = 40 * ratio canvas.height = 40 * ratio con.scale(ratio, ratio) con.fillStyle = '#1890ff' con.fillRect(0, 0, 40, 40) con.fillStyle = '#ffffff' con.font = '12px Arial' con.textAlign = 'center' con.fillText(name, 20, 25) return canvas.toDataURL() }, // 头像模糊处理 getPixelRatio (context) { var backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1 return (window.devicePixelRatio || 1) / backingStore }, selectHandlestatus (value) { this.searchSource.payStatus = value }, selectAgent (value) { this.searchSource.agentName = value }, search () { this.pagination.current = 1 this.queryOrderList() }, queryOrderList () { let RechargeData = { pageNumber: 10, currentPage: this.pagination.current, agentName: this.searchSource.agentName, payStatus: this.searchSource.payStatus, buyerId: this.searchSource.UserMessage.emplId } $http.post(`/mingpay/v1/isv/order/list_order_page`, RechargeData).then((res) => { let data = res.data.data this.pagination.total = parseInt(data.total) this.OrderList = data.list }) } } } </script> <style lang="less" scoped> .searchBox{ display: flex; margin-bottom: 20px; } .searchBox > input { margin-right: 20px; max-width: 180px; } .operationTable a{ margin-right: 8px; } .searchUserMessage{ width: 100%; display: flex; flex-direction: column; justify-content: center; font-size: 12px; padding: 8px 8px; border: 1px solid #cccccc; margin-bottom: 15px; border-radius: 8px; position: relative; } .searchUserMessage img{ width: 32px; height: 32px; border-radius: 50%; margin-bottom: 8px; } .positionDiv{ height: 12px; width: 12px; transform:rotate(45deg); border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; position: absolute; top: -7px; left: 30px; background: white; z-index: 99; } .clearUserMessage{ position: absolute; right: 10px; } .userListBox{ text-align: center; display: flex; } .userListBox>div>img{ display: block; text-align: center; } .choosePeople{ line-height: 32px; width: 120px; margin-right: 20px; padding-left: 11px; height: 32px; border: 1px solid #d9d9d9; border-radius: 4px; color: #bfbfbf; cursor: pointer; } .choosePeople:hover{ border: 1px solid #1890ff; } .deptModel{ background: #F2F0F0; margin: 5px 0; margin-right: 5px; padding: 2px 4px; border-radius: 3px; line-height: 2; } .ant-table-tbody > tr:hover .deptModel{ background: #CAEEFF; } .ant-popover-inner-content>p{ margin: 0; } .mingPayOrderDetailItem{ display: flex; width: 190px; margin: 15px 0; } .mingPayOrderDetailItem > div:nth-of-type(1){ width: 40px; height: 40px; overflow: hidden; } .mingPayOrderDetailItem > div:nth-of-type(1) img{ width: 40px; height: 40px; display: block; } .mingPayOrderDetailItem > div:nth-of-type(2){ height: 40px; width: 80px; font-size: 14px; margin-left: 10px; } .mingPayOrderDetailItem > div:nth-of-type(2) div:nth-of-type(1){ overflow: hidden;/*超出部分隐藏*/ text-overflow:ellipsis;/* 超出部分显示省略号 */ white-space: nowrap;/*规定段落中的文本不进行换行 */ width: 80px;/*需要配合宽度来使用*/ color: black; } .mingPayOrderDetailItem > div:nth-of-type(2) div:nth-of-type(2){ overflow: hidden;/*超出部分隐藏*/ text-overflow:ellipsis;/* 超出部分显示省略号 */ white-space: nowrap;/*规定段落中的文本不进行换行 */ width: 80px;/*需要配合宽度来使用*/ color: #868686; font-size: 12px; } .mingPayOrderDetailItem > div:nth-of-type(3){ height: 40px; text-align: right; flex: 1; color: black; } </style>