开发者社区 > 云原生 > 正文

宜搭中,表单的某一行数据确保唯一性

表单的某一行与已提交的数据进行比对,在宜搭官方没有找到获取已提交表单的案例,谢谢

展开
收起
火星雷云 2024-04-15 15:44:16 51 0
1 条回答
写回答
取消 提交回答
  • 若回答对您有帮助,记得点下赞同哦~

    您好您是需要主表字段和历史提交的数据做匹配还是子表单里面的某一行和历史子表单里面填写的信息做匹配呀?如果是主表的话可以参考一下这个案例:https://docs.aliwork.com/docs/yida_subject/xnc05ivrxsq23833
    如果是子表单参考一下下列方式:
    image.png
    接口地址:

    `/${window.pageConfig.appType || window.g_config.appKey}/query/formProcInstData/getInstanceDatasLight.json`
    

    image.png
    image.png

    image.png

    export function didMount() {
      this.setState({
        options: {
          formUuid: 'formUuid', // 需要参与校验的表 formUuid
          checkedTable: '组件唯一标识', // 需要参与校验的子表单组件唯一标识
          checkedField: '组件id' // 需要参与校验的子表单内组件唯一标识
        }
      });
    
      if (!this.utils.isSubmissionPage()) {
        // 获取未修改前的被校验子表单数据
        const { options } = this.state;
        const oldData = this.$(options.checkedTable).getValue();
        this.setState({
          oldData,
        });
      };
    }
    

    image.png

    async function validateRule(value) {
      if (!value) { return true };
      const { options, oldData } = this.state;
      if (!this.utils.isSubmissionPage() && oldData.length && oldData[this.index] && (value == oldData[this.index][options.checkedField])) {
        return true;
      } else {
        return await this.dataSourceMap.checkOnly.load({
          formUuid: options.formUuid,
          searchField: JSON.stringify([{ "key": options.checkedField, "value": value, "type": "TEXT", "operator": "eq", "componentName": "TextField", "parentId": options.checkedTable }]),
          pageSize: 10,
          currentPage: 1,
          page: 1,
          limit: 10
        }).then(res => {
          if (!res.totalCount) { return true };
          return false;
        }).catch(error => {
          this.utils.toast({
            title: error.message,
            type: 'error',
          });
          return true;
        });
      }
    }
    
    2024-04-17 09:25:31
    赞同 3 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
宜搭 - 企业智能化应用搭建平台 立即下载
《云市场-宜搭解决方案》 立即下载
《宜搭开发手册》 立即下载