Procházet zdrojové kódy

Merge branch 'master' of qk:zhuishuyun/precise_delivery_distribution_front

xia před 4 roky
rodič
revize
3862361415

+ 1 - 0
src/components/confirm-button/index.vue

@@ -40,6 +40,7 @@ const ConfirmButton = defineComponent({
         icon: createVNode(ExclamationCircleOutlined),
         title: props.confirmTitle,
         content: props.confirmContent,
+        okType: "danger",
         onOk: () => {
           emit("click");
         },

+ 35 - 2
src/helper/config/range.ts

@@ -1,6 +1,6 @@
 import moment from "moment";
 
-export const RangePicker = {
+export const picker = {
   today: [moment(), moment()],
   week: [moment().subtract(7, "days"), moment()],
   month: [moment().subtract(30, "days"), moment()],
@@ -12,9 +12,42 @@ export const RangePicker = {
   ],
 };
 
-export const RangePickerText = {
+export const pickerText = {
   today: "今天",
   week: "一周前",
   month: "一月前",
   three_month: "3个月前",
 };
+
+/**
+ * 日期picker range可自定义添加
+ * @methods add("本周", [moment(), moment()])
+ * @methods pick(["today", "week"])
+ */
+class RangePicker implements RangePickerClass {
+  private config: Record<string, moment.Moment[]>;
+
+  constructor() {
+    this.config = Object.create({});
+  }
+
+  add(text: string, range: moment.Moment[]) {
+    this.config[text] = range;
+    return this;
+  }
+
+  pick(range: string[]) {
+    range.forEach((r: string) => {
+      const text = (<Record<string, string>>pickerText)[r];
+      this.config[text] = (picker as Record<string, moment.Moment[]>)[r];
+    });
+
+    return this;
+  }
+
+  getRange() {
+    return this.config;
+  }
+}
+
+export default new RangePicker();

+ 0 - 16
src/helper/index.ts

@@ -1,5 +1,4 @@
 const path = require("path");
-import { RangePicker, RangePickerText } from "./config/range";
 
 /**
  * json字符串格式化
@@ -75,18 +74,3 @@ export const formatSelectOptions = <T>(
     };
   });
 };
-
-/**
- * 获取需要筛选的时间区间
- * @param range eg: ["today", "month", "week", "three_month"]
- */
-export const rangePicker = (range: string[]) => {
-  let rangeConfig: Record<string, moment.Moment[]> = Object.create({});
-
-  range.forEach((r: string) => {
-    const text = (<Record<string, string>>RangePickerText)[r];
-    rangeConfig[text] = (RangePicker as Record<string, moment.Moment[]>)[r];
-  });
-
-  return rangeConfig;
-};

+ 1 - 0
src/plugins/vue-confirm.ts

@@ -9,6 +9,7 @@ const confirmEvent = (binding: DirectiveBinding) => {
     title: "请确认您的操作",
     content: "确定删除该内容吗?",
     icon: createVNode(ExclamationCircleOutlined),
+    okType: "danger",
     onOk: () => binding.value.call(),
   });
 };

+ 6 - 0
src/types/global.d.ts

@@ -14,4 +14,10 @@ declare type SelectOptions<T = any> = {
 
 declare type EmitType = (event: string, ...args: any[]) => void;
 
+declare interface RangePickerClass {
+  add(text: string, range: moment.Moment[]): this;
 
+  pick(range: string[]): this;
+
+  getRange(): Record<string, moment.Moment[]>;
+}

+ 1 - 1
src/views/account/account.vue

@@ -5,7 +5,7 @@
               v-model:loading="searching"
               @confirm="onSearch">
       <div class="tool-bar-item">
-        <p class="label">平台</p>
+        <p class="label">小说平台</p>
         <a-select class="full-width"
                   v-model:value="query.platform">
           <a-select-option v-for="platform in platforms"