1
This commit is contained in:
parent
b0a5be471b
commit
d61171ee58
@ -2,7 +2,7 @@
|
||||
* @Author: gtz
|
||||
* @Date: 2022-07-25 14:18:00
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2022-07-29 13:31:29
|
||||
* @LastEditTime: 2022-08-02 13:55:00
|
||||
* @Description: file content
|
||||
* @FilePath: \hf-pda\src\api\eqInspection.js
|
||||
*/
|
||||
@ -17,6 +17,24 @@ export const list = data => {
|
||||
})
|
||||
}
|
||||
|
||||
// 获取巡检记录列表
|
||||
export const add = data => {
|
||||
return request({
|
||||
url: '/api/equipment/inspectionLog/add',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取巡检记录列表
|
||||
export const update = data => {
|
||||
return request({
|
||||
url: '/api/equipment/inspectionLog/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取巡检记录详情
|
||||
export const detail = data => {
|
||||
return request({
|
||||
|
@ -1,3 +1,11 @@
|
||||
/*
|
||||
* @Author: gtz
|
||||
* @Date: 2022-08-02 08:42:08
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2022-08-02 14:54:43
|
||||
* @Description: file content
|
||||
* @FilePath: \hf-pda\src\api\file.js
|
||||
*/
|
||||
import request from '@/util/request'
|
||||
|
||||
// 文件上传
|
||||
@ -9,3 +17,14 @@ export const uploadFile = data => {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 文件下载
|
||||
export const downloadFile = params => {
|
||||
return request({
|
||||
url: '/api/common/attachment/downloadFile',
|
||||
method: 'GET',
|
||||
formState: true,
|
||||
params,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: gtz
|
||||
* @Date: 2022-07-28 10:22:30
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2022-07-29 17:06:04
|
||||
* @LastEditTime: 2022-08-02 15:15:11
|
||||
* @Description: file content
|
||||
* @FilePath: \hf-pda\src\pages\eqInspection\eqInspection-edit.vue
|
||||
-->
|
||||
@ -61,6 +61,7 @@
|
||||
clear-trigger="always"
|
||||
disabled
|
||||
placeholder="选择巡检时间"
|
||||
@click="handleDate"
|
||||
/>
|
||||
</van-col>
|
||||
</van-row>
|
||||
@ -119,15 +120,32 @@
|
||||
:after-read="upload"
|
||||
/>
|
||||
</van-col>
|
||||
<van-col :span="22" :offset="1">
|
||||
<van-button type="info" round size="large" @click="handleSubmit">
|
||||
提交
|
||||
</van-button>
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
</div>
|
||||
<van-popup v-model="show" position="bottom">
|
||||
<van-datetime-picker
|
||||
v-model="currentDate"
|
||||
type="datetime"
|
||||
:title="dateType ? '选择结束时间' : '选择开始时间'"
|
||||
:min-date="minDate"
|
||||
@confirm="setDate"
|
||||
@cancel="show = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { detail, eqList, getInsList, updateInsStatus } from '@/api/eqInspection'
|
||||
import { uploadFile } from '@/api/file'
|
||||
import moment from 'moment'
|
||||
import { detail, eqList, getInsList, updateInsStatus, add, update } from '@/api/eqInspection'
|
||||
import { uploadFile, downloadFile } from '@/api/file'
|
||||
import { blobToBase64 } from '@/util/utils'
|
||||
import shortLine from '@/components/shortLine.vue'
|
||||
import { Toast } from 'vant'
|
||||
|
||||
@ -150,7 +168,11 @@ export default {
|
||||
insList: [],
|
||||
insTime: null,
|
||||
fileList: [],
|
||||
eqId: null
|
||||
eqId: null,
|
||||
show: false,
|
||||
currentDate: null,
|
||||
minDate: new Date(2020, 0, 1),
|
||||
dateType: 0
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@ -191,20 +213,39 @@ export default {
|
||||
})
|
||||
if (result1.success) {
|
||||
this.insList = result1.data.map(item => {
|
||||
item.statusBoolean = item.status === '1' ? true : false
|
||||
if (item.status === '1') {
|
||||
item.statusBoolean = true
|
||||
} else {
|
||||
item.statusBoolean = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
if (result.data.annexUrl) {
|
||||
const result2 = await downloadFile({
|
||||
type: 'file',
|
||||
attachmentId: result.data.annexUrl
|
||||
})
|
||||
blobToBase64(result2.data.data, (v) => {
|
||||
const file = new File([result2.data.data], result2.data.headers['content-disposition'].slice(result2.data.headers['content-disposition'].indexOf('filename=') + 9), { type: '*' })
|
||||
this.fileList.push({
|
||||
content: v,
|
||||
file
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
// 文件上传
|
||||
async upload (file) {
|
||||
console.log(this.fileList)
|
||||
const data = new FormData()
|
||||
data.append('files', file.file)
|
||||
data.append('typeCode', 'file')
|
||||
setTimeout(async () => {
|
||||
const result = await uploadFile(data)
|
||||
}, 1000)
|
||||
const result = await uploadFile(data)
|
||||
if (result.success) {
|
||||
this.dataForm.annexUrl = result.data[0].id
|
||||
}
|
||||
},
|
||||
// 更新巡检内容状态
|
||||
async updateStatus (item) {
|
||||
@ -220,6 +261,45 @@ export default {
|
||||
} else {
|
||||
item.statusBoolean = !item.statusBoolean
|
||||
}
|
||||
},
|
||||
// 更新时间
|
||||
setDate (v) {
|
||||
if (this.dateType) {
|
||||
if (v.valueOf() - new Date(this.dataForm.inspectionStartTime).valueOf()) {
|
||||
this.dataForm.inspectionEndTime = moment(v).format('YYYY-MM-DDTHH:mm:ss')
|
||||
this.show = false
|
||||
this.insTime = moment(this.dataForm.inspectionStartTime).format('YYYY-MM-DD HH:mm:ss') + '-' + moment(v).format('YYYY-MM-DD HH:mm:ss')
|
||||
this.dateType = 0
|
||||
} else {
|
||||
this.$notify('结束时间必须大于开始时间!')
|
||||
}
|
||||
} else {
|
||||
this.dataForm.inspectionStartTime = moment(v).format('YYYY-MM-DDTHH:mm:ss')
|
||||
this.dateType = 1
|
||||
}
|
||||
},
|
||||
// 弹出日期选择器
|
||||
handleDate () {
|
||||
this.show = true
|
||||
},
|
||||
// 提交表单
|
||||
async handleSubmit () {
|
||||
let result = {}
|
||||
if (this.$route.query.id) {
|
||||
result = await update(this.dataForm)
|
||||
} else {
|
||||
result = await add(this.dataForm)
|
||||
}
|
||||
if (result.success) {
|
||||
Toast.success({
|
||||
message: '操作成功',
|
||||
onClose: () => {
|
||||
this.$router.push({
|
||||
name: 'eqInspection'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: gtz
|
||||
* @Date: 2022-07-25 14:18:00
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2022-07-29 13:18:34
|
||||
* @LastEditTime: 2022-08-02 15:08:29
|
||||
* @Description: file content
|
||||
* @FilePath: \hf-pda\src\util\request.js
|
||||
*/
|
||||
@ -58,6 +58,11 @@ service.interceptors.response.use(
|
||||
data: response.data.data,
|
||||
pagetotal: response.data.pagetotal
|
||||
}
|
||||
} else if (response.config.responseType === 'blob') {
|
||||
return {
|
||||
success: true,
|
||||
data: response
|
||||
}
|
||||
} else {
|
||||
Notify(response.data.msg)
|
||||
return {
|
||||
|
16
src/util/utils.js
Normal file
16
src/util/utils.js
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* @Author: gtz
|
||||
* @Date: 2022-08-02 15:00:02
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2022-08-02 15:03:00
|
||||
* @Description: file content
|
||||
* @FilePath: \hf-pda\src\util\utils.js
|
||||
*/
|
||||
|
||||
export const blobToBase64 = (blob, callback) => {
|
||||
var reader = new FileReader()
|
||||
reader.onload = function (e) {
|
||||
callback(e.target.result)
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
}
|
Loading…
Reference in New Issue
Block a user