From ec0d91353b767f089fa72f3cd1eb62568852710b Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 22 八月 2024 10:39:30 +0800
Subject: [PATCH] 工单管理增加取消下发功能

---
 src/views/tigerprojects/system/lowcode/data.ts |  113 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 107 insertions(+), 6 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts
index 80cde58..6e77912 100644
--- a/src/views/tigerprojects/system/lowcode/data.ts
+++ b/src/views/tigerprojects/system/lowcode/data.ts
@@ -4,19 +4,20 @@
  * @version:
  * @Date: 2024-06-02 17:52:35
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-07-02 19:40:27
+ * @LastEditTime: 2024-08-04 17:43:44
  */
 
-import { ActionItem, 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 { Ref, unref } from 'vue';
-import { getRouteData } from '/@/api/tigerapi/mes/router';
+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();
 /**
@@ -30,7 +31,7 @@
  *  5. 鍒濆鍖栬〃鏍� GetBasicColumnAndInit
  *  6. 璁剧疆杩斿洖 getHomeUrl
  *  7. 璁剧疆鏍囬 getTitle
- *  8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getOthersValues
+ *  8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getKeyFieldValues
  *  9. 鏇挎崲鍒犻櫎鏂规硶 GetActionsData
  * @param {*} params
  * @param {array} args
@@ -153,10 +154,10 @@
  * @param {*} lf
  * @return {*}
  */
-export async function initRoute(lf, rotId, routeData, currlf) {
+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) => {
@@ -174,6 +175,8 @@
       routeData.value.nodes.push(act.node);
     });
     unref(lf).render(routeData.value);
+    // lf.graphModel.translateCenter();
+    // lf.graphModel.fitView();
   }
 }
 
@@ -220,4 +223,102 @@
   }
 }
 
+/**
+ * @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();
+    }
+  });
+}

--
Gitblit v1.9.3