完善物料监控功能迁移
Some checks failed
Release pipeline / publish (push) Has been cancelled
Release pipeline / Always run job (push) Has been cancelled

This commit is contained in:
sheng
2026-06-25 15:35:32 +08:00
parent 169de64f21
commit 7cb026fc71

View File

@@ -28,7 +28,7 @@
clearable clearable
filterable filterable
style="width:200px" style="width:200px"
@focus="loadBatchOptions" @focus="loadProcessOptions"
> >
<el-option <el-option
v-for="item in processOptions" v-for="item in processOptions"
@@ -82,14 +82,28 @@
</template> </template>
</page-table> </page-table>
<el-dialog :title="$t(key('input_semi_product_data'))" :visible.sync="dialogVisible" width="520px"> <page-dialog-form
<el-form ref="form" :model="form" :rules="rules" label-width="130px" size="mini"> ref="dialogForm"
:visible.sync="dialogVisible"
:title="key('input_semi_product_data')"
width="520px"
:form-cols="[]"
:form-data="form"
:rules="rules"
label-width="130px"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="submitForm"
@close="onDialogClose"
>
<el-form-item :label="$t(key('batch_id'))" prop="batch_id"> <el-form-item :label="$t(key('batch_id'))" prop="batch_id">
<el-select <el-select
v-model="form.batch_id" v-model="form.batch_id"
:placeholder="$t(key('select_batch_id'))" :placeholder="$t(key('select_batch_id'))"
clearable clearable
filterable filterable
size="mini"
style="width:100%" style="width:100%"
@focus="loadBatchOptions" @focus="loadBatchOptions"
@change="onBatchChange" @change="onBatchChange"
@@ -108,6 +122,7 @@
:placeholder="$t(key('select_workingsubclass'))" :placeholder="$t(key('select_workingsubclass'))"
clearable clearable
filterable filterable
size="mini"
style="width:100%" style="width:100%"
:disabled="!form.batch_id" :disabled="!form.batch_id"
> >
@@ -125,6 +140,7 @@
:placeholder="$t(key('select_device_code'))" :placeholder="$t(key('select_device_code'))"
clearable clearable
filterable filterable
size="mini"
style="width:100%" style="width:100%"
@focus="loadDeviceOptions" @focus="loadDeviceOptions"
> >
@@ -137,39 +153,36 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t(key('output_quantity'))" prop="item_quantity"> <el-form-item :label="$t(key('output_quantity'))" prop="item_quantity">
<el-input-number v-model="form.item_quantity" :min="1" style="width:100%" /> <el-input-number v-model="form.item_quantity" :min="1" size="mini" style="width:100%" />
</el-form-item> </el-form-item>
<el-form-item :label="$t(key('output_date'))" prop="start_time"> <el-form-item :label="$t(key('output_date'))" prop="start_time">
<el-date-picker <el-date-picker
v-model="form.start_time" v-model="form.start_time"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
size="mini"
style="width:100%" style="width:100%"
:placeholder="$t(key('output_date'))" :placeholder="$t(key('output_date'))"
/> />
</el-form-item> </el-form-item>
</el-form> </page-dialog-form>
<span slot="footer">
<el-button size="mini" @click="dialogVisible = false">{{ $t(key('cancel')) }}</el-button>
<el-button size="mini" type="primary" :loading="submitting" @click="submitForm">
{{ $t(key('confirm')) }}
</el-button>
</span>
</el-dialog>
</d2-container> </d2-container>
</template> </template>
<script> <script>
import { useTableColumns } from '@/composables/useTableColumns' import { useTableColumns } from '@/composables/useTableColumns'
import useTableButtons from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n' import { i18nMixin } from '@/composables/useI18n'
import PageTable from '@/components/page-table' import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
import { getBatchAll } from '@/api/planning-production/batch-list' import { getBatchAll } from '@/api/planning-production/batch-list'
import { getDeviceAll } from '@/api/planning-production/equipment-monitoring' import { getDeviceAll } from '@/api/planning-production/equipment-monitoring'
import { createWipData, getWipDataList } from '@/api/planning-production/material-monitoring' import { createWipData, getWipDataList } from '@/api/planning-production/material-monitoring'
import { getWorkingsubclassAll } from '@/api/production-master-data/process-step'
export default { export default {
name: 'planning-production-material-monitoring', name: 'planning-production-material-monitoring',
components: { PageTable }, components: { PageTable, PageDialogForm },
mixins: [i18nMixin('page.planning_production.production_monitoring.material_monitoring')], mixins: [i18nMixin('page.planning_production.production_monitoring.material_monitoring')],
data () { data () {
return { return {
@@ -196,7 +209,8 @@ export default {
start_time: '' start_time: ''
}, },
batchOptions: [], batchOptions: [],
deviceOptions: [] deviceOptions: [],
processOptions: []
} }
}, },
computed: { computed: {
@@ -216,23 +230,26 @@ export default {
}) })
}, },
toolbarButtons () { toolbarButtons () {
return [ return useTableButtons({
toolbar: [
{ {
key: 'create', key: 'create',
label: this.key('input_semi_product_data'), label: this.key('input_semi_product_data'),
type: 'primary', type: 'primary',
icon: 'el-icon-plus', icon: 'el-icon-plus',
size: 'mini', size: 'mini',
auth: '/planning_production/production_batch_management/batch/create',
onClick: this.openDialog onClick: this.openDialog
} }
] ]
}, this.$permission).toolbarButtons
}, },
rules () { rules () {
return { return {
batch_id: [{ required: true, message: this.$t(this.key('select_batch_id')), trigger: 'change' }], batch_id: [{ required: true, message: this.key('select_batch_id'), trigger: 'change' }],
process_code: [{ required: true, message: this.$t(this.key('select_workingsubclass')), trigger: 'change' }], process_code: [{ required: true, message: this.key('select_workingsubclass'), trigger: 'change' }],
device_code: [{ required: true, message: this.$t(this.key('select_device_code')), trigger: 'change' }], device_code: [{ required: true, message: this.key('select_device_code'), trigger: 'change' }],
item_quantity: [{ required: true, message: this.$t(this.key('enter_output_quantity')), trigger: 'blur' }] item_quantity: [{ required: true, message: this.key('enter_output_quantity'), trigger: 'change' }]
} }
}, },
selectedBatch () { selectedBatch () {
@@ -240,25 +257,36 @@ export default {
}, },
selectedBatchProcesses () { selectedBatchProcesses () {
return Array.isArray(this.selectedBatch.process) ? this.selectedBatch.process : [] return Array.isArray(this.selectedBatch.process) ? this.selectedBatch.process : []
},
processOptions () {
const map = new Map()
this.batchOptions.forEach(batch => {
const processes = Array.isArray(batch.process) ? batch.process : []
processes.forEach(item => {
const value = item.code || item.name
if (value && !map.has(value)) map.set(value, item)
})
})
return Array.from(map.values())
} }
}, },
created () { created () {
this.fetchData() this.fetchData()
}, },
methods: { methods: {
responseData (res) { normalizePayload (res) {
return res && res.data ? res.data : (res || {}) if (res && res.code !== undefined && res.data !== undefined) return res.data
return res || {}
},
normalizeList (res) {
const payload = this.normalizePayload(res)
if (Array.isArray(payload)) return payload
if (Array.isArray(payload.data)) return payload.data
if (payload.data && Array.isArray(payload.data.data)) return payload.data.data
return []
},
normalizePage (res) {
const payload = this.normalizePayload(res)
if (Array.isArray(payload)) return { data: payload, count: payload.length }
if (payload.data && !Array.isArray(payload.data)) {
return {
data: Array.isArray(payload.data.data) ? payload.data.data : [],
count: Number(payload.data.count || 0)
}
}
return {
data: Array.isArray(payload.data) ? payload.data : [],
count: Number(payload.count || 0)
}
}, },
searchParams () { searchParams () {
const params = { const params = {
@@ -280,9 +308,9 @@ export default {
page_no: this.pagination.current, page_no: this.pagination.current,
page_size: this.pagination.size page_size: this.pagination.size
}) })
const payload = this.responseData(res) const payload = this.normalizePage(res)
this.tableData = Array.isArray(payload.data) ? payload.data : [] this.tableData = payload.data
this.pagination.total = Number(payload.count || 0) this.pagination.total = payload.count
} finally { } finally {
this.loading = false this.loading = false
} }
@@ -314,7 +342,7 @@ export default {
start_time: '' start_time: ''
} }
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.form) this.$refs.form.clearValidate() if (this.$refs.dialogForm) this.$refs.dialogForm.reset()
}) })
this.loadBatchOptions() this.loadBatchOptions()
this.loadDeviceOptions() this.loadDeviceOptions()
@@ -322,21 +350,25 @@ export default {
async loadBatchOptions () { async loadBatchOptions () {
if (this.batchOptions.length) return if (this.batchOptions.length) return
const res = await getBatchAll({}) const res = await getBatchAll({})
const data = Array.isArray(res) ? res : (res && res.data) || [] this.batchOptions = this.normalizeList(res)
this.batchOptions = Array.isArray(data) ? data : []
}, },
async loadDeviceOptions () { async loadDeviceOptions () {
if (this.deviceOptions.length) return if (this.deviceOptions.length) return
const res = await getDeviceAll({}) const res = await getDeviceAll({})
const payload = this.responseData(res) this.deviceOptions = this.normalizeList(res)
this.deviceOptions = Array.isArray(payload.data) ? payload.data : [] },
async loadProcessOptions () {
if (this.processOptions.length) return
const res = await getWorkingsubclassAll({})
this.processOptions = this.normalizeList(res)
}, },
onBatchChange () { onBatchChange () {
this.form.process_code = '' this.form.process_code = ''
}, },
submitForm () { onDialogClose () {
this.$refs.form.validate(async valid => { this.submitting = false
if (!valid) return },
async submitForm () {
this.submitting = true this.submitting = true
try { try {
await createWipData({ ...this.form }) await createWipData({ ...this.form })
@@ -346,7 +378,6 @@ export default {
} finally { } finally {
this.submitting = false this.submitting = false
} }
})
} }
} }
} }