124 lines
7.2 KiB
Vue
124 lines
7.2 KiB
Vue
<template>
|
|
<div class="app-container plm-material">
|
|
<el-card shadow="never">
|
|
<h2 slot="header">物料信息</h2>
|
|
<el-form size="mini" inline @submit.native.prevent="search">
|
|
<el-form-item v-for="key in ['物料名称','图号','物料编码']" :key="key" :label="key">
|
|
<el-input v-model.trim="draft[key]" :maxlength="100" :placeholder="key" clearable/>
|
|
</el-form-item>
|
|
<el-form-item label="原始类型">
|
|
<el-select v-model="draft.原始类型" placeholder="原始类型" clearable filterable allow-create default-first-option>
|
|
<el-option v-for="type in types" :key="type" :value="type" :label="type"/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-button type="primary" size="mini" native-type="submit">查询</el-button>
|
|
<el-button size="mini" @click="reset">重置</el-button>
|
|
<el-button size="mini" icon="el-icon-refresh" @click="load">刷新</el-button>
|
|
<el-button v-if="checkedCode && checkedCode === draft.物料编码" size="mini"
|
|
@click="$refs.plmFiles.open('cards', checkedCode)">按编码查 PLM 工序卡</el-button>
|
|
</el-form>
|
|
<el-alert v-if="error" :title="error" type="error" show-icon :closable="false"/>
|
|
<el-table ref="table" v-loading="loading" :data="rows" row-key="物料流水号" border size="mini" :empty-text="error ? '读取失败' : '无匹配物料'" @sort-change="sort">
|
|
<el-table-column prop="序号" label="序号" width="65"/>
|
|
<el-table-column prop="物料编码" label="物料编码" min-width="120" show-overflow-tooltip/>
|
|
<el-table-column prop="物料名称" label="物料名称" min-width="150" sortable="custom" show-overflow-tooltip/>
|
|
<el-table-column prop="图号" label="图号" min-width="135" sortable="custom" show-overflow-tooltip/>
|
|
<el-table-column prop="规格" label="规格" min-width="100" show-overflow-tooltip/>
|
|
<el-table-column prop="材料" label="材料" min-width="85" show-overflow-tooltip/>
|
|
<el-table-column prop="单位" label="单位" width="80"><template slot-scope="s">{{ s.row.单位 || s.row.单位来源 }}</template></el-table-column>
|
|
<el-table-column label="类型" min-width="90"><template slot-scope="s">{{ category(s.row) }}</template></el-table-column>
|
|
<el-table-column label="操作" width="66"><template slot-scope="s"><el-button type="text" size="mini" @click="selected = s.row">资料</el-button></template></el-table-column>
|
|
</el-table>
|
|
<el-pagination v-if="!error" :current-page="page" :page-size="size" :page-sizes="[20,50,100]" :total="total"
|
|
layout="total, sizes, prev, pager, next, jumper" @current-change="turn" @size-change="resize"/>
|
|
</el-card>
|
|
<plm-material-files ref="plmFiles"/>
|
|
<el-dialog title="物料资料" :visible="!!selected" @close="selected = null">
|
|
<dl v-if="selected"><template v-for="field in detailFields">
|
|
<dt :key="field+'-label'">{{ field }}</dt><dd :key="field">{{ selected[field] == null || selected[field] === '' ? '未登记' : selected[field] }}</dd>
|
|
</template></dl>
|
|
<div v-if="selected"><el-button size="mini" :disabled="!selected.物料编码" @click="$refs.plmFiles.open('drawings', selected.物料编码)">PLM图纸</el-button>
|
|
<el-button size="mini" :disabled="!selected.物料编码" @click="$refs.plmFiles.open('cards', selected.物料编码)">工序卡</el-button></div>
|
|
<el-button slot="footer" size="mini" @click="selected = null">关闭</el-button>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import PlmMaterialFiles from '@/components/PLMMaterialFiles'
|
|
import { navigationRead } from '@/api/erp/navigationReads'
|
|
|
|
function filters() { return { 物料名称: '', 图号: '', 物料编码: '', 原始类型: '' } }
|
|
|
|
const classes = { '01': '毛坯类', '02': '自制件', '03': '外购件', '04': '原材料', '05': '耗材库', '06': '设备库', '07': '质检库', '08': '半成品库', '09': '模具库', '10': '成品库' }
|
|
|
|
export default {
|
|
components: { PlmMaterialFiles },
|
|
name: 'PLMMaterialInfo',
|
|
data() {
|
|
return { draft: filters(), applied: filters(), page: 1, size: 20, total: 0, rows: [], selected: null,
|
|
sortField: '', direction: '', loading: false, error: '', sequence: 0, checkedCode: '',
|
|
detailFields: ['物料流水号','物料编码','物料名称','图号','规格','材料','单位','单位来源','原始类型','库位','曾用物料编码','备注'] }
|
|
},
|
|
computed: {
|
|
types() { return Array.from(new Set(this.rows.map(row => row.原始类型 == null ? '' : String(row.原始类型)).filter(Boolean))) },
|
|
actor() { return this.$store.getters.id }
|
|
},
|
|
watch: {
|
|
actor() { this.selected = null; this.rows = []; this.total = 0; if (this.$route.path === '/plm/material-info') this.search() },
|
|
'$route.path'(path) {
|
|
if (path === '/plm/material-info') this.load()
|
|
else { this.sequence++; this.selected = null; this.rows = []; this.total = 0 }
|
|
}
|
|
},
|
|
created() { this.load() },
|
|
beforeDestroy() { this.sequence++ },
|
|
methods: {
|
|
category(row) {
|
|
const prefix = /^(\d{2})\.(?=\d)/.exec(String(row.物料编码 || '').trim())
|
|
const raw = row.原始类型 == null ? '' : String(row.原始类型)
|
|
return (prefix && classes[prefix[1]]) || (/^\d+$/.test(raw) ? '类型代码 ' + raw : raw || '未提供')
|
|
},
|
|
search() { this.applied = Object.assign({}, this.draft); this.page = 1; this.load() },
|
|
reset() { this.draft = filters(); this.sortField = ''; this.direction = ''; this.$refs.table.clearSort(); this.search() },
|
|
turn(page) { if (page !== this.page) { this.page = page; this.load() } },
|
|
resize(size) { this.size = size; this.page = 1; this.load() },
|
|
sort(event) {
|
|
this.sortField = event.order ? event.prop : ''
|
|
this.direction = event.order === 'ascending' ? '升序' : event.order === 'descending' ? '降序' : ''
|
|
this.page = 1
|
|
this.load()
|
|
},
|
|
load() {
|
|
this.checkedCode = ''
|
|
const version = ++this.sequence
|
|
const values = Object.assign({}, this.applied, { 排序字段: this.sortField, 排序方向: this.direction })
|
|
this.loading = true
|
|
this.error = ''
|
|
this.selected = null
|
|
return navigationRead('ai_物料信息_启用物料清单', values, this.page, this.size).then(response => {
|
|
if (version !== this.sequence) return
|
|
const data = response.data
|
|
if (!data || !Array.isArray(data.rows) || !Number.isSafeInteger(data.total) || data.total < 0) throw new Error('物料清单缺少分页结果')
|
|
this.rows = data.rows
|
|
this.total = data.total
|
|
if (/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$/.test(values.物料编码)) this.checkedCode = values.物料编码
|
|
}).catch(error => {
|
|
if (version !== this.sequence) return
|
|
this.rows = []
|
|
this.total = 0
|
|
this.error = error.httpStatus === 403 ? '当前员工尚未获得物料查看权限' : error.message || '物料查询失败'
|
|
}).then(() => { if (version === this.sequence) this.loading = false })
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
h2 { margin: 0; }
|
|
.el-pagination { margin-top: 10px; white-space: normal; }
|
|
dl { display: grid; grid-template-columns: 7em 1fr; gap: 10px; }
|
|
dt { color: #606266; }
|
|
dd { margin: 0; overflow-wrap: anywhere; }
|
|
</style>
|