123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <template>
- <view class="wrap">
- <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
- <uni-forms-item label="问题描述" name="remark">
- <uni-easyinput v-model="formData.snapshotContent" type="textarea" :maxlength="-1" autoHeight placeholder="备注" />
- </uni-forms-item>
- <!-- <uni-forms-item label="处理人员" name="accountId" required >
- <uni-data-select v-model="formData.accountId" :localdata="userList"></uni-data-select>
- </uni-forms-item> -->
- <uni-file-picker v-model="formData.attachList"
- fileMediatype="image"
- title="附件"
- limit="1"
- @select="uploadSuccess"
- @delete="deleteFile"></uni-file-picker>
- </uni-forms>
- <button type="primary" @click="onSubmit" class="submit-BT">提交</button>
- </view>
- </template>
- <script>
- import {upload} from '@/api/system/upload.js'
- import {getUserList} from '@/api/system/user.js'
- import { createSnapshot } from '@/api/aqpt/snapshotApi'
- export default {
- data() {
- return {
- formData:{
- snapshotContent:"",
- attachList:[]
- },
- userList:[],
- rules:{},
- snapshot:{}
- }
- },
- onLoad() {
- this.init()
- },
- methods: {
- init(){
- this.getUserList()
- },
- async onSubmit() {
- let attachList=[]
- for(let i=0;i<this.formData.attachList.length;i++){
- let filePath=this.formData.attachList[i].url
- let fileresq=await upload({filePath})
- fileresq=JSON.parse(fileresq)
- attachList.push(fileresq.data)
- }
- let qrcode=uni.getStorageSync('qrcode')
- let qrcode_target={
- targetId:qrcode.targetId,
- targetType:qrcode.targetType,
- targetTitle:qrcode.targetTitle,
- targetGroupId:qrcode.groupId,
- targetGroupName:qrcode.groupName,
- }
- // let flow=this.userList.filter(item=>this.formData.accountId===item.accountId)[0]
- // this.handleSelectUser(flow)
- await createSnapshot({
- ...this.formData,
- ...qrcode_target,
- attachList:attachList
- }).then(()=>{
- uni.showToast({
- icon:'none',
- title:"提交成功!",
- complete() {
- uni.$emit('type',5)
- uni.switchTab({
- url:'/pages/history/history?type=snapshot'
- })
- }
- })
- })
- .catch(()=>{
- uni.showToast({
- icon:'none',
- title:"提交失败!"
- })
- })
- },
- uploadSuccess(e){
- let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
- attachList.push(e.tempFiles[0])
- this.formData.attachList=attachList
- },
- deleteFile(e){
- let attachList=JSON.parse(JSON.stringify(this.formData.attachList))
- attachList.filter(item=>item.uuid!==e.tempFile.uuid)
- this.formData.attachList=attachList
- },
- handleSelectUser(item) {
- this.formData.handleAccountId = item.accountId
- this.formData.handleAccountName = item.accountName
- this.formData.handlePositionId = item.positionId
- this.formData.handlePositionName = item.positionName
- this.formData.handleGroupId = item.groupId
- this.formData.handleGroupName = item.groupName
- },
- getUserList(){
- getUserList().then((res)=>{
- var userList=[]
- for (var i = 0; i < res.data.length; i++) {
- userList.push({
- value: -i,
- text: res.data[i].name,
- disable:true
- })
- for(let j = 0; j < res.data[i].children.length; j++){
- userList.push({
- ...res.data[i].children[j],
- value: res.data[i].children[j].accountId,
- text: res.data[i].children[j].accountName
- })
- }
- }
- this.userList=userList
- })
- }
- },
- onUnload() {
- uni.removeStorageSync('hazard')
- }
- }
- </script>
- <style lang="scss" scoped>
- .wrap{
- padding: 32rpx;
- padding-bottom: 200rpx;
- .submit-BT {
- width: 750rpx;
- height:156rpx;
- line-height:88rpx;
- color: #4D73FF;
- text-align: center;
- font-size: 32rpx;
- padding-bottom: 68rpx;
- background-color: #fff;
- position: fixed;
- left: 0;
- bottom: 0;
- z-index: 99;
- box-shadow: 0px 0px 12px 0px #0000000A;
- border-radius: 8px 8px 0px 0px
- }
- }
- </style>
|