devilhell 2 gadi atpakaļ
vecāks
revīzija
31b2568096

+ 66 - 4
imcs-bt-fe/imcs-bt-fe/imcs-ui/src/api/adSomeelse.js

@@ -1,9 +1,9 @@
 /*
  * @Author: wangj
  * @Date: 2023-02-27 20:58:17
- * @LastEditors: @EXtreeDesigner
- * @LastEditTime: 2023-03-05 16:40:18
- * @FilePath: \imcs-ui\src\api\adSomeelse.js
+ * @LastEditors: wangj
+ * @LastEditTime: 2023-03-11 09:54:30
+ * @FilePath: \code\src\api\adSomeelse.js
  * @Description: 异常中心-设备异常、广告管理、优惠券管理
  */
 import axiosApi from './AxiosApi.js'
@@ -48,7 +48,6 @@ const apiList = {
     method: 'POST',
     url: `/file/attachment/upload`,
     formData:1
-    // url:'/api/file/attachment/upload'
   },
   epuip: {
     method: 'POST',
@@ -66,6 +65,34 @@ const apiList = {
     url: `/authority/advertisement`,
     method: 'DELETE'
   },
+  // 营销中心-优惠券管理
+  quan: {
+    url: `/authority/coupon/page`,
+    method: 'POST'
+  },
+  quanadd:{
+    method: 'POST',
+    url: `/authority/coupon/saveCoupon`
+  },
+  quanedit: {
+    method: 'POST',
+    url: `/authority/coupon/updateCoupon`
+  },
+  quandelete: {
+    url: `/authority/coupon/delete/`,
+    // /authority/coupon/delete/{couponId}
+    method: 'DELETE'
+  },
+  quanend:{
+    url: `/authority/coupon/finish/`,
+    // /authority/coupon/finish/{couponId}
+    method: 'GET'
+  },
+  quanHistory:{
+    url: `/authority/coupon/memberCouponList/`,
+    // /authority/coupon/memberCouponList/{couponId}
+    method: 'GET'
+  }
 }
 
 export const bug = {
@@ -155,4 +182,39 @@ export const ad = {
       data
     })
   }
+}
+const getconfig = (apiInfo,id) => {
+  const config = JSON.parse(JSON.stringify(apiInfo))
+  config.url += id
+  return config
+}
+export const quan = {
+  page (data) {
+    return axiosApi({
+      ...apiList.quan,
+      data,
+    })
+  },
+  save (data) {
+    return axiosApi({
+      ...apiList.quanadd,
+      data,
+    })
+  },
+  update (data) {
+    return axiosApi({
+      ...apiList.quanedit,
+      data,
+    })
+  },
+  delete (data) {
+    return axiosApi(getconfig(apiList.quandelete,data))
+  },
+  quanend(data) {
+    return axiosApi(getconfig(apiList.quanend,data))
+  },
+  
+  quanHistory(data) {
+    return axiosApi(getconfig(apiList.quanHistory,data))
+  },
 }

+ 31 - 3
imcs-bt-fe/imcs-bt-fe/imcs-ui/src/lang/zh/adsel.js

@@ -1,9 +1,9 @@
 /*
  * @Author: wangj
  * @Date: 2023-03-02 17:41:19
- * @LastEditors: @EXtreeDesigner
- * @LastEditTime: 2023-03-05 13:05:00
- * @FilePath: \imcs-ui\src\lang\zh\adsel.js
+ * @LastEditors: wangj
+ * @LastEditTime: 2023-03-11 10:13:44
+ * @FilePath: \code\src\lang\zh\adsel.js
  * @Description: ad and somthing else:广告、异常、优惠券
  */
 export default {
@@ -68,4 +68,32 @@ export default {
       ,'投放结束时间'
     ]
   }
+  // 营销中心-优惠券管理
+  ,sales:{
+    table:[
+      '优惠劵名称'
+      ,'优惠金额(元)'
+      ,'数量'
+      ,'使用条件'
+      ,'剩余'
+      ,'结束时间'
+      ,'状态'
+    ],
+    history:'领取记录',
+    end:'结束'
+    ,statusList:['全部','进行中','结束'],
+    add:[
+      '优惠劵名称'
+      ,'结束时间'
+      ,'数量'
+      ,'优惠金额'
+      ,'使用条件'
+      ,'说明'
+    ],
+    hisList:[
+      '领取时间'
+      ,'会员id'
+      ,'会员名称'
+    ]
+  }
 }

+ 549 - 0
imcs-bt-fe/imcs-bt-fe/imcs-ui/src/views/zuihou/sales/volume/Index.vue

@@ -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>

+ 317 - 0
imcs-bt-fe/imcs-bt-fe/imcs-ui/src/views/zuihou/sales/volume/components/Edit.vue

@@ -0,0 +1,317 @@
+<!--
+ * @Author: wangj
+ * @Date: 2023-02-19 13:54:14
+ * @LastEditors: wangj
+ * @LastEditTime: 2023-03-11 21:55:42
+ * @FilePath: \code\src\views\zuihou\sales\volume\components\Edit.vue
+ * @Description: 
+-->
+<template>
+  <el-dialog
+    :close-on-click-modal="false"
+    :close-on-press-escape="true"
+    :title="title"
+    :type="type"
+    :visible.sync="isVisible"
+    :width="width"
+    top="50px"
+    v-el-drag-dialog
+  >
+    <el-form
+      :model="place"
+      :rules="rules"
+      label-position="right"
+      label-width="180px"
+      ref="form"
+    >
+      <!-- 优惠劵名称 -->
+      <el-form-item :label="$t('sales.add.0')" prop="name">
+        <el-input v-model.trim="place.name" :placeholder="$t('sales.add.0')" />
+      </el-form-item>
+      <!-- 结束时间 -->
+      <el-form-item :label="$t('sales.add.1')" prop="endDate">
+        <!-- <el-input
+          v-model.trim="place.contactName"
+          :placeholder="$t('sales.add.1')"
+        /> -->
+        <el-date-picker
+          class="from-item"
+          v-model="place.endDate"
+          type="datetime"
+          :value-format="'yyyy-MM-dd hh:mm:ss'"
+          placeholder="选择日期时间"
+        >
+        </el-date-picker>
+      </el-form-item>
+      <!-- 数量 -->
+      <el-form-item :label="$t('sales.add.2')" prop="quantity">
+        <el-input
+          v-model.trim="place.quantity"
+          :placeholder="$t('sales.add.2')"
+          type="number"
+        />
+      </el-form-item>
+      <!-- 优惠金额 -->
+      <el-form-item :label="$t('sales.add.3')" prop="preferentialAmount">
+        <el-input
+          v-model.trim="place.preferentialAmount"
+          :placeholder="$t('sales.add.3')"
+          @blur="inputmoney($event,'preferentialAmount')"
+        />
+      </el-form-item>
+      <!-- 使用条件 -->
+      <el-form-item :label="$t('sales.add.4')" prop="plcStatus">
+        <template>
+          <el-select
+            style="width: 5.5em"
+            v-model="place.preferentialMethod"
+            placeholder="请选择"
+            :disabled="type!=='add'"
+          >
+            <el-option
+              v-for="item in options"
+              :key="item.value"
+              :label="item.name"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
+          消费累计满
+          <el-input
+            style="width: 8em"
+            v-model.trim="place.accumulatedAmount"
+            @blur="inputmoney($event,'accumulatedAmount')"
+          />元
+        </template>
+      </el-form-item>
+      <!-- 说明 -->
+      <el-form-item :label="$t('sales.add.5')" prop="remark">
+        <el-input
+          type="textarea"
+          v-model="place.remark"
+          :placeholder="$t('sales.add.5')"
+          maxlength="255"
+        />
+      </el-form-item>
+    </el-form>
+    <div class="dialog-footer" slot="footer">
+      <el-button @click="isVisible = false" plain type="warning">
+        {{ $t("common.cancel") }}
+      </el-button>
+      <el-button
+        @click="submitForm"
+        :disabled="confirmDisabled"
+        plain
+        type="primary"
+      >
+        {{ $t("common.confirm") }}
+      </el-button>
+    </div>
+  </el-dialog>
+</template>
+<script>
+import elDragDialog from "@/directive/el-drag-dialog";
+import { quan } from "@/api/adSomeelse";
+
+export default {
+  name: "PlaceEdit",
+  directives: { elDragDialog },
+  components: {},
+  props: {
+    dialogVisible: {
+      type: Boolean,
+      default: false,
+    },
+    type: {
+      type: String,
+      default: "add",
+    },
+  },
+  data() {
+    return {
+      confirmDisabled: false,
+      place: this.initPlace(),
+      screenWidth: 0,
+      width: this.initWidth(),
+      rules: {
+        name: [
+          {
+            required: true,
+            message: this.$t("rules.require"),
+            trigger: "blur",
+          },
+        ],
+        preferentialAmount: [
+          {
+            required: true,
+            message: this.$t("rules.require"),
+            trigger: "blur",
+          },
+        ],        
+        quantity: [
+          {
+            required: true,
+            message: this.$t("rules.require"),
+            trigger: "blur",
+          },
+        ],        
+        accumulatedAmount: [
+          {
+            required: true,
+            message: this.$t("rules.require"),
+            trigger: "blur",
+          },
+        ],
+        endDate: [
+          {
+            required: true,
+            message: this.$t("rules.require"),
+            trigger: "blur",
+          },
+        ],
+      },
+      options: [
+        {
+          value: "0",
+          name: "本月",
+        },
+        {
+          value: "1",
+          name: "累计",
+        },
+      ],
+    };
+  },
+  computed: {
+    isVisible: {
+      get() {
+        return this.dialogVisible;
+      },
+      set() {
+        this.close();
+        this.reset();
+      },
+    },
+    title() {
+      return this.$t("common." + this.type);
+    },
+    res: function () {
+      const r = JSON.parse(JSON.stringify(this.place));
+      r.regionIds = this.place.regionIds.join();
+      return r;
+    },
+  },
+  watch: {},
+  mounted() {
+    window.onresize = () => {
+      return (() => {
+        this.width = this.initWidth();
+      })();
+    };
+  },
+  methods: {
+    setPlace(e) {
+      if (e) {
+        const { row } = e;
+        this.place = JSON.parse(JSON.stringify(row));
+      } else {
+        this.place = this.initPlace();
+      }
+    },
+    initPlace() {
+      return {
+        name: "",
+        preferentialAmount: "",
+        quantity: "",
+        preferentialMethod: "0",
+        accumulatedAmount: "0",
+        endDate: "",
+        remark: "",
+      };
+    },
+    inputmoney(e,key) {
+      const res = Number(parseFloat(e.target.value).toFixed(2));
+      this.place[key] = isNaN(res) ? "0" : res.toString();
+    },
+    initWidth() {
+      this.screenWidth = document.body.clientWidth;
+      if (this.screenWidth < 991) {
+        return "90%";
+      } else if (this.screenWidth < 1400) {
+        return "45%";
+      } else {
+        return "800px";
+      }
+    },
+    close() {
+      this.$emit("close");
+    },
+    reset() {
+      // 先清除校验,再清除表单,不然有奇怪的bug
+      this.$refs.form.clearValidate();
+      this.$refs.form.resetFields();
+      this.confirmDisabled = false;
+      this.place = this.initPlace();
+    },
+    submitForm() {
+      const vm = this;
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          vm.editSubmit();
+        } else {
+          return false;
+        }
+      });
+    },
+    editSubmit() {
+      const vm = this;
+      if (vm.type === "edit") {
+        vm.update();
+      } else {
+        vm.save();
+      }
+    },
+    save() {
+      const vm = this;
+      vm.confirmDisabled = true;
+      quan
+        .save(this.place)
+        .then((response) => {
+          const res = response.data;
+          if (res.isSuccess) {
+            vm.isVisible = false;
+            vm.$message({
+              message: vm.$t("tips.createSuccess"),
+              type: "success",
+            });
+            vm.$emit("success");
+          }
+        })
+        .finally(() => (vm.confirmDisabled = false));
+    },
+    update() {
+      const vm = this;
+      vm.confirmDisabled = true;
+      quan
+        .update(this.place)
+        .then((response) => {
+          const res = response.data;
+          if (res.isSuccess) {
+            vm.isVisible = false;
+            vm.$message({
+              message: this.$t("tips.updateSuccess"),
+              type: "success",
+            });
+            vm.$emit("success");
+          }
+        })
+        .finally(() => (vm.confirmDisabled = false));
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+.from-item {
+  width: 100%;
+}
+</style>