|
@@ -54,25 +54,48 @@
|
|
|
<div>{{ baseLot.prodNum }}</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="工序合格数量:">
|
|
|
+ <div>{{ baseLot.qualifiedNum }}</div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="当前载具:">
|
|
|
+ <div>{{ baseLot.carriers.map(v => v.code).join(',') }}</div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="24">
|
|
|
<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" :max="10" />
|
|
|
+ <el-input-number v-model="baseLot.sparateNum" :controls="false" @blur="handleNumBlur" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
<el-divider />
|
|
|
<el-row v-for="(e, i) in baseLot.sparateList" :key="i">
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="分批批次号:">
|
|
|
<el-input disabled v-model="e.lotCode" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="5">
|
|
|
<el-form-item label="分批数量:">
|
|
|
<el-input-number v-model="e.lotNumber" :controls="false" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="5">
|
|
|
+ <el-form-item label="合格数量:">
|
|
|
+ <el-input-number v-model="e.qualifiedNum" :controls="false" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="分批载具:">
|
|
|
+ <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%" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -85,15 +108,20 @@
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-import { getLotInfoForInBatches } from '@/api/business/lot'
|
|
|
+import { getLotInfoForInBatches, listCarriers, saveInBatches } from '@/api/business/lot'
|
|
|
+// import {}
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
/**工段弹窗变量 */
|
|
|
const total = ref(0);
|
|
|
-const baseLot = ref({})
|
|
|
+const baseLot = ref({
|
|
|
+ carriers: []
|
|
|
+})
|
|
|
const selections = ref([]);
|
|
|
const visible = ref(false);
|
|
|
const deptIds = ref([])
|
|
|
const loading = ref(false);
|
|
|
+const carriers = ref([])
|
|
|
+const loadingCarrier = ref(true)
|
|
|
/**查询对象 */
|
|
|
const data = reactive({
|
|
|
queryParams: {
|
|
@@ -109,18 +137,44 @@ const { queryParams } = toRefs(data);
|
|
|
* 对话框打开 事件
|
|
|
*/
|
|
|
function open(data) {
|
|
|
- baseLot.value = { ...data, id: data.lotId }
|
|
|
+ baseLot.value = { ...data, id: data.lotId, carriers: [] }
|
|
|
visible.value = true;
|
|
|
loadLot();
|
|
|
+ getCarriers()
|
|
|
+}
|
|
|
+
|
|
|
+function getCarriers() {
|
|
|
+ listCarriers({ isAbandoned: 0 }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ carriers.value = res.rows.map(v => ({ value: v.id, label: v.code }))
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
+// 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 loadLot() {
|
|
|
getLotInfoForInBatches({ id: baseLot.value.id }).then(res => {
|
|
|
- baseLot.value.issueDate = res.data.issueDate
|
|
|
- baseLot.value.prodNum = res.data.prodNum
|
|
|
- baseLot.value.currentDept = res.data.currentDept
|
|
|
- baseLot.value.sparateList = []
|
|
|
- baseLot.value.sparateNum = 0
|
|
|
+ if (res.code === 200) {
|
|
|
+ baseLot.value.issueDate = res.data.issueDate
|
|
|
+ baseLot.value.prodNum = res.data.prodNum
|
|
|
+ baseLot.value.currentDept = res.data.currentDept
|
|
|
+ baseLot.value.sparateList = []
|
|
|
+ baseLot.value.qualifiedNum = res.data.qualifiedNum
|
|
|
+ baseLot.value.carriers = res.data.carriers
|
|
|
+ baseLot.value.sparateNum = 0
|
|
|
+ baseLot.value.latestLotCode = res.data.latestLotCode
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -148,13 +202,16 @@ function handleMultipleSelected() {
|
|
|
}
|
|
|
|
|
|
function handleSave() {
|
|
|
- console.log(baseLot.value)
|
|
|
+ // console.log(baseLot.value)
|
|
|
// 保存时判断下分批数量和是否等于投产数量。不等要提示一下
|
|
|
let num = 0
|
|
|
+ let qualified = 0
|
|
|
baseLot.value.sparateList.forEach(e => {
|
|
|
num += e.prodNum
|
|
|
+ qualified += e.qualifiedNum
|
|
|
})
|
|
|
const prodNum = !!baseLot.value.prodNum ? baseLot.value.prodNum : baseLot.value.productionQuantity
|
|
|
+ const qualifiedNum = !!baseLot.value.qualifiedNum ? baseLot.value.qualifiedNum : 0
|
|
|
if (num != prodNum) {
|
|
|
proxy.$message({
|
|
|
type: 'warning',
|
|
@@ -162,34 +219,65 @@ function handleSave() {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ if (qualified != qualifiedNum) {
|
|
|
+ proxy.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '分批合格数量需等于总合格数量'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const saveDate = { ...baseLot.value, sparateList: baseLot.value.sparateList.map(v => ({ ...v, carriers: v.id === baseLot.id ? v.carriers : carrierSelection.map(e => ({ id: e })) })) }
|
|
|
// 提交分批结果
|
|
|
-
|
|
|
+ saveInBatches(saveDate).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ proxy.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '分批成功'
|
|
|
+ })
|
|
|
+ close()
|
|
|
+ } else {
|
|
|
+ proxy.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: res.message
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function handleNumBlur() {
|
|
|
- // console.log('blur number')
|
|
|
// 分批数量修改
|
|
|
baseLot.value.sparateList = []
|
|
|
const prodNum = !!baseLot.value.prodNum ? baseLot.value.prodNum : baseLot.value.productionQuantity
|
|
|
const arg = baseLot.value.sparateNum
|
|
|
+ const latestLotCode = baseLot.value.latestLotCode
|
|
|
+ if ((latestLotCode.charAt(latestLotCode.length - 1) + arg - 1) > 9) {
|
|
|
+ proxy.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '总分批书里不能大于9'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
for (let i = 0; i < arg; i++) {
|
|
|
const item = { ...baseLot.value }
|
|
|
if (i === 0) {
|
|
|
// 第一条
|
|
|
item.lotNumber = Math.ceil(prodNum / 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.lotCode.slice(0, -1) + i
|
|
|
+ item.lotCode = baseLot.value.latestLotCode.slice(0, -1) + (Number(latestLotCode.charAt(latestLotCode.length - 1)) + i)
|
|
|
item.id = null
|
|
|
item.lotId = null
|
|
|
item.last = 0
|
|
|
+ item.carrierSelection = []
|
|
|
} else {
|
|
|
item.id = null
|
|
|
item.lotId = null
|
|
|
- item.lotCode = baseLot.value.lotCode.slice(0, -1) + i
|
|
|
+ item.lotCode = baseLot.value.latestLotCode.slice(0, -1) + (Number(latestLotCode.charAt(latestLotCode.length - 1)) + i)
|
|
|
item.lotNumber = Math.ceil(prodNum / arg)
|
|
|
item.fromId = baseLot.value.id
|
|
|
item.last = 0
|
|
|
+ item.carrierSelection = []
|
|
|
}
|
|
|
baseLot.value.sparateList.push(item)
|
|
|
}
|