|
|
@ -6,44 +6,99 @@ |
|
|
|
<view class="xjTips">请您填写相关问题</view> |
|
|
|
<view class="conItem"> |
|
|
|
<u-form labelPosition="left"> |
|
|
|
|
|
|
|
<u-form-item labelAlign="right" labelWidth="100px" label="乐业社区" prop="sex" borderBottom |
|
|
|
@click="lysqShow = true" required> |
|
|
|
<u--input v-model="form.apartmentName" disabled disabledColor="#ffffff" placeholder="请选择" border="none"></u--input> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="100px" |
|
|
|
label="乐业社区" |
|
|
|
prop="sex" |
|
|
|
borderBottom |
|
|
|
@click="lysqShow = true" |
|
|
|
required |
|
|
|
> |
|
|
|
<u--input |
|
|
|
v-model="form.apartmentName" |
|
|
|
disabled |
|
|
|
disabledColor="#ffffff" |
|
|
|
placeholder="请选择" |
|
|
|
border="none" |
|
|
|
></u--input> |
|
|
|
<u-icon slot="right" name="arrow-right"></u-icon> |
|
|
|
</u-form-item> |
|
|
|
|
|
|
|
<u-form-item labelAlign="right" labelWidth="100px" label="巡检问题类型" borderBottom |
|
|
|
@click="wtlxShow = true" required> |
|
|
|
<u--input v-model="form.questionName" disabled disabledColor="#ffffff" placeholder="请选择" border="none"></u--input> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="100px" |
|
|
|
label="巡检问题类型" |
|
|
|
borderBottom |
|
|
|
@click="wtlxShow = true" |
|
|
|
required |
|
|
|
> |
|
|
|
<u--input |
|
|
|
v-model="form.questionName" |
|
|
|
disabled |
|
|
|
disabledColor="#ffffff" |
|
|
|
placeholder="请选择" |
|
|
|
border="none" |
|
|
|
></u--input> |
|
|
|
<u-icon slot="right" name="arrow-right"></u-icon> |
|
|
|
</u-form-item> |
|
|
|
|
|
|
|
<u-form-item labelAlign="right" labelWidth="100px" label="标题内容" borderBottom required> |
|
|
|
<u--textarea v-model="form.title" placeholder="请输入内容" count maxlength="500"></u--textarea> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="100px" |
|
|
|
label="标题内容" |
|
|
|
borderBottom |
|
|
|
required |
|
|
|
> |
|
|
|
<u--textarea |
|
|
|
v-model="form.title" |
|
|
|
placeholder="请输入内容" |
|
|
|
count |
|
|
|
maxlength="500" |
|
|
|
></u--textarea> |
|
|
|
</u-form-item> |
|
|
|
|
|
|
|
<u-form-item labelAlign="right" labelWidth="100px" label="问题描述" borderBottom required> |
|
|
|
<u--textarea v-model="form.content" placeholder="请输入内容" count maxlength="500"></u--textarea> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="100px" |
|
|
|
label="问题描述" |
|
|
|
borderBottom |
|
|
|
required |
|
|
|
> |
|
|
|
<u--textarea |
|
|
|
v-model="form.content" |
|
|
|
placeholder="请输入内容" |
|
|
|
count |
|
|
|
maxlength="500" |
|
|
|
></u--textarea> |
|
|
|
</u-form-item> |
|
|
|
<u-form-item labelAlign="right" labelWidth="120px" label="上传图片/视频" borderBottom> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="120px" |
|
|
|
label="上传图片/视频" |
|
|
|
borderBottom |
|
|
|
> |
|
|
|
<u-upload |
|
|
|
v-model="fileList" |
|
|
|
:max-count="10" |
|
|
|
:multiple="true" |
|
|
|
:preview-full-image="true" |
|
|
|
:deletable="true" |
|
|
|
:show-upload-list="true" |
|
|
|
:fileList="fileList" |
|
|
|
:auto-upload="false" |
|
|
|
accept="all" |
|
|
|
@afterRead="afterRead" |
|
|
|
:maxSize="10 * 1024 * 1024" |
|
|
|
@oversize="oversize" |
|
|
|
@delete="onDelete" |
|
|
|
:maxSize="10 * 1024 * 1024" |
|
|
|
@oversize="oversize" |
|
|
|
:disabled="true" |
|
|
|
> |
|
|
|
<view class="custom-upload-btn"> |
|
|
|
<view class="custom-upload-btn" @click.stop="chooseImage"> |
|
|
|
<view class="icon-box"> |
|
|
|
<image class="camera-icon" src="/static/img/camera-icon.png" mode="aspectFill"></image> |
|
|
|
<image |
|
|
|
class="camera-icon" |
|
|
|
src="/static/img/camera-icon.png" |
|
|
|
mode="aspectFill" |
|
|
|
></image> |
|
|
|
</view> |
|
|
|
<view class="upload-tips">点击上传</view> |
|
|
|
</view> |
|
|
@ -52,12 +107,24 @@ |
|
|
|
</u-form> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="conItem" style="margin-top: 40rpx;"> |
|
|
|
<view class="conItem" style="margin-top: 40rpx"> |
|
|
|
<u--form labelPosition="left"> |
|
|
|
<u-form-item labelAlign="right" labelWidth="100px" label="巡检人姓名" borderBottom required> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="100px" |
|
|
|
label="巡检人姓名" |
|
|
|
borderBottom |
|
|
|
required |
|
|
|
> |
|
|
|
<u--input v-model="form.inspector" border="none"></u--input> |
|
|
|
</u-form-item> |
|
|
|
<u-form-item labelAlign="right" labelWidth="100px" label="巡检人电话" borderBottom required> |
|
|
|
<u-form-item |
|
|
|
labelAlign="right" |
|
|
|
labelWidth="100px" |
|
|
|
label="巡检人电话" |
|
|
|
borderBottom |
|
|
|
required |
|
|
|
> |
|
|
|
<u--input v-model="form.inspectorPhone" border="none"></u--input> |
|
|
|
</u-form-item> |
|
|
|
</u--form> |
|
|
@ -65,117 +132,130 @@ |
|
|
|
|
|
|
|
<view class="btn" @click="handleBtn">提交</view> |
|
|
|
|
|
|
|
<u-action-sheet :show="lysqShow" :actions="apartmentList" title="请选择乐业社区" @close="lysqShow = false" @select="handleTreeSelect"> |
|
|
|
<u-action-sheet |
|
|
|
:show="lysqShow" |
|
|
|
:actions="apartmentList" |
|
|
|
title="请选择乐业社区" |
|
|
|
@close="lysqShow = false" |
|
|
|
@select="handleTreeSelect" |
|
|
|
> |
|
|
|
</u-action-sheet> |
|
|
|
<u-action-sheet :show="wtlxShow" :actions="questionTypeList" title="请选择问题类型" @close="wtlxShow = false" @select="handleQuestionSelect"> |
|
|
|
<u-action-sheet |
|
|
|
:show="wtlxShow" |
|
|
|
:actions="questionTypeList" |
|
|
|
title="请选择问题类型" |
|
|
|
@close="wtlxShow = false" |
|
|
|
@select="handleQuestionSelect" |
|
|
|
> |
|
|
|
</u-action-sheet> |
|
|
|
</scroll-view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { |
|
|
|
queryDeptDropdownList, |
|
|
|
} from "@/common/rec"; |
|
|
|
import { getdeptList,addInspection } from '@/common/api'; |
|
|
|
import { uploadImage } from '@/pages/api.js'; |
|
|
|
import { queryDeptDropdownList } from "@/common/rec"; |
|
|
|
import { getdeptList, addInspection } from "@/common/api"; |
|
|
|
import { uploadImage } from "@/pages/api"; |
|
|
|
import { getDicts } from "@/common/system/dict/data"; |
|
|
|
|
|
|
|
export default { |
|
|
|
data () { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
wtlxShow: false, |
|
|
|
lysqShow: false, |
|
|
|
deptOptions: [], |
|
|
|
questionTypeList: [], |
|
|
|
form: { |
|
|
|
apartmentId: '', |
|
|
|
apartmentName:'', |
|
|
|
questionType: '', |
|
|
|
questionName: '', |
|
|
|
title: '', |
|
|
|
content: '', |
|
|
|
inspector: '', |
|
|
|
inspectorPhone: '', |
|
|
|
inspectionTime: '', |
|
|
|
imageList: [] |
|
|
|
apartmentId: "", |
|
|
|
apartmentName: "", |
|
|
|
questionType: "", |
|
|
|
questionName: "", |
|
|
|
title: "", |
|
|
|
content: "", |
|
|
|
inspector: "", |
|
|
|
inspectorPhone: "", |
|
|
|
inspectionTime: "", |
|
|
|
imageList: [], |
|
|
|
}, |
|
|
|
rules:{ |
|
|
|
sex:[ |
|
|
|
{ required: true, message: '请输入', trigger: 'blur' } |
|
|
|
] |
|
|
|
rules: { |
|
|
|
sex: [{ required: true, message: "请输入", trigger: "blur" }], |
|
|
|
}, |
|
|
|
radio: '', |
|
|
|
radio: "", |
|
|
|
switchVal: false, |
|
|
|
fileList: [], |
|
|
|
apartmentList:[] |
|
|
|
} |
|
|
|
apartmentList: [], |
|
|
|
}; |
|
|
|
}, |
|
|
|
onLoad () { |
|
|
|
this.getTree() |
|
|
|
this.getDictType() |
|
|
|
onLoad() { |
|
|
|
this.getTree(); |
|
|
|
this.getDictType(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async afterRead(event) { |
|
|
|
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 uploadImage(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.url, |
|
|
|
}) |
|
|
|
); |
|
|
|
fileListLen++; |
|
|
|
} |
|
|
|
var arry = []; |
|
|
|
this.fileList.filter((v, i) => { |
|
|
|
arry.push({ |
|
|
|
name: v.name || '', |
|
|
|
format: v.type, |
|
|
|
url:v.url |
|
|
|
}); |
|
|
|
chooseImage() { |
|
|
|
uni.chooseImage({ |
|
|
|
count: 10 - this.fileList.length, |
|
|
|
sizeType: ["original", "compressed"], |
|
|
|
sourceType: ["album", "camera"], |
|
|
|
success: async (res) => { |
|
|
|
uni.showLoading({ title: "上传中...", mask: true }); |
|
|
|
try { |
|
|
|
// 兼容微信小程序和H5 |
|
|
|
const files = |
|
|
|
res.tempFiles || res.tempFilePaths.map((path) => ({ path })); |
|
|
|
for (let i = 0; i < files.length; i++) { |
|
|
|
const filePath = files[i].path; |
|
|
|
// 走上传接口 |
|
|
|
const uploadRes = await uploadImage(filePath); |
|
|
|
// 兼容后端返回结构 |
|
|
|
this.fileList.push({ |
|
|
|
url: uploadRes.data?.url || uploadRes.url || uploadRes.path, // 兼容不同后端字段 |
|
|
|
name: uploadRes.data?.name || uploadRes.name || "", |
|
|
|
type: uploadRes.data?.type || uploadRes.type || "image", |
|
|
|
status: "success", |
|
|
|
}); |
|
|
|
} |
|
|
|
// 更新 form.imageList |
|
|
|
this.form.imageList = this.fileList.map((v) => ({ |
|
|
|
name: v.name || "", |
|
|
|
format: v.type, |
|
|
|
url: v.url, |
|
|
|
})); |
|
|
|
} catch (e) { |
|
|
|
uni.showToast({ title: "上传失败", icon: "none" }); |
|
|
|
} finally { |
|
|
|
uni.hideLoading(); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: () => { |
|
|
|
uni.hideLoading(); |
|
|
|
}, |
|
|
|
}); |
|
|
|
this.form.imageList = arry |
|
|
|
}, |
|
|
|
//图片超过大小时取消上传 |
|
|
|
oversize(e) { |
|
|
|
this.$u.toast("请传10MB以内大小的图片/视频!"); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
onDelete(event) { |
|
|
|
this[`fileList${event.name}`].splice(event.index, 1); |
|
|
|
var arry = []; |
|
|
|
this.fileList.filter((v, i) => { |
|
|
|
arry.push({ |
|
|
|
name: v.name || '', |
|
|
|
name: v.name || "", |
|
|
|
format: v.type, |
|
|
|
url:v.url |
|
|
|
url: v.url, |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.form.imageList = arry |
|
|
|
}, |
|
|
|
//图片超过大小时取消上传 |
|
|
|
oversize(e) { |
|
|
|
this.$u.toast("请传10MB以内大小的图片/视频!"); |
|
|
|
return false; |
|
|
|
this.form.imageList = arry; |
|
|
|
}, |
|
|
|
getDictType(){ |
|
|
|
getDicts('inspection_question_type').then((res) => { |
|
|
|
this.questionTypeList = res.data.map(item=>{ |
|
|
|
item.name = item.dictLabel |
|
|
|
return item |
|
|
|
}) |
|
|
|
getDictType() { |
|
|
|
getDicts("inspection_question_type").then((res) => { |
|
|
|
this.questionTypeList = res.data.map((item) => { |
|
|
|
item.name = item.dictLabel; |
|
|
|
return item; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
getTree(){ |
|
|
|
getTree() { |
|
|
|
getdeptList().then(async (res) => { |
|
|
|
this.deptOptions = this.handleTree( |
|
|
|
res.data, |
|
|
@ -184,13 +264,13 @@ export default { |
|
|
|
"children", |
|
|
|
2 |
|
|
|
); |
|
|
|
console.log(this.deptOptions,'this.deptOptions'); |
|
|
|
|
|
|
|
const deptInfo = this.deptOptions[0].children[0] |
|
|
|
const newArr = this.deptOptions.map(item => ({ |
|
|
|
console.log(this.deptOptions, "this.deptOptions"); |
|
|
|
|
|
|
|
const deptInfo = this.deptOptions[0].children[0]; |
|
|
|
const newArr = this.deptOptions.map((item) => ({ |
|
|
|
name: item.deptName, |
|
|
|
})) |
|
|
|
this.apartmentList = newArr |
|
|
|
})); |
|
|
|
this.apartmentList = newArr; |
|
|
|
// this.deptOptions = await this.getListByParentId("1", deptInfo.deptId); |
|
|
|
// console.log(this.deptOptions); |
|
|
|
}); |
|
|
@ -203,97 +283,98 @@ export default { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
handleBtn () { |
|
|
|
handleBtn() { |
|
|
|
console.log(this.form); |
|
|
|
if(!this.form.apartmentId){ |
|
|
|
if (!this.form.apartmentId) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '请选择乐业社区' |
|
|
|
}) |
|
|
|
return |
|
|
|
} else if(!this.form.questionType){ |
|
|
|
icon: "none", |
|
|
|
title: "请选择乐业社区", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} else if (!this.form.questionType) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '巡检问题类型' |
|
|
|
}) |
|
|
|
return |
|
|
|
} else if(!this.form.title){ |
|
|
|
icon: "none", |
|
|
|
title: "巡检问题类型", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} else if (!this.form.title) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '请输入标题内容' |
|
|
|
}) |
|
|
|
return |
|
|
|
} else if(!this.form.content){ |
|
|
|
icon: "none", |
|
|
|
title: "请输入标题内容", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} else if (!this.form.content) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '请输入问题描述' |
|
|
|
}) |
|
|
|
return |
|
|
|
} else if(!this.form.inspector){ |
|
|
|
icon: "none", |
|
|
|
title: "请输入问题描述", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} else if (!this.form.inspector) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '请输入巡检人姓名' |
|
|
|
}) |
|
|
|
return |
|
|
|
} else if(!this.form.inspectorPhone){ |
|
|
|
icon: "none", |
|
|
|
title: "请输入巡检人姓名", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} else if (!this.form.inspectorPhone) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'none', |
|
|
|
title: '请输入巡检人电话' |
|
|
|
}) |
|
|
|
return |
|
|
|
icon: "none", |
|
|
|
title: "请输入巡检人电话", |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
// console.log(this.form); |
|
|
|
let parmas = JSON.parse(JSON.stringify(this.form)) |
|
|
|
delete parmas.apartmentName |
|
|
|
delete parmas.questionName |
|
|
|
addInspection(parmas).then(res=>{ |
|
|
|
if(res.code == 200){ |
|
|
|
let parmas = JSON.parse(JSON.stringify(this.form)); |
|
|
|
delete parmas.apartmentName; |
|
|
|
delete parmas.questionName; |
|
|
|
addInspection(parmas).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'success', |
|
|
|
title: '提交成功!', |
|
|
|
success:()=>{ |
|
|
|
this.fileList = [] |
|
|
|
icon: "success", |
|
|
|
title: "提交成功!", |
|
|
|
success: () => { |
|
|
|
this.fileList = []; |
|
|
|
this.form = { |
|
|
|
apartmentId: '', |
|
|
|
apartmentName:'', |
|
|
|
questionType: '', |
|
|
|
questionName: '', |
|
|
|
title: '', |
|
|
|
content: '', |
|
|
|
inspector: '', |
|
|
|
inspectorPhone: '', |
|
|
|
inspectionTime: '', |
|
|
|
imageList: [] |
|
|
|
} |
|
|
|
apartmentId: "", |
|
|
|
apartmentName: "", |
|
|
|
questionType: "", |
|
|
|
questionName: "", |
|
|
|
title: "", |
|
|
|
content: "", |
|
|
|
inspector: "", |
|
|
|
inspectorPhone: "", |
|
|
|
inspectionTime: "", |
|
|
|
imageList: [], |
|
|
|
}; |
|
|
|
setTimeout(() => { |
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/tabBar/work/index' |
|
|
|
}); |
|
|
|
},2000) |
|
|
|
uni.switchTab({ |
|
|
|
url: "/pages/tabBar/work/index", |
|
|
|
}); |
|
|
|
}, 2000); |
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
}else{ |
|
|
|
}); |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: res.msg || "提交失败", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
title: res.msg || "提交失败", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
handleTreeSelect(e) { |
|
|
|
console.log(e); |
|
|
|
console.log(this.deptOptions); |
|
|
|
|
|
|
|
this.form.apartmentName = e.name |
|
|
|
this.form.apartmentId = this.deptOptions.find(item=>item.deptName === e.name).deptId |
|
|
|
|
|
|
|
this.form.apartmentName = e.name; |
|
|
|
this.form.apartmentId = this.deptOptions.find( |
|
|
|
(item) => item.deptName === e.name |
|
|
|
).deptId; |
|
|
|
}, |
|
|
|
handleQuestionSelect(e){ |
|
|
|
this.form.questionName = e.dictLabel |
|
|
|
this.form.questionType = e.dictValue |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
handleQuestionSelect(e) { |
|
|
|
this.form.questionName = e.dictLabel; |
|
|
|
this.form.questionType = e.dictValue; |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
@ -346,7 +427,12 @@ export default { |
|
|
|
height: 70rpx; |
|
|
|
line-height: 70rpx; |
|
|
|
border-radius: 600rpx; |
|
|
|
background: linear-gradient(86.25deg, rgba(13, 198, 198, 1) 3.03%, rgba(19, 194, 194, 1) 3.03%, rgba(70, 219, 213, 1) 96.43%); |
|
|
|
background: linear-gradient( |
|
|
|
86.25deg, |
|
|
|
rgba(13, 198, 198, 1) 3.03%, |
|
|
|
rgba(19, 194, 194, 1) 3.03%, |
|
|
|
rgba(70, 219, 213, 1) 96.43% |
|
|
|
); |
|
|
|
color: rgba(255, 255, 255, 1); |
|
|
|
font-size: 34rpx; |
|
|
|
text-align: center; |
|
|
@ -366,7 +452,7 @@ export default { |
|
|
|
justify-content: center; |
|
|
|
margin: 20rpx 16rpx 0 0; |
|
|
|
} |
|
|
|
.icon-box{ |
|
|
|
.icon-box { |
|
|
|
width: 60rpx; |
|
|
|
height: 60rpx; |
|
|
|
background: #ceeced; |
|
|
@ -375,7 +461,7 @@ export default { |
|
|
|
align-items: center; |
|
|
|
justify-content: center; |
|
|
|
} |
|
|
|
.camera-icon{ |
|
|
|
.camera-icon { |
|
|
|
width: 36rpx; |
|
|
|
height: 36rpx; |
|
|
|
} |
|
|
@ -399,10 +485,9 @@ export default { |
|
|
|
</style> |
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
.xj-page{ |
|
|
|
.u-form-item__body__left__content__required{ |
|
|
|
.xj-page { |
|
|
|
.u-form-item__body__left__content__required { |
|
|
|
font-size: 24rpx !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
</style> |
|
|
|