| | |
| | | }) |
| | | } |
| | | |
| | | |
| | | export function getWarehousingRecordList(query) { |
| | | return request({ |
| | | url: '/system/warehousingRecord/selectWarehousingRecordList', |
| | |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | export function getMaterialList(query) { |
| | | return request({ |
| | | url: '/system/warehousingRecord/selectMaterialList', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | export function delMaterial(query) { |
| | | return request({ |
| | | url: '/system/warehousingRecord/deletedMaterial', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | export function updateMaterial(data) { |
| | | return request({ |
| | | url: '/system/warehousingRecord/saveMaterial', |
| | | method: 'post', |
| | | data: data |
| | | }) |
| | | } |
| | | |
| | | export function getWarehousingRecordDetailList(query) { |
| | | return request({ |
| | | url: '/system/warehousingRecord/selectWarehousingRecordDetailList', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | |
| | | } else { |
| | | this.roles = ['ROLE_DEFAULT'] |
| | | } |
| | | this.id = user.userId |
| | | this.name = user.userName |
| | | this.id = user.id |
| | | this.name = user.name |
| | | this.companyId = user.companyId |
| | | this.companyName = user.companyName |
| | | this.avatar = avatar |
| 对比新文件 |
| | |
| | | <template> |
| | | <div class="notice"> |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | :title="state.title" |
| | | width="700px" |
| | | :before-close="handleClose" |
| | | :close-on-press-escape="false" |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" > |
| | | <el-form-item v-if="state.isAdmin" label="企业:" prop="companyId"> |
| | | <el-select v-model="state.form.companyId" placeholder="请选择" :disabled="state.title =='查看'" clearable style="width: 100%"> |
| | | <el-option |
| | | v-for="item in state.companyList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="材料名称:" prop="materialName"> |
| | | <el-input v-model.trim="state.form.materialName" :readonly="state.title =='查看'" placeholder="材料名称"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="规格:" prop="specification"> |
| | | <el-input v-model.trim="state.form.specification" :readonly="state.title =='查看'" placeholder="规格"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="单位:" prop="materialUnit"> |
| | | <el-input v-model.trim="state.form.materialUnit" :readonly="state.title =='查看'" placeholder="单位"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="库存量:" prop="inventory"> |
| | | <el-input type="number" v-model.number.trim="state.form.inventory" :readonly="state.title =='查看'" placeholder="库存量"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer v-if="state.title !='查看'"> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="handleClose" size="default">取 消</el-button> |
| | | <el-button type="primary" @click="onSubmit" size="default" v-preReClick>确认</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | import {reactive, ref, toRefs, defineEmits, nextTick, onMounted} from 'vue' |
| | | import {ElMessage} from "element-plus"; |
| | | import {addUser, editUser, getUserById, resetPwd} from "@/api/onlineEducation/user" |
| | | import {Base64} from "js-base64" |
| | | import {getCompany} from "@/api/onlineEducation/company"; |
| | | import {updateInfoPlatforms} from "@/api/staffManage/staff"; |
| | | import {updateMaterial} from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | |
| | | const emit = defineEmits(["getList"]); |
| | | const dialogVisible = ref(false) |
| | | const superRef = ref() |
| | | const state = reactive({ |
| | | title: '', |
| | | form: { |
| | | id: null, |
| | | companyId: null, |
| | | materialName: '', |
| | | specification: '', |
| | | materialUnit: '', |
| | | inventory: '' |
| | | }, |
| | | formRules:{ |
| | | companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }], |
| | | materialName: [{ required: true, message: '请输入材料名称', trigger: 'blur' }], |
| | | specification: [{ required: true, message: '请输入规格', trigger: 'blur' }], |
| | | materialUnit: [{ required: true, message: '请输入单位', trigger: 'blur' }], |
| | | inventory: [{ required: true, message: '请输入库存量', trigger: 'blur' }] |
| | | }, |
| | | isAdmin: false, |
| | | companyList: [] |
| | | }) |
| | | onMounted(() => { |
| | | |
| | | }); |
| | | |
| | | const openDialog = async (type, value,companyId, isAdmin, companyList) => { |
| | | state.isAdmin = isAdmin |
| | | if(isAdmin){ |
| | | state.companyList = companyList |
| | | } |
| | | state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' |
| | | state.form.companyId = companyId |
| | | if(state.title == '编辑'||state.title == '查看'){ |
| | | Object.keys(state.form).forEach(key => { |
| | | if (key in value) { |
| | | state.form[key] = value[key] |
| | | } |
| | | }) |
| | | } |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | const onSubmit = async () => { |
| | | const valid = await superRef.value.validate(); |
| | | if(valid){ |
| | | let data = {} |
| | | if(state.title == '新增'){ |
| | | data = { |
| | | companyId: state.form.companyId, |
| | | materialName: state.form.materialName, |
| | | specification: state.form.specification, |
| | | materialUnit: state.form.materialUnit, |
| | | inventory: state.form.inventory |
| | | } |
| | | }else{ |
| | | data = state.form |
| | | } |
| | | const res = await updateMaterial(data) |
| | | if(res.code == 200){ |
| | | ElMessage.success(res.message) |
| | | emit('getList') |
| | | handleClose() |
| | | dialogVisible.value = false; |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | const handleClose = () => { |
| | | state.form = { |
| | | id: null, |
| | | companyId: null, |
| | | materialName: '', |
| | | specification: '', |
| | | materialUnit: '', |
| | | inventory: '' |
| | | } |
| | | superRef.value.clearValidate(); |
| | | superRef.value.resetFields() |
| | | dialogVisible.value = false; |
| | | } |
| | | |
| | | defineExpose({ |
| | | openDialog |
| | | }); |
| | | |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .notice{ |
| | | :deep(.el-form .el-form-item__label) { |
| | | font-size: 15px; |
| | | } |
| | | .file { |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: flex-start; |
| | | } |
| | | } |
| | | </style> |
| 对比新文件 |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div style="display: flex;justify-content: space-between"> |
| | | <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" > |
| | | <el-form-item> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="openDialog('add',{})" |
| | | >新增</el-button> |
| | | </el-form-item> |
| | | <el-form-item v-if="isAdmin" label="企业:" > |
| | | <el-select v-model="data.queryParams.companyId" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in companyList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item > |
| | | <el-button v-if="isAdmin" type="primary" @click="getList">查询</el-button> |
| | | <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="dataList" :border="true"> |
| | | <el-table-column label="序号" type="index" align="center" width="80"/> |
| | | <el-table-column label="材料名称" prop="materialName" align="center"/> |
| | | <el-table-column label="规格" prop="specification" align="center"/> |
| | | <el-table-column label="单位" prop="materialUnit" align="center"/> |
| | | <el-table-column label="库存量" prop="inventory" align="center"/> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width" > |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="openDialog('view',scope.row)">查看</el-button> |
| | | <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button> |
| | | <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <edit-dialog ref="dialogRef" @getList="getList"></edit-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import {delCompany, getCompany} from "@/api/onlineEducation/company"; |
| | | import Cookies from "js-cookie"; |
| | | import editDialog from './components/editDialog.vue' |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { |
| | | delMaterial, |
| | | delOutsourcedProductNameList, |
| | | getMaterialList |
| | | } from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | const userStore = useUserStore() |
| | | const { proxy } = getCurrentInstance(); |
| | | const loading = ref(false); |
| | | const dialogRef = ref(); |
| | | const data = reactive({ |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: null |
| | | }, |
| | | total: 0, |
| | | dataList: [], |
| | | companyList: [], |
| | | isAdmin: false |
| | | }); |
| | | |
| | | const { queryParams, total, dataList,companyList, isAdmin } = toRefs(data); |
| | | const userInfo = ref() |
| | | onMounted(async ()=>{ |
| | | userInfo.value = JSON.parse(Cookies.get('userInfo')) |
| | | if(userStore.roles.includes('admin')){ |
| | | data.isAdmin = true |
| | | await getCompanyList() |
| | | }else{ |
| | | data.isAdmin = false |
| | | data.queryParams.companyId = userStore.companyId |
| | | } |
| | | await getList() |
| | | }) |
| | | |
| | | onUnmounted(()=>{ |
| | | |
| | | }) |
| | | |
| | | const getList = async () => { |
| | | loading.value = true |
| | | const res = await getMaterialList(data.queryParams) |
| | | if(res.code == 200){ |
| | | data.dataList = res.data.list || [] |
| | | data.total = res.data.total |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | loading.value = false |
| | | } |
| | | |
| | | const getCompanyList = async ()=>{ |
| | | const queryParams = { |
| | | pageNum: 1, |
| | | pageSize: 999 |
| | | } |
| | | const res = await getCompany(queryParams) |
| | | if (res.code == 200) { |
| | | data.companyList = res.data.list?res.data.list:[] |
| | | // data.queryParams.companyId = data.companyList[0].id |
| | | } else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const openDialog = (type, value) => { |
| | | dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList ); |
| | | } |
| | | |
| | | /** 重置新增的表单以及其他数据 */ |
| | | const reset= async()=> { |
| | | data.queryParams = { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: null |
| | | } |
| | | await getCompanyList() |
| | | await getList() |
| | | } |
| | | const handleDelete = (val) => { |
| | | ElMessageBox.confirm( |
| | | '确定删除此条数据?', |
| | | '提示', |
| | | { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then( async() => { |
| | | const res = await delMaterial({id: val.id}) |
| | | if(res.code == 200){ |
| | | ElMessage.success('数据删除成功') |
| | | await getList() |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | </script> |
| | |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="记录名称:" prop="recordName"> |
| | | <el-input v-model.trim="state.form.recordName" :readonly="state.title =='查看'" placeholder="文件名称"></el-input> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="材料名称:" prop="materialId"> |
| | | <el-select v-model="state.form.materialId" placeholder="请选择" :disabled="state.title =='查看'" clearable @change="getInventory()"> |
| | | <el-option |
| | | v-for="item in state.materialList" |
| | | :key="item.id" |
| | | :label="item.materialName" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | @click="openAdd('add',{})" |
| | | >新增材料</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-form-item label="库存数量:"> |
| | | <el-input v-model.trim="state.originInventory" readonly placeholder="库存数量"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="材料清单:" prop="warehousingRecordDetails"> |
| | | <el-button |
| | |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="名称" prop="name" align="center"> |
| | | <el-table-column label="出入库" prop="recordType" align="center"> |
| | | <template #default="scope"> |
| | | <el-select clearable v-model="scope.row.recordType" :disabled="state.title =='查看'" filterable placeholder="出入库" style="width: 100%" @change="checkRemain(scope)"> |
| | | <el-option :key="1" label="入库" :value="1"/> |
| | | <el-option :key="2" label="出库" :value="2"/> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="规格" prop="specification" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim="scope.row.name" |
| | | size="large" |
| | | v-model.trim="scope.row.specification" |
| | | type="textarea" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | readonly |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="入库-单位" prop="enterCompany" align="center"> |
| | | <el-table-column label="单位" prop="materialUnit" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim="scope.row.enterCompany" |
| | | size="large" |
| | | v-model.trim="scope.row.materialUnit" |
| | | type="textarea" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | readonly |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="入库数量" prop="enterNum" align="center"> |
| | | <el-table-column label="数量" prop="num" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim.number="scope.row.enterNum" |
| | | size="large" |
| | | v-model.trim.number="scope.row.num" |
| | | type="number" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | @input="checkRemain(scope)" |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="入库-入库经手人" prop="enterPerson" align="center"> |
| | | <el-table-column label="经手人" prop="createBy" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim="scope.row.enterPerson" |
| | | size="large" |
| | | type="textarea" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="出库-出库单位" prop="outboundCompany" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim="scope.row.outboundCompany" |
| | | size="large" |
| | | type="textarea" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="出库-出库数量" prop="outboundNum" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim.number="scope.row.outboundNum" |
| | | size="large" |
| | | type="number" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="出库-出库经手人" prop="outboundPerson" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim="scope.row.outboundPerson" |
| | | size="large" |
| | | type="textarea" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | > |
| | | </el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="库存数量" prop="amount" align="center"> |
| | | <template #default="scope"> |
| | | <el-input |
| | | v-model.trim.number="scope.row.amount" |
| | | size="large" |
| | | type="number" |
| | | style="width: 100%;" |
| | | clearable |
| | | :readonly="state.title =='查看'" |
| | | > |
| | | </el-input> |
| | | <el-select clearable v-model="scope.row.createBy" :disabled="state.title =='查看'" filterable placeholder="经手人" style="width: 100%"> |
| | | <el-option |
| | | v-for="item in state.userList" |
| | | :key="item.userId" |
| | | :label="item.name" |
| | | :value="item.name" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="备注" prop="remark" align="center"> |
| | |
| | | <el-button type="primary" @click="onSubmit" size="default" v-preReClick>确认</el-button> |
| | | </span> |
| | | </template> |
| | | <edit-dialog ref="dialogRef" @getList="getMaterials"></edit-dialog> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | import {reactive, ref, toRefs, defineEmits, nextTick, onMounted} from 'vue' |
| | | import editDialog from '@/views/work/procurementPlatform/materialMng/components/editDialog.vue' |
| | | import {ElMessage} from "element-plus"; |
| | | import {getToken} from "@/utils/auth"; |
| | | import { |
| | | updateMaintenanceEvaluate, |
| | | getMaintenanceEvaluateDetail |
| | | } from "@/api/infrastructureMng/ledger"; |
| | | |
| | | import {listUser} from "@/api/system/user"; |
| | | import {getWarehousingRecordDetail, updateWarehousingRecord} from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | |
| | | import {getMaterialList} from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | const emit = defineEmits(["getList"]); |
| | | const dialogVisible = ref(false) |
| | | const superRef = ref() |
| | | const dialogRef = ref(); |
| | | const checkList = (rule, value, callback) => { |
| | | if (state.form.warehousingRecordDetails.length == 0) { |
| | | callback(new Error('材料清单不可为空')) |
| | |
| | | callback() |
| | | } |
| | | } |
| | | const userStore = useUserStore() |
| | | const state = reactive({ |
| | | title: '', |
| | | form: { |
| | | id: null, |
| | | companyId: null, |
| | | materialId: null, |
| | | recordName: '', |
| | | inventory: null, |
| | | warehousingRecordDetails: [], |
| | | delDetails: [] |
| | | }, |
| | | oldDeviceList: [], |
| | | formRules:{ |
| | | companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }], |
| | | recordName: [{ required: true, message: '请填写记录名称', trigger: 'blur' }], |
| | | materialId: [{ required: true, message: '请选择材料', trigger: 'blur' }], |
| | | warehousingRecordDetails: [{ required: true, validator: checkList, trigger: 'blur' }], |
| | | }, |
| | | isAdmin: false, |
| | | companyList: [] |
| | | companyList: [], |
| | | userList: [], |
| | | isOverNum: false, |
| | | originInventory: 0 |
| | | }) |
| | | onMounted(() => { |
| | | |
| | |
| | | if(isAdmin){ |
| | | state.companyList = companyList |
| | | } |
| | | await getUserList() |
| | | await getMaterials(companyId) |
| | | state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' |
| | | state.form.companyId = companyId |
| | | if(state.title == '编辑'||state.title == '查看'){ |
| | |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | const openAdd = (type, value) => { |
| | | dialogRef.value.openDialog(type, value, state.form.companyId, state.isAdmin, state.companyList ); |
| | | } |
| | | |
| | | const calculateInventoryExcludingCurrent = (currentRow) => { |
| | | if(!state.form.materialId) return 0 |
| | | let inventory = state.materialList.find(i=>i.id == state.form.materialId)?.inventory || 0; |
| | | if(Array.isArray(state.form.warehousingRecordDetails) && state.form.warehousingRecordDetails.length>0){ |
| | | for(let i of state.form.warehousingRecordDetails){ |
| | | if(i === currentRow) continue |
| | | if(i.recordType == 1 && i.num){ |
| | | inventory = inventory + Number(i.num); |
| | | } |
| | | if(i.recordType == 2 && i.num){ |
| | | inventory = inventory - Number(i.num); |
| | | } |
| | | } |
| | | } |
| | | return inventory; |
| | | } |
| | | |
| | | const calculateInventory = () => { |
| | | if(state.form.materialId){ |
| | | let inventory = state.materialList.find(i=>i.id == state.form.materialId)?.inventory || 0 |
| | | if(Array.isArray(state.form.warehousingRecordDetails) && state.form.warehousingRecordDetails.length>0){ |
| | | for(let i of state.form.warehousingRecordDetails){ |
| | | if(i.recordType == 1 && i.num){ |
| | | inventory = inventory + Number(i.num) |
| | | } |
| | | if(i.recordType == 2 && i.num){ |
| | | inventory = inventory - Number(i.num) |
| | | } |
| | | } |
| | | } |
| | | state.originInventory = inventory |
| | | if(inventory < 0){ |
| | | ElMessage.warning('库存不足,无法出库') |
| | | } |
| | | }else{ |
| | | state.originInventory = 0 |
| | | } |
| | | } |
| | | |
| | | const checkRemain = (scope) => { |
| | | if (scope.row.recordType === 2 && scope.row.num !== null && scope.row.num !== '') { |
| | | const availableInventory = calculateInventoryExcludingCurrent(scope.row); |
| | | const inputNum = Number(scope.row.num); |
| | | if (inputNum > availableInventory) { |
| | | ElMessage.warning(`出库数量不能大于当前库存,当前可用库存为:${availableInventory}`); |
| | | scope.row.num = availableInventory; |
| | | } |
| | | calculateInventory(); |
| | | } else { |
| | | calculateInventory(); |
| | | } |
| | | } |
| | | |
| | | const getMaterials = async (companyId)=>{ |
| | | const queryParams = { |
| | | pageNum: 1, |
| | | pageSize: 999, |
| | | companyId: companyId |
| | | } |
| | | const res = await getMaterialList(queryParams) |
| | | if (res.code == 200) { |
| | | state.materialList = res.data.list?res.data.list:[] |
| | | } else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const getInventory = ()=>{ |
| | | state.form.warehousingRecordDetails = state.form.warehousingRecordDetails.map(i=>{ |
| | | return { |
| | | ...i, |
| | | specification: state.materialList.find(i=>i.id == state.form.materialId)?.specification, |
| | | materialUnit: state.materialList.find(i=>i.id == state.form.materialId)?.materialUnit |
| | | } |
| | | }) |
| | | calculateInventory() |
| | | } |
| | | |
| | | const addLine = () => { |
| | | const obj = { |
| | | id: null, |
| | | recordId: null, |
| | | boardingTime: '', |
| | | name: '', |
| | | enterCompany: '', |
| | | enterNum: null, |
| | | enterPerson: '', |
| | | outboundCompany: '', |
| | | outboundNum: null, |
| | | outboundPerson: '', |
| | | amount: null, |
| | | recordType: null, |
| | | specification: state.materialList.find(i=>i.id == state.form.materialId)?.specification || '', |
| | | materialUnit: state.materialList.find(i=>i.id == state.form.materialId)?.materialUnit || '', |
| | | num: null, |
| | | createBy: userStore.name || null, |
| | | remark: '' |
| | | } |
| | | state.form.warehousingRecordDetails.push(obj); |
| | | state.form.warehousingRecordDetails.push(obj) |
| | | calculateInventory() |
| | | } |
| | | |
| | | const handleDelete = (i) =>{ |
| | | state.form.warehousingRecordDetails = state.form.warehousingRecordDetails.filter((item,index) => index != i) |
| | | calculateInventory() |
| | | } |
| | | |
| | | const onSubmit = async () => { |
| | | const valid = await superRef.value.validate(); |
| | | if(valid){ |
| | | const data = JSON.parse(JSON.stringify(state.form)) |
| | | console.log(data,'return') |
| | | // return |
| | | data.recordName = state.materialList.find(i=>i.id == state.form.materialId)?.materialName |
| | | data.inventory = state.originInventory |
| | | data.delDetails = state.oldDeviceList.filter(i =>!data.warehousingRecordDetails.some(item=>item.id == i.id)).map(i=>i.id) |
| | | if(state.title == '新增'){ |
| | | delete data.id |
| | |
| | | id: item.id, |
| | | recordId: item.recordId, |
| | | boardingTime: item.boardingTime, |
| | | name: item.name, |
| | | enterCompany: item.enterCompany, |
| | | enterNum: item.enterNum, |
| | | enterPerson: item.enterPerson, |
| | | outboundCompany: item.outboundCompany, |
| | | outboundNum: item.outboundNum, |
| | | outboundPerson: item.outboundPerson, |
| | | amount: item.amount, |
| | | recordType: item.recordType, |
| | | specification: item.specification, |
| | | materialUnit: item.materialUnit, |
| | | num: item.num, |
| | | createBy: item.createBy, |
| | | remark: item.remark |
| | | } |
| | | }) |
| | |
| | | } |
| | | |
| | | const getDeptList = async ()=>{ |
| | | // state.form.establishmentId = null |
| | | // state.form.processId = null |
| | | // state.form.approvalId = null |
| | | // await getUserList(state.form.companyId) |
| | | state.form.materialId = null |
| | | await getMaterials(state.form.companyId) |
| | | } |
| | | |
| | | const getUserList = async (companyId)=> { |
| | | const res = await listUser({pageIndex: 1,pageSize: 999,companyId: companyId}) |
| | | const getUserList = async ()=> { |
| | | const res = await listUser({pageIndex: 1,pageSize: 999}) |
| | | if(res.code == 200){ |
| | | state.userList = res.data.list?res.data.list.map(item=>{ |
| | | const user = item.id |
| | |
| | | state.form = { |
| | | id: null, |
| | | companyId: null, |
| | | materialId: null, |
| | | recordName: '', |
| | | inventory: null, |
| | | warehousingRecordDetails: [], |
| | | delDetails: [] |
| | | } |
| | |
| | | </el-form> |
| | | </div> |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="dataList" :border="true" default-expand-all> |
| | | <el-table v-loading="loading" :data="dataList" :border="true"> |
| | | <el-table-column type="index" label="序号" width="80"/> |
| | | <el-table-column type="expand" label="材料清单" width="100"> |
| | | <template #default="props"> |
| | | <el-table class="customedSubTable" :data="props.row.warehousingRecordDetails" :border="true"> |
| | | <el-table-column label="材料名称" align="center" prop="name"/> |
| | | <el-table-column label="库存数量" align="center" prop="amount"/> |
| | | </el-table> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="recordName" align="center" label="记录名称"/> |
| | | <!-- <el-table-column prop="name" align="center" label="材料名称"/>--> |
| | | <!-- <el-table-column prop="amount" align="center" label="库存数量"/>--> |
| | | <el-table-column prop="recordName" align="center" label="材料名称"/> |
| | | <el-table-column prop="inventory" align="center" label="当前库存"/> |
| | | <el-table-column label="操作" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="openDialog('view',scope.row)">查看</el-button> |
| | |
| | | import { |
| | | delWarehousingRecord, |
| | | getWarehousingRecordDetail, |
| | | getWarehousingRecordList |
| | | getWarehousingRecordDetailList |
| | | } from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | |
| | | |
| | |
| | | |
| | | const getList = async () => { |
| | | loading.value = true |
| | | const res = await getWarehousingRecordList(data.queryParams) |
| | | const res = await getWarehousingRecordDetailList(data.queryParams) |
| | | if(res.code == 200){ |
| | | data.dataList = res.data.list || [] |
| | | data.total = res.data.total |
| | |
| | | const columns = [ |
| | | { label: '序号', key: 'index' }, |
| | | { label: '登记时间', key: 'boardingTime' }, |
| | | { label: '名称', key: 'name' }, |
| | | { label: '单位', key: 'enterCompany' }, |
| | | { label: '数量', key: 'enterNum' }, |
| | | { label: '入库经手人', key: 'enterPerson' }, |
| | | { label: '单位', key: 'outboundCompany' }, |
| | | { label: '数量', key: 'outboundNum' }, |
| | | { label: '出库经手人', key: 'outboundPerson' }, |
| | | { label: '库存数量', key: 'amount' }, |
| | | { label: '出入库', key: 'recordType' }, |
| | | { label: '规格', key: 'specification' }, |
| | | { label: '单位', key: 'materialUnit' }, |
| | | { label: '数量', key: 'num' }, |
| | | { label: '经手人', key: 'createBy' }, |
| | | { label: '备注', key: 'remark' } |
| | | ]; |
| | | |
| | | // 样式定义 |
| | | const headerStyle = { |
| | | font: { bold: true, sz: 12, color: { rgb: "000000" } }, |
| | | fill: { fgColor: { rgb: "CCCCCC" } }, |
| | | alignment: { horizontal: "center", vertical: "center" }, |
| | | border: { |
| | | top: { style: "thin", color: { rgb: "000000" } }, |
| | | bottom: { style: "thin", color: { rgb: "000000" } }, |
| | | left: { style: "thin", color: { rgb: "000000" } }, |
| | | right: { style: "thin", color: { rgb: "000000" } } |
| | | } |
| | | }; |
| | | |
| | | const subHeaderStyle = { |
| | | font: { bold: true, sz: 11, color: { rgb: "000000" } }, |
| | | fill: { fgColor: { rgb: "CCCCCC" } }, |
| | | alignment: { horizontal: "center", vertical: "center" }, |
| | | border: { |
| | |
| | | alignment: { horizontal: "center", vertical: "center" } |
| | | }; |
| | | |
| | | // 处理数据,添加序号 |
| | | const summaryStyle = { |
| | | font: { bold: true, sz: 12, color: { rgb: "000000" } }, |
| | | alignment: { horizontal: "left", vertical: "center" }, |
| | | border: { |
| | | top: { style: "thin", color: { rgb: "000000" } }, |
| | | bottom: { style: "thin", color: { rgb: "000000" } }, |
| | | left: { style: "thin", color: { rgb: "000000" } }, |
| | | right: { style: "thin", color: { rgb: "000000" } } |
| | | } |
| | | }; |
| | | |
| | | // 处理数据,添加序号和转换recordType |
| | | const processData = () => { |
| | | return jsonData.warehousingRecordDetails.map((item, index) => { |
| | | // 转换recordType:1->入库,2->出库 |
| | | const recordTypeText = item.recordType === 1 ? '入库' : item.recordType === 2 ? '出库' : ''; |
| | | |
| | | return { |
| | | index: index + 1, |
| | | ...item |
| | | boardingTime: item.boardingTime, |
| | | recordType: recordTypeText, |
| | | specification: item.specification, |
| | | materialUnit: item.materialUnit, |
| | | num: item.num, |
| | | createBy: item.createBy, |
| | | remark: item.remark |
| | | }; |
| | | }); |
| | | }; |
| | |
| | | } |
| | | wsData.push(titleRow); |
| | | |
| | | // 添加上层表头行(包含"入库"和"出库"合并标题) |
| | | const topHeaderRow = [ |
| | | { v: '序号', t: 's', s: headerStyle }, // 序号 |
| | | { v: '登记时间', t: 's', s: headerStyle }, // 登记时间 |
| | | { v: '名称', t: 's', s: headerStyle }, // 名称 |
| | | { v: '入库', t: 's', s: headerStyle }, // 入库(将合并3列) |
| | | { v: '', t: 's', s: headerStyle }, // 占位 |
| | | { v: '', t: 's', s: headerStyle }, // 占位 |
| | | { v: '出库', t: 's', s: headerStyle }, // 出库(将合并3列) |
| | | { v: '', t: 's', s: headerStyle }, // 占位 |
| | | { v: '', t: 's', s: headerStyle }, // 占位 |
| | | { v: '库存数量', t: 's', s: headerStyle }, // 库存数量 |
| | | { v: '备注', t: 's', s: headerStyle } // 备注 |
| | | ]; |
| | | wsData.push(topHeaderRow); |
| | | |
| | | // 添加下层表头行(具体字段名称) |
| | | const bottomHeaderRow = columns.map(col => ({ |
| | | // 添加表头行 |
| | | const headerRow = columns.map(col => ({ |
| | | v: col.label, |
| | | t: 's', |
| | | s: subHeaderStyle |
| | | s: headerStyle |
| | | })); |
| | | wsData.push(bottomHeaderRow); |
| | | wsData.push(headerRow); |
| | | |
| | | // 添加数据行 |
| | | const processedData = processData(); |
| | | processedData.forEach(item => { |
| | | const row = columns.map(col => ({ |
| | | v: item[col.key], |
| | | t: typeof item[col.key] === 'number' ? 'n' : 's', |
| | | const row = columns.map(col => { |
| | | const value = item[col.key]; |
| | | return { |
| | | v: value, |
| | | t: typeof value === 'number' ? 'n' : 's', |
| | | s: dataStyle |
| | | })); |
| | | }; |
| | | }); |
| | | wsData.push(row); |
| | | }); |
| | | |
| | | // 添加汇总行(当前库存) |
| | | const summaryRow = [ |
| | | { v: `当前库存:${jsonData.inventory}`, t: 's', s: summaryStyle } |
| | | ]; |
| | | wsData.push(summaryRow); |
| | | |
| | | // 创建工作表 |
| | | const ws = utils.aoa_to_sheet(wsData); |
| | | |
| | | // 设置合并单元格 |
| | | // 设置合并单元格(只保留标题行合并) |
| | | const merges = [ |
| | | // 标题行合并 |
| | | { s: { r: 0, c: 0 }, e: { r: 0, c: columns.length - 1 } }, |
| | | // 入库标题合并(第1行,第3-5列) |
| | | { s: { r: 1, c: 3 }, e: { r: 1, c: 5 } }, |
| | | // 出库标题合并(第1行,第6-8列) |
| | | { s: { r: 1, c: 6 }, e: { r: 1, c: 8 } }, |
| | | // 序号、登记时间、名称跨行合并(第1-2行) |
| | | { s: { r: 1, c: 0 }, e: { r: 2, c: 0 } }, |
| | | { s: { r: 1, c: 1 }, e: { r: 2, c: 1 } }, |
| | | { s: { r: 1, c: 2 }, e: { r: 2, c: 2 } }, |
| | | // 库存数量、备注跨行合并(第1-2行) |
| | | { s: { r: 1, c: 9 }, e: { r: 2, c: 9 } }, |
| | | { s: { r: 1, c: 10 }, e: { r: 2, c: 10 } } |
| | | //库存行合并 |
| | | { s: { r: wsData.length - 1, c: 0 }, e: { r: wsData.length - 1, c: columns.length - 1 } } |
| | | ]; |
| | | |
| | | ws['!merges'] = merges; |
| | | |
| | | // 设置列宽 |
| | | const colWidths = [ |
| | | { wch: 8 }, // 序号 |
| | | { wch: 20 }, // 登记时间 |
| | | { wch: 15 }, // 名称 |
| | | { wch: 15 }, // 入库单位 |
| | | { wch: 12 }, // 入库数量 |
| | | { wch: 15 }, // 入库经手人 |
| | | { wch: 15 }, // 出库单位 |
| | | { wch: 12 }, // 出库数量 |
| | | { wch: 15 }, // 出库经手人 |
| | | { wch: 12 }, // 库存数量 |
| | | { wch: 10 }, // 出入库 |
| | | { wch: 15 }, // 规格 |
| | | { wch: 10 }, // 单位 |
| | | { wch: 12 }, // 数量 |
| | | { wch: 15 }, // 经手人 |
| | | { wch: 20 } // 备注 |
| | | ]; |
| | | ws['!cols'] = colWidths; |
| | |
| | | } |
| | | |
| | | </script> |
| | | <style lang="scss"> |
| | | .customedSubTable{ |
| | | width: calc(100% - 180px); |
| | | margin-left: 180px; |
| | | box-shadow: none; |
| | | border-radius: 0 !important; |
| | | .el-table__header-wrapper th, .el-table__fixed-header-wrapper th{ |
| | | background-color: #fff !important; |
| | | } |
| | | } |
| | | </style> |