diff --git a/src/assets/api.js b/src/assets/api.js index a8edf6d7..0eabc170 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -814,7 +814,7 @@ export const getDirectList = (data) => { // key码有效期修改 export const updateKeyDelay = (data) => { - return req("put", baseurl + "key/valid/update", data) + return req("put", baseurl + "/key/valid/update", data) } // 编辑分销商电话邮箱 diff --git a/src/components/keyDelay/index.jsx b/src/components/keyDelay/index.jsx index 569191cf..19bb9821 100644 --- a/src/components/keyDelay/index.jsx +++ b/src/components/keyDelay/index.jsx @@ -2,17 +2,25 @@ import FormItem from "@/components/form-item/main" import Form from "@/components/form/main" import { useSetState } from "ahooks" import moment from "moment" -import { useRef } from "react" +import { useRef, useEffect } from "react" import "./index.less" import { Button, DateRangePicker, Input, Notify, Radio } from "zent" import { updateKeyDelay } from "../../assets/api" -export default ({ data, onColes }) => { +import { keyDelayFunc } from "@/tools" +export default ({ data = [], onColes }) => { const ref = useRef() const [model, setModel] = useSetState({ expiration_type: "1", expiration_value: "" }) + useEffect(() => { + if (data.length < 2) { + console.log(1) + setModel({ ...data[0].expiration_value }) + } + }, [data]) + function submit() { if (model.expiration_type == 2 && model.expiration_value.length < 1) { return Notify.error("请选择固定时间段") @@ -20,10 +28,11 @@ export default ({ data, onColes }) => { if (model.expiration_type == 3 && !model.expiration_value) { return Notify.error("请输入接口调取后有效期") } + const keys = data.map((item) => item.key) updateKeyDelay({ expiration_conf: model, - keys: data + keys }) .then((res) => { if (res) { @@ -63,7 +72,10 @@ export default ({ data, onColes }) => { return ( <>
- + +

{keyDelayFunc(data[0].batch_expiration_value)}

+
+ { @@ -80,7 +92,7 @@ export default ({ data, onColes }) => { {model.expiration_type === "2" ? ( - + { ) : null} {model.expiration_type === "3" ? ( - + { /> ) : null} + {data.length > 1 ? ( +

*提交后将会对所有选中key码进行批量更新有效期,请谨慎操作

+ ) : null}