123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <view class="danger-submit-wrap">
- <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="80">
- <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="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>
- <button type="primary" @click="onSubmit" class="submit-BT">提交</button>
- </view>
- </template>
- <script>
- import {getUserList} 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'
- export default {
- data() {
- return {
- dangerSourceRange:[
- { value: 0, text: "自查" },
- { value: 1, text: "内部反馈" },
- { value: 2, text: "上级检查" },
- { value: 3, text: "政府执法" },
- ],
- dangerLevelRange:[
- { value: 1, text: "一般隐患" },
- { value: 2, text: "重大隐患" }
- ],
- groupList:[],
- riskPointRange:[],
- dangerCatRange:[],
- userList:[],
- formData:{
- formCode: 'submit',
- dangerId: undefined,
- dangerCode: '',
- dangerTitle: '',
- dangerSource: 0,
- dangerDesc: '',
- dangerLevel: 1,
- dangerCatId: undefined,
- dangerCatTitle: '',
- riskPointId: undefined,
- dangerLocation: '',
- attachList:[]
- },
- rules: {
- dangerTitle: {
- 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()
- },
- 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
- }
- })
- })
- },
- getRiskPoint(){
- let app=uni.getStorageSync('qrcode');
- this.formData.dangerLocation=app.riskPointTitle
- this.formData.riskPointId=app.riskPointId
- },
- 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 = res.groupId
- res.curGroupName = group.groupName
- res.curPositionId = flow.positionId
- res.curPositionName = flow.positionName
- res.curAccountId = flow.accountId
- res.curAccountName = flow.accountName
- 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,
- "groupIdTo": res.groupId||flow.groupId,
- "accountIdTo": flow.accountId,
- "accountNameTo": flow.accountName,
- "groupNameTo": group.groupName||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 data=await handleWorkflow({...workflowForm,attachList})
- let resq=await handleDanger({...res,attachList,status:1})
- 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;
- .submit-BT {
- height: 72rpx;
- line-height: 72rpx;
- text-align: center;
- background:#3D90F4;
- border-radius: 42rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- margin: 50rpx auto;
- }
- }
- </style>
|