页面搭建
parent
5dba23280d
commit
1c65d9c8a3
|
|
@ -56,7 +56,7 @@ export default {
|
|||
|
||||
if (uni.getStorageSync('loginChecked')===true){
|
||||
this.formData = {
|
||||
username: uni.getStorageSync('loginName'),
|
||||
username: uni.getStorageSync('username'),
|
||||
password: uni.getStorageSync('password'),
|
||||
checked: true,
|
||||
}
|
||||
|
|
@ -100,12 +100,12 @@ export default {
|
|||
//记住密码功能
|
||||
if (formData.checked === true) {
|
||||
uni.setStorageSync('loginChecked', true)
|
||||
uni.setStorageSync('loginName', postForm.loginName)
|
||||
uni.setStorageSync('username', postForm.username)
|
||||
uni.setStorageSync('password',formData.password)
|
||||
uni.setStorageSync('secretKey', postForm.secretKey)
|
||||
} else {
|
||||
uni.setStorageSync('loginChecked', false)
|
||||
uni.removeStorageSync('loginName')
|
||||
uni.removeStorageSync('username')
|
||||
uni.removeStorageSync('secretKey')
|
||||
uni.removeStorageSync('password')
|
||||
this.formData.username = ''
|
||||
|
|
|
|||
|
|
@ -0,0 +1,338 @@
|
|||
<template>
|
||||
<view class="contentItem">
|
||||
<uni-collapse >
|
||||
|
||||
<uni-collapse-item
|
||||
title-border="none"
|
||||
v-for="(item,index) in listData"
|
||||
:key="index"
|
||||
:border="false"
|
||||
:show-animation="true"
|
||||
>
|
||||
<template v-slot:title >
|
||||
<view style="display: flex;align-items: center;">
|
||||
<text class="yuandian"></text>
|
||||
<text>{{item.name}}</text>
|
||||
<text style="margin-left: auto; color:#ff0000">{{getIsItem(item.children)}}项未填写</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="xj-content">
|
||||
<view class="xj-text" v-for="(o,i) in item.children" :key="i">
|
||||
<text>{{o.itemDesc}}</text>
|
||||
<view class="subsectioin">
|
||||
<u--form labelPosition="left" :model="o" ref="uForm">
|
||||
<u-form-item label="状态" prop="isNormal" borderBottom
|
||||
required>
|
||||
<u-subsection
|
||||
:list="list"
|
||||
:current="getNormal(o.isNormal)"
|
||||
mode="subsection"
|
||||
@change="(e)=>change(e,o,index,i,'isNormal')"
|
||||
style="width:200px;margin-left: 10px"
|
||||
></u-subsection>
|
||||
</u-form-item>
|
||||
<view class="" v-if="o.isNormal">
|
||||
<u-form-item label="现场图片" prop="inspectPics" borderBottom
|
||||
required>
|
||||
<u-upload accept="image" :fileList="o.inspectPics" @afterRead="(e)=>afterRead(e,o,index,i)" @delete="(e)=>deletePic(e,o,index,i)" name="inspectPics" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
</u-form-item>
|
||||
<u-form-item label="现场视频" prop="inspectVideos" borderBottom
|
||||
>
|
||||
<u-upload accept="video" :fileList="o.inspectVideos" @afterRead="(e)=>afterRead(e,o,index,i)" @delete="(e)=>deletePic(e,o,index,i)" name="inspectVideos" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
</u-form-item>
|
||||
<u-form-item label="问题描述" prop="itemProblemDesc" borderBottom
|
||||
required>
|
||||
<u--textarea v-model="o.itemProblemDesc" placeholder="请输入内容"></u--textarea>
|
||||
</u-form-item>
|
||||
<u-form-item label="处理状态" prop="isHandle" borderBottom
|
||||
required>
|
||||
<u-subsection
|
||||
:list="listStatus"
|
||||
:current="getHandle(o.isHandle)"
|
||||
mode="subsection"
|
||||
@change="(e)=>change(e,o,index,i,'isHandle')"
|
||||
style="width:200px;margin-left: 10px"
|
||||
></u-subsection>
|
||||
</u-form-item>
|
||||
<view class="" v-if="o.isHandle !== 1">
|
||||
<u-form-item label="现场图片" prop="handlePics" borderBottom
|
||||
required>
|
||||
<u-upload accept="image" :fileList="o.handlePics" @afterRead="(e)=>afterRead(e,o,index,i)" @delete="(e)=>deletePic(e,o,index,i)" name="handlePics" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
</u-form-item>
|
||||
<u-form-item label="现场视频" prop="handleVideos" borderBottom
|
||||
>
|
||||
<u-upload accept="video" :fileList="o.handleVideos" @afterRead="(e)=>afterRead(e,o,index,i)" @delete="(e)=>deletePic(e,o,index,i)" name="handleVideos" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
</u-form-item>
|
||||
<u-form-item label="问题描述" prop="handleDesc" borderBottom
|
||||
required>
|
||||
<u--textarea v-model="o.handleDesc" placeholder="请输入内容"></u--textarea>
|
||||
</u-form-item>
|
||||
</view>
|
||||
<view class="" v-if="o.isHandle == 1">
|
||||
<u-form-item label="责任人" prop="handleUserId" borderBottom @click="showSex = true; hideKeyboard()" required
|
||||
>
|
||||
<u--input v-model="o.handleUserId" disabled disabledColor="#ffffff" placeholder="请选择性别"
|
||||
border="none"></u--input>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</u-form-item>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</u--form>
|
||||
<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" description="如果选择保密会报错"
|
||||
@close="showSex = false" @select="sexSelect">
|
||||
</u-action-sheet>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-collapse-item >
|
||||
|
||||
</uni-collapse>
|
||||
<u-button type="primary" text="结束巡检" customStyle="margin-top: 50px" @click="submit"></u-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default{
|
||||
props:{
|
||||
xjItem:Array
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
list:["正常","异常"],
|
||||
listStatus:["已处理","未处理"],
|
||||
current:0,
|
||||
listData:[],
|
||||
showSex:false,
|
||||
actions: [{
|
||||
name: '男',
|
||||
},
|
||||
{
|
||||
name: '女',
|
||||
},
|
||||
{
|
||||
name: '保密',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// this.listData = this.xjItem
|
||||
},
|
||||
watch:{
|
||||
xjItem:function(n,o){
|
||||
|
||||
this.listData = n.map(item=>{
|
||||
item.childen=item.children.map(i=>{
|
||||
if(!i.handlePics){
|
||||
i.handlePics=[]
|
||||
}
|
||||
if(!i.handleVideos){
|
||||
i.handleVideos=[]
|
||||
}
|
||||
if(!i.inspectPics){
|
||||
i.inspectPics=[]
|
||||
}
|
||||
if(!i.inspectVideos){
|
||||
i.inspectVideos=[]
|
||||
}
|
||||
return i
|
||||
})
|
||||
return item
|
||||
})
|
||||
console.log(n,this.listData,'this.listData ');
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
getIsItem(arr){
|
||||
return arr.filter(item1=> item1.isNormal!==1 && item1.isNormal!==0).length
|
||||
},
|
||||
getNormal(isNormal){
|
||||
if(isNormal == 0){
|
||||
return 0
|
||||
}
|
||||
if(isNormal == 1){
|
||||
return 1
|
||||
}
|
||||
if(isNormal == null){
|
||||
return 3
|
||||
}
|
||||
},
|
||||
getHandle(isHandle){
|
||||
if(isHandle == 0){
|
||||
return 0
|
||||
}
|
||||
if(isHandle == 1){
|
||||
return 1
|
||||
}
|
||||
if(isHandle == null){
|
||||
return 3
|
||||
}
|
||||
},
|
||||
async uploadContent(){
|
||||
|
||||
try {
|
||||
let params={
|
||||
status:2,
|
||||
list:[]
|
||||
}
|
||||
this.listData.map(i=>{
|
||||
params.list.push(i.children)
|
||||
})
|
||||
const {data} = await uni.$http.post(`/gunshiApp/xyt/inspect/task/finish`,params)
|
||||
if(data.code == 200){
|
||||
this.xjItem = data.data
|
||||
}
|
||||
} catch (error) {
|
||||
uni.$showMsg();
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
let tigger =true
|
||||
//判断是否符合提交条件
|
||||
this.listData.forEach(item=>{
|
||||
item.ab = item.children.filter(i=>{
|
||||
if(i.isNormal ==1){
|
||||
if(i.inspectPics?.length && i.itemProblemDesc){
|
||||
tigger=true
|
||||
}else{
|
||||
tigger=false
|
||||
}
|
||||
if(i.isHandle ==0){
|
||||
if(i.handlePics?.length && i.handleDesc){
|
||||
tigger=true
|
||||
}else{
|
||||
tigger=false
|
||||
}
|
||||
}else if(i.isHandle ==1){
|
||||
tigger=true
|
||||
}
|
||||
}else if(i.isNormal == 0){
|
||||
tigger=true
|
||||
}
|
||||
})
|
||||
return item
|
||||
})
|
||||
console.log(tigger,'arr');
|
||||
if(tigger){
|
||||
this.uploadContent()
|
||||
}
|
||||
//
|
||||
// if()
|
||||
},
|
||||
// 删除图片
|
||||
deletePic(event,o,index,index1) {
|
||||
this.listData[index].children[index1][event.name].splice(event.index, 1)
|
||||
},
|
||||
// 新增图片
|
||||
async afterRead(event,o,index,index1) {
|
||||
console.log(event,index1,this.listData[index]);
|
||||
// let file
|
||||
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
||||
let lists = [].concat(event.file)
|
||||
let fileListLen = this.listData[index].children[index1][event.name]?.length
|
||||
lists.map((item) => {
|
||||
this.listData[index].children[index1][event.name].push({
|
||||
...item,
|
||||
status: 'uploading',
|
||||
message: '上传中'
|
||||
})
|
||||
})
|
||||
for (let i = 0; i < lists.length; i++) {
|
||||
const result = await this.uploadFilePromise(lists[i].url,event.name,index,index1)
|
||||
console.log(result);
|
||||
let item = this.listData[index].children[index1][event.name][fileListLen]
|
||||
this.listData[index].children[index1][event.name].splice(fileListLen, 1, Object.assign(item, {
|
||||
status: 'success',
|
||||
message: '',
|
||||
...result
|
||||
}))
|
||||
fileListLen++
|
||||
}
|
||||
},
|
||||
uploadFilePromise(url,name,index,index1) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let a = uni.uploadFile({
|
||||
url: 'http://local.gunshiiot.com:18083/gunshiApp/xyt/maintain/service/file/upload/singleSimple', // 仅为示例,非真实的接口地址
|
||||
filePath: url,
|
||||
name: 'file',
|
||||
formData: {
|
||||
user: 'test'
|
||||
},
|
||||
success: (res) => {
|
||||
setTimeout(() => {
|
||||
// this.listData[index].children[index1][name].push({...res.data.data,url:res.data.data.filePath})
|
||||
console.log(res.data)
|
||||
resolve(JSON.parse(res.data).data)
|
||||
}, 1000)
|
||||
}
|
||||
});
|
||||
// resolve(a)
|
||||
})
|
||||
},
|
||||
change(e,o,index,i,key){
|
||||
|
||||
this.listData[index].children[i][key] = e;
|
||||
this.$forceUpdate()
|
||||
},
|
||||
sexSelect(e) {
|
||||
// this.model1.userInfo.sex = e.name
|
||||
// this.$refs.uForm.validateField('userInfo.sex')
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.contentItem{
|
||||
height: 260px;
|
||||
overflow: auto;
|
||||
.itemC{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
display: flex;
|
||||
color: #666666;
|
||||
padding: 10px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
.itemNo{
|
||||
color: #666666;
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
.circle-btn{
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background-color: #007aff;
|
||||
border-radius: 50%;
|
||||
color:#fff;
|
||||
text-align: center;
|
||||
line-height: 120px;
|
||||
}
|
||||
.yuandian{
|
||||
display: inline-block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background-color: #409eff;
|
||||
border-radius: 50%;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.xj-content{
|
||||
height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.xj-text{
|
||||
margin-left: 10%;
|
||||
margin-top: 2%;
|
||||
}
|
||||
.subsectioin{
|
||||
display: flex;
|
||||
column-gap: 10px;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
<template>
|
||||
<view>
|
||||
<!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
|
||||
<u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm">
|
||||
<u-form-item label="姓名" prop="userInfo.name" borderBottom ref="item1">
|
||||
<u--input v-model="model1.userInfo.name" border="none"></u--input>
|
||||
</u-form-item>
|
||||
<u-form-item label="性别" prop="userInfo.sex" borderBottom @click="showSex = true; hideKeyboard()"
|
||||
ref="item1">
|
||||
<u--input v-model="model1.userInfo.sex" disabled disabledColor="#ffffff" placeholder="请选择性别"
|
||||
border="none"></u--input>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</u-form-item>
|
||||
<u-form-item label="内容" prop="userInfo.sex" borderBottom @click="showSex = true; hideKeyboard()"
|
||||
ref="item1">
|
||||
<u--textarea v-model="model1.userInfo.namevalue1" placeholder="请输入内容"></u--textarea>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</u-form-item>
|
||||
<u-form-item label="内容" prop="userInfo.sex" borderBottom @click="showSex = true; hideKeyboard()"
|
||||
ref="item1">
|
||||
<u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</u-form-item>
|
||||
<u-form-item label="内容" prop="userInfo.sex" borderBottom @click="showSex = true; hideKeyboard()"
|
||||
ref="item1">
|
||||
<u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
|
||||
:maxCount="10"></u-upload>
|
||||
<u-icon slot="right" name="arrow-right"></u-icon>
|
||||
</u-form-item>
|
||||
</u--form>
|
||||
<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" description="如果选择保密会报错"
|
||||
@close="showSex = false" @select="sexSelect">
|
||||
</u-action-sheet>
|
||||
<button @click="submit">11</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showSex: false,
|
||||
model1: {
|
||||
userInfo: {
|
||||
name: 'uView UI',
|
||||
sex: '',
|
||||
},
|
||||
},
|
||||
actions: [{
|
||||
name: '男',
|
||||
},
|
||||
{
|
||||
name: '女',
|
||||
},
|
||||
{
|
||||
name: '保密',
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
'userInfo.name': {
|
||||
type: 'string',
|
||||
required: true,
|
||||
message: '请填写姓名',
|
||||
trigger: ['blur', 'change']
|
||||
},
|
||||
'userInfo.sex': {
|
||||
type: 'string',
|
||||
max: 1,
|
||||
required: true,
|
||||
message: '请选择男或女',
|
||||
trigger: ['blur', 'change']
|
||||
},
|
||||
},
|
||||
radio: '',
|
||||
switchVal: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 删除图片
|
||||
deletePic(event) {
|
||||
this[`fileList${event.name}`].splice(event.index, 1)
|
||||
},
|
||||
// 新增图片
|
||||
async afterRead(event) {
|
||||
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
||||
let lists = [].concat(event.file)
|
||||
let fileListLen = this[`fileList${event.name}`].length
|
||||
lists.map((item) => {
|
||||
this[`fileList${event.name}`].push({
|
||||
...item,
|
||||
status: 'uploading',
|
||||
message: '上传中'
|
||||
})
|
||||
})
|
||||
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, 1, Object.assign(item, {
|
||||
status: 'success',
|
||||
message: '',
|
||||
url: result
|
||||
}))
|
||||
fileListLen++
|
||||
}
|
||||
},
|
||||
uploadFilePromise(url,name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let a = uni.uploadFile({
|
||||
url: 'http://local.gunshiiot.com:18083/gunshiApp/xyt/maintain/service/file/upload/singleSimple', // 仅为示例,非真实的接口地址
|
||||
filePath: url,
|
||||
name: 'file',
|
||||
formData: {
|
||||
user: 'test'
|
||||
},
|
||||
success: (res) => {
|
||||
setTimeout(() => {
|
||||
// const obj = this.model1[name].find(item=>item.fileId==res.data.data.fileId)
|
||||
// if(obj){
|
||||
|
||||
// }
|
||||
console.log(JSON.parse(res.data),this.model1,name);
|
||||
this.model1[name].push({fileId:JSON.parse(res.data).data.fileId})
|
||||
resolve(res.data.data)
|
||||
}, 1000)
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
sexSelect(e) {
|
||||
this.model1.userInfo.sex = e.name
|
||||
this.$refs.uForm.validateField('userInfo.sex')
|
||||
},
|
||||
submit() {
|
||||
this.$refs.uForm.validate().then(res => {
|
||||
uni.$u.toast('校验通过')
|
||||
}).catch(errors => {
|
||||
uni.$u.toast('校验失败')
|
||||
})
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
//如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
|
||||
this.$refs.uForm.setRules(this.rules)
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -48,39 +48,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="contentItem">
|
||||
<uni-collapse>
|
||||
|
||||
<uni-collapse-item
|
||||
title-border="none"
|
||||
v-for="(item,index) in xjItem"
|
||||
:key="index"
|
||||
:border="false"
|
||||
:show-animation="true"
|
||||
>
|
||||
<template v-slot:title >
|
||||
<view style="display: flex;align-items: center;">
|
||||
<text class="yuandian"></text>
|
||||
<text>{{item.name}}</text>
|
||||
<text style="margin-left: auto; color:#ff0000">{{item.children.length}}项未填写</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="xj-content">
|
||||
<view class="xj-text" v-for="(o,i) in item.children" :key="i">
|
||||
<text>{{o.itemDesc}}</text>
|
||||
<view class="subsectioin">
|
||||
<text>状态</text>
|
||||
<u-subsection
|
||||
:list="list"
|
||||
:current="current"
|
||||
mode="subsection"
|
||||
style="width:250px;margin-left: 10px"
|
||||
@change="change"
|
||||
></u-subsection>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-collapse-item >
|
||||
</uni-collapse>
|
||||
<db-form :xjItem="xjItem"></db-form>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -89,7 +57,11 @@
|
|||
|
||||
<script>
|
||||
import moment from 'moment'
|
||||
import DbForm from './dbForm.vue'
|
||||
export default {
|
||||
components:{
|
||||
DbForm
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
taskTitle:'',
|
||||
|
|
|
|||
Loading…
Reference in New Issue