Commit 15ba59ad authored by 15008242619's avatar 15008242619

紧急领用 单独页面

parent de6bdc75
<!--
* @Author: gjn
* @Date: 2023-08-23 17:52:16
* @Description:领用出库申请新建
-->
<template>
<div class="addOutStorageUseCom">
<div class="sub-title">领用类型</div>
<div class="useType">
<span class="typeName">领用类型:</span>
<el-select v-model="typeName" style="width: 200px;" :disabled="!!basicData.id || !!outStorageUseId" placeholder="请选择" size="mini">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
<dee-as-com
v-if="typeName==='replaceUse'"
ref="basicInfoTable"
:form="bindForm"
style="border:none;"
model-name="OutStorageUse"
:lay-config="cmpOptions"
:basic-data="{...basicData,useRequestType:basicData.typeName||typeName}"
/>
<dee-as-com
v-else-if="typeName"
ref="basicInfoTable"
style="border:none;"
model-name="OutStorageUse"
:lay-config="cmpOptions"
:basic-data="{...basicData,useRequestType:basicData.typeName||typeName}"
/>
<!-- @on-cancelCreate="cancelHandler" -->
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '紧急领用出库申请新建',
name: 'AddOutStorageUseCom',
components: {},
props: {
basicData: {
type: Object,
default: () => null
},
defaultData: {
type: Object,
default: () => null
},
isEdit: {
type: Boolean,
default: false
}
},
data() {
const that = this
return {
typeName: that.basicData.typeName || 'UrgentUse',
options: [
],
showCmp: true,
cmpOptions: {
typeName: 'OutStorageUse',
layKey: 'outStorageUseApplyAdd_UrgentUse'
},
bindForm: {},
outStorageUseId: ''
}
},
computed: {},
watch: {
typeName: {
immediate: true,
handler(val) {
this.bindForm = {}
if (!this.basicData.id) {
this.$set(this.cmpOptions, 'layKey', `outStorageUseApplyAdd_${val}`)
} else {
this.$set(this.cmpOptions, 'layKey', `outStorageUseApplyEdit_${val}`)
}
}
},
'bindForm.replaceDocNo': {
immediate: true,
handler(val) {
val && typeof (val) === 'number' && this.getReplaceOutInfo(val)
}
}
},
created() {
this.$bus.$on('getApplyId', (data) => {
this.outStorageUseId = data
})
this.$bus.$on('cancelAndRefresh', (data) => {
this.$emit('cancel')
})
},
mounted() {
this.getUseRequestTypes()
},
// 组件方法
methods: {
async getUseRequestTypes() {
const dicData = await this.$utils.getDicListByCode('UseRequestType')
this.options = dicData.filter(item => item.label === '紧急领用')
},
dataChangeHandler(val) {
if (val) {
this.formData = Object.assign({}, val)
this.formData.typeName = this.typeName
}
},
getReplaceOutInfo(id) {
this.bindForm = { replaceDocNo: this.bindForm.replaceDocNo }
post(`OutStorageRequest/createReplaceOutInfo?replaceDocId=${id}`).then(res => {
if (!res.items) return
this.bindForm = res.items
}).catch(err => {
console.log(err)
}).finally(() => {})
}
// cancelHandler(val) {
// this.$confirm('此操作将解除已占用的操作, 是否继续?', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// post(`OutStorageRequest/outStorageOut/delete?applyIds=${this.outStorageUseId}`).then(res => {
// this.$message({
// type: 'success',
// message: '删除成功!'
// })
// this.$emit('cancel')
// }).catch((err) => {
// console.log(err)
// })
// }).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删除'
// })
// })
// }
}
}
</script>
<style lang='scss'>
.addOutStorageUseCom{
.sub-title{
margin-left: 6px;
}
.useType{
.typeName{
width:100px;
margin-left:33px;
text-align: right;
vertical-align: middle;
font-size: 14px;
color: #606266;
line-height: 40px;
}
}
}
</style>
<template>
<div>
<dee-as-com
ref="applyTable"
class="list-table"
:basic-data="{ selectData,selectionRows }"
:lay-config="{ typeName: 'OutStorageUse', layKey: 'outStorageUrgentUseApplyList' }"
@tableToolHandler="tableToolHandler"
@selectionChange="selectionChange"
/>
<dee-dialog
title="发起领用申请"
:dialog-visible="dialogVisible"
>
<div style="margin-bottom: 20px;font-size: 14px;font-weight: bolder;">确认提交吗?</div>
<div style="text-align: center;">
<el-button type="primary" @click="confirm">确 定</el-button>
<el-button @click="cancle">取 消</el-button>
</div>
</dee-dialog>
<dee-dialog
title="选择审批领导:"
:dialog-visible="setPersonVisible"
>
<dee-form
ref="form"
label-width="100"
:form="form"
:form-data="formData"
:rules="rules"
>
<el-button type="primary" @click="setPersonConfirm">确 定</el-button>
<el-button @click="setPersonCancle">取 消</el-button>
</dee-form>
</dee-dialog>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
name: 'UrgentUseApply',
componentName: '紧急领用申请',
components: { },
props: {
selectData: {
type: Object,
default: () => {}
}
},
data() {
return {
dialogVisible: false,
setPersonVisible: false,
selectionRows: [],
form: {},
formData: [{
split: 1,
data: [
{
title: '设置审批领导',
key: 'userIds',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择',
multiple: true,
options: []
}
}]
}],
rules: {
userIds: [
{
required: true,
message: '请填写审批领导',
trigger: ['blur', 'change']
}
]
}
}
},
created() {
const httpParams = {
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [],
'items': [
{
'fieldName': 'source.name',
'operator': 'IN',
'value': ['项目部审批人员']
}
],
'operator': 'AND'
},
'openProps': [
{
'name': 'source',
'pageFrom': 1,
'pageSize': 9999
},
{
'name': 'target',
'pageFrom': 1,
'pageSize': 9999
}
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
post('/DxGroupMemberLink/search', httpParams).then(res => {
const arr = []
const ids = []
res.items.content.forEach(item => {
if (ids.indexOf(item.target.id) === -1) {
ids.push(item.target.id)
arr.push({
value: item.target.id,
label: item.target.name + '/' + item.target.number
})
}
})
this.formData[0].data.forEach(item => {
if (item.key === 'userIds') {
item.component.options = arr
}
/**
item.key === 'userIds' && (item.component.options = arr.map(row => {
return {
value: row.value,
label: row.label
}
}
))
*/
})
}).catch((err) => {
console.log(err)
})
},
methods: {
tableToolHandler(e) {
console.log(e.key.btnValue)
if (e.key.btnValue === 'UseApply') {
this.useApply()
}
},
useApply() {
this.dialogVisible = true
},
confirm() {
let isUrgentUse = 0
this.selectionRows.forEach(item => {
if (item.typeName !== 'UrgentUse') {
isUrgentUse++
}
})
if (isUrgentUse === 0) {
// 紧急领用选人
this.dialogVisible = false
this.setPersonVisible = true
} else if (isUrgentUse === this.selectionRows.length) {
post('/OutStorageRequest/outStorageOut/submit?applyIds=' + this.selectionRows.map(item => Number(item.id))).then(res => {
this.$utils.showMessageSuccess('提交成功')
this.$refs.applyTable.$refs.asCom.getData()
}).catch(() => {
this.$utils.showMessageWarning('出现异常,提交失败')
}).finally(() => {
this.dialogVisible = false
})
} else {
this.dialogVisible = false
this.$utils.showMessageWarning('紧急领用不能和其他领用类型一起提交')
}
},
cancle() {
this.dialogVisible = false
},
setPersonConfirm() {
const ids = []
if (this.selectionRows && this.selectionRows.length) {
this.selectionRows.forEach(item => ids.push(item.id))
}
if (this.form.userIds && this.form.userIds.length !== 0) {
post('/OutStorageRequest/creator/apply?userIds=' + this.form.userIds, ids).then(res => {
this.$utils.showMessageSuccess('提交成功')
setTimeout(() => {
this.$refs.applyTable.$refs.asCom.getData()
}, 1500)
}).catch(err => {
this.$utils.showMessageWarning('出现异常,提交失败')
console.log(err)
}).finally(() => {
this.dialogVisible = false
this.setPersonVisible = false
this.$set(this.form, 'userIds', '')
})
} else {
this.$utils.showMessageWarning('请选择审批领导')
}
},
setPersonCancle() {
this.setPersonVisible = false
this.$set(this.form, 'userIds', '')
},
selectionChange(val) {
this.selectionRows = val
}
}
}
</script>
<style></style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment