pointParticulars.vue 8.69 KB
<template>
    <d2-container class="point-list">
        <template #header>
            <div class="header">
                <d2-search ref="showSearch"
                           class="show-search"
                           :form-data="showFormData"
                           label-width="150px"
                           :search-form="searchForm" />
                <div class="up-btns">
                    <el-button size="small"
                               type="primary"
                               @click="handleSearch">
                        查询
                    </el-button>
                    <el-button size="small" @click="handleReset">
                        重置
                    </el-button>
                </div>
            </div>
        </template>
        <div class="d2-container-content">
            <d2-table-header title="积分明细列表" title-class-name="tableHeaderTitle">
                <span style="margin-right: 10px">
                    <auth-button category="Button"
                                 :show-btn-ids="['9140204']" />
                </span>

                <auth-button category="Button" :show-btn-ids="['9140202']" />
            </d2-table-header>

            <d2-table ref="pointTable"
                      :before-search-fn="beforeSearchFn"
                      :get-list-api="getListApi"
                      :search-form="searchFormSearch"
                      :table-params="tableParams">
                <template #auth-button="scope">
                    <div>
                        <!-- 查看 -->
                        <span style="margin-right: 10px">
                            <auth-button :data="scope.scope" :show-btn-ids="['9140201']" />
                        </span>
                        <!-- 更换手机号 -->
                        <span style="margin-right: 10px">
                            <auth-button :data="scope.scope" :show-btn-ids="['9140205']" />
                        </span>
                    </div>
                </template>
            </d2-table>
        </div>
        <GoverningDialog v-if="governingVisible"
                         :visible.sync="governingVisible"
                         @handleClose="handleGoverningClose"
                         @handleConfirm="handleGoverningComfirm" />
        <ChangePhoneDialog v-if="changePhoneVisible"
                           :data-info="dataInfo"
                           :visible.sync="changePhoneVisible"
                           @handleClose="handleChangePhoneClose"
                           @handleConfirm="handleChangePhoneComfirm" />
    </d2-container>
</template>

<script>
import { exportScore, getScorePage, getShopMerchantList } from "@api/point";
import { deepClone, Util } from "@/common/util";
import ChangePhoneDialog from "./components/changePhoneDialog.vue";
import GoverningDialog from "./components/GoverningDialog";

export default {
	components: {
		GoverningDialog,
		ChangePhoneDialog,
	},

	data() {
		return {
			dataInfo: {},
			changePhoneVisible: false,
			governingVisible: false,
			searchForm: {
				staffName: "",
				staffPhone: "",
				merchantId: "",
				rewardTime: [],
				reviewTime: [],
				successTime: [],
			},
			searchFormSearch: {

			},
			getListApi: getScorePage,
			showFormData: [
				{
					label: "员工名称",
					name: "staffName",
					type: "input",
					isClear: true,
				},
				{
					label: "员工手机号",
					name: "staffPhone",
					type: "input",
					isClear: true,
				},
				{
					label: "门店名称",
					name: "merchantId",
					type: "select",
					optionList: [],
					optionId: "merchantId",
					optionLabel: "merchantName",
					optionsName: "merchantServiceList",
				},
				{
					label: "积分收益时间",
					name: "rewardTime",
					type: "datePicker",
					isClear: true,
					pickerOptions: "rangePickerOptions",
				},
				// {
				//   label: "积分兑换时间",
				//   name: "withdrawalTime",
				//   type: "datePicker",
				//   isClear: true,
				//   pickerOptions: "rangePickerOptions"
				// },
				{
					label: "积分付款时间",
					name: "reviewTime",
					type: "datePicker",
					isClear: true,
					pickerOptions: "rangePickerOptions",
				},
				{
					label: "积分到账时间",
					name: "successTime",
					type: "datePicker",
					isClear: true,
					pickerOptions: "rangePickerOptions",
				},
			],
			tableParams: {
				btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
				listName: "list",
				tableOption: {
					width: "150",
				},
				tableColumns: [
					{
						label: "门店名称",
						prop: "merchantName",
					},
					{
						label: "员工名称",
						prop: "staffName",
					},
					{
						label: "员工手机号",
						prop: "staffPhone",
					},
					{
						label: "当前积分",
						prop: "currentScore",
					},
					{
						label: "累计收益积分",
						prop: "totalRewardScore",
					},
					{
						label: "累计兑换积分",
						prop: "totalWithdrawalScore",
					},
					{
						label: "累计抵扣积分",
						prop: "totalDeductScore",
					},
				],
			},
			baseData: {
				merchantServiceList: [],
			},
		};
	},
	mounted() {
		getShopMerchantList({}).then((res) => {
			this.baseData.merchantServiceList = res;
			this.getOptionsList();
		});
	},
	methods: {
		handleChangePhone(data) {
			this.dataInfo = data;
			this.changePhoneVisible = !this.changePhoneVisible;
		},
		handleGoverningClose() {
			this.governingVisible = !this.governingVisible;
		},
		handleGoverningComfirm() {
			this.governingVisible = !this.governingVisible;
			this.handleSearch();
		},
		handleChangePhoneComfirm() {
			this.changePhoneVisible = !this.changePhoneVisible;
			this.handleSearch();
		},
		handleChangePhoneClose() {
			this.changePhoneVisible = !this.changePhoneVisible;
		},

		// 积分调整
		handleGoverning() {
			this.governingVisible = !this.governingVisible;
		},
		// 导出
		handleExport() {
			let params = {
				...this.searchFormSearch,
				currentPage: 1,
				pageSize: 9999,
			};

			exportScore(params).then((res) => {
				this.$open(res);
			});
		},
		handleDetail(data) {
			this.$router.push({
				name: "pointDetail",
				query: {
					staffId: data.staffId,
				},
			});
		},
		getOptionsList() {
			this.showFormData.forEach((item, index) => {
				if (item.type === "select") {
					if (
						this.baseData[item.optionsName].length
						&& this.baseData[item.optionsName][0][
							this.showFormData[index].optionLabel
						] !== "全部"
					) {
						const temp = {};
						temp[this.showFormData[index].optionId] = "";
						temp[this.showFormData[index].optionLabel] = "全部";
						this.baseData[item.optionsName].unshift(temp);
					}
					this.$set(
						this.showFormData[index],
						"optionList",
						this.baseData[item.optionsName],
					);
				}
			});
		},
		beforeSearchFn() {
			return new Promise((resolve) => {
				this.searchFormSearch = deepClone(this.searchForm);
				if (this.searchFormSearch.rewardTime && this.searchFormSearch.rewardTime.length) {
					this.searchFormSearch.rewardBeginTime
						= Util.dateFormate(
							this.searchFormSearch.rewardTime[0],
							"YYYY-MM-DD",
						) + " 00:00:00";
					this.searchFormSearch.rewardEndTime
						= Util.dateFormate(
							this.searchFormSearch.rewardTime[1],
							"YYYY-MM-DD",
						) + " 23:59:59";
				}
				if (this.searchFormSearch.reviewTime && this.searchFormSearch.reviewTime.length) {
					this.searchFormSearch.reviewBeginTime
						= Util.dateFormate(
							this.searchFormSearch.reviewTime[0],
							"YYYY-MM-DD",
						) + " 00:00:00";
					this.searchFormSearch.reviewEndTime
						= Util.dateFormate(
							this.searchFormSearch.reviewTime[1],
							"YYYY-MM-DD",
						) + " 23:59:59";
				}
				if (this.searchFormSearch.successTime && this.searchFormSearch.successTime.length) {
					this.searchFormSearch.successBeginTime
						= Util.dateFormate(
							this.searchFormSearch.successTime[0],
							"YYYY-MM-DD",
						) + " 00:00:00";
					this.searchFormSearch.successEndTime
						= Util.dateFormate(
							this.searchFormSearch.successTime[1],
							"YYYY-MM-DD",
						) + " 23:59:59";
				}
				delete this.searchFormSearch.rewardTime;
				delete this.searchFormSearch.successTime;
				delete this.searchFormSearch.reviewTime;
				resolve();
			});
		},
		handleSearch() {
			this.$refs.pointTable.refreshTable();
		},
		handleReset() {
			this.searchForm = {
				staffName: "",
				staffPhone: "",
				merchantId: "",
				rewardTime: [],
				reviewTime: [],
				successTime: [],
			};
			this.searchFormSearch = {};
			this.$refs.pointTable.refreshTable(true, true);
		},
	},
};
</script>

<style scoped lang="scss">
.d2-container-content {
	::v-deep {
		.tableHeaderTitle {
			font-weight: 500;
			font-size: 16px;
			color: #333333;
		}
	}
}
</style>