|
|
@ -126,6 +126,7 @@ |
|
|
const curRowId = ref<any>(''); |
|
|
const curRowId = ref<any>(''); |
|
|
const visible = ref(false); |
|
|
const visible = ref(false); |
|
|
const quillEditor = ref<InstanceType<typeof QuillEditor> | null>(null); |
|
|
const quillEditor = ref<InstanceType<typeof QuillEditor> | null>(null); |
|
|
|
|
|
const submitting = ref(false); // 表单提交状态 |
|
|
const editorOptions = ref({ |
|
|
const editorOptions = ref({ |
|
|
theme: 'snow', |
|
|
theme: 'snow', |
|
|
modules: { |
|
|
modules: { |
|
|
@ -205,7 +206,11 @@ |
|
|
// quillImageUploadCustom(quillEditor.value); |
|
|
// quillImageUploadCustom(quillEditor.value); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const handleOk = async () => { |
|
|
|
|
|
|
|
|
const handleOk = useDebounceFn(async () => { |
|
|
|
|
|
if (submitting.value) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const values = await formRef?.validate(); |
|
|
const values = await formRef?.validate(); |
|
|
if (values) { |
|
|
if (values) { |
|
|
console.log('values: ', values); |
|
|
console.log('values: ', values); |
|
|
@ -214,43 +219,51 @@ |
|
|
message.warning('请等待附件上传完成'); |
|
|
message.warning('请等待附件上传完成'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
values.id = curRecord.value.id; |
|
|
|
|
|
|
|
|
|
|
|
if (values.files && Array.isArray(values.files) && values.files.length) { |
|
|
|
|
|
values.files = values.files.map((e) => { |
|
|
|
|
|
if (e.response) { |
|
|
|
|
|
|
|
|
submitting.value = true; |
|
|
|
|
|
try { |
|
|
|
|
|
values.id = curRecord.value.id; |
|
|
|
|
|
|
|
|
|
|
|
if (values.files && Array.isArray(values.files) && values.files.length) { |
|
|
|
|
|
values.files = values.files.map((e) => { |
|
|
|
|
|
if (e.response) { |
|
|
|
|
|
return { |
|
|
|
|
|
name: e.name, |
|
|
|
|
|
url: e.response.url, |
|
|
|
|
|
id: e.response.id, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
return { |
|
|
return { |
|
|
name: e.name, |
|
|
|
|
|
url: e.response.url, |
|
|
|
|
|
id: e.response.id, |
|
|
|
|
|
|
|
|
...e, |
|
|
}; |
|
|
}; |
|
|
} |
|
|
|
|
|
return { |
|
|
|
|
|
...e, |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
values.fileIds = values.files |
|
|
|
|
|
.filter((e) => e.id) |
|
|
|
|
|
.map((e) => e.id) |
|
|
|
|
|
.join(','); |
|
|
|
|
|
} else { |
|
|
|
|
|
values.fileIds = ''; |
|
|
|
|
|
} |
|
|
|
|
|
if (values?.fileIds === ',') { |
|
|
|
|
|
values.fileIds = ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { |
|
|
|
|
|
values.tags = values.tags.join(','); |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
values.fileIds = values.files |
|
|
|
|
|
.filter((e) => e.id) |
|
|
|
|
|
.map((e) => e.id) |
|
|
|
|
|
.join(','); |
|
|
|
|
|
} else { |
|
|
|
|
|
values.fileIds = ''; |
|
|
|
|
|
} |
|
|
|
|
|
if (values?.fileIds === ',') { |
|
|
|
|
|
values.fileIds = ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { |
|
|
|
|
|
values.tags = values.tags.join(','); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await (values.id ? updateIssue : createIssue)(values); |
|
|
|
|
|
message.success(`${values.id ? '编辑' : '新增'}成功`); |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
resetFormFields(); |
|
|
|
|
|
dynamicTableInstance?.reload(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('提交失败:', error); |
|
|
|
|
|
} finally { |
|
|
|
|
|
submitting.value = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await (values.id ? updateIssue : createIssue)(values); |
|
|
|
|
|
message.success(`${values.id ? '编辑' : '新增'}成功`); |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
resetFormFields(); |
|
|
|
|
|
dynamicTableInstance?.reload(); |
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
}, 300); |
|
|
|
|
|
|
|
|
const handleCancel = () => { |
|
|
const handleCancel = () => { |
|
|
visible.value = false; |
|
|
visible.value = false; |
|
|
@ -311,17 +324,17 @@ |
|
|
handleEdit(record); |
|
|
handleEdit(record); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
|
|
|
icon: 'init', |
|
|
|
|
|
size: '15', |
|
|
|
|
|
title: '处理', |
|
|
|
|
|
label: '处理', |
|
|
|
|
|
ifShow: stateText === '退回', |
|
|
|
|
|
onClick: (e) => { |
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
changeState(record, 0); |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
// { |
|
|
|
|
|
// icon: 'init', |
|
|
|
|
|
// size: '15', |
|
|
|
|
|
// title: '处理', |
|
|
|
|
|
// label: '处理', |
|
|
|
|
|
// ifShow: stateText === '退回', |
|
|
|
|
|
// onClick: (e) => { |
|
|
|
|
|
// e.stopPropagation(); |
|
|
|
|
|
// changeState(record, 0); |
|
|
|
|
|
// }, |
|
|
|
|
|
// }, |
|
|
{ |
|
|
{ |
|
|
icon: 'dev', |
|
|
icon: 'dev', |
|
|
size: '15', |
|
|
size: '15', |
|
|
@ -330,7 +343,7 @@ |
|
|
ifShow: stateText === '待处理', |
|
|
ifShow: stateText === '待处理', |
|
|
onClick: (e) => { |
|
|
onClick: (e) => { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
changeState(record, 2); |
|
|
|
|
|
|
|
|
changeState(record, 1); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -338,10 +351,10 @@ |
|
|
size: '20', |
|
|
size: '20', |
|
|
title: '退回', |
|
|
title: '退回', |
|
|
label: '退回', |
|
|
label: '退回', |
|
|
ifShow: stateText === '开发中' || stateText === '测试中', |
|
|
|
|
|
|
|
|
ifShow: stateText !== '待处理' && stateText !== '关闭', |
|
|
onClick: (e) => { |
|
|
onClick: (e) => { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
changeState(record, 1); |
|
|
|
|
|
|
|
|
changeState(record, record.state - 1); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -352,7 +365,7 @@ |
|
|
ifShow: stateText === '开发中', |
|
|
ifShow: stateText === '开发中', |
|
|
onClick: (e) => { |
|
|
onClick: (e) => { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
changeState(record, 3); |
|
|
|
|
|
|
|
|
changeState(record, 2); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
// 待客户确认 4 |
|
|
// 待客户确认 4 |
|
|
@ -364,7 +377,7 @@ |
|
|
ifShow: stateText === '测试中', |
|
|
ifShow: stateText === '测试中', |
|
|
onClick: (e) => { |
|
|
onClick: (e) => { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
changeState(record, 4); |
|
|
|
|
|
|
|
|
changeState(record, 3); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -375,7 +388,7 @@ |
|
|
ifShow: stateText === '待客户确认', |
|
|
ifShow: stateText === '待客户确认', |
|
|
onClick: (e) => { |
|
|
onClick: (e) => { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
changeState(record, 5); |
|
|
|
|
|
|
|
|
changeState(record, 4); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -397,7 +410,7 @@ |
|
|
ifShow: stateText !== '关闭', |
|
|
ifShow: stateText !== '关闭', |
|
|
onClick: (e) => { |
|
|
onClick: (e) => { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
changeState(record, 6); |
|
|
|
|
|
|
|
|
changeState(record, 5); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -425,44 +438,62 @@ |
|
|
/** |
|
|
/** |
|
|
* @description 打开问题工单弹窗 |
|
|
* @description 打开问题工单弹窗 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
// 创建防抖的提交处理函数 |
|
|
|
|
|
const createSubmitHandler = (record: Partial<TableListItem>, isModal = false) => { |
|
|
|
|
|
let isSubmitting = false; |
|
|
|
|
|
return useDebounceFn(async (values: any) => { |
|
|
|
|
|
if (isSubmitting) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
isSubmitting = true; |
|
|
|
|
|
try { |
|
|
|
|
|
console.log('新增/编辑问题工单', values); |
|
|
|
|
|
values.id = record.id; |
|
|
|
|
|
|
|
|
|
|
|
if (values.files && Array.isArray(values.files) && values.files.length) { |
|
|
|
|
|
values.files = values.files.map((e) => { |
|
|
|
|
|
if (e.response) { |
|
|
|
|
|
return { |
|
|
|
|
|
name: e.name, |
|
|
|
|
|
url: e.response.url, |
|
|
|
|
|
id: e.response.id, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
return { |
|
|
|
|
|
...e, |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
values.fileIds = values.files |
|
|
|
|
|
.filter((e) => e.id) |
|
|
|
|
|
.map((e) => e.id) |
|
|
|
|
|
.join(','); |
|
|
|
|
|
} else { |
|
|
|
|
|
values.fileIds = ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { |
|
|
|
|
|
values.tags = values.tags.join(','); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await (record.id ? updateIssue : createIssue)(values); |
|
|
|
|
|
message.success(`${record.id ? '编辑' : '新增'}成功`); |
|
|
|
|
|
dynamicTableInstance?.reload(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('提交失败:', error); |
|
|
|
|
|
} finally { |
|
|
|
|
|
isSubmitting = false; |
|
|
|
|
|
} |
|
|
|
|
|
}, 300); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const openIssueModal = async (record: Partial<TableListItem> = {}, isReadOnly = false) => { |
|
|
const openIssueModal = async (record: Partial<TableListItem> = {}, isReadOnly = false) => { |
|
|
|
|
|
const handleSubmit = createSubmitHandler(record); |
|
|
|
|
|
|
|
|
const [formRef] = await showModal<any>({ |
|
|
const [formRef] = await showModal<any>({ |
|
|
modalProps: { |
|
|
modalProps: { |
|
|
title: `${isReadOnly ? '查看' : record.id ? '编辑' : '新增'}问题工单`, |
|
|
title: `${isReadOnly ? '查看' : record.id ? '编辑' : '新增'}问题工单`, |
|
|
width: 700, |
|
|
width: 700, |
|
|
onFinish: async (values) => { |
|
|
|
|
|
console.log('新增/编辑问题工单', values); |
|
|
|
|
|
values.id = record.id; |
|
|
|
|
|
|
|
|
|
|
|
if (values.files && Array.isArray(values.files) && values.files.length) { |
|
|
|
|
|
values.files = values.files.map((e) => { |
|
|
|
|
|
if (e.response) { |
|
|
|
|
|
return { |
|
|
|
|
|
name: e.name, |
|
|
|
|
|
url: e.response.url, |
|
|
|
|
|
id: e.response.id, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
return { |
|
|
|
|
|
...e, |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
values.fileIds = values.files |
|
|
|
|
|
.filter((e) => e.id) |
|
|
|
|
|
.map((e) => e.id) |
|
|
|
|
|
.join(','); |
|
|
|
|
|
} else { |
|
|
|
|
|
values.fileIds = ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (values?.tags && Array.isArray(values.tags) && values.tags.length) { |
|
|
|
|
|
values.tags = values.tags.join(','); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await (record.id ? updateIssue : createIssue)(values); |
|
|
|
|
|
message.success(`${record.id ? '编辑' : '新增'}成功`); |
|
|
|
|
|
dynamicTableInstance?.reload(); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
onFinish: handleSubmit, |
|
|
footer: isReadOnly ? null : undefined, |
|
|
footer: isReadOnly ? null : undefined, |
|
|
}, |
|
|
}, |
|
|
formProps: { |
|
|
formProps: { |
|
|
@ -499,26 +530,40 @@ |
|
|
|
|
|
|
|
|
const openFlowModal = async (record: Partial<TableListItem> = {}, state) => { |
|
|
const openFlowModal = async (record: Partial<TableListItem> = {}, state) => { |
|
|
const flowTitle = stateTypeList.find((item) => item.value === state)?.label; |
|
|
const flowTitle = stateTypeList.find((item) => item.value === state)?.label; |
|
|
|
|
|
|
|
|
|
|
|
let isFlowSubmitting = false; |
|
|
|
|
|
const handleFlowSubmit = useDebounceFn(async (values: any) => { |
|
|
|
|
|
if (isFlowSubmitting) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
isFlowSubmitting = true; |
|
|
|
|
|
try { |
|
|
|
|
|
await updateIssueState({ |
|
|
|
|
|
id: record.id, |
|
|
|
|
|
state: state, |
|
|
|
|
|
...values, |
|
|
|
|
|
}); |
|
|
|
|
|
message.success(`操作成功`); |
|
|
|
|
|
dynamicTableInstance?.reload(); |
|
|
|
|
|
// 判断当前行是否有选中 |
|
|
|
|
|
if (curRowId.value === record.id) { |
|
|
|
|
|
curRowId.value = ''; |
|
|
|
|
|
nextTick(() => { |
|
|
|
|
|
curRowId.value = record.id; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('提交失败:', error); |
|
|
|
|
|
} finally { |
|
|
|
|
|
isFlowSubmitting = false; |
|
|
|
|
|
} |
|
|
|
|
|
}, 300); |
|
|
|
|
|
|
|
|
const [formRef] = await showFlowModal<any>({ |
|
|
const [formRef] = await showFlowModal<any>({ |
|
|
modalProps: { |
|
|
modalProps: { |
|
|
title: `${flowTitle}问题工单`, |
|
|
title: `${flowTitle}问题工单`, |
|
|
width: 700, |
|
|
width: 700, |
|
|
onFinish: async (values) => { |
|
|
|
|
|
await updateIssueState({ |
|
|
|
|
|
id: record.id, |
|
|
|
|
|
state: state, |
|
|
|
|
|
...values, |
|
|
|
|
|
}); |
|
|
|
|
|
message.success(`操作成功`); |
|
|
|
|
|
dynamicTableInstance?.reload(); |
|
|
|
|
|
// 判断当前行是否有选中 |
|
|
|
|
|
if (curRowId.value === record.id) { |
|
|
|
|
|
curRowId.value = ''; |
|
|
|
|
|
nextTick(() => { |
|
|
|
|
|
curRowId.value = record.id; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
onFinish: handleFlowSubmit, |
|
|
}, |
|
|
}, |
|
|
formProps: { |
|
|
formProps: { |
|
|
labelWidth: 100, |
|
|
labelWidth: 100, |
|
|
|