✨ feat:客户管理对接85%
This commit is contained in:
@@ -10,7 +10,7 @@ import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format
|
||||
import Form from "./components/form"
|
||||
import Remark from '../orderDetails/components/remark';
|
||||
import Address from "@/components/address"
|
||||
import { mppurchaser } from '@/api/customer'
|
||||
import { mppurchaser, mppurchaserpost, mppurchaserput } from '@/api/customer'
|
||||
|
||||
export default () => {
|
||||
|
||||
@@ -20,12 +20,18 @@ export default () => {
|
||||
|
||||
const [formData, setformData] = useState<any>()
|
||||
|
||||
useEffect(() => {
|
||||
if (router.params.type === 'edit') {
|
||||
getInfo()
|
||||
}
|
||||
}, [])
|
||||
|
||||
//默认业务员
|
||||
useDidShow(() => {
|
||||
if (router.params.type === 'add') {
|
||||
setNavigationBarTitle({ title: "新增客户" })
|
||||
} else {
|
||||
getInfo()
|
||||
|
||||
setNavigationBarTitle({ title: "客户编辑" })
|
||||
}
|
||||
let userInfo = JSON.parse(Taro.getStorageSync('userInfo'))
|
||||
@@ -34,8 +40,8 @@ export default () => {
|
||||
let currPage = pages[pages.length - 1]; // 获取当前页面
|
||||
//判断是否有跳转选择业务员
|
||||
if (currPage.data?.saleuserId && currPage.data?.saleuserId !== '') {
|
||||
setformData((e) => ({
|
||||
...e,
|
||||
setformData((val) => ({
|
||||
...val,
|
||||
sale_user_id: currPage.data?.saleuserId,
|
||||
sale_user_name: currPage.data?.saleuserName
|
||||
}))
|
||||
@@ -78,8 +84,8 @@ export default () => {
|
||||
address_detail: res.data?.address_detail,
|
||||
purchaser_type: res.data?.purchaser_type,
|
||||
district_id: res.data?.district_id
|
||||
// remark: res.data?.remark
|
||||
})
|
||||
setremarkDesc(res.data?.remark)
|
||||
Taro.hideLoading()
|
||||
}
|
||||
|
||||
@@ -140,10 +146,12 @@ export default () => {
|
||||
}
|
||||
|
||||
//备注操作
|
||||
const [remarkDesc, setremarkDesc] = useState('')
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
const getRemark = useCallback(async (e) => {
|
||||
setShowDesc(false)
|
||||
setformData((val) => ({ ...val, remark: e }))
|
||||
setremarkDesc(e)
|
||||
// setformData((val) => ({ ...val, remark: e }))
|
||||
}, [])
|
||||
|
||||
//地址选择
|
||||
@@ -198,6 +206,48 @@ export default () => {
|
||||
})
|
||||
}
|
||||
|
||||
const { fetchData: postFetch } = mppurchaserpost()
|
||||
const { fetchData: putFetch } = mppurchaserput()
|
||||
//提交
|
||||
const handSure = async () => {
|
||||
if (!isDisabled) return false
|
||||
let query = {
|
||||
...formData,
|
||||
remark: remarkDesc,
|
||||
id: infoObj?.id
|
||||
}
|
||||
if (router.params.type == 'add') {
|
||||
delete query.id
|
||||
}
|
||||
Taro.showModal({
|
||||
content: "确定要提交吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await (router.params.type == 'add' ? postFetch(query) : putFetch(query))
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
@@ -269,7 +319,7 @@ export default () => {
|
||||
></Form>
|
||||
</View>
|
||||
<DefaultBox title={'备注信息'} showMode={true} modeName={`${'填写/修改备注'} >`} clickNode={() => setShowDesc(true)}>
|
||||
<View className={styles.remarkFont}>{infoObj?.remark === '' ? '尚未备注信息' : infoObj?.remark}</View>
|
||||
<View className={styles.remarkFont}>{remarkDesc === '' ? '尚未备注信息' : remarkDesc}</View>
|
||||
</DefaultBox>
|
||||
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
|
||||
<Remark onSave={(e) => getRemark(e)} defaultValue={infoObj?.remark} showInput={showDesc ? true : false} />
|
||||
|
||||
Reference in New Issue
Block a user