|
@@ -1,25 +1,13 @@
|
|
|
import { useAjax } from '@/Hook/useAjax';
|
|
|
-import { apiDistributorInfoList } from '@/services/distribution/info';
|
|
|
-import {
|
|
|
- apiWxAppInfo,
|
|
|
- apiWxAppInfoPageList,
|
|
|
- apiWxAppInfoRemove,
|
|
|
- apiWxAppInfoUpdate,
|
|
|
- apiWxAppInfoUpdateEnabled,
|
|
|
- apiWxAppInfoWxAppConfigAddOrEdit,
|
|
|
- wechatMchAll,
|
|
|
-} from '@/services/distribution/weChatInfo';
|
|
|
-import { PlusCircleOutlined } from '@ant-design/icons';
|
|
|
import {
|
|
|
ActionType,
|
|
|
BetaSchemaForm,
|
|
|
- PageContainer,
|
|
|
ProFormInstance,
|
|
|
ProTable,
|
|
|
} from '@ant-design/pro-components';
|
|
|
import { useModel } from '@umijs/max';
|
|
|
import { Button, message } from 'antd';
|
|
|
-import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
+import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
|
import formConfig from './formConfig';
|
|
|
import { columns } from './tableConfig';
|
|
|
import { apiMiniappComponentInfoDel, apiMiniappComponentInfoPageList, apiMiniappComponentInfoSave, apiMiniappComponentInfoUpdate, apiMiniappComponentInfoUpdateEnabled } from '@/services/distribution/miniprogram';
|
|
@@ -28,13 +16,12 @@ type DataItem = {
|
|
|
name: string;
|
|
|
state: string;
|
|
|
};
|
|
|
-const Page: React.FC = () => {
|
|
|
+const Page = forwardRef((props: any, ref?: any) =>{
|
|
|
+ let { data,reload } = props
|
|
|
const formRef = useRef<ProFormInstance>();
|
|
|
- const assignRormRef = useRef<ProFormInstance>();
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
let { state } = useModel('global');
|
|
|
- let [open, setOpen] = useState<any>(null); //新增
|
|
|
- let [assignOpen, setAssignOpen] = useState(false);
|
|
|
+ let [open, setOpen] = useState<any>(null); //新增 存在ID代表是当前模板页面
|
|
|
let [editValues, setEditValues] = useState<any>({});
|
|
|
// ======API===============
|
|
|
let MiniappComponentInfoPageList = useAjax((params) => apiMiniappComponentInfoPageList(params), { type: 'table' }); //列表
|
|
@@ -49,7 +36,7 @@ const Page: React.FC = () => {
|
|
|
const del = (id: any) => {
|
|
|
MiniappComponentInfoDel.run(id).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
- actionRef?.current?.reload();
|
|
|
+ reload()
|
|
|
message.success('删除成功');
|
|
|
}
|
|
|
});
|
|
@@ -58,7 +45,7 @@ const Page: React.FC = () => {
|
|
|
const stateUpdata = (id: any, ck: boolean) => {
|
|
|
MiniappComponentInfoUpdateEnabled.run({ id, enabled: ck }).then((res) => {
|
|
|
if (res.data) {
|
|
|
- actionRef?.current?.reload();
|
|
|
+ reload()
|
|
|
message.success(ck ? '启动成功' : '停用成功');
|
|
|
}
|
|
|
});
|
|
@@ -68,10 +55,14 @@ const Page: React.FC = () => {
|
|
|
let api = editValues?.id ? MiniappComponentInfoUpdate : MiniappComponentInfoSave;
|
|
|
if (editValues?.id) {
|
|
|
values.id = editValues?.id;
|
|
|
+ values.enabledAppPageId = editValues?.enabledAppPageId
|
|
|
+ }else{
|
|
|
+ values.enabledAppPageId = open
|
|
|
}
|
|
|
+
|
|
|
api.run(values).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
- actionRef?.current?.reload();
|
|
|
+ reload()
|
|
|
message.success('操作成功!');
|
|
|
closeForm(false);
|
|
|
}
|
|
@@ -92,34 +83,24 @@ const Page: React.FC = () => {
|
|
|
setOpen(b);
|
|
|
}
|
|
|
};
|
|
|
+ useImperativeHandle(ref, () => ({
|
|
|
+ openMoadl:(id:any)=>{
|
|
|
+ setOpen(id)
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ console.log("open",open)
|
|
|
return (
|
|
|
- <PageContainer>
|
|
|
+ <div >
|
|
|
<ProTable<any, any>
|
|
|
- headerTitle={'小程序组件列表'}
|
|
|
+ headerTitle={false}
|
|
|
actionRef={actionRef}
|
|
|
rowKey={(r) => r.id}
|
|
|
- search={{
|
|
|
- labelWidth: 120,
|
|
|
- }}
|
|
|
+ search={false}
|
|
|
scroll={{ x: 'auto' }}
|
|
|
- request={async (params) => {
|
|
|
- return await MiniappComponentInfoPageList.run(params);
|
|
|
- }}
|
|
|
- toolBarRender={() => {
|
|
|
- return [
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- onClick={() => {
|
|
|
- setOpen(true);
|
|
|
- }}
|
|
|
- >
|
|
|
- <PlusCircleOutlined />
|
|
|
- 新增组件
|
|
|
- </Button>,
|
|
|
- ];
|
|
|
- }}
|
|
|
- columns={columns(closeForm, del, stateUpdata,state?.enumList)}
|
|
|
- // bordered
|
|
|
+ dataSource={data}
|
|
|
+ toolBarRender={false}
|
|
|
+ columns={columns(closeForm, del, stateUpdata, state?.enumList)}
|
|
|
+ // bordered
|
|
|
/>
|
|
|
{/* 新增修改 */}
|
|
|
<BetaSchemaForm<DataItem>
|
|
@@ -140,47 +121,7 @@ const Page: React.FC = () => {
|
|
|
columns={formConfig(state?.enumList)}
|
|
|
loading={MiniappComponentInfoSave?.loading || MiniappComponentInfoUpdate?.loading}
|
|
|
/>
|
|
|
- {/*指派 */}
|
|
|
- {/* <BetaSchemaForm<DataItem>
|
|
|
- title={editValues?.appName + '小程序指派'}
|
|
|
- formRef={assignRormRef}
|
|
|
- width={400}
|
|
|
- open={assignOpen}
|
|
|
- onOpenChange={(b) => {
|
|
|
- if (!b) {
|
|
|
- setEditValues({});
|
|
|
- setAssignOpen(false);
|
|
|
- }
|
|
|
- }}
|
|
|
- layoutType={'ModalForm'}
|
|
|
- labelCol={{ span: 6 }}
|
|
|
- wrapperCol={{ span: 14 }}
|
|
|
- grid={true}
|
|
|
- rowProps={{ gutter: [20, 20] }}
|
|
|
- layout="horizontal"
|
|
|
- onFinish={assign}
|
|
|
- columns={[
|
|
|
- {
|
|
|
- title: '分销商',
|
|
|
- dataIndex: 'distributorId',
|
|
|
- formItemProps: {
|
|
|
- style: { marginTop: 20 },
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '此项为必填项',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- valueEnum: () => {
|
|
|
- let arr = DistributorInfoList?.data?.data;
|
|
|
- return new Map(arr?.map(({ id, companyName }: any) => [id, companyName]));
|
|
|
- },
|
|
|
- },
|
|
|
- ]}
|
|
|
- loading={WxAppInfoWxAppConfigAddOrEdit?.loading}
|
|
|
- /> */}
|
|
|
- </PageContainer>
|
|
|
+ </div>
|
|
|
);
|
|
|
-};
|
|
|
+});
|
|
|
export default Page;
|