123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <template>
- <view class="wrap">
- <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
- <uni-forms-item label="隐患等级" name="checkResult" required>
- <view class="uni-data-checkbox-wrap">
- <uni-data-checkbox v-model="formData.action" :localdata="actions" />
- </view>
- </uni-forms-item>
- <uni-forms-item label="处理结果" name="remark" v-if="formData.action===1">
- <uni-easyinput v-model="formData.handleRemark" type="textarea" :maxlength="-1" autoHeight placeholder="备注" />
- </uni-forms-item>
- <uni-forms-item label="执行人" name="accountId" required v-if="formData.action===2">
- <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 {updateChecklistHazardRecordDoing} from '@/api/aqpt/checklistHazardRecordApi.js'
- import { getSnapshotById, completeSnapshot, transferSnapshot } from '@/api/aqpt/snapshotApi'
- export default {
- data() {
- return {
- actions:[
- {text:"完成处理",value:1},
- {text:"转交",value:2},
- ],
- formData:{
- action:1,
- handleRemark:"",
- attachList:[]
- },
- userList:[],
- rules:{},
- snapshotId:undefined,
- snapshot:{}
- }
- },
- onLoad(options) {
- this.init()
- this.snapshotId=options.snapshotId
- this.formData.snapshotId=options.snapshotId
- },
- methods: {
- init(){
- this.getUserList()
- },
- async onSubmit() {
- let snapshotId=this.snapshotId
- 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 flow=this.userList.filter(item=>this.formData.accountId===item.accountId)[0]
- this.handleSelectUser(flow)
- if(this.formData.action===1){
- await completeSnapshot({...this.formData,attachList})
- .then(()=>{
- uni.showToast({
- icon:'none',
- title:"提交成功!",
- complete() {
- uni.$emit('type',5)
- uni.switchTab({
- url:'/pages/history/history'
- })
- }
- })
- })
- .catch(()=>{
- uni.showToast({
- icon:'none',
- title:"提交失败!"
- })
- })
- }else{
- await transferSnapshot(snapshotId,{...this.formData,attachList})
- .then(()=>{
- uni.showToast({
- icon:'none',
- title:"提交成功!",
- complete() {
- uni.$emit('type',5)
- uni.switchTab({
- url:'/pages/history/history'
- })
- }
- })
- })
- .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(obj) {
- this.formData.accountIdTo = obj.accountId
- this.formData.groupIdTo = obj.groupId
- this.formData.positionIdTo = obj.positionId
- this.formData.accountNameTo = obj.accountName
- this.formData.groupNameTo = obj.groupName
- this.formData.positionNameTo = obj.positionName
- },
- 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>
|