|
@@ -101,137 +101,137 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { addForApp, getTroubleDetail } from "@/service/api_company.js";
|
|
|
|
|
-import { upload } from "@/service/api_upload";
|
|
|
|
|
-import { Toast } from "vant";
|
|
|
|
|
|
|
+import { addForApp, getTroubleDetail } from '@/service/api_company.js'
|
|
|
|
|
+import { upload } from '@/service/api_upload'
|
|
|
|
|
+import { Toast } from 'vant'
|
|
|
export default {
|
|
export default {
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- show: false,
|
|
|
|
|
- columns: [
|
|
|
|
|
- { label: "梁溪区", value: 320213, isSelected: false },
|
|
|
|
|
- { label: "锡山区", value: 320205, isSelected: false },
|
|
|
|
|
- { label: "惠山区", value: 320206, isSelected: false },
|
|
|
|
|
- { label: "滨湖区", value: 320211, isSelected: false },
|
|
|
|
|
- { label: "新吴区", value: 320214, isSelected: false },
|
|
|
|
|
- { label: "经开区", value: 320299, isSelected: false },
|
|
|
|
|
- { label: "江阴市", value: 320281, isSelected: false },
|
|
|
|
|
- { label: "宜兴市", value: 320282, isSelected: false },
|
|
|
|
|
- ],
|
|
|
|
|
- form: {
|
|
|
|
|
- createdBy: "10008611",
|
|
|
|
|
- },
|
|
|
|
|
- entryForm: [],
|
|
|
|
|
- fileList: [
|
|
|
|
|
- // { url: 'https://cloud-image', isImage: true },
|
|
|
|
|
- ],
|
|
|
|
|
- };
|
|
|
|
|
- },
|
|
|
|
|
- methods: {
|
|
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ columns: [
|
|
|
|
|
+ { label: '梁溪区', value: 320213, isSelected: false },
|
|
|
|
|
+ { label: '锡山区', value: 320205, isSelected: false },
|
|
|
|
|
+ { label: '惠山区', value: 320206, isSelected: false },
|
|
|
|
|
+ { label: '滨湖区', value: 320211, isSelected: false },
|
|
|
|
|
+ { label: '新吴区', value: 320214, isSelected: false },
|
|
|
|
|
+ { label: '经开区', value: 320299, isSelected: false },
|
|
|
|
|
+ { label: '江阴市', value: 320281, isSelected: false },
|
|
|
|
|
+ { label: '宜兴市', value: 320282, isSelected: false }
|
|
|
|
|
+ ],
|
|
|
|
|
+ form: {
|
|
|
|
|
+ createdBy: '10008611'
|
|
|
|
|
+ },
|
|
|
|
|
+ entryForm: [],
|
|
|
|
|
+ fileList: [
|
|
|
|
|
+ // { url: 'https://cloud-image', isImage: true },
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
|
|
|
- async addForm() {
|
|
|
|
|
- console.log(this.fileList);
|
|
|
|
|
- console.log(this.form);
|
|
|
|
|
- if (
|
|
|
|
|
- !this.form.hiddenTroubleDescription ||
|
|
|
|
|
|
|
+ async addForm() {
|
|
|
|
|
+ console.log(this.fileList)
|
|
|
|
|
+ console.log(this.form)
|
|
|
|
|
+ if (
|
|
|
|
|
+ !this.form.hiddenTroubleDescription ||
|
|
|
this.form.hiddenTroubleDescription.length == 0
|
|
this.form.hiddenTroubleDescription.length == 0
|
|
|
- ) {
|
|
|
|
|
- return Toast("请填写隐患描述");
|
|
|
|
|
- }
|
|
|
|
|
- if (!this.form.reportPeople || this.form.reportPeople.length == 0) {
|
|
|
|
|
- return Toast("请填写联系人");
|
|
|
|
|
- }
|
|
|
|
|
- if (!this.form.reportPeopleTel || this.form.reportPeopleTel.length == 0) {
|
|
|
|
|
- return Toast("请填写联系电话");
|
|
|
|
|
- }
|
|
|
|
|
- if (!this.form.area || this.form.area.length == 0) {
|
|
|
|
|
- return Toast("请选择所在区域");
|
|
|
|
|
- }
|
|
|
|
|
- if (
|
|
|
|
|
- !this.form.hiddenTroubleAddress ||
|
|
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return Toast('请填写隐患描述')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!this.form.reportPeople || this.form.reportPeople.length == 0) {
|
|
|
|
|
+ return Toast('请填写联系人')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!this.form.reportPeopleTel || this.form.reportPeopleTel.length == 0) {
|
|
|
|
|
+ return Toast('请填写联系电话')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!this.form.area || this.form.area.length == 0) {
|
|
|
|
|
+ return Toast('请选择所在区域')
|
|
|
|
|
+ }
|
|
|
|
|
+ if (
|
|
|
|
|
+ !this.form.hiddenTroubleAddress ||
|
|
|
this.form.hiddenTroubleAddress.length == 0
|
|
this.form.hiddenTroubleAddress.length == 0
|
|
|
- ) {
|
|
|
|
|
- return Toast("请填写隐患位置");
|
|
|
|
|
- }
|
|
|
|
|
- let form = { ...this.form };
|
|
|
|
|
- form.scenePhoto = JSON.stringify(this.entryForm);
|
|
|
|
|
- let data = await addForApp(form);
|
|
|
|
|
- console.log(data);
|
|
|
|
|
- if (data.code == 200) {
|
|
|
|
|
- Toast("提交成功");
|
|
|
|
|
- this.$router.go(-1);
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- async getTroubleDetail() {
|
|
|
|
|
- let data = await getTroubleDetail({ id: this.$route.query.id });
|
|
|
|
|
- this.form = data;
|
|
|
|
|
- let index = this.columns.findIndex((e) => e.value == data.area);
|
|
|
|
|
- console.log(this.columns[index]);
|
|
|
|
|
- console.log(JSON.parse(data.scenePhoto));
|
|
|
|
|
- this.entryForm = JSON.parse(data.scenePhoto);
|
|
|
|
|
- this.form.areaName = this.columns[index].label;
|
|
|
|
|
- },
|
|
|
|
|
- uploadImg(file) {
|
|
|
|
|
- const formParam = new FormData(); // 创建form对象
|
|
|
|
|
- formParam.append("file", file.file); // 通过append向form对象添加数据
|
|
|
|
|
- const config = {
|
|
|
|
|
- headers: {
|
|
|
|
|
- "Content-Type": "multipart/form-data",
|
|
|
|
|
- "MVVM-Key": String(new Date().getTime()),
|
|
|
|
|
- xx: "anything",
|
|
|
|
|
- }, // 这里是重点,需要和后台沟通好请求头,Content-Type不一定是这个值
|
|
|
|
|
- }; // 添加请求头
|
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
- upload(formParam, config)
|
|
|
|
|
- .then((response) => {
|
|
|
|
|
- console.log(response);
|
|
|
|
|
- if (response.data) {
|
|
|
|
|
- this.entryForm[this.entryForm.length - 1].url = response.data.msg;
|
|
|
|
|
- this.entryForm[this.entryForm.length - 1].content = null;
|
|
|
|
|
- this.entryForm[this.entryForm.length - 1].name =
|
|
|
|
|
- response.data.name;
|
|
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return Toast('请填写隐患位置')
|
|
|
|
|
+ }
|
|
|
|
|
+ const form = { ...this.form }
|
|
|
|
|
+ form.scenePhoto = JSON.stringify(this.entryForm)
|
|
|
|
|
+ const data = await addForApp(form)
|
|
|
|
|
+ console.log(data)
|
|
|
|
|
+ if (data.code == 200) {
|
|
|
|
|
+ Toast('提交成功')
|
|
|
|
|
+ this.$router.go(-1)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ async getTroubleDetail() {
|
|
|
|
|
+ const data = await getTroubleDetail({ id: this.$route.query.id })
|
|
|
|
|
+ this.form = data
|
|
|
|
|
+ const index = this.columns.findIndex((e) => e.value == data.area)
|
|
|
|
|
+ console.log(this.columns[index])
|
|
|
|
|
+ console.log(JSON.parse(data.scenePhoto))
|
|
|
|
|
+ this.entryForm = JSON.parse(data.scenePhoto)
|
|
|
|
|
+ this.form.areaName = this.columns[index].label
|
|
|
|
|
+ },
|
|
|
|
|
+ uploadImg(file) {
|
|
|
|
|
+ const formParam = new FormData() // 创建form对象
|
|
|
|
|
+ formParam.append('file', file.file) // 通过append向form对象添加数据
|
|
|
|
|
+ const config = {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ 'Content-Type': 'multipart/form-data',
|
|
|
|
|
+ 'MVVM-Key': String(new Date().getTime()),
|
|
|
|
|
+ xx: 'anything'
|
|
|
|
|
+ } // 这里是重点,需要和后台沟通好请求头,Content-Type不一定是这个值
|
|
|
|
|
+ } // 添加请求头
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
|
+ upload(formParam, config)
|
|
|
|
|
+ .then((response) => {
|
|
|
|
|
+ console.log(response)
|
|
|
|
|
+ if (response.data) {
|
|
|
|
|
+ this.entryForm[this.entryForm.length - 1].url = response.data.msg
|
|
|
|
|
+ this.entryForm[this.entryForm.length - 1].content = null
|
|
|
|
|
+ this.entryForm[this.entryForm.length - 1].name =
|
|
|
|
|
+ response.data.name
|
|
|
|
|
|
|
|
- Toast("上传成功");
|
|
|
|
|
- Toast.clear();
|
|
|
|
|
- console.log(this.entryForm);
|
|
|
|
|
|
|
+ Toast('上传成功')
|
|
|
|
|
+ Toast.clear()
|
|
|
|
|
+ console.log(this.entryForm)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Toast('上传失败')
|
|
|
|
|
+ Toast.clear()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err, x) => {
|
|
|
|
|
+ reject(err, x)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ afterRead(file) {
|
|
|
|
|
+ if (file instanceof Array) {
|
|
|
|
|
+ file.map((v) => {
|
|
|
|
|
+ this.uploadImg(v)
|
|
|
|
|
+ })
|
|
|
} else {
|
|
} else {
|
|
|
- Toast("上传失败");
|
|
|
|
|
- Toast.clear();
|
|
|
|
|
|
|
+ this.uploadImg(file)
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- .catch((err, x) => {
|
|
|
|
|
- reject(err, x);
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- afterRead(file) {
|
|
|
|
|
- if (file instanceof Array) {
|
|
|
|
|
- file.map((v) => {
|
|
|
|
|
- this.uploadImg(v);
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.uploadImg(file);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ onConfirm(e) {
|
|
|
|
|
+ this.form.area = e.value
|
|
|
|
|
+ this.form.areaName = e.label
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ this.show = false
|
|
|
|
|
+ },
|
|
|
|
|
+ onCancel() {
|
|
|
|
|
+ this.show = false
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
- onConfirm(e) {
|
|
|
|
|
- this.form.area = e.value;
|
|
|
|
|
- this.form.areaName = e.label;
|
|
|
|
|
- console.log(e);
|
|
|
|
|
- this.show = false;
|
|
|
|
|
- },
|
|
|
|
|
- onCancel() {
|
|
|
|
|
- this.show = false;
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- mounted() {
|
|
|
|
|
|
|
+ mounted() {
|
|
|
console.log('this.$route.params', this.$route.params, this.$route.params.openId)
|
|
console.log('this.$route.params', this.$route.params, this.$route.params.openId)
|
|
|
// alert('openId'+this.$route.params.openId)
|
|
// alert('openId'+this.$route.params.openId)
|
|
|
this.form.createdBy = this.$route.params.openId
|
|
this.form.createdBy = this.$route.params.openId
|
|
|
- if (this.$route.query.id) {
|
|
|
|
|
- this.getTroubleDetail();
|
|
|
|
|
|
|
+ if (this.$route.query.id) {
|
|
|
|
|
+ this.getTroubleDetail()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
-};
|
|
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|