✨ feat:小程序角色权限控制

This commit is contained in:
Haiyi
2022-10-14 15:56:49 +08:00
parent 3f01990a35
commit 3111f211ae
11 changed files with 310 additions and 123 deletions
@@ -56,10 +56,11 @@
}
.rightFlex {
width: 50%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 100%;
// overflow: hidden;
// white-space: nowrap;
// text-overflow: ellipsis;
.placeholderStyle {
color: #f7f7f7;
font-size: 28px;
@@ -70,7 +71,7 @@
font-size: 28px;
font-weight: 400;
color: #000000;
width: 100%;
// width: 100%;
}
}
@@ -27,75 +27,77 @@ interface Params {
getScan?: (any) => void, // 扫描
navTo?: () => void, //跳转选择
showSizeFont?: boolean, //展示金额的大写
bigMoney?: any //展示的大写金额
bigMoney?: any, //展示的大写金额,
isOpen?: boolean //是否展开状态
}
export default memo((pros: Params) => {
return (
<View className={styles.itemBox}
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}>
<View className={styles.itemLeft}
<>
{
pros.isOpen && <View className={styles.itemBox}
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}>
<View className={styles.itemLeft}
>
<View className={styles.finkFlex}>
<View className={styles.itemTitle}>{pros.title}</View>
{
pros.require && <Text className={styles.xing}>*</Text>
}
</View>
{
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
}
</View>
{
pros.showPic &&
<View className={styles.bigPic}>
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
</View>
}
{
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
style={{
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`, alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
display: `${!pros.showSizeFont ? 'flex' : ''}`
}}
>
<View className={styles.rightFlex}>
>
<View className={styles.finkFlex}>
<View className={styles.itemTitle}>{pros.title}</View>
{
pros.require && <Text className={styles.xing}>*</Text>
}
</View>
{
pros.isInput && <Input
disabled={pros.disabled}
placeholder={pros.placeholderFont}
value={pros.inputValue}
className={styles.inputStyle}
type={pros.inputType}
placeholderStyle={styles.placeholderStyle}
onBlur={(e) => pros.getInput?.(e.detail.value)}
></Input>
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
}
</View>
<View className={styles.iconFlex}></View>
{
pros.showMore && <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'}></IconFont>
pros.showPic &&
<View className={styles.bigPic}>
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
</View>
}
{
pros.showScan && <View className={styles.shu}></View>
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
style={{
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`, alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
display: `${!pros.showSizeFont ? 'flex' : ''}`
}}
>
<View className={styles.rightFlex}>
{
pros.isInput && <Input
disabled={pros.disabled}
placeholder={pros.placeholderFont}
value={pros.inputValue}
className={styles.inputStyle}
type={pros.inputType}
placeholderStyle={styles.placeholderStyle}
onBlur={(e) => pros.getInput?.(e.detail.value)}
></Input>
}
</View>
}
{
pros.showScan && <View onClick={(e) => pros.getScan?.(e)}><IconFont name={'icon-saomiao'} size={50} color={'#337FFF'}></IconFont></View>
{/* <View className={styles.iconFlex}></View> */}
{
pros.showMore && <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'}></IconFont>
}
{
pros.showScan && <View className={styles.shu}></View>
}
{
pros.showScan && <View onClick={(e) => pros.getScan?.(e)}><IconFont name={'icon-saomiao'} size={50} color={'#337FFF'}></IconFont></View>
}
{
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
}
</View>
}
{
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
}
</View>
}
</View>
</>
)
})
+23
View File
@@ -6,6 +6,14 @@
transition: 0.3s;
}
.addBox:hover {
margin: 24px;
padding: 0px 32px 40px 32px;
background: #FFFFFF;
border-radius: 16px 16px 0px 0px;
transition: 0.3s;
}
.textAreaBox {
margin-top: 40px;
display: flex;
@@ -93,4 +101,19 @@
.safeBox {
height: 160px;
width: 100%;
}
.openBox {
height: 82px;
display: flex;
align-items: center;
justify-content: center;
line-height: 82px;
.openFont {
font-size: 28px;
font-weight: 400;
color: #337FFF;
margin-right: 10px;
}
}
+78 -30
View File
@@ -10,12 +10,14 @@ import Taro, { faceVerifyForPay, useDidShow } from '@tarojs/taro'
import Form from './components/form'
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
import {
mpcashManagementOrderpost
mpcashManagementOrderpost, mpshouldCollectOrderpurchaser
} from "@/api/newCollection"
import TimePicker from "@/components/timePicker"
import dayjs from 'dayjs'
import { alert } from "@/common/common"
import smallToBig from '@/common/money'
import IconFont from '@/components/iconfont/iconfont'
import { mpcashManagementOrderaccount } from '@/api/newCollection'
export default () => {
//获取选择的客户
@@ -26,10 +28,10 @@ export default () => {
setQuery((e) => ({
...e,
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : '',
clientName: currPage.data?.clientName ? currPage.data?.clientName : '',
bankId: currPage.data?.bankId ? currPage.data?.bankId : '',
bankName: currPage.data?.bankName ? currPage.data?.bankName : '',
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id,
clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName,
bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId,
bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName,
}))
})
@@ -39,17 +41,33 @@ export default () => {
const picUrl = useRef([])
const getImageList = useCallback((list) => {
picUrl.current = list
console.log(picUrl.current, 'picUrl.current')
setQuery((val) => ({ ...val, picList: list }))
}, [])
useEffect(() => {
getCuss()
}, [])
//获取首个银行账号
const { fetchData: clitentFetch } = mpcashManagementOrderaccount()
const getCuss = async () => {
let res = await clitentFetch({ page: 1, size: 10 })
if (res.data) {
setQuery((val) => ({ ...val, bankId: res.data.list[0].receiving_account_id, bankName: res.data.list[0].company_account }))
}
}
const { fetchData: scanFetch } = mpshouldCollectOrderpurchaser()
//扫描
const handScan = (e) => {
e.stopPropagation()
Taro.scanCode({
success(res) {
// setQuery({...Query})
// setsearchObj((e) => ({ ...e, orderNo: res.result }))
success: async function (res) {
const restult = await scanFetch({ order_no: res.result })
setQuery((val) => ({ ...val, purchaser_id: restult.data.purchaser_id, clientName: restult.data.purchaser_name }))
},
fail(res) {
console.log(res);
@@ -78,13 +96,13 @@ export default () => {
const isDisabled = useMemo(() => {
if (Query.clientName == '' ||
Query.money == '' ||
picUrl.current.length == 0
Query.picList?.length == 0
) {
return true
} else {
return false
}
}, [Query, picUrl])
}, [Query])
//收款金额回调
const getInput = (e) => {
@@ -95,11 +113,11 @@ export default () => {
setQuery(Query)
}, [Query])
useEffect(() => {
if (currPage.data?.clientId && (currPage.data?.clientId != Query.purchaser_id)) {
setQuery({ ...Query, bankId: '', bankName: '' })
}
}, [Query])
// useEffect(() => {
// if (currPage.data?.clientId && (currPage.data?.clientId != Query.purchaser_id)) {
// setQuery({ ...Query, bankId: '', bankName: '' })
// }
// }, [Query])
//备注信息
@@ -156,10 +174,28 @@ export default () => {
}
})
}
const [IsOpen, setIsOpen] = useState(false)
const handOpen = () => {
if (IsOpen) {
setIsOpen(false)
} else {
setIsOpen(true)
}
}
const openFont = useMemo(() => {
if (IsOpen) {
return '收起'
} else {
return '展开'
}
}, [IsOpen])
return (
<>
<View className={styles.addBox}>
<Form
isOpen={true}
title={'客户名称'}
require={true}
isInput={true}
@@ -175,6 +211,7 @@ export default () => {
showSizeFont={false}
></Form>
<Form
isOpen={true}
title={'收款金额'}
require={true}
isInput={true}
@@ -191,6 +228,7 @@ export default () => {
bigMoney={smallToBig(typeof (Query.money) == 'undefined' ? 0 : Query.money)}
></Form>
<Form
isOpen={true}
styleNone={false}
title={'收款凭证'}
require={true}
@@ -202,6 +240,7 @@ export default () => {
showSizeFont={false}
></Form>
<Form
isOpen={IsOpen}
title={'收款账户'}
require={false}
isInput={true}
@@ -215,22 +254,31 @@ export default () => {
navTo={() => navTo(2)}
showSizeFont={false}
></Form>
<View className={styles.textAreaBox}>
<View className={styles.textAreaLeft}>备注信息</View>
<View className={styles.textAreaRight}>
<Textarea
style={{ width: '70%' }}
onInput={(e) => getDesc(e.detail.value)}
value={TextareaValue}
placeholderStyle='font-size: 28rpx;font-weight: 400;'
maxlength={64}
placeholder={'请填写备注信息'}
></Textarea>
<View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View>
{
IsOpen && <View className={styles.textAreaBox}>
<View className={styles.textAreaLeft}>备注信息</View>
<View className={styles.textAreaRight}>
<Textarea
style={{ width: '70%' }}
onInput={(e) => getDesc(e.detail.value)}
value={TextareaValue}
placeholderStyle='font-size: 28rpx;font-weight: 400;'
maxlength={64}
placeholder={'请填写备注信息'}
></Textarea>
<View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View>
</View>
</View>
}
<View className={styles.openBox} onClick={() => handOpen()}>
<View className={styles.openFont}>{openFont}</View>
{
!IsOpen && <IconFont name={'icon-zhankai'} size={30} color={'#337FFF'} ></IconFont>
}
{
IsOpen && <IconFont name={'icon-shouqi'} size={30} color={'#337FFF'} ></IconFont>
}
</View>
</View >
<View className={styles.safeBox}> </View>
<View className={styles.bottomBox}>