feat: task order (#141)

* feat: task order => routes

* feat: Page

* refactor: pagination

* refactor: taskOrder => table, card and constants

* feat: add structure select request list comp

* fix: re-export type

* refactor: edit path route of task order

* feat: trigger task order

* refactor: edit type task statss

* feat: table select request list

* feat: i18n

* refactor: quasar expansion chevron color

* refactor: type

* refactor: state btn status done

* feat: task order => order view layout

* feat: task order => remark expansion

* fix: task order => rename attachment to additional file

* feat: upload file section optional layout

* feat: task order => additional file expansion

* feat: task order => payment expansion

* feat: conditionally add urgent

* feat: send id together with link

* refactor: edit type

* feat: new form.ts

* refactor: edit url

* refactor: edit id trigger

* feat: select institution component

* feat: task order code i18n

* feat: task order => document expansion form

* feat: fallback address on null

* refactor: add type for table

* feat: add filter parameter

* refactor: edit name routes

* refactor: add type of task order payload

* refactor: by value form

* refactor: responsive quotation form info

* refactor: submit form

* refactor: add i18n

* refactor: status canceled

* refactor: handle task status

* refactor: handle mode view

* refactor: addtaskstatus

* refactor: i18n & constants

* refactor: table employee

* refactor: select ready request work

* refactor: handle save form

* refactor: edit layout btn

* feat: undo()

* cleanup delete import

* feat: closetab

* refactor: handle readonly

* fix: body edit

* refactor: handle readonly uploadfile

* feat: import manage attachment

* refactor: quotation/task-order => type

* refactor: select ready request work

* refactor: i18n & constants

* chore: clean duplicate i18n

* refactor: type according to backend relation

* refactor: edit base url

* feat: upload file

* feat: fetch file list

* feat: get url file

* refactor: set default opened

* refactor: type

* feat: removefile

* feat: task order => select product

* feat: add parameter only active branch is selectable

* refactor: add i18n

* feat: set layout

* feat: add info product expansion

* refactor: new info messenger

* refactor: add slot name value

* refactor: add i18n

* refactor: edit type task status

* refactor: use date format

* refactor: value can null

* refactor: add i18n

* cleanup

* feat: productlistinput

* refactor: edit i18n

* refactor: edit redo

* refactor: add slot

* feat: task order => i18n

* refactor: task order => constant

* refactor: taskOrder => status type and index

* feat: taskOrder => ReceiveDialog

* refactor: wording

* refactor: table employee due date

* refactor: receive task i18n

* feat: trigger receive & task stat in receive page

* refactor: receive dialog task in cart  i18n

* fix: remove task-order/receive/add

* feat: receivetabletaskorder

* refactor: fetch task on receive dialog

* feat: add separate api get user task

* refactor: receive fetch (messenger)

* refactor: edit layout table

* refactor: task order i18n & constant

* refactor: task order change tab and stat (messenger and !messenger)

* fix: task order status display & receive badge color (card)

* refactor: trigger receive view

* fix: add receive task condition

* feat: total count

* feat: prepare information

* fix: i18n error task order not found

* refacor: value

* feat: select worker

* refactor: status i18n & constant

* refactor: table employee props (check box, step)

* fix: order => select ready task

* refactor: order => toggle status

* refactor: receive => receive dialog

* feat: featch value

* refactor: task status display components

* refactor: status active can is null

* feat: update status tab

* refactor: data display

* refactor: i18n & fullTaskOrder variable

* refactor: task receive view

* refactor: add type responsible user

* refactor: set group messenger

* cleanup:

* refactor: i18n / clone full task order / service => workflow type

* refactor: receive view

* refactor: show info messenger

* refactor: handle flow step

* refactor: receive view => opacity when pending

* feat: add workflow template name and step name

* feat: display workflow data on table

* feat: add template step identifier

* fix: edit does not change workflow id if changed

* feat: detect if same template and step

* refactor: handle template

* refactor: add slot name product

* refactor: map step in list product

* refactor: bind data messenger list group

* refactor: change endpoint name

* chore: add helper package

* feat: changetaskstatus

* refactor: update type

* refactor: set color btn

* refactor: add step

* refactor: add resposible institution

* feat: disabled

* refactor: map responsible institution

* fix: order view => readonly

* chore: clean

* refactor: edit url api

* refactor: edit name type

* refactor: add slots action

* refactor: add type row

* refactor: add opts of task status

* refactor: add select status

* refactor: handle btn

* refactor: add btn change task status

* refactor: edit i18n redo th

* refactor: sort status opts

* feat: receive & order banner img

* refactor: fetch status after submit

* refactor: handle create only

* refactor: task order status type Accept (messenger only)

* feat: receive messenger profile

* refactor: receive toggle status (display only)

* fix: document expansion readonly

* feat: confirmsendingbtn

* refactor: constant and task order status

* feat: receive task list count

* refactor: post or get

* refactor: define props institution group

* refactor: fetch status after submit

* refactor: handle create

* refactor: handle query

* refactor: update endpoint to support accept multiple order

* refactor: change function name

* feat: receive => functional accept task order

* feat: task status count

* feat: receive stat card count

* refactor: order messenger profile

* refactor: edit value to be task status

* refactor: handle status of type order

* refactor: use componet task status

* refactor: handle show btn saving status

* refactor: order => task status

* refactor: edit selectStatus => changeStatus

* refactor: edit @click btn confirmssending

* refactor: add i18n

* refactor: add function get template data

* refactor: add change status

* refactor: handle type receive

* feat: order => auto change tab by status

* refactor: fetch task after change status

* feat: fail remark dialog

* refactor: display step order (table employee)

* refactor: fail remark dialog

* refactor: order => open ready request dialog map selected

* refactor: task list type & change status param

* refactor: table task order, td background when selected

* refactor: order => change status param

* refactor: order => selectedEmployee variable type

* refactor: task status component => shield btn

* refactor: receive => change status

* refactor: order => step btn waiting

* fix: step btn waiting condition

* refactor: filter selectable task (Failed)

* refactor: find index condition on check

* refactor: no request list available

* refactor: fail btn no-wrap

* refactor: fail dialog readonly

* fix: reset state on open dialog

* fix: wrong title position

* refactor: hide task status drop down icon

* fix: handle check condition

* refactor: add userTask type and status

* feat: submit task order function

* refactor: table employee checkbox display condition

* refactor: main layout

* fix: task order validate i18n

* refactor: table task order add submit status

* refactor: status list

* refactor: info product => user task status

* feat: receive => submit task & step

* refactor: i18n

* feat: complete task oder function

* refactor: task status component no action props

* refactor: info messenger status

* refactor: receive and order view

* refactor: order complete view

* refactor: order => complete color and title

* refactor: calc price on table

* refactor: quotation table i18n + product image

* refactor: remove urgent checkbox

* refactor: task status color

* feat: calc summary price

* fix: data is not available

* feat: add doc view structure

* refactor: format address text

* feat: fetch document data from api

* fix: value is null

* fix: regression cannot edit package

* feat: add document view for task order

* feat: add view document button

* feat: update type add discount

* feat: readonly on cancel

* feat: add discount from relation

* refactor: add taskProduct on submit order

* refactor: order => task product discount

* refactor: order => date, task status count, view example

* refactor: receive date

* refactor: receive task status count

---------

Co-authored-by: puriphatt <puriphat@frappet.com>
Co-authored-by: nwpptrs <jay02499@gmail.com>
Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
Co-authored-by: Methapon2001 <61303214+Methapon2001@users.noreply.github.com>
Co-authored-by: oat_dev <nattapon@frappet.com>
This commit is contained in:
Methapon Metanipat 2024-12-25 11:59:49 +07:00 committed by GitHub
parent cd0831bac1
commit 9eff614dbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 6981 additions and 361 deletions

View file

@ -85,6 +85,7 @@ const useCustomerStore = defineStore('api-customer', () => {
query?: string;
page?: number;
pageSize?: number;
activeRegisBranchOnly?: boolean;
},
Data extends Pagination<
(CustomerBranch &

View file

@ -21,15 +21,29 @@ export const useInstitution = defineStore('institution-store', () => {
return null;
}
async function getInstitutionList(params?: {
async function getInstitutionList(opts?: {
page?: number;
pageSize?: number;
query?: string;
group?: string;
payload?: { group?: string[] };
}) {
const res = await api.get<PaginationResult<Institution>>('/institution', {
params,
});
const { payload, ...params } = opts || {};
console.log(params.query);
const res = payload
? await api.post<PaginationResult<Institution>>(
'/institution/list',
payload,
{
params,
},
)
: await api.get<PaginationResult<Institution>>(`/institution`, {
params,
});
if (res.status < 400) {
return res.data;
}

View file

@ -1,6 +1,9 @@
import { Status } from '../types';
import { UpdatedBy, CreatedBy } from 'stores/types';
import { WorkFlowPayloadStep } from '../workflow-template/types';
import {
WorkFlowPayloadStep,
WorkflowTemplate,
} from '../workflow-template/types';
export interface TreeProduct {
name: string;
@ -27,6 +30,8 @@ export interface Service {
work: Work[];
imageUrl: string;
registeredBranchId: string;
workflowId?: string;
workflow: WorkflowTemplate;
}
export interface WorkCreate {
@ -80,6 +85,8 @@ export interface Attributes {
workflowStep: (WorkFlowPayloadStep & { productsId: string[] })[];
}
export type PropVariant = PropString | PropNumber | PropDate | PropOptions;
export type PropString = {
type: 'string';
fieldName: string;

View file

@ -3,6 +3,7 @@ import { District, Province, SubDistrict } from '../address';
import { CreatedBy, Status, UpdatedBy } from '../types';
import { Invoice } from '../payment/types';
import { Employee } from '../employee/types';
import { WorkflowTemplate } from '../workflow-template/types';
export type PayCondition =
| 'Full'
@ -184,6 +185,7 @@ type ServiceRelation = {
createdByUserId: string;
updatedAt: string;
updatedByUserId: string;
workflow?: WorkflowTemplate;
work: (WorkRelation & {
productOnWork: {
@ -331,6 +333,8 @@ export type QuotationFull = {
updatedByUserId: string;
updatedAt: string | Date;
updatedBy: UpdatedBy;
agentPrice?: boolean;
};
export type QuotationPayload = {

View file

@ -215,9 +215,12 @@ export const useRequestList = defineStore('request-list', () => {
}
async function getRequestWorkList(params?: {
requestDataId?: string;
query?: string;
page?: number;
pageSize?: number;
requestDataId?: string;
workStatus?: RequestWorkStatus;
readyToTask?: boolean;
}) {
const res = await api.get<PaginationResult<RequestWork>>('/request-work', {
params,
@ -290,3 +293,5 @@ export const useRequestList = defineStore('request-list', () => {
cancelRequest,
};
});
export * from './types.ts';

View file

@ -22,6 +22,7 @@ export enum RequestDataStatus {
Pending = 'Pending',
InProgress = 'InProgress',
Completed = 'Completed',
Canceled = 'Canceled',
}
export enum RequestWorkStatus {

View file

@ -0,0 +1,189 @@
import { ref } from 'vue';
import { defineStore } from 'pinia';
import { api } from 'src/boot/axios';
// NOTE: Stores
// NOTE: Type
import {
SetTaskStatusPayload,
TaskOrder,
TaskOrderPayload,
TaskOrderStatus,
UserTaskStatus,
} from './types';
import { PaginationResult } from 'src/types';
import { manageAttachment } from '../utils';
export const useTaskOrderStore = defineStore('taskorder-store', () => {
const data = ref<TaskOrder[]>([]);
const page = ref<number>(1);
const pageMax = ref<number>(1);
const pageSize = ref<number>(30);
const stats = ref<Record<TaskOrderStatus, number>>({
[TaskOrderStatus.Pending]: 0,
[TaskOrderStatus.InProgress]: 0,
[TaskOrderStatus.Validate]: 0,
[TaskOrderStatus.Complete]: 0,
[TaskOrderStatus.Accept]: 0,
[TaskOrderStatus.Submit]: 0,
});
const fileManager = manageAttachment(api, 'task-order');
async function getTaskOrderStats() {
const res =
await api.get<Record<TaskOrderStatus, number>>('/task-order/stats');
if (res.status < 400) {
stats.value = res.data;
return res.data;
}
return null;
}
async function getTaskOrderList(params?: {
page?: number;
pageSize?: number;
query?: string;
taskOrderStatus?: TaskOrderStatus;
assignedUserId?: boolean;
}) {
const res = await api.get<PaginationResult<TaskOrder>>('/task-order', {
params,
});
if (res.status < 400) {
return res.data;
}
return null;
}
async function getTaskOrderById(
id: string,
params?: { taskAssignedUserId?: string },
) {
const res = await api.get<TaskOrder>(`/task-order/${id}`, { params });
if (res.status < 400) {
return res.data;
}
return null;
}
async function createTaskOrder(body: TaskOrderPayload) {
const res = await api.post<TaskOrder>('/task-order', body);
if (res.status < 400) {
return res.data;
}
return null;
}
async function changeTaskStatus(id: string, body: SetTaskStatusPayload[]) {
const res = await api.post<TaskOrder>(
`/task-order/${id}/set-task-status`,
body,
);
if (res.status < 400) {
return res.data;
}
return null;
}
async function acceptTaskOrder(id: string | string[]) {
const res = await api.post<TaskOrder>('/user-task-order/accept', {
taskOrderId: Array.isArray(id) ? id : [id],
});
if (res.status < 400) {
return res.data;
}
return null;
}
async function editTaskOrder(body: TaskOrderPayload) {
const res = await api.put<TaskOrder>(`/task-order/${body.id}`, {
taskList: body.taskList.map((v) => ({
step: v.step,
requestWorkId: v.requestWorkId,
})),
institutionId: body.institutionId,
contactTel: body.contactTel,
contactName: body.contactName,
taskStatus: body.taskStatus,
taskName: body.taskName,
});
if (res.status < 400) {
return res.data;
}
return null;
}
async function deleteTaskOrder(id: string) {
const res = await api.delete<TaskOrder>(`/task-order/${id}`);
if (res.status < 400) {
return true;
}
return null;
}
async function submitTaskOrder(id: string) {
const res = await api.post<TaskOrder>(`/task-order/${id}/submit`);
if (res.status < 400) {
return true;
}
return null;
}
async function completeTaskOrder(id: string) {
const res = await api.post<TaskOrder>(`/task-order/${id}/complete`);
if (res.status < 400) {
return true;
}
return null;
}
async function getUserTaskOrderList(params?: {
page?: number;
pageSize?: number;
query?: string;
userTaskStatus?: UserTaskStatus;
}) {
const res = await api.get<PaginationResult<TaskOrder>>('/user-task-order', {
params,
});
if (res.status < 400) {
return res.data;
}
return null;
}
return {
data,
page,
pageMax,
pageSize,
stats,
getTaskOrderStats,
getTaskOrderList,
getTaskOrderById,
createTaskOrder,
acceptTaskOrder,
editTaskOrder,
deleteTaskOrder,
changeTaskStatus,
submitTaskOrder,
completeTaskOrder,
// for receive user (messenger role)
getUserTaskOrderList,
...fileManager,
};
});

View file

@ -0,0 +1,207 @@
import { strict } from 'node:assert';
import { Branch } from '../branch/types';
import { Product, Service, Work } from '../product-service/types';
import { RequestWork } from '../request-list/types';
import { CreatedBy } from '../types';
import { User } from '../user';
export enum TaskOrderStatus {
Pending = 'Pending',
InProgress = 'InProgress',
Validate = 'Validate',
Complete = 'Complete',
Accept = 'Accept', // messenger only
Submit = 'Submit', // messenger only
}
export enum TaskStatus {
Pending = 'Pending',
InProgress = 'InProgress',
Success = 'Success',
Failed = 'Failed',
Redo = 'Redo',
Validate = 'Validate',
Complete = 'Complete',
Canceled = 'Canceled',
}
export interface TaskOrder {
createdBy: CreatedBy;
registeredBranch: Branch;
taskProduct: {
productId: string;
discount?: number;
}[];
taskList: {
step: number;
requestWorkId: string;
requestWorkStep: Task;
taskStatus: TaskStatus;
taskOrderId: string;
id: string;
failedType?: string;
failedComment?: string;
}[];
institution: Institution;
createdByUserId: string;
createdAt: string;
registeredBranchId: string;
institutionId: string;
contactTel: string;
contactName: string;
taskOrderStatus: TaskOrderStatus;
taskName: string;
code: string;
id: string;
userTask: UserTask[];
}
export interface UserTask {
id: string;
taskOrderId: string;
userId: string;
userTaskStatus: UserTaskStatus;
}
export interface Institution {
selectedImage: string;
subDistrictId: string;
districtId: string;
provinceId: string;
streetEN: string;
street: string;
mooEN: string;
moo: string;
soiEN: string;
soi: string;
addressEN: string;
address: string;
nameEN: string;
group: string;
name: string;
code: string;
id: string;
}
export interface AcceptedBy {
updatedByUserId: string;
updatedAt: string;
statusOrder: number;
status: string;
birthDate: string;
trainingPlace: string;
importNationality: string;
sourceNationality: string;
licenseExpireDate: string;
licenseIssueDate: string;
licenseNo: string;
discountCondition: string;
citizenExpire: string;
citizenIssue: string;
citizenId: string;
userRole: string;
userType: string;
checkpointEN: string;
checkpoint: string;
retireDate: string;
startDate: string;
registrationNo: string;
telephoneNo: string;
email: string;
gender: string;
username: string;
lastNameEN: string;
lastName: string;
middleNameEN: string;
middleName: string;
firstNameEN: string;
firstName: string;
namePrefix: string;
selectedImage: string;
subDistrictId: string;
districtId: string;
provinceId: string;
streetEN: string;
street: string;
mooEN: string;
moo: string;
soiEN: string;
soi: string;
addressEN: string;
address: string;
createdByUserId: string;
createdAt: string;
code: string;
id: string;
}
export interface Task {
step: number;
workStatus: string;
requestWorkId: string;
attributes: any;
customerDuty?: boolean;
customerDutyCost?: number;
companyDuty?: boolean;
companyDutyCost?: number;
individualDuty?: boolean;
individualDutyCost?: number;
responsibleUserLocal?: boolean;
responsibleUserId?: string;
responsibleUser?: User;
taskOrderId: string;
requestWork: RequestWork;
}
export interface TaskOrderPayload {
taskList: {
step: number;
requestWorkId: string;
requestWorkStep?: Task;
taskStatus?: TaskStatus;
}[];
taskProduct?: {
productId: string;
discount?: number;
}[];
institutionId: string;
contactTel: string;
contactName: string;
taskStatus?: TaskOrderStatus;
taskName: string;
registeredBranchId?: string;
id?: string;
code?: string;
}
export interface ProductService {
id: string;
quotationId: string;
order: number;
vat: number;
amount: number;
discount: number;
pricePerUnit: number;
installmentNo: number;
productId: string;
workId: string;
serviceId: string;
attributes: any;
product: Product;
service: Service;
work: Work;
}
export enum UserTaskStatus {
Pending = 'Pending',
Accept = 'Accept',
Submit = 'Submit',
}
export interface SetTaskStatusPayload {
failedComment?: string;
failedType?: string;
taskStatus: TaskStatus;
requestWorkId: string;
step: number;
}

View file

@ -117,7 +117,7 @@ export function deleteItem(items: unknown[], index: number) {
}
}
export function formatNumberDecimal(num: number, point: number): string {
export function formatNumberDecimal(num: number, point: number = 2): string {
return num.toLocaleString('eng', {
minimumFractionDigits: point,
maximumFractionDigits: point,

View file

@ -21,7 +21,7 @@ export type WorkflowStep = {
userId: string;
user: CreatedBy;
}[];
responsibleInstitution: string[];
responsibleInstitution: (string | { group: string })[];
attributes: WorkFlowAttributes;
};