|
@@ -68,7 +68,7 @@
|
|
|
<div style="display: flex; flex-direction: row;">
|
|
|
<div style="line-height: 32px;">分批信息</div>
|
|
|
<el-form-item label="分批数量" style="margin-bottom: 0px;">
|
|
|
- <el-input-number v-model="baseLot.sparateNum" :controls="false" @blur="handleNumBlur" />
|
|
|
+ <el-input-number v-model="baseLot.sparateNum" :controls="false" @blur="handleNumBlur" :max="10" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
<el-divider />
|
|
@@ -90,10 +90,16 @@
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="分批载具:">
|
|
|
- <el-select-v2 v-model="e.carrierSelection"
|
|
|
+ <!-- <el-select-v2 v-model="e.carrierSelection"
|
|
|
:disabled="e.id === baseLot.id || baseLot.currentDept == null" multiple filterable
|
|
|
collapse-tags-tooltip collapse-tags clearable :options="carriers" placeholder="请选择载具"
|
|
|
- style="width: 100%" />
|
|
|
+ style="width: 100%" /> -->
|
|
|
+ <el-select v-model="e.carrierSelection" :disabled="e.id === baseLot.id || baseLot.currentDept == null"
|
|
|
+ multiple filterable remote reserve-keyword placeholder="请选择载具" collapse-tags-tooltip collapse-tags
|
|
|
+ :remote-method="(arg) => remoteCarriers(arg, e.carriers)" :loading="loadingCarrier"
|
|
|
+ @change="(arg) => handleCarrierChange(arg, e)">
|
|
|
+ <el-option v-for="item in carriers" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -109,8 +115,16 @@
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { getLotInfoForInBatches, listCarriers, saveInBatches } from '@/api/business/lot'
|
|
|
+import { toRefs } from 'vue';
|
|
|
// import {}
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
+const props = defineProps({
|
|
|
+ getList: {
|
|
|
+ type: Function,
|
|
|
+ default: () => { }
|
|
|
+ }
|
|
|
+})
|
|
|
+const { getList } = toRefs(props);
|
|
|
/**工段弹窗变量 */
|
|
|
const total = ref(0);
|
|
|
const baseLot = ref({
|
|
@@ -144,24 +158,32 @@ function open(data) {
|
|
|
}
|
|
|
|
|
|
function getCarriers() {
|
|
|
- listCarriers({ isAbandoned: 0 }).then(res => {
|
|
|
+ listCarriers({ isAbandoned: 0, pageSize: 200 }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ carriers.value.push(...res.rows.map(v => ({ value: v.id, label: v.code })))
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function remoteCarriers(queryString, choiced) {
|
|
|
+ loadingCarrier.value = true
|
|
|
+ listCarriers({ isAbandoned: 0, pageSize: 200, code: queryString != '' ? queryString : null }).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
carriers.value = res.rows.map(v => ({ value: v.id, label: v.code }))
|
|
|
+ carriers.value.push(...choiced.filter(v => !carriers.value.map(e => e.value).includes(v.id)).map(v => ({ value: v.id, label: v.code })))
|
|
|
+ } else {
|
|
|
+ carriers.value = []
|
|
|
+ carriers.value.push(...choiced)
|
|
|
}
|
|
|
+ console.log(carriers.value)
|
|
|
+ loadingCarrier.value = false
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// function remoteCarriers(queryString) {
|
|
|
-// loadingCarrier.value = true
|
|
|
-// listCarriers({ isAbandoned: 0, pageSize: 200, code: queryString != '' ? queryString : null }).then(res => {
|
|
|
-// if (res.code === 200) {
|
|
|
-// carriers.value = res.rows.map(v => ({ value: v.id, label: v.code }))
|
|
|
-// } else {
|
|
|
-// carriers.value = []
|
|
|
-// }
|
|
|
-// loadingCarrier.value = false
|
|
|
-// })
|
|
|
-// }
|
|
|
+function handleCarrierChange(arg, item) {
|
|
|
+ item.carriers = carriers.value.filter(v => arg.includes(v.value)).map(v => ({ id: v.value, code: v.label }))
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
function loadLot() {
|
|
|
getLotInfoForInBatches({ id: baseLot.value.id }).then(res => {
|
|
@@ -174,6 +196,8 @@ function loadLot() {
|
|
|
baseLot.value.carriers = res.data.carriers
|
|
|
baseLot.value.sparateNum = 0
|
|
|
baseLot.value.latestLotCode = res.data.latestLotCode
|
|
|
+ baseLot.value.productId = res.data.productId
|
|
|
+ carriers.value.push(...res.data.carriers.map(v => ({ value: v.id, label: v.code })))
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -207,7 +231,7 @@ function handleSave() {
|
|
|
let num = 0
|
|
|
let qualified = 0
|
|
|
baseLot.value.sparateList.forEach(e => {
|
|
|
- num += e.prodNum
|
|
|
+ num += e.lotNumber
|
|
|
qualified += e.qualifiedNum
|
|
|
})
|
|
|
const prodNum = !!baseLot.value.prodNum ? baseLot.value.prodNum : baseLot.value.productionQuantity
|
|
@@ -226,7 +250,10 @@ function handleSave() {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- const saveDate = { ...baseLot.value, sparateList: baseLot.value.sparateList.map(v => ({ ...v, carriers: v.id === baseLot.id ? v.carriers : carrierSelection.map(e => ({ id: e })) })) }
|
|
|
+ // const saveDate = { ...baseLot.value, sparateList: baseLot.value.sparateList.map(v => ({ ...v, carriers: v.id === baseLot.id ? v.carriers : v.carrierSelection.map(e => ({ id: e })) })) }
|
|
|
+ // const saveDate = { ...baseLot.value }
|
|
|
+ const saveDate = { id: baseLot.value.id, lotCode: baseLot.value.lotCode, sparateList: baseLot.value.sparateList.map(v => ({ id: v.id, fromId: v.fromId, lotNumber: v.lotNumber, qualifiedNum: v.qualifiedNum, productionPlanDetailId: v.productionPlanDetailId, technologicalProcessId: v.technologicalProcessId, technologyVersion: v.technologyVersion, productId: v.productId, productionQuantity: v.lotNumber, lotCode: v.lotCode, carriers: v.id === baseLot.id ? v.carriers : v.carrierSelection.map(e => ({ id: e })) })) }
|
|
|
+
|
|
|
// 提交分批结果
|
|
|
saveInBatches(saveDate).then(res => {
|
|
|
if (res.code === 200) {
|
|
@@ -235,6 +262,7 @@ function handleSave() {
|
|
|
message: '分批成功'
|
|
|
})
|
|
|
close()
|
|
|
+ getList.value()
|
|
|
} else {
|
|
|
proxy.$message({
|
|
|
type: 'error',
|
|
@@ -248,9 +276,11 @@ function handleNumBlur() {
|
|
|
// 分批数量修改
|
|
|
baseLot.value.sparateList = []
|
|
|
const prodNum = !!baseLot.value.prodNum ? baseLot.value.prodNum : baseLot.value.productionQuantity
|
|
|
+ const qualifiedNum = !!baseLot.value.qualifiedNum ? baseLot.value.qualifiedNum : 0
|
|
|
const arg = baseLot.value.sparateNum
|
|
|
const latestLotCode = baseLot.value.latestLotCode
|
|
|
- if ((latestLotCode.charAt(latestLotCode.length - 1) + arg - 1) > 9) {
|
|
|
+ // debugger
|
|
|
+ if ((Number(latestLotCode.charAt(latestLotCode.length - 1)) + arg - 1) > 9) {
|
|
|
proxy.$message({
|
|
|
type: 'warning',
|
|
|
message: '总分批书里不能大于9'
|
|
@@ -262,10 +292,13 @@ function handleNumBlur() {
|
|
|
if (i === 0) {
|
|
|
// 第一条
|
|
|
item.lotNumber = Math.ceil(prodNum / arg)
|
|
|
+ item.qualifiedNum = Math.ceil(qualifiedNum / arg)
|
|
|
item.carrierSelection = baseLot.value.carriers.map(v => v.id)
|
|
|
} else if ((i + 1) === arg) {
|
|
|
item.lotNumber = prodNum - (Math.ceil(prodNum / arg) * (arg - 1))
|
|
|
item.lotCode = baseLot.value.latestLotCode.slice(0, -1) + (Number(latestLotCode.charAt(latestLotCode.length - 1)) + i)
|
|
|
+ item.qualifiedNum = qualifiedNum - (Math.ceil(qualifiedNum / arg) * (arg - 1))
|
|
|
+ item.fromId = baseLot.value.id
|
|
|
item.id = null
|
|
|
item.lotId = null
|
|
|
item.last = 0
|
|
@@ -273,8 +306,10 @@ function handleNumBlur() {
|
|
|
} else {
|
|
|
item.id = null
|
|
|
item.lotId = null
|
|
|
+ item.fromId = baseLot.value.id
|
|
|
item.lotCode = baseLot.value.latestLotCode.slice(0, -1) + (Number(latestLotCode.charAt(latestLotCode.length - 1)) + i)
|
|
|
item.lotNumber = Math.ceil(prodNum / arg)
|
|
|
+ item.qualifiedNum = Math.ceil(qualifiedNum / arg)
|
|
|
item.fromId = baseLot.value.id
|
|
|
item.last = 0
|
|
|
item.carrierSelection = []
|