主要看审核反审核,禁用反禁用。
//高级查询组件回调参数
seachcallck(params,paramsText){
this.superQueryCollect.queryParams = params
this.superQueryCollect.paramText = paramsText
},
//反禁用
unForbidden () {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
if (!this.model.id) {
that.warning('请先保存!')
that.confirmLoading = false
return
}
let formData = Object.assign(this.model, values)
console.log('表单提交数据', formData)
if (formData.forbidFlag == 0) {
that.warning('已经是正常状态了!')
that.confirmLoading = false
return
}
putAction(this.url.unForbid, formData).then((res) => {
if (res.success) {
that.success('反禁用成功!')
that.form.setFieldsValue({
forbidFlag: '0'
})
} else {
that.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
//表单禁用
forbidden () {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
if (!this.model.id) {
that.warning('请先保存!')
that.confirmLoading = false
return
}
let formData = Object.assign(this.model, values)
console.log('表单提交数据', formData)
if (formData.forbidFlag == 1) {
that.warning('已经是禁用状态了!')
that.confirmLoading = false
return
}
putAction(this.url.forbid, formData).then((res) => {
if (res.success) {
that.success('禁用成功!')
that.form.setFieldsValue({
forbidFlag: '1'
})
} else {
that.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
//表单反审核
unAudit() {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
if (!this.model.id) {
that.warning('请先保存!')
that.confirmLoading = false
return
}
let formData = Object.assign(this.model, values)
if (formData.dataStatus == 2) {
that.warning('已经是重新审核状态了!')
that.confirmLoading = false
return
}
if (formData.dataStatus == 0) {
that.warning('保存状态下不能反审核!')
that.confirmLoading = false
return
}
console.log('表单提交数据', formData)
if (formData.forbidFlag == 1) {
that.warning('禁用状态下不能反审核!')
that.confirmLoading = false
return
}
putAction(this.url.unAudit, formData).then((res) => {
if (res.success) {
that.success('反审核成功!')
that.form.setFieldsValue({
dataStatus: 2
})
} else {
that.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
})
}
})
},
//表单审核
audit() {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
if (!this.model.id) {
that.warning('请先保存!')
that.confirmLoading = false
return
}
let formData = Object.assign(this.model, values)
if (formData.dataStatus == 1) {
that.warning('已经是已审核状态了!')
that.confirmLoading = false
return
}
console.log('表单提交数据', formData)
if (values.forbidFlag == 1) {
that.warning('禁用状态下不能审核!')
that.confirmLoading = false
return
}
putAction(this.url.audit, formData).then((res) => {
if (res.success) {
that.success('审核成功!')
that.form.setFieldsValue({
dataStatus: res.result.dataStatus,
chkBy: res.result.chkBy,
chkTime: res.result.chkTime
})
} else {
that.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
//保存
handleOk () {
const that = this
// 触发表单验证
that.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
let httpurl = ''
let method = ''
if (!that.model.id) {
httpurl += that.url.add
method = 'post'
} else {
httpurl += that.url.edit
method = 'put'
}
let formData = Object.assign(that.model, values)
console.log('表单提交数据', formData)
if (formData.dataStatus == 1) {
that.warning('审核状态下不可编辑!')
that.confirmLoading = false
return
}
if (formData.forbidFlag == 1) {
that.warning('禁用状态下不可编辑!')
that.confirmLoading = false
return
}
httpAction(httpurl, formData, method).then((res) => {
if (res.success) {
that.success('操作成功!')
that.edit(res.result)
} else {
that.error(res.message)
}
}).finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
randomNumber () {
const now = new Date()
let month = now.getMonth() + 1
let day = now.getDate()
let hour = now.getHours()
let minutes = now.getMinutes()
let seconds = now.getSeconds()
month = this.setTimeDateFmt(month)
hour = this.setTimeDateFmt(hour)
minutes = this.setTimeDateFmt(minutes)
seconds = this.setTimeDateFmt(seconds)
return now.getFullYear().toString() + month.toString() + day + hour + minutes + seconds + (Math.round(Math.random() * 23 + 100)).toString()
},
loadData (arg) {
if (!this.url.list) {
this.error('请设置url.list属性!')
// this.$message.error('请设置url.list属性!')
return
}
//加载数据 若传入参数1则加载第一页的内容
if (arg === 1) {
this.ipagination.current = 1
}
var params = this.getQueryParams()//查询条件
// params.pageSize = 20
this.loading = true
console.log('sparamsdf:' + JSON.stringify(params))
getAction(this.url.list, params).then((res) => {
console.log('res:' + JSON.stringify(res))
if (res.success) {
// alert(JSON.stringify(res))
console.log('=========================' + JSON.stringify(res))
this.dataSource = res.result.records
this.current = res.result.current
this.pages = res.result.pages
this.total = res.result.total
// this.current=res.result.current
this.ipagination.total = res.result.total
}
if (res.code === 510) {
this.warning(res.message)
// this.$message.warning(res.message)
}
this.loading = false
})
},
调用:
<a-menu slot="overlay">
<a-menu-item key="2" @click="auditBatch">{{ $t('button.audit') }}</a-menu-item>
<a-menu-item key="3" @click="unAuditBatch">{{ $t('button.unAudit') }}</a-menu-item>
</a-menu>
</a-dropdown>
<a-dropdown style="margin-left: 24px;margin-top: 10px;">
<a class="ant-dropdown-link" @click="e => e.preventDefault()">
{{ $t('button.forbid') }}
<a-icon type="caret-down"/>
</a>
<a-menu slot="overlay">
<a-menu-item key="4" @click="forbidBatch">{{ $t('button.forbid') }}</a-menu-item>
<a-menu-item key="5" @click="unForbidBatch">{{ $t('button.unForbid') }}</a-menu-item>
</a-menu>
url: {
auditBatch: `${window._CONFIG['mes']}/base/baseTeam/auditBatch`,
unAuditBatch: `${window._CONFIG['mes']}/base/baseTeam/unAuditBatch`,
forbidBatch: `${window._CONFIG['mes']}/base/baseTeam/forbidBatch`,
unForbidBatch: `${window._CONFIG['mes']}/base/baseTeam/unForbidBatch`,
},