| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- <template>
- <div>
- <header-title title="物料清单"></header-title>
- <ele-pro-table
- ref="table"
- row-key="id"
- :columns="materialColumns"
- :datasource="materialList"
- cache-key="prenatal-examination-material-list-table-2511031522"
- autoAmendPage
- :needPage="false"
- @refresh="$emit('refresh', 'material')"
- >
- <template v-slot:toolbar>
- <el-button type="primary" @click="openMaterialModal"
- >添加物料</el-button
- >
- </template>
- <template v-slot:selectColumn="{ row }">
- <el-checkbox
- v-model="row.selected"
- @change="selectedChange(row)"
- ></el-checkbox>
- </template>
- </ele-pro-table>
- <header-title title="产出清单" style="margin-top: 20px"></header-title>
- <ele-pro-table
- ref="table"
- row-key="id"
- :columns="outputDetailsColumns"
- :datasource="localOutputDetails"
- cache-key="prenatal-examination-output-list-table-2511031523"
- autoAmendPage
- :needPage="false"
- @refresh="$emit('refresh', 'output')"
- >
- <template v-slot:reportQuantity="{ row }">
- <el-input-number
- size="small"
- v-model.number="row.reportQuantity"
- controls-position="right"
- :min="0"
- :max="row.feedQuantity"
- ></el-input-number>
- </template>
- <template v-slot:qualifiedQuantity="{ row }">
- <el-input-number
- size="small"
- v-model.number="row.qualifiedQuantity"
- controls-position="right"
- :min="0"
- :max="qualifiedQuantityMax(row)"
- ></el-input-number>
- </template>
- <template v-slot:noQualifiedQuantity="{ row }">
- <el-input-number
- size="small"
- v-model.number="row.noQualifiedQuantity"
- controls-position="right"
- :min="0"
- :max="noQualifiedQuantityMax(row)"
- ></el-input-number>
- </template>
- <template v-slot:msg="{ row }">
- <el-input
- v-model="row.msg"
- type="textarea"
- rows="1"
- autosize
- ></el-input>
- </template>
- </ele-pro-table>
- <materialModal ref="materialModalRef" @confirm="materialConfirm" />
- </div>
- </template>
- <script>
- import materialModal from './materialModal.vue';
- import {
- getMaterialQuotaInfo,
- getCategoryAndLevelByCategoryId
- } from '@/api/producetaskrecordrulesrecord/index';
- export default {
- components: {
- materialModal
- },
- props: {
- // 物料明细
- pickDetails: {
- type: Array,
- default: () => []
- },
- // 本次产出明细
- outputDetails: {
- type: Array,
- default: () => []
- },
- // 上到工序产出明细
- preOutputDetails: {
- type: Array,
- default: () => []
- },
- // 工单id
- workOrderId: {
- type: [String, Number],
- required: true
- },
- // 规则id
- ruleId: {
- type: [String, Number],
- required: true
- },
- // 工序id
- produceTaskId: {
- type: [String, Number],
- required: true
- },
- // BOM产品分类id
- bomCategoryId: {
- type: [String, Number],
- required: true
- },
- // 产出类型 1-物料本身 2-在制品 3-BOM标准产出
- outputType: {
- type: [Number],
- required: true
- },
- // 产品分类id
- categoryId: {
- type: [String, Number],
- required: false
- }
- },
- watch: {
- pickDetails: {
- handler(newVal) {
- this.localPickDetails = JSON.parse(JSON.stringify(newVal));
- },
- deep: true
- },
- outputDetails: {
- handler(newVal) {
- this.localOutputDetails = JSON.parse(JSON.stringify(newVal));
- },
- deep: true
- },
- bomCategoryId: {
- handler() {
- this.getMaterialQuotaInfo();
- }
- },
- produceTaskId: {
- handler() {
- this.getMaterialQuotaInfo();
- }
- },
- outputType: {
- handler() {
- // 重置产出明细
- this.localOutputDetails = [];
- // 根据不同的类型,重置物料明细
- if (this.outputType == 1) {
- this.$emit('update:outputDetails', this.localOutputDetails);
- // 1-物料本身
- } else if (this.outputType == 2) {
- // 2-在制品
- this.getCategoryAndLevelByCategoryId();
- } else {
- // 3 BOM标准产出
- this.getMaterialQuotaInfo();
- }
- }
- }
- },
- computed: {
- // 物料清单(包含上到工序产出明细)
- materialList() {
- return [...this.preOutputDetails, ...this.localPickDetails];
- },
- // 物料清单表头
- materialColumns() {
- const list = [
- {
- width: 45,
- type: 'index',
- columnKey: 'index',
- align: 'center'
- },
- {
- label: '类型',
- prop: 'categoryLevelNamePath',
- minWidth: 120
- },
- {
- label: '编码',
- prop: 'categoryCode',
- minWidth: 120
- },
- {
- label: '名称',
- prop: 'categoryName',
- minWidth: 120
- },
- {
- prop: 'model',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specifications',
- label: '规格',
- align: 'center',
- width: 160,
- showOverflowTooltip: true
- },
- {
- prop: 'brandNo',
- label: '牌号',
- align: 'center'
- },
- {
- label: '工序名称',
- prop: 'produceTaskName',
- minWidth: 120
- },
- {
- label: '数量',
- prop: 'feedQuantity',
- minWidth: 120,
- formatter: (row) => {
- return (row.quantity || '') + (row.unit || '');
- }
- }
- ];
- if (this.outputType == 1) {
- list.push({
- prop: '',
- label: '选择',
- slot: 'selectColumn',
- align: 'center',
- fixed: 'right'
- });
- }
- return list;
- }
- },
- data() {
- return {
- localPickDetails: JSON.parse(JSON.stringify(this.pickDetails)),
- localOutputDetails: JSON.parse(JSON.stringify(this.outputDetails)),
- materialQuotaInfo: null,
- // 产出清单表头
- outputDetailsColumns: [
- {
- width: 45,
- type: 'index',
- columnKey: 'index',
- align: 'center'
- },
- {
- label: '类型',
- prop: 'categoryLevelNamePath',
- minWidth: 120
- },
- {
- label: '编码',
- prop: 'categoryCode',
- minWidth: 120
- },
- {
- label: '名称',
- prop: 'categoryName',
- minWidth: 120
- },
- {
- prop: 'model',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specifications',
- label: '规格',
- align: 'center',
- width: 160,
- showOverflowTooltip: true
- },
- {
- prop: 'brandNo',
- label: '牌号',
- align: 'center'
- },
- {
- label: '工序名称',
- prop: 'produceTaskName',
- minWidth: 120
- },
- {
- label: '当次报工数量',
- prop: 'reportQuantity',
- minWidth: 160,
- slot: 'reportQuantity',
- formatter: (row) => {
- return (
- (row.reportQuantity == null ? '' : row.unit) +
- (row.feedUnit || '')
- );
- }
- },
- {
- label: '当次合格数量',
- prop: 'qualifiedQuantity',
- minWidth: 160,
- slot: 'qualifiedQuantity',
- formatter: (row) => {
- return (
- (row.qualifiedQuantity == null ? '' : row.unit) +
- (row.feedUnit || '')
- );
- }
- },
- {
- label: '当次不合格数量',
- prop: 'noQualifiedQuantity',
- minWidth: 160,
- slot: 'noQualifiedQuantity',
- formatter: (row) => {
- return (row.noQualifiedQuantity || 0) + (row.unit || '');
- }
- },
- {
- label: '不合格原因',
- prop: 'msg',
- minWidth: 160,
- slot: 'msg'
- },
- {
- label: '已报工数量',
- prop: 'sumReportQuantity',
- minWidth: 120,
- formatter(row) {
- return (row.sumReportQuantity || 0) + row.unit;
- }
- },
- {
- label: '合格总数',
- prop: 'sumQualifiedQuantity',
- minWidth: 120,
- formatter(row) {
- return (row.sumQualifiedQuantity || 0) + (row.unit || '');
- }
- },
- {
- label: '不合格总数',
- prop: 'sumNoQualifiedQuantity',
- minWidth: 120,
- formatter(row) {
- return (row.sumNoQualifiedQuantity || 0) + (row.unit || '');
- }
- }
- ]
- };
- },
- mounted() {
- if (this.outputType == 2) {
- this.getCategoryAndLevelByCategoryId();
- }
- if (this.outputType == 3) {
- this.getMaterialQuotaInfo();
- }
- },
- methods: {
- // 选择物料
- openMaterialModal() {
- this.$refs.materialModalRef.open(
- {
- workOrderId: this.workOrderId,
- ruleId: this.ruleId,
- produceTaskId: this.produceTaskId
- },
- []
- );
- },
- materialConfirm(data) {
- // 选择物料后添加
- console.log('data', data);
- data.forEach((newItem) => {
- const index = this.localPickDetails.findIndex(
- (item) =>
- item.categoryCode === newItem.categoryCode &&
- item.produceTaskInstanceId === newItem.produceTaskInstanceId
- );
- if (index !== -1) {
- // 存在则替换数量
- this.localPickDetails[index].quantity = newItem.quantity;
- } else {
- // 不存在则添加
- this.localPickDetails.push({ ...newItem });
- }
- });
- this.$emit('update:pickDetails', this.localPickDetails);
- },
- // 获取bom的产出
- async getMaterialQuotaInfo() {
- if (this.bomCategoryId && this.produceTaskId) {
- const data = await getMaterialQuotaInfo(
- this.bomCategoryId,
- this.produceTaskId
- );
- console.log('this.materialQuotaInfo', data);
- if (!data.standardOutput) {
- return this.$message.warning('未配置标准产出物料');
- }
- // 赋值产出
- this.localOutputDetails = [
- {
- ...data.standardOutput,
- reportQuantity: 0,
- qualifiedQuantity: 0,
- noQualifiedQuantity: 0,
- msg: '',
- sumReportQuantity: 0,
- sumQualifiedQuantity: 0,
- sumNoQualifiedQuantity: 0
- }
- ];
- this.$emit('update:outputDetails', this.localOutputDetails);
- console.log('this.localOutputDetails', this.localOutputDetails);
- }
- },
- // qualifiedQuantityMax 最大合格数量
- qualifiedQuantityMax(row) {
- return row.reportQuantity - row.noQualifiedQuantity;
- },
- noQualifiedQuantityMax(row) {
- return row.reportQuantity - row.qualifiedQuantity;
- },
- selectedChange(row) {
- console.log('row', row);
- if (row.selected) {
- // 判断是否存在
- const index = this.localOutputDetails.findIndex(
- (item) =>
- item.categoryId === row.categoryId &&
- item.produceTaskInstanceId === row.produceTaskInstanceId
- );
- if (index === -1) {
- // 不存在则添加
- this.localOutputDetails.push({
- ...row,
- reportQuantity: 0,
- qualifiedQuantity: 0,
- noQualifiedQuantity: 0,
- msg: '',
- sumReportQuantity: 0,
- sumQualifiedQuantity: 0,
- sumNoQualifiedQuantity: 0
- });
- } else {
- this.$message.warning('该物料已存在于产出清单中');
- }
- this.$emit('update:outputDetails', this.localOutputDetails);
- }
- },
- // getCategoryAndLevelByCategoryId 获取产品
- async getCategoryAndLevelByCategoryId() {
- const data = await getCategoryAndLevelByCategoryId(this.categoryId);
- this.localOutputDetails = [
- {
- ...data,
- reportQuantity: 0,
- qualifiedQuantity: 0,
- noQualifiedQuantity: 0,
- msg: '',
- sumReportQuantity: 0,
- sumQualifiedQuantity: 0,
- sumNoQualifiedQuantity: 0
- }
- ];
- this.$emit('update:outputDetails', this.localOutputDetails);
- console.log('this.localOutputDetails', this.localOutputDetails);
- }
- }
- };
- </script>
- <style></style>
|