<template>
|
<view class="box">
|
<view class="box_list">
|
<u--form
|
labelPosition="top"
|
:model="model"
|
:rules="rules"
|
labelWidth="160"
|
ref="uForm"
|
>
|
<u-form-item
|
label="姓名:"
|
prop="name"
|
borderBottom
|
>
|
<u--input v-model="model.name" border="none" placeholder="请输入"></u--input>
|
</u-form-item>
|
<u-form-item
|
label="身份证号:"
|
prop="idCard"
|
borderBottom
|
>
|
<view style="idth: 100%; position: relative;">
|
<u--input v-model="model.idCard" maxlength="18" border="none" placeholder="请输入"></u--input>
|
<button style="position: absolute; top: 0; right: 0; font-size: 22rpx;" @click="test">识别身份证</button>
|
</view>
|
</u-form-item>
|
<u-form-item
|
label="派遣单位:"
|
prop="pqId"
|
borderBottom
|
@click="show = true"
|
>
|
<u--input
|
v-model="model.pqName"
|
disabled
|
disabledColor="#ffffff"
|
placeholder="请选择"
|
border="none"
|
></u--input>
|
<u-icon
|
slot="right"
|
name="arrow-right"
|
></u-icon>
|
</u-form-item>
|
<u-form-item
|
label="所属工种:"
|
prop="gzId"
|
borderBottom
|
@click="show1 = true"
|
>
|
<u--input
|
v-model="model.gzName"
|
disabled
|
disabledColor="#ffffff"
|
placeholder="请选择"
|
border="none"
|
></u--input>
|
<u-icon
|
slot="right"
|
name="arrow-right"
|
></u-icon>
|
</u-form-item>
|
<u-form-item
|
label="备注:"
|
prop="remark"
|
borderBottom
|
>
|
<u--input v-model="model.remark" border="none" placeholder="请输入"></u--input>
|
</u-form-item>
|
</u--form>
|
</view>
|
<view class="box_footer">
|
<u-button type="primary" shape="circle" color="#437CB3" text="确认添加" @click="submit"></u-button>
|
</view>
|
<!-- 派遣单位 -->
|
<u-picker :show="show" :columns="columns" confirmColor="#437CB3" keyName="label" @cancel="show = false" @confirm="confirm"></u-picker>
|
<!-- 工种 -->
|
<u-picker :show="show1" :columns="columns1" confirmColor="#437CB3" keyName="label" @cancel="show1 = false" @confirm="confirm1"></u-picker>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
show: false,
|
show1: false,
|
solutionId: null,
|
columns: [],
|
columns1: [],
|
duSolutionId: '',
|
model: {
|
name: '',
|
remark:'',
|
idCard: '',
|
gzId: '',
|
gzName: '',
|
pqId: '',
|
pqName: ''
|
},
|
rules: {
|
'name': {
|
type: 'string',
|
required: true,
|
message: '请填写姓名',
|
trigger: ['blur', 'change']
|
},
|
'idCard': {
|
type: 'string',
|
required: true,
|
message: '请填写身份证号',
|
trigger: ['blur', 'change']
|
}
|
}
|
};
|
},
|
onLoad(options) {
|
this.solutionId = options.solutionId
|
this.getDispatchingUnit()
|
},
|
methods: {
|
test() {
|
var that = this;
|
// 选择图片
|
wx.chooseImage({
|
count: 1,
|
success: async function(res) {
|
try {
|
uni.showLoading({ title: '识别中' });
|
const invokeRes = await wx.serviceMarket.invokeService({
|
service: 'wx79ac3de8be320b71',
|
api: 'OcrAllInOne',
|
data: {
|
// 用 CDN 方法标记要上传并转换成 HTTP URL 的文件
|
img_url: new wx.serviceMarket.CDN({
|
type: 'filePath',
|
filePath: res.tempFilePaths[0],
|
}),
|
data_type: 3,
|
ocr_type: 1
|
},
|
})
|
that.model.idCard = invokeRes.data.idcard_res.id.text
|
that.model.name = invokeRes.data.idcard_res.name.text
|
uni.hideLoading();
|
} catch (err) {
|
wx.showModal({ title: 'fail', content: err })
|
uni.hideLoading();
|
}
|
},
|
fail: function(res) {},
|
complete: function(res) {},
|
})
|
},
|
// 派遣单位
|
getDispatchingUnit() {
|
this.$u.api.findListByDTO({
|
solutionId: this.solutionId
|
}).then(res => {
|
if (res.code === 200) {
|
let arr = res.data.map(item => {
|
return {
|
label: item.name,
|
duSolutionId: item.duSolutionId,
|
id: item.id
|
}
|
})
|
this.columns.push(arr)
|
}
|
})
|
},
|
// 工种
|
getGZ() {
|
this.$u.api.worktypeFindListByDTO({
|
id: this.duSolutionId,
|
queryType: 1
|
}).then(res => {
|
if (res.code === 200) {
|
let arr = res.data.map(item => {
|
return {
|
label: item.name,
|
id: item.id
|
}
|
})
|
this.columns1 = [arr]
|
}
|
})
|
},
|
confirm(e) {
|
this.model.pqId = e.value[0].id
|
this.model.pqName = e.value[0].label
|
this.duSolutionId = e.value[0].duSolutionId
|
this.model.gzId = ''
|
this.model.gzName = ''
|
this.model.remark=''
|
this.getGZ()
|
this.show = false
|
},
|
confirm1(e) {
|
this.model.gzId = e.value[0].id
|
this.model.gzName = e.value[0].label
|
this.show1 = false
|
},
|
submit() {
|
this.$refs.uForm.validate().then(res => {
|
uni.$emit('add', { model: this.model })
|
uni.navigateBack({ delta: 1 });
|
}).catch(errors => {
|
|
})
|
}
|
}
|
}
|
</script>
|
<style>
|
page {
|
background-color: #f7f7f7;
|
}
|
</style>
|
<style lang="scss" scoped>
|
.box {
|
width: 100vw;
|
height: 100vh;
|
padding: 20rpx 30rpx;
|
box-sizing: border-box;
|
.box_list {
|
width: 100%;
|
height: calc(100vh - 158rpx - env(safe-area-inset-bottom));
|
background: #FFFFFF;
|
border-radius: 16rpx;
|
padding: 32rpx 30rpx;
|
box-sizing: border-box;
|
}
|
.box_footer {
|
width: 100%;
|
margin-top: 40rpx;
|
height: 88rpx;
|
}
|
}
|
</style>
|