qa-prevention-xgf-app/pages/certificate_information/add.vue

444 lines
16 KiB
Vue
Raw Permalink Normal View History

2023-11-07 10:24:08 +08:00
<template>
<view class="content">
<view class="card">
<u--form labelPosition="left" :model="form" :rules="rules" ref="form" labelWidth="100px">
2024-04-08 16:28:12 +08:00
<u-form-item label="证书正面图片" prop="fileList" borderBottom required>
2023-11-07 10:24:08 +08:00
<u-upload
:fileList="form.fileList"
@afterRead="fnAfterRead"
@delete="fnDeletePic"
2024-04-08 16:28:12 +08:00
:maxCount="1"
previewFullImage
></u-upload>
</u-form-item>
<u-form-item label="证书反面图片" prop="fileListBack" borderBottom required>
<u-upload
:fileList="form.fileListBack"
@afterRead="fnAfterRead1"
@delete="fnDeletePic1"
:maxCount="1"
2023-11-07 10:24:08 +08:00
previewFullImage
></u-upload>
</u-form-item>
<u-form-item label="姓名" prop="NAME" borderBottom required>
<u--input v-model="form.NAME" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="性别" prop="SEX_NAME" borderBottom required ng-switch-default="">
<u--input v-model="form.SEX_NAME" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="手机号" prop="PHONE" borderBottom required>
<u--input v-model="form.PHONE" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="身份证号码" prop="CARD_ID" borderBottom required>
2024-09-30 09:40:54 +08:00
<u--input v-model="form.CARD_ID" border="none" @blur="fnCardIdDisassembly" disabled
disabledColor="#ffffff"></u--input>
2023-11-07 10:24:08 +08:00
</u-form-item>
<u-form-item label="证书类型" prop="CER_TYPE_NAME" borderBottom required @click="fnShowCertificateType">
<u--input v-model="form.CER_TYPE_NAME" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="证书名称" prop="CERTIFICATE" borderBottom required>
<u--input v-model="form.CERTIFICATE" border="none"></u--input>
</u-form-item>
<u-form-item label="证书编号" prop="SPECIAL_NUMBER" borderBottom required>
<u--input v-model="form.SPECIAL_NUMBER" border="none"></u--input>
</u-form-item>
<u-form-item label="发证机关" prop="ISSUING_AUTHORITY" borderBottom required>
<u--input v-model="form.ISSUING_AUTHORITY" border="none"></u--input>
</u-form-item>
<!-- @click="fnShowCertificateTypeJobs" -->
<u-form-item label="工种" prop="JOBS_TYPE" borderBottom required>
<u--input v-model="form.JOBS_TYPE" border="none" disabledColor="#ffffff"></u--input>
</u-form-item>
2024-09-30 09:40:54 +08:00
<u-form-item v-if="form.CER_TYPE_NAME === ''" label="作业类别" prop="specialName" borderBottom required
@click="fnShowCertificateTypeSpe">
2023-11-07 10:24:08 +08:00
<u--input v-model="form.specialName" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
2024-09-30 09:40:54 +08:00
<u-form-item v-if="form.CER_TYPE_NAME === ''" label="操作项目" prop="operationName" borderBottom
required @click="fnShowCertificateTypeOpe">
2023-11-07 10:24:08 +08:00
<u--input v-model="form.operationName" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="有效期开始" prop="VALIDITY_TIME_START" borderBottom required
@click="fnShowTermOfValidityStart">
<u--input v-model="form.VALIDITY_TIME_START" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="有效期结束" prop="VALIDITY_TIME_END" borderBottom required
@click="fnShowTermOfValidityEnd">
<u--input v-model="form.VALIDITY_TIME_END" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
<u-form-item label="复审时间" prop="REVIEW_TIME" borderBottom required @click="fnShowReviewTime">
<u--input v-model="form.REVIEW_TIME" border="none" disabled disabledColor="#ffffff"></u--input>
</u-form-item>
</u--form>
<u-picker :show="showCertificateType" :columns="certificateTypeColumns" keyName="NAME"
@confirm="fnCertificateTypeConfirm" @cancel="fnShowCertificateType"></u-picker>
<u-picker :show="showCertificateTypeSpe" :columns="certificateTypeColumnsSpe" keyName="NAME"
@confirm="fnCertificateTypeConfirmSpe" @cancel="fnShowCertificateTypeSpe"></u-picker>
<u-picker :show="showCertificateTypeOpe" :columns="certificateTypeColumnsOpe" keyName="NAME"
@confirm="fnCertificateTypeConfirmOpe" @cancel="fnShowCertificateTypeOpe"></u-picker>
<u-datetime-picker :show="showTermOfValidityStart" v-model="termOfValidityStartValue" mode="date"
@confirm="fnTermOfValidityStartConfirm"
@cancel="fnShowTermOfValidityStart"></u-datetime-picker>
<u-datetime-picker :show="showTermOfValidityEnd" v-model="termOfValidityEndValue" mode="date"
@confirm="fnTermOfValidityEndConfirm" @cancel="fnShowTermOfValidityEnd"></u-datetime-picker>
<u-datetime-picker :show="showReviewTime" v-model="reviewTimeValue" mode="date"
@confirm="fnReviewTimeConfirm" @cancel="fnShowReviewTime"></u-datetime-picker>
2024-09-30 09:40:54 +08:00
<view class="mt-10">
<u-button type="primary" text="保 存" @click="$u.debounce(fnSubmit, 1000,true)"></u-button>
</view>
2023-11-07 10:24:08 +08:00
</view>
</view>
</template>
<script>
import {
getCertificateInformationView,
getDataDictionary,
getUserInfo,
setCertificateInformationAdd,
setCertificateInformationEdit,
setCertificateInformationEditPost
} from "../../api";
export default {
data() {
return {
SPECIAL_USER_ID: '',
showCertificateType: false,
showCertificateTypeSpe: false,
showCertificateTypeOpe: false,
certificateTypeColumns: [[]],
certificateTypeColumnsJobs: [[]],
certificateTypeColumnsSpe: [[]],
certificateTypeColumnsOpe: [[]],
showTermOfValidityStart: false,
termOfValidityStartValue: new Date().toString(),
showTermOfValidityEnd: false,
termOfValidityEndValue: new Date().toString(),
showReviewTime: false,
reviewTimeValue: new Date().toString(),
form: {
fileList: [],
2024-04-08 16:28:12 +08:00
fileListBack: [],
2023-11-07 10:24:08 +08:00
NAME: '',
SEX_NAME: '',
PHONE: '',
CARD_ID: '',
CER_TYPE: '',
CER_TYPE_NAME: '',
2024-09-30 09:40:54 +08:00
CERTIFICATE: '',
JOBS_TYPE: '',
SPECIAL_TYPE: '',
OPERATION_TYPE: '',
2023-11-07 10:24:08 +08:00
SPECIAL_NUMBER: '',
ISSUING_AUTHORITY: '',
VALIDITY_TIME_START: '',
VALIDITY_TIME_END: '',
REVIEW_TIME: ''
},
rules: {
2024-04-08 14:48:21 +08:00
fileList: {
type: 'array',
required: true,
message: '请上传证书图片',
trigger: ['change']
},
2024-04-08 16:28:12 +08:00
fileListBack: {
type: 'array',
required: true,
message: '请上传证书图片',
trigger: ['change']
},
2024-04-08 14:48:21 +08:00
CER_TYPE_NAME: {
required: true,
message: '请选择证书类型',
trigger: ['change']
},
CERTIFICATE: {
required: true,
message: '请填写证书名称',
trigger: ['change']
},
SPECIAL_NUMBER: {
required: true,
message: '请填写证书编号',
trigger: ['blur']
},
JOBS_TYPE: {
required: true,
message: '请填写工种',
trigger: ['change']
},
specialName: {
required: true,
message: '请选择作业类别',
trigger: ['change']
},
operationName: {
required: true,
message: '请选择操作项目',
trigger: ['change']
},
ISSUING_AUTHORITY: {
required: true,
message: '请填写发证机关',
trigger: ['blur']
},
VALIDITY_TIME_START: {
required: true,
message: '请选择有效期开始时间',
trigger: ['change']
},
VALIDITY_TIME_END: {
required: true,
message: '请选择有效期结束时间',
trigger: ['change']
},
2023-11-07 10:24:08 +08:00
REVIEW_TIME: {
required: true,
message: '请选择复审时间',
trigger: ['change']
}
}
}
},
onLoad(query) {
this.SPECIAL_USER_ID = query.SPECIAL_USER_ID
if (query.SPECIAL_USER_ID) {
uni.setNavigationBarTitle({
title: '证书信息编辑'
})
} else {
uni.setNavigationBarTitle({
title: '证书信息添加'
})
}
this.fnGetDataDictionary()
this.fnGetData()
this.fnGetDataDictionaryJobs()
this.fnGetDataDictionarySpe()
//this.fnGetDataDictionaryOpe()
},
computed: {
userInfo() {
return this.$store.getters.getUserInfo
}
},
methods: {
async fnGetData() {
2024-04-08 16:28:12 +08:00
if (this.SPECIAL_USER_ID) {
2023-11-07 10:24:08 +08:00
let resData = await getCertificateInformationView({
2024-04-08 16:28:12 +08:00
SPECIAL_USER_ID: this.SPECIAL_USER_ID
2023-11-07 10:24:08 +08:00
})
2024-04-08 16:28:12 +08:00
this.form = {...this.form, ...resData.pd, CER_TYPE_NAME: resData.pd.typeName}
this.$set(this.form, 'fileList', [{
url: this.$filePath + resData.pd.FILEPATH,
FILEPATH: this.$filePath + resData.pd.FILEPATH
}])
this.$set(this.form, 'fileListBack', [{
url: this.$filePath + resData.pd.FILEPATH_BACK,
FILEPATH: this.$filePath + resData.pd.FILEPATH_BACK
}])
let resDatares = await getDataDictionary({DICTIONARIES_ID: this.form.SPECIAL_TYPE})
this.certificateTypeColumnsOpe = [resDatares.list]
} else {
2023-11-07 10:24:08 +08:00
let resData = await getUserInfo({
CORPINFO_ID: this.userInfo.CORPINFO_ID,
})
this.form = {...this.form, ...resData.pd}
this.fnCardIdDisassembly(this.form.CARD_ID)
this.fnCardIdDisassembly(this.form.CARD_ID)
}
2024-04-08 16:28:12 +08:00
if (this.form.SEX_NAME === '0') {
2023-11-07 10:24:08 +08:00
this.form.SEX_NAME = '男'
2024-04-08 16:28:12 +08:00
} else if (this.form.SEX_NAME === '1') {
2023-11-07 10:24:08 +08:00
this.form.SEX_NAME = '女'
}
},
2024-09-30 09:40:54 +08:00
async fnGetDataDictionary() {
let resData = await getDataDictionary({DICTIONARIES_ID: '6f87965751b84311b066484ac93c8077'})
2023-11-07 10:24:08 +08:00
this.certificateTypeColumns = [resData.list]
},
2024-09-30 09:40:54 +08:00
async fnGetDataDictionaryJobs() {
let resData = await getDataDictionary({DICTIONARIES_ID: '55484e491a5e442d839c4595380713ec'})
2023-11-07 10:24:08 +08:00
this.certificateTypeColumnsJobs = [resData.list]
},
2024-09-30 09:40:54 +08:00
async fnGetDataDictionarySpe() {
let resData = await getDataDictionary({DICTIONARIES_ID: 'f4c3890d06d54904b32986cb6428ed4f'})
2023-11-07 10:24:08 +08:00
this.certificateTypeColumnsSpe = [resData.list]
},
2024-09-30 09:40:54 +08:00
async fnGetDataDictionaryOpe() {
let resData = await getDataDictionary({DICTIONARIES_ID: this.form.SPECIAL_TYPE})
2023-11-07 10:24:08 +08:00
this.certificateTypeColumnsOpe = [resData.list]
},
fnCardIdDisassembly(event) {
if (uni.$u.test.idCard(event)) {
if (parseInt(event.substring(17, 1)) % 2 === 1) {
this.form.SEX = "0";
this.form.SEX_NAME = "男";
} else {
this.form.SEX = "1";
this.form.SEX_NAME = "女";
}
}
},
fnShowCertificateType() {
this.showCertificateType = !this.showCertificateType
},
fnShowCertificateTypeSpe() {
this.showCertificateTypeSpe = !this.showCertificateTypeSpe;
},
fnShowCertificateTypeOpe() {
this.showCertificateTypeOpe = !this.showCertificateTypeOpe
},
fnCertificateTypeConfirm(e) {
this.form.CER_TYPE = e.value[0].DICTIONARIES_ID
this.form.CER_TYPE_NAME = e.value[0].NAME
this.fnShowCertificateType()
},
fnCertificateTypeConfirmSpe(e) {
this.form.specialName = e.value[0].NAME
this.form.SPECIAL_TYPE = e.value[0].DICTIONARIES_ID
this.fnShowCertificateTypeSpe()
2024-09-30 09:40:54 +08:00
this.fnGetDataDictionaryOpe();
this.form.operationName = '';
this.form.OPERATION_TYPE = '';
2023-11-07 10:24:08 +08:00
},
fnCertificateTypeConfirmOpe(e) {
2024-09-30 09:40:54 +08:00
this.form.operationName = e.value[0].NAME
this.form.OPERATION_TYPE = e.value[0].DICTIONARIES_ID
2023-11-07 10:24:08 +08:00
this.fnShowCertificateTypeOpe()
},
fnShowTermOfValidityStart() {
this.showTermOfValidityStart = !this.showTermOfValidityStart
},
fnTermOfValidityStartConfirm(event) {
this.termOfValidityStartValue = event.value
this.fnShowTermOfValidityStart()
this.form.VALIDITY_TIME_START = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
},
fnShowTermOfValidityEnd() {
this.showTermOfValidityEnd = !this.showTermOfValidityEnd
},
fnTermOfValidityEndConfirm(event) {
this.termOfValidityEndValue = event.value
this.fnShowTermOfValidityEnd()
this.form.VALIDITY_TIME_END = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
},
fnShowReviewTime() {
this.showReviewTime = !this.showReviewTime
},
fnReviewTimeConfirm(event) {
this.reviewTimeValue = event.value
this.fnShowReviewTime()
this.form.REVIEW_TIME = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
},
fnAfterRead(event) {
2024-04-08 16:28:12 +08:00
var houzhui = event.file.url.replace(/.+\./, "");
console.log(houzhui);
if (houzhui == "jpg" || houzhui == "png") {
this.form.fileList.push(event.file)
} else {
uni.$u.toast('图片格式不正确请上传jpg格式图片或者png格式图片')
this.form.fileList = []
2024-04-08 14:48:21 +08:00
2024-04-08 16:28:12 +08:00
}
},
fnAfterRead1(event) {
var houzhui = event.file.url.replace(/.+\./, "");
console.log(houzhui);
if (houzhui == "jpg" || houzhui == "png") {
this.form.fileListBack.push(event.file)
} else {
uni.$u.toast('图片格式不正确请上传jpg格式图片或者png格式图片')
this.form.fileListBack = []
}
2023-11-07 10:24:08 +08:00
},
fnDeletePic(event) {
this.form.fileList.splice(event.index, 1)
},
2024-04-08 16:28:12 +08:00
fnDeletePic1(event) {
this.form.fileListBack.splice(event.index, 1)
},
2023-11-07 10:24:08 +08:00
async fnSubmit() {
console.info(this.$refs)
this.$refs.form.validate().then(async () => {
2024-09-30 09:40:54 +08:00
if (!this.SPECIAL_USER_ID) {
2024-04-08 14:48:21 +08:00
let files = []
files.push({
name: 'FILEPATH',
file: this.form.fileList[0],
uri: this.form.fileList[0].url,
})
files.push({
name: 'FILEPATH_BACK',
2024-04-08 16:28:12 +08:00
file: this.form.fileListBack[0],
uri: this.form.fileListBack[0].url,
2024-04-08 14:48:21 +08:00
})
2024-09-30 09:40:54 +08:00
if (files.length !== 2) {
2024-04-08 16:28:12 +08:00
uni.$u.toast('请上传证书正反面')
return
}
2023-11-07 10:24:08 +08:00
await setCertificateInformationAdd({
2024-04-08 14:48:21 +08:00
files: files,
2023-11-07 10:24:08 +08:00
formData: {
...this.form
}
})
2024-09-30 09:40:54 +08:00
} else {
2024-04-08 16:28:12 +08:00
if (!this.form.fileList[0].FILEPATH || !this.form.fileListBack[0].FILEPATH) {
uni.$u.toast('1')
let files = []
2024-09-30 09:40:54 +08:00
if (!this.form.fileList[0].FILEPATH) {
2024-04-08 16:28:12 +08:00
files.push({
name: 'FILEPATH',
file: this.form.fileList[0],
uri: this.form.fileList[0].url,
})
}
2024-09-30 09:40:54 +08:00
if (!this.form.fileListBack[0].FILEPATH) {
2024-04-08 16:28:12 +08:00
files.push({
name: 'FILEPATH_BACK',
file: this.form.fileListBack[0],
uri: this.form.fileListBack[0].url,
})
}
2023-11-07 10:24:08 +08:00
await setCertificateInformationEdit({
2024-04-08 16:28:12 +08:00
files: files,
2023-11-07 10:24:08 +08:00
formData: {
...this.form
}
})
} else {
this.form.fileMark = '1',
2024-09-30 09:40:54 +08:00
await setCertificateInformationEditPost({
...this.form
})
2023-11-07 10:24:08 +08:00
}
}
2024-04-08 16:28:12 +08:00
// uni.$u.toast('保存成功')
2024-09-30 09:40:54 +08:00
setTimeout(() => {
2023-11-07 10:24:08 +08:00
uni.navigateBack()
2024-09-30 09:40:54 +08:00
}, 2000)
2023-11-07 10:24:08 +08:00
}).catch((e) => {
console.info(e)
2024-04-08 16:28:12 +08:00
// uni.$u.toast('请补全必填项')
uni.$u.toast(e)
2023-11-07 10:24:08 +08:00
})
}
},
}
</script>
<style scoped lang="scss">
</style>