|
|
|
|
|
|
|
|
:before-close="handleClose" |
|
|
:before-close="handleClose" |
|
|
> |
|
|
> |
|
|
<div class="photo-form"> |
|
|
<div class="photo-form"> |
|
|
<el-form ref="ruleForm" :model="ruleForm" size="small" label-width="180px"> |
|
|
|
|
|
|
|
|
<el-form ref="ruleForm" :model="ruleForm" size="small" label-width="100px"> |
|
|
<el-form-item label="正射图" prop="photoUrl"> |
|
|
<el-form-item label="正射图" prop="photoUrl"> |
|
|
<uploadImage |
|
|
|
|
|
:isCompress="false" |
|
|
|
|
|
ref="uploadImage" |
|
|
|
|
|
v-model="ruleForm.photoUrl" |
|
|
|
|
|
:img="ruleForm.photoUrl" |
|
|
|
|
|
v-on:addImage="addImage" |
|
|
|
|
|
:limit="1" |
|
|
|
|
|
v-on:removeImage="removeImage" |
|
|
|
|
|
></uploadImage> |
|
|
|
|
|
|
|
|
<el-button |
|
|
|
|
|
:loading="uploadLoading" |
|
|
|
|
|
@click="uploadFile()" |
|
|
|
|
|
size="small" |
|
|
|
|
|
type="primary" |
|
|
|
|
|
icon="el-icon-upload2" |
|
|
|
|
|
>上传</el-button> |
|
|
|
|
|
<span>{{ruleForm.photoName}}</span> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item label="左下经度" prop="leftLongitude"> |
|
|
|
|
|
<el-input clearable v-model="ruleForm.leftLongitude" size="small" placeholder="请输入河湖名称" /> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="左下纬度" prop="leftLatitude"> |
|
|
|
|
|
<el-input clearable v-model="ruleForm.leftLatitude" size="small" placeholder="请输入河湖名称" /> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item label="右上经度" prop="rightLongitude"> |
|
|
|
|
|
<el-input clearable v-model="ruleForm.rightLongitude" size="small" placeholder="请输入河湖名称" /> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item label="右上纬度" prop="rightLatitude"> |
|
|
|
|
|
<el-input clearable v-model="ruleForm.rightLatitude" size="small" placeholder="请输入河湖名称" /> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
<div style="text-align: center"> |
|
|
<div style="text-align: center"> |
|
|
|
|
|
|
|
|
>提交</el-button> |
|
|
>提交</el-button> |
|
|
<el-button |
|
|
<el-button |
|
|
icon="el-icon-back" |
|
|
icon="el-icon-back" |
|
|
v-if="ruleForm.id" |
|
|
|
|
|
style="margin-left: 15px" |
|
|
style="margin-left: 15px" |
|
|
size="medium" |
|
|
size="medium" |
|
|
@click="handleClose" |
|
|
@click="handleClose" |
|
|
>返回</el-button> |
|
|
>返回</el-button> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<input id="upload" type="file" name="file" @change="uploadClick" style="display: none;" /> |
|
|
</el-drawer> |
|
|
</el-drawer> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import driverApi from "@/api/basicData/driver"; |
|
|
|
|
|
import uploadImage from "@/components/uploadImage"; |
|
|
|
|
|
|
|
|
import api from "@/api/user/user"; |
|
|
|
|
|
import inspectApi from "@/api/file/inspectfile" |
|
|
|
|
|
import $ from "jquery"; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: "photorForm", |
|
|
name: "photorForm", |
|
|
data() { |
|
|
data() { |
|
|
var patrn = /^\d+(\.\d+)?$/; |
|
|
|
|
|
var lengthP = /^(\d+)(.\d{0,4})?$/; |
|
|
|
|
|
var validateNum = (rule, value, callback) => { |
|
|
|
|
|
if (!value) { |
|
|
|
|
|
callback(); |
|
|
|
|
|
} else { |
|
|
|
|
|
if (rule.field == "length") { |
|
|
|
|
|
if (!lengthP.test(value)) { |
|
|
|
|
|
callback(new Error("小数点最多4位")); |
|
|
|
|
|
} else if (parseInt(value) > 9999) { |
|
|
|
|
|
callback(new Error("最大10000")); |
|
|
|
|
|
} else { |
|
|
|
|
|
callback(); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!patrn.test(value)) { |
|
|
|
|
|
callback(new Error("请输入数字")); |
|
|
|
|
|
} else { |
|
|
|
|
|
callback(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
return { |
|
|
return { |
|
|
ruleForm: {}, |
|
|
ruleForm: {}, |
|
|
validateNum: validateNum, |
|
|
|
|
|
addBtnLoading: false, |
|
|
|
|
|
categoryList: [ |
|
|
|
|
|
{ id: "categoryOne", name: "Ⅰ类" }, |
|
|
|
|
|
{ id: "categoryTwo", name: "Ⅱ类" }, |
|
|
|
|
|
{ id: "categoryThree", name: "Ⅲ类" }, |
|
|
|
|
|
{ id: "categoryFour", name: "Ⅳ类" }, |
|
|
|
|
|
{ id: "categoryFive", name: "Ⅴ类" } |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
uploadLoading: false, |
|
|
|
|
|
addBtnLoading: false |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
props: { |
|
|
props: { |
|
|
visible: { |
|
|
visible: { |
|
|
type: Boolean, |
|
|
type: Boolean, |
|
|
default() { |
|
|
default() { |
|
|
false; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
userList: { |
|
|
|
|
|
type: Array, |
|
|
|
|
|
default() { |
|
|
|
|
|
return []; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
typeList: { |
|
|
|
|
|
type: Object, |
|
|
|
|
|
default() { |
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
levelList: { |
|
|
|
|
|
|
|
|
data: { |
|
|
type: Object, |
|
|
type: Object, |
|
|
default() { |
|
|
default() { |
|
|
return {}; |
|
|
return {}; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
components: {uploadImage }, |
|
|
|
|
|
created() {}, |
|
|
|
|
|
|
|
|
components: {}, |
|
|
|
|
|
created() { |
|
|
|
|
|
this.ruleForm = JSON.parse(JSON.stringify(this.data)); |
|
|
|
|
|
}, |
|
|
mounted() {}, |
|
|
mounted() {}, |
|
|
methods: { |
|
|
methods: { |
|
|
handleClose(){ |
|
|
|
|
|
this.$emit('handleClose') |
|
|
|
|
|
}, |
|
|
|
|
|
removeImage() { |
|
|
|
|
|
this.ruleForm.photoUrl = ""; |
|
|
|
|
|
|
|
|
uploadFile() { |
|
|
|
|
|
$("#upload").click(); |
|
|
}, |
|
|
}, |
|
|
addImage(...data) { |
|
|
|
|
|
this.ruleForm.photoUrl = data[0]; |
|
|
|
|
|
|
|
|
uploadClick(event) { |
|
|
|
|
|
let file = event.target.files[0]; |
|
|
|
|
|
let formdata = new window.FormData(); |
|
|
|
|
|
formdata.append("file", file); |
|
|
|
|
|
this.uploadLoading = true; |
|
|
|
|
|
api.upload(formdata).then( |
|
|
|
|
|
rs => { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
type: "success", |
|
|
|
|
|
message: "上传成功" |
|
|
|
|
|
}); |
|
|
|
|
|
this.ruleForm.photoUrl = rs.data.url; |
|
|
|
|
|
this.ruleForm.photoName = rs.data.fileName; |
|
|
|
|
|
this.uploadLoading = false; |
|
|
|
|
|
}, |
|
|
|
|
|
error => { |
|
|
|
|
|
this.uploadLoading = false; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
event.target.value = ""; |
|
|
}, |
|
|
}, |
|
|
clearValidate() { |
|
|
|
|
|
this.$refs.ruleForm.clearValidate("driverArea"); |
|
|
|
|
|
|
|
|
handleClose() { |
|
|
|
|
|
this.$emit("handleClose"); |
|
|
}, |
|
|
}, |
|
|
submitForm(formName) { |
|
|
submitForm(formName) { |
|
|
this.$refs[formName].validate(valid => { |
|
|
this.$refs[formName].validate(valid => { |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
let method = "addDriver"; |
|
|
|
|
|
if (this.ruleForm.id) { |
|
|
|
|
|
method = "editDriver"; |
|
|
|
|
|
} |
|
|
|
|
|
let ruleForm = JSON.parse(JSON.stringify(this.ruleForm)); |
|
|
let ruleForm = JSON.parse(JSON.stringify(this.ruleForm)); |
|
|
this.addBtnLoading = true; |
|
|
this.addBtnLoading = true; |
|
|
driverApi[method](ruleForm) |
|
|
|
|
|
|
|
|
inspectApi.editPhoto(ruleForm) |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
this.addBtnLoading = false; |
|
|
this.addBtnLoading = false; |
|
|
this.$refs[formName].resetFields(); |
|
|
|
|
|
this.$message({ |
|
|
this.$message({ |
|
|
type: "success", |
|
|
type: "success", |
|
|
message: this.ruleForm.id ? "修改成功" : "添加成功" |
|
|
|
|
|
|
|
|
message:"操作成功" |
|
|
}); |
|
|
}); |
|
|
if (this.ruleForm.id) { |
|
|
|
|
|
this.$emit("submit", 2); |
|
|
|
|
|
this.$emit("onBack"); |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$emit("submit", 1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.$emit('successSubmit') |
|
|
}) |
|
|
}) |
|
|
.catch(e => { |
|
|
.catch(e => { |
|
|
this.addBtnLoading = false; |
|
|
this.addBtnLoading = false; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
|
|
|
onBack() { |
|
|
|
|
|
this.$refs["ruleForm"].resetFields(); |
|
|
|
|
|
this.$emit("onBack"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |