npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-xcrmsdk

v1.0.5

Published

vue-xcrmsdk

Readme

Vue-xcrmsdk 使用说明

前言

在portal和移动开发中,使用crm webapi格式访问后台api,减少后台代码量,基本的CRUD都可使用vue-xcrmsdk实现,无需额外实现后台自定义接口

Portal版本要求

portal v6.18.5+

安装方式

  • 使用yarn
    yarn add vue-xcrmsdk
  • 使用npm
    npm install vue-xcrmsdk

引入方式 - 按需引用

import { retrieve, retrieveMultiple, create, update, fetch, deleteEntity } from '@/assets/js/crmUtil'

Begin =====vue-xcrmsdk - 1.0.x+升级注意事项===== 2019-9-11编辑

升级说明

  • 将vue-xcrmsdk升级至1.0.x+
  • 导入平台CRM最新的解决方案,包含如下操作:
    • CRUD 记录查询
    • CRUD Fetch查询
    • CRUD 创建
    • CRUD 更新
    • CRUD 删除

升级调整说明

数据结构调整
  • 查询返回数据结构变更【retrieve/retrieveMultiple】
    • PickList类型数据返回int类型,如:statecode:0
    • 原有的PickList名称默认放到FormattedValues属性中
    {
        FormattedValues:{
            statecode:是
        }
    }
      
    • lookup类型的结构现变更为
    {
        createdby:{
            id:"00000000-0000-0000-0000-000000000000",
            logicalname:"systemuser",
            name:"Administrator"
        },
        cratedbyname:"Administrator"
    }
    • 完整的数据结构格式
    {
        FormattedValues:{
            statecode:是,
            participatesinworkflow:否
        },
        accountid:"00000000-0000-0000-0000-000000000000",
        name:"客户",
        createdby:{
            id:"00000000-0000-0000-0000-000000000000",
            logicalname:"systemuser",
            name:"Administrator"
        },
        createdon:"2019-08-23T16:58:37.017",
        cratedbyname:"Administrator",
        participatesinworkflow:0,
        state:0
    }
  • 创建/更新提交数据结构变更【create/update】
    • 格式按照查询返回的数据结构提交
    • 更新【update】的时候带上id,如:
    accountid:"00000000-0000-0000-0000-000000000000"
调用方法变更说明
  • 入参实体名称
    • 原先使用的是复数名称,现改成单数格式
    如:accounts => account, opportunities => opportunity
  • retrieve查询指定字段调整,默认查询全部不做调整
    • 移除入参:config,原先使用的是config.select
    • 改成使用columnSet
  • create
    • 移除入参:config,原先使用的是config.select,用于查询创建后返回的查询字段
    • 现默认返回创建记录的ID
  • update
    • 移除入参:config,原先使用的是config.select,用于查询更新后返回的查询字段
    • 现默认返回当前记录的ID

crm新解决方案导入变更

  • 添加系统参数:
    • LanguageSource, 默认值: WebResource

End =====vue-xcrmsdk - 1.0.x+升级注意事项===== 2019-9-11编辑

使用方式

  • retrieve 查询单条数据

     //第一个参数为实体的复数
     retrieve('accounts', '01e9b6e1-f133-e911-80d1-000c2957a8ce', {
     	select: 'name,createdon'
     })
     .then(resp => {
         //resp.data 返回的结果
     })
     .catch(error => {
         rt.showErrorToast(error.message)
     })
      
  • retrieveMultiple 查询多条数据, 含返回记录总条数,对象可查看【附录-retrieveMultiple对象示例】

    retrieveMultiple('opportunities', {
          entityName: 'opportunity',
          page: 1,
          count: 20,
          returnTotalRecordCount: true,
          columnSet: ['name', 'createdon']
        })
          .then((resp1,resp2) => {
            //resp1.data 为列表结果集
            //resp2.data 为返回的总记录数
          })
          .catch(error => {
            rt.showErrorToast(error.message)
          })
  • retrieveMultiple 查询多条数据, 不含返回总条数,对象可查看【附录-retrieveMultiple对象示例】

    retrieveMultiple('opportunities', {
          entityName: 'opportunity',
          page: 1,
          count: 20,
          returnTotalRecordCount: false,
          columnSet: ['name', 'createdon']
        })
          .then((resp) => {
            //resp.data 为列表结果集
          })
          .catch(error => {
            rt.showErrorToast(error.message)
          })
  • create 创建一条记录

    create(
    	'accounts',
        {
        	//需要创建的字段以及值
            name: 'Sample Account one - 9527 - test',
            creditonhold: false,
            address1_latitude: 47.639583,
            description: 'This is the description ',
            revenue: 5000000,
            accountcategorycode: 1
        },
        {
        	//创建后,需要返回查询的字段
            select: 'name,createdby'
        }
    )
    .then(resp => {
    	//resp.data 返回的结果
    })
    .catch(error => {
    	rt.showErrorToast(error.message)
    })
  • update 更新一条记录

    update(
        'accounts',
        'AF9EE779-5854-E911-80DA-000C2957A8CE',
        {
        	//需要更新的字段以及值
            name: 'Sample Account one - 9527 - test for update',
            creditonhold: false,
            address1_latitude: 47.639583,
            description: 'This is the description ',
            revenue: 5000000,
            accountcategorycode: 1
        },
        {
        	//更新后需要返回查询的值
            select: 'name,createdby'
        }
    )
    .then(resp => {
    	//resp.data 返回的结果
    })
    .catch(error => {
    	rt.showErrorToast(error.message)
    })
  • fetch 使用fetch自定义查询

       let fetchXml = `<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
      <entity name="account">
        <attribute name="name" />
        <attribute name="primarycontactid" />
        <attribute name="telephone1" />
        <attribute name="accountid" />
        <order attribute="name" descending="false" />
        <filter type="and">
          <condition attribute="name" operator="ne" value="kane" />
          <condition attribute="accountnumber" operator="ne" value="kane" />
        </filter>
      </entity>
    </fetch>`
      fetch('accounts', fetchXml)
        .then(resp => {
          //resp.data 返回的结果
        })
        .catch(error => {
          rt.showErrorToast(error.message)
        })
  • deleteEntity 调用操作

     deleteEntity('accounts', '761c73fa-7544-e911-80d8-000c2957a8ce')
  • 使用invokeAction 调用操作

     invokeAction('new_getautonumber', {
          EntityName: 'account'
        })
          .then(resp => {
            //resp.data 返回的结果
          })
          .catch(error => {
            rt.showErrorToast(error.message)
          })
  • invokeEntityAction 调用操作

     invokeEntityAction('new_ord_saleorder_getorderlinelist','new_ord_invoices','DA7944A1-7262-E911-80DB-000C29C12AB0', {
          EntityName: 'account'
        })
          .then(resp => {
            //resp.data 返回的结果
          })
          .catch(error => {
            rt.showErrorToast(error.message)
          })

注意事项

  • url特殊字符转义

    由于http请求,会将url的一些特殊字符进行转义: 所在在使用fetch调用查询的时候,查询参数包含有【%,# ,中文.....】等特殊符号的时候。 使用:encodeURIComponent('%name%') 转义后再进行fetch拼接,然后调用,不然会造成xml无效的结果

附录-retrieveMultiple对象示例

//查询数据对象
var config = {
  entityName: 'account',
  page: 1,
  count: 20,
  returnTotalRecordCount: true,
  columnSet: ['name', 'accountnumber', 'new_telephone', 'createdon'],
  order: [
    { name: 'name', descending: false },
    { name: 'createdon', descending: true }
  ],
  filter: {
    type: 'and',
    conditions: [
      { attribute: 'statecode', operator: 'eq', value: 0 },
      {
        filter: {
          type: 'or',
          conditions: [
            { attribute: 'statecode', operator: 'eq', value: 0 },
            {
              attribute: 'createdon',
              operator: 'between',
              value: [1, 2]
            },
            { attribute: 'statecode', operator: 'today' }
          ]
        }
      }
    ]
  },
  linkEntities: [
    {
      entityName: 'systemuser',
      alias: 't',
      from: 'systemuserid',
      to: 'ownerid',
      linkType: 'inner',
      columnSet: ['name', 'accountnumber', 'new_telephone', 'createdon'],
      filter: {
        type: 'and',
        conditions: [
          { attribute: 'statecode', operator: 'eq', value: 0 },
          {
            filter: {
              type: 'or',
              conditions: [
                {
                  attribute: 'statecode',
                  operator: 'eq',
                  value: 0
                },
                {
                  attribute: 'statecode',
                  operator: 'between',
                  value: [1, 2]
                },
                { attribute: 'statecode', operator: 'today' }
              ]
            }
          }
        ]
      },
      linkEntities: []
    },
    {
      entityName: 'systemuser',
      alias: 's',
      from: 'systemuserid',
      to: 'ownerid',
      linkType: 'inner',
      columnSet: ['name', 'accountnumber', 'new_telephone', 'createdon'],
      filter: {
        type: 'and',
        conditions: [
          { attribute: 'statecode', operator: 'eq', value: 0 }
        ]
      },
      linkEntities: []
    }
  ]
}