You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
632 lines
28 KiB
632 lines
28 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[95002],{
|
|
|
|
/***/ 95002:
|
|
/*!****************************************************************************!*\
|
|
!*** ./src/pages/virtualSpaces/components/AddOrEdit/index.tsx + 1 modules ***!
|
|
\****************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
Z: function() { return /* binding */ components_AddOrEdit; }
|
|
});
|
|
|
|
// UNUSED EXPORTS: Edit
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(7557);
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(41498);
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(79800);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/form/index.js + 19 modules
|
|
var es_form = __webpack_require__(78241);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
var es_message = __webpack_require__(8591);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
|
|
var modal = __webpack_require__(43418);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 3 modules
|
|
var input = __webpack_require__(92832);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js
|
|
var es_radio = __webpack_require__(69140);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/upload/index.js
|
|
var upload = __webpack_require__(60028);
|
|
;// CONCATENATED MODULE: ./src/pages/virtualSpaces/components/AddOrEdit/index.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var AddOrEditmodules = ({"flex_box_center":"flex_box_center___ze4wf","flex_space_between":"flex_space_between___JpH0B","flex_box_vertical_center":"flex_box_vertical_center___NbRyF","flex_box_center_end":"flex_box_center_end___fUFoB","flex_box_column":"flex_box_column___i2BZL","flex-col":"flex-col___pqjMD","flex-row":"flex-row___Ma8e6","justify-start":"justify-start___leWFZ","justify-center":"justify-center___GV2Az","justify-end":"justify-end___TByOk","justify-evenly":"justify-evenly___IOmbU","justify-around":"justify-around___hySOr","justify-between":"justify-between___fGSxF","align-start":"align-start___DzTZ7","align-center":"align-center___FKJX2","align-end":"align-end___rBsrF","form":"form____yVeV","btn":"btn___X16NC","img":"img___sQnKq"});
|
|
// EXTERNAL MODULE: ./src/components/ui-customization/reset.less?modules
|
|
var resetmodules = __webpack_require__(24695);
|
|
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
|
|
var env = __webpack_require__(14160);
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.6.1@@ant-design/icons/es/icons/CloseCircleFilled.js + 1 modules
|
|
var icons_CloseCircleFilled = __webpack_require__(19248);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
;// CONCATENATED MODULE: ./src/pages/virtualSpaces/components/AddOrEdit/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var AddOrEdit = function AddOrEdit(_ref) {
|
|
var _fileList$3, _fileOtherList$3;
|
|
var visible = _ref.visible,
|
|
onOk = _ref.onOk,
|
|
onCancel = _ref.onCancel,
|
|
_ref$title = _ref.title,
|
|
title = _ref$title === void 0 ? '' : _ref$title;
|
|
var _Form$useForm = es_form/* default */.Z.useForm(),
|
|
_Form$useForm2 = slicedToArray_default()(_Form$useForm, 1),
|
|
form = _Form$useForm2[0];
|
|
var _useState = (0,_react_17_0_2_react.useState)(false),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
btnLoading = _useState2[0],
|
|
setBtnLoading = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)([]),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
fileList = _useState4[0],
|
|
setFileList = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
fileOtherList = _useState6[0],
|
|
setFileOtherList = _useState6[1];
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
imgLoading = _useState8[0],
|
|
setImgLoading = _useState8[1];
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
if (visible !== null && visible !== void 0 && visible.name) {
|
|
var _visible$cover_url, _visible$cover_url2, _visible$backbground_, _visible$backbground_2;
|
|
form.setFieldsValue({
|
|
name: visible === null || visible === void 0 ? void 0 : visible.name
|
|
});
|
|
var newFileList = visible !== null && visible !== void 0 && (_visible$cover_url = visible.cover_url) !== null && _visible$cover_url !== void 0 && _visible$cover_url.includes('attachments') ? [{
|
|
response: {
|
|
id: visible === null || visible === void 0 || (_visible$cover_url2 = visible.cover_url) === null || _visible$cover_url2 === void 0 ? void 0 : _visible$cover_url2.split('/')[3]
|
|
}
|
|
}] : [];
|
|
var newFileOtherList = visible !== null && visible !== void 0 && (_visible$backbground_ = visible.backbground_image_url) !== null && _visible$backbground_ !== void 0 && _visible$backbground_.includes('attachments') ? [{
|
|
response: {
|
|
id: visible === null || visible === void 0 || (_visible$backbground_2 = visible.backbground_image_url) === null || _visible$backbground_2 === void 0 ? void 0 : _visible$backbground_2.split('/')[3]
|
|
}
|
|
}] : [];
|
|
setFileList(newFileList);
|
|
setFileOtherList(newFileOtherList);
|
|
}
|
|
}, [visible]);
|
|
var handleOk = function handleOk() {
|
|
form.submit();
|
|
};
|
|
var handleCancel = function handleCancel() {
|
|
onCancel();
|
|
};
|
|
var addSubmit = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(values) {
|
|
var _fileList$, _fileOtherList$;
|
|
var param;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
setBtnLoading(true);
|
|
console.log(fileList, fileOtherList, 3333);
|
|
param = {
|
|
name: values === null || values === void 0 ? void 0 : values.name,
|
|
vs_type: values === null || values === void 0 ? void 0 : values.vs_type,
|
|
identifier: values === null || values === void 0 ? void 0 : values.identifier,
|
|
cover_id: (fileList === null || fileList === void 0 || (_fileList$ = fileList[0]) === null || _fileList$ === void 0 || (_fileList$ = _fileList$.response) === null || _fileList$ === void 0 ? void 0 : _fileList$.id) || '',
|
|
backbground_image_id: (fileOtherList === null || fileOtherList === void 0 || (_fileOtherList$ = fileOtherList[0]) === null || _fileOtherList$ === void 0 || (_fileOtherList$ = _fileOtherList$.response) === null || _fileOtherList$ === void 0 ? void 0 : _fileOtherList$.id) || ''
|
|
};
|
|
onOk(param, function (res) {
|
|
if ((res === null || res === void 0 ? void 0 : res.status) === -3) {
|
|
form.setFields([{
|
|
name: 'identifier',
|
|
errors: ['该标识已存在,请更换']
|
|
}]);
|
|
}
|
|
setBtnLoading(false);
|
|
});
|
|
case 4:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function addSubmit(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var handleFileChange = function handleFileChange(info, type) {
|
|
var statusList = ["uploading", "done", "removed"];
|
|
if (statusList.includes(info.file.status)) {
|
|
if (info.file.status === 'uploading') {
|
|
setImgLoading(true);
|
|
}
|
|
if (info.file.status === 'done') {
|
|
setImgLoading(false);
|
|
}
|
|
if (type === 1) {
|
|
setFileList(info.fileList);
|
|
} else {
|
|
setFileOtherList(info.fileList);
|
|
}
|
|
}
|
|
};
|
|
var handleFileRemove = function handleFileRemove(file, type) {
|
|
if (type === 1) {
|
|
setFileList([]);
|
|
} else {
|
|
setFileOtherList([]);
|
|
}
|
|
};
|
|
var handleFileBeforeUpload = function handleFileBeforeUpload(file, type) {
|
|
var isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
if (!isJpgOrPng) {
|
|
es_message/* default */.ZP.warning('请上传jpg或png的图片!');
|
|
return false;
|
|
}
|
|
var is200K = file.size / 1024 > 200;
|
|
var is1M = file.size / 1024 / 1024 > 1;
|
|
if (is200K && type === 1) {
|
|
es_message/* default */.ZP.warning('文件大小必须小于200KB');
|
|
return false;
|
|
}
|
|
if (is1M && type === 2) {
|
|
es_message/* default */.ZP.warning('文件大小必须小于1MB');
|
|
return false;
|
|
}
|
|
if (type === 1) {
|
|
setFileList([]);
|
|
} else {
|
|
setFileOtherList([]);
|
|
}
|
|
return true;
|
|
};
|
|
var renderImg = function renderImg(type) {
|
|
var _fileList$2, _fileOtherList$2;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: AddOrEditmodules.img,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("img", {
|
|
src: env/* default */.Z.API_SERVER + "/api/attachments/" + (type === 1 ? fileList === null || fileList === void 0 || (_fileList$2 = fileList[0]) === null || _fileList$2 === void 0 || (_fileList$2 = _fileList$2.response) === null || _fileList$2 === void 0 ? void 0 : _fileList$2.id : fileOtherList === null || fileOtherList === void 0 || (_fileOtherList$2 = fileOtherList[0]) === null || _fileOtherList$2 === void 0 || (_fileOtherList$2 = _fileOtherList$2.response) === null || _fileOtherList$2 === void 0 ? void 0 : _fileOtherList$2.id),
|
|
alt: "avatar",
|
|
style: {
|
|
width: '100%'
|
|
}
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(icons_CloseCircleFilled/* default */.Z, {
|
|
onClick: function onClick() {
|
|
if (type === 1) {
|
|
setFileList([]);
|
|
} else {
|
|
setFileOtherList([]);
|
|
}
|
|
},
|
|
style: {
|
|
fontSize: '16px',
|
|
color: 'red'
|
|
}
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
|
|
title: title,
|
|
open: visible,
|
|
onOk: handleOk,
|
|
centered: true,
|
|
onCancel: handleCancel,
|
|
confirmLoading: btnLoading,
|
|
okButtonProps: {
|
|
disabled: imgLoading
|
|
},
|
|
width: 694,
|
|
afterClose: function afterClose() {
|
|
setBtnLoading(false);
|
|
setFileList([]);
|
|
setFileOtherList([]);
|
|
form.resetFields();
|
|
},
|
|
okText: visible !== null && visible !== void 0 && visible.name ? '确认' : '确认新建',
|
|
cancelText: "\u53D6\u6D88",
|
|
wrapClassName: resetmodules/* default */.Z.CustomCss,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, {
|
|
form: form,
|
|
colon: false,
|
|
onFinish: addSubmit
|
|
// labelCol={{ span: 4 }}
|
|
// wrapperCol={{ span: 18 }}
|
|
,
|
|
className: AddOrEditmodules.form,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
label: "\u793E\u533A\u540D\u79F0",
|
|
name: "name",
|
|
rules: [{
|
|
required: true,
|
|
message: '请输入社区名称'
|
|
}, {
|
|
whitespace: true,
|
|
message: '请输入社区名称'
|
|
}, {
|
|
max: 60,
|
|
message: '只能输入60个字符'
|
|
}],
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
maxLength: 60,
|
|
placeholder: "\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
label: "\u793E\u533A\u7C7B\u578B",
|
|
initialValue: "classroom",
|
|
name: "vs_type",
|
|
rules: [{
|
|
required: true,
|
|
message: '请输入社区类型'
|
|
}],
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
value: "classroom",
|
|
children: "\u865A\u62DF\u6559\u7814\u5BA4"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
className: "ml20",
|
|
value: "plan",
|
|
children: "101\u8BA1\u5212"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
label: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
style: {
|
|
width: 66
|
|
},
|
|
children: "\u6807\u8BC6"
|
|
}),
|
|
name: "identifier",
|
|
rules: [{
|
|
pattern: /^[a-zA-Z0-9]+$/,
|
|
message: '仅支持填写英文和数字'
|
|
}],
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
maxLength: 15
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
style: {
|
|
marginLeft: 78
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "14px c-grey-999",
|
|
children: "\u7528\u4E8E\u5355\u72EC\u6807\u8BC6\u865A\u62DF\u793E\u533A\uFF0C\u5728\u94FE\u63A5\u4E2D\u4F53\u73B0\uFF0C\u5982\uFF1Awww.educoder.net/vtrs/+\u6807\u8BC6"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: "14px c-grey-333",
|
|
children: ["\u6CE8\u610F\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "1\u3001\u6807\u8BC6\u4E0D\u53EF\u91CD\u590D", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "2\u3001\u4EC5\u652F\u6301\u586B\u5199\u82F1\u6587\u548C\u6570\u5B57", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "3\u3001\u4E0D\u8D85\u8FC715\u4E2A\u5B57\u7B26", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "4\u3001\u672A\u586B\u5199\u65F6\uFF0C\u7CFB\u7EDF\u81EA\u52A8\u751F\u6210\u72EC\u7ACB\u6807\u8BC6"]
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
name: "cover_id",
|
|
label: "\u4E0A\u4F20\u5C01\u9762\u56FE",
|
|
valuePropName: "fileList",
|
|
className: "mt30",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: AddOrEditmodules.upload,
|
|
children: fileList !== null && fileList !== void 0 && (_fileList$3 = fileList[0]) !== null && _fileList$3 !== void 0 && (_fileList$3 = _fileList$3.response) !== null && _fileList$3 !== void 0 && _fileList$3.id ? renderImg(1) : /*#__PURE__*/(0,jsx_runtime.jsx)(upload/* default */.Z, {
|
|
fileList: fileList,
|
|
action: "".concat(env/* default */.Z.API_SERVER, "/api/attachments.json"),
|
|
onChange: function onChange(e) {
|
|
return handleFileChange(e, 1);
|
|
},
|
|
onRemove: function onRemove(e) {
|
|
return handleFileRemove(e, 1);
|
|
},
|
|
beforeUpload: function beforeUpload(e) {
|
|
return handleFileBeforeUpload(e, 1);
|
|
},
|
|
withCredentials: true,
|
|
accept: "image/*",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: AddOrEditmodules.btn,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "iconfont icon-shangchuantupian2"
|
|
}), "\u4E0A\u4F20\u56FE\u7247"]
|
|
})
|
|
})
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
children: "\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7200KB\uFF0C\u5EFA\u8BAE\u4F7F\u7528282*228\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
name: "backbground_image_id",
|
|
label: "\u8BE6\u60C5\u9876\u90E8\u80CC\u666F",
|
|
valuePropName: "fileList",
|
|
className: "mt30",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: AddOrEditmodules.upload,
|
|
children: fileOtherList !== null && fileOtherList !== void 0 && (_fileOtherList$3 = fileOtherList[0]) !== null && _fileOtherList$3 !== void 0 && (_fileOtherList$3 = _fileOtherList$3.response) !== null && _fileOtherList$3 !== void 0 && _fileOtherList$3.id ? renderImg(2) : /*#__PURE__*/(0,jsx_runtime.jsx)(upload/* default */.Z, {
|
|
fileList: fileOtherList,
|
|
action: "".concat(env/* default */.Z.API_SERVER, "/api/attachments.json"),
|
|
onChange: function onChange(e) {
|
|
return handleFileChange(e, 2);
|
|
},
|
|
onRemove: function onRemove(e) {
|
|
return handleFileRemove(e, 2);
|
|
},
|
|
beforeUpload: function beforeUpload(e) {
|
|
return handleFileBeforeUpload(e, 2);
|
|
},
|
|
withCredentials: true,
|
|
accept: "image/*",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: AddOrEditmodules.btn,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "iconfont icon-shangchuantupian2"
|
|
}), "\u4E0A\u4F20\u56FE\u7247"]
|
|
})
|
|
})
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
children: "\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC71MB\uFF0C\u5EFA\u8BAE\u4F7F\u75283840*148\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"
|
|
})]
|
|
})
|
|
});
|
|
};
|
|
var Edit = function Edit(_ref3) {
|
|
var _fileList$6, _fileOtherList$6;
|
|
var data = _ref3.data,
|
|
onOk = _ref3.onOk;
|
|
var _Form$useForm3 = Form.useForm(),
|
|
_Form$useForm4 = _slicedToArray(_Form$useForm3, 1),
|
|
form = _Form$useForm4[0];
|
|
var _useState9 = useState(false),
|
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
btnLoading = _useState10[0],
|
|
setBtnLoading = _useState10[1];
|
|
var _useState11 = useState([]),
|
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
fileList = _useState12[0],
|
|
setFileList = _useState12[1];
|
|
var _useState13 = useState([]),
|
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
fileOtherList = _useState14[0],
|
|
setFileOtherList = _useState14[1];
|
|
var _useState15 = useState(false),
|
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
imgLoading = _useState16[0],
|
|
setImgLoading = _useState16[1];
|
|
useEffect(function () {
|
|
if (data !== null && data !== void 0 && data.name) {
|
|
var _data$cover_url, _data$cover_url2, _data$backbground_ima, _data$backbground_ima2;
|
|
form.setFieldsValue({
|
|
name: data === null || data === void 0 ? void 0 : data.name
|
|
});
|
|
var newFileList = data !== null && data !== void 0 && (_data$cover_url = data.cover_url) !== null && _data$cover_url !== void 0 && _data$cover_url.includes('attachments') ? [{
|
|
response: {
|
|
id: data === null || data === void 0 || (_data$cover_url2 = data.cover_url) === null || _data$cover_url2 === void 0 ? void 0 : _data$cover_url2.split('/')[3]
|
|
}
|
|
}] : [];
|
|
var newFileOtherList = data !== null && data !== void 0 && (_data$backbground_ima = data.backbground_image_url) !== null && _data$backbground_ima !== void 0 && _data$backbground_ima.includes('attachments') ? [{
|
|
response: {
|
|
id: data === null || data === void 0 || (_data$backbground_ima2 = data.backbground_image_url) === null || _data$backbground_ima2 === void 0 ? void 0 : _data$backbground_ima2.split('/')[3]
|
|
}
|
|
}] : [];
|
|
setFileList(newFileList);
|
|
setFileOtherList(newFileOtherList);
|
|
}
|
|
}, [data]);
|
|
var handleOk = function handleOk() {
|
|
form.submit();
|
|
};
|
|
var addSubmit = /*#__PURE__*/function () {
|
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(values) {
|
|
var _fileList$4, _fileOtherList$4;
|
|
var param;
|
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
case 0:
|
|
setBtnLoading(true);
|
|
param = {
|
|
name: values === null || values === void 0 ? void 0 : values.name,
|
|
cover_id: (fileList === null || fileList === void 0 || (_fileList$4 = fileList[0]) === null || _fileList$4 === void 0 || (_fileList$4 = _fileList$4.response) === null || _fileList$4 === void 0 ? void 0 : _fileList$4.id) || '',
|
|
backbground_image_id: (fileOtherList === null || fileOtherList === void 0 || (_fileOtherList$4 = fileOtherList[0]) === null || _fileOtherList$4 === void 0 || (_fileOtherList$4 = _fileOtherList$4.response) === null || _fileOtherList$4 === void 0 ? void 0 : _fileOtherList$4.id) || ''
|
|
};
|
|
onOk(param, function () {
|
|
setBtnLoading(false);
|
|
});
|
|
case 3:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}));
|
|
return function addSubmit(_x2) {
|
|
return _ref4.apply(this, arguments);
|
|
};
|
|
}();
|
|
var handleFileChange = function handleFileChange(info, type) {
|
|
var statusList = ["uploading", "done", "removed"];
|
|
if (statusList.includes(info.file.status)) {
|
|
if (info.file.status === 'uploading') {
|
|
setImgLoading(true);
|
|
}
|
|
if (info.file.status === 'done') {
|
|
setImgLoading(false);
|
|
}
|
|
if (type === 1) {
|
|
setFileList(info.fileList);
|
|
} else {
|
|
setFileOtherList(info.fileList);
|
|
}
|
|
}
|
|
};
|
|
var handleFileRemove = function handleFileRemove(file, type) {
|
|
if (type === 1) {
|
|
setFileList([]);
|
|
} else {
|
|
setFileOtherList([]);
|
|
}
|
|
};
|
|
var handleFileBeforeUpload = function handleFileBeforeUpload(file, type) {
|
|
var isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
if (!isJpgOrPng) {
|
|
message.error('请上传jpg或png的图片!');
|
|
return false;
|
|
}
|
|
var is150M = file.size / 1024 / 1024 > 2;
|
|
if (is150M) {
|
|
message.info('文件大小必须小于2MB');
|
|
return false;
|
|
}
|
|
if (type === 1) {
|
|
setFileList([]);
|
|
} else {
|
|
setFileOtherList([]);
|
|
}
|
|
return true;
|
|
};
|
|
var renderImg = function renderImg(type) {
|
|
var _fileList$5, _fileOtherList$5;
|
|
return /*#__PURE__*/_jsxs("div", {
|
|
className: styles.img,
|
|
children: [/*#__PURE__*/_jsx("img", {
|
|
src: ENV.API_SERVER + "/api/attachments/" + (type === 1 ? fileList === null || fileList === void 0 || (_fileList$5 = fileList[0]) === null || _fileList$5 === void 0 || (_fileList$5 = _fileList$5.response) === null || _fileList$5 === void 0 ? void 0 : _fileList$5.id : fileOtherList === null || fileOtherList === void 0 || (_fileOtherList$5 = fileOtherList[0]) === null || _fileOtherList$5 === void 0 || (_fileOtherList$5 = _fileOtherList$5.response) === null || _fileOtherList$5 === void 0 ? void 0 : _fileOtherList$5.id),
|
|
alt: "avatar",
|
|
style: {
|
|
width: '100%'
|
|
}
|
|
}), /*#__PURE__*/_jsx("div", {
|
|
children: /*#__PURE__*/_jsx(CloseCircleFilled, {
|
|
onClick: function onClick() {
|
|
if (type === 1) {
|
|
setFileList([]);
|
|
} else {
|
|
setFileOtherList([]);
|
|
}
|
|
},
|
|
style: {
|
|
fontSize: '16px',
|
|
color: 'red'
|
|
}
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/_jsxs(Form, {
|
|
form: form,
|
|
colon: false,
|
|
onFinish: addSubmit,
|
|
labelCol: {
|
|
span: 3
|
|
},
|
|
wrapperCol: {
|
|
span: 19
|
|
},
|
|
className: styles.form,
|
|
children: [/*#__PURE__*/_jsx(Form.Item, {
|
|
label: "\u793E\u533A\u540D\u79F0",
|
|
name: "name",
|
|
rules: [{
|
|
required: true,
|
|
message: '请输入社区名称'
|
|
}, {
|
|
whitespace: true,
|
|
message: '请输入社区名称'
|
|
}, {
|
|
max: 60,
|
|
message: '只能输入60个字符'
|
|
}],
|
|
children: /*#__PURE__*/_jsx(Input, {
|
|
maxLength: 60,
|
|
placeholder: "\u8BF7\u8F93\u5165\u793E\u533A\u540D\u79F0"
|
|
})
|
|
}), /*#__PURE__*/_jsx(Form.Item, {
|
|
name: "cover_id",
|
|
label: "\u5C01\u9762\u56FE",
|
|
valuePropName: "fileList",
|
|
children: /*#__PURE__*/_jsxs("div", {
|
|
className: styles.upload,
|
|
children: [fileList !== null && fileList !== void 0 && (_fileList$6 = fileList[0]) !== null && _fileList$6 !== void 0 && (_fileList$6 = _fileList$6.response) !== null && _fileList$6 !== void 0 && _fileList$6.id ? renderImg(1) : /*#__PURE__*/_jsx(Upload, {
|
|
fileList: fileList,
|
|
action: "".concat(ENV.API_SERVER, "/api/attachments.json"),
|
|
onChange: function onChange(e) {
|
|
return handleFileChange(e, 1);
|
|
},
|
|
onRemove: function onRemove(e) {
|
|
return handleFileRemove(e, 1);
|
|
},
|
|
beforeUpload: function beforeUpload(e) {
|
|
return handleFileBeforeUpload(e, 1);
|
|
},
|
|
withCredentials: true,
|
|
accept: "image/*",
|
|
children: /*#__PURE__*/_jsxs(Button, {
|
|
children: [/*#__PURE__*/_jsx("i", {
|
|
className: "iconfont icon-shangchuantupian2 mr10"
|
|
}), "\u4E0A\u4F20\u56FE\u7247"]
|
|
})
|
|
}), /*#__PURE__*/_jsx("aside", {
|
|
children: "\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u7B49\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC72M,\u5EFA\u8BAE\u4F7F\u7528278*225\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/_jsx(Form.Item, {
|
|
name: "backbground_image_id",
|
|
label: "\u8BE6\u60C5\u9876\u90E8\u80CC\u666F",
|
|
valuePropName: "fileList",
|
|
children: /*#__PURE__*/_jsxs("div", {
|
|
className: styles.upload,
|
|
children: [fileOtherList !== null && fileOtherList !== void 0 && (_fileOtherList$6 = fileOtherList[0]) !== null && _fileOtherList$6 !== void 0 && (_fileOtherList$6 = _fileOtherList$6.response) !== null && _fileOtherList$6 !== void 0 && _fileOtherList$6.id ? renderImg(2) : /*#__PURE__*/_jsx(Upload, {
|
|
fileList: fileOtherList,
|
|
action: "".concat(ENV.API_SERVER, "/api/attachments.json"),
|
|
onChange: function onChange(e) {
|
|
return handleFileChange(e, 2);
|
|
},
|
|
onRemove: function onRemove(e) {
|
|
return handleFileRemove(e, 2);
|
|
},
|
|
beforeUpload: function beforeUpload(e) {
|
|
return handleFileBeforeUpload(e, 2);
|
|
},
|
|
withCredentials: true,
|
|
accept: "image/*",
|
|
children: /*#__PURE__*/_jsxs(Button, {
|
|
children: [/*#__PURE__*/_jsx("i", {
|
|
className: "iconfont icon-shangchuantupian2 mr10"
|
|
}), "\u4E0A\u4F20\u56FE\u7247"]
|
|
})
|
|
}), /*#__PURE__*/_jsx("aside", {
|
|
children: "\u4EC5\u652F\u6301\u4E0A\u4F20jpg/png\u7B49\u683C\u5F0F\u6587\u4EF6\uFF0C\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC72M,\u5EFA\u8BAE\u4F7F\u75281920*220\u50CF\u7D20\uFF1B\u5982\u4E0D\u4E0A\u4F20\uFF0C\u9ED8\u8BA4\u4F7F\u7528\u7CFB\u7EDF\u56FE\u7247\u3002"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/_jsx(Button, {
|
|
disabled: imgLoading,
|
|
loading: btnLoading,
|
|
type: "primary",
|
|
onClick: handleOk,
|
|
style: {
|
|
marginLeft: 120
|
|
},
|
|
children: "\u786E\u8BA4"
|
|
})]
|
|
});
|
|
};
|
|
/* harmony default export */ var components_AddOrEdit = (AddOrEdit);
|
|
|
|
/***/ }),
|
|
|
|
/***/ 24695:
|
|
/*!************************************************************!*\
|
|
!*** ./src/components/ui-customization/reset.less?modules ***!
|
|
\************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ __webpack_exports__.Z = ({"flex_box_center":"flex_box_center___vG4eV","flex_space_between":"flex_space_between___qVVxe","flex_box_vertical_center":"flex_box_vertical_center___P8Z8s","flex_box_center_end":"flex_box_center_end___VMme3","flex_box_column":"flex_box_column___VMHwm","flex-col":"flex-col___3jhOh","flex-row":"flex-row___LeEp_","justify-start":"justify-start___jO65N","justify-center":"justify-center___YQKbt","justify-end":"justify-end___y7VEp","justify-evenly":"justify-evenly___F8k6J","justify-around":"justify-around___mvOUA","justify-between":"justify-between___EJXel","align-start":"align-start___Rq8D8","align-center":"align-center___JoAlR","align-end":"align-end___NJn7K","dropdownmenus":"dropdownmenus___oVzoj","popupClassNames":"popupClassNames___OcZq7","selectdown":"selectdown___mmcA8"});
|
|
|
|
/***/ })
|
|
|
|
}]); |