123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <template>
- <view class="danger-submit-wrap">
- <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
- <uni-forms-item label="隐患标题" name="dangerTitle" required>
- <uni-easyinput v-model="formData.dangerTitle" />
- </uni-forms-item>
- <!-- <uni-forms-item label="隐患编码" name="dangerCode" required>
- <uni-easyinput v-model="formData.dangerCode" />
- </uni-forms-item> -->
- <uni-forms-item label="所在部门" name="groupId" required>
- <!-- <uni-data-picker :localdata="groupList"
- v-model="formData.groupId"
- placeholder="请选择组织"
- popup-title="请选择组织"
- @nodeclick="onNodeclickGroup"
- @change="onChangeGroup"
- :map="{text:'groupName',value:'groupId'}"></uni-data-picker> -->
- <uni-data-select v-model="formData.groupId" :localdata="groupList"></uni-data-select>
- </uni-forms-item>
- <!-- <uni-forms-item label="所在位置" name="riskPointId" required>
- <p>{{formData.dangerLocation}}</p>
- </uni-forms-item> -->
- <uni-forms-item label="隐患类别" name="dangerCatId" required>
- <uni-data-select v-model="formData.dangerCatId" :localdata="dangerCatRange"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="隐患来源" name="dangerSource" required>
- <uni-data-select v-model="formData.dangerSource" :localdata="dangerSourceRange"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="隐患等级" name="dangerLevel" required>
- <uni-data-checkbox v-model="formData.dangerLevel" :localdata="dangerLevelRange" />
- </uni-forms-item>
- <uni-forms-item label="整改截止时间" name="dangerDeadLine" required>
- <uni-datetime-picker type="datetime" return-type="string" v-model="formData.dangerDeadLine"/>
- </uni-forms-item>
- <uni-forms-item label="评审部门" name="handleGroup" required>
- <uni-data-select v-model="formData.handleGroup" :localdata="groupList" @change="changeHandGroup"></uni-data-select>
- </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-forms-item label="描述" name="dangerDesc">
- <uni-easyinput v-model="formData.dangerDesc" type="textarea" :maxlength="-1" autoHeight placeholder="隐患描述" />
- </uni-forms-item>
- <uni-section title="上传附件" type="line">
- <view class="example-body">
- <uni-file-picker v-model="formData.attachList"
- fileMediatype="image"
- title="请上传附件"
- limit="1"
- @select="uploadSuccess"
- @delete="deleteFile"></uni-file-picker>
- </view>
- </uni-section>
- </uni-forms>
- <view class="button-container" @click="onSubmit">提交</view>
- </view>
- </template>
- <script>
- import {getUserList,selectUserByGroupId} from '@/api/system/user.js'
- import {getGroupView,getGroupByList} from '@/api/system/groupApi.js'
- import {getDangerCatByList} from '@/api/danger.js'
- import {getRiskPointByList} from '@/api/riskPiont.js'
- import { startWorkflow, handleWorkflow } from '@/api/system/wfApi'
- import { handleDanger } from '@/api/system/dangerApi.js'
- import {upload} from '@/api/system/upload.js'
- import {getchecklistRecord} from '@/api/aqpt/checklistPoint.js'
- import { getChecklistHazardRecordView } from '@/api/aqpt/checklistRecordHazardApi'
-
- export default {
- data() {
- return {
- dangerSourceRange:[
- { value: 0, text: "自查" },
- { value: 1, text: "内部反馈" },
- { value: 2, text: "上级检查" },
- { value: 3, text: "政府执法" },
- ],
- dangerLevelRange:[
- { value: 1, text: "重大隐患" },
- { value: 2, text: "较大隐患" },
- { value: 3, text: "严重隐患" },
- { value: 4, text: "一般隐患" }
- ],
- groupList:[],
- riskPointRange:[],
- dangerCatRange:[],
- userList:[],
- formData:{
- formCode: 'submit',
- dangerId: undefined,
- dangerCode: undefined,
- dangerTitle: '',
- dangerSource: 0,
- dangerDesc: '',
- dangerLevel: 1,
- dangerCatId: undefined,
- dangerCatTitle: '',
- riskPointId: undefined,
- dangerLocation: '',
- accountId:"",
- attachList:[]
- },
- rules: {
- dangerTitle: {
- rules:[
- {required: true,errorMessage: '请填写姓名',},
- ]
- },
- handleGroup: {
- rules:[
- {required: true,errorMessage: '请选择评审部门',},
- ]
- },
- accountId: {
- rules:[
- {required: true,errorMessage: '请选择评审人员',},
- ]
- },
- // dangerCode: {rules:[{required: true,errorMessage: '请填写隐患编码'}]},
- dangerDeadLine: {rules:[{required: true,errorMessage: '请填写整改截止时间'}]}
- },
- flowData:{}
- }
- },
- onReady() {
- this.$refs.form.setRules(this.rules)
- },
- created() {
- this.init()
- },
- onLoad(data) {
- this.getchecklist(data)
- },
- methods: {
- init(){
- this.getDangerCat()
- this.getRiskPoint()
- this.getUserList()
- this.getGroupRange()
- this.start(1)
- },
- // 启动流程
- async start(wfDefId) {
- const { data } = await startWorkflow(wfDefId)
- this.flowData = data
- },
- getDangerCat(){
- getDangerCatByList().then((res)=>{
- this.dangerCatRange=res.data.map(item=>{
- return{
- value: item.dangerCatId,
- text: item.dangerCatTitle
- }
- })
- })
- },
- changeHandGroup(id){
- this.userList=[]
- this.formData.accountId="";
- if(!id){
- this.getUserList();
- return;
- }
- selectUserByGroupId(id).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
- })
- }
- }
- console.log({userList})
- this.userList=userList
- })
- },
- getRiskPoint(){
- let app=uni.getStorageSync('qrcode');
- this.formData.dangerLocation=app.riskPointTitle
- this.formData.riskPointId=app.riskPointId
- },
- getchecklist({cid,rid,type}){
- if(type==='hazard'){
- getChecklistHazardRecordView(rid).then((res)=>{
- let itemList=res.data.hazardList
- let measures=[]
- for(let i=0;i<itemList.length;i++){
- if(itemList[i].riskList){
- itemList[i].riskList.map(child=>{
- child.recordList.map(measure=>{
- measures.push(measure)
- })
- })
- }
- }
- let noPassPoints=measures.filter(item=>item.checkResult===-1)
- let dangerDesc=noPassPoints.reduce((acc, cur) => `${cur.measureContent}【未通过】;\n` + acc, "")
- this.formData.dangerDesc=dangerDesc
- this.formData.dangerTitle=`${res.data.targetTitle}【${res.data.hazardList[0].hazardTitle}】`
-
- })
- }
- if(type==='point'){
- getchecklistRecord(cid,rid).then((res)=>{
- let itemList=res.data.itemList
- let points=[]
- for(let i=0;i<itemList.length;i++){
- if(itemList[i].children){
- itemList[i].children.map(child=>{
- child.recordList.map(pointitem=>{
- points.push(pointitem)
- })
- })
- }else{
- itemList[i].recordList.map(pointitem=>{
- points.push(pointitem)
- })
-
- }
- }
- let noPassPoints=points.filter(item=>item.checkResult===-1)
- let dangerDesc=noPassPoints.reduce((acc, cur) => `${cur?.pointContent}【未通过】;\n` + acc, "")
- this.formData.dangerDesc=dangerDesc
- this.formData.dangerTitle=res.data.targetTitle
- })
- }
- },
- getGroupRange(){
- getGroupByList().then((res)=>{
- this.groupList=res.data.map(item=>{
- return{
- ...item,
- value: item.groupId,
- text: 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
- })
- },
- onNodeclickGroup(node){
- // console.log({node})
- },
- onChangeGroup({detail}){
- // console.log(detail)
- },
- onSubmit(){
- this.$refs.form.validate().then(res=>{
- let flow=this.userList.filter(item=>this.formData.accountId===item.accountId)[0]
- let group=this.groupList.filter(item=>this.formData.groupId===item.groupId)[0]
- res.curGroupId = flow.groupId
- res.curGroupName = flow.groupName
- res.curPositionId = flow.positionId
- res.curPositionName = flow.positionName
- res.curAccountId = flow.accountId
- res.curAccountName = flow.accountName
- res.groupId=this.formData.groupId
- res.formCode= 'submit'
- res.dangerId=this.flowData.wfInsId
- res.dangerLocation=this.formData.dangerLocation
- res.riskPointId=this.formData.riskPointId
- res.submitRemark=this.formData.dangerDesc
- /*start*/
- let workflowForm={
- "actionId": 1,
- "wfDefId":this.flowData.wfDefId,
- "wfInsId":this.flowData.wfInsId,
- "activityDefId":this.flowData.activityDefId,
- "activityInsId":this.flowData.activityInsId,
- "activityCode":this.flowData.activityCode,
- "actionInsId":this.flowData.actionInsId,
- "actionDefId":this.flowData.actionDefList[0].actionDefId,
- "actionCode":this.flowData.actionDefList[0].actionCode,
- "groupId":this.formData.groupId,
- "groupName":group.groupName,
- "groupIdTo": flow.groupId,
- "accountIdTo": flow.accountId,
- "accountNameTo": flow.accountName,
- "groupNameTo": flow.groupName,
- "positionIdTo": flow.positionId,
- "positionNameTo": flow.positionName,
- "actionRemark":this.formData.dangerDesc
- }
- this.handleSubmit({res,workflowForm})
- }).catch(err =>{
- console.log('表单错误信息:', err);
- })
- },
- async handleSubmit({res,workflowForm}) {
- 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=await handleWorkflow({...workflowForm,attachList})
- let resq=await handleDanger({... this.formData,...qrcode_target,attachList,status:1,riskPointId:qrcode.targetId})
- uni.showToast({
- icon:'none',
- title:"提交成功!",
- complete() {
- uni.$emit('type',2)
- uni.switchTab({
- url:'/pages/history/history?type=dangersubmit'
- })
- }
- })
- },
- 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
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .danger-submit-wrap{
- padding: 20rpx 20rpx 200rpx 20rpx;
- .button-container{
- width: 750rpx;
- height:88rpx;
- 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: 2;
- box-shadow: 0px 0px 12px 0px #0000000A;
- border-radius: 8px 8px 0px 0px
- }
- }
- </style>
|