|
@@ -0,0 +1,549 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <div class="filter-container">
|
|
|
+ <span>
|
|
|
+ <span> {{ $t("sales.table.0") }}: </span>
|
|
|
+ <span>
|
|
|
+ <el-input
|
|
|
+ class="search-item"
|
|
|
+ v-model="queryParams.model.name"
|
|
|
+ :placeholder="$t('sales.table.0')"
|
|
|
+ />
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <span> {{ $t("sales.table.6") }}: </span>
|
|
|
+ <span>
|
|
|
+ <el-select
|
|
|
+ v-model="queryParams.model.status"
|
|
|
+ :placeholder="$t('sales.table.6')"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+ <!--操作按钮-->
|
|
|
+ <span>
|
|
|
+ <el-button @click="search" plain type="primary">
|
|
|
+ {{ $t("table.search") }}
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="reset" plain type="warning">
|
|
|
+ {{ $t("table.reset") }}
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 添加修改删除-->
|
|
|
+ <el-row class="filter-container">
|
|
|
+ <el-col>
|
|
|
+ <!--添加按钮,调用add方法-->
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="medium"
|
|
|
+ @click="add"
|
|
|
+ >{{ $t("common.add") }}</el-button
|
|
|
+ >
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table
|
|
|
+ :data="tableData.records"
|
|
|
+ :key="tableKey"
|
|
|
+ @cell-click="cellClick"
|
|
|
+ @filter-change="filterChange"
|
|
|
+ @selection-change="onSelectChange"
|
|
|
+ @sort-change="sortChange"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ row-key="id"
|
|
|
+ ref="table"
|
|
|
+ style="width: 100%"
|
|
|
+ v-loading="loading"
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ type="index"
|
|
|
+ width="40px"
|
|
|
+ :reserve-selection="true"
|
|
|
+ />
|
|
|
+ <!-- 优惠劵名称 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.0')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="name"
|
|
|
+ min-width="100px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.name }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 优惠金额(元) -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.1')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="preferentialAmount"
|
|
|
+ min-width="80px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.preferentialAmount }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 数量 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.2')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="quantity"
|
|
|
+ min-width="100px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.quantity }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 使用条件 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.3')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="preferentialMethod"
|
|
|
+ min-width="200px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span
|
|
|
+ >{{
|
|
|
+ Number(scope.row.preferentialMethod) ? "历史" : "本月"
|
|
|
+ }}消费累计满:{{ scope.row.accumulatedAmount }}元
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 剩余 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.4')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="remainingQuantity"
|
|
|
+ min-width="100px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.remainingQuantity }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 结束时间 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.5')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="endDate"
|
|
|
+ min-width="150px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.endDate }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 状态 -->
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('sales.table.6')"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ align="center"
|
|
|
+ prop="status"
|
|
|
+ min-width="100px"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ Number(scope.row.status) ? "进行中" : "结束" }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('table.operation')"
|
|
|
+ align="center"
|
|
|
+ column-key="operation"
|
|
|
+ class-name="small-padding fixed-width"
|
|
|
+ min-width="100px"
|
|
|
+ >
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <i
|
|
|
+ @click="checkhistory(row)"
|
|
|
+ class="el-icon-document table-operation"
|
|
|
+ :title="$t('sales.history')"
|
|
|
+ style="color: #2dddf5"
|
|
|
+ />
|
|
|
+ <i
|
|
|
+ @click="edit(row)"
|
|
|
+ class="el-icon-edit table-operation"
|
|
|
+ :title="$t('common.edit')"
|
|
|
+ style="color: #2db7f5"
|
|
|
+ />
|
|
|
+ <i
|
|
|
+ @click="closequan(row)"
|
|
|
+ class="el-icon-switch-button table-operation"
|
|
|
+ :title="$t('sales.end')"
|
|
|
+ style="color: #d50"
|
|
|
+ />
|
|
|
+ <i
|
|
|
+ @click="singleDelete(row)"
|
|
|
+ class="el-icon-delete table-operation"
|
|
|
+ :title="$t('common.delete')"
|
|
|
+ style="color: #f50"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <pagination
|
|
|
+ :limit.sync="queryParams.size"
|
|
|
+ :page.sync="queryParams.current"
|
|
|
+ :total="Number(tableData.total)"
|
|
|
+ @pagination="fetch"
|
|
|
+ v-show="tableData.total > 0"
|
|
|
+ />
|
|
|
+ <place-edit
|
|
|
+ :dialog-visible="dialog.isVisible"
|
|
|
+ :type="dialog.type"
|
|
|
+ @close="editClose"
|
|
|
+ @success="editSuccess"
|
|
|
+ ref="edit"
|
|
|
+ />
|
|
|
+ <place-import
|
|
|
+ ref="import"
|
|
|
+ :dialog-visible="fileImport.isVisible"
|
|
|
+ :type="fileImport.type"
|
|
|
+ :action="fileImport.action"
|
|
|
+ accept=".xls,.xlsx"
|
|
|
+ @close="importClose"
|
|
|
+ @success="importSuccess"
|
|
|
+ />
|
|
|
+ <el-dialog
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="true"
|
|
|
+ title="领取记录"
|
|
|
+ width="38%"
|
|
|
+ top="50px"
|
|
|
+ :visible.sync="history.isVisible"
|
|
|
+ v-el-drag-dialog
|
|
|
+ v-loading="history.loading"
|
|
|
+ >
|
|
|
+ <el-scrollbar>
|
|
|
+ <el-table :data="history.data" style="width: 100%">
|
|
|
+ <el-table-column prop="createTime" :label="$t('sales.hisList.0')" width="180">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="memberId" :label="$t('sales.hisList.1')">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="memberName" :label="$t('sales.hisList.2')"> </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-scrollbar>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import Pagination from "@/components/Pagination";
|
|
|
+import elDragDialog from "@/directive/el-drag-dialog";
|
|
|
+import PlaceEdit from "./components/Edit";
|
|
|
+import { quan } from "@/api/adSomeelse";
|
|
|
+import PlaceImport from "@/components/zuihou/Import";
|
|
|
+import { loadEnums, initDicts, initQueryParams } from "@/utils/commons";
|
|
|
+import { CodeToText } from "element-china-area-data";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "PlaceManage",
|
|
|
+ directives: { elDragDialog },
|
|
|
+ components: { Pagination, PlaceEdit, PlaceImport },
|
|
|
+ filters: {
|
|
|
+ getCodeName(code) {
|
|
|
+ return CodeToText[code];
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ selectedOptions: [],
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ value: "",
|
|
|
+ name: this.$t("sales.statusList.0"),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: "1",
|
|
|
+ name: this.$t("sales.statusList.1"),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: "0",
|
|
|
+ name: this.$t("sales.statusList.2"),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ form: {
|
|
|
+ provinces: "",
|
|
|
+ pCode: "",
|
|
|
+ city: "",
|
|
|
+ cCode: "",
|
|
|
+ area: "",
|
|
|
+ aCode: "",
|
|
|
+ },
|
|
|
+
|
|
|
+ // 编辑
|
|
|
+ dialog: {
|
|
|
+ isVisible: false,
|
|
|
+ type: "add",
|
|
|
+ },
|
|
|
+ // 预览
|
|
|
+ history: {
|
|
|
+ isVisible: false,
|
|
|
+ data: [],
|
|
|
+ loading: true,
|
|
|
+ },
|
|
|
+ // 导入
|
|
|
+ fileImport: {
|
|
|
+ isVisible: false,
|
|
|
+ type: "import",
|
|
|
+ action: `${process.env.VUE_APP_BASE_API}/place/place/import`,
|
|
|
+ },
|
|
|
+ tableKey: 0,
|
|
|
+ queryParams: initQueryParams(),
|
|
|
+ selection: [],
|
|
|
+ loading: false,
|
|
|
+ tableData: {
|
|
|
+ total: 0,
|
|
|
+ },
|
|
|
+ // 枚举
|
|
|
+ enums: {},
|
|
|
+ // 字典
|
|
|
+ dicts: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ watch: {},
|
|
|
+ mounted() {
|
|
|
+ this.fetch();
|
|
|
+
|
|
|
+ // 初始化字典和枚举
|
|
|
+ const enumList = [];
|
|
|
+ const dictList = [];
|
|
|
+ loadEnums(enumList, this.enums, "place");
|
|
|
+ initDicts(dictList, this.dicts);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ codeToName(code) {
|
|
|
+ return CodeToText[code];
|
|
|
+ },
|
|
|
+
|
|
|
+ editOne() {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.selection.length > 1) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.mustOne"),
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.edit(this.selection[0]);
|
|
|
+ },
|
|
|
+
|
|
|
+ handleChange() {
|
|
|
+ // this.form.provinces = CodeToText[this.selectedOptions[0]]
|
|
|
+ // this.form.pCode = this.selection[0],
|
|
|
+ // this.form.city = CodeToText[this.selectedOptions[1]],
|
|
|
+ // this.form.cCode = this.selectedOptions[1],
|
|
|
+ // this.form.area = CodeToText[this.selectedOptions[2]]
|
|
|
+ // this.form.aCode = this.selectedOptions[2]
|
|
|
+
|
|
|
+ this.queryParams.model.plcPid = CodeToText[this.selectedOptions[0]];
|
|
|
+ this.queryParams.model.plcCid = CodeToText[this.selectedOptions[1]];
|
|
|
+ this.queryParams.model.plcAid = CodeToText[this.selectedOptions[2]];
|
|
|
+
|
|
|
+ console.log("省市县数据" + JSON.stringify(this.selectedOptions));
|
|
|
+ },
|
|
|
+
|
|
|
+ editClose() {
|
|
|
+ this.dialog.isVisible = false;
|
|
|
+ },
|
|
|
+ editSuccess() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ onSelectChange(selection) {
|
|
|
+ this.selection = selection;
|
|
|
+ },
|
|
|
+ search() {
|
|
|
+ this.fetch({
|
|
|
+ ...this.queryParams,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ reset() {
|
|
|
+ this.queryParams = initQueryParams();
|
|
|
+ this.selectedOptions = [];
|
|
|
+ this.$refs.table.clearSort();
|
|
|
+ this.$refs.table.clearFilter();
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ importExcel() {
|
|
|
+ this.fileImport.type = "upload";
|
|
|
+ this.fileImport.isVisible = true;
|
|
|
+ this.$refs.import.setModel(false);
|
|
|
+ },
|
|
|
+ importSuccess() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ importClose() {
|
|
|
+ this.fileImport.isVisible = false;
|
|
|
+ },
|
|
|
+ singleDelete(row) {
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ this.$refs.table.toggleRowSelection(row, true);
|
|
|
+ this.batchDelete();
|
|
|
+ },
|
|
|
+ batchDelete() {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$confirm(this.$t("tips.confirmDelete"), this.$t("common.tips"), {
|
|
|
+ confirmButtonText: this.$t("common.confirm"),
|
|
|
+ cancelButtonText: this.$t("common.cancel"),
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ const ids = this.selection.map((u) => u.id);
|
|
|
+ this.delete(ids);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.clearSelections();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ closequan(row) {
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ this.$refs.table.toggleRowSelection(row, true);
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$confirm("确定结束优惠劵活动吗?", this.$t("common.tips"), {
|
|
|
+ confirmButtonText: this.$t("common.confirm"),
|
|
|
+ cancelButtonText: this.$t("common.cancel"),
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ const ids = this.selection.map((u) => u.id);
|
|
|
+ quan.quanend(...ids).then((response) => {
|
|
|
+ const res = response.data;
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.$message({
|
|
|
+ message: "操作成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.clearSelections();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ clearSelections() {
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ },
|
|
|
+ delete(ids) {
|
|
|
+ quan.delete(...ids).then((response) => {
|
|
|
+ const res = response.data;
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.deleteSuccess"),
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ add() {
|
|
|
+ this.dialog.type = "add";
|
|
|
+ this.dialog.isVisible = true;
|
|
|
+ this.$refs.edit.setPlace(false);
|
|
|
+ // this.selectedOptions=[];
|
|
|
+ },
|
|
|
+ edit(row) {
|
|
|
+ // this.$refs.edit.setPlace({row, enums: this.enums, dicts: this.dicts});
|
|
|
+ this.$refs.edit.setPlace({ row });
|
|
|
+ this.dialog.type = "edit";
|
|
|
+ this.dialog.isVisible = true;
|
|
|
+ },
|
|
|
+ checkhistory(row) {
|
|
|
+ this.history.loading = true;
|
|
|
+ quan.quanHistory(row.id).then((response) => {
|
|
|
+ const res = response.data;
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.history.data = res.data;
|
|
|
+ this.history.loading = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.history.isVisible = true;
|
|
|
+ },
|
|
|
+ fetch(params = {}) {
|
|
|
+ this.loading = true;
|
|
|
+ this.queryParams.current = params.current
|
|
|
+ ? params.current
|
|
|
+ : this.queryParams.current;
|
|
|
+ this.queryParams.size = params.size ? params.size : this.queryParams.size;
|
|
|
+ quan
|
|
|
+ .page(this.queryParams)
|
|
|
+ .then((response) => {
|
|
|
+ const res = response.data;
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.tableData = res.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => (this.loading = false));
|
|
|
+ },
|
|
|
+ sortChange(val) {
|
|
|
+ this.queryParams.sort = val.prop;
|
|
|
+ this.queryParams.order = val.order;
|
|
|
+ if (this.queryParams.sort) {
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ filterChange(filters) {
|
|
|
+ for (const key in filters) {
|
|
|
+ if (key.includes(".")) {
|
|
|
+ const val = {};
|
|
|
+ val[key.split(".")[1]] = filters[key][0];
|
|
|
+ this.queryParams.model[key.split(".")[0]] = val;
|
|
|
+ } else {
|
|
|
+ this.queryParams.model[key] = filters[key][0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ cellClick(row, column) {
|
|
|
+ if (column["columnKey"] === "operation") {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let flag = false;
|
|
|
+ this.selection.forEach((item) => {
|
|
|
+ if (item.id === row.id) {
|
|
|
+ flag = true;
|
|
|
+ this.$refs.table.toggleRowSelection(row);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!flag) {
|
|
|
+ this.$refs.table.toggleRowSelection(row, true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped></style>
|