完善物料监控功能迁移
This commit is contained in:
@@ -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,94 +82,107 @@
|
|||||||
</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"
|
||||||
<el-form-item :label="$t(key('batch_id'))" prop="batch_id">
|
:visible.sync="dialogVisible"
|
||||||
<el-select
|
:title="key('input_semi_product_data')"
|
||||||
v-model="form.batch_id"
|
width="520px"
|
||||||
:placeholder="$t(key('select_batch_id'))"
|
:form-cols="[]"
|
||||||
clearable
|
:form-data="form"
|
||||||
filterable
|
:rules="rules"
|
||||||
style="width:100%"
|
label-width="130px"
|
||||||
@focus="loadBatchOptions"
|
:submitting="submitting"
|
||||||
@change="onBatchChange"
|
:confirm-text="key('confirm')"
|
||||||
>
|
:cancel-text="key('cancel')"
|
||||||
<el-option
|
@submit="submitForm"
|
||||||
v-for="item in batchOptions"
|
@close="onDialogClose"
|
||||||
:key="item.id"
|
>
|
||||||
:label="item.batch"
|
<el-form-item :label="$t(key('batch_id'))" prop="batch_id">
|
||||||
:value="item.id"
|
<el-select
|
||||||
/>
|
v-model="form.batch_id"
|
||||||
</el-select>
|
:placeholder="$t(key('select_batch_id'))"
|
||||||
</el-form-item>
|
clearable
|
||||||
<el-form-item :label="$t(key('workingsubclass'))" prop="process_code">
|
filterable
|
||||||
<el-select
|
size="mini"
|
||||||
v-model="form.process_code"
|
style="width:100%"
|
||||||
:placeholder="$t(key('select_workingsubclass'))"
|
@focus="loadBatchOptions"
|
||||||
clearable
|
@change="onBatchChange"
|
||||||
filterable
|
>
|
||||||
style="width:100%"
|
<el-option
|
||||||
:disabled="!form.batch_id"
|
v-for="item in batchOptions"
|
||||||
>
|
:key="item.id"
|
||||||
<el-option
|
:label="item.batch"
|
||||||
v-for="item in selectedBatchProcesses"
|
:value="item.id"
|
||||||
:key="item.code || item.name"
|
|
||||||
:label="item.name || item.code"
|
|
||||||
:value="item.code || item.name"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="$t(key('device_code'))" prop="device_code">
|
|
||||||
<el-select
|
|
||||||
v-model="form.device_code"
|
|
||||||
:placeholder="$t(key('select_device_code'))"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
style="width:100%"
|
|
||||||
@focus="loadDeviceOptions"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in deviceOptions"
|
|
||||||
:key="item.code || item.device_code"
|
|
||||||
:label="item.name || item.device_name || item.code || item.device_code"
|
|
||||||
:value="item.code || item.device_code"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<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-form-item>
|
|
||||||
<el-form-item :label="$t(key('output_date'))" prop="start_time">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="form.start_time"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
style="width:100%"
|
|
||||||
:placeholder="$t(key('output_date'))"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-select>
|
||||||
</el-form>
|
</el-form-item>
|
||||||
<span slot="footer">
|
<el-form-item :label="$t(key('workingsubclass'))" prop="process_code">
|
||||||
<el-button size="mini" @click="dialogVisible = false">{{ $t(key('cancel')) }}</el-button>
|
<el-select
|
||||||
<el-button size="mini" type="primary" :loading="submitting" @click="submitForm">
|
v-model="form.process_code"
|
||||||
{{ $t(key('confirm')) }}
|
:placeholder="$t(key('select_workingsubclass'))"
|
||||||
</el-button>
|
clearable
|
||||||
</span>
|
filterable
|
||||||
</el-dialog>
|
size="mini"
|
||||||
|
style="width:100%"
|
||||||
|
:disabled="!form.batch_id"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in selectedBatchProcesses"
|
||||||
|
:key="item.code || item.name"
|
||||||
|
:label="item.name || item.code"
|
||||||
|
:value="item.code || item.name"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t(key('device_code'))" prop="device_code">
|
||||||
|
<el-select
|
||||||
|
v-model="form.device_code"
|
||||||
|
:placeholder="$t(key('select_device_code'))"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
size="mini"
|
||||||
|
style="width:100%"
|
||||||
|
@focus="loadDeviceOptions"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in deviceOptions"
|
||||||
|
:key="item.code || item.device_code"
|
||||||
|
:label="item.name || item.device_name || item.code || item.device_code"
|
||||||
|
:value="item.code || item.device_code"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t(key('output_quantity'))" prop="item_quantity">
|
||||||
|
<el-input-number v-model="form.item_quantity" :min="1" size="mini" style="width:100%" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t(key('output_date'))" prop="start_time">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="form.start_time"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
size="mini"
|
||||||
|
style="width:100%"
|
||||||
|
:placeholder="$t(key('output_date'))"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</page-dialog-form>
|
||||||
</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',
|
{
|
||||||
label: this.key('input_semi_product_data'),
|
key: 'create',
|
||||||
type: 'primary',
|
label: this.key('input_semi_product_data'),
|
||||||
icon: 'el-icon-plus',
|
type: 'primary',
|
||||||
size: 'mini',
|
icon: 'el-icon-plus',
|
||||||
onClick: this.openDialog
|
size: 'mini',
|
||||||
}
|
auth: '/planning_production/production_batch_management/batch/create',
|
||||||
]
|
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,31 +350,34 @@ 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
|
},
|
||||||
this.submitting = true
|
async submitForm () {
|
||||||
try {
|
this.submitting = true
|
||||||
await createWipData({ ...this.form })
|
try {
|
||||||
this.$message.success(this.$t(this.key('operation_success')))
|
await createWipData({ ...this.form })
|
||||||
this.dialogVisible = false
|
this.$message.success(this.$t(this.key('operation_success')))
|
||||||
this.fetchData()
|
this.dialogVisible = false
|
||||||
} finally {
|
this.fetchData()
|
||||||
this.submitting = false
|
} finally {
|
||||||
}
|
this.submitting = false
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user