diff --git a/src/credit/creditMpCustomer/add.config.ts b/src/credit/creditMpCustomer/add.config.ts new file mode 100644 index 0000000..cb5c110 --- /dev/null +++ b/src/credit/creditMpCustomer/add.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '新增小程序端客户', + navigationBarTextStyle: 'black' +}) diff --git a/src/credit/creditMpCustomer/add.tsx b/src/credit/creditMpCustomer/add.tsx new file mode 100644 index 0000000..51cdd3d --- /dev/null +++ b/src/credit/creditMpCustomer/add.tsx @@ -0,0 +1,98 @@ +import {useEffect, useState, useRef} from "react"; +import {useRouter} from '@tarojs/taro' +import {Button, Loading, CellGroup, Input, TextArea, Form} from '@nutui/nutui-react-taro' +import Taro from '@tarojs/taro' +import {View} from '@tarojs/components' +import {CreditMpCustomer} from "@/api/credit/creditMpCustomer/model"; +import {getCreditMpCustomer, listCreditMpCustomer, updateCreditMpCustomer, addCreditMpCustomer} from "@/api/credit/creditMpCustomer"; + +const AddCreditMpCustomer = () => { + const {params} = useRouter(); + const [loading, setLoading] = useState(true) + const [FormData, setFormData] = useState({}) + const formRef = useRef(null) + + const reload = async () => { + if (params.id) { + const data = await getCreditMpCustomer(Number(params.id)) + setFormData(data) + } else { + setFormData({}) + } + } + + // 提交表单 + const submitSucceed = async (values: any) => { + try { + if (params.id) { + // 编辑模式 + await updateCreditMpCustomer({ + ...values, + id: Number(params.id) + }) + } else { + // 新增模式 + await addCreditMpCustomer(values) + } + + Taro.showToast({ + title: `操作成功`, + icon: 'success' + }) + + setTimeout(() => { + return Taro.navigateBack() + }, 1000) + } catch (error) { + Taro.showToast({ + title: `操作失败`, + icon: 'error' + }); + } + } + + const submitFailed = (error: any) => { + console.log(error, 'err...') + } + + useEffect(() => { + reload().then(() => { + setLoading(false) + }) + }, []); + + if (loading) { + return 加载中 + } + + return ( + <> +
submitSucceed(values)} + onFinishFailed={(errors) => submitFailed(errors)} + footer={ +
+ +
+ } + > + + diff --git a/src/credit/creditMpCustomer/index.config.ts b/src/credit/creditMpCustomer/index.config.ts new file mode 100644 index 0000000..ec9d02f --- /dev/null +++ b/src/credit/creditMpCustomer/index.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '小程序端客户管理', + navigationBarTextStyle: 'black' +}) diff --git a/src/credit/creditMpCustomer/index.tsx b/src/credit/creditMpCustomer/index.tsx new file mode 100644 index 0000000..2c1ee7f --- /dev/null +++ b/src/credit/creditMpCustomer/index.tsx @@ -0,0 +1,64 @@ +import {useState} from "react"; +import Taro, {useDidShow} from '@tarojs/taro' +import {Button, Cell, CellGroup, Space, Empty, ConfigProvider, Divider} from '@nutui/nutui-react-taro' +import {Dongdong, ArrowRight, CheckNormal, Checked} from '@nutui/icons-react-taro' +import {View} from '@tarojs/components' +import {CreditMpCustomer} from "@/api/credit/creditMpCustomer/model"; +import {listCreditMpCustomer, removeCreditMpCustomer, updateCreditMpCustomer} from "@/api/credit/creditMpCustomer"; + +const CreditMpCustomerList = () => { + const [list, setList] = useState([]) + + const reload = () => { + listCreditMpCustomer({ + // 添加查询条件 + }) + .then(data => { + setList(data || []) + }) + .catch(() => { + Taro.showToast({ + title: '获取数据失败', + icon: 'error' + }); + }) + } + + + const onDel = async (id?: number) => { + await removeCreditMpCustomer(id) + Taro.showToast({ + title: '删除成功', + icon: 'success' + }); + reload(); + } + + useDidShow(() => { + reload() + }); + + if (list.length == 0) { + return ( + +
+ + + + +
+
+ ) + } + + return ( + <> + {list.map((item, _) => ( +