Files
data-fetch-plugin/vue-project/my-kintone-plugin/src/js/desktop.ts
2025-01-26 16:42:56 +09:00

268 lines
11 KiB
TypeScript

import type { Field, FieldLayout, SavedData } from "@/types/model";
import { KintoneIndexEventHandler } from "./KintoneIndexEventHandler";
(function (PLUGIN_ID) {
kintone.events.on('app.record.index.show', (event) => {
const setting = kintone.plugin.app.getConfig(PLUGIN_ID);
const config:SavedData<FieldLayout> = getConfig(setting);
const currentApp = kintone.app.getId()?.toString();
if(!currentApp) return;
const handler = new KintoneIndexEventHandler(config,currentApp);
handler.init();
return event;
});
/**
* Config設定値を変換する
* @param setting
* @returns
*/
function getConfig(setting:any):SavedData<FieldLayout>{
const config:SavedData<FieldLayout>={
buttonName:setting.buttonName,
joinTables:JSON.parse(setting.joinTables)
}
return config;
}
// function getTestSetting(config:SavedData):SavedData{
// const retConfig :SavedData<FieldLayout> ={
// "buttonName": "集約する",
// "joinTables": [
// {
// "id": "m6c69ojr-bx9l8n9fm",
// "app": "140",
// "table": "",
// "onConditions": [
// {
// "leftField": "",
// "rightField": "",
// "id": "m6c69ojr-7pho6voer"
// }
// ],
// "fieldsMapping": [
// {
// "leftField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行_",
// "label": "社員番号",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "rightField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行_",
// "label": "社員番号",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "id": "m6c69ojr-i75a82qvb"
// },
// {
// "leftField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__0",
// "label": "氏名",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "rightField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__0",
// "label": "氏名",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "id": "m6c6v8sp-7yw58m6e9"
// }
// ],
// "whereConditions": [
// {
// "field": "",
// "condition": "",
// "data": "",
// "id": "m6c69ojr-az5k7bvp6"
// }
// ]
// },
// {
// "id": "m6c6u15u-yq4kzp31c",
// "app": "141",
// "table": "使用者テーブル",
// "onConditions": [
// {
// "leftField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "社員番号",
// "label": "社員番号",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "rightField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行_",
// "label": "社員番号",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "id": "m6c6ue5e-k7yibisue"
// }
// ],
// "fieldsMapping": [
// {
// "leftField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "氏名",
// "label": "氏名",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "rightField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__0",
// "label": "氏名",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "id": "m6c6ue5e-bjdpae18q"
// }
// ],
// "whereConditions": [
// {
// "field": "",
// "condition": "",
// "data": "",
// "id": "m6c6ue5e-1rf2v4l9m"
// }
// ]
// },
// {
// "id": "m6c6vrso-vr7a7v5h1",
// "app": "143",
// "table": "テーブル",
// "onConditions": [
// {
// "leftField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__1",
// "label": "資産管理番号",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "rightField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__1",
// "label": "資産管理番号",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "id": "m6c6vx94-02xbd48xt"
// }
// ],
// "fieldsMapping": [
// {
// "leftField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__2",
// "label": "資産名",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "rightField": {
// "type": "SINGLE_LINE_TEXT",
// "code": "文字列__1行__2",
// "label": "資産名",
// "noLabel": false,
// "required": false,
// "minLength": "",
// "maxLength": "",
// "expression": "",
// "hideExpression": false,
// "unique": false,
// "defaultValue": ""
// },
// "id": "m6c6vx94-t7d8juf6x"
// }
// ],
// "whereConditions": [
// {
// "field": "",
// "condition": "",
// "data": "",
// "id": "m6c6vx94-gbxhjgf8m"
// }
// ]
// }
// ]
// };
// return retConfig;
// }
})(kintone.$PLUGIN_ID);