软测宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
6.3 KiB

7 months ago
<template>
<view style="">
<view class="navTab">
<view class="sintitle" style="margin-top:15px;margin-left: -20px;">
<img src="/static/index/jnzs.png" alt="">
<p style="color:#fa3534;margin-right:3px">* </p>
<p>资格证书</p>
7 months ago
</view>
<u-form :model="basicobj" ref="basicobj" label-position='left' label-width='150' border-bottom='false'>
<u-form-item label="证书名称:" prop="credentialsName" border-bottom='false' required='true'>
7 months ago
<view class="sinput">
<u-input style="width:100%;" v-model="basicobj.credentialsName" placeholder='输入证书名称' />
7 months ago
</view>
</u-form-item>
<u-form-item prop="url" border-bottom='false'>
<u-upload width='100px' height='100px' :action="action" :header="headers" :auto-upload="true"
:show-progress="false" max-count="1" :deletable="true" :file-list="basicobj.url"
7 months ago
@on-success="(data,index,lists) => {fielUploadSuc(data,index,lists) }"
@on-remove="(index, lists, name)=>{deleteUpfile(index)}"
@on-error="(data,index, lists)=>{errorUpfile(data,index, lists)}">
<view slot="addBtn" class="slot-btn">
<img v-if="basicobj.url" :src="basicobj.url" mode="aspectFill"
style="width: 100px;height: 100px;">
<div v-else class="upliacla">
<p style="font-size: 18px;">+</p>
<p>选择图片</p>
</div>
7 months ago
</view>
</u-upload>
</u-form-item>
</u-form>
7 months ago
</view>
<view class="bottbtn" @click="resource">保存</view>
7 months ago
<view style="height:10px"></view>
<u-toast ref="uToast" />
</view>
</template>
<script>
export default {
data() {
return {
cityshow: false,
basicobj: {
url: ''
},
wxUserInfo: null,
testerdata: null,
cityList: [],
action: this.http.baseUrl + '/upload',
headers: {
Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
},
7 months ago
certRules: {
credentialsName: [{
required: true,
message: '请输入证书名称',
trigger: 'change',
}],
url: [{
required: true,
message: '请上传证书',
trigger: 'change'
}],
7 months ago
},
fileItem: {},
fileInfo: []
7 months ago
}
},
onShow() {},
onReady() {
7 months ago
this.$refs.basicobj.setRules(this.certRules);
},
onLoad(options) {
if (options.fileItem) {
uni.setNavigationBarTitle({
title: '修改资格证书'
});
this.fileInfo = JSON.parse(options.fileList)
this.fileInfo = this.fileInfo.map(it => {
return {
credentialsName: it.fileName,
url: it.filePath
}
})
this.fileItem = JSON.parse(options.fileItem)
this.basicobj.credentialsName = this.fileItem.fileName
this.basicobj.url = this.fileItem.fileUrl
} else {
uni.setNavigationBarTitle({
title: '添加资格证书'
});
}
7 months ago
},
computed: {
7 months ago
},
methods: {
7 months ago
//文件上传成功回调
fielUploadSuc(data, index) {
7 months ago
if (data.code === 200) {
this.basicobj.url = data.filePath
7 months ago
}
},
//移除
deleteUpfile(index, lists) {
this.basicobj.url = ''
7 months ago
},
errorUpfile(data, index) {},
// 保存
resource() {
7 months ago
this.$refs.basicobj.validate(valid => {
if (valid) {
if (this.fileItem.fileId) {
// 有文件回填
var modifiedUrl = this.basicobj.url.replace(/.*\/profile/, '/profile');
const data = {
credentialsList: [ {url: modifiedUrl, credentialsName: this.basicobj.credentialsName}, ...this.fileInfo]
7 months ago
}
this.http.quickPost(`/tester/cert/credentials/edit`, data, true).then(res => {
if (res.data.code == 200) {
this.$refs.uToast.show({
title: '修改成功',
type: 'success',
url: 'pages/personal/personalresume/personalresume'
})
} else {
}
})
} else {
// 新增
const data = {
credentialsList: [this.basicobj]
}
this.http.quickPost(`/tester/cert/credentials`, data, true).then(res => {
if (res.data.code == 200) {
this.$refs.uToast.show({
title: '保存成功',
type: 'success',
url: 'pages/personal/personalresume/personalresume'
})
} else {
}
})
}
} else {}
7 months ago
})
}
}
}
</script>
<style>
page {
background: #FFFFFF !important;
7 months ago
}
.navTab {
padding: 13px 20px 13px 20px;
7 months ago
}
.sinput {
7 months ago
display: flex;
align-items: center;
/* height: 50px; */
}
.u-form-left__content__label {
color: #808080 !important;
7 months ago
}
.sintitle {
7 months ago
display: flex;
align-items: center;
/* height: 50px; */
background: #F2F4F7;
/* background:#20529c; */
border-radius: 4rpx;
padding: 7px 15px;
7 months ago
}
.sintitle img {
width: 20px;
height: 18px;
margin-right: 5px;
7 months ago
}
.sintitle p {
7 months ago
font-size: 15px;
color: #000000;
7 months ago
font-weight: bold;
}
.sinput .u-input {
height: 35px;
border-bottom: 1px solid #EBEBEB !important;
7 months ago
}
.sinput p {
7 months ago
color: #808080;
}
.bottbtn {
width: 94vw;
margin: 30px 3vw 15px 3vw;
height: 75rpx;
7 months ago
background: linear-gradient(90deg, #5EA6FD, #1A81F9);
border-radius: 43rpx;
7 months ago
text-align: center;
line-height: 75rpx;
7 months ago
color: #FFFFFF;
font-size: 33rpx;
/* margin-left:13px; */
}
.sinputrt {
7 months ago
display: flex;
/* align-items: center; */
/* height: 50px; */
padding: 10px 0px;
}
.sinputrt .u-input {
7 months ago
/* width:75vw; */
height: 100px;
7 months ago
border: 1px solid #E6E6E6;
background: #FFFFFF;
border-radius: 10rpx 10rpx 0rpx 0rpx;
padding-left: 10px !important;
7 months ago
}
.u-list-item {
margin: 0 !important;
zIndex: 0 !important;
7 months ago
}
7 months ago
.slot-btn {
width: 200rpx;
height: 0rpx;
zIndex: 99;
7 months ago
/* display: flex;
justify-content: center;
align-items: center;
background: rgb(244, 245, 246);
border-radius: 10rpx; */
}
.slot-btn__hover {
background-color: rgb(235, 236, 238);
}
.u-form-item {
margin-bottom: -5px;
color: #808080 !important;
7 months ago
}
.u-form {
7 months ago
margin-left: 20px;
}
.u-list-item {
7 months ago
margin: 0 !important;
background: transparent !important;
color: transparent !important;
7 months ago
}
.upliacla {
width: 100px;
height: 100px;
/* line-height:100px; */
border-radius: 4px;
background: #f4f5f6;
color: #606266;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.wuploa {
/* width: 100px;
7 months ago
height: 100px;
line-height: 100px;
font-size: 12px;
border: 1px solid #E6E6E6;
text-align: center;
border-radius: 4px; */
}
</style>