|
@@ -131,11 +131,11 @@
|
|
|
<el-input v-model="form.email" autocomplete="off" placeholder="请输入电子邮箱.."></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="相关资料:" :label-width="formLabelWidth" prop="" class="custom-align-right">
|
|
|
- <el-upload class="upload-demo" :action="uploadFileUrl" :headers="headers" :on-preview="handlePreview"
|
|
|
- :on-remove="handleRemove" :before-remove="beforeRemove" :on-success="handleUploadSuccess" multiple
|
|
|
- :limit="30" :on-exceed="handleExceed" :file-list="otherList">
|
|
|
+ <el-upload class="upload-demo" :action="uploadFileUrl" :headers="headers" accept=".jpg, .jpeg, .png"
|
|
|
+ :before-remove="beforeRemove" :on-success="handleUploadSuccess" multiple :limit="30"
|
|
|
+ :on-exceed="handleExceed" :file-list="otherList" list-type="picture" :before-upload="beforeAvatarUpload1">
|
|
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
|
- <div slot="tip" class="el-upload__tip">每张图片最大1MB,最多上传30张图片。</div>
|
|
|
+ <div slot="tip" class="el-upload__tip">每张图片最大2MB,最多上传30张图片。</div>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="提示词:" :label-width="formLabelWidth" prop="" class="custom-align-right">
|
|
@@ -197,11 +197,37 @@ export default {
|
|
|
console.log(value, typeof value)
|
|
|
console.log(value >= 0)
|
|
|
if (value < 0) {
|
|
|
- callback(new Error('该项不能为空1'))
|
|
|
+ callback(new Error('该项不能为空!'))
|
|
|
} else {
|
|
|
callback()
|
|
|
}
|
|
|
}
|
|
|
+ //
|
|
|
+ function validatePhone(phone) {
|
|
|
+ // 正则表达式:11位数字,以1开头
|
|
|
+ const regex = /^1\d{10}$/;
|
|
|
+ return regex.test(phone);
|
|
|
+ }
|
|
|
+ const validatePhoneNumber = (rule, value, callback) => {
|
|
|
+ if (!value || !validatePhone(value)) {
|
|
|
+ callback(new Error('请输入正确的手机号!'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 验证身份证号码
|
|
|
+ function validateIdCard(idCard) {
|
|
|
+ // 正则表达式:18位数字
|
|
|
+ const regex = /^\d{18}$/;
|
|
|
+ return regex.test(idCard);
|
|
|
+ }
|
|
|
+ const validateIdCardNumber = (rule, value, callback) => {
|
|
|
+ if (!value || !validateIdCard(value)) {
|
|
|
+ callback(new Error('请输入正确的身份证号码!'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
let self = this;
|
|
|
return {
|
|
|
//xx
|
|
@@ -210,7 +236,7 @@ export default {
|
|
|
|
|
|
formLabelWidth: "120px",
|
|
|
editId: "",
|
|
|
- uploadFileUrl: URL.testUrl + "/public/uploadFile",//获得上传地址
|
|
|
+ uploadFileUrl: URL.baseUrl + "/public/uploadFile",//获得上传地址
|
|
|
headers: {},
|
|
|
|
|
|
|
|
@@ -316,13 +342,13 @@ export default {
|
|
|
//5.真实姓名
|
|
|
real_name: [{ required: true, trigger: 'blur', validator: validateEmpty }],
|
|
|
//6.手机号
|
|
|
- mobile: [{ required: true, trigger: 'blur', validator: validateEmpty }],
|
|
|
+ mobile: [{ required: true, trigger: 'blur', validator: validatePhoneNumber }],
|
|
|
//7.身份证号
|
|
|
- id_card: [{ required: true, trigger: 'blur', validator: validateEmpty }],
|
|
|
+ id_card: [{ required: true, trigger: 'blur', validator: validateIdCardNumber }],
|
|
|
//8.性别
|
|
|
gender: [{ required: true, trigger: 'blur', validator: validateEmpty }],
|
|
|
//9.手机号
|
|
|
- mobile: [{ required: true, trigger: 'blur', validator: validateEmpty }],
|
|
|
+ mobile: [{ required: true, trigger: 'blur', validator: validatePhoneNumber }],
|
|
|
//10.工作区域
|
|
|
address_arr_id: [{ required: true, trigger: 'blur', validator: validateArray }],
|
|
|
//11.企业名称
|
|
@@ -405,17 +431,22 @@ export default {
|
|
|
//表单收集 end ------------------------------------------------------------>
|
|
|
//2.提交表单 start ------------------------------------------------------------>
|
|
|
//2.3 多文件上传
|
|
|
- handleRemove(file, fileList) {
|
|
|
- console.log(file, fileList);
|
|
|
- },
|
|
|
- handlePreview(file) {
|
|
|
- console.log(file);
|
|
|
- },
|
|
|
+ // handleRemove(file, fileList) {
|
|
|
+ // console.log(file, fileList);
|
|
|
+ // },
|
|
|
+ // handlePreview(file) {
|
|
|
+ // console.log(file);
|
|
|
+ // },
|
|
|
+ //2.3 多文件上传
|
|
|
handleExceed(files, fileList) {
|
|
|
this.$message.warning(`当前限制选择 30 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
|
|
},
|
|
|
beforeRemove(file, fileList) {
|
|
|
- return this.$confirm(`确定移除 ${file.name}?`);
|
|
|
+ console.log('file, fileList', file, fileList);
|
|
|
+ for (let item of fileList) {
|
|
|
+ this.form.other = this.form.other.filter(item => item !== file.url);
|
|
|
+ }
|
|
|
+ return this.$confirm(`确定移除 ${file.name}?`);
|
|
|
},
|
|
|
//获取token
|
|
|
getTokenFromCookie() {
|
|
@@ -442,6 +473,15 @@ export default {
|
|
|
console.log('上传成功:', response);
|
|
|
console.log(this.form.other);
|
|
|
},
|
|
|
+ //只能上传图片
|
|
|
+ beforeAvatarUpload1(file) {
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
+
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('上传图片大小不能超过 2MB!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
//提交表单
|
|
|
addData() {
|
|
|
//1.格式化时间戳
|
|
@@ -471,6 +511,8 @@ export default {
|
|
|
if (typeof this.form.address_arr_id == 'string') {
|
|
|
this.form.address_arr_id = JSON.parse(this.form.address_arr_id);
|
|
|
}
|
|
|
+ this.form.other = JSON.stringify(this.form.other);
|
|
|
+
|
|
|
// this.form.address_id = this.form.address_arr_id[this.form.address_arr_id.length-1];
|
|
|
// this.form.address_arr_id = JSON.stringify(this.form.address_arr_id);
|
|
|
//2.设置修改的用户id
|
|
@@ -746,4 +788,10 @@ export default {
|
|
|
/* 禁止用户拖拽调整大小 */
|
|
|
}
|
|
|
|
|
|
+::v-deep .el-upload-list__item {
|
|
|
+ width: 15%;
|
|
|
+ float: left;
|
|
|
+ margin-right: 20px;
|
|
|
+}
|
|
|
+
|
|
|
//执行v-deep穿透scope选择器 end------------------------------------------------------------>*/</style>
|