| | |
| | | * @version: |
| | | * @Date: 2024-06-02 17:52:35 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-06-29 06:12:26 |
| | | * @LastEditTime: 2024-08-04 17:43:44 |
| | | */ |
| | | |
| | | import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; |
| | | import { ActionItem, FormSchema, PopConfirm } from '/@/components/Table'; |
| | | import { useI18n } from '/@/hooks/web/useI18n'; |
| | | import { isNullOrEmpty } from '/@/utils/is'; |
| | | import { woCustFn, woformSchema } from '/@/views/components/bizMesWo'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | import LogicFlow from '@logicflow/core'; |
| | | import { BpmnElement } from '@logicflow/extension/es/bpmn'; |
| | | import { Ref, ref, unref } from 'vue'; |
| | | import customEdge from '/@/components/FlowChart/src/customEdge'; |
| | | import actionRect from '/@/components/FlowChart/src/actionRect'; |
| | | import TestNode from '/@/components/FlowChart/src/TestNode'; |
| | | import CollectNode from '/@/components/FlowChart/src/CollectNode'; |
| | | import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode'; |
| | | import PackingNode from '/@/components/FlowChart/src/PackingNode'; |
| | | import RepairNode from '/@/components/FlowChart/src/RepairNode'; |
| | | import { getRouteData } from '/@/api/tigerapi/mes/router'; |
| | | import { toLogicFlowData } from '/@/components/FlowChart/src/adpterForTurbo'; |
| | | import { SelectionSelect } from '@logicflow/extension'; |
| | | import { Ref, unref } from 'vue'; |
| | | import { getRouteData, getWoRouteData } from '/@/api/tigerapi/mes/router'; |
| | | import { buildUUID } from '/@/utils/uuid'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { formatToDateTime } from '/@/utils/dateUtil'; |
| | | import { DeleteEntity } from '/@/api/tigerapi/system'; |
| | | |
| | | const { t } = useI18n(); |
| | | /** |
| | |
| | | * 5. 初始化表格 GetBasicColumnAndInit |
| | | * 6. 设置返回 getHomeUrl |
| | | * 7. 设置标题 getTitle |
| | | * 8. 设置新增时就默认的值 getOthersValues |
| | | * 8. 设置新增时就默认的值 getKeyFieldValues |
| | | * 9. 替换删除方法 GetActionsData |
| | | * @param {*} params |
| | | * @param {array} args |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description: 工艺路线初始化 |
| | | * @param {*} lf |
| | | * @return {*} |
| | | */ |
| | | export async function initRoute(lf, rotId, routeData, currlf) { |
| | | * @description: 工艺路线初始化 |
| | | * @param {*} lf |
| | | * @return {*} |
| | | */ |
| | | export async function initRoute(lf, rotId, routeData, currlf, rotType) { |
| | | currlf.value = unref(lf); |
| | | //通过工艺路线ID获取图形数据,并渲染 |
| | | var _data = await getRouteData(rotId); |
| | | var _data = rotType == 'Wo'?await getWoRouteData(rotId): await getRouteData(rotId); |
| | | console.log('组件已挂载', _data); |
| | | if (_data.Data != null) { |
| | | _data.Data.nodes.forEach((n) => { |
| | |
| | | routeData.value.nodes.push(act.node); |
| | | }); |
| | | unref(lf).render(routeData.value); |
| | | // lf.graphModel.translateCenter(); |
| | | // lf.graphModel.fitView(); |
| | | } |
| | | } |
| | | |
| | | /* 高级表单公用方法 *********************************Start */ |
| | | |
| | | /** |
| | | * @description: 查询自定义方法,当在高级表单中的表格中查询时触发事件,并把{ type: type, data: data }传到父组件 |
| | | * @param {string} type 表格的名字,好确定是哪个表格要查询 |
| | | * @param {Ref} data 此表格的原数据 |
| | | * @param {*} emit dtl组件的事件,触发一个'search'事件 |
| | | * @return {*} |
| | | */ |
| | | export async function Search(type: string, data: Ref<any>, emit) { |
| | | emit('search', { type: type, data: data }); |
| | | } |
| | | |
| | | /** |
| | | * @description: 高级表单新增编辑方法 |
| | | * @param {Ref} data |
| | | * @param {*} d |
| | | * @param {*} u |
| | | * @param {*} item |
| | | * @param {*} updates |
| | | * @return {*} |
| | | */ |
| | | export function EditOperation(data: Ref<any[]>, d, u, item, updates) { |
| | | if (u.isUpdate) { |
| | | //更新 |
| | | data.value[item] = updates; |
| | | } else { |
| | | //新增 |
| | | d.ID = buildUUID(); |
| | | d.CREATE_USER = useUserStore().getUserInfo.userId as string; |
| | | d.UPDATE_TIME = formatToDateTime(new Date()); |
| | | d.UPDATE_USER = useUserStore().getUserInfo.userId as string; |
| | | var _data2: any[] = []; |
| | | if (!isNullOrEmpty(data.value[item])) { |
| | | _data2 = data.value[item].map((item) => { |
| | | return item; |
| | | }); |
| | | } |
| | | _data2.push(d); |
| | | data.value[item] = _data2; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description: 自定义删除方法 |
| | | * @param {Fn} args |
| | | * @param {*} params |
| | | * @return {*} |
| | | */ |
| | | export function custDel(args: Fn[], params: {}) { |
| | | const name = params['name']; |
| | | const useTables = args[1]; |
| | | if (!isNullOrEmpty(params['data'])) { |
| | | var _data = params['data'].value[name].filter((item) => item['ID'] != params['record']['ID']); |
| | | params['data'].value[name] = _data; |
| | | useTables[name][1].setProps({ |
| | | dataSource: [], |
| | | }); |
| | | useTables[name][1].setProps({ |
| | | dataSource: params['data'].value[name], |
| | | }); |
| | | useTables[name][1].reload(); |
| | | } else { |
| | | DeleteEntity(params['record'], params['entityName']).then((action) => { |
| | | if (action.IsSuccessed) { |
| | | useTables[name][1].reload(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /* 高级表单公用方法 *********************************End */ |
| | | |
| | | /** |
| | | * @description: 获取权限按钮列表 |
| | | * @param {*} params |
| | | * @return {*} |
| | | */ |
| | | export function GenerateActionButton(params: any, buttons: Ref<[]>, openDrawer: Fn, reload: Fn) { |
| | | let actionItem = [] as ActionItem[]; |
| | | buttons.value.map((x) => { |
| | | if (x['BUTTON_TYPE'] == 1) { |
| | | let url = ''; |
| | | let color = undefined as 'success' | 'error' | 'warning' | undefined; |
| | | let _click = null as any; |
| | | let _popConfirm = undefined as PopConfirm | undefined; |
| | | let _tooltip = ''; |
| | | if (x['DO_METHOD'] == 'Edit') { |
| | | url = 'clarity:note-edit-line'; |
| | | _tooltip = '编辑'; |
| | | _click = editRecord.bind(null, openDrawer, params); |
| | | } else { |
| | | _click = () => {}; |
| | | if (x['DO_METHOD'] == 'Delete') { |
| | | url = 'ant-design:delete-outlined'; |
| | | color = 'error'; |
| | | _tooltip = '删除'; |
| | | _popConfirm = { |
| | | title: '是否确认删除?', |
| | | placement: 'left', |
| | | confirm: deleteRecord.bind(null, reload, params), |
| | | }; |
| | | } |
| | | } |
| | | actionItem.push({ |
| | | icon: isNullOrEmpty(x['ICON_URL']) ? url : x['ICON_URL'], |
| | | tooltip: _tooltip, |
| | | onClick: _click, |
| | | color: color, |
| | | popConfirm: _popConfirm, |
| | | name: x['DO_METHOD'], |
| | | }); |
| | | } |
| | | }); |
| | | return actionItem; |
| | | } |
| | | |
| | | /** |
| | | * @description: 公用编辑方法 |
| | | * @param {Fn} fn |
| | | * @param {*} params |
| | | * @return {*} |
| | | */ |
| | | export function editRecord(fn: Fn, params: {}) { |
| | | fn(true, params); |
| | | } |
| | | |
| | | /** |
| | | * @description: 公用删除方法 |
| | | * @param {Fn} fn |
| | | * @param {*} params |
| | | * @return {*} |
| | | */ |
| | | function deleteRecord(fn: Fn, params: {}) { |
| | | console.log(params['record']); |
| | | //删除 |
| | | DeleteEntity(params['record'], params['entityName']).then((action) => { |
| | | if (action.IsSuccessed) { |
| | | fn(); |
| | | } |
| | | }); |
| | | } |