This commit is contained in:
2022-06-27 19:25:41 +08:00
parent d8f10d2761
commit 8bc7f54bbc
1841 changed files with 180676 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
<template>
<el-dialog
title="选择设备扩展项"
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
:show-close="false"
width="1000px"
@close="close"
@open="open"
>
<el-input
v-model="query.search"
clearable
placeholder="请输入项点编码或名称"
style="width: 185px;"
class="filter-item"
/>
<rrOperation :crud="crud" />
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
style="width: 100%;margin-top: 18px"
size="mini"
border
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column type="selection" width="55" />
<el-table-column show-overflow-tooltip prop="item_code" label="项点编码"/>
<el-table-column show-overflow-tooltip prop="item_name" label="项点名称" />
<el-table-column show-overflow-tooltip prop="order_seq" label="顺序号" />
<el-table-column show-overflow-tooltip prop="default_value" label="默认值">
<template slot-scope="scope">
{{ is_or_no(scope.row.default_value, scope.row.data_type) }}
</template>
</el-table-column>
<el-table-column prop="data_type" label="默认值数据类型">
<template slot-scope="scope">
{{ dict.label.ITEM_VALUE_TYPE[scope.row.data_type] }}
</template>
</el-table-column>
<el-table-column show-overflow-tooltip prop="remark" label="备注"/>
</el-table>
<!--分页组件-->
<pagination />
<span slot="footer" class="dialog-footer">
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
<el-button slot="left" type="primary" @click="submit">保存</el-button>
</span>
</el-dialog>
</template>
<script>
import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
export default {
name: 'AddDtl',
components: { rrOperation, pagination },
dicts: ['ITEM_VALUE_TYPE'],
cruds() {
return CRUD({ title: '项点', idField: 'item_id', url: 'api/deviceitem',
optShow: {
add: false,
edit: false,
del: false,
reset: true,
download: false
}})
},
mixins: [presenter(), header()],
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: String
}
},
data() {
return {
dialogVisible: false,
opendtlParam: '',
rows: []
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
openParam: {
handler(newValue, oldValue) {
this.opendtlParam = newValue
}
}
},
methods: {
is_or_no(val, type) {
if (type === '01' && val === '1') {
return '是'
} else if (type === '01' && val === '0') {
return '否'
} else {
return val
}
},
open() {
this.crud.toQuery()
},
close() {
this.crud.resetQuery(false)
this.$emit('update:dialogShow', false)
},
submit() {
this.rows = this.$refs.table.selection
if (this.rows.length <= 0) {
this.$message('至少勾选一条项点信息')
return
}
this.crud.resetQuery(false)
this.$emit('update:dialogShow', false)
this.$emit('tableChanged', this.rows)
}
}
}
</script>

View File

@@ -0,0 +1,257 @@
<template>
<el-dialog
title="复制新增"
append-to-body
fullscreen
:visible.sync="dialogVisible"
@open="open"
@close="close"
>
<el-row :gutter="20">
<el-col :span="18" style="border: 1px solid white">
<span />
</el-col>
<el-col :span="6" style="margin-bottom: 20px">
<span style="float: right">
<el-button icon="el-icon-close" size="mini" type="info" @click="dialogVisible = false"> </el-button>
<el-button icon="el-icon-check" size="mini" type="primary" @click="saveCheck('form')">保存</el-button>
</span>
</el-col>
</el-row>
<el-card class="box-card" shadow="never">
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="mini" label-width="80px">
<el-form-item label="设备编码" prop="device_code">
<el-input v-model="form.device_code" placeholder="" style="width: 200px;" />
</el-form-item>
<el-form-item label="设备名称" prop="device_name">
<el-input v-model="form.device_name" style="width: 200px;" />
</el-form-item>
<el-form-item label="设备型号">
<el-input v-model="form.device_model" style="width: 370px;" />
</el-form-item>
<el-form-item label="所属工序">
<el-select v-model="form.workprocedure_id" filterable clearable class="filter-item" style="width: 200px">
<el-option
v-for="item in workList"
:key="item.workprocedure_id"
:label="item.workprocedure_name"
:value="item.workprocedure_id"
/>
</el-select>
</el-form-item>
<el-form-item label="外部编码">
<el-input v-model="form.extend_code" style="width: 200px;" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.remark" :rows="2" type="textarea" style="width: 370px;" />
</el-form-item>
</el-form>
</el-card>
<div class="crud-opts2" style="margin-top: 30px">
<span class="role-span">扩展项明细</span>
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-plus"
size="mini"
@click="addrow"
>
新增扩展项
</el-button>
</span>
</div>
<!--表格渲染-->
<el-table
ref="table"
:data="tableData"
style="width: 100%;"
border
size="mini"
:highlight-current-row="true"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
@current-change="handleCurrentChange"
>
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column prop="item_code" label="项点编码" align="center" />
<el-table-column prop="item_name" label="项点名称" align="center" />
<el-table-column prop="default_value" label="默认值" align="center">
<template slot-scope="scope">
{{ is_or_no(scope.row.default_value, scope.row.data_type) }}
</template>
</el-table-column>
<el-table-column prop="data_type" label="默认值数据类型">
<template slot-scope="scope">
{{ dict.label.ITEM_VALUE_TYPE[scope.row.data_type] }}
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center" />
<el-table-column align="center" label="操作" width="160" fixed="right">
<template scope="scope">
<el-button type="danger" class="filter-item" size="mini" icon="el-icon-delete" @click.native.prevent="deleteRow(scope.$index, tableData)" />
</template>
</el-table-column>
</el-table>
<AddDtl :dialog-show.sync="dtlShow" @tableChanged="tableChanged" />
</el-dialog>
</template>
<script>
import CRUD, { crud } from '@crud/crud'
import crudDevice from '@/api/wms/pdm/device'
import AddDtl from '@/views/wms/pdm/device/AddDtl'
export default {
name: 'CopyDialog',
components: { AddDtl },
dicts: ['ITEM_VALUE_TYPE'],
mixins: [crud()],
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: Object
}
},
data() {
return {
dialogVisible: false,
nowindex: '',
nowrow: null,
dtlShow: false,
materShow: false,
workList: [],
form: {
device_id: '',
device_code: '',
device_name: '',
device_model: '',
workprocedure_id: '',
extend_code: '',
remark: '',
is_active: ''
},
tableData: [],
rules: {
device_code: [
{ required: true, message: '设备编码不能为空', trigger: 'blur' }
],
device_name: [
{ required: true, message: '设备名称不能为空', trigger: 'blur' }
]
}
}
},
watch: {
dialogShow: {
handler(newValue) {
this.dialogVisible = newValue
}
}
},
methods: {
is_or_no(val, type) {
if (type === '01' && val === '1') {
return '是'
} else if (type === '01' && val === '0') {
return '否'
} else {
return val
}
},
handleCurrentChange(current) {
if (current !== null) {
this.nowrow = current
} else {
this.nowrow = null
}
},
async queryMater(index, row) {
this.materShow = true
this.nowindex = index
this.nowrow = row
},
getWorkprocedure() {
crudDevice.getWorkprocedure().then(res => {
this.workList = res
})
},
open() {
this.getWorkprocedure()
crudDevice.getItemByDevice({ device_id: this.form.device_id }).then(res => {
this.tableData = res
// 将明细变成不可编辑
for (let i = 0; i < this.tableData.length; i++) {
const row = this.tableData[i]
this.tableData.splice(i, 1, row)
}
})
},
close() {
this.$emit('AddChanged')
},
tableChanged(rows) {
var array = ([...this.tableData, ...rows])
this.tableData = this.unique(array)
},
unique(arr) {
// 根据唯一标识item_code来对数组进行过滤
// 定义常量 res,值为一个Map对象实例
const res = new Map()
// 返回arr数组过滤后的结果结果为一个数组 过滤条件是如果res中没有某个键就设置这个键的值为1
return arr.filter((arr) => !res.has(arr.item_code) && res.set(arr.item_code, 1))
},
setForm(row) {
this.dialogVisible = true
this.form = row
this.form.device_code = ''
this.form.device_name = ''
},
addrow() {
this.dtlShow = true
},
deleteRow(index, rows) {
rows.splice(index, 1)
this.nowindex = ''
this.nowrow = null
},
saveCheck(form) {
if (this.tableData.length === 0) {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
this.$refs[form].validate((valid) => {
if (valid) {
crudDevice.copyAdd({ 'row': this.form, 'rows': this.tableData }).then(res => {
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.dialogVisible = false
})
}
})
}
}
}
</script>
<style>
.crud-opts2 {
padding: 0 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .crud-opts-right2 {
margin-left: auto;
padding: 4px 4px;
}
.input-with-select {
background-color: #fff;
}
</style>

View File

@@ -0,0 +1,234 @@
<template>
<el-dialog
title="设备详情"
append-to-body
fullscreen
:visible.sync="dialogVisible"
@open="open"
@close="close"
>
<el-row :gutter="20">
<el-col :span="18" style="border: 1px solid white">
<span />
</el-col>
<el-col :span="6" style="margin-bottom: 20px">
<span style="float: right">
<el-button icon="el-icon-close" size="mini" type="info" @click="dialogVisible = false"> </el-button>
<el-button icon="el-icon-check" size="mini" type="primary" @click="saveCheck">保存</el-button>
</span>
</el-col>
</el-row>
<el-card class="box-card" shadow="never">
<el-form ref="form" disabled :inline="true" :model="form" :rules="rules" size="mini" label-width="80px">
<el-form-item label="设备编码">
<el-input v-model="form.device_code" placeholder="自动生产" style="width: 200px;" />
</el-form-item>
<el-form-item label="设备名称" prop="dtl_count">
<el-input v-model="form.device_name" style="width: 200px;" />
</el-form-item>
</el-form>
</el-card>
<div class="crud-opts2" style="margin-top: 30px;margin-bottom: 15px">
<span class="role-span">项点明细</span>
</div>
<!--表格渲染-->
<el-table
ref="table"
:data="tableData"
style="width: 100%;"
size="mini"
border
:highlight-current-row="true"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
@current-change="handleCurrentChange"
>
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column prop="item_code" label="项点编码" align="center" />
<el-table-column prop="item_name" label="项点名称" align="center" />
<el-table-column prop="item_value" label="项点值" align="center">
<template slot-scope="scope">
<span v-if="scope.row.is_show === '1' && scope.row.data_type !== '01'">{{ scope.row.item_value }}</span>
<span v-if="scope.row.is_show === '1' && scope.row.data_type === '01'">{{ is_or_no(scope.row.item_value) }}</span>
<el-input
v-else-if="scope.row.is_show === '0' && (scope.row.data_type === '' || scope.row.data_type === '03')"
v-model="scope.row.item_value"
/>
<el-input
type="number"
v-else-if="scope.row.is_show === '0' && scope.row.data_type === '02'"
v-model="scope.row.item_value"
/>
<el-select
v-else-if="scope.row.is_show === '0' && scope.row.data_type === '01'"
v-model="scope.row.item_value"
placeholder=""
>
<el-option
v-for="item in dict.IS_OR_NOT"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
</el-table-column>
<el-table-column prop="data_type" label="默认值数据类型">
<template slot-scope="scope">
{{ dict.label.ITEM_VALUE_TYPE[scope.row.data_type] }}
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center" />
<el-table-column align="center" label="操作" width="160" fixed="right">
<template scope="scope">
<el-button v-if="scope.row.is_show === '1'" type="primary" class="filter-item" size="mini" icon="el-icon-edit" @click="editData(scope.row,scope.$index)" />
<el-button v-else type="success" class="filter-item" size="mini" icon="el-icon-check" @click="saveData(scope.row,scope.column,scope.$index)" />
</template>
</el-table-column>
</el-table>
<AddDtl :dialog-show.sync="dtlShow" @tableChanged="tableChanged" />
</el-dialog>
</template>
<script>
import CRUD, { crud } from '@crud/crud'
import crudDevice from '@/api/wms/pdm/device'
import AddDtl from '@/views/wms/pdm/device/AddDtl'
export default {
name: 'DeviceInfoDialog',
components: { AddDtl },
mixins: [crud()],
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: Object
}
},
dicts: ['ITEM_VALUE_TYPE', 'IS_OR_NOT'],
data() {
return {
dialogVisible: false,
nowindex: '',
nowrow: null,
dtlShow: false,
materShow: false,
form: {
device_id: '',
device_code: '',
device_name: ''
},
tableData: [],
rules: {
}
}
},
watch: {
dialogShow: {
handler(newValue) {
this.dialogVisible = newValue
}
}
},
methods: {
is_or_no(val) {
if (val === '1') {
return '是'
} else {
return '否'
}
},
editData(row, index) {
this.tableData[index].is_show = '0'
},
saveData(row, column, index) {
this.tableData[index].is_show = '1'
},
handleCurrentChange(current) {
if (current !== null) {
this.nowrow = current
} else {
this.nowrow = null
}
},
async queryMater(index, row) {
this.materShow = true
this.nowindex = index
this.nowrow = row
},
open() {
crudDevice.getItemByDevice({ device_id: this.form.device_id }).then(res => {
this.tableData = res
// 将明细变成不可编辑
for (let i = 0; i < this.tableData.length; i++) {
const row = this.tableData[i]
this.tableData.splice(i, 1, row)
}
})
},
close() {
this.$emit('AddChanged')
},
tableChanged(rows) {
const tablemap = new Map()
rows.forEach((item) => {
item.item_value = item.default_value
if (this.tableData.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].item_code === item.item_code) {
this.flagnow = true
}
}
if (!this.flagnow) {
tablemap.set(item.item_code, item)
}
} else {
tablemap.set(item.item_code, item)
}
})
for (const value of tablemap.values()) {
this.tableData.push(value)
}
},
setForm(row) {
this.dialogVisible = true
this.form = row
},
saveCheck() {
if (this.tableData.length === 0) {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].is_show === '0') {
this.crud.notify('尚有未完成编辑的项点值,序号为' + (i + 1) + ',请检查!')
return false
}
}
crudDevice.savaDeviceItem({ 'row': this.form, 'rows': this.tableData }).then(res => {
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.dialogVisible = false
})
}
}
}
</script>
<style>
.crud-opts2 {
padding: 0 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .crud-opts-right2 {
margin-left: auto;
padding: 4px 4px;
}
.input-with-select {
background-color: #fff;
}
</style>

View File

@@ -0,0 +1,252 @@
<template>
<el-dialog
title="设备扩展项"
append-to-body
fullscreen
:visible.sync="dialogVisible"
@open="open"
@close="close"
>
<el-row :gutter="20">
<el-col :span="18" style="border: 1px solid white">
<span />
</el-col>
<el-col :span="6" style="margin-bottom: 20px">
<span style="float: right">
<el-button icon="el-icon-close" size="mini" type="info" @click="dialogVisible = false"> </el-button>
<el-button icon="el-icon-check" size="mini" type="primary" @click="saveCheck">保存</el-button>
</span>
</el-col>
</el-row>
<el-card class="box-card" shadow="never">
<el-form ref="form" disabled :inline="true" :model="form" :rules="rules" size="mini" label-width="80px">
<el-form-item label="设备编码">
<el-input v-model="form.device_code" placeholder="自动生产" style="width: 200px;" />
</el-form-item>
<el-form-item label="设备名称" prop="dtl_count">
<el-input v-model="form.device_name" style="width: 200px;" />
</el-form-item>
</el-form>
</el-card>
<div class="crud-opts2" style="margin-top: 30px">
<span class="role-span">扩展项明细</span>
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-plus"
size="mini"
@click="addrow"
>
新增扩展项
</el-button>
</span>
</div>
<!--表格渲染-->
<el-table
ref="table"
:data="tableData"
style="width: 100%;"
size="mini"
border
:highlight-current-row="true"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
@current-change="handleCurrentChange"
>
<el-table-column type="index" label="序号" width="50" align="center" />
<el-table-column prop="item_code" label="项点编码" align="center" />
<el-table-column prop="item_name" label="项点名称" align="center" />
<el-table-column prop="item_value" label="项点值" align="center">
<template slot-scope="scope">
<span v-if="scope.row.is_show === '1' && scope.row.data_type !== '01'">{{ scope.row.item_value }}</span>
<span v-if="scope.row.is_show === '1' && scope.row.data_type === '01'">{{ is_or_no(scope.row.item_value) }}</span>
<el-input
v-else-if="scope.row.is_show === '0' && (scope.row.data_type === '' || scope.row.data_type === '03')"
v-model="scope.row.item_value"
/>
<el-input
type="number"
v-else-if="scope.row.is_show === '0' && scope.row.data_type === '02'"
v-model="scope.row.item_value"
/>
<el-select
ref="select"
v-else-if="scope.row.is_show === '0' && scope.row.data_type === '01'"
v-model="scope.row.item_value"
placeholder=""
>
<el-option
v-for="item in dict.IS_OR_NOT"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
</el-table-column>
<el-table-column prop="data_type" label="默认值数据类型">
<template slot-scope="scope">
{{ dict.label.ITEM_VALUE_TYPE[scope.row.data_type] }}
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" align="center" />
<el-table-column align="center" label="操作" width="160" fixed="right">
<template scope="scope">
<el-button v-if="scope.row.is_show === '1'" type="primary" class="filter-item" size="mini" icon="el-icon-edit" @click="editData(scope.row,scope.$index)" />
<el-button v-else type="success" class="filter-item" size="mini" icon="el-icon-check" @click="saveData(scope.row,scope.column,scope.$index)" />
<el-button type="danger" class="filter-item" size="mini" icon="el-icon-delete" @click.native.prevent="deleteRow(scope.$index, tableData)" />
</template>
</el-table-column>
</el-table>
<AddDtl :dialog-show.sync="dtlShow" @tableChanged="tableChanged" />
</el-dialog>
</template>
<script>
import CRUD, { crud } from '@crud/crud'
import crudDevice from '@/api/wms/pdm/device'
import AddDtl from '@/views/wms/pdm/device/AddDtl'
export default {
name: 'DeviceItemDialog',
components: { AddDtl },
mixins: [crud()],
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: Object
}
},
dicts: ['ITEM_VALUE_TYPE', 'IS_OR_NOT'],
data() {
return {
dialogVisible: false,
nowindex: '',
nowrow: null,
dtlShow: false,
materShow: false,
form: {
device_id: '',
device_code: '',
device_name: ''
},
tableData: [],
rules: {
}
}
},
watch: {
dialogShow: {
handler(newValue) {
this.dialogVisible = newValue
}
}
},
methods: {
is_or_no(val) {
if (val === '1') {
return '是'
} else {
return '否'
}
},
editData(row, index) {
this.tableData[index].is_show = '0'
},
saveData(row, column, index) {
this.tableData[index].is_show = '1'
},
handleCurrentChange(current) {
if (current !== null) {
this.nowrow = current
} else {
this.nowrow = null
}
},
async queryMater(index, row) {
this.materShow = true
this.nowindex = index
this.nowrow = row
},
open() {
crudDevice.getItemByDevice({ device_id: this.form.device_id }).then(res => {
this.tableData = res
// 将明细变成不可编辑
for (let i = 0; i < this.tableData.length; i++) {
const row = this.tableData[i]
this.tableData.splice(i, 1, row)
}
})
},
close() {
this.$emit('AddChanged')
},
tableChanged(rows) {
rows.forEach((item) => {
this.$set(item, 'item_value', item.default_value)
})
var array = ([...this.tableData, ...rows])
this.tableData = this.unique(array)
},
unique(arr) {
// 根据唯一标识item_code来对数组进行过滤
// 定义常量 res,值为一个Map对象实例
const res = new Map()
// 返回arr数组过滤后的结果结果为一个数组 过滤条件是如果res中没有某个键就设置这个键的值为1
return arr.filter((arr) => !res.has(arr.item_code) && res.set(arr.item_code, 1))
},
setForm(row) {
this.dialogVisible = true
this.form = row
},
addrow() {
this.dtlShow = true
},
deleteRow(index, rows) {
rows.splice(index, 1)
this.nowindex = ''
this.nowrow = null
},
saveCheck() {
if (this.tableData.length === 0) {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].is_show === '0') {
this.crud.notify('尚有未完成编辑的项点值,序号为' + (i + 1) + ',请检查!')
return false
}
}
crudDevice.savaDeviceItem({ 'row': this.form, 'rows': this.tableData }).then(res => {
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.dialogVisible = false
})
}
}
}
</script>
<style>
.crud-opts2 {
padding: 0 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .crud-opts-right2 {
margin-left: auto;
padding: 4px 4px;
}
.input-with-select {
background-color: #fff;
}
</style>

View File

@@ -0,0 +1,223 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<label class="el-form-item-label">模糊搜索</label>
<el-input
v-model="query.search"
clearable
size="small"
placeholder="请输入设备编码或名称"
style="width: 220px;"
class="filter-item"
/>
<label class="el-form-item-label">所属工序</label>
<el-select v-model="query.workprocedure_id" filterable clearable size="small" placeholder="所属工序" class="filter-item" style="width: 220px" @change="changeHeader(query.search, query.workprocedure_id)">
<el-option
v-for="item in workList"
:key="item.workprocedure_id"
:label="item.workprocedure_name"
:value="item.workprocedure_id"
/>
</el-select>
<rrOperation :crud="crud" />
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="success"
icon="el-icon-position"
size="mini"
:disabled="crud.selections.length !== 1"
@click="addItem(crud.selections[0])"
>
设备扩展项
</el-button>
<el-button
slot="right"
class="filter-item"
type="danger"
icon="el-icon-position"
size="mini"
:disabled="crud.selections.length !== 1"
@click="deviceInfo(crud.selections[0])"
>
设备详情
</el-button>
<el-button
slot="right"
class="filter-item"
type="warning"
icon="el-icon-document-copy"
:disabled="crud.selections.length !== 1"
size="mini"
@click="copyAdd(crud.selections[0])"
>
复制新增
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
<el-form-item label="设备编码" prop="device_code">
<el-input v-model="form.device_code" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备名称" prop="device_name">
<el-input v-model="form.device_name" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备型号">
<el-input v-model="form.device_model" style="width: 370px;" />
</el-form-item>
<el-form-item label="设备产能">
<el-input type="number" oninput="value = value.replace(/[^\d]/g, '')" v-model="form.productivity" style="width: 370px;" />
</el-form-item>
<el-form-item label="所属工序">
<el-select v-model="form.workprocedure_id" filterable clearable class="filter-item" style="width: 370px">
<el-option
v-for="item in workList"
:key="item.workprocedure_id"
:label="item.workprocedure_name"
:value="item.workprocedure_id"
/>
</el-select>
</el-form-item>
<el-form-item label="外部编码">
<el-input v-model="form.extend_code" style="width: 370px;" />
</el-form-item>
<!-- <el-form-item label="设备档案标识">
未设置字典,请手动设置 Select
</el-form-item>-->
<el-form-item label="备注">
<el-input v-model="form.remark" :rows="3" type="textarea" style="width: 370px;" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column prop="device_code" label="设备编码" />
<el-table-column prop="device_name" label="设备名称" min-width="200" show-overflow-tooltip />
<el-table-column prop="productivity" label="设备产能" />
<el-table-column prop="produceorder_code" label="工单编号" />
<template v-for="(item, index) in tableLabel">
<el-table-column
v-if="item.show"
:key="index"
:show-overflow-tooltip="true"
:prop="item.prop"
:label="item.label"
:min-width="item.width"
/>
</template>
<el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
/>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
<DeviceItemDialog ref="child" @AddChanged="querytable" />
<DeviceInfoDialog ref="child1" @AddChanged="querytable" />
<CopyDialog ref="copyChiled" @AddChanged="querytable" />
</div>
</template>
<script>
import crudDevice from '@/api/wms/pdm/device'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import DeviceItemDialog from '@/views/wms/pdm/device/DeviceItemDialog'
import DeviceInfoDialog from '@/views/wms/pdm/device/DeviceInfoDialog'
import CopyDialog from '@/views/wms/pdm/device/CopyDialog'
const defaultForm = { device_id: null, device_code: null, device_name: null, device_model: null, workprocedure_id: null, extend_code: null, devicebill_id: null, remark: null, is_active: null, create_id: null, create_name: null, create_time: null, is_delete: null, productivity: null }
export default {
name: 'Device',
components: { pagination, crudOperation, rrOperation, udOperation, DeviceItemDialog, CopyDialog, DeviceInfoDialog },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({ title: '生产设备', url: 'api/device', idField: 'device_id', sort: 'device_id,desc',
optShow: {
add: true,
edit: false,
del: false,
reset: true,
download: false
},
crudMethod: { ...crudDevice }})
},
data() {
return {
permission: {
},
workList: [],
tableLabel: [],
rules: {
device_code: [
{ required: true, message: '设备编码不能为空', trigger: 'blur' }
],
device_name: [
{ required: true, message: '设备名称不能为空', trigger: 'blur' }
]
}
}
},
created() {
this.getWorkprocedure()
},
methods: {
changeHeader(search, workprocedure_id) {
this.getHeader(search, workprocedure_id)
this.crud.toQuery()
},
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
this.getHeader(this.query.search, this.query.workprocedure_id)
return true
},
getWorkprocedure() {
crudDevice.getWorkprocedure().then(res => {
this.workList = res
})
},
addItem(data) {
this.$refs.child.setForm(data)
},
deviceInfo(data) {
this.$refs.child1.setForm(data)
},
copyAdd(data) {
const d = JSON.parse(JSON.stringify(data))
this.$refs.copyChiled.setForm(d)
},
querytable() {
this.crud.toQuery()
},
getHeader(search, workprocedure_id) {
crudDevice.getItemByDeviceId({ search: search, workprocedure_id: workprocedure_id }).then(res => {
this.tableLabel = res.newArray
})
}
}
}
</script>
<style scoped>
</style>