Commit 59d0b6fe authored by 张海景's avatar 张海景

update:修改zb-table组件加上选中方法

parent f62a9a80
......@@ -16,10 +16,11 @@
<view class="prod-body-left-task">
<zb-table
ref="zbtable"
:columns="tableColumn"
:stripe="true"
rowKey="taskWorkunitId"
@rowClick="rowClick"
@cellClick="cellClick"
@toggleRowSelection="toggleRowSelection"
@toggleAllSelection="toggleAllSelection"
:border="true"
......@@ -695,19 +696,22 @@ export default {
tableColumn: [
{
type: 'selection',
width: 35
width: 80
},
{
name: 'arrangeCode',
label: '编排单号',
width: 140,
func: 'numclik'
width: 200,
cellFun: (row, index) => {
console.log(row, index)
this.tableDataDetail = row.proWorkorderList;
this.showRowDeatilFlag = true;
}
},
{
name: 'startTime',
label: '计划开始时间',
width: 140,
func: 'numclik'
},
{
name: 'endTime',
......@@ -735,7 +739,7 @@ export default {
ERROR_STOP: '异常停工',
FINISH: '完工'
},
width: 60,
width: 100,
align: 'center'
},
// {
......@@ -746,14 +750,14 @@ export default {
{
name: 'taskCode',
label: '任务单号',
width: 110
},
{
name: 'workorderCode',
label: '生产单号',
width: 120
width: 180
},
// {
// name: 'workorderCode',
// label: '生产单号',
// width: 120
// },
// {
// name: 'itemCode',
// label: '物料编号',
// width: 110,
......@@ -779,12 +783,12 @@ export default {
width: 80,
align: 'center'
},
{
name: 'clientName',
label: '作业人员',
width: 60,
align: 'center'
}
// {
// name: 'clientName',
// label: '作业人员',
// width: 60,
// align: 'center'
// }
],
dModelData: [],
tableSelectData: [],
......@@ -942,12 +946,14 @@ export default {
urls: this.viewSop
});
},
cellClick(row, index, column) {
if (column.name === 'arrangeCode') {
this.tableDataDetail = row.proWorkorderList;
this.showRowDeatilFlag = true;
}
},
// cellClick(row, index, column) {
// if (column.name === 'arrangeCode') {
// this.tableDataDetail = row.proWorkorderList;
// this.showRowDeatilFlag = true;
// console.log(e)
// e.stopPropagation()
// }
// },
numclik(...arg) {
console.log('99999999', arg);
},
......@@ -1095,14 +1101,16 @@ export default {
});
},
rowClick(row, index) {
this.$refs.zbtable.toggleRowSelection(row)
this.curTaskInfo = row;
this.getMaterialUsageRecordList();
},
toggleAllSelection(checked, arr) {
// console.log(arr, 'this.tableSelectData');
this.tableSelectData = arr;
},
toggleRowSelection(checked, arr) {
console.log(this.tableSelectData, 'this.tableSelectData');
// console.log(arr, 'this.tableSelectData');
this.tableSelectData = arr;
},
knifeTemp() {
......
<template>
<view class="login">
<u-form ref="loginForm" :modelValue="loginForm" :rules="loginRules" class="login-form">
<h3 class="title">MES-PAD</h3>
<h3 class="title">MES作业端</h3>
<u-form-item prop="username">
<input
v-model="loginForm.username"
......
......@@ -140,6 +140,11 @@
<text v-else>{{ ite.emptyString }}</text>
</view>
</template>
<template v-else-if="ite.cellFun">
<view @click.stop="ite.cellFun(item,index)" class="cellfunction">
<text>{{ ite.filters ? itemFilter(item, ite) : formatterAction(item, ite, index, i) }}</text>
</view>
</template>
<template v-else>
<!-- {{ ite.filters?itemFilter(item,ite):(item[ite.name]==null||item[ite.name]==='')?ite.emptyString:item[ite.name] }}-->
{{ ite.filters ? itemFilter(item, ite) : formatterAction(item, ite, index, i) }}
......@@ -796,6 +801,30 @@ export default {
cellClick(row, index, column) {
this.$emit('cellClick', row, index, column)
},
toggleRowSelection(row) {
const items = this.selectArr.find(v => v[this.rowKey] === row[this.rowKey])
if (items&&Object.keys(items).length > 0) {
this.data.forEach(item => {
if (item[this.rowKey] === row[this.rowKey]) {
this.$set(item, 'checked', false)
}
})
this.selectArr.forEach((item, index) => {
if (item[this.rowKey] === row[this.rowKey]) {
this.selectArr.splice(index, 1)
}
});
this.$emit('toggleRowSelection', false, this.selectArr)
} else {
this.data.forEach(item => {
if (item[this.rowKey] === row[this.rowKey]) {
this.$set(item, 'checked', true)
this.selectArr.push(item)
}
})
this.$emit('toggleRowSelection', true, this.selectArr)
}
},
rowClick(row, index) {
if (this.highlight) {
this.currentRowIndex = index
......@@ -1352,6 +1381,9 @@ export default {
//height: 100%;
width: 100%;
}
.cellfunction{
text-align: left;
}
.even {
background-color: white;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment