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.

356 lines
9.2 KiB

4 years ago
<template>
3 years ago
<view class="content">
<view>
所属道路{{roadName}}
</view>
4 years ago
<u-form :model="form" ref="uForm">
4 years ago
<u-form-item label="问题类型" label-position="top" prop="typeName" required>
4 years ago
<u-input v-model="form.typeName" type="select" :border="true" @click="typeshow = true" />
4 years ago
<u-select v-model="typeshow" mode="single-column" value-name="id" label-name="value" :list="plist"
@confirm="confirmType"></u-select>
4 years ago
</u-form-item>
4 years ago
<u-form-item label="问题内容" label-position="top" prop="contentName" required>
4 years ago
<u-input v-model="form.contentName" type="select" :border="true" @click="contentshow = true" />
4 years ago
<u-select v-model="contentshow" mode="single-column" value-name="id" label-name="value" :list="list"
@confirm="confirmContent"></u-select>
4 years ago
</u-form-item>
4 years ago
<u-form-item label="位置" label-position="top" required>
4 years ago
<u-input v-model="form.address" disabled type='text'/>
<u-button shape="square" slot='right' size="mini" @click="chooseLocation" type="info">重新获取</u-button>
4 years ago
</u-form-item>
4 years ago
<u-form-item label-position="top" label="描述" prop="content">
<u-input v-model="form.content" type='textarea' height='100' :border="true" />
4 years ago
</u-form-item>
4 years ago
<u-form-item label-position="top" label="附件上传">
<u-upload ref="uUpload" multiple :maxCount="10" :action="action" upload-text=""
4 years ago
:previewFullImage="true" @on-progress="onprogress" @on-success="tosuccess" :file-list="filesList" :form-data="otherData" :show-tips="false" @on-uploaded="toupload"
4 years ago
@on-remove="toremove">
</u-upload>
</u-form-item>
<u-form-item label="反馈科室" label-position="top" required>
<u-input v-model="form.unitName" placeholder="请选择反馈科室" type="select" :border="true"
@click="unitshow = true" />
<u-select v-model="unitshow" mode="single-column" value-name="id" label-name="name" :list="listUnit"
@confirm="confirmUnit"></u-select>
4 years ago
</u-form-item>
</u-form>
<u-button type="primary" @click="submit"></u-button>
</view>
</template>
<script>
export default {
data() {
return {
4 years ago
otherData: {
token: ""
3 years ago
},
roadName:"",
4 years ago
unitshow: false,
4 years ago
typeshow: false,
contentshow: false,
action: "",
location: {},
4 years ago
plist: [],
list: [],
3 years ago
listUnit: [],
filesList:[],
4 years ago
infoId:"",
4 years ago
form: {
4 years ago
unitName: "",
ask_type_id: "",
ask_content_id: "",
4 years ago
typeName: "",
4 years ago
contentName: "",
content: "",
feedback_department_id: "",
longitude: "",
latitude: "",
files_list: [],
address: ""
4 years ago
},
width: 300,
4 years ago
height: 300,
action: "",
rules: {
typeName: [{
required: true,
message: '请选择类型',
// 可以单个或者同时写两个触发验证方式
trigger: ['change', 'blur'],
}],
contentName: [{
required: true,
message: '请选择内容',
// 可以单个或者同时写两个触发验证方式
trigger: ['change', 'blur'],
}]
}
4 years ago
}
},
4 years ago
onLoad(options) {
4 years ago
var that = this;
this.loadType({
'number': "general_type",
}, function(res) {
that.plist = res;
3 years ago
});
if(options.id){
this.infoId = options.id;
this.showInfo(this.infoId);
3 years ago
}
if(options.roadid){
this.form.road_id = options.roadid
this.roadName = options.roadname
4 years ago
}
4 years ago
this.action = this.util.HOST + "/api/mobile/upload-file";
this.otherData.token = uni.getStorageSync("userInfo_token").access_token;
this.loadUnit();
4 years ago
},
4 years ago
onReady() {
4 years ago
this.$refs.uForm.setRules(this.rules);
4 years ago
let that = this;
uni.getLocation({
4 years ago
type: "gcj02",
4 years ago
success(res) {
3 years ago
that.location = res;
var loc = null
console.log(typeof(window.android))
if (typeof(window.android) != undefined && typeof(window.android) != "undefined") {
loc = window.android.getLocInfo();
}
if (loc) {
that.form.latitude = JSON.parse(loc).lat;
that.form.longitude = JSON.parse(loc).lon;
} else {
that.form.latitude = res.latitude;
that.form.longitude = res.longitude;
}
const url =
"https://apis.map.qq.com/ws/geocoder/v1/?key=EUQBZ-MJALU-WZFVR-2HFNW-TIK2K-TNBJI&location=" +
that.form.latitude + "," + that.form.longitude + "&output=jsonp"
3 years ago
that.$jsonp(
url
).then(re => {
that.form.address = re.result.formatted_addresses.recommend
4 years ago
})
4 years ago
}
})
uni.getSystemInfo({
complete(res) {
that.width = res.screenWidth * .8
that.height = res.screenHeight * .6
}
})
},
3 years ago
methods: {
onprogress(res){
uni.showToast({
icon: "none",
title: "上传中",
duration: 2000
})
},
tosuccess(){
uni.showToast({
icon: "none",
title: "上传成功",
duration: 2000
})
4 years ago
},
4 years ago
toremove(index, lists, nam) {
console.log(lists);
let list = [];
4 years ago
this.filesList.splice(index,1)
4 years ago
},
toupload(lists, name) {
console.log(lists)
let list = [];
3 years ago
// for (var m of lists) {
// if(m.response){
// this.filesList.push(m)
3 years ago
// }
// }
3 years ago
this.filesList = lists;
4 years ago
},
confirmUnit(e) {
var that = this;
this.form.feedback_department_id = e[0].value
this.form.unitName = e[0].label
},
4 years ago
loadType(data, call) {
let that = this;
this.util.request({
api: '/api/admin/parameter/show',
data: data,
utilSuccess: function(res) {
call(res.detail)
},
utilFail: function(res) {
this.util.alert(res);
}
});
},
4 years ago
loadUnit() {
let that = this;
this.util.request({
api: '/api/mobile/other/department-list',
utilSuccess: function(res) {
that.listUnit = res;
},
utilFail: function(res) {
this.util.alert(res);
}
});
3 years ago
},
showInfo(id){
var that = this;
that.util.request({
api: '/api/mobile/common-inspection/show',
method: "get",
data: {
id:id
},
utilSuccess: function(result) {
that.form = result;
that.form.typeName = result.ask_type_detail.value;
that.form.contentName = result.ask_content_detail.value;
3 years ago
that.form.unitName = result.feedback_department.name
that.roadName = result.road?result.road.name:""
3 years ago
let _files = [];
for (var mod of result.common_inspection_files) {
let m = Object.assign({}, mod);
m.url = mod.files.url;
m.id = mod.files.id;
m.name = mod.files.original_name;
_files.push(m);
}
that.filesList = _files
// that.form.files_list = _upfiles;
},
utilFail: function(res) {
that.util.alert(res);
}
});
4 years ago
},
4 years ago
4 years ago
submit() {
3 years ago
let that = this;
let list = [];
for(var mod of that.filesList){
if( mod.response){
list.push({
upload_id: mod.response.id
})
}else{
list.push({
upload_id:mod.id
})
}
}
this.form.files_list = list
// console.log(that.form);
4 years ago
// return;
4 years ago
this.$refs.uForm.validate(valid => {
if (valid) {
3 years ago
console.log('验证通过');
if(that.infoId){
that.util.request({
api: '/api/mobile/common-inspection/save',
method: "POST",
data: that.form,
utilSuccess: function(res) {
uni.showToast({
icon: "none",
title: "提交成功",
complete() {
that.afterSubmit(res);
},
duration: 2000
})
},
utilFail: function(res) {
this.util.alert(res);
}
});
}else{
that.util.request({
api: '/api/mobile/common-inspection/store',
method: "POST",
data: that.form,
utilSuccess: function(res) {
uni.showToast({
icon: "none",
title: "提交成功",
complete() {
that.afterSubmit(res);
},
duration: 2000
})
},
utilFail: function(res) {
this.util.alert(res);
}
});
4 years ago
}
4 years ago
} else {
console.log('验证失败');
}
});
},
afterSubmit(res) {
uni.redirectTo({
url: "../generalList/generalList"
})
},
4 years ago
confirmType(e) {
4 years ago
var that = this;
4 years ago
this.form.ask_type_id = e[0].value
4 years ago
this.form.typeName = e[0].label
4 years ago
this.loadType({
pid: e[0].value
}, function(res) {
3 years ago
that.list = res;
that.form.ask_content_id =""
4 years ago
that.form.contentName =""
4 years ago
})
4 years ago
},
confirmContent(e) {
4 years ago
this.form.ask_content_id = e[0].value
4 years ago
this.form.contentName = e[0].label
},
3 years ago
chooseLocation(e) { //打开地图选择位置
var that = this;
uni.chooseLocation({
longitude : that.form.longitude,
latitude : that.form.latitude,
success: res => {
that.form.address = res.name;
that.form.longitude = res.longitude;
that.form.latitude = res.latitude;
}
});
4 years ago
},
4 years ago
}
}
</script>
<style>
.content {
padding: 20rpx;
}
.popuptitle {
3 years ago
background: #0385e5;
4 years ago
color: #fff;
padding: 20rpx 30rpx;
}
3 years ago
</style>