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.

276 lines
7.1 KiB

4 years ago
<template>
<view class="content">
<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
<text>江苏省苏州市通园路66号</text>
4 years ago
<u-button shape="square" slot='right' size="mini" @click="toshowMap" 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=""
:previewFullImage="true" :form-data="otherData" :show-tips="false" @on-uploaded="toupload"
@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>
<u-popup v-model="showMap" mode="center" closeable close-icon-color="#ffffff" border-radius="14">
<view>
<view class="popuptitle">选择位置</view>
<map :style="{width:width+'px',height:height+ 'px'}" :latitude="location.latitude"
4 years ago
:longitude="location.longitude" id="map">
4 years ago
</map>
<view>
4 years ago
<u-button type="primary" shape="square">确认选择</u-button>
4 years ago
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
4 years ago
otherData: {
token: ""
},
unitshow: false,
4 years ago
showMap: false,
typeshow: false,
contentshow: false,
action: "",
location: {},
4 years ago
plist: [],
list: [],
4 years ago
listUnit: [],
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() {
var that = this;
this.loadType({
'number': "general_type",
}, function(res) {
that.plist = res;
});
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
this._mapContext = uni.createMapContext("map", this);
4 years ago
let that = this;
uni.getLocation({
4 years ago
type: "gcj02",
4 years ago
success(res) {
that.location = res;
4 years ago
that.form.latitude = res.latitude;
that.form.longitude = res.longitude;
4 years ago
}
})
uni.getSystemInfo({
complete(res) {
that.width = res.screenWidth * .8
that.height = res.screenHeight * .6
}
})
},
methods: {
4 years ago
toremove(index, lists, nam) {
console.log(lists);
let list = [];
for (var m of lists) {
list.push({
upload_id: m.response.id
})
}
this.form.files_list = list;
},
toupload(lists, name) {
console.log(lists)
let list = [];
for (var m of lists) {
list.push({
upload_id: m.response.id
})
}
this.form.files_list = list;
},
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);
}
});
},
4 years ago
toshowMap() {
this.showMap = true;
this.addMaker();
},
4 years ago
submit() {
let that = this;
this.$refs.uForm.validate(valid => {
if (valid) {
console.log('验证通过');
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);
}
});
} 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) {
that.list = res;
})
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
},
4 years ago
addMaker() {
let img = "../../../static/img/location.png"
const marker = {
id: 1,
iconPath: img,
width: 50,
height: 50,
label: {
width: 50,
height: 30,
borderWidth: 1,
borderRadius: 10,
bgColor: '#ffffff'
},
latitude: this.location.latitude,
longitude: this.location.longitude
};
this._mapContext.addMarkers({
marker,
clear: true,
complete(res) {
console.log('addMarkers', res)
},
fail(res) {
console.log('fail', res)
}
});
}
4 years ago
}
}
</script>
<style>
.content {
padding: 20rpx;
}
.popuptitle {
background: #2979ff;
color: #fff;
padding: 20rpx 30rpx;
}
</style>