Commit 385cc9f7 by 李伟康

feat(common): 添加OCR识别功能并更新图标样式

- 在common模块中新增orcRecognition方法用于OCR识别功能
- 添加dateTime图标样式定义
- 更新detailArrow图标的背景位置坐标
- 更新employeeResponse图标的背景位置坐标
- 更新equityTip图标的背景位置坐标
- 更新errortips图标的背景位置坐标
- 更新eyesOff和eyesOn图标的背景位置坐标
- 更新filter图标的背景位置坐标
- 更新frontGear、frontWindow和fullScreen图标的背景位置坐标
- 更新iconAppeal、iconArrow、iconCopy图标的背景位置坐标
- 更新iconInstructions、iconNavigation、iconNotice图标的背景位置坐标
- 更新iconScanning、iconSelect、iconShop图标的背景位置坐标
- 更新iconStore、iconWeixin图标的背景位置坐标
- 更新location图标的背景位置坐标
1 parent b1941237
...@@ -700,4 +700,12 @@ module.exports = { ...@@ -700,4 +700,12 @@ module.exports = {
...data, ...data,
}) })
}, },
/** OCR 识别 */
orcRecognition(data = {}) {
return http.post({
method: 'dj.api.common.ocr.recognition',
projectName: 'boutique',
...data,
})
},
} }

3.21 MB | W: | H:

3.21 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -111,7 +111,6 @@ export default { ...@@ -111,7 +111,6 @@ export default {
this.$refs.editForm.open(data, c_index, index, parent) this.$refs.editForm.open(data, c_index, index, parent)
}, },
confirm (data, c_index, index) { confirm (data, c_index, index) {
console.log(data)
this.$set(this.list[index].children, c_index, utils.deepClone(data)) this.$set(this.list[index].children, c_index, utils.deepClone(data))
} }
} }
......
...@@ -84,48 +84,7 @@ export default { ...@@ -84,48 +84,7 @@ export default {
{ {
rowHeader: '客户电话', rowHeader: '客户电话',
data: ['12345678901', 'ddd', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', 123] data: ['12345678901', 'ddd', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', '12345678901', 123]
}, }
{
rowHeader: '客户地址',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户来源',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
{
rowHeader: '客户备注',
data: ['XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX', 'XX']
},
] ]
} }
}, },
......
<template>
<view class="car-model-box">
<scroll-view
class="scroll-view"
scroll-y
:scroll-into-view="letter"
>
<template v-if="listData.length">
<template v-for="(i, index) in listData">
<view
class="item-box"
:key="index"
:id="i.letter"
>
<view class="letter-title flex">{{i.letter}}</view>
<template v-for="(c,cindex) in i.list">
<view
class="car-model"
:key="cindex"
>
<view class="brand-name">{{c.name}}</view>
<template v-for="(j, jindex) in c.childs">
<view
:key="jindex"
class="car-block"
>
<view
class="sub-brand-name"
@click="getCarSeries(j,c)"
>
{{j.name}}
</view>
<view class="series-list">
<template v-for="(k, kindex) in j.childs">
<view
class="series-name"
:key="kindex"
>
<view
class="series-name flex"
@click="getCarTypeList(k)"
>
{{k.name}}
<uni-icons
:type="`${k.childs && k.childs.length && k.open ?'down':'right'}`"
size="18"
></uni-icons>
</view>
<view
class="brand-list"
v-if="k.open"
>
<template v-for="(s,sindex) in k.childs">
<view
:class="['item flex',{active: checkActive(s)}]"
:key="`${s.id}_${sindex}`"
@click.stop="chooseCarType(s,c)"
>
{{s.name}}
<view class="sprite-icon icon-tag-checked"></view>
</view>
</template>
</view>
</view>
</template>
</view>
</view>
</template>
</view>
</template>
</view>
</template>
</template>
</scroll-view>
<view class="letter-list">
<template v-for="(i, index) in listData">
<view
class="letter-item"
:key="index"
@click="letter = i.letter"
>
{{i.letter}}
</view>
</template>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
import popupmixin from './popupmixin'
export default {
mixins: [popupmixin],
name: 'CarModelList',
data () {
return {
letter: 'A',
}
},
mounted () {
},
methods: {
async getList (searchValue) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentId = ''
if (cacheData && cacheData.length) {
this.initData(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
const { shopMerchantId } = userInfo,
{ data } = await uni.$api.commonApi.getMerchantCarBrandList([shopMerchantId]),
{ carBrandList } = data[0]
this.updateParams(params, carBrandList || [])
},
initData (carData) {
let { params: { idKey }, data: { customer, carInfo } } = this,
letterList = Array.from(new Set([...carData.map((e) => e.letter)])),
carModelList = letterList.map(e => {
let list = []
carData.map(i => {
if (e === i.letter) {
list.push(i)
}
})
return {
letter: e,
list,
}
})
console.log(carModelList)
this.list = carModelList
this.$emit('onComplete')
},
handleSearch (searchValue) {
if (!searchValue) {
this.searchStatus = false
this.letter = 'A'
} else {
searchValue = searchValue.toUpperCase()
let { list } = this,
carBrand = JSON.parse(JSON.stringify(list))
let arr = [];
carBrand.map(c => {
c.list.map(i => {
let childs = [],
i_name = i.name.toUpperCase()
i.childs.map((k) => {
let k_name = k.name.toUpperCase()
if (k_name.indexOf(searchValue) != -1) {
childs.push(k);
}
});
if (i_name.indexOf(searchValue) != -1 || childs.length > 0) {
i.childs = childs.length > 0 ? childs : i.childs;
arr.push(i);
}
})
})
let letterList = Array.from(new Set([...arr.map((e) => e.letter)]));
let searchList = letterList.map((l) => {
let _list = [];
arr.map((i) => {
if (l === i.letter) {
_list.push(i);
}
})
return {
letter: l,
list: _list,
}
})
this.searchList = searchList
this.searchStatus = true
}
},
async getCarSeries (j, c) {
if (j.childs && j.childs.length) return
uni.showLoading({
mask: true
})
const data = await uni.$api.popupApi.getCarSeriesList({
brandId: c.id,
childBrandId: j.id
})
uni.hideLoading()
j.childs = data
this.$forceUpdate()
},
async getCarTypeList (k) {
if (k.childs && k.childs.length) {
k.open = !k.open
this.$forceUpdate()
return
}
uni.showLoading({
mask: true
})
const data = await uni.$api.popupApi.getCarTypeList({
carSeriesId: k.id
})
uni.hideLoading()
if (data && data.length) {
k.childs = data
k.open = true
console.log(k)
this.$forceUpdate()
} else uni.showToast({
title: '暂无数据',
icon: 'none'
})
},
chooseCarType (s, c) {
let chooseItem = {
vehicleBrandId: c.id,
vehicleBrandName: c.name,
vehicleSubBrandId: s.brandId,
vehicleSubBrandName: s.brandName,
vehicleSeriesId: s.seriesId,
vehicleSeriesName: s.seriesName,
vehicleShapeId: s.id,
vehicleShapeName: s.name
}
this.currentId = s.id
this.$emit('choose', chooseItem)
},
checkActive (s) {
let { currentId, data, params, data: { key } } = this,
carInfo = data[key] || {}
return (currentId ? s.id == currentId : s.id == carInfo[params.idKey] || '' )
},
}
}
</script>
<style scoped lang='scss'>
.car-model-box {
position: relative;
height: 100%;
width: 100%;
.scroll-view {
height: 100%;
}
.letter-list {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
color: #888888;
font-size: toRpx(28);
line-height: toRpx(40);
padding: 0 toRpx(18);
text-align: center;
}
.item-box {
margin-bottom: toRpx(32);
.letter-title {
color: #888888;
font-size: toRpx(28);
height: toRpx(40);
background: #f5f7fa;
padding-left: toRpx(48);
}
.car-model {
margin: 0 toRpx(48);
.brand-name {
color: #000;
font-size: toRpx(40);
line-height: toRpx(40);
margin: toRpx(20) 0;
font-weight: 500;
}
.car-block {
border-bottom: toRpx(2) solid #dce0e6;
}
.sub-brand-name {
color: #333;
font-size: toRpx(32);
line-height: toRpx(40);
width: 100%;
flex-shrink: 0;
margin: 16rpx 0;
padding-left: 10rpx;
}
.series-name {
color: #555;
font-size: toRpx(28);
line-height: toRpx(40);
width: 100%;
flex-shrink: 0;
margin-bottom: 16rpx;
padding-left: 20rpx;
}
}
}
.brand-list {
// display: grid;
// grid-template-columns: repeat(4, 1fr);
gap: toRpx(32);
display: flex;
// gap: toRpx(32) 0;
flex-wrap: wrap;
padding: 0 20rpx;
.item {
width: calc((100% - #{toRpx(96)}) / 4);
justify-content: center;
min-height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
padding: 10rpx 20rpx;
box-sizing: border-box;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<view class="employee-list">
<template v-for="(i, index) in listData">
<view
:key="index"
@click="choose(i)"
:class="['item flex', { active: checkActive(i) }]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{ i.staffName }}
</view>
</template>
</view>
</template>
<script type="text/ecmascript-6">
import popupmixin from './popupmixin'
export default {
mixins: [popupmixin],
name: 'EmployeeList',
inject: ['userInfo'],
data () {
return {
}
},
computed: {
idKey () {
let { params: { idKey }, sceneType } = this
return Array.isArray(idKey) ? idKey[sceneType] : idKey
}
},
mounted () {
},
methods: {
async getList (searchValue, search) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentId = ''
if (!search && cacheData && cacheData.length) {
this.initData(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
this.componentLoading(params)
const { shopMerchantId, sceneType, merchantId } = userInfo,
apiTargetName = sceneType == 1 || params.defeat ? 'getEmployeeList' : 'getOrderScreenEmployeeList',
apiParams = {
merchantId: params.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'sellerUserId' ? '' : [sceneType],
}
if (searchValue) apiParams.name = searchValue
const data = await uni.$api.popupApi[apiTargetName](apiParams)
this.updateParams(params, data || [])
},
initData (list) {
const { data, data: { key } } = this
if (data[key]) {
this.currentId = data[key]
let item = list.find(i => i.uuid == this.currentId)
this.$emit('choose', item)
}
this.list = list
this.$emit('onComplete')
},
handleSearch (searchValue) {
const { sceneType } = this
if (sceneType == 1) {
this.list = []
this.getList(searchValue, true)
} else this.originalDataSearch(searchValue)
},
originalDataSearch (searchValue) {
console.log(searchValue, '===')
if (!searchValue) this.searchStatus = false
else {
searchValue = searchValue.toUpperCase()
let { list } = this,
employeeList = JSON.parse(JSON.stringify(list)),
arr = []
employeeList.map(e => {
if (e.staffName && e.staffName.toUpperCase().indexOf(searchValue) != -1) arr.push(e)
})
this.searchList = arr
this.searchStatus = true
}
},
choose (i) {
this.currentId = i.uuid
this.$emit('choose', i)
},
checkActive (i) {
let { currentId, data: { key }, data } = this
return currentId ? i.uuid == currentId : i.uuid == data[key]
}
}
}
</script>
<style scoped lang="scss">
.employee-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: toRpx(32);
margin: 0 toRpx(48);
.item {
justify-content: center;
height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
export default {
inject: ['userInfo', 'baseConfigData'],
data () {
return {
list: [],
searchStatus: false,
searchList: [],
chooseList: [],
currentId: '',
currentIds: [],
}
},
props: {
params: Object,
data: [Object, Array],
dataKey: String,
isDefeatOrder: Boolean,
positionTypeList: Array,
},
computed: {
listData () {
return this.searchStatus ? this.searchList : this.list
},
noData () {
return !this.listData.length
},
sceneType(){
return uni.$storage.get('userInfo').sceneType
}
},
watch: {
noData: {
handler (val) {
let { params } = this
params.noData = val
this.updateParams(params)
},
deep: true
}
},
methods: {
updateParams (params, data) {
if (data) {
this.initData && this.initData(data)
params.cacheData = data
}
this.$emit('update:params', params)
},
componentLoading (params) {
params.loadComplete = false
this.$emit('update:params', this.params)
}
}
}
\ No newline at end of file \ No newline at end of file
/**
* popupType
* 0:销售顾问
* 1:交付专员
* 2:车品牌
* 4: 订单
* 5: 日历
*/
const componentConfig = {
0: {
name: 'EmployeeList',
title: '销售顾问/录单员',
placeholder: '请输入姓名',
idKey: ['userId'],
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false
},
1: {
name: 'EmployeeList',
title: '交付专员',
placeholder: '请输入姓名',
nullTips: '请选择交付专员',
idKey: ['deliveryId'],
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false
},
3: {
name: 'CarModelList',
title: '选择车型',
placeholder: '查找',
idKey: 'vehicleShapeId',
nullTips: '请选择车型',
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false,
},
4: {
},
5: {
name: 'Calendar',
title: '日历',
placeholder: '请选择日期',
nullTips: '请选择日期',
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false
}
}
export default { componentConfig }
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
v-if="itemShow(item)" v-if="itemShow(item)"
@onSelect="onSelect($event, ind)" @onSelect="onSelect($event, ind)"
@onInput="onInput($event, ind)" @onInput="onInput($event, ind)"
@openSelect="openSelect(...arguments, ind)"
@onScanSuccess="onScanSuccess($event, ind)"
/> />
</template> </template>
</view> </view>
...@@ -52,6 +54,13 @@ ...@@ -52,6 +54,13 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<DailyPopup
ref="dailyPopup"
@onConfirm="onPopupConfirm"
:startDate="startDate"
:endDate="endDate"
/>
</view> </view>
</template> </template>
...@@ -59,9 +68,10 @@ ...@@ -59,9 +68,10 @@
import Popup from '@/components/Popup.vue' import Popup from '@/components/Popup.vue'
import FormItem from './FormItem.vue' import FormItem from './FormItem.vue'
import utils from '@/utils/utils' import utils from '@/utils/utils'
import DailyPopup from './DailyPopup/index.vue'
import dayjs from 'dayjs'
export default { export default {
components: { Popup, FormItem }, components: { Popup, FormItem, DailyPopup },
name: 'EditForm', name: 'EditForm',
props: { props: {
cancelText: { cancelText: {
...@@ -75,12 +85,32 @@ export default { ...@@ -75,12 +85,32 @@ export default {
}, },
data () { data () {
return { return {
carBrandData: [],
data: {}, data: {},
c_index: 0, c_index: 0,
index: 0, index: 0,
parent: {} parent: {},
currentItem: {}
}
},
computed: {
startDate () {
let childrenRules = this.parent.childrenRules,
item = this.currentItem
if (childrenRules && item.key) {
let rules = childrenRules[item.key]
return rules?.minDate ? dayjs(eval(rules.minDate)).format('YYYY-MM-DD') : '2020-01-01'
}
},
endDate () {
let childrenRules = this.parent.childrenRules,
item = this.currentItem
if (childrenRules && item.key) {
let rules = childrenRules[item.key]
return rules?.maxDate ? dayjs(eval(rules.maxDate)).format('YYYY-MM-DD') : '2020-01-01'
} }
}, },
},
mounted () { mounted () {
}, },
methods: { methods: {
...@@ -90,8 +120,14 @@ export default { ...@@ -90,8 +120,14 @@ export default {
return rules[item.key] || null return rules[item.key] || null
} else return null } else return null
}, },
/**
*
* @param data 表单数据
* @param c_index 子菜单index
* @param index 父级index
* @param parent 父级数据
*/
open (data, c_index, index, parent) { open (data, c_index, index, parent) {
console.log(c_index, index)
this.data = utils.deepClone(data) || {} this.data = utils.deepClone(data) || {}
this.c_index = c_index || 0 this.c_index = c_index || 0
this.index = index || 0 this.index = index || 0
...@@ -124,7 +160,8 @@ export default { ...@@ -124,7 +160,8 @@ export default {
let { keys, result } = childrenShowRules[item.key], let { keys, result } = childrenShowRules[item.key],
{ data } = this, { data } = this,
params = keys.map((i, index) => `val${index + 1}`), params = keys.map((i, index) => `val${index + 1}`),
func = new Function(...params, result), // 将 new Function 改为 eval 方式
func = eval(`(function(${params.join(',')}) { return ${result}; })`),
value = [] value = []
keys.map(key => { keys.map(key => {
let item = data.find(i => i.key == key) let item = data.find(i => i.key == key)
...@@ -142,9 +179,34 @@ export default { ...@@ -142,9 +179,34 @@ export default {
this.$set(this.data[index], 'value', val) this.$set(this.data[index], 'value', val)
}, },
onSelect (val, index) { onSelect (val, index) {
console.log(val)
this.$set(this.data[index], 'value', val) this.$set(this.data[index], 'value', val)
},
openSelect (item, type, index) {
this.currentItem = item
this.$refs.dailyPopup.open(item, type, index)
},
onScanSuccess (val, index) {
this.$set(this.data[index], 'value', val)
},
onPopupConfirm ({
chooseContent,
popupType,
itemIndex
}) {
if (popupType == 5) {
this.$set(this.data[itemIndex], 'value', chooseContent)
} else if (popupType == 3) {
console.log(chooseContent)
const { vehicleBrandName, vehicleSubBrandName, vehicleSeriesName, vehicleShapeName } = chooseContent
this.$set(this.data[itemIndex], 'value', `${vehicleBrandName}-${vehicleSubBrandName}-${vehicleSeriesName}-${vehicleShapeName}`)
this.$set(this.data[itemIndex], this.data[itemIndex].key, chooseContent)
} else {
this.$set(this.data[itemIndex], 'value', chooseContent.staffName)
this.$set(this.data[itemIndex], this.data[itemIndex].key, chooseContent.uuid)
}
} }
} }
} }
</script> </script>
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
<view <view
:class="['select flex', { 'placeholderStyle': !item.value }]" :class="['select flex', { 'placeholderStyle': !item.value }]"
@click="select" @click="select"
>{{ item.value || item.placeholder || '请选择' }} >
<text class="text-hide">{{ item.value || item.placeholder || '请选择' }}</text>
<view class="sprite-icon icon-icon-select"></view> <view class="sprite-icon icon-icon-select"></view>
</view> </view>
</template> </template>
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
<view <view
:class="['select flex', { 'placeholderStyle': !item.value }]" :class="['select flex', { 'placeholderStyle': !item.value }]"
@click="select" @click="select"
>{{ item.value || item.placeholder || '请选择' }} ><text class="text-hide">{{ item.value || item.placeholder || '请选择' }}</text>
<view class="sprite-icon icon-icon-select"></view> <view class="sprite-icon icon-icon-select"></view>
</view> </view>
</picker> </picker>
...@@ -72,20 +73,10 @@ ...@@ -72,20 +73,10 @@
<template v-else-if="item.type == 'datetime'"> <template v-else-if="item.type == 'datetime'">
<view <view
:class="['select flex', { 'placeholderStyle': !item.value }]" :class="['select flex', { 'placeholderStyle': !item.value }]"
@click="$refs.calendar.open()" @click="select"
>{{ item.value || item.placeholder || '请选择' }} >{{ item.value || item.placeholder || '请选择' }}
<view class="sprite-icon icon-date-time"></view> <view class="sprite-icon icon-date-time"></view>
</view> </view>
<uni-calendar
ref="calendar"
:insert="false"
:clearDate="false"
:startDate="startDate"
:endDate="endDate"
@confirm="confirmCalendar"
hideMask
showBottomBtn
/>
</template> </template>
<template v-else-if="item.type == 'radio'"> <template v-else-if="item.type == 'radio'">
<radio-group <radio-group
...@@ -104,7 +95,7 @@ ...@@ -104,7 +95,7 @@
<template v-else-if="item.type == 'numberInput'"> <template v-else-if="item.type == 'numberInput'">
<input <input
:placeholder="item.placeholder || '请输入'" :placeholder="item.placeholder || '请输入'"
:value="item.value" v-model="item.value"
class="input" class="input"
:maxlength="rules.maxLength || 11" :maxlength="rules.maxLength || 11"
placeholder-class="placeholderStyle" placeholder-class="placeholderStyle"
...@@ -112,9 +103,20 @@ ...@@ -112,9 +103,20 @@
@input="numberInput" @input="numberInput"
/> />
</template> </template>
<template v-else-if="item.type == 'carBrandSelect'">
<view
:class="['select flex', { 'placeholderStyle': !item.value }]"
@click="select"
><text class="text-hide">{{ item.value || item.placeholder || '请选择' }}</text>
<view class="sprite-icon icon-icon-select"></view>
</view>
</template>
</template> </template>
<template v-if="item.prefixComponent"> <template v-if="item.prefixComponent">
<view :class="[`sprite-icon icon-${item.prefixComponent}Icon`]"></view> <view
:class="[`sprite-icon icon-${item.prefixComponent}Icon`]"
@click="clickPrefix"
></view>
</template> </template>
<template v-if="item.unit"> <template v-if="item.unit">
<view class="unit">{{ item.unit }}</view> <view class="unit">{{ item.unit }}</view>
...@@ -127,6 +129,8 @@ ...@@ -127,6 +129,8 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import utils from '@/utils/utils' import utils from '@/utils/utils'
import permision from '@/js_sdk/wa-permission/permission.js'
export default { export default {
name: 'FormItem', name: 'FormItem',
props: { props: {
...@@ -153,13 +157,13 @@ export default { ...@@ -153,13 +157,13 @@ export default {
let { rules } = this let { rules } = this
return rules.maxLength ? `请输入(${rules.maxLength}字以内)` : '请输入' return rules.maxLength ? `请输入(${rules.maxLength}字以内)` : '请输入'
}, },
startDate () { popupType () {
let { rules } = this let { item } = this,
return rules.minDate ? dayjs(eval(rules.minDate)).format('YYYY-MM-DD') : '2020-01-01' popupType = {
}, datetime: 5,
endDate () { carBrandSelect: 3
let { rules } = this }[item.type] || 0
return rules.maxDate ? dayjs(eval(rules.maxDate)).format('YYYY-MM-DD') : '2099-12-31' return popupType
}, },
}, },
data () { data () {
...@@ -170,20 +174,97 @@ export default { ...@@ -170,20 +174,97 @@ export default {
mounted () { mounted () {
}, },
methods: { methods: {
confirmCalendar ({ fulldate }) {
this.$emit('onSelect', fulldate)
},
input (e) { input (e) {
this.$emit('onInput', e.detail.value) this.$emit('onInput', e.detail.value)
}, },
select (e) { select (e) {
let { item } = this let { item } = this
if (item.optionsKey) { if (item.optionsKey || item.type == 'datetime' || item.type == 'carBrandSelect') {
console.log(this.popupType)
this.$emit('openSelect', item, this.popupType)
} else { } else {
this.$emit('onSelect', item.options[e.detail.value].value) this.$emit('onSelect', item.options[e.detail.value].value)
} }
}, },
async clickPrefix () {
let { item } = this
if (item.prefixComponent == 'scan') {
try {
// #ifdef APP-PLUS
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) throw '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限'
if (camera != 1) throw '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限'
if (!isOnline) throw '当前无网络连接,请连接网络后重试'
// #endif
let that = this
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
success: async function (res) {
console.log(res)
// 将图片转换为base64
const tempFilePath = res.tempFilePaths[0]
try {
const base64 = await that.getBase64FromImagePath(tempFilePath)
that.orcRecogintion(base64)
} catch (error) {
console.error('转换base64失败:', error)
uni.showToast({
title: '图片转换失败',
icon: 'none'
})
}
}
})
} catch (error) {
uni.hideLoading()
return uni.showToast({
title: error,
icon: 'none'
})
}
}
},
getBase64FromImagePath (imagePath) {
return new Promise((resolve, reject) => {
// APP 平台使用 plus.io 来读取文件
plus.io.resolveLocalFileSystemURL(imagePath, (entry) => {
entry.file((file) => {
const reader = new plus.io.FileReader()
reader.onloadend = (e) => {
const base64 = e.target.result
let prefix = 'data:image/png;base64,'
if (imagePath.toLowerCase().endsWith('.jpg') || imagePath.toLowerCase().endsWith('.jpeg')) {
prefix = 'data:image/jpeg;base64,'
} else if (imagePath.toLowerCase().endsWith('.gif')) {
prefix = 'data:image/gif;base64,'
}
resolve(prefix + base64.split(',')[1]) // 去掉 data URL 前缀,因为我们自己添加
}
reader.onerror = (err) => {
reject(err)
}
reader.readAsDataURL(file)
}, (err) => {
reject(err)
})
}, (err) => {
reject(err)
})
})
},
async orcRecogintion (imgBase64) {
/**
* type 3 : standNo 车架号
*/
const res = await uni.$api.commonApi.orcRecognition({ type: 3, imgBase64 })
console.log('进行 orc 识别', res)
if(res.vin) this.$emit('onScanSuccess', res.vin)
else uni.showToast({ title: '识别失败', icon: 'none' })
},
numberInput (e) { numberInput (e) {
let { rules } = this, let { rules } = this,
val = e.detail.value, val = e.detail.value,
...@@ -206,9 +287,11 @@ export default { ...@@ -206,9 +287,11 @@ export default {
if (!isNaN(numValue) && numValue > max) { if (!isNaN(numValue) && numValue > max) {
filtered = String(max); filtered = String(max);
} }
e.detail.value = filtered
this.$set(this.item, 'value', filtered) this.$set(this.item, 'value', filtered)
this.$emit('onInput', filtered) this.$emit('onInput', filtered)
this.$nextTick(() => {
this.$forceUpdate()
})
} }
if (rules.decimal) { if (rules.decimal) {
// 只保留数字和小数点 // 只保留数字和小数点
...@@ -248,8 +331,12 @@ export default { ...@@ -248,8 +331,12 @@ export default {
} }
this.$set(this.item, 'value', filtered) this.$set(this.item, 'value', filtered)
this.$emit('onInput', filtered) this.$emit('onInput', filtered)
this.$nextTick(() => {
this.$forceUpdate()
})
} }
} },
} }
} }
</script> </script>
...@@ -266,12 +353,15 @@ export default { ...@@ -266,12 +353,15 @@ export default {
font-size: 28rpx; font-size: 28rpx;
font-weight: 400; font-weight: 400;
line-height: 40rpx; line-height: 40rpx;
flex-shrink: 0;
.required { .required {
color: #f24724; color: #f24724;
} }
} }
&-content { &-content {
flex: 1; flex: 1;
max-width: 75%;
margin-left: auto;
.input, .input,
.radio-group { .radio-group {
text-align: right; text-align: right;
...@@ -326,6 +416,7 @@ export default { ...@@ -326,6 +416,7 @@ export default {
height: 80rpx; height: 80rpx;
} }
.item-content { .item-content {
max-width: 100%;
height: 192rpx; height: 192rpx;
border-radius: 16rpx; border-radius: 16rpx;
border: 2rpx solid #eff0f2; border: 2rpx solid #eff0f2;
......
...@@ -66,12 +66,14 @@ ...@@ -66,12 +66,14 @@
</view> </view>
</view> </view>
</view> </view>
<template v-if="hasFooter">
<view class="footer-row"> <view class="footer-row">
<view <view
class="add" class="add"
@click="$emit('clickAdd')" @click="$emit('clickAdd')"
></view> ></view>
</view> </view>
</template>
</view> </view>
</view> </view>
...@@ -99,7 +101,7 @@ export default { ...@@ -99,7 +101,7 @@ export default {
}, },
LeftWidth: { LeftWidth: {
type: String, type: String,
default: '400rpx' default: '200rpx'
}, },
tableStyle: { tableStyle: {
type: String, type: String,
......
...@@ -298,7 +298,7 @@ export default { ...@@ -298,7 +298,7 @@ export default {
showNextBtn () { showNextBtn () {
let { cale, endDate, nowDate } = this, let { cale, endDate, nowDate } = this,
maxDate = cale.getDate(endDate, -1, 'month') maxDate = cale.getDate(endDate, -1, 'month')
return !endDate ? true :cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${maxDate.year}/${maxDate.month}`) return !endDate ? true : cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${maxDate.year}/${maxDate.month}`)
}, },
showPreBtn () { showPreBtn () {
let { cale, startDate, nowDate } = this, let { cale, startDate, nowDate } = this,
...@@ -668,10 +668,12 @@ $uni-text-color-grey: #999; ...@@ -668,10 +668,12 @@ $uni-text-color-grey: #999;
width: 50px; width: 50px;
height: 50px; height: 50px;
} }
.next-btn ,.prev-btn{ .next-btn,
.prev-btn {
opacity: 0; opacity: 0;
} }
.show-next-btn ,.show-prev-btn{ .show-next-btn,
.show-prev-btn {
opacity: 1; opacity: 1;
} }
.uni-calendar__header-btn { .uni-calendar__header-btn {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!