neo-cmp-cli 1.9.27 → 1.9.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/neo/neoLogin.js +1 -1
  2. package/dist/package.json.js +1 -1
  3. package/package.json +1 -1
  4. package/template/antd-custom-cmp-template/package.json +2 -2
  5. package/template/antd-custom-cmp-template/src/components/infoCard__c/index.tsx +4 -2
  6. package/template/antd-custom-cmp-template/src/components/searchWidget__c/index.tsx +64 -0
  7. package/template/antd-custom-cmp-template/src/components/searchWidget__c/model.ts +104 -0
  8. package/template/antd-custom-cmp-template/src/components/searchWidget__c/style.scss +11 -0
  9. package/template/develop/demo1/index.jsx +84 -0
  10. package/template/develop/demo1/index1.jsx +81 -0
  11. package/template/echarts-custom-cmp-template/package.json +2 -2
  12. package/template/echarts-custom-cmp-template/src/components/mapWidget__c/index.tsx +23 -2
  13. package/template/echarts-custom-cmp-template/src/components/mapWidget__c/model.ts +17 -0
  14. package/template/empty-cmp/index.tsx +8 -4
  15. package/template/empty-custom-cmp-template/@types/neo-ui-common.d.ts +36 -0
  16. package/template/empty-custom-cmp-template/package.json +2 -2
  17. package/template/neo-custom-cmp-template/neo.config.js +7 -0
  18. package/template/neo-custom-cmp-template/package.json +2 -2
  19. package/template/neo-custom-cmp-template/src/components/entityCardList__c/index.tsx +9 -6
  20. package/template/neo-custom-cmp-template/src/components/entityDetail__c/index.tsx +3 -2
  21. package/template/neo-custom-cmp-template/src/components/entityForm__c/index.tsx +1 -1
  22. package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +6 -2
  23. package/template/neo-custom-cmp-template/src/components/entityTable__c/model.ts +9 -0
  24. package/template/neo-custom-cmp-template/tsconfig.json +61 -42
  25. package/template/react-custom-cmp-template/package.json +2 -2
  26. package/template/react-custom-cmp-template/src/components/infoCard__c/index.jsx +2 -2
  27. package/template/react-ts-custom-cmp-template/package.json +2 -2
  28. package/template/react-ts-custom-cmp-template/src/components/listWidget__c/index.tsx +3 -2
  29. package/template/vue2-custom-cmp-template/package.json +2 -2
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("axios"),t=require("node:fs"),n=require("node:path"),s=require("ora"),r=require("node:http"),o=require("node:url"),i=require("open"),a=require("node:net"),c=require("lodash"),l=require("../utils/common.js"),h=require("./neoEnvManager.js");var p,u;exports.__require=function(){if(u)return p;u=1;const d=e,g=t,m=n,y=s,k=r,_=o,f=i,T=a,w=c,{errorLog:U,successLog:$}=l.__require(),R=h.__require();return p=class{constructor(e){if(!e)return;const{loginURL:t,tokenURL:n}=e,s=R.getAuthConfig(),{redirectUri:r,authType:o,auth:i}=s;if(!t||!n)throw new Error("auth.config.js 配置不完整,需要包含 loginURL、tokenURL");this.loginURL=t,this.tokenURL=n,this.NeoCrmAPI=s,this.redirectUri=r,this.authType=o||"oauth2",this.response_type=i.response_type||"code",this.client_id=i.client_id,this.client_secret=i.client_secret,this.scope=i.scope||"all",this.oauthType=i.oauthType||"standard",this.access_type=i.access_type||"offline",this.grant_type=i.grant_type||"authorization_code",this.tokenDir=m.join(process.cwd(),".neo-cli"),this.tokenFile=m.join(this.tokenDir,"token.json"),this.pageDir=m.join(__dirname,"../../template/pageHtml"),this.authErrorTemplate=m.join(this.pageDir,"auth-error.html"),this.authSuccessTemplate=m.join(this.pageDir,"auth-success.html"),this.tokenErrorTemplate=m.join(this.pageDir,"token-error.html"),this.authFailedTemplate=m.join(this.pageDir,"auth-failed.html");try{R.setEnvConfig(w.pick(e,["neoBaseURL","loginURL","tokenURL"]))}catch(e){U(`保存环境配置失败: ${e.message||e.msg}`)}}ensureTokenDir(){g.existsSync(this.tokenDir)||g.mkdirSync(this.tokenDir,{recursive:!0})}saveToken(e){this.ensureTokenDir();const t={...e,savedAt:Date.now(),expiresAt:Date.now()+1e3*(e.expires_in||7200)};g.writeFileSync(this.tokenFile,JSON.stringify(t,null,2),"utf-8")}readToken(){if(!g.existsSync(this.tokenFile))return null;try{return JSON.parse(g.readFileSync(this.tokenFile,"utf-8"))}catch(e){return U(`读取 token 文件失败: ${e.message||e.msg}`),null}}isTokenExpired(e){return!e||!e.expiresAt||Date.now()>=e.expiresAt-3e5}clearToken(){g.existsSync(this.tokenFile)&&g.unlinkSync(this.tokenFile)}getRedirectURI(e){return`http://localhost:${e}`}buildAuthUrl(e){const t=new URLSearchParams({response_type:this.response_type,client_id:this.client_id,redirect_uri:e,scope:this.scope,oauthType:this.oauthType,access_type:this.access_type});return`${this.loginURL}?${t.toString()}`}async openBrowser(e){try{await f(e)}catch(t){U(`无法自动打开浏览器: ${t.message||t.msg}`),console.log(`\n请手动访问以下 URL 进行授权:\n${e}\n`)}}getHtmlTemplate(e,t={}){try{let n=g.readFileSync(e,"utf-8");return Object.keys(t).forEach(e=>{const s=`{{${e}}}`;n=n.replace(new RegExp(s,"g"),t[e])}),n}catch(e){return U(`读取 HTML 模板失败: ${e.message||e.msg}`),"<html><body><h1>页面加载失败</h1></body></html>"}}async isPortInUse(e){return new Promise(t=>{const n=T.createServer();n.once("error",e=>{"EADDRINUSE"===e.code?t(!0):t(!1)}),n.once("listening",()=>{n.once("close",()=>{t(!1)}),n.close()}),n.listen(e)})}async startCallbackServer(){let e=this.redirectUri,t=new URL(e),n=parseInt(t.port,10);await this.isPortInUse(n)&&(U(`\n警告: 端口 ${n} 已被占用,请调整 redirectUri 配置项,使其指向一个未被占用的端口。`),process.exit(1));const s=new Promise((s,r)=>{const o=k.createServer(async(n,i)=>{const a=_.parse(n.url,!0);if(a.pathname===t.pathname||"/"===a.pathname){const t=a.query.code,n=a.query.error;if(n){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"});const e=this.getHtmlTemplate(this.authErrorTemplate,{ERROR:n});return i.end(e),o.close(),void r(new Error(`授权失败: ${n}`))}if(t)try{const n=await this.getTokenByCode(t,e);this.saveToken(n);const r=n.userInfo.tenantName?`${n.userInfo.tenantName}(${n.tenant_id})`:n.tenant_id||"未返回",a=n.instance_uri||"未返回";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"});const c=this.getHtmlTemplate(this.authSuccessTemplate,{TENANT_ID:r,INSTANCE_URI:a});return i.end(c),o.close(),void s({code:t,tokenData:n})}catch(e){i.writeHead(500,{"Content-Type":"text/html; charset=utf-8"});const t=this.getHtmlTemplate(this.tokenErrorTemplate,{ERROR:e});return i.end(t),o.close(),void r(e)}i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"});const c=this.getHtmlTemplate(this.authFailedTemplate);i.end(c),o.close(),r(new Error("未获取到授权码"))}else i.writeHead(404,{"Content-Type":"text/plain"}),i.end("Not Found")});o.on("error",e=>{"EADDRINUSE"===e.code?r(new Error(`端口 ${n} 已被占用,无法启动回调服务器`)):r(e)}),o.listen(n,()=>{console.log(`\n本地回调服务器已启动,监听端口: ${n}`),console.log(`回调地址: ${e}`)}),setTimeout(()=>{o.close(),r(new Error("授权超时,请重试"))},3e5)});return{redirectUri:e,getCodeAndTokenPromise:s}}async getTokenByCode(e,t){const n=y("正在获取 access token...").start();try{const s=new URLSearchParams;s.append("grant_type",this.grant_type),s.append("client_id",this.client_id),s.append("client_secret",this.client_secret),s.append("code",e),s.append("redirect_uri",t);const r=(await d.post(this.tokenURL,s.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;if(r&&r.access_token){const e=await this.getUserInfo(r.access_token);r.userInfo=e}else U("获取 token 失败:响应中未包含 access_token",n),U(`响应数据: ${JSON.stringify(r)}`),process.exit(1);return $("成功获取 access token",n),r}catch(e){U("获取 token 失败",n),U(`\n获取 token 失败: ${e.message||e.msg}`),e.response&&U(`响应数据: ${JSON.stringify(e.response.data)}`),process.exit(1)}}async refreshToken(e){const t=y("正在刷新授权信息(token)...").start();try{const n=new URLSearchParams;n.append("grant_type","refresh_token"),n.append("client_id",this.client_id),n.append("client_secret",this.client_secret),n.append("refresh_token",e);const s=(await d.post(this.tokenURL,n.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;if(!s||!s.access_token)return U("刷新授权信息失败:响应中未包含 access_token",t),U(`响应数据: ${JSON.stringify(s)}`),null;{const e=await this.getUserInfo(s.access_token);s.userInfo=e}return $("刷新授权信息成功(token)。",t),s}catch(e){return U("刷新授权信息失败",t),U(`\n刷新授权信息失败: ${e.message||e.msg}`),e.response&&U(`响应数据: ${JSON.stringify(e.response.data)}`),null}}async getUserInfo(e){let t={};try{let n=this.buildFullUrl(this.NeoCrmAPI.getUserInfoAPI);const s=await d.get(n,{headers:{Authorization:`Bearer ${e}`,"xsy-inner-source":"bff","Content-Type":"application/json"}}),{code:r,message:o,msg:i}=s.data||{};r&&"200"!==r&&(U(`获取用户信息失败: ${o||i||"未知错误"}`),process.exit(1)),t=s.data.result||s.data.data||{}}catch(e){const t=e.message||e.msg;U(t?`获取用户信息失败: ${t}`:`响应数据: ${JSON.stringify(e)}`),process.exit(1)}return t}async login(){console.log("\n========== NeoCRM 登录授权 ==========\n");try{const{redirectUri:e,getCodeAndTokenPromise:t}=await this.startCallbackServer(),n=this.buildAuthUrl(e);console.log("授权 URL:",n),console.log("\n正在打开浏览器进行授权..."),await this.openBrowser(n);const{code:s,tokenData:r}=await t;return $("\n✓ 已获取授权码"),console.log("\n========== 登录成功 ==========\n"),console.log(`实例地址: ${r.instance_uri||"未返回"}`),console.log(`当前租户信息: ${r.userInfo.tenantName||"未返回租户名称"}(${r.tenant_id||"未返回租户 ID"})`),console.log(`当前登录用户: ${r.userInfo.name||"未返回用户名"}`),r}catch(e){U(`\n登录失败: ${e.message||e.msg}`),process.exit(1)}}async logout(){if(console.log("\n========== NeoCRM 登出 ==========\n"),g.existsSync(this.tokenFile))try{R.clearEnvConfig(),this.clearToken(),$("已清除授权信息,下次登录需要重新授权。"),console.log("\n登出成功!\n")}catch(e){U(`登出失败: ${e.message||e.msg}`),process.exit(1)}else console.log("当前未登录,无需登出。")}async getValidToken(){const e=this.readToken();if(e||(U("未找到授权信息,请先执行 neo login 进行登录。"),process.exit(1)),this.isTokenExpired(e)){console.log("授权信息已过期,正在尝试刷新..."),e.refresh_token||(U("自动刷新授权信息失败,请重新登录(neo login)。"),process.exit(1));const t=await this.refreshToken(e.refresh_token);return t||(U("刷新授权信息失败,请重新登录 (neo login)"),process.exit(1)),this.saveToken(t),t}return e}async getAccessToken(){return await this.getValidToken()}buildFullUrl(e){return e.startsWith("http://")||e.startsWith("https://")?e:`${this.NeoCrmAPI.neoBaseURL}${e}`}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("axios"),t=require("node:fs"),n=require("node:path"),s=require("ora"),r=require("node:http"),o=require("node:url"),i=require("open"),a=require("node:net"),c=require("lodash"),l=require("../utils/common.js"),h=require("./neoEnvManager.js");var p,u;exports.__require=function(){if(u)return p;u=1;const d=e,g=t,m=n,y=s,k=r,_=o,f=i,T=a,w=c,{errorLog:U,successLog:$}=l.__require(),R=h.__require();return p=class{constructor(e){if(!e)return;const{loginURL:t,tokenURL:n}=e,s=R.getAuthConfig(),{redirectUri:r,authType:o,auth:i}=s;if(!t||!n)throw new Error("neo.config.js 配置不完整,需要包含 loginURL、tokenURL");this.loginURL=t,this.tokenURL=n,this.NeoCrmAPI=s,this.redirectUri=r,this.authType=o||"oauth2",this.response_type=i.response_type||"code",this.client_id=i.client_id,this.client_secret=i.client_secret,this.scope=i.scope||"all",this.oauthType=i.oauthType||"standard",this.access_type=i.access_type||"offline",this.grant_type=i.grant_type||"authorization_code",this.tokenDir=m.join(process.cwd(),".neo-cli"),this.tokenFile=m.join(this.tokenDir,"token.json"),this.pageDir=m.join(__dirname,"../../template/pageHtml"),this.authErrorTemplate=m.join(this.pageDir,"auth-error.html"),this.authSuccessTemplate=m.join(this.pageDir,"auth-success.html"),this.tokenErrorTemplate=m.join(this.pageDir,"token-error.html"),this.authFailedTemplate=m.join(this.pageDir,"auth-failed.html");try{R.setEnvConfig(w.pick(e,["neoBaseURL","loginURL","tokenURL"]))}catch(e){U(`保存环境配置失败: ${e.message||e.msg}`)}}ensureTokenDir(){g.existsSync(this.tokenDir)||g.mkdirSync(this.tokenDir,{recursive:!0})}saveToken(e){this.ensureTokenDir();const t={...e,savedAt:Date.now(),expiresAt:Date.now()+1e3*(e.expires_in||7200)};g.writeFileSync(this.tokenFile,JSON.stringify(t,null,2),"utf-8")}readToken(){if(!g.existsSync(this.tokenFile))return null;try{return JSON.parse(g.readFileSync(this.tokenFile,"utf-8"))}catch(e){return U(`读取 token 文件失败: ${e.message||e.msg}`),null}}isTokenExpired(e){return!e||!e.expiresAt||Date.now()>=e.expiresAt-3e5}clearToken(){g.existsSync(this.tokenFile)&&g.unlinkSync(this.tokenFile)}getRedirectURI(e){return`http://localhost:${e}`}buildAuthUrl(e){const t=new URLSearchParams({response_type:this.response_type,client_id:this.client_id,redirect_uri:e,scope:this.scope,oauthType:this.oauthType,access_type:this.access_type});return`${this.loginURL}?${t.toString()}`}async openBrowser(e){try{await f(e)}catch(t){U(`无法自动打开浏览器: ${t.message||t.msg}`),console.log(`\n请手动访问以下 URL 进行授权:\n${e}\n`)}}getHtmlTemplate(e,t={}){try{let n=g.readFileSync(e,"utf-8");return Object.keys(t).forEach(e=>{const s=`{{${e}}}`;n=n.replace(new RegExp(s,"g"),t[e])}),n}catch(e){return U(`读取 HTML 模板失败: ${e.message||e.msg}`),"<html><body><h1>页面加载失败</h1></body></html>"}}async isPortInUse(e){return new Promise(t=>{const n=T.createServer();n.once("error",e=>{"EADDRINUSE"===e.code?t(!0):t(!1)}),n.once("listening",()=>{n.once("close",()=>{t(!1)}),n.close()}),n.listen(e)})}async startCallbackServer(){let e=this.redirectUri,t=new URL(e),n=parseInt(t.port,10);await this.isPortInUse(n)&&(U(`\n警告: 端口 ${n} 已被占用,请调整 redirectUri 配置项,使其指向一个未被占用的端口。`),process.exit(1));const s=new Promise((s,r)=>{const o=k.createServer(async(n,i)=>{const a=_.parse(n.url,!0);if(a.pathname===t.pathname||"/"===a.pathname){const t=a.query.code,n=a.query.error;if(n){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"});const e=this.getHtmlTemplate(this.authErrorTemplate,{ERROR:n});return i.end(e),o.close(),void r(new Error(`授权失败: ${n}`))}if(t)try{const n=await this.getTokenByCode(t,e);this.saveToken(n);const r=n.userInfo.tenantName?`${n.userInfo.tenantName}(${n.tenant_id})`:n.tenant_id||"未返回",a=n.instance_uri||"未返回";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"});const c=this.getHtmlTemplate(this.authSuccessTemplate,{TENANT_ID:r,INSTANCE_URI:a});return i.end(c),o.close(),void s({code:t,tokenData:n})}catch(e){i.writeHead(500,{"Content-Type":"text/html; charset=utf-8"});const t=this.getHtmlTemplate(this.tokenErrorTemplate,{ERROR:e});return i.end(t),o.close(),void r(e)}i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"});const c=this.getHtmlTemplate(this.authFailedTemplate);i.end(c),o.close(),r(new Error("未获取到授权码"))}else i.writeHead(404,{"Content-Type":"text/plain"}),i.end("Not Found")});o.on("error",e=>{"EADDRINUSE"===e.code?r(new Error(`端口 ${n} 已被占用,无法启动回调服务器`)):r(e)}),o.listen(n,()=>{console.log(`\n本地回调服务器已启动,监听端口: ${n}`),console.log(`回调地址: ${e}`)}),setTimeout(()=>{o.close(),r(new Error("授权超时,请重试"))},3e5)});return{redirectUri:e,getCodeAndTokenPromise:s}}async getTokenByCode(e,t){const n=y("正在获取 access token...").start();try{const s=new URLSearchParams;s.append("grant_type",this.grant_type),s.append("client_id",this.client_id),s.append("client_secret",this.client_secret),s.append("code",e),s.append("redirect_uri",t);const r=(await d.post(this.tokenURL,s.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;if(r&&r.access_token){const e=await this.getUserInfo(r.access_token);r.userInfo=e}else U("获取 token 失败:响应中未包含 access_token",n),U(`响应数据: ${JSON.stringify(r)}`),process.exit(1);return $("成功获取 access token",n),r}catch(e){U("获取 token 失败",n),U(`\n获取 token 失败: ${e.message||e.msg}`),e.response&&U(`响应数据: ${JSON.stringify(e.response.data)}`),process.exit(1)}}async refreshToken(e){const t=y("正在刷新授权信息(token)...").start();try{const n=new URLSearchParams;n.append("grant_type","refresh_token"),n.append("client_id",this.client_id),n.append("client_secret",this.client_secret),n.append("refresh_token",e);const s=(await d.post(this.tokenURL,n.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;if(!s||!s.access_token)return U("刷新授权信息失败:响应中未包含 access_token",t),U(`响应数据: ${JSON.stringify(s)}`),null;{const e=await this.getUserInfo(s.access_token);s.userInfo=e}return $("刷新授权信息成功(token)。",t),s}catch(e){return U("刷新授权信息失败",t),U(`\n刷新授权信息失败: ${e.message||e.msg}`),e.response&&U(`响应数据: ${JSON.stringify(e.response.data)}`),null}}async getUserInfo(e){let t={};try{let n=this.buildFullUrl(this.NeoCrmAPI.getUserInfoAPI);const s=await d.get(n,{headers:{Authorization:`Bearer ${e}`,"xsy-inner-source":"bff","Content-Type":"application/json"}}),{code:r,message:o,msg:i}=s.data||{};r&&"200"!==r&&(U(`获取用户信息失败: ${o||i||"未知错误"}`),process.exit(1)),t=s.data.result||s.data.data||{}}catch(e){const t=e.message||e.msg;U(t?`获取用户信息失败: ${t}`:`响应数据: ${JSON.stringify(e)}`),process.exit(1)}return t}async login(){console.log("\n========== NeoCRM 登录授权 ==========\n");try{const{redirectUri:e,getCodeAndTokenPromise:t}=await this.startCallbackServer(),n=this.buildAuthUrl(e);console.log("授权 URL:",n),console.log("\n正在打开浏览器进行授权..."),await this.openBrowser(n);const{code:s,tokenData:r}=await t;return $("\n✓ 已获取授权码"),console.log("\n========== 登录成功 ==========\n"),console.log(`实例地址: ${r.instance_uri||"未返回"}`),console.log(`当前租户信息: ${r.userInfo.tenantName||"未返回租户名称"}(${r.tenant_id||"未返回租户 ID"})`),console.log(`当前登录用户: ${r.userInfo.name||"未返回用户名"}`),r}catch(e){U(`\n登录失败: ${e.message||e.msg}`),process.exit(1)}}async logout(){if(console.log("\n========== NeoCRM 登出 ==========\n"),g.existsSync(this.tokenFile))try{R.clearEnvConfig(),this.clearToken(),$("已清除授权信息,下次登录需要重新授权。"),console.log("\n登出成功!\n")}catch(e){U(`登出失败: ${e.message||e.msg}`),process.exit(1)}else console.log("当前未登录,无需登出。")}async getValidToken(){const e=this.readToken();if(e||(U("未找到授权信息,请先执行 neo login 进行登录。"),process.exit(1)),this.isTokenExpired(e)){console.log("授权信息已过期,正在尝试刷新..."),e.refresh_token||(U("自动刷新授权信息失败,请重新登录(neo login)。"),process.exit(1));const t=await this.refreshToken(e.refresh_token);return t||(U("刷新授权信息失败,请重新登录 (neo login)"),process.exit(1)),this.saveToken(t),t}return e}async getAccessToken(){return await this.getValidToken()}buildFullUrl(e){return e.startsWith("http://")||e.startsWith("https://")?e:`${this.NeoCrmAPI.neoBaseURL}${e}`}}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.9.27";const o={version:e};exports.default=o,exports.version=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.9.29";const o={version:e};exports.default=o,exports.version=e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.9.27",
3
+ "version": "1.9.29",
4
4
  "description": "Neo 自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -38,7 +38,7 @@
38
38
  "url": "https://github.com/wibetter/antd-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.1.0",
41
+ "neo-register": "^1.1.2",
42
42
  "antd": "4.9.4",
43
43
  "react": "^16.9.0",
44
44
  "react-dom": "^16.9.0"
@@ -48,7 +48,7 @@
48
48
  "@commitlint/config-conventional": "^9.1.1",
49
49
  "@types/react": "^16.9.11",
50
50
  "@types/react-dom": "^16.9.15",
51
- "neo-cmp-cli": "^1.9.21",
51
+ "neo-cmp-cli": "^1.9.28",
52
52
  "husky": "^4.2.5",
53
53
  "lint-staged": "^10.2.9",
54
54
  "prettier": "^2.0.5"
@@ -9,6 +9,7 @@ interface InfoCardProps {
9
9
  imgCount: number;
10
10
  commentCount: number;
11
11
  data?: any;
12
+ className?: string;
12
13
  }
13
14
 
14
15
  export default class InfoCard extends React.PureComponent<InfoCardProps> {
@@ -28,7 +29,8 @@ export default class InfoCard extends React.PureComponent<InfoCardProps> {
28
29
  }
29
30
 
30
31
  render() {
31
- const { title, backgroundImage, imgCount, commentCount } = this.props;
32
+ const { title, backgroundImage, imgCount, commentCount, className } =
33
+ this.props;
32
34
  console.log('当前自定义组件:', this.props, this);
33
35
  const curAmisData = this.props.data || {};
34
36
 
@@ -38,7 +40,7 @@ export default class InfoCard extends React.PureComponent<InfoCardProps> {
38
40
  const curBackgroundImage =
39
41
  backgroundImage || 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg';
40
42
  return (
41
- <div className="info-card-container">
43
+ <div className={`info-card-container ${className}`}>
42
44
  <div className="news-title">
43
45
  {title ||
44
46
  '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
@@ -0,0 +1,64 @@
1
+ import * as React from 'react';
2
+ import { Input, message } from 'antd';
3
+ // 引入 neo-ui-common / NeoEvent
4
+ // @ts-ignore
5
+ import { NeoEvent } from 'neo-ui-common';
6
+ import './style.scss';
7
+
8
+ const { Search } = Input;
9
+
10
+ interface SearchWidgetProps {
11
+ placeholder?: string;
12
+ size?: 'large' | 'middle' | 'small';
13
+ enterButton?: boolean | string;
14
+ allowClear?: boolean;
15
+ disabled?: boolean;
16
+ maxLength?: number;
17
+ data?: any;
18
+ env?: any;
19
+ className?: string;
20
+ }
21
+
22
+ export default class SearchWidget extends React.PureComponent<SearchWidgetProps> {
23
+ constructor(props: SearchWidgetProps) {
24
+ super(props);
25
+ this.handleSearch = this.handleSearch.bind(this);
26
+ }
27
+
28
+ @NeoEvent.dispatch
29
+ handleSearch(value: string) {
30
+ if (!value || value.trim() === '') {
31
+ message.warning('请输入搜索内容');
32
+ return;
33
+ }
34
+ message.success(`搜索内容:${value}`);
35
+ }
36
+
37
+ render() {
38
+ const {
39
+ placeholder = '请输入搜索内容',
40
+ size = 'middle',
41
+ enterButton = true,
42
+ allowClear = true,
43
+ disabled = false,
44
+ maxLength,
45
+ className,
46
+ } = this.props;
47
+
48
+ console.log('当前自定义组件:', this.props, this);
49
+
50
+ return (
51
+ <div className={`search-widget-container ${className}`}>
52
+ <Search
53
+ placeholder={placeholder}
54
+ size={size}
55
+ enterButton={enterButton}
56
+ allowClear={allowClear}
57
+ disabled={disabled}
58
+ maxLength={maxLength}
59
+ onSearch={this.handleSearch}
60
+ />
61
+ </div>
62
+ );
63
+ }
64
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @file 自定义组件对接编辑器的描述文件
3
+ */
4
+ export class SearchWidgetModel {
5
+ /**
6
+ * cmpType 为自定义组件名称,用于标识组件的唯一性
7
+ * 在构建时根据当前组件目录名称自动生成
8
+ */
9
+ // cmpType: string = 'searchWidget';
10
+
11
+ // 组件名称,用于设置在编辑器左侧组件面板中展示的名称
12
+ label: string = '搜索组件';
13
+
14
+ // 组件描述,用于设置在编辑器左侧组件面板中展示的描述
15
+ description: string = '支持搜索输入,点击回车键显示搜索内容';
16
+
17
+ // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示
18
+ // tags: string[] = ['自定义组件'];
19
+
20
+ /**
21
+ * 用于设置组件支持的页面类型
22
+ *
23
+ * 当前 NeoCRM 平台存在的页面类型:
24
+ * all: 1 全页面
25
+ * entityFormPage: 4 实体表单页
26
+ * customPage: 6 自定义页面
27
+ */
28
+ // targetPage: string[] = ['all'];
29
+
30
+ // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
31
+ iconUrl: string = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
32
+ // iconUrl = 'https://neo-widgets.bj.bcebos.com/favicon.png';
33
+
34
+ // 初次插入页面的默认属性数据
35
+ defaultComProps = {
36
+ placeholder: '请输入搜索内容',
37
+ label: '搜索组件',
38
+ size: 'middle',
39
+ enterButton: true,
40
+ allowClear: true,
41
+ disabled: false,
42
+ };
43
+
44
+ /**
45
+ * 声明当前组件会触发的所有事件
46
+ * 备注:页面设计器端可用于进行事件绑定,在组件属性配置模式中配置事件动作
47
+ */
48
+ events = [
49
+ {
50
+ apiKey: 'handleSearch', // 事件名称
51
+ label: '提交表单后', // 事件
52
+ helpText: '表单提交后触发该事件', // 信息icon hover 时的提示文本
53
+ },
54
+ ];
55
+
56
+ /**
57
+ * 组件面板配置,用于生成编辑器右侧属性配置面板内容
58
+ */
59
+ propsSchema = [
60
+ {
61
+ type: 'text',
62
+ name: 'placeholder',
63
+ label: '占位符',
64
+ value: '请输入搜索内容',
65
+ },
66
+ {
67
+ type: 'select',
68
+ name: 'size',
69
+ label: '尺寸',
70
+ options: [
71
+ { label: '大', value: 'large' },
72
+ { label: '中', value: 'middle' },
73
+ { label: '小', value: 'small' },
74
+ ],
75
+ value: 'middle',
76
+ },
77
+ {
78
+ type: 'switch',
79
+ name: 'enterButton',
80
+ label: '显示搜索按钮',
81
+ value: true,
82
+ },
83
+ {
84
+ type: 'switch',
85
+ name: 'allowClear',
86
+ label: '允许清除',
87
+ value: true,
88
+ },
89
+ {
90
+ type: 'switch',
91
+ name: 'disabled',
92
+ label: '禁用状态',
93
+ value: false,
94
+ },
95
+ {
96
+ type: 'number',
97
+ name: 'maxLength',
98
+ label: '最大长度',
99
+ value: undefined,
100
+ },
101
+ ];
102
+ }
103
+
104
+ export default SearchWidgetModel;
@@ -0,0 +1,11 @@
1
+ .search-widget-container {
2
+ position: relative;
3
+ box-sizing: border-box;
4
+ margin: 6px 12px;
5
+ padding: 6px 0;
6
+ background-color: #fff;
7
+
8
+ .ant-input-search {
9
+ width: 100%;
10
+ }
11
+ }
@@ -0,0 +1,84 @@
1
+ import * as React from 'react';
2
+ import { useState, useRef, useEffect } from 'react';
3
+
4
+ // ===== 子组件:核心是【手动触发原生事件】 =====
5
+ const Son = () => {
6
+ const [triggerTimes, setTriggerTimes] = useState(0);
7
+ // 1. 创建ref,绑定到子组件的按钮DOM,获取真实DOM
8
+ const sonBtnRef = useRef(null);
9
+
10
+ // 子组件核心方法:运行时【手动触发原生click事件】
11
+ const handleManualTrigger = () => {
12
+ const btnDom = sonBtnRef.current;
13
+ if (!btnDom) return;
14
+
15
+ // ✅ 方式A:推荐 - dispatchEvent 手动触发原生click事件(父子通信必须开启bubbles: true)
16
+ const clickEvent = new Event('click', { bubbles: true });
17
+ btnDom.dispatchEvent(clickEvent, {
18
+ detail: { // 子组件传递给父组件的自定义参数,任意格式都可以
19
+ sonMsg: '子组件手动触发了自定义原生事件',
20
+ timestamp: new Date().getTime()
21
+ }
22
+ });
23
+
24
+ // ✅ 方式B:极简 - 等价写法,效果完全一致(只支持click)
25
+ // btnDom.click();
26
+
27
+ setTriggerTimes(prev => prev + 1);
28
+ };
29
+
30
+ return (
31
+ <div style={{ padding: '20px', border: '1px solid #f00', margin: '10px' }}>
32
+ <h4>子组件</h4>
33
+ <p>手动触发原生事件次数:{triggerTimes}</p>
34
+ {/* 真实DOM,绑定ref,无任何onClick合成事件 */}
35
+ <button ref={sonBtnRef} id="son-native-btn">子组件原生按钮(无合成事件)</button>
36
+ <br />
37
+ <button onClick={handleManualTrigger} style={{ marginTop: '10px' }}>
38
+ 点击我 → 手动触发上方按钮的原生click事件
39
+ </button>
40
+ </div>
41
+ );
42
+ };
43
+
44
+ // ===== 父组件:核心是【监听子组件手动触发的原生事件】 =====
45
+ const Father = () => {
46
+ const [msg, setMsg] = useState('');
47
+ // 1. 创建ref,绑定到父组件根DOM,获取真实DOM
48
+ const fatherRootRef = useRef(null);
49
+
50
+ // 父组件核心:原生事件处理函数,监听子组件冒泡上来的原生事件
51
+ const fatherNativeEventListener = (e) => {
52
+ const target = e.target;
53
+ console.log('targetEvent:', e);
54
+ console.log('target:', target, target.id, target.tagName);
55
+ // 2. 精准判断:事件是否来自子组件的指定DOM元素
56
+ if (target.id === 'son-native-btn') {
57
+ console.log('✅ 父组件监听到:子组件手动触发的【原生click事件】');
58
+ setMsg(`父组件捕获到子组件原生事件 → ${new Date().toLocaleTimeString()}`);
59
+ }
60
+ };
61
+
62
+ // 3. 组件挂载时绑定原生事件,卸载时解绑(防止内存泄漏,必写)
63
+ useEffect(() => {
64
+ const fatherDom = fatherRootRef.current;
65
+ if (!fatherDom) return;
66
+ // 绑定原生事件:事件名是【小写click】,监听子组件冒泡的事件
67
+ fatherDom.addEventListener('click', fatherNativeEventListener);
68
+ // 卸载解绑,避免内存泄漏
69
+ return () => {
70
+ fatherDom.removeEventListener('click', fatherNativeEventListener);
71
+ };
72
+ }, []);
73
+
74
+ return (
75
+ <div ref={fatherRootRef} style={{ padding: '20px', border: '1px solid #000' }}>
76
+ <h3>父组件</h3>
77
+ <p style={{ color: 'red', fontSize: '16px' }}>{msg}</p>
78
+ {/* 子组件直接渲染,无需传递任何props!!! 完全解耦 */}
79
+ <Son />
80
+ </div>
81
+ );
82
+ };
83
+
84
+ export default Father;
@@ -0,0 +1,81 @@
1
+ import * as React from 'react';
2
+ import { useState, useRef, useEffect } from 'react';
3
+
4
+ // ===== 子组件:手动触发【自定义原生事件】+ 传递参数 =====
5
+ const Son = () => {
6
+ const [sonData, setSonData] = useState('我是子组件的初始数据');
7
+ const sonDomRef = useRef(null); // 获取子组件真实DOM
8
+
9
+ // 子组件手动触发自定义事件的核心方法
10
+ const triggerCustomNativeEvent = () => {
11
+ const dom = sonDomRef.current;
12
+ if (!dom) return;
13
+
14
+ // ✅ 核心:创建自定义原生事件 + 传递参数,开启冒泡
15
+ const customNativeEvent = new CustomEvent('son-custom-native-event', {
16
+ bubbles: true,
17
+ detail: { // 子组件传递给父组件的自定义参数,任意格式都可以
18
+ sonMsg: '子组件手动触发了自定义原生事件',
19
+ sonData: sonData,
20
+ timestamp: new Date().getTime()
21
+ }
22
+ });
23
+ // 手动触发这个自定义原生事件
24
+ dom.dispatchEvent(customNativeEvent);
25
+
26
+ setSonData(`子组件数据-${Math.floor(Math.random() * 100)}`);
27
+ };
28
+
29
+ return (
30
+ <div ref={sonDomRef} style={{ padding: '20px', border: '1px solid #f00', margin: '10px' }} id="son-root-dom">
31
+ <h4>子组件</h4>
32
+ <p>子组件当前数据:{sonData}</p>
33
+ <button onClick={triggerCustomNativeEvent} style={{ marginTop: '10px' }}>
34
+ 点击我 → 手动触发【自定义原生事件】并传参给父组件
35
+ </button>
36
+ </div>
37
+ );
38
+ };
39
+
40
+ // ===== 父组件:监听【子组件的自定义原生事件】+ 接收参数 =====
41
+ const Father = () => {
42
+ const [receiveData, setReceiveData] = useState({});
43
+ const fatherDomRef = useRef(null);
44
+
45
+ // 父组件监听自定义原生事件的处理函数
46
+ const fatherCustomEventListener = (e) => {
47
+ const target = e.target;
48
+ console.log('targetEvent:', e);
49
+ console.log('target:', target, target.id, target.tagName);
50
+ // 1. 判断事件来源是子组件
51
+ if (e.target.closest('#son-root-dom')) {
52
+ console.log('✅ 父组件监听到子组件的【自定义原生事件】');
53
+ // 2. ✅ 核心:通过e.detail获取子组件传递的自定义参数
54
+ const sonParams = e.detail;
55
+ setReceiveData(sonParams);
56
+ console.log('子组件传递的参数:', sonParams);
57
+ }
58
+ };
59
+
60
+ useEffect(() => {
61
+ const fatherDom = fatherDomRef.current;
62
+ if (!fatherDom) return;
63
+ // ✅ 核心:监听子组件的【自定义事件名】,和子组件保持一致
64
+ fatherDom.addEventListener('son-custom-native-event', fatherCustomEventListener);
65
+ // 卸载解绑
66
+ return () => {
67
+ fatherDom.removeEventListener('son-custom-native-event', fatherCustomEventListener);
68
+ };
69
+ }, []);
70
+
71
+ return (
72
+ <div ref={fatherDomRef} style={{ padding: '20px', border: '1px solid #000' }}>
73
+ <h3>父组件</h3>
74
+ <p style={{ color: 'blue', fontSize: '16px' }}>监听到子组件自定义事件,接收参数:</p>
75
+ <pre>{JSON.stringify(receiveData, null, 2)}</pre>
76
+ <Son />
77
+ </div>
78
+ );
79
+ };
80
+
81
+ export default Father;
@@ -38,7 +38,7 @@
38
38
  "url": "https://github.com/wibetter/echarts-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.1.0",
41
+ "neo-register": "^1.1.2",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0",
44
44
  "echarts": "^5.5.1"
@@ -48,7 +48,7 @@
48
48
  "@commitlint/config-conventional": "^9.1.1",
49
49
  "@types/react": "^16.9.11",
50
50
  "@types/react-dom": "^16.9.15",
51
- "neo-cmp-cli": "^1.9.21",
51
+ "neo-cmp-cli": "^1.9.28",
52
52
  "husky": "^4.2.5",
53
53
  "lint-staged": "^10.2.9",
54
54
  "prettier": "^2.0.5",
@@ -23,6 +23,7 @@ interface MapWidgetProps {
23
23
  // 地图高度
24
24
  height?: number;
25
25
  data?: any;
26
+ className?: string;
26
27
  }
27
28
 
28
29
  interface MapWidgetState {
@@ -119,6 +120,26 @@ export default class MapWidget extends React.PureComponent<
119
120
  }
120
121
  };
121
122
 
123
+ /**
124
+ * 展示对应区域的地图
125
+ */
126
+ showLocation = (newLocationName: string) => {
127
+ if (newLocationName !== this.locationName) {
128
+ this.setState(
129
+ {
130
+ urlLocationName: newLocationName,
131
+ error: undefined,
132
+ },
133
+ () => {
134
+ // 重新初始化地图
135
+ this.initMap(newLocationName);
136
+ },
137
+ );
138
+ } else {
139
+ console.warn('当前地址未发现变化。');
140
+ }
141
+ };
142
+
122
143
  /**
123
144
  * 动态加载高德地图脚本
124
145
  */
@@ -320,7 +341,7 @@ export default class MapWidget extends React.PureComponent<
320
341
  };
321
342
 
322
343
  render() {
323
- const { height = 400, data } = this.props;
344
+ const { height = 400, data, className } = this.props;
324
345
  const { isLoading, error } = this.state;
325
346
 
326
347
  const curAmisData = data || {};
@@ -329,7 +350,7 @@ export default class MapWidget extends React.PureComponent<
329
350
  console.log('this.props:', this.props);
330
351
 
331
352
  return (
332
- <div className="map-widget-wrapper">
353
+ <div className={`map-widget-wrapper ${className}`}>
333
354
  {/*
334
355
  // 地图头部: 显示地图标题和当前位置地址
335
356
  <div className="map-widget-header">
@@ -41,6 +41,23 @@ export class MapWidgetModel {
41
41
  height: 400, // 地图高度
42
42
  };
43
43
 
44
+ // 当前组件支持的函数列表(其他组件可触发当前组件的函数)
45
+ functions = [
46
+ {
47
+ apiKey: 'showLocation',
48
+ label: '展示对应区域',
49
+ helpTextKey: '展示对应区域的地图',
50
+ funcInParams: [
51
+ {
52
+ apiKey: 'newLocationName',
53
+ label: '区域名称',
54
+ type: 'String',
55
+ required: true,
56
+ }
57
+ ]
58
+ }
59
+ ]
60
+
44
61
  /**
45
62
  * 组件面板配置,用于生成编辑器右侧属性配置面板内容
46
63
  */
@@ -1,26 +1,30 @@
1
1
  import * as React from 'react';
2
+ // 引入 neo-ui-common / BaseCmp
3
+ // @ts-ignore
4
+ import { BaseCmp } from 'neo-ui-common';
2
5
  import './style.scss'; // 组件内容样式
3
6
 
4
7
  interface CustomCmpProps {
5
8
  title: string;
6
9
  data?: any;
10
+ className?: string;
7
11
  }
8
12
 
9
13
  interface CustomCmpStates {
10
14
  [key: string]: any;
11
15
  }
12
16
 
13
- export default class CustomCmp extends React.PureComponent<CustomCmpProps, CustomCmpStates> {
17
+ export default class CustomCmp extends BaseCmp<CustomCmpProps, CustomCmpStates> {
14
18
  constructor(props: CustomCmpProps) {
15
19
  super(props);
16
20
  }
17
21
 
18
22
  render() {
19
- const { title } = this.props;
20
- console.log('当前自定义组件:', this.props, this);
23
+ const { title, className } = this.props;
24
+ console.log('当前自定义组件:', this.props);
21
25
 
22
26
  return (
23
- <div className="custom-cmp-container">
27
+ <div className={`custom-cmp-container ${className}`}>
24
28
  <div className="news-title">
25
29
  {title}
26
30
  </div>
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * BaseCmpProps 基础组件属性接口
5
+ */
6
+ export interface BaseCmpProps {
7
+ [key: string]: any;
8
+ }
9
+
10
+ /**
11
+ * ScopedComponentType 作用域组件类型接口
12
+ */
13
+ export interface ScopedComponentType {
14
+ [key: string]: any;
15
+ }
16
+
17
+ /**
18
+ * BaseCmp 基础组件类
19
+ * 继承自 React.PureComponent,提供基础组件功能
20
+ */
21
+ export declare class BaseCmp<
22
+ T extends BaseCmpProps = BaseCmpProps,
23
+ S = any
24
+ > extends React.PureComponent<T, S> implements ScopedComponentType {
25
+ props: Readonly<T> & Readonly<{ children?: React.ReactNode }>;
26
+ state: Readonly<S>;
27
+ setState<K extends keyof S>(
28
+ state:
29
+ | ((prevState: Readonly<S>, props: Readonly<T>) => Pick<S, K> | S | null)
30
+ | (Pick<S, K> | S | null),
31
+ callback?: () => void
32
+ ): void;
33
+ forceUpdate(callback?: () => void): void;
34
+ render(): React.ReactNode;
35
+ }
36
+
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/wibetter/empty-custom-cmp-template/issues"
38
38
  },
39
39
  "dependencies": {
40
- "neo-register": "^1.1.0",
40
+ "neo-register": "^1.1.2",
41
41
  "react": "^16.9.0",
42
42
  "react-dom": "^16.9.0",
43
43
  "antd": "4.9.4",
@@ -48,7 +48,7 @@
48
48
  "@commitlint/config-conventional": "^9.1.1",
49
49
  "@types/react": "^16.9.11",
50
50
  "@types/react-dom": "^16.9.15",
51
- "neo-cmp-cli": "^1.9.21",
51
+ "neo-cmp-cli": "^1.9.27",
52
52
  "husky": "^4.2.5",
53
53
  "lint-staged": "^10.2.9",
54
54
  "prettier": "^2.0.5"
@@ -99,6 +99,13 @@ module.exports = {
99
99
  }
100
100
  */
101
101
  },
102
+ // 选择「自定义环境」时需要添加 NeoCRM 平台配置,可自定义对接的任何环境
103
+ neoConfig: {
104
+ // authType: 'oauth2', // 默认授权模式:OAuth2 授权码模式
105
+ neoBaseURL: 'https://crm-test.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
106
+ loginURL: 'https://login-test.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
107
+ tokenURL: 'https://login-test.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
108
+ },
102
109
  pushCmp: {
103
110
  // 用于构建并发布至 NeoCRM 的相关配置
104
111
  /*
@@ -41,7 +41,7 @@
41
41
  "url": "https://github.com/wibetter/neo-custom-cmp-template/issues"
42
42
  },
43
43
  "dependencies": {
44
- "neo-register": "^1.1.0",
44
+ "neo-register": "^1.1.2",
45
45
  "react": "^16.9.0",
46
46
  "react-dom": "^16.9.0",
47
47
  "axios": "^0.27.2",
@@ -55,7 +55,7 @@
55
55
  "@types/react": "^16.9.11",
56
56
  "@types/react-dom": "^16.9.15",
57
57
  "@types/axios": "^0.14.0",
58
- "neo-cmp-cli": "^1.9.21",
58
+ "neo-cmp-cli": "^1.9.28",
59
59
  "husky": "^4.2.5",
60
60
  "lint-staged": "^10.2.9",
61
61
  "prettier": "^2.0.5"
@@ -1,16 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { Card, Row, Col, Spin, Empty, Avatar, Button } from 'antd';
3
3
  import { UserOutlined, PhoneOutlined, ReloadOutlined } from '@ant-design/icons';
4
+ // 引入 neo-ui-common / BaseCmp
4
5
  // @ts-ignore
5
- import { xObject } from 'neo-open-api';
6
+ import { BaseCmp } from 'neo-ui-common';
6
7
 
7
- // Neo Open API// 引入 neo-ui-common / BaseCmp
8
+ // 引入 Neo Open API
8
9
  // @ts-ignore
9
- import { BaseCmp } from 'neo-ui-common';
10
+ import { xObject } from 'neo-open-api';
10
11
 
11
12
  // 引入 neo-ui-common / NeoEvent
12
13
  // @ts-ignore
13
- import { NeoEvent } from 'neo-ui-common'; // 后续考虑 使用 props.dispatchEvent 方法替代
14
+ import { NeoEvent } from 'neo-ui-common';
14
15
 
15
16
  import './style.scss';
16
17
 
@@ -19,6 +20,7 @@ interface EntityCardListProps {
19
20
  xObjectDataApi?: any;
20
21
  entityData?: any;
21
22
  data?: any;
23
+ className?: string;
22
24
  }
23
25
 
24
26
  interface ContactData {
@@ -75,6 +77,7 @@ export default class EntityCardList extends BaseCmp<
75
77
  }
76
78
  }
77
79
 
80
+ @NeoEvent.function
78
81
  async loadObjectData(parma1?: any) {
79
82
  const { xObjectDataApi } = this.props;
80
83
  const { autoFetchData } = xObjectDataApi || {};
@@ -154,14 +157,14 @@ export default class EntityCardList extends BaseCmp<
154
157
  }
155
158
 
156
159
  render() {
157
- const { title } = this.props;
160
+ const { title, className } = this.props;
158
161
  const { objectDataList, loading, error } = this.state;
159
162
  const curAmisData = this.props.data || {};
160
163
  const systemInfo = curAmisData.__NeoSystemInfo || {};
161
164
  console.log('this.props:', this.props);
162
165
 
163
166
  return (
164
- <div className="entity-card-list-container">
167
+ <div className={`entity-card-list-container ${className}`}>
165
168
  <div className="card-list-header">
166
169
  <div className="header-content">
167
170
  <h3 className="header-title">
@@ -35,6 +35,7 @@ interface EntityDetailProps {
35
35
  showTitle?: boolean;
36
36
  data?: any;
37
37
  entityData?: any;
38
+ className?: string;
38
39
  }
39
40
 
40
41
  interface FieldDescription {
@@ -270,14 +271,14 @@ export default class EntityDetail extends React.PureComponent<
270
271
  }
271
272
 
272
273
  render() {
273
- const { title, showTitle = true } = this.props;
274
+ const { title, showTitle = true, className } = this.props;
274
275
  const { loading, error } = this.state;
275
276
  const curAmisData = this.props.data || {};
276
277
  const systemInfo = curAmisData.__NeoSystemInfo || {};
277
278
  console.log('this.props:', this.props);
278
279
 
279
280
  return (
280
- <div className="entity-detail-container">
281
+ <div className={`entity-detail-container ${className}`}>
281
282
  {showTitle && (
282
283
  <div className="detail-header">
283
284
  <div className="header-content">
@@ -29,7 +29,7 @@ import { xObject } from 'neo-open-api'; // Neo Open API
29
29
  import isEqual from 'lodash/isEqual';
30
30
  // 引入 neo-ui-common / NeoEvent
31
31
  // @ts-ignore
32
- import { NeoEvent } from 'neo-ui-common'; // 后续考虑 使用 props.dispatchEvent 方法替代
32
+ import { NeoEvent } from 'neo-ui-common';
33
33
  import './style.scss';
34
34
 
35
35
  const { Option } = Select;
@@ -40,7 +40,7 @@ import { BaseCmp } from 'neo-ui-common';
40
40
 
41
41
  // 引入 neo-ui-common / NeoEvent
42
42
  // @ts-ignore
43
- import { NeoEvent } from 'neo-ui-common'; // 后续考虑 使用 props.dispatchEvent 方法替代
43
+ import { NeoEvent } from 'neo-ui-common';
44
44
 
45
45
  import './style.scss';
46
46
 
@@ -70,6 +70,8 @@ interface EntityTableProps {
70
70
  showDeleteButton?: boolean;
71
71
  /** 是否为自定义实体对象 */
72
72
  custom?: boolean;
73
+ /** 组件类名 */
74
+ className?: string;
73
75
  }
74
76
 
75
77
  /**
@@ -341,6 +343,7 @@ export default class EntityTable extends BaseCmp<
341
343
  * @param page 页码,默认为 1
342
344
  * @param pageSize 每页条数,默认为 10
343
345
  */
346
+ @NeoEvent.function
344
347
  async loadData(page = 1, pageSize = 10) {
345
348
  const { xObjectApiKey, autoFetchData } = this.props.xObjectDataApi || {};
346
349
  if (!xObjectApiKey) return;
@@ -702,6 +705,7 @@ export default class EntityTable extends BaseCmp<
702
705
  isModalVisible,
703
706
  isEditMode,
704
707
  } = this.state;
708
+ const { className } = this.props;
705
709
  const curAmisData = this.props.data || {};
706
710
  const systemInfo = curAmisData.__NeoSystemInfo || {};
707
711
  const { xObjectApiKey } = this.props.xObjectDataApi || {};
@@ -709,7 +713,7 @@ export default class EntityTable extends BaseCmp<
709
713
  console.log('this.props:', this.props, columns, this);
710
714
 
711
715
  return (
712
- <div className="entity-table-container">
716
+ <div className={`entity-table-container ${className}`}>
713
717
  <Card>
714
718
  <div className="table-header">
715
719
  <div className="header-content">
@@ -34,6 +34,15 @@ export class EntityTableModel {
34
34
  */
35
35
  targetPage: string[] = ['all'];
36
36
 
37
+ /**
38
+ * 用于设置组件支持的终端类型
39
+ *
40
+ * 当前 NeoCRM 平台存在的终端类型:
41
+ * web: 网页端
42
+ * mobile: 移动端
43
+ */
44
+ targetDevice: string = 'all';
45
+
37
46
  /** 初次插入页面的默认属性数据 */
38
47
  defaultComProps = {
39
48
  title: '实体数据表格',
@@ -1,49 +1,68 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "experimentalDecorators": true,
4
+ /* Basic Options */
4
5
  "target": "esnext",
5
- "module": "esnext",
6
- "allowJs": false,
7
- "jsx": "react",
8
- "declaration": false,
9
- "noEmit": false,
10
- "importHelpers": true,
11
- "isolatedModules": false,
12
- "strict": false,
13
- "noImplicitAny": true,
14
- "strictNullChecks": true,
15
- "noImplicitThis": true,
16
- "noUnusedLocals": false,
17
- "noImplicitReturns": true,
18
- "moduleResolution": "node",
19
- "baseUrl": "./",
6
+ /* 指定编译之后的版本: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
7
+ "module": "esnext" /* 指定要使用的模板标准: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
8
+ // "lib": [], /* Specify library files to be included in the compilation. */
9
+ "allowJs": false /* 指定是否允许编译JS文件,默认false,即不编译JS文件. */,
10
+ // "checkJs": true, /* 指定是否检查和报告JS文件中的错误,默认false */
11
+ "jsx": "react" /* 指定jsx代码用于的开发环境:'preserve','react-native', or 'react'. */,
12
+ "declaration": false /* 指定是否在编译的时候生成相的d.ts声明文件 */,
13
+ // "declarationMap": true, /* 指定编译时是否生成.map文件 */
14
+ // "sourceMap": true, /* 指定编译时是否生成.map文件 */
15
+ // "outFile": "./", /* 指定输出文件合并为一个文件 */
16
+ // "outDir": "dist", /* 指定输出文件夹,值为一个文件夹路径字符串,输出的文件都将放置在这个文件夹*/
17
+ // "rootDir": "src", /* 指定编译文件的根目录,编译器会在根目录查找入口文件 */
18
+ // "composite": true, /* 是否编译构建引用项目 */
19
+ // "removeComments": true, /* 指定是否将编译后的文件注释删掉,设为true的话即删除注释,默认为false */
20
+ "noEmit": false /* 不生成编译文件 */,
21
+ "importHelpers": true /* 指定是否引入tslib里的复制工具函数,默认为false */,
22
+ // "downlevelIteration": true, /* 当target为"ES5"或"ES3"时,为"for-of" "spread"和"destructuring"中的迭代器提供完全支持 */
23
+ "isolatedModules": false /* 指定是否将每个文件作为单独的模块,默认为true */,
24
+
25
+ /* Strict Type-Checking Options */
26
+ "strict": false /* 指定是否启动所有类型检查 */,
27
+ "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
28
+ "strictNullChecks": true /* Enable strict null checks. */,
29
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
30
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
31
+ "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
32
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
33
+
34
+ /* Additional Checks */
35
+ "noUnusedLocals": false /* Report errors on unused locals. */,
36
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
37
+ "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
38
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
39
+
40
+ /* Module Resolution Options */
41
+ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
42
+ "baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
20
43
  "paths": {
21
- "@": [
22
- "./src"
23
- ],
24
- "@assets/*": [
25
- "src/assets/*"
26
- ],
27
- "@components/*": [
28
- "src/components/*"
29
- ],
30
- "$utils/*": [
31
- "src/utils/*"
32
- ]
33
- },
34
- "typeRoots": [
35
- "./@types",
36
- "./node_modules/@types"
37
- ],
38
- "allowSyntheticDefaultImports": true,
39
- "esModuleInterop": true,
40
- "forceConsistentCasingInFileNames": true
44
+ "@": ["./src"]
45
+ } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
46
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
47
+ /* 指定声明文件或文件夹的路径列表,如果指定了此项,则只有在这里列出的声明文件才会被加载 */
48
+ "typeRoots": ["./@types", "./node_modules/@types"],
49
+ // "types": [], /* 指定需要包含的模块,只有在这里列出的模块的声明文件才会被加载 */
50
+ "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
51
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
52
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
53
+
54
+ /* Source Map Options */
55
+ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
56
+ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
57
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
58
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
59
+
60
+ /* Experimental Options */
61
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
62
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
63
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
64
+ // "suppressImplicitAnyIndexErrors": true /* Suppress --noImplicitAny errors for indexing objects lacking index signatures. See issue #1232 for more details. */
41
65
  },
42
- "include": [
43
- "src",
44
- "test"
45
- ],
46
- "exclude": [
47
- "node_modules"
48
- ]
66
+ "include": ["src", "test"],
67
+ "exclude": ["node_modules"]
49
68
  }
@@ -38,14 +38,14 @@
38
38
  "url": "https://github.com/wibetter/react-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.1.0",
41
+ "neo-register": "^1.1.2",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@commitlint/cli": "^8.3.5",
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
- "neo-cmp-cli": "^1.9.21",
48
+ "neo-cmp-cli": "^1.9.28",
49
49
  "husky": "^4.2.5",
50
50
  "lint-staged": "^10.2.9",
51
51
  "prettier": "^2.0.5"
@@ -15,11 +15,11 @@ export default class InfoCard extends React.PureComponent {
15
15
  }
16
16
  }
17
17
  render() {
18
- const { title, backgroundImage, imgCount, commentCount } = this.props;
18
+ const { title, backgroundImage, imgCount, commentCount, className } = this.props;
19
19
  const curBackgroundImage =
20
20
  backgroundImage || 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg';
21
21
  return (
22
- <div className="info-card-container">
22
+ <div className={`info-card-container ${className}`}>
23
23
  <div className="news-title">
24
24
  {title ||
25
25
  '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
@@ -38,7 +38,7 @@
38
38
  "url": "https://github.com/wibetter/react-ts-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.1.0",
41
+ "neo-register": "^1.1.2",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0"
44
44
  },
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.9.21",
50
+ "neo-cmp-cli": "^1.9.28",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"
@@ -22,6 +22,7 @@ interface ListWidgetProps {
22
22
  itemCount: number;
23
23
  listType: 'default' | 'card' | 'simple';
24
24
  data?: any;
25
+ className?: string;
25
26
  }
26
27
 
27
28
  /**
@@ -183,7 +184,7 @@ export default class ListWidget extends React.PureComponent<ListWidgetProps> {
183
184
  }
184
185
 
185
186
  render() {
186
- const { title, itemCount, listType, data } = this.props;
187
+ const { title, itemCount, listType, data, className } = this.props;
187
188
 
188
189
  const curAmisData = data || {};
189
190
  const systemInfo = curAmisData.__NeoSystemInfo || {};
@@ -191,7 +192,7 @@ export default class ListWidget extends React.PureComponent<ListWidgetProps> {
191
192
  const mockData = this.generateMockData(itemCount);
192
193
 
193
194
  return (
194
- <div className="list-widget-container">
195
+ <div className={`list-widget-container ${className}`}>
195
196
  <div className="list-header">
196
197
  <h2 className="list-title">
197
198
  {title || '内容列表'}
@@ -38,14 +38,14 @@
38
38
  "url": "https://github.com/wibetter/vue2-custom-cmp-template/issues"
39
39
  },
40
40
  "dependencies": {
41
- "neo-register": "^1.1.0",
41
+ "neo-register": "^1.1.2",
42
42
  "vue": "^2.6.14",
43
43
  "element-ui": "^2.15.12"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@commitlint/cli": "^8.3.5",
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
- "neo-cmp-cli": "^1.9.21",
48
+ "neo-cmp-cli": "^1.9.28",
49
49
  "husky": "^4.2.5",
50
50
  "lint-staged": "^10.2.9",
51
51
  "prettier": "^2.0.5",