|
|
@ -1,7 +1,9 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div class="jcb-table-container"> |
|
|
<div class="jcb-table-container"> |
|
|
<CustomTable :ref="`tableRef`" :columns="jcbColumns" :formData="formData" :prefixKey="prefixKey" |
|
|
<CustomTable :ref="`tableRef`" :columns="jcbColumns" :formData="formData" :prefixKey="prefixKey" |
|
|
class="jcb-table" operationWidth="120px" @clickButton="handleClickButton" |
|
|
|
|
|
|
|
|
class="jcb-table" operationWidth="120px" @clickButton="handleClickButton" @blur="commonHandleUpdate" |
|
|
|
|
|
@onAddRow="onAddRow" |
|
|
|
|
|
@onRegentSubmit="commonHandleUpdate" |
|
|
fieldItemLabel="template.common.operationSteps" :showOperation="templateFillType === 'preFill'"> |
|
|
fieldItemLabel="template.common.operationSteps" :showOperation="templateFillType === 'preFill'"> |
|
|
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> |
|
|
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> |
|
|
<TableOpertaionDelete :row="row" :rowIndex="rowIndex" :columns="columns" @deleteRow="deleteRow"> |
|
|
<TableOpertaionDelete :row="row" :rowIndex="rowIndex" :columns="columns" @deleteRow="deleteRow"> |
|
|
@ -12,7 +14,8 @@ |
|
|
</template> |
|
|
</template> |
|
|
<script> |
|
|
<script> |
|
|
import CustomTable from '../CustomTable.vue'; |
|
|
import CustomTable from '../CustomTable.vue'; |
|
|
import TableOpertaionDelete from "@/components/Template/operation/TableOpertaionDelete.vue" |
|
|
|
|
|
|
|
|
import TableOpertaionDelete from "@/components/Template/operation/TableOpertaionDelete.vue"; |
|
|
|
|
|
import { getuuid } from "@/utils/index.js"; |
|
|
import moment from "moment" |
|
|
import moment from "moment" |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
@ -32,6 +35,10 @@ export default { |
|
|
default: '', |
|
|
default: '', |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
}; |
|
|
|
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
jcbColumns() { |
|
|
jcbColumns() { |
|
|
return [ |
|
|
return [ |
|
|
@ -60,11 +67,23 @@ export default { |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
// 添加表格行 |
|
|
|
|
|
onAddRow(data) { |
|
|
|
|
|
const { dataSource = [] } = data; |
|
|
|
|
|
const tableRef = this.$refs['tableRef']; |
|
|
|
|
|
if (tableRef) { |
|
|
|
|
|
tableRef.addRow({ clp: '', time: '' ,id:getuuid(),rowIndex:dataSource.length}); |
|
|
|
|
|
// 添加行后触发数据变化 |
|
|
|
|
|
this.onDataChange(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
// 删除表格行 |
|
|
// 删除表格行 |
|
|
deleteRow(rowIndex) { |
|
|
deleteRow(rowIndex) { |
|
|
const tableRef = this.$refs['tableRef']; |
|
|
const tableRef = this.$refs['tableRef']; |
|
|
if (tableRef) { |
|
|
if (tableRef) { |
|
|
tableRef.deleteRow(rowIndex); |
|
|
tableRef.deleteRow(rowIndex); |
|
|
|
|
|
// 删除行后触发数据变化 |
|
|
|
|
|
this.onDataChange(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 实现validateFormData方法,用于表单验证 |
|
|
// 实现validateFormData方法,用于表单验证 |
|
|
@ -85,11 +104,34 @@ export default { |
|
|
return validateResult; |
|
|
return validateResult; |
|
|
}, |
|
|
}, |
|
|
// 点击按钮事件 |
|
|
// 点击按钮事件 |
|
|
handleClickButton(key, rowIndex, row) { |
|
|
|
|
|
|
|
|
handleClickButton(key, rowIndex) { |
|
|
if (key === 'timeClick') { |
|
|
if (key === 'timeClick') { |
|
|
this.$refs['tableRef'].updateDataSourceByRowIndex(rowIndex, { time: moment().format("YYYY-MM-DD HH:mm:ss") }) |
|
|
this.$refs['tableRef'].updateDataSourceByRowIndex(rowIndex, { time: moment().format("YYYY-MM-DD HH:mm:ss") }) |
|
|
|
|
|
this.onDataChange(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 数据变化处理方法 |
|
|
|
|
|
onDataChange() { |
|
|
|
|
|
// 获取表格数据 |
|
|
|
|
|
let tableData = []; |
|
|
|
|
|
if (this.$refs.tableRef) { |
|
|
|
|
|
const filledData = this.$refs.tableRef.getFilledFormData(); |
|
|
|
|
|
tableData = filledData.stepTableFormData || []; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 触发自定义事件,将数据变化传递给父组件 |
|
|
|
|
|
this.$emit('update', { |
|
|
|
|
|
jcbInfo: { |
|
|
|
|
|
stepTableFormData: tableData, |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 处理表格blur事件 |
|
|
|
|
|
commonHandleUpdate() { |
|
|
|
|
|
// 表格数据变化时触发数据变化通知 |
|
|
|
|
|
this.onDataChange(); |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|