| | |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-form :model="state.form" size="default" ref="busRef" :rules="state.formRules" label-width="150px" > |
| | | <el-form-item required label= "申购订单列表" > |
| | | <el-form-item label= "申购订单列表" prop="subscribeNum"> |
| | | <el-select |
| | | clearable |
| | | v-model="state.orderName" |
| | | v-model="state.form.subscribeNum" |
| | | filterable |
| | | remote |
| | | reserve-keyword |
| | |
| | | <el-table-column type="index" label="序号" width="80" align="center"></el-table-column> |
| | | <el-table-column label="危化品名称" align="center" > |
| | | <template #default="{row,$index}"> |
| | | <el-form-item :prop="'subscribeHazmats.' + '[' + $index + ']' + '.hazmatName'" :rules="state.formRules.hazmatName"> |
| | | <el-input type="textarea" :rows="1" v-model="row.hazmatName" placeholder="请输入危化品名称"></el-input> |
| | | <el-form-item align="center" :prop="'subscribeHazmats.' + '[' + $index + ']' + '.hazmatName'" :rules="state.formRules.hazmatName"> |
| | | <span>{{row.hazmatName}}</span> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="数量" align="center" > |
| | | <template #default="{row,$index}"> |
| | | <el-form-item :prop="'subscribeHazmats.' + '[' + $index + ']' + '.hazmatCount'" :rules="state.formRules.hazmatCount"> |
| | | <el-input v-model="row.hazmatCount" @input="row.hazmatCount = row.hazmatCount.replace(/[^0-9]/g,'')" placeholder="请输入数量"></el-input> |
| | | <span>{{row.hazmatCount}}</span> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | import {addSubscribe, editSubscribe, getSubscribeList} from "@/api/hazardousChemicals/subscribeApply"; |
| | | import {getCupById, getWarehouse} from "@/api/hazardousChemicals/warehouse"; |
| | | import moment from "moment"; |
| | | import Cookies from "js-cookie"; |
| | | import {addOrder, editOrder} from "@/api/hazardousChemicals/orderWarehouse"; |
| | | |
| | | const dialogVisible = ref(false); |
| | | const title = ref(""); |
| | |
| | | const state = reactive({ |
| | | form: { |
| | | id: '', |
| | | checkId: null, |
| | | checkName:'', |
| | | subscribeHazmats:[], |
| | | companyId:null, |
| | | cupboardId: null, |
| | | warehouseId:null, |
| | | batchNo:'', |
| | | subscribeNum:'', |
| | | num:'', |
| | | warehouseName:'', |
| | | subscribeHazmats:[] |
| | | }, |
| | | orderName:'', |
| | | orderList:[], |
| | | wareHouseList: [], |
| | | cupList: [], |
| | | subscribePersonId:null, |
| | | formRules:{ |
| | | checkId: [{ required: true, message: '请选择审核人', trigger: 'blur' }], |
| | | filePath:[{ required: true, message: '请上传文件', trigger: 'blur' }], |
| | | hazmatName: [{ required: true, message: '', trigger: 'blur' }], |
| | | hazmatCount: [{ required: true, message: '', trigger: 'blur' }], |
| | | warehouseName: [{ required: true, message: '请选择主柜', trigger: 'blur' }], |
| | | cupboardId:[{ required: true, message: '请选择副柜', trigger: 'blur' }], |
| | | subscribeNum: [{ required: true, message: '请选择申购订单', trigger: 'blur' }], |
| | | }, |
| | | |
| | | }) |
| | | |
| | | |
| | | const openDialog = async (type, value) => { |
| | | await getOrderList("") |
| | | await getWareHouseList("") |
| | | title.value = type === 'add' ? '申购申请' : type ==='edit' ? '申购编辑' : '查看' ; |
| | | const userInfo= JSON.parse(Cookies.get('userInfo')) |
| | | state.subscribePersonId = userInfo.id |
| | | title.value = type === 'add' ? '订单入库' : type ==='edit' ? '编辑' : '查看' ; |
| | | if(type === 'edit' || type === 'view') { |
| | | state.form = JSON.parse(JSON.stringify(value)); |
| | | if(state.form.filePath) { |
| | | const obj = { |
| | | url: value.filePath, |
| | | name: value.fileName |
| | | } |
| | | state.fileList = [obj] |
| | | } |
| | | Object.keys(value).forEach(key => key in state.form && (state.form[key] = value[key])); |
| | | state.form.subscribeHazmats = value.subscribe.subscribeHazmats |
| | | state.form.warehouseName = value.warehouse.name |
| | | state.form.companyId = userInfo.companyId |
| | | await getCupList(state.form.warehouseId) |
| | | } |
| | | state.form.batchNo = moment(new Date()).format("YYYYMMDD") |
| | | dialogVisible.value = true; |
| | |
| | | const onSubmit = async () => { |
| | | const valid = await busRef.value.validate(); |
| | | if(valid){ |
| | | if(title.value === '申购申请'){ |
| | | const {id, ...data} = JSON.parse(JSON.stringify(state.form)) |
| | | const res = await addSubscribe(data) |
| | | state.form.num = state.form.subscribeHazmats.reduce((sum, item) => sum + item.hazmatCount, 0) |
| | | if(title.value === '订单入库'){ |
| | | const {id,subscribeHazmats,warehouseName,companyId, ...data} = JSON.parse(JSON.stringify(state.form)) |
| | | const res = await addOrder(data) |
| | | if(res.code === 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | busRef.value.clearValidate(); |
| | | reset(); |
| | | dialogVisible.value = false; |
| | | }else if(title.value === '申购编辑'){ |
| | | const {...data} = JSON.parse(JSON.stringify(state.form)) |
| | | const res = await editSubscribe(data) |
| | | }else if(title.value === '编辑'){ |
| | | const {subscribeHazmats,warehouseName,...data} = JSON.parse(JSON.stringify(state.form)) |
| | | const res = await editOrder(data) |
| | | if(res.code === 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | const reset = () => { |
| | | state.form = { |
| | | id: '', |
| | | checkId: null, |
| | | filePath: '', |
| | | fileName: '', |
| | | companyId:null, |
| | | cupboardId: null, |
| | | warehouseId:null, |
| | | batchNo:'', |
| | | subscribeNum:'', |
| | | num:'', |
| | | subscribeHazmats:[], |
| | | warehouseName:'' |
| | | } |
| | | state.subscribePersonId = null |
| | | state.orderName = '' |
| | | } |
| | | const selectValue = (val) => { |
| | | state.form.orderId = null |
| | | if(!val){ |
| | | state.form.subscribeHazmats = [] |
| | | return |
| | | } |
| | | state.orderList.forEach(item => { |
| | | if(item.subscribeNum === val){ |
| | | state.form.orderId = item.id |
| | | state.form.subscribeHazmats = item.subscribeHazmats |
| | | } |
| | | }) |
| | | const match = state.orderList.find(i => i.subscribeNum == val) |
| | | if(match){ |
| | | state.form.subscribeHazmats = match.subscribeHazmats |
| | | } |
| | | } |
| | | const getOrderList = async (val) => { |
| | | let param = {} |
| | | if(val != ""){ |
| | | param = { |
| | | name: val, |
| | | status: 1 |
| | | subscribeNum: val, |
| | | status: 1, |
| | | subscribePersonId:state.subscribePersonId |
| | | } |
| | | }else { |
| | | param = { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | status: 1 |
| | | status: 1, |
| | | subscribePersonId:state.subscribePersonId |
| | | } |
| | | } |
| | | const res = await getSubscribeList(param) |