From 6faebcfcc6ca629ae3d242f9a086a40e0cddf0a7 Mon Sep 17 00:00:00 2001 From: zhanglin Date: Thu, 13 Jun 2024 16:02:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E6=97=B6=E5=B7=A5=E6=83=85?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/xxsb/dsfrom.vue | 144 ++++++++----------------- pages/xxsb/from.vue | 208 ++++++------------------------------ pages/xxsb/fromSeverity.vue | 153 ++++++++------------------ 3 files changed, 124 insertions(+), 381 deletions(-) diff --git a/pages/xxsb/dsfrom.vue b/pages/xxsb/dsfrom.vue index 413c92e..986e078 100644 --- a/pages/xxsb/dsfrom.vue +++ b/pages/xxsb/dsfrom.vue @@ -362,14 +362,6 @@ export default { chcount: '', spcount: '', elose: '', - - projectName: '', //工程名称 - projectType: '', //工程类型 - - isControlled: '', // 是否已管控(0 否 1 是) - incidentDescription: '', - controlResponsiblePerson: '', // 管控责任人 - responsiblePersonPhone: '', //责任人电话 remark: '' }, @@ -404,11 +396,11 @@ export default { } ], rules: { - projectName: [ + otime: [ { type: 'string', required: true, - message: '请选择工程名称', + message: '请选择时间', trigger: ['blur', 'change'] } ] @@ -425,11 +417,7 @@ export default { onReady () { console.log('搜索框22key', this.key) // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则 - if (this.key == 1) { - this.$refs.form1.setRules(this.rules) - } else if (this.key == 1) { - this.$refs.form2.setRules(this.rules) - } + this.$refs.form2.setRules(this.rules) }, methods: { async getresList () { @@ -482,8 +470,6 @@ export default { item.isShow = true this.gclabel = item.resName this.formList.projectName = item.resName - - this.$refs.form1.validateField('isPowerGeneration') } else { item.isShow = false } @@ -536,15 +522,12 @@ export default { uploadFilePromise (url) { return new Promise((resolve, reject) => { let a = uni.uploadFile({ - url: uni.$http.baseUrl + '/xfProjectRun/file/upload/singleSimple', // 仅为示例,非真实的接口地址 + url: `${uni.$http.baseUrl}/gunshiApp/xfflood/iaCHsfwater/file/upload/singleSimple`, filePath: url, name: 'file', - formData: { - user: 'test' - }, success: res => { setTimeout(() => { - resolve(res.data.data) + resolve(res.data) }, 1000) } }) @@ -552,12 +535,7 @@ export default { }, open () {}, - groupChange (n) { - // console.log('groupChange', n); - }, - radioChange (n) { - // console.log('radioChange', n); - }, + navigateBack () { uni.navigateBack() }, @@ -573,83 +551,51 @@ export default { }, submit () { - if (key == 2) { - this.$refs.form2 - .validate() - .then(res => { - uni.$u.toast('校验通过', res) + this.$refs.form2 + .validate() + .then(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.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 + if (this.fileList1.length > 0) { + params.fileId = this.fileList1.map(item => { + return JSON.parse(item.url).data.fileId + }) + } - uni.$http - .post('/gunshiApp/xfflood/iaCHsfwater/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 if (key == 3) { - this.$refs.form3 - .validate() - .then(res => { - uni.$u.toast('校验通过', res) - console.log('this.==', this.formList) + uni.$http + .post('/gunshiApp/xfflood/iaCHsfwater/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('校验失败', errors) + console.log('校验失败') + }) - 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 { - } // 如果有错误,会在catch中返回报错信息数组,校验通过则在then中返回true }, reset () { - const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1'] + const validateList = ['projectName', 'radiovalue1'] this.$refs.form1.resetFields() this.$refs.form1.clearValidate() setTimeout(() => { diff --git a/pages/xxsb/from.vue b/pages/xxsb/from.vue index ef4de06..0d1f8d5 100644 --- a/pages/xxsb/from.vue +++ b/pages/xxsb/from.vue @@ -139,133 +139,6 @@ > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -421,11 +293,10 @@ export default { projectName: '', //工程名称 projectType: '', //工程类型 severity: '', // 严重程度(1一般险情 2较大险情 3重大险情 4特别重大险情) - isControlled:'' ,// 是否已管控(0 否 1 是) - incidentDescription:'', - controlResponsiblePerson:"", // 管控责任人 - responsiblePersonPhone:'' //责任人电话 - + isControlled: '', // 是否已管控(0 否 1 是) + incidentDescription: '', + controlResponsiblePerson: '', // 管控责任人 + responsiblePersonPhone: '' //责任人电话 }, model1: { projectName: '', @@ -437,7 +308,7 @@ export default { remark: '' }, fileIds: [], - isControlled:false, + isControlled: false, isseverity: false, // 严重程度 showSex: false, isRelease: false, @@ -445,20 +316,16 @@ export default { severityList: [ { - name: '一般险情', - + name: '一般险情' }, { - name: '较大险情', - + name: '较大险情' }, { - name: '重大险情', - + name: '重大险情' }, { - name: '特别重大险情', - + name: '特别重大险情' } ], @@ -486,17 +353,13 @@ export default { onLoad (options) { this.key = options.key console.log('搜索框22', options.key) - + this.getresList() }, onReady () { - console.log('搜索框22key', this.key ) + console.log('搜索框22key', this.key) // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则 - if (this.key == 1) { - this.$refs.form1.setRules(this.rules) - } else if(this.key == 1) { - this.$refs.form2.setRules(this.rules) - } + this.$refs.form1.setRules(this.rules) }, methods: { async getresList () { @@ -586,6 +449,8 @@ export default { }) for (let i = 0; i < lists.length; i++) { const result = await this.uploadFilePromise(lists[i].url) + console.log('result', JSON.parse(result)) + let item = this[`fileList${event.name}`][fileListLen] this[`fileList${event.name}`].splice( fileListLen, @@ -602,27 +467,19 @@ export default { uploadFilePromise (url) { return new Promise((resolve, reject) => { let a = uni.uploadFile({ - url: uni.$http.baseUrl + '/xfProjectRun/file/upload/singleSimple', // 仅为示例,非真实的接口地址 + url: `${uni.$http.baseUrl}/gunshiApp/xfflood/xfProjectRun/file/upload/singleSimple`, filePath: url, name: 'file', - formData: { - user: 'test' - }, success: res => { + console.log('res888', JSON.parse(res.data)) setTimeout(() => { - resolve(res.data.data) + resolve(res.data) + this.fileId = JSON.parse(res.data).data.fileId }, 1000) } }) }) }, - afterRead (event) { - this.fileList1.push({ - url: event.file, - status: 'uploading', - message: '上传中' - }) - }, open () {}, groupChange (n) { @@ -650,28 +507,30 @@ export default { this.formList.severity = e.name this.$refs.form2.validateField('severity') }, - controlledSelect (e){ + controlledSelect (e) { this.formList.isControlled = e.name this.$refs.form2.validateField('isControlled') }, - submit () { - if(key ==1){ - this.$refs.form1 + this.$refs.form1 .validate() .then(res => { - uni.$u.toast('校验通过', res) - console.log('this.model1', this.model1) + debugger + console.log('文件', this.fileId) - let params = Object.assign(this.model1) - if (this.fileId !== '') { - params = Object.assign(this.model1, this.fileId) - } - params.projectType = this.params.projectType + let params = this.model1 + + params.projectType = this.projectType params.isPowerGeneration = params.isPowerGeneration == '是' ? 1 : 0 params.isFloodRelease = params.isFloodRelease == '是' ? 1 : 0 + console.log('参数', params) + + if (this.fileId != '') { + params.fileId = [this.fileId] + } + uni.$http .post('/gunshiApp/xfflood/xfProjectRun/insert', params) .then(res => { @@ -685,11 +544,10 @@ export default { }) }) .catch(errors => { - uni.$u.toast('校验失败', res) + uni.$u.toast('校验失败', errors) }) - } + // 如果有错误,会在catch中返回报错信息数组,校验通过则在then中返回true - }, reset () { const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1'] diff --git a/pages/xxsb/fromSeverity.vue b/pages/xxsb/fromSeverity.vue index 3c0eb49..4a4010e 100644 --- a/pages/xxsb/fromSeverity.vue +++ b/pages/xxsb/fromSeverity.vue @@ -16,7 +16,6 @@ :model="formList" ref="form2" labelWidth="100" - v-if="key == 2" > - + - - @@ -276,16 +277,14 @@ export default { projectName: '', //工程名称 projectType: '', //工程类型 severity: '', // 严重程度(1一般险情 2较大险情 3重大险情 4特别重大险情) - isControlled:'' ,// 是否已管控(0 否 1 是) - incidentDescription:'', - controlResponsiblePerson:"", // 管控责任人 - responsiblePersonPhone:'', //责任人电话 - remark:"" - + isControlled: '', // 是否已管控(0 否 1 是) + incidentDescription: '', + controlResponsiblePerson: '', // 管控责任人 + responsiblePersonPhone: '', //责任人电话 + remark: '' }, - fileIds: [], - isControlled:false, + isControlled: false, isseverity: false, // 严重程度 showSex: false, isRelease: false, @@ -293,20 +292,16 @@ export default { severityList: [ { - name: '一般险情', - + name: '一般险情' }, { - name: '较大险情', - + name: '较大险情' }, { - name: '重大险情', - + name: '重大险情' }, { - name: '特别重大险情', - + name: '特别重大险情' } ], @@ -328,23 +323,20 @@ export default { } ] }, - projectType: 1 + projectType: 1, + fileId: [] } }, onLoad (options) { this.key = options.key console.log('搜索框22', options.key) - + this.getresList() }, onReady () { - console.log('搜索框22key', this.key ) + console.log('搜索框22key', this.key) // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则 - if (this.key == 1) { - this.$refs.form1.setRules(this.rules) - } else if(this.key == 1) { - this.$refs.form2.setRules(this.rules) - } + this.$refs.form2.setRules(this.rules) }, methods: { async getresList () { @@ -397,8 +389,6 @@ export default { item.isShow = true this.gclabel = item.resName this.formList.projectName = item.resName - - this.$refs.form1.validateField('isPowerGeneration') } else { item.isShow = false } @@ -435,6 +425,7 @@ export default { }) for (let i = 0; i < lists.length; i++) { const result = await this.uploadFilePromise(lists[i].url) + let item = this[`fileList${event.name}`][fileListLen] this[`fileList${event.name}`].splice( fileListLen, @@ -447,31 +438,23 @@ export default { ) fileListLen++ } + + console.log('fileList1111', this.fileList1) }, uploadFilePromise (url) { return new Promise((resolve, reject) => { let a = uni.uploadFile({ - url: uni.$http.baseUrl + '/xfProjectRun/file/upload/singleSimple', // 仅为示例,非真实的接口地址 + url: `${uni.$http.baseUrl}/gunshiApp/xfflood/xfProjectIncident/file/upload/singleSimple`, filePath: url, name: 'file', - formData: { - user: 'test' - }, success: res => { setTimeout(() => { - resolve(res.data.data) + resolve(res.data) }, 1000) } }) }) }, - afterRead (event) { - this.fileList1.push({ - url: event.file, - status: 'uploading', - message: '上传中' - }) - }, open () {}, groupChange (n) { @@ -484,45 +467,44 @@ export default { uni.navigateBack() }, - - severitySelect (e) { console.log('severitySelect0', e) this.formList.severity = e.name this.$refs.form2.validateField('severity') }, - controlledSelect (e){ + controlledSelect (e) { this.formList.isControlled = e.name this.$refs.form2.validateField('isControlled') }, - submit () { - if(key ==2){ - this.$refs.form2 + this.$refs.form2 .validate() .then(res => { uni.$u.toast('校验通过', res) - - 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, + 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.severity = this.formLis.severity[type] - params.projectType = this.params.projectType + + 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 - .post('/gunshiApp/xfProjectIncident/insert', params) + .post('/gunshiApp/xfflood/xfProjectIncident/insert', params) .then(res => { console.log('this.---', res) if (res.data.code == 200) { @@ -534,54 +516,11 @@ export default { }) }) .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{ - - } - // 如果有错误,会在catch中返回报错信息数组,校验通过则在then中返回true - }, reset () { - const validateList = ['projectName', 'isPowerGeneration', 'radiovalue1'] + const validateList = ['projectName', 'radiovalue1'] this.$refs.form1.resetFields() this.$refs.form1.clearValidate() setTimeout(() => {