123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <template>
- <view class="appWrapper">
- <form action="">
- <view style="height:30rpx"></view>
- <view class="form-item">
- <view class="title">
- <text class="necessary">*</text>
- 监察标题:
- </view>
- <input type="text" v-model="supervision_title" required>
- <!-- <select name="" id="" filterable clearable v-model="supervision_title">
- <option value="">请选择</option>
- <option :value=item.supervision_name v-for="item in titleListData">{{ item.supervision_name}}</option>
- </select> -->
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>所属站点:</view>
- <select name="" id="" filterable clearable v-model="site_id">
- <option value="">请选择</option>
- <option :value=item.id v-for="item in siteListData">{{ item.site_name}}</option>
- </select>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>监察内容:</view>
- <textarea maxlength="-1" width="250" v-model="supervision_content"></textarea>
- </view>
-
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>上传图片:</view>
- <view style="width:500rpx">
-
- <!-- <uni-group title="只选择图片">
- <uni-file-picker limit="1"></uni-file-picker>
- </uni-group> -->
-
-
- <view ref="input" class="input">
- </view>
- <!-- <view class="cu-form-group" style="padding:0">
- <view class="grid col-4 grid-square flex-sub">
- <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage"
- :data-url="imgList[index]">
- <image :src="imgList[index]" mode="aspectFill"></image>
- <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
- <text class='cuIcon-close'></text>
- </view>
- </view>
- <view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
- <text class='cuIcon-cameraadd'></text>
- </view>
- </view>
- </view> -->
- </view>
- </view>
- <br>
- <view style="height:20rpx;background:#EDEDED"></view>
- <view class="form-item justify-between" style="border-bottom:1px solid #EDEDED;padding:20rpx 30rpx" @tap="goArchivePage()">
- <view >现场档案</view>
- <view><text class="icon iconfont margin-left-xs "></text></view>
- </view>
- <view class="btn-area submitBottomBtn padding-lr-sm">
- <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
- </view>
- </form>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- noClick:true,
-
- imgList: [],
- supervision_title: '',
- site_id: '',
- supervision_content: '',
- msg:'',
- img:'',
- titleListData: [],
- siteListData: [],
- }
- },
- onLoad: function(option) {
- this.getSiteList();
-
-
- },
- mounted(){
- // 创建附件上传
- var _self = this;
- var input = document.createElement('input');//创建元素
- input.type = 'file'//添加file类型
- input.onchange = (event) => {
- _self.upFile(input, event)
- }
- this.$refs.input.$el.appendChild(input)
-
- },
- methods: {
-
- goArchivePage(){
- uni.navigateTo({
- url: '/pages/siteArchive/siteArchive',
- });
- },
- upFile(input, event) {
- var _self = this;
-
- uni.uploadFile({
- url: 'https://wx.ewoogi.com/wx/USKYOF/USKYOF.php/Home/MonitoringReporting/setUpload',
-
- files: [
- {
- file: input.files[0],
- uri: event.srcElement.value
- }
- ],
- success: (uploadFileRes) => {
- var data=JSON.parse(uploadFileRes.data)
- // alert('上传成功')
- // alert(data.img_url)
- // console.log('data')
- // console.log(data.img_url)
- // console.log('uploadFileRes')
- this.img=data.img_url
- },
- fail: (err) => {
- // alert('上传失败')
- console.log(err)
- }
- });
- },
-
- //新增提交
- async addSubmit() {
-
- if (!this.supervision_title.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入监察标题",
- icon: "none"
- });
- return
- }
- if (!this.site_id) {
- uni.showToast({
- title: "请选择站点",
- icon: "none"
- });
- return
- }
- if (!this.supervision_content.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请输入监察内容",
- icon: "none"
- });
- return
- }
- if (!this.img) {
- uni.showToast({
- title: "请上传图片",
- icon: "none"
- });
- return
- }
-
- // if (!this.msg ) {
- // uni.showToast({
- // title: "请上传图片",
- // icon: "none"
- // });
- // return
- // }
-
- let res = await this.addReport({
- "supervision_title": this.supervision_title,
- "site_id": this.site_id,
- "supervision_content": this.supervision_content,
- // "img":this.imgList[0]
- "img_url":this.img
- })
- if (!res.data.flag) {
- uni.showToast({
- title: "添加失败",
- icon: "none"
- });
- } else {
- uni.showToast({
- title: "添加成功",
- });
- }
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/siteArchive/controlReport/controlReport',
- });
- }, 1000);
- },
- addReport(params = {}) {
- return this.$myRequest({
- url: 'MonitoringReporting/addMonitoringReporting',
- data: params
- })
- },
- //站带下拉数据请求
- async getSiteList(params = {}) {
- const res = await this.$myRequest({
- url: 'BlackoutPlan/getSiteBox',
- showLoading: true,
- data: params
- })
- this.siteListData = res.data.data
- },
- ChooseImage() {
- uni.chooseImage({
- count: 4, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album'], //从相册选择
- success: (res) => {
- if (this.imgList.length != 0) {
- this.imgList = this.imgList.concat(res.tempFilePaths)
- } else {
- this.imgList = res.tempFilePaths
- }
- }
- });
- },
- ViewImage(e) {
- uni.previewImage({
- urls: this.imgList,
- current: e.currentTarget.dataset.url
- });
- },
- DelImg(e) {
- uni.showModal({
- title: '删除',
- content: '确定要删除此图片吗?',
- cancelText: '取消',
- confirmText: '确定',
- success: res => {
- if (res.confirm) {
- this.imgList.splice(e.currentTarget.dataset.index, 1)
- }
- }
- })
- },
- submit() {
- uni.navigateTo({
- url: '/pages/accountManage/success/success',
- });
- },
- }
- }
- </script>
- <style lang="scss">
- select {
- background-size: 6%;
- }
- </style>
|