|
|
@@ -1,6 +1,7 @@
|
|
|
<template>
|
|
|
<view class="main">
|
|
|
- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" right-icon="scan" title="申请报修" @clickLeft="goHome" @clickRight="HandlScanCode"></uni-nav-bar>
|
|
|
+ <uni-nav-bar fixed="true" statusBar="true" left-icon="back" right-icon="scan" title="申请报修" @clickLeft="goHome"
|
|
|
+ @clickRight="HandlScanCode"></uni-nav-bar>
|
|
|
<view>
|
|
|
<!-- <CellTip title="基本信息" /> -->
|
|
|
<!-- <Cell cellType="more" title="选择设备">
|
|
|
@@ -65,13 +66,15 @@
|
|
|
<view class="item">
|
|
|
<view class="label">通知领导</view>
|
|
|
<view class="value-wrap" style="padding-left: 0">
|
|
|
- <zxz-uni-data-select :localdata="userList" v-model="addForm.leaderUserId" @change="handleUserChange"></zxz-uni-data-select>
|
|
|
+ <zxz-uni-data-select :localdata="userList" v-model="addForm.leaderUserId"
|
|
|
+ @change="handleUserChange"></zxz-uni-data-select>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="item">
|
|
|
<view class="label">期望完成时间</view>
|
|
|
<view class="value-wrap">
|
|
|
- <uni-datetime-picker type="datetime" class="picker" v-model="addForm.expectedTime" @change="confirm">
|
|
|
+ <uni-datetime-picker type="datetime" class="picker" v-model="addForm.expectedTime"
|
|
|
+ @change="confirm">
|
|
|
{{ showTime }}
|
|
|
</uni-datetime-picker>
|
|
|
</view>
|
|
|
@@ -79,7 +82,14 @@
|
|
|
</view>
|
|
|
<view class="gzms-wrap">
|
|
|
<view class="title">故障描述</view>
|
|
|
- <u--textarea v-model="addForm.remark" class="border" maxlength="500" placeholder="请输入内容" count></u--textarea>
|
|
|
+ <u--textarea v-model="addForm.remark" class="border" maxlength="500" placeholder="请输入内容"
|
|
|
+ count></u--textarea>
|
|
|
+ </view>
|
|
|
+ <view class="gzms-wrap">
|
|
|
+ <view class="photo_btn" @click="chooseImage">拍照</view>
|
|
|
+ <view class="photo_list">
|
|
|
+ <PreviewPhoto type="add" @imagedelete="imagedelete" :imageList="form.repairsImg" />
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<!-- <view class="sc-wrap">
|
|
|
<view class="title">相关照片</view>
|
|
|
@@ -89,19 +99,34 @@
|
|
|
<view class="footer">
|
|
|
<text @click="submitAdd">报修</text>
|
|
|
</view>
|
|
|
- <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirmDep" title="选择部门" :localdata="listData" valueKey="id" textKey="name" childrenKey="children" />
|
|
|
+ <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirmDep" title="选择部门"
|
|
|
+ :localdata="listData" valueKey="id" textKey="name" childrenKey="children" />
|
|
|
+ <u-toast ref="uToast"></u-toast>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import PreviewPhoto from '@/pages/maintenance/check/components/PreviewPhoto.vue'
|
|
|
import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
|
|
|
- import { listOrganizations, getUserPage } from '@/api/myTicket/index.js'
|
|
|
+ import {
|
|
|
+ listOrganizations,
|
|
|
+ getUserPage
|
|
|
+ } from '@/api/myTicket/index.js'
|
|
|
import Assign from '@/components/Assign.vue'
|
|
|
- import { getAssetInfo, save, getByFixCode } from '@/api/repair'
|
|
|
+ import {
|
|
|
+ getAssetInfo,
|
|
|
+ save,
|
|
|
+ getByFixCode
|
|
|
+ } from '@/api/repair'
|
|
|
import CellTip from '@/components/CellTip.vue'
|
|
|
import Cell from '@/components/Cell.vue'
|
|
|
- import { postJ, get } from '@/utils/api.js'
|
|
|
- import { getRuleNo } from '@/utils/utils.js'
|
|
|
+ import {
|
|
|
+ postJ,
|
|
|
+ get
|
|
|
+ } from '@/utils/api.js'
|
|
|
+ import {
|
|
|
+ getRuleNo
|
|
|
+ } from '@/utils/utils.js'
|
|
|
import selectUser from '../selectUser/index.vue'
|
|
|
import dayjs from 'dayjs'
|
|
|
export default {
|
|
|
@@ -110,7 +135,8 @@
|
|
|
Cell,
|
|
|
selectUser,
|
|
|
Assign,
|
|
|
- baTreePicker
|
|
|
+ baTreePicker,
|
|
|
+ PreviewPhoto
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -164,6 +190,74 @@
|
|
|
url: '/pages/index/index'
|
|
|
})
|
|
|
},
|
|
|
+ // *** 新增拍照
|
|
|
+ chooseImage() {
|
|
|
+ const _this = this
|
|
|
+ if (_this.form.repairsImg.length >= 9) {
|
|
|
+ _this.$refs.uToast.show({
|
|
|
+ type: "warning",
|
|
|
+ message: "最多上传9张照片",
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.chooseImage({
|
|
|
+ count: 9, //默认9
|
|
|
+ sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
+ sourceType: ['camera'], //从相册选择
|
|
|
+ success: function(res) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中'
|
|
|
+ })
|
|
|
+
|
|
|
+ _this.uploadFile(res.tempFilePaths).then(res => {
|
|
|
+ res.forEach(item => {
|
|
|
+ let fileNames = item.storePath.split('/')
|
|
|
+ let url = _this.apiUrl +
|
|
|
+ '/main/file/getFile?objectName=' + item.storePath +
|
|
|
+ '&fullfilename=' + fileNames[fileNames.length -
|
|
|
+ 1]
|
|
|
+ let repairsImg = _this.form.repairsImg;
|
|
|
+ // 不能存储超过 9 张
|
|
|
+ if (repairsImg.length < 9) {
|
|
|
+ _this.form.repairsImg.push(url);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ uni.hideLoading()
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ uploadFile(list) {
|
|
|
+ let PromiseAll = []
|
|
|
+ const apiUrl = this.apiUrl
|
|
|
+ const token = uni.getStorageSync("token"); //取存本地的token
|
|
|
+ list.forEach(item => {
|
|
|
+ PromiseAll.push(
|
|
|
+ new Promise((resolve, reject) => {
|
|
|
+ uni.uploadFile({
|
|
|
+ url: apiUrl + '/main/file/upload',
|
|
|
+ filePath: item,
|
|
|
+ name: 'multiPartFile',
|
|
|
+ header: {
|
|
|
+ authorization: token
|
|
|
+ },
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ let data = JSON.parse(uploadFileRes.data)
|
|
|
+ resolve(data.data)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ })
|
|
|
+ return Promise.all(PromiseAll)
|
|
|
+ },
|
|
|
+ // 图片删除
|
|
|
+ imagedelete(index) {
|
|
|
+ this.form.repairsImg.splice(index, 1);
|
|
|
+ },
|
|
|
+
|
|
|
+ // ***
|
|
|
// 提交新增
|
|
|
submitAdd() {
|
|
|
if (!this.addForm.code) {
|
|
|
@@ -186,7 +280,8 @@
|
|
|
sourceType: 1,
|
|
|
leaderDeptId: this.addForm.leaderDeptId,
|
|
|
leaderUserId: this.addForm.leaderUserId,
|
|
|
- leaderName: this.addForm.leaderName
|
|
|
+ leaderName: this.addForm.leaderName,
|
|
|
+ repairsImg: this.form.repairsImg,
|
|
|
}
|
|
|
save(params)
|
|
|
.then(res => {
|
|
|
@@ -217,7 +312,11 @@
|
|
|
this.getUser(data[0])
|
|
|
},
|
|
|
getUser(deptCode) {
|
|
|
- getUserPage({ pageNum: 1, size: -1, groupId: deptCode }).then(data => {
|
|
|
+ getUserPage({
|
|
|
+ pageNum: 1,
|
|
|
+ size: -1,
|
|
|
+ groupId: deptCode
|
|
|
+ }).then(data => {
|
|
|
this.userList = data.list.map(item => {
|
|
|
item.text = item.name
|
|
|
item.value = item.id
|
|
|
@@ -242,7 +341,8 @@
|
|
|
...res,
|
|
|
leaderUserId: ''
|
|
|
}
|
|
|
- this.addForm.equiLocation = this.addForm.deviceLocationName + '-' + this.addForm.deviceDetailAddress
|
|
|
+ this.addForm.equiLocation = this.addForm.deviceLocationName + '-' + this.addForm
|
|
|
+ .deviceDetailAddress
|
|
|
})
|
|
|
},
|
|
|
confirm(e) {
|
|
|
@@ -265,7 +365,8 @@
|
|
|
this.form.equiCode = data.assetCode
|
|
|
this.form.equiName = data.assetName
|
|
|
this.form.equiModel = data.information.modelType || ''
|
|
|
- this.form.equiLocation = this.initDetailLocation(`${data.factoryName}/${data.workshopName}/${data.lineName}/${data.detailLocation}`)
|
|
|
+ this.form.equiLocation = this.initDetailLocation(
|
|
|
+ `${data.factoryName}/${data.workshopName}/${data.lineName}/${data.detailLocation}`)
|
|
|
},
|
|
|
// 设备位置
|
|
|
initDetailLocation(val) {
|
|
|
@@ -304,10 +405,10 @@
|
|
|
deptName: n.deptName
|
|
|
}
|
|
|
})
|
|
|
- let repairsImg = param.repairsImg.map(n => {
|
|
|
- return n.url
|
|
|
- })
|
|
|
- param.repairsImg = repairsImg.join(',')
|
|
|
+ // let repairsImg = param.repairsImg.map(n => {
|
|
|
+ // return n.url
|
|
|
+ // })
|
|
|
+ // param.repairsImg = repairsImg.join(',')
|
|
|
param.expectedTime = this.showTime
|
|
|
postJ(this.apiUrl + '/repair/info/saveOrEdit', param).then(res => {
|
|
|
if (res.success) {
|
|
|
@@ -324,50 +425,50 @@
|
|
|
},
|
|
|
|
|
|
// 选择图片
|
|
|
- async handlImageSelect(e) {
|
|
|
- let element = e.tempFiles[0]
|
|
|
- let url = await this.uploadFiles(element.path)
|
|
|
- console.log(url)
|
|
|
- if (url) {
|
|
|
- element.url = url
|
|
|
- this.form.repairsImg.push(element)
|
|
|
- }
|
|
|
- },
|
|
|
+ // async handlImageSelect(e) {
|
|
|
+ // let element = e.tempFiles[0]
|
|
|
+ // let url = await this.uploadFiles(element.path)
|
|
|
+ // console.log(url)
|
|
|
+ // if (url) {
|
|
|
+ // element.url = url
|
|
|
+ // this.form.repairsImg.push(element)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
// 图片删除
|
|
|
- handlImagDeletee(e) {
|
|
|
- let index = this.form.repairsImg.findIndex(n => {
|
|
|
- return n.uuid == e.tempFile.uuid
|
|
|
- })
|
|
|
- if (index !== -1) {
|
|
|
- this.form.repairsImg.splice(index, 1)
|
|
|
- }
|
|
|
- },
|
|
|
+ // handlImagDeletee(e) {
|
|
|
+ // let index = this.form.repairsImg.findIndex(n => {
|
|
|
+ // return n.uuid == e.tempFile.uuid
|
|
|
+ // })
|
|
|
+ // if (index !== -1) {
|
|
|
+ // this.form.repairsImg.splice(index, 1)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
// 文件上传
|
|
|
- uploadFiles(tempFilePaths) {
|
|
|
- let that = this
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- uni.uploadFile({
|
|
|
- url: this.apiUrl + '/data/doc/add', //后端用于处理图片并返回图片地址的接口
|
|
|
- filePath: tempFilePaths,
|
|
|
- name: 'file',
|
|
|
- header: that.header,
|
|
|
- formData: {
|
|
|
- module: '申请报修'
|
|
|
- },
|
|
|
- success: res => {
|
|
|
- let data = JSON.parse(res.data) //返回的是字符串,需要转成对象格式
|
|
|
- resolve(data.data.accessUrl)
|
|
|
- },
|
|
|
- fail: err => {
|
|
|
- reject(null)
|
|
|
- uni.showToast({
|
|
|
- title: '图片上传失败',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+ // uploadFiles(tempFilePaths) {
|
|
|
+ // let that = this
|
|
|
+ // return new Promise((resolve, reject) => {
|
|
|
+ // uni.uploadFile({
|
|
|
+ // url: this.apiUrl + '/data/doc/add', //后端用于处理图片并返回图片地址的接口
|
|
|
+ // filePath: tempFilePaths,
|
|
|
+ // name: 'file',
|
|
|
+ // header: that.header,
|
|
|
+ // formData: {
|
|
|
+ // module: '申请报修'
|
|
|
+ // },
|
|
|
+ // success: res => {
|
|
|
+ // let data = JSON.parse(res.data) //返回的是字符串,需要转成对象格式
|
|
|
+ // resolve(data.data.accessUrl)
|
|
|
+ // },
|
|
|
+ // fail: err => {
|
|
|
+ // reject(null)
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '图片上传失败',
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // },
|
|
|
// 打开用户选择
|
|
|
handlselectUser() {
|
|
|
this.$refs.select_user.open()
|
|
|
@@ -399,10 +500,12 @@
|
|
|
'm+': this.getMinutes(),
|
|
|
's+': this.getSeconds()
|
|
|
}
|
|
|
- if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
|
|
|
+ if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1
|
|
|
+ .length))
|
|
|
for (var i in args) {
|
|
|
var n = args[i]
|
|
|
- if (new RegExp('(' + i + ')').test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ('00' + n).substr(('' + n).length))
|
|
|
+ if (new RegExp('(' + i + ')').test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ?
|
|
|
+ n : ('00' + n).substr(('' + n).length))
|
|
|
}
|
|
|
return format
|
|
|
},
|
|
|
@@ -431,7 +534,8 @@
|
|
|
...res,
|
|
|
leaderUserId: ''
|
|
|
}
|
|
|
- this.addForm.equiLocation = this.addForm.deviceLocationName + '-' + this.addForm.deviceDetailAddress
|
|
|
+ this.addForm.equiLocation = this.addForm.deviceLocationName + '-' + this
|
|
|
+ .addForm.deviceDetailAddress
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
@@ -488,6 +592,19 @@
|
|
|
font-size: 32rpx;
|
|
|
}
|
|
|
|
|
|
+ .photo_btn {
|
|
|
+ background-color: #157a2c;
|
|
|
+ width: 140rpx;
|
|
|
+ height: 60rpx;
|
|
|
+ line-height: 60rpx;
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #fff;
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ margin-bottom: 12rpx;
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+
|
|
|
.equiDetails {
|
|
|
.list {
|
|
|
border-bottom: none;
|
|
|
@@ -607,7 +724,7 @@
|
|
|
display: flex;
|
|
|
border: 1px solid #d7d7d7;
|
|
|
|
|
|
- & + .item {
|
|
|
+ &+.item {
|
|
|
margin-top: 20rpx;
|
|
|
}
|
|
|
|
|
|
@@ -697,7 +814,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- & + .jsr-item {
|
|
|
+ &+.jsr-item {
|
|
|
margin-left: 20rpx;
|
|
|
}
|
|
|
}
|
|
|
@@ -722,4 +839,4 @@
|
|
|
.border {
|
|
|
border: 1px solid #eee;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|