import list from '@/mixins/list'
import {dibootApi} from '@/utils/dibootApi'
export default {
	mixins: [list],
	created() {
		this.activeIndex = -100
        this.getList(true)
	},
    
	methods: {
		handle2ProcessTask(id, instId, category, definitionId, allowDeal) {
			uni.navigateTo({
				url:`/pages/workflowTask/webviewPages/dealTask?id=${id}&definitionId=${definitionId}&instId=${instId}&category=${category}&allowDeal=${allowDeal}`
			})
		},
        // 撤销
        handle2Click(processInstanceId, taskOperate) {
            uni.showModal({
            title: '',
            content: `确认撤销？`,
            showCancel: true,
            confirmText: '确定',
            success: async (res) => {
                if (res.confirm) {
                    const res = await dibootApi.put('/workflow/task/taskOperate', {
                        processInstanceId,
                        taskOperate,
                        validTask: false
                    })
                    if (res.code === 0) {
                        uni.showToast({
                            title: '撤销成功',
                            icon: 'none'
                        })
                        this.page.pageIndex = 1
                        this.getList(true)
                    }
                }
            }
        })
        },
        // 重新发起
        handle2RestartWorkflow(item){
            uni.navigateTo({
                url: `/pages/workflowTask/webviewPages/startFlow?id=${item.procDefId}&processInstanceId=${item.id}&defaultTitle=${item.name}&name=${item.processDefinitionName}&restart=true&type=myLaunch`
            })
        }
	},
	watch: {
	  searchKeyWord: {
	    handler: function (val) {
		  this.list = []
          console.log(val,'搜索关键字', this.type)
          if(this.type === 'myLaunch'){
            this.queryParam['processNo'] = val||undefined
          }else{
            this.queryParam['queryName'] = val
          }
		  this.handlePullDownRefresh()
	    }
	  },
      applyTime:{
        handler: function (val) {
            console.log('改变',val)
            this.queryParam['applyTime'] = val||undefined
            this.handlePullDownRefresh()
        }
      },
      processDefinitionName:{
        handler: function (val) {
            console.log('改变',val)
            this.queryParam['processDefinitionName'] = val||undefined
            this.handlePullDownRefresh()
        }
      },
      processStatus:{
        handler: function (val) {
            console.log('改变',val)
            this.queryParam['processStatus'] = val||undefined
            this.handlePullDownRefresh()
        }
      }
	},
	props: {
		approveListHeight: {
			type: Number
		},
		searchKeyWord: {
			type: String
		},
        type: {
            type: String,
            required: true
        },
        applyTime: {
			type: Array
		},
        processDefinitionName: {
			type: String
		},
        processStatus: {
			type: Number
		},
	}
}