Commit 1c4d96bf74de70576ba4c82a7de78d07acd7c985

Authored by zhongnanhuang
1 parent 42363323

feat: update 商品参数改为非必填

src/pages/Order/components/OrderDrawer.tsx
... ... @@ -571,11 +571,14 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
571 571 };
572 572  
573 573 /**
574   - * 是否有草稿
575   - */
  574 + * 是否有草稿
  575 + */
576 576 function checkHasLocalData() {
577 577 let preOrderData = localStorage.getItem('preOrderData');
578   - let hasLocalData = preOrderData !== null && preOrderData !== undefined && preOrderData !== '';
  578 + let hasLocalData =
  579 + preOrderData !== null &&
  580 + preOrderData !== undefined &&
  581 + preOrderData !== '';
579 582 setHasLocalData(hasLocalData);
580 583 return hasLocalData;
581 584 }
... ... @@ -586,25 +589,25 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
586 589 function saveFormDataToLocal() {
587 590 let preOrderData = localStorage.getItem('preOrderData');
588 591 let values = form.getFieldsValue();
589   - values.isLocalData = true;//标识为本地草稿数据
  592 + values.isLocalData = true; //标识为本地草稿数据
590 593 let formData = JSON.stringify(values);
591 594  
592 595 //检查本地是否已有数据
593 596 if (preOrderData) {
594 597 Modal.confirm({
595   - title: "提示",
596   - content: "检测到本地有订单数据,是否覆盖?",
  598 + title: '提示',
  599 + content: '检测到本地有订单数据,是否覆盖?',
597 600 onOk: () => {
598   - localStorage.setItem("preOrderData", formData);
599   - message.success("本地保存成功");
  601 + localStorage.setItem('preOrderData', formData);
  602 + message.success('本地保存成功');
600 603 },
601 604 onCancel: () => {
602   - message.info("取消保存");
603   - }
604   - })
  605 + message.info('取消保存');
  606 + },
  607 + });
605 608 } else {
606   - localStorage.setItem("preOrderData", formData);
607   - message.success("本地保存成功");
  609 + localStorage.setItem('preOrderData', formData);
  610 + message.success('本地保存成功');
608 611 }
609 612  
610 613 checkHasLocalData();
... ... @@ -625,11 +628,10 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
625 628 /**
626 629 * 刪除草稿数据
627 630 */
628   - function removeLocalFormData(){
629   - localStorage.removeItem("preOrderData");
  631 + function removeLocalFormData() {
  632 + localStorage.removeItem('preOrderData');
630 633 }
631 634  
632   -
633 635 useEffect(() => {
634 636 checkHasLocalData();
635 637 getSalesCodeOptions();
... ... @@ -659,7 +661,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
659 661 minWidth: 400,
660 662 }}
661 663 onFinishFailed={() => {
662   - message.error("表单项存在错误,请检查");
  664 + message.error('表单项存在错误,请检查');
663 665 setSubmitBtnLoading(false);
664 666 }}
665 667 submitter={{
... ... @@ -676,7 +678,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
676 678 <Button
677 679 key="localSave"
678 680 loading={localSaveLoading}
679   - hidden={!optType('add') && !optType("copy")}
  681 + hidden={!optType('add') && !optType('copy')}
680 682 onClick={() => {
681 683 setLocalSaveLoading(true);
682 684 saveFormDataToLocal();
... ... @@ -692,7 +694,6 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
692 694 onClick={() => {
693 695 setSubmitBtnLoading(true);
694 696 props.submit();
695   -
696 697 }}
697 698 >
698 699 提交
... ... @@ -705,7 +706,18 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
705 706 drawerProps={{
706 707 destroyOnClose: true,
707 708 maskClosable: false,
708   - extra: [<Button key="useLocalData" hidden={!hasLocalData} type='link' onClick={() => { useLocalFormData() }}>使用草稿</Button>]
  709 + extra: [
  710 + <Button
  711 + key="useLocalData"
  712 + hidden={!hasLocalData}
  713 + type="link"
  714 + onClick={() => {
  715 + useLocalFormData();
  716 + }}
  717 + >
  718 + 使用草稿
  719 + </Button>,
  720 + ],
709 721 }}
710 722 submitTimeout={2000}
711 723 onFinish={async (values) => {
... ... @@ -779,8 +791,8 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
779 791 onClose(true);
780 792  
781 793 //判断保存的数据是否是本地草稿,是的话将草稿删除
782   - let isLocalData = form.getFieldValue("isLocalData");
783   - if(isLocalData){
  794 + let isLocalData = form.getFieldValue('isLocalData');
  795 + if (isLocalData) {
784 796 removeLocalFormData();
785 797 checkHasLocalData();
786 798 }
... ... @@ -955,7 +967,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
955 967 },
956 968 }}
957 969 debounceTime={1000}
958   - request={async (value, { }) => {
  970 + request={async (value, {}) => {
959 971 const keywords = value.keyWords;
960 972 const res = await postKingdeeRepCustomer({
961 973 data: { search: keywords },
... ... @@ -1361,10 +1373,9 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1361 1373 name="parameters"
1362 1374 label="商品参数"
1363 1375 placeholder="请输入商品参数"
1364   - rules={[{ required: true, message: '商品参数必填' }]}
1365 1376 disabled={
1366 1377 productParametersDisabledFlagList[listMeta.index] !==
1367   - false || optType('after-sales-check')
  1378 + false || optType('after-sales-check')
1368 1379 }
1369 1380 />,
1370 1381 <ProFormDigit
... ... @@ -1405,7 +1416,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1405 1416 placeholder="请输入商品单位"
1406 1417 disabled={
1407 1418 productParametersDisabledFlagList[listMeta.index] !==
1408   - false || optType('after-sales-check')
  1419 + false || optType('after-sales-check')
1409 1420 }
1410 1421 rules={[{ required: true, message: '商品单位必填' }]}
1411 1422 />,
... ...
src/pages/Prepaid/index.tsx 0 → 100644
  1 +import ButtonConfirm from '@/components/ButtomConfirm';
  2 +import EllipsisDiv from '@/components/Div/EllipsisDiv';
  3 +import { RESPONSE_CODE } from '@/constants/enum';
  4 +import {} from '@/pages/Invoice/constant';
  5 +import {
  6 + postCanrdApiUserList,
  7 + postPrepaidDelete,
  8 + postPrepaidList,
  9 +} from '@/services';
  10 +import { enumValueToLabel, formatDateTime } from '@/utils';
  11 +import { PlusOutlined } from '@ant-design/icons';
  12 +import { ActionType, ProTable } from '@ant-design/pro-components';
  13 +import { Button, Divider, Image, Tabs, message } from 'antd';
  14 +import { cloneDeep } from 'lodash';
  15 +import React, { useRef, useState } from 'react';
  16 +import CheckModal from '../Order/components/CheckModal';
  17 +import { CHECK_TYPE } from '../Order/constant';
  18 +import BalanceChangeRecordsModal from './components/BalanceChangeRecordsModal';
  19 +import RechargePrepaymentModal from './components/RechargePrepaymentModal';
  20 +import {
  21 + ACCOUNT_COLUMNS,
  22 + PREPAID_STATUS_OPTIONS,
  23 + SALES_RECHARGE_PREPAYMENT_COLUMNS,
  24 +} from './constant';
  25 +import './index.less';
  26 +const PrepaidPage = () => {
  27 + const prepaidActionRef = useRef<ActionType>();
  28 + const accountActionRef = useRef<ActionType>();
  29 + const [rechargePrepaymentModalVisible, setRechargePrepaymentModalVisible] =
  30 + useState(false);
  31 + const [currentOptPrepaymentObj, setCurrentOptPrepaymentObj] = useState(null);
  32 + const [currentOptUserObj, setCurrentOptUserObj] = useState(null);
  33 + const [checkVisible, setCheckVisible] = useState(false);
  34 + const [
  35 + balanceChangeRecordsModalVisible,
  36 + setBalanceChangeRecordsModalVisible,
  37 + ] = useState(false);
  38 +
  39 + const reloadPrepaidTable = () => {
  40 + prepaidActionRef.current?.reload();
  41 + };
  42 +
  43 + const reloadAccountTable = () => {
  44 + accountActionRef.current?.reload();
  45 + };
  46 +
  47 + const getTableCellText = (target: any) => {
  48 + if (!target) {
  49 + return '';
  50 + }
  51 +
  52 + if (target.props) {
  53 + return target.props.text;
  54 + }
  55 +
  56 + return target;
  57 + };
  58 +
  59 + /**
  60 + * 加载发票列表表格的各个列格式
  61 + */
  62 + const prepaidColumnsInit = () => {
  63 + let columns = SALES_RECHARGE_PREPAYMENT_COLUMNS.map((item) => {
  64 + let newItem = { ...item };
  65 + let dataIndex = item.dataIndex;
  66 +
  67 + newItem.render = (text, record) => {
  68 + let textValue = record[dataIndex];
  69 +
  70 + if (dataIndex === 'status') {
  71 + textValue = enumValueToLabel(textValue, PREPAID_STATUS_OPTIONS);
  72 + }
  73 +
  74 + if (dataIndex.endsWith('Time')) {
  75 + textValue = formatDateTime(textValue);
  76 + }
  77 +
  78 + if (
  79 + dataIndex === 'proofImages' &&
  80 + textValue !== null &&
  81 + textValue !== undefined
  82 + ) {
  83 + console.log(textValue);
  84 + return (
  85 + <Image.PreviewGroup
  86 + className="mr-10"
  87 + preview={{
  88 + onChange: (current, prev) =>
  89 + console.log(`current index: ${current}, prev index: ${prev}`),
  90 + }}
  91 + >
  92 + {textValue.map((item, index) => (
  93 + <React.Fragment key={index}>
  94 + {index > 0 ? <Divider type="vertical" /> : ''}
  95 + <Image
  96 + className="max-h-[35px] max-w-[45px]"
  97 + src={item}
  98 + title={item}
  99 + />{' '}
  100 + </React.Fragment>
  101 + ))}
  102 + </Image.PreviewGroup>
  103 + );
  104 + }
  105 +
  106 + return <EllipsisDiv text={textValue} />;
  107 + };
  108 +
  109 + return newItem;
  110 + });
  111 +
  112 + columns.push({
  113 + title: '操作',
  114 + valueType: 'option',
  115 + key: 'option',
  116 + fixed: 'right',
  117 + width: 120,
  118 + render: (text, record) => {
  119 + let btns = [];
  120 + let opts = record.operations;
  121 + if (opts?.includes('modify')) {
  122 + btns.push(
  123 + <Button
  124 + className="p-0"
  125 + key="modify"
  126 + type="link"
  127 + onClick={() => {
  128 + setRechargePrepaymentModalVisible(true);
  129 + setCurrentOptPrepaymentObj(cloneDeep(record));
  130 + }}
  131 + >
  132 + 编辑
  133 + </Button>,
  134 + );
  135 + }
  136 +
  137 + if (opts?.includes('audit')) {
  138 + btns.push(
  139 + <Button
  140 + className="p-0"
  141 + key="view"
  142 + type="link"
  143 + onClick={() => {
  144 + setCurrentOptPrepaymentObj(record);
  145 + setCheckVisible(true);
  146 + }}
  147 + >
  148 + 审核
  149 + </Button>,
  150 + );
  151 + }
  152 +
  153 + if (opts?.includes('delete')) {
  154 + btns.push(
  155 + <ButtonConfirm
  156 + key="delete"
  157 + className="p-0"
  158 + title={'确认删除编号为[ ' + record.id + ' ]的预存记录吗?'}
  159 + text="删除"
  160 + onConfirm={async () => {
  161 + let res = await postPrepaidDelete({
  162 + data: { ids: [record.id] },
  163 + });
  164 + if (res && res.result === RESPONSE_CODE.SUCCESS) {
  165 + message.success(res.message);
  166 + reloadPrepaidTable();
  167 + }
  168 + }}
  169 + />,
  170 + );
  171 + }
  172 + return btns;
  173 + },
  174 + });
  175 +
  176 + return columns;
  177 + };
  178 +
  179 + const accountColumnsInit = () => {
  180 + let columns = ACCOUNT_COLUMNS.map((item) => {
  181 + let newItem = { ...item };
  182 + let dataIndex = item.dataIndex;
  183 +
  184 + newItem.render = (text, record) => {
  185 + let textValue = record[dataIndex];
  186 + return <EllipsisDiv text={getTableCellText(textValue)} />;
  187 + };
  188 +
  189 + return newItem;
  190 + });
  191 +
  192 + columns.push({
  193 + title: '操作',
  194 + valueType: 'option',
  195 + key: 'option',
  196 + fixed: 'right',
  197 + width: 120,
  198 + render: (text, record) => {
  199 + let btns = [];
  200 + btns.push(
  201 + <Button
  202 + className="p-0"
  203 + key="view"
  204 + type="link"
  205 + onClick={() => {
  206 + setCurrentOptUserObj(record);
  207 + setBalanceChangeRecordsModalVisible(true);
  208 + }}
  209 + >
  210 + 消费记录
  211 + </Button>,
  212 + );
  213 + return btns;
  214 + },
  215 + });
  216 +
  217 + return columns;
  218 + };
  219 +
  220 + const tabsItems = [
  221 + {
  222 + key: 1,
  223 + label: '预存管理',
  224 + children: (
  225 + <ProTable
  226 + columns={prepaidColumnsInit()}
  227 + actionRef={prepaidActionRef}
  228 + cardBordered
  229 + pagination={{
  230 + pageSize: 10,
  231 + }}
  232 + request={async (params) => {
  233 + const res = await postPrepaidList({
  234 + data: { ...params },
  235 + });
  236 + return {
  237 + data: res?.data?.data || [],
  238 + total: res?.data?.total || 0,
  239 + };
  240 + }}
  241 + columnsState={{
  242 + persistenceKey: 'pro-table-singe-prepaid',
  243 + persistenceType: 'localStorage',
  244 + defaultValue: {
  245 + option: { fixed: 'right', disable: true },
  246 + },
  247 + onChange(value) {
  248 + console.log('value: ', value);
  249 + },
  250 + }}
  251 + rowKey="id"
  252 + search={{
  253 + labelWidth: 'auto',
  254 + }}
  255 + options={{
  256 + setting: {
  257 + listsHeight: 400,
  258 + },
  259 + }}
  260 + form={{}}
  261 + dateFormatter="string"
  262 + headerTitle="预存管理"
  263 + scroll={{ x: 1400 }}
  264 + toolBarRender={() => [
  265 + <Button
  266 + key="button"
  267 + icon={<PlusOutlined />}
  268 + onClick={() => {
  269 + setCurrentOptPrepaymentObj(null);
  270 + setRechargePrepaymentModalVisible(true);
  271 + }}
  272 + type="primary"
  273 + >
  274 + 新建
  275 + </Button>,
  276 + ]}
  277 + />
  278 + ),
  279 + },
  280 + {
  281 + key: 2,
  282 + label: '账号列表',
  283 + children: (
  284 + <ProTable
  285 + columns={accountColumnsInit()}
  286 + actionRef={accountActionRef}
  287 + cardBordered
  288 + pagination={{
  289 + pageSize: 10,
  290 + }}
  291 + request={async (params) => {
  292 + const res = await postCanrdApiUserList({
  293 + data: { ...params },
  294 + });
  295 + return {
  296 + data: res?.data?.data || [],
  297 + total: res?.data?.total || 0,
  298 + };
  299 + }}
  300 + columnsState={{
  301 + persistenceKey: 'pro-table-singe-account',
  302 + persistenceType: 'localStorage',
  303 + defaultValue: {
  304 + option: { fixed: 'right', disable: true },
  305 + },
  306 + onChange(value) {
  307 + console.log('value: ', value);
  308 + },
  309 + }}
  310 + rowKey="id"
  311 + search={{
  312 + labelWidth: 'auto',
  313 + }}
  314 + options={{
  315 + setting: {
  316 + listsHeight: 400,
  317 + },
  318 + }}
  319 + form={{}}
  320 + dateFormatter="string"
  321 + headerTitle="账号列表"
  322 + scroll={{ x: 1400 }}
  323 + toolBarRender={() => []}
  324 + />
  325 + ),
  326 + },
  327 + ];
  328 + return (
  329 + <div className="prepaid-index">
  330 + <Tabs
  331 + defaultActiveKey="1"
  332 + items={tabsItems}
  333 + onChange={(value) => {
  334 + if (value === '1') {
  335 + reloadPrepaidTable();
  336 + } else {
  337 + reloadAccountTable();
  338 + }
  339 + }}
  340 + />
  341 +
  342 + {rechargePrepaymentModalVisible && (
  343 + <RechargePrepaymentModal
  344 + setVisible={setRechargePrepaymentModalVisible}
  345 + onClose={() => {
  346 + setRechargePrepaymentModalVisible(false);
  347 + reloadPrepaidTable();
  348 + }}
  349 + prepaymentObject={currentOptPrepaymentObj}
  350 + />
  351 + )}
  352 +
  353 + {checkVisible && (
  354 + <CheckModal
  355 + setCheckVisible={(val: boolean) => {
  356 + setCheckVisible(val);
  357 + }}
  358 + data={[currentOptPrepaymentObj]}
  359 + subOrders={[currentOptPrepaymentObj]}
  360 + orderCheckType={CHECK_TYPE.PREPAID_AUDIT}
  361 + openOrderDrawer={false}
  362 + onClose={() => {
  363 + setCheckVisible(false);
  364 + reloadPrepaidTable();
  365 + }}
  366 + />
  367 + )}
  368 +
  369 + {balanceChangeRecordsModalVisible && (
  370 + <BalanceChangeRecordsModal
  371 + setVisible={(val: boolean) => {
  372 + setBalanceChangeRecordsModalVisible(val);
  373 + }}
  374 + userInfoObj={currentOptUserObj}
  375 + onClose={() => {
  376 + setBalanceChangeRecordsModalVisible(false);
  377 + }}
  378 + />
  379 + )}
  380 + </div>
  381 + );
  382 +};
  383 +
  384 +export default PrepaidPage;
... ...