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.
75 lines
4.1 KiB
75 lines
4.1 KiB
import { jsx as _jsx } from "react/jsx-runtime"; |
|
import { useRequest } from 'ahooks'; |
|
import { getTemplate } from './action'; |
|
import { Col, Empty } from 'antd'; |
|
import { map } from 'lodash'; |
|
import { ProFormList, ProFormRate, ProFormSelect, ProFormRadio, } from '@ant-design/pro-components'; |
|
import { useEffect } from 'react'; |
|
import { LoadingOutlined } from '@ant-design/icons'; |
|
import { Spin } from 'antd'; |
|
export default function ({ templateId }) { |
|
var _a, _b; |
|
const { data: list, runAsync, loading, } = useRequest(getTemplate, { |
|
manual: true, |
|
onSuccess(data) { |
|
console.log('data', data); |
|
}, |
|
}); |
|
useEffect(() => { |
|
runAsync({ templateId }).then((res) => { |
|
console.log('resssssssss', res); |
|
}); |
|
}, [templateId]); |
|
const antIcon = _jsx(LoadingOutlined, { style: { fontSize: 24 }, spin: true }); |
|
if (loading) { |
|
return _jsx(Spin, { indicator: antIcon }); |
|
} |
|
if (!list) { |
|
return (_jsx(Col, Object.assign({ span: 24 }, { children: _jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: "\u6682\u65E0\u8868\u5355" }) }))); |
|
} |
|
return (_jsx(ProFormList, Object.assign({ name: "item", copyIconProps: false, deleteIconProps: false, initialValue: (_a = list === null || list === void 0 ? void 0 : list.checkItem) !== null && _a !== void 0 ? _a : [], creatorButtonProps: { |
|
style: { |
|
display: 'none', |
|
}, |
|
} }, { children: (meta, index, item) => { |
|
var _a, _b, _c, _d, _e, _f, _g; |
|
if (((_a = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _a === void 0 ? void 0 : _a.itemType) == 'radio') { |
|
return (_jsx(ProFormRadio.Group, { colProps: { |
|
span: 24, |
|
}, label: (_b = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _b === void 0 ? void 0 : _b.itemName, name: "item_val_code", options: map(JSON.parse((_c = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _c === void 0 ? void 0 : _c.tag), (item) => ({ |
|
label: item === null || item === void 0 ? void 0 : item.choice, |
|
value: item === null || item === void 0 ? void 0 : item.choice, |
|
})), rules: [ |
|
{ |
|
required: true, |
|
message: `请选择${(_d = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _d === void 0 ? void 0 : _d.itemName}`, |
|
}, |
|
] })); |
|
} |
|
if (((_e = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _e === void 0 ? void 0 : _e.itemType) == 'text') { |
|
return (_jsx(ProFormRate, { colProps: { |
|
span: 24, |
|
}, label: (_f = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _f === void 0 ? void 0 : _f.itemName, name: "item_val_code", fieldProps: { allowHalf: false }, rules: [ |
|
{ |
|
required: true, |
|
message: `请给“${(_g = list === null || list === void 0 ? void 0 : list.checkItem[index]) === null || _g === void 0 ? void 0 : _g.itemName}”这一项打分`, |
|
}, |
|
] })); |
|
} |
|
} }))); |
|
return (_jsx(ProFormList, Object.assign({ name: "users", initialValue: (_b = list === null || list === void 0 ? void 0 : list.checkItem) !== null && _b !== void 0 ? _b : [], creatorButtonProps: { |
|
position: 'top', |
|
creatorButtonText: '再建一行', |
|
}, creatorRecord: { |
|
useMode: 'none', |
|
} }, { children: _jsx(ProFormSelect, { options: [ |
|
{ |
|
value: 'text', |
|
label: '打分', |
|
}, |
|
{ |
|
value: 'radio', |
|
label: '选择', |
|
}, |
|
], width: "md", name: "useMode", label: "\u5408\u540C\u7EA6\u5B9A\u751F\u6548\u65B9\u5F0F" }, "itemType") }))); |
|
}
|
|
|