Browse Source

fix(): 修改资讯管理页面

tags/PMS_Frontend_v1.0.6-develop
fengxiang 2 years ago
parent
commit
b52de564b0
  1. 4
      src/pages/OperationCenter/OperationSales/AdsMgm/loadable.jsx
  2. 101
      src/pages/OperationCenter/OperationSales/InformationMgm/index.scss
  3. 387
      src/pages/OperationCenter/OperationSales/InformationMgm/loadable.jsx
  4. 30
      src/services/OperationCenter/OperationMarket/information.js

4
src/pages/OperationCenter/OperationSales/AdsMgm/loadable.jsx

@ -508,6 +508,10 @@ function AdsMgm() {
// -
const handleComfirm = () => {
let newArr = [...sortArr];
if (!modalObj?.name) {
message.error("请输入分类标签名称");
return;
}
//
const isEdit = modalObj.index < newArr.length;
(isEdit

101
src/pages/OperationCenter/OperationSales/InformationMgm/index.scss

@ -305,63 +305,86 @@
}
}
.ul-list {
width: 300px;
.cr-box {
width: 540px;
margin: 10px auto 20px;
border: 1px solid #ccc;
border: 1px solid #ebeef5;
li {
.list-top {
width: 100%;
height: 40px;
border-bottom: 1px solid #ccc;
padding: 18px 20px;
border-bottom: 1px solid #ebeef5;
display: flex;
align-items: center;
justify-content: space-between;
>span {
.anticon {
cursor: pointer;
margin-left: 10px;
span:last-child {
color: #409eff;
cursor: pointer;
}
}
&.anticon-edit,
&.anticon-plus-circle {
color: rgb(64, 158, 255);
}
.list-wrap {
width: 100%;
padding: 20px;
&.anticon-minus-circle {
display: none;
color: rgb(245, 108, 108);
}
}
.list-ul {
width: 100%;
padding-left: 20px;
&:nth-last-child(3) {
width: 40px;
text-align: center;
&.list-outer {
padding-left: 0;
}
&:nth-last-child(2) {
flex: 1;
text-align: center;
@include textEllipsis("one");
}
.list-item {
width: 100%;
&:nth-last-child(1) {
width: 60px;
.li-box {
padding: 3px 0;
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
&:hover,&.active{
background-color: #f0f6f9;
}
.btn,
.gap {
display: inline-block;
width: 15px;
height: 15px;
margin-right: 5px;
}
.tool {
display: inline-block;
text-align: center;
min-width: 200px;
span+span {
margin-left: 15px;
}
span {
color: rgb(64, 158, 255);
cursor: pointer;
&:last-child {
color: rgb(245, 108, 108);
}
}
}
}
}
}
&:last-child {
border-bottom: unset;
cursor: pointer;
}
&:hover {
>span .anticon-minus-circle {
display: inline-block;
.no-data {
text-align: center;
}
}
}
}
}
.extra-group {

387
src/pages/OperationCenter/OperationSales/InformationMgm/loadable.jsx

@ -15,15 +15,13 @@ import {
Upload,
Popover,
Checkbox,
TimePicker,
Cascader,
Tooltip,
} from "antd";
import {
CalendarOutlined,
EditOutlined,
MinusCircleOutlined,
PlusCircleOutlined,
CaretRightOutlined,
CaretDownOutlined,
LoadingOutlined,
PlusOutlined,
DeleteOutlined,
@ -83,7 +81,7 @@ function InformationMgm() {
title: "", //
author: "", //
areaId: [], //
releaseType: [], //
releaseType: ["1"], //
shareTitle: "", //
shareDescribe: "", //
shareImgUrl: "", //
@ -104,13 +102,11 @@ function InformationMgm() {
const [rowData, setRowData] = useState(defRowData);
//
const [uploading, setUploading] = useState(false);
//
const [sortArr, setSortArr] = useState([]);
//
const [modalObj, setModalObj] = useState({
visible: false, //
title: "修改标签", //
index: 0, //
title: "添加", //
id: 0, //id
name: "", //
});
const [general, setGeneral] = useState(""); //
@ -125,6 +121,10 @@ function InformationMgm() {
isStick: [], //
category: [], //
});
//
const [checkId, setCheckId] = useState("");
//
const [foldIds, setFoldIds] = useState([]);
// 访
useEffect(() => {
@ -137,21 +137,16 @@ function InformationMgm() {
getData();
}, [isAjax]);
// -
const statusArr = [
{ value: "0", label: "已保存" },
{ value: "1", label: "待上架" },
{ value: "2", label: "已上架" },
{ value: "3", label: "已下架" },
];
// -
const items = [
{ key: "0", label: <span>预览</span> },
{ key: "1", label: <span>详情</span> },
{ key: "2", label: <span>编辑</span> },
{ key: "3", label: <span>上架</span> },
{ key: "4", label: <span>下架</span> },
{ key: "5", label: <span>封存</span> },
{ key: "2", label: <span>发布</span> },
{ key: "3", label: <span>编辑</span> },
{ key: "4", label: <span>上架</span> },
{ key: "5", label: <span>下架</span> },
{ key: "6", label: <span>封存</span> },
{ key: "7", label: <span>删除</span> },
];
//
@ -288,23 +283,27 @@ function InformationMgm() {
align: "center",
width: 140,
render: (val, row, index) => {
// 1= 2= 3= 0= 4=
const status = row?.status;
return (
<Dropdown
arrow
placement="bottomLeft"
menu={{
items,
items:
status == 1
? items.filter((v, i) => [0, 1, 2, 3, 7].includes(i))
: status == 2
? items.filter((v, i) => [0, 1, 5].includes(i))
: status == 3
? items.filter((v, i) => [0, 1, 3, 4, 6].includes(i))
: status == 0
? items.filter((v, i) => [0, 1, 2, 3, 7].includes(i))
: items.filter((v, i) => [0, 1].includes(i)),
onClick: (key) => {
return clickDropDown(key, row);
},
}}
placement="bottomLeft"
arrow
onOpenChange={(open) => {
if (open) {
// setCurrentPersonRecord(row)
} else {
// setCurrentPersonRecord({})
}
}}
>
<Button type="primary">操作</Button>
</Dropdown>
@ -315,22 +314,31 @@ function InformationMgm() {
//
const clickDropDown = (param, record) => {
console.log(param.key);
// console.log(param.key, record);
setRowData(record);
if (param.key == "1") {
//
setPageType("3");
} else if (param.key == "2") {
//
handleStatus(record?.informationId, "1");
} else if (param.key == "3") {
//
setPageType("2");
setGeneral("");
setGeneral(record?.general || "");
setContent(record?.content || "<p><br></p>");
} else if (param.key == "3") {
//
} else if (param.key == "4") {
//
//
handleStatus(record?.informationId, "2");
} else if (param.key == "5") {
//
handleStatus(record?.informationId, "3");
} else if (param.key == "6") {
//
handleStatus(record?.informationId, "4");
} else if (param.key == "7") {
//
deleteItem(record?.informationId);
} else {
//
if (record?.jumpUrl) {
@ -341,6 +349,42 @@ function InformationMgm() {
}
};
// 1= 2= 3= 0= 4=
const handleStatus = (id, status) => {
ajax.doInfoStatus({ informationId: id, status }).then(
(res) => {
if (parseInt(res?.status) === 20000) {
message.success(res?.message);
setPageInfo({ ...pageInfo, ...{ pageNum: 1 } });
setIsAjax(!isAjax);
} else {
message.error(res?.message);
}
},
(err) => {
console.log(err);
}
);
};
//
const deleteItem = (id) => {
ajax.doInfoDelete({ informationId: id }).then(
(res) => {
if (parseInt(res?.status) === 20000) {
message.success(res?.message);
setPageInfo({ ...pageInfo, ...{ pageNum: 1 } });
setIsAjax(!isAjax);
} else {
message.error(res?.message);
}
},
(err) => {
console.log(err);
}
);
};
//
const paginationProps = {
position: ["bottomCenter"],
@ -384,7 +428,7 @@ function InformationMgm() {
};
// console.log(postData, newObj);
setTabLoading(true);
ajax.getInformationList({ ...newObj, ...pageInfo }).then(
ajax.getInfoList({ ...newObj, ...pageInfo }).then(
(res) => {
if (parseInt(res?.status) === 20000) {
setResultData(res?.data || {});
@ -411,18 +455,6 @@ function InformationMgm() {
};
//
const getSelectList = () => {
ajax.getInformationLabel().then(
(res) => {
if (parseInt(res?.status) === 20000) {
setAllSelect(res?.data || {});
} else {
message.error(res?.message);
}
},
(err) => {
console.log(err);
}
);
//
ajaxCom.getAreaTree().then(
(res) => {
@ -446,15 +478,10 @@ function InformationMgm() {
//
const getTypeList = () => {
ajax.getAdvertTypeList().then(
ajax.getInfoLabel().then(
(res) => {
if (parseInt(res?.status) === 20000) {
// setSortArr(res?.data || []);
setSortArr([
{ value: "0", label: "新闻" },
{ value: "1", label: "体育" },
{ value: "2", label: "测试" },
]);
setAllSelect(res?.data || {});
} else {
message.error(res?.message);
}
@ -466,23 +493,26 @@ function InformationMgm() {
};
// -
const handleEditItem = (val, num) => {
const handleEditItem = (obj) => {
setModalObj({
visible: true,
title: "修改标签",
index: num,
name: val?.label,
title: "修改",
id: obj?.id,
name: obj?.name,
});
};
// -
const handleDelItem = (val, num) => {
ajax.doAdvertTypeDelete({ categoryId: sortArr[num]["value"] }).then(
// -
const handleDelItem = (id) => {
ajax.doInfoLabelDelete({ id }).then(
(res) => {
if (parseInt(res?.status) === 20000) {
message.success(res?.message);
getTypeList();
// setSortArr(sortArr.filter((v, i) => i !== num));
// setAllSelect({
// ...allSelect,
// category: allSelect?.category.filter((v, i) => v.id != id),
// });
} else {
message.error(res?.message);
}
@ -494,39 +524,38 @@ function InformationMgm() {
};
// -
const handleAddItem = () => {
const handleAddItem = (fid) => {
setModalObj({
visible: true,
title: "创建标签",
index: sortArr.length,
title: "添加",
id: fid,
name: "",
});
};
// -
const handleComfirm = () => {
let newArr = [...sortArr];
if (!modalObj?.name) {
message.error("请输入分类名称");
return;
}
//
const isEdit = modalObj.index < newArr.length;
const isEdit = modalObj.title == "修改";
(isEdit
? ajax.doAdvertTypeEdit({
categoryId: newArr[modalObj.index]["value"],
? ajax.doInfoLabelEdit({
id: modalObj.id,
name: modalObj.name,
})
: ajax.doInfoLabelInsert({
fid: modalObj.id,
name: modalObj.name,
})
: ajax.doAdvertTypeInsert({ name: modalObj.name })
).then(
(res) => {
if (parseInt(res?.status) === 20000) {
message.success(res?.message);
setModalObj({ ...modalObj, visible: false });
getTypeList();
// let newArr = [...sortArr];
// if (isEdit) {
// newArr[modalObj.index]["label"] = modalObj.name;
// } else {
// newArr.push({ value: modalObj.index, label: modalObj.name });
// }
// setSortArr(newArr);
} else {
message.error(res?.message);
}
@ -539,8 +568,21 @@ function InformationMgm() {
// -
const handleForm = (key, val) => {
if (key === "jumpUrlType") {
const numKeys = [
"readBasics",
"readMultiple",
"pointBasics",
"pointMultiple",
];
if (key === "isReprint") {
setGeneral("");
setContent("<p><br></p>");
setRowData({ ...rowData, [key]: val, jumpUrl: "" });
} else if (numKeys.includes(key)) {
setRowData({
...rowData,
[key]: val.replace(/[^\d]/g, "").replace(/0*(\d+)/, "$1"),
});
} else {
setRowData({ ...rowData, [key]: val });
}
@ -645,7 +687,7 @@ function InformationMgm() {
//
const handleSaveInfo = () => {
console.log(rowData);
ajax[rowData?.informationId ? "doInformationEdit" : "doInformationInsert"]({
ajax[rowData?.informationId ? "doInfoEdit" : "doInfoInsert"]({
...rowData,
general,
content,
@ -670,6 +712,66 @@ function InformationMgm() {
setIsAjax(!isAjax);
};
//
const toggle = (obj) => {
if (foldIds.includes(obj.id)) {
setFoldIds(foldIds.filter((v) => v != obj.id));
} else {
setFoldIds([...foldIds, ...[obj.id]]);
}
};
// -
const clickItem = (obj) => {
setCheckId(obj.id);
};
//
const renderTree = (nodes, levels) => {
return nodes.map((modal, index) => {
const lvs = [...(levels || []), ...[index]];
const isFolder = modal?.children?.length;
return (
<li key={modal.id} className="list-item">
<div
title={modal.name}
className={checkId == modal.id ? "li-box active" : "li-box"}
onClick={(e) => {
e.stopPropagation();
clickItem(modal);
}}
>
<span>
{isFolder ? (
<span className="btn" onClick={() => toggle(modal)}>
{foldIds.includes(modal.id) ? (
<CaretRightOutlined />
) : (
<CaretDownOutlined />
)}
</span>
) : (
<span className="gap"></span>
)}
<span className="item-name">
{modal.name}({modal.num})
</span>
</span>
<span className="tool">
<span onClick={() => handleEditItem(modal)}>修改</span>
{lvs.length == 1 ? (
<span onClick={() => handleAddItem(modal.id)}>添加</span>
) : null}
<span onClick={() => handleDelItem(modal.id)}>删除</span>
</span>
</div>
{isFolder && !foldIds.includes(modal.id) ? (
<ul className="list-ul">{renderTree(modal.children, lvs)}</ul>
) : null}
</li>
);
});
};
return (
<div className="information-mgm">
{/* 主页 */}
@ -805,7 +907,14 @@ function InformationMgm() {
>
创建资讯
</Button>
<Button type="primary" onClick={() => setPageType("4")}>
<Button
type="primary"
onClick={() => {
setCheckId("");
setFoldIds([]);
setPageType("4");
}}
>
设置
</Button>
</div>
@ -1141,17 +1250,19 @@ function InformationMgm() {
</div>
</div>
</div>
<div className="row-line">
<div className="r-txt">原文链接</div>
<div className="r-con">
<Input
className="row-lg"
placeholder="请输入转发的原文地址"
value={rowData?.jumpUrl || ""}
onChange={(e) => handleForm("jumpUrl", e.target.value)}
/>
{rowData?.isReprint == 1 ? (
<div className="row-line">
<div className="r-txt">原文链接</div>
<div className="r-con">
<Input
className="row-lg"
placeholder="请输入转发的原文地址"
value={rowData?.jumpUrl || ""}
onChange={(e) => handleForm("jumpUrl", e.target.value)}
/>
</div>
</div>
</div>
) : null}
<div className="row-line">
<div className="r-txt">定时发布时间</div>
<div className="r-con">
@ -1174,34 +1285,36 @@ function InformationMgm() {
</div>
</div>
</div>
<div className="extra-group">
<div className="row-box">
<div className="r-txt">
<Upload {...upProps}>
<Button type="primary">上传资源</Button>
</Upload>
</div>
<div className="r-con r-sm">
<Input
placeholder="上传成功后资源的路径会显示在这里"
value={rowData?.jumpUrl || ""}
onChange={(e) => handleForm("jumpUrl", e.target.value)}
/>
{rowData?.isReprint != 1 ? (
<div className="extra-group">
<div className="row-box">
<div className="r-txt">
<Upload {...upProps}>
<Button type="primary">上传资源</Button>
</Upload>
</div>
<div className="r-con r-sm">
<Input
placeholder="上传成功后资源的路径会显示在这里"
value={rowData?.jumpUrl || ""}
onChange={(e) => handleForm("jumpUrl", e.target.value)}
/>
</div>
</div>
</div>
<div className="row-box">
<div className="r-txt">内容</div>
<div className="r-con">
<MyEditor
content={content}
onChange={(v, k) => {
setContent(v);
setGeneral(k);
}}
/>
<div className="row-box">
<div className="r-txt">内容</div>
<div className="r-con">
<MyEditor
content={content}
onChange={(v, k) => {
setContent(v);
setGeneral(k);
}}
/>
</div>
</div>
</div>
</div>
) : null}
</div>
</div>
{/* 详情 */}
@ -1349,33 +1462,25 @@ function InformationMgm() {
{/* 设置 */}
<div className={pageType === "4" ? "wraper" : "wraper hidden"}>
<div className="row-operate">
<span></span>
<Button onClick={() => handleBack()}>返回</Button>
</div>
<div className="full-group">
<ul className="ul-list">
{sortArr?.length
? sortArr.map((v, i) => {
return (
<li key={"i" + i}>
<span>{i + 1}</span>
<span>{v?.label || "-"}</span>
<span>
<EditOutlined onClick={() => handleEditItem(v, i)} />
<MinusCircleOutlined
onClick={() => handleDelItem(v, i)}
/>
</span>
</li>
);
})
: null}
<li onClick={handleAddItem}>
<span>创建分类标签</span>
<span>
<PlusCircleOutlined />
</span>
</li>
</ul>
<div className="cr-box">
<div className="list-top">
<span>分类名称</span>
<span onClick={() => handleAddItem("0")}>添加分类</span>
</div>
<div className="list-wrap">
<ul className="list-ul list-outer">
{allSelect?.category?.length ? (
renderTree(allSelect?.category)
) : (
<li className="no-data">暂无数据</li>
)}
</ul>
</div>
</div>
</div>
</div>
<Modal
@ -1389,7 +1494,7 @@ function InformationMgm() {
>
<div>
<Input
placeholder="请输入分类标签名称"
placeholder="请输入分类名称"
value={modalObj.name}
onChange={(e) => setModalObj({ ...modalObj, name: e.target.value })}
/>

30
src/services/OperationCenter/OperationMarket/information.js

@ -2,21 +2,31 @@ import ajax from "@/config/ajax";
// --资讯管理--
export default {
// 所有下拉
getInformationLabel: (data) =>
getInfoLabel: (data) =>
ajax({ url: "/api/ope/information/get_label", type: "get", data }),
// // 应用路径
// getPushPath: (data) =>
// ajax({ url: "/api/ope/push/get_path", type: "get", data }),
// 列表
getInformationList: (data) =>
getInfoList: (data) =>
ajax({ url: "/api/ope/information/list", type: "post", data }),
// 新增
doInformationInsert: (data) =>
doInfoInsert: (data) =>
ajax({ url: "/api/ope/information/insert", type: "post", data }),
// 修改
doInformationEdit: (data) =>
doInfoEdit: (data) =>
ajax({ url: "/api/ope/information/edit", type: "post", data }),
// // 删除
// doPushDelete: (data) =>
// ajax({ url: "/api/ope/push/delete", type: "post", data }),
// 改变状态
doInfoStatus: (data) =>
ajax({ url: "/api/ope/information/status_edit", type: "post", data }),
// 删除
doInfoDelete: (data) =>
ajax({ url: "/api/ope/information/delete", type: "post", data }),
// 分类标签-修改
doInfoLabelEdit: (data) =>
ajax({ url: "/api/ope/information/label_edit", type: "post", data }),
// 分类标签-删除
doInfoLabelDelete: (data) =>
ajax({ url: "/api/ope/information/label_delete", type: "post", data }),
// 分类标签-新增
doInfoLabelInsert: (data) =>
ajax({ url: "/api/ope/information/label_insert", type: "post", data }),
};
Loading…
Cancel
Save