IO-853 Added delete bill line.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { WarningOutlined } from "@ant-design/icons";
|
import { DeleteFilled, WarningOutlined } from "@ant-design/icons";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Form,
|
Form,
|
||||||
@@ -36,7 +36,8 @@ export function BillEnterModalLinesComponent({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { setFieldsValue, getFieldsValue, getFieldValue } = form;
|
const { setFieldsValue, getFieldsValue, getFieldValue } = form;
|
||||||
|
|
||||||
const columns = [
|
const columns = (remove) => {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
title: t("billlines.fields.jobline"),
|
title: t("billlines.fields.jobline"),
|
||||||
dataIndex: "joblineid",
|
dataIndex: "joblineid",
|
||||||
@@ -69,8 +70,9 @@ export function BillEnterModalLinesComponent({
|
|||||||
quantity: opt.part_qty || 1,
|
quantity: opt.part_qty || 1,
|
||||||
actual_price: opt.cost,
|
actual_price: opt.cost,
|
||||||
cost_center: opt.part_type
|
cost_center: opt.part_type
|
||||||
? responsibilityCenters.defaults.costs[opt.part_type] ||
|
? responsibilityCenters.defaults.costs[
|
||||||
null
|
opt.part_type
|
||||||
|
] || null
|
||||||
: null,
|
: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -104,6 +106,7 @@ export function BillEnterModalLinesComponent({
|
|||||||
title: t("billlines.fields.quantity"),
|
title: t("billlines.fields.quantity"),
|
||||||
dataIndex: "quantity",
|
dataIndex: "quantity",
|
||||||
editable: true,
|
editable: true,
|
||||||
|
width: "5rem",
|
||||||
formItemProps: (field) => {
|
formItemProps: (field) => {
|
||||||
return {
|
return {
|
||||||
key: `${field.index}quantity`,
|
key: `${field.index}quantity`,
|
||||||
@@ -123,6 +126,7 @@ export function BillEnterModalLinesComponent({
|
|||||||
{
|
{
|
||||||
title: t("billlines.fields.actual_price"),
|
title: t("billlines.fields.actual_price"),
|
||||||
dataIndex: "actual_price",
|
dataIndex: "actual_price",
|
||||||
|
width: "6rem",
|
||||||
editable: true,
|
editable: true,
|
||||||
formItemProps: (field) => {
|
formItemProps: (field) => {
|
||||||
return {
|
return {
|
||||||
@@ -179,6 +183,7 @@ export function BillEnterModalLinesComponent({
|
|||||||
title: t("billlines.fields.actual_cost"),
|
title: t("billlines.fields.actual_cost"),
|
||||||
dataIndex: "actual_cost",
|
dataIndex: "actual_cost",
|
||||||
editable: true,
|
editable: true,
|
||||||
|
width: "7rem",
|
||||||
formItemProps: (field) => {
|
formItemProps: (field) => {
|
||||||
return {
|
return {
|
||||||
key: `${field.index}actual_cost`,
|
key: `${field.index}actual_cost`,
|
||||||
@@ -389,9 +394,21 @@ export function BillEnterModalLinesComponent({
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
{
|
||||||
|
title: t("general.labels.actions"),
|
||||||
|
|
||||||
const mergedColumns = columns.map((col) => {
|
dataIndex: "actions",
|
||||||
|
render: (text, record) => (
|
||||||
|
<Button disabled={disabled} onClick={() => remove(record.name)}>
|
||||||
|
<DeleteFilled />
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
const mergedColumns = (remove) =>
|
||||||
|
columns(remove).map((col) => {
|
||||||
if (!col.editable) return col;
|
if (!col.editable) return col;
|
||||||
return {
|
return {
|
||||||
...col,
|
...col,
|
||||||
@@ -420,7 +437,7 @@ export function BillEnterModalLinesComponent({
|
|||||||
size="small"
|
size="small"
|
||||||
bordered
|
bordered
|
||||||
dataSource={fields}
|
dataSource={fields}
|
||||||
columns={mergedColumns}
|
columns={mergedColumns(remove)}
|
||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
rowClassName="editable-row"
|
rowClassName="editable-row"
|
||||||
/>
|
/>
|
||||||
@@ -467,7 +484,7 @@ const EditableCell = ({
|
|||||||
name={dataIndex}
|
name={dataIndex}
|
||||||
{...(formItemProps && formItemProps(record))}
|
{...(formItemProps && formItemProps(record))}
|
||||||
>
|
>
|
||||||
{formInput && formInput(record, record.key)}
|
{(formInput && formInput(record, record.key)) || children}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{additional && additional(record, record.key)}
|
{additional && additional(record, record.key)}
|
||||||
</Space>
|
</Space>
|
||||||
@@ -477,7 +494,7 @@ const EditableCell = ({
|
|||||||
return (
|
return (
|
||||||
<td {...restProps}>
|
<td {...restProps}>
|
||||||
<Form.Item name={dataIndex} {...(formItemProps && formItemProps(record))}>
|
<Form.Item name={dataIndex} {...(formItemProps && formItemProps(record))}>
|
||||||
{formInput && formInput(record, record.key)}
|
{(formInput && formInput(record, record.key)) || children}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user