feat: 实时工情上报

master
张林 2024-06-13 16:02:00 +08:00
parent 62e0a66a3e
commit 6faebcfcc6
3 changed files with 124 additions and 381 deletions

View File

@ -362,14 +362,6 @@ export default {
chcount: '', chcount: '',
spcount: '', spcount: '',
elose: '', elose: '',
projectName: '', //
projectType: '', //
isControlled: '', // 0 1
incidentDescription: '',
controlResponsiblePerson: '', //
responsiblePersonPhone: '', //
remark: '' remark: ''
}, },
@ -404,11 +396,11 @@ export default {
} }
], ],
rules: { rules: {
projectName: [ otime: [
{ {
type: 'string', type: 'string',
required: true, required: true,
message: '请选择工程名称', message: '请选择时间',
trigger: ['blur', 'change'] trigger: ['blur', 'change']
} }
] ]
@ -425,11 +417,7 @@ export default {
onReady () { onReady () {
console.log('搜索框22key', this.key) console.log('搜索框22key', this.key)
// setRules // setRules
if (this.key == 1) { this.$refs.form2.setRules(this.rules)
this.$refs.form1.setRules(this.rules)
} else if (this.key == 1) {
this.$refs.form2.setRules(this.rules)
}
}, },
methods: { methods: {
async getresList () { async getresList () {
@ -482,8 +470,6 @@ export default {
item.isShow = true item.isShow = true
this.gclabel = item.resName this.gclabel = item.resName
this.formList.projectName = item.resName this.formList.projectName = item.resName
this.$refs.form1.validateField('isPowerGeneration')
} else { } else {
item.isShow = false item.isShow = false
} }
@ -536,15 +522,12 @@ export default {
uploadFilePromise (url) { uploadFilePromise (url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let a = uni.uploadFile({ let a = uni.uploadFile({
url: uni.$http.baseUrl + '/xfProjectRun/file/upload/singleSimple', // url: `${uni.$http.baseUrl}/gunshiApp/xfflood/iaCHsfwater/file/upload/singleSimple`,
filePath: url, filePath: url,
name: 'file', name: 'file',
formData: {
user: 'test'
},
success: res => { success: res => {
setTimeout(() => { setTimeout(() => {
resolve(res.data.data) resolve(res.data)
}, 1000) }, 1000)
} }
}) })
@ -552,12 +535,7 @@ export default {
}, },
open () {}, open () {},
groupChange (n) {
// console.log('groupChange', n);
},
radioChange (n) {
// console.log('radioChange', n);
},
navigateBack () { navigateBack () {
uni.navigateBack() uni.navigateBack()
}, },
@ -573,83 +551,51 @@ export default {
}, },
submit () { submit () {
if (key == 2) { this.$refs.form2
this.$refs.form2 .validate()
.validate() .then(res => {
.then(res => { uni.$u.toast('校验通过', res)
uni.$u.toast('校验通过', res) debugger
let params = Object.assign(this.formList)
// 1 2 3 4
if (this.formList.severity == '一般险情') {
params.severity = 1
} else if (this.formList.severity == '较大险情') {
params.severity = 2
} else if (this.formList.severity == '重大险情') {
params.severity = 3
} else if (this.formList.severity == '特别重大险情') {
params.severity = 4
}
params.adcd = ''
let params = Object.assign(this.formList) if (this.fileList1.length > 0) {
if (this.fileId !== '') { params.fileId = this.fileList1.map(item => {
params = Object.assign(this.formList, this.fileId) return JSON.parse(item.url).data.fileId
} })
// 1 2 3 4 }
let type = {
一般险情: 1,
较大险情: 2,
重大险情: 3,
特别重大险情: 4
}
params.severity = this.formLis.severity[type]
params.projectType = this.params.projectType
uni.$http uni.$http
.post('/gunshiApp/xfflood/iaCHsfwater/insert', params) .post('/gunshiApp/xfflood/iaCHsfwater/insert', params)
.then(res => { .then(res => {
console.log('this.---', res) console.log('this.---', res)
if (res.data.code == 200) { if (res.data.code == 200) {
console.log('this.model122', res.data) console.log('this.model122', res.data)
uni.reLaunch({ uni.reLaunch({
url: '/pages/xxsb/index' url: '/pages/xxsb/index'
}) })
} }
}) })
}) })
.catch(errors => { .catch(errors => {
uni.$u.toast('校验失败', res) uni.$u.toast('校验失败', errors)
}) console.log('校验失败')
} else if (key == 3) { })
this.$refs.form3
.validate()
.then(res => {
uni.$u.toast('校验通过', res)
console.log('this.==', this.formList)
let params = Object.assign(this.formList)
if (this.fileId !== '') {
params = Object.assign(this.formList, this.fileId)
}
// 1 2 3 4
let type = {
一般险情: 1,
较大险情: 2,
重大险情: 3,
特别重大险情: 4
}
params.severity = this.formLis.severity[type]
params.projectType = this.params.projectType
uni.$http
.post('/gunshiApp/xfProjectIncident/insert', params)
.then(res => {
console.log('this---', res)
if (res.data.code == 200) {
console.log('this.model122', res.data)
uni.reLaunch({
url: '/pages/xxsb/index'
})
}
})
})
.catch(errors => {
uni.$u.toast('校验失败', res)
})
} else {
}
// catchthentrue // catchthentrue
}, },
reset () { reset () {
const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1'] const validateList = ['projectName', 'radiovalue1']
this.$refs.form1.resetFields() this.$refs.form1.resetFields()
this.$refs.form1.clearValidate() this.$refs.form1.clearValidate()
setTimeout(() => { setTimeout(() => {

View File

@ -139,133 +139,6 @@
></u-upload> ></u-upload>
</u-form-item> </u-form-item>
</u--form> </u--form>
<!-- 工程详情上报 -->
<u--form
labelPosition="left"
:model="formList"
ref="form2"
labelWidth="100"
v-if="key == 2"
>
<u-form-item
label="工程名称"
prop="projectName"
@click="
isName = true
hideKeyboard()
"
:borderBottom="false"
ref="item1"
>
<u--input
placeholder="请选择"
v-model="model1.projectName"
suffixIcon="arrow-right"
suffixIconStyle="color: #909399"
></u--input>
</u-form-item>
<u-form-item
label="严重程度"
prop="severityList"
:borderBottom="false"
@click="
isseverity = true
hideKeyboard()
"
ref="item1"
>
<u--input
placeholder="请选择"
v-model="formList.severity"
suffixIcon="arrow-right"
suffixIconStyle="color: #909399"
></u--input>
</u-form-item>
<u-form-item
label="是否已管控"
prop="isControlled"
:borderBottom="false"
@click="
isControlled = true
hideKeyboard()
"
ref="item1"
>
<u--input
placeholder="请选择"
v-model="formList.isControlled"
suffixIcon="arrow-right"
suffixIconStyle="color: #909399"
></u--input>
</u-form-item>
<!-- 水位(m) -->
<u-form-item
label="险情描述"
prop="incidentDescription"
:borderBottom="false"
ref="item3"
>
<u--textarea
placeholder="请输入"
v-model="formList.incidentDescription"
count
></u--textarea>
</u-form-item>
<!-- 管控责任人 -->
<u-form-item label="管控责任人" prop="controlResponsiblePerson" ref="item3">
<u--input
v-model="formList.controlResponsiblePerson"
placeholder="请输入"
border="surround"
clearable
></u--input>
</u-form-item>
<!-- 出库流量 (/s) -->
<u-form-item
label="联系电话"
prop="responsiblePersonPhone"
:borderBottom="false"
ref="item3"
>
<u--input
v-model="formList.responsiblePersonPhone"
placeholder="请输入"
type="number"
clearable
border="surround"
@blur="BlurText($event)"
></u--input>
</u-form-item>
<!-- 其他运行情况 -->
<u-form-item
label="其他情况说明"
prop="remark"
:borderBottom="false"
ref="item3"
>
<u--textarea
placeholder="请输入"
v-model="formList.remark"
count
></u--textarea>
</u-form-item>
<u-form-item
label="附件"
prop="fileList"
:borderBottom="false"
ref="item3"
>
<u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
multiple
:maxCount="10"
:previewFullImage="true"
></u-upload>
</u-form-item>
</u--form>
<u-button <u-button
type="primary" type="primary"
@ -389,7 +262,6 @@
@select="controlledSelect" @select="controlledSelect"
> >
</u-action-sheet> </u-action-sheet>
</u-action-sheet>
</view> </view>
</view> </view>
</view> </view>
@ -421,11 +293,10 @@ export default {
projectName: '', // projectName: '', //
projectType: '', // projectType: '', //
severity: '', // 1 2 3 4 severity: '', // 1 2 3 4
isControlled:'' ,// 0 1 isControlled: '', // 0 1
incidentDescription:'', incidentDescription: '',
controlResponsiblePerson:"", // controlResponsiblePerson: '', //
responsiblePersonPhone:'' // responsiblePersonPhone: '' //
}, },
model1: { model1: {
projectName: '', projectName: '',
@ -437,7 +308,7 @@ export default {
remark: '' remark: ''
}, },
fileIds: [], fileIds: [],
isControlled:false, isControlled: false,
isseverity: false, // isseverity: false, //
showSex: false, showSex: false,
isRelease: false, isRelease: false,
@ -445,20 +316,16 @@ export default {
severityList: [ severityList: [
{ {
name: '一般险情', name: '一般险情'
}, },
{ {
name: '较大险情', name: '较大险情'
}, },
{ {
name: '重大险情', name: '重大险情'
}, },
{ {
name: '特别重大险情', name: '特别重大险情'
} }
], ],
@ -490,13 +357,9 @@ export default {
this.getresList() this.getresList()
}, },
onReady () { onReady () {
console.log('搜索框22key', this.key ) console.log('搜索框22key', this.key)
// setRules // setRules
if (this.key == 1) { this.$refs.form1.setRules(this.rules)
this.$refs.form1.setRules(this.rules)
} else if(this.key == 1) {
this.$refs.form2.setRules(this.rules)
}
}, },
methods: { methods: {
async getresList () { async getresList () {
@ -586,6 +449,8 @@ export default {
}) })
for (let i = 0; i < lists.length; i++) { for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url) const result = await this.uploadFilePromise(lists[i].url)
console.log('result', JSON.parse(result))
let item = this[`fileList${event.name}`][fileListLen] let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice( this[`fileList${event.name}`].splice(
fileListLen, fileListLen,
@ -602,27 +467,19 @@ export default {
uploadFilePromise (url) { uploadFilePromise (url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let a = uni.uploadFile({ let a = uni.uploadFile({
url: uni.$http.baseUrl + '/xfProjectRun/file/upload/singleSimple', // url: `${uni.$http.baseUrl}/gunshiApp/xfflood/xfProjectRun/file/upload/singleSimple`,
filePath: url, filePath: url,
name: 'file', name: 'file',
formData: {
user: 'test'
},
success: res => { success: res => {
console.log('res888', JSON.parse(res.data))
setTimeout(() => { setTimeout(() => {
resolve(res.data.data) resolve(res.data)
this.fileId = JSON.parse(res.data).data.fileId
}, 1000) }, 1000)
} }
}) })
}) })
}, },
afterRead (event) {
this.fileList1.push({
url: event.file,
status: 'uploading',
message: '上传中'
})
},
open () {}, open () {},
groupChange (n) { groupChange (n) {
@ -650,28 +507,30 @@ export default {
this.formList.severity = e.name this.formList.severity = e.name
this.$refs.form2.validateField('severity') this.$refs.form2.validateField('severity')
}, },
controlledSelect (e){ controlledSelect (e) {
this.formList.isControlled = e.name this.formList.isControlled = e.name
this.$refs.form2.validateField('isControlled') this.$refs.form2.validateField('isControlled')
}, },
submit () { submit () {
if(key ==1){ this.$refs.form1
this.$refs.form1
.validate() .validate()
.then(res => { .then(res => {
uni.$u.toast('校验通过', res) debugger
console.log('this.model1', this.model1) console.log('文件', this.fileId)
let params = Object.assign(this.model1) let params = this.model1
if (this.fileId !== '') {
params = Object.assign(this.model1, this.fileId) params.projectType = this.projectType
}
params.projectType = this.params.projectType
params.isPowerGeneration = params.isPowerGeneration == '是' ? 1 : 0 params.isPowerGeneration = params.isPowerGeneration == '是' ? 1 : 0
params.isFloodRelease = params.isFloodRelease == '是' ? 1 : 0 params.isFloodRelease = params.isFloodRelease == '是' ? 1 : 0
console.log('参数', params)
if (this.fileId != '') {
params.fileId = [this.fileId]
}
uni.$http uni.$http
.post('/gunshiApp/xfflood/xfProjectRun/insert', params) .post('/gunshiApp/xfflood/xfProjectRun/insert', params)
.then(res => { .then(res => {
@ -685,11 +544,10 @@ export default {
}) })
}) })
.catch(errors => { .catch(errors => {
uni.$u.toast('校验失败', res) uni.$u.toast('校验失败', errors)
}) })
}
// catchthentrue
// catchthentrue
}, },
reset () { reset () {
const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1'] const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1']

View File

@ -16,7 +16,6 @@
:model="formList" :model="formList"
ref="form2" ref="form2"
labelWidth="100" labelWidth="100"
v-if="key == 2"
> >
<u-form-item <u-form-item
label="工程名称" label="工程名称"
@ -83,7 +82,11 @@
></u--textarea> ></u--textarea>
</u-form-item> </u-form-item>
<!-- 管控责任人 --> <!-- 管控责任人 -->
<u-form-item label="管控责任人" prop="controlResponsiblePerson" ref="item3"> <u-form-item
label="管控责任人"
prop="controlResponsiblePerson"
ref="item3"
>
<u--input <u--input
v-model="formList.controlResponsiblePerson" v-model="formList.controlResponsiblePerson"
placeholder="请输入" placeholder="请输入"
@ -147,7 +150,6 @@
<!-- 下拉选择 --> <!-- 下拉选择 -->
<!-- mode="top" --> <!-- mode="top" -->
<view v-if="isName"> <view v-if="isName">
<u-popup <u-popup
@ -244,7 +246,6 @@
@select="controlledSelect" @select="controlledSelect"
> >
</u-action-sheet> </u-action-sheet>
</u-action-sheet>
</view> </view>
</view> </view>
</view> </view>
@ -276,16 +277,14 @@ export default {
projectName: '', // projectName: '', //
projectType: '', // projectType: '', //
severity: '', // 1 2 3 4 severity: '', // 1 2 3 4
isControlled:'' ,// 0 1 isControlled: '', // 0 1
incidentDescription:'', incidentDescription: '',
controlResponsiblePerson:"", // controlResponsiblePerson: '', //
responsiblePersonPhone:'', // responsiblePersonPhone: '', //
remark:"" remark: ''
}, },
fileIds: [], isControlled: false,
isControlled:false,
isseverity: false, // isseverity: false, //
showSex: false, showSex: false,
isRelease: false, isRelease: false,
@ -293,20 +292,16 @@ export default {
severityList: [ severityList: [
{ {
name: '一般险情', name: '一般险情'
}, },
{ {
name: '较大险情', name: '较大险情'
}, },
{ {
name: '重大险情', name: '重大险情'
}, },
{ {
name: '特别重大险情', name: '特别重大险情'
} }
], ],
@ -328,7 +323,8 @@ export default {
} }
] ]
}, },
projectType: 1 projectType: 1,
fileId: []
} }
}, },
onLoad (options) { onLoad (options) {
@ -338,13 +334,9 @@ export default {
this.getresList() this.getresList()
}, },
onReady () { onReady () {
console.log('搜索框22key', this.key ) console.log('搜索框22key', this.key)
// setRules // setRules
if (this.key == 1) { this.$refs.form2.setRules(this.rules)
this.$refs.form1.setRules(this.rules)
} else if(this.key == 1) {
this.$refs.form2.setRules(this.rules)
}
}, },
methods: { methods: {
async getresList () { async getresList () {
@ -397,8 +389,6 @@ export default {
item.isShow = true item.isShow = true
this.gclabel = item.resName this.gclabel = item.resName
this.formList.projectName = item.resName this.formList.projectName = item.resName
this.$refs.form1.validateField('isPowerGeneration')
} else { } else {
item.isShow = false item.isShow = false
} }
@ -435,6 +425,7 @@ export default {
}) })
for (let i = 0; i < lists.length; i++) { for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url) const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen] let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice( this[`fileList${event.name}`].splice(
fileListLen, fileListLen,
@ -447,31 +438,23 @@ export default {
) )
fileListLen++ fileListLen++
} }
console.log('fileList1111', this.fileList1)
}, },
uploadFilePromise (url) { uploadFilePromise (url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let a = uni.uploadFile({ let a = uni.uploadFile({
url: uni.$http.baseUrl + '/xfProjectRun/file/upload/singleSimple', // url: `${uni.$http.baseUrl}/gunshiApp/xfflood/xfProjectIncident/file/upload/singleSimple`,
filePath: url, filePath: url,
name: 'file', name: 'file',
formData: {
user: 'test'
},
success: res => { success: res => {
setTimeout(() => { setTimeout(() => {
resolve(res.data.data) resolve(res.data)
}, 1000) }, 1000)
} }
}) })
}) })
}, },
afterRead (event) {
this.fileList1.push({
url: event.file,
status: 'uploading',
message: '上传中'
})
},
open () {}, open () {},
groupChange (n) { groupChange (n) {
@ -484,45 +467,44 @@ export default {
uni.navigateBack() uni.navigateBack()
}, },
severitySelect (e) { severitySelect (e) {
console.log('severitySelect0', e) console.log('severitySelect0', e)
this.formList.severity = e.name this.formList.severity = e.name
this.$refs.form2.validateField('severity') this.$refs.form2.validateField('severity')
}, },
controlledSelect (e){ controlledSelect (e) {
this.formList.isControlled = e.name this.formList.isControlled = e.name
this.$refs.form2.validateField('isControlled') this.$refs.form2.validateField('isControlled')
}, },
submit () { submit () {
if(key ==2){ this.$refs.form2
this.$refs.form2
.validate() .validate()
.then(res => { .then(res => {
uni.$u.toast('校验通过', res) uni.$u.toast('校验通过', res)
let params = Object.assign(this.formList) let params = Object.assign(this.formList)
if (this.fileId !== '') {
params = Object.assign(this.formList, this.fileId)
}
// 1 2 3 4
let type ={
'一般险情':1,
'较大险情':2,
'重大险情':3,
'特别重大险情':4,
}
params.severity = this.formLis.severity[type]
params.projectType = this.params.projectType
params.isControlled = params.isControlled == '是' ? 1 : 0
// 1 2 3 4
if (this.formList.severity == '一般险情') {
params.severity = 1
} else if (this.formList.severity == '较大险情') {
params.severity = 2
} else if (this.formList.severity == '重大险情') {
params.severity = 3
} else if (this.formList.severity == '特别重大险情') {
params.severity = 4
}
params.projectType = this.projectType
params.isControlled = params.isControlled == '是' ? 1 : 0
if (this.fileList1.length > 0) {
params.fileId = this.fileList1.map(item => {
return JSON.parse(item.url).data.fileId
})
}
uni.$http uni.$http
.post('/gunshiApp/xfProjectIncident/insert', params) .post('/gunshiApp/xfflood/xfProjectIncident/insert', params)
.then(res => { .then(res => {
console.log('this.---', res) console.log('this.---', res)
if (res.data.code == 200) { if (res.data.code == 200) {
@ -534,54 +516,11 @@ export default {
}) })
}) })
.catch(errors => { .catch(errors => {
uni.$u.toast('校验失败', res) uni.$u.toast('校验失败', errors)
}) })
}else if(key ==3){
this.$refs.form3
.validate()
.then(res => {
uni.$u.toast('校验通过', res)
console.log('this.==', this.formList)
let params = Object.assign(this.formList)
if (this.fileId !== '') {
params = Object.assign(this.formList, this.fileId)
}
// 1 2 3 4
let type ={
'一般险情':1,
'较大险情':2,
'重大险情':3,
'特别重大险情':4,
}
params.severity = this.formLis.severity[type]
params.projectType = this.params.projectType
params.isControlled = params.isControlled == '是' ? 1 : 0
uni.$http
.post('/gunshiApp/xfProjectIncident/insert', params)
.then(res => {
console.log('this---', res)
if (res.data.code == 200) {
console.log('this.model122', res.data)
uni.reLaunch({
url: '/pages/xxsb/index'
})
}
})
})
.catch(errors => {
uni.$u.toast('校验失败', res)
})
}else{
}
// catchthentrue
}, },
reset () { reset () {
const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1'] const validateList = ['projectName', 'radiovalue1']
this.$refs.form1.resetFields() this.$refs.form1.resetFields()
this.$refs.form1.clearValidate() this.$refs.form1.clearValidate()
setTimeout(() => { setTimeout(() => {