<template>
|
<el-dialog
|
:visible.sync="deliverDialog"
|
:close-on-click-modal="false"
|
width="50%"
|
:append-to-body="true"
|
:title=stockName
|
center
|
size="medium"
|
>
|
<div class="app-container">
|
<div class="upTitle">
|
请勾选或取消勾选允许使用该仓库的批发企业,您允许使用的企业可将货物入库到该仓库。
|
</div>
|
<div class="table_content">
|
<el-checkbox-group v-model="authorityCorts" @change="changeData">
|
<el-checkbox v-for="item in companyList" :key="item.enterpriseId" :label="item.enterpriseId" :disabled="item.enterpriseAuthority == 1? true: false" border style="display: block">
|
{{item.enterpriseName}}
|
</el-checkbox>
|
</el-checkbox-group>
|
</div>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="deliverDialog = false">取 消</el-button>
|
<el-button type="primary" @click="handleSubmit()">提 交</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {computePageCount} from "@/utils";
|
import {listStockhouseEnterpriseUserInfo,editEnterpriseUserAuthority} from "../../../api/warehouse";
|
|
export default {
|
name: "deliverUsage",
|
components: {},
|
data(){
|
return{
|
tableStatus: true,
|
tableKey:'',
|
stockName: '',
|
listLoading:false,
|
companyList:[],
|
authorityCorts: [],
|
deliverDialog:false,
|
reserveId: null,
|
storehouseId: null,
|
submitForm: {
|
addEnterprises: [],
|
addStatus: false,
|
deleteEnterprises: [],
|
deleteStatus: false
|
}
|
}
|
},
|
created() {
|
const t = this
|
},
|
methods:{
|
open(data){
|
this.submitForm = {
|
addEnterprises: [],
|
addStatus: false,
|
deleteEnterprises: [],
|
deleteStatus: false
|
}
|
this.reserveId = data.topId
|
this.storehouseId = data.id
|
listStockhouseEnterpriseUserInfo({id: data.id}).then((res)=>{
|
this.stockName = '仓库【'+ data.storehouseName + '】使用权分配'
|
if(res.data.code == 200){
|
this.companyList = res.data.result.enterpriseUserAuthorityInfo
|
this.authorityCorts = this.companyList.filter(item=>item.enterpriseAuthority == 1 || item.enterpriseAuthority == 2).map(i=>{return i.enterpriseId})
|
}else{
|
this.$message.warning(res.data.message)
|
}
|
this.deliverDialog = true
|
}).catch(()=>{
|
this.$message.warning('数据获取失败')
|
})
|
},
|
changeData(value){
|
console.log(value,'val')
|
},
|
async handleSubmit(){
|
const originList = this.companyList.filter(i=>i.enterpriseAuthority == 1 || i.enterpriseAuthority==2)
|
const companyIds = originList.map(i=>i.enterpriseId)
|
const addedElementsSet = new Set(this.authorityCorts.filter(element => !companyIds.includes(element)))
|
const removedElementsSet = new Set(companyIds.filter(element => !this.authorityCorts.includes(element)))
|
const addedElements = Array.from(addedElementsSet)
|
const removedElements = Array.from(removedElementsSet)
|
if(addedElements.length>0){
|
this.submitForm.addStatus = true
|
this.submitForm.addEnterprises = addedElements.map((i)=>{
|
return {
|
enterpriseId: i,
|
reserveId: this.reserveId,
|
storehouseId: this.storehouseId
|
}
|
})
|
}
|
if(removedElements.length>0){
|
this.submitForm.deleteStatus = true
|
for(let i of this.companyList){
|
if(removedElements.find(item=>item == i.enterpriseId)){
|
this.submitForm.deleteEnterprises.push({
|
id: i.id?i.id:null,
|
enterpriseId: i.enterpriseId,
|
reserveId: this.reserveId,
|
storehouseId: this.storehouseId
|
})
|
}
|
}
|
}
|
const res = await editEnterpriseUserAuthority(this.submitForm)
|
if(res.data.code == 200){
|
this.$message.success('仓库使用权修改成功')
|
}else{
|
this.$message.warning(res.data.message)
|
}
|
this.deliverDialog = false
|
this.$emit('refresh')
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.upTitle{
|
font-size: 16px;
|
margin-bottom: 20px;
|
}
|
/deep/ .el-checkbox{
|
width: 80%;
|
margin-left: 0 !important;
|
margin-right: 0 !important;
|
margin-bottom: 10px !important;
|
}
|
</style>
|