<template>
|
<a-card :bordered="false">
|
<a-button
|
v-if="warehouseSelectionRows.length == 1"
|
@click="handleAdd"
|
type="primary"
|
icon="plus"
|
>新增</a-button>
|
|
<div>
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination=false
|
:loading="loading"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
@change="handleTableChange"
|
>
|
<template
|
v-for="col in columns"
|
:slot="col.dataIndex"
|
slot-scope='text, record, index'
|
>
|
<div :key="col.dataIndex">
|
|
<span v-if="col.dataIndex == 'remark'">
|
<j-ellipsis
|
:value="text"
|
:length="10"
|
/>
|
</span>
|
|
<a-input-number
|
:value="text"
|
v-if="col.dataIndex == 'upperLimit'"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
style="width: 100%"
|
/>
|
<a-input-number
|
:value="text"
|
v-if="col.dataIndex == 'lowerLimit'"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
style="width: 100%"
|
/>
|
<a-input-number
|
:value="text"
|
v-if="col.dataIndex == 'actualValue'"
|
@change="(e)=>handleChange(e, record.key, col, index)"
|
style="width: 100%"
|
/>
|
|
<span v-if="col.dataIndex == 'action'">
|
<a-button
|
type="primary"
|
@click="handleEdit(record)"
|
>提交</a-button>
|
</span>
|
|
</div>
|
</template>
|
|
</a-table>
|
</div>
|
<manage-objcet-modal
|
ref="modalForm"
|
@ok="modalFormOk"
|
></manage-objcet-modal>
|
</a-card>
|
</template>
|
|
<script>
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import { getAction, postAction } from '@/api/manage'
|
import JInput from '@/components/jeecg/JInput'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import JEllipsis from "@/components/jeecg/JEllipsis";
|
import ManageObjectModal from './ManageObjectModal'
|
|
export default {
|
name: "ManageObjectList",
|
mixins: [JeecgListMixin],
|
components: {
|
JInput,
|
Tooltip,
|
JEllipsis,
|
ManageObjectModal
|
},
|
data() {
|
return {
|
// disabled: true,
|
description: '设备精度',
|
colorMap: {},
|
// 表头
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: "center",
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1;
|
}
|
},
|
{
|
title: '管理对象编码',
|
dataIndex: 'precisionParametersNum',
|
align: "center",
|
},
|
{
|
title: '管理对象名称',
|
dataIndex: 'precisionParametersName',
|
align: "center",
|
},
|
{
|
title: '默认库区',
|
dataIndex: 'precisionParametersUnitName',
|
align: "center",
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
width: 100,
|
align: "center",
|
scopedSlots: {
|
customRender: 'action'
|
},
|
},
|
],
|
url: {
|
list: "/eam/equipmentPrecisionParameters/list",
|
edit: "/eam/equipmentPrecisionParameters/edit",
|
},
|
warehouseSelectionRows: [],
|
equipmentId: '',
|
}
|
},
|
watch: {
|
equipmentId() {
|
this.queryParam = {};
|
this.queryParam.equipmentId = this.equipmentId;
|
this.loadData(1);
|
},
|
},
|
mounted() {
|
this.$bus.$on('warehouseSelectionRows', (data) => {
|
this.warehouseSelectionRows = data
|
})
|
},
|
methods: {
|
modalFormOk() {
|
this.loadData();
|
},
|
|
handleAdd: function () {
|
this.$refs.modalForm.add();
|
this.$refs.modalForm.title = "设备精度参数绑定";
|
this.$refs.modalForm.disableSubmit = false;
|
this.$refs.modalForm.equipmentId = this.warehouseSelectionRows[0].id
|
},
|
|
handleEdit(record) {
|
this.loading = true;
|
if (record.actualValue === "" || record.actualValue === null) {
|
this.$message.warning("参考值不能为空!")
|
this.loading = false;
|
return
|
}
|
postAction(this.url.edit, record).then((res) => {
|
if (res.success) {
|
this.$message.success(res.message);
|
this.loadData()
|
} else {
|
this.$message.warning(res.message);
|
}
|
}).finally(() => {
|
this.loading = false;
|
});
|
},
|
|
modalFormOk() {
|
this.loadData(1);
|
},
|
|
handleChange(value, key, column, index) {
|
let that = this;
|
const temp = [...that.dataSource];
|
const target = temp.filter(item => key === item.key)[index];
|
if (target) {
|
target[column.dataIndex] = value;
|
if ('actualValue' == column.dataIndex) {
|
target['actualValue'] = value;
|
}
|
if ('upperLimit' == column.dataIndex) {
|
target['upperLimit'] = value;
|
}
|
if ('lowerLimit' == column.dataIndex) {
|
target['lowerLimit'] = value;
|
}
|
//显示带过来的数据
|
that.dataSource = temp;
|
}
|
},
|
|
loadData(arg) {
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
// var params = this.getQueryParams();//查询条件
|
var params = this.queryParam
|
params.pageNo = this.ipagination.current
|
params.pageSize = this.ipagination.pageSize
|
if (this.equipmentId == '') {
|
params.equipmentId = '-1';
|
}
|
this.loading = true;
|
getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
this.dataSource = res.result.records || res.result;
|
if (res.result.total) {
|
this.ipagination.total = res.result.total;
|
} else {
|
this.ipagination.total = 0;
|
}
|
} else {
|
this.$message.warning(res.message)
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
},
|
|
}
|
</script>
|
|
<style scoped>
|
@import '~@assets/less/common.less';
|
/deep/ .frozenRowClass {
|
color: #c9c9c9;
|
}
|
.success {
|
color: green;
|
}
|
.error {
|
color: red;
|
}
|
.fontweight {
|
font-weight: bold;
|
}
|
.ant-card {
|
margin-left: -30px;
|
margin-right: -30px;
|
}
|
</style>
|