开发者社区> 问答> 正文

宜搭子表格中,下拉单选项如何实现禁重或标重?

11.png
22.png
如图所示,在子表格中添加表格后,如何让下拉单选项中的重复选项内容状态为禁止选择,或更改已选项字体颜色

展开
收起
游客s2o4xrknh3zfy 2024-05-16 17:05:33 30 0
1 条回答
写回答
取消 提交回答
  • 若回答对您有帮助,记得点下赞同哦~

    如果你需要在表单提交时校验的话可以使用宜搭自带的校验函数ARRAYREPEATED
    image.png
    如果需要输入时校验参考一下下列代码:
    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: 'tableField', // 需要参与校验的子表单组件唯一标识
          checkedField: 'textField' // 需要参与校验的子表单内组件唯一标识
        }
      });
    
      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-05-20 10:57:37
    赞同 2 展开评论 打赏
问答分类:
问答地址:
关联地址:
问答排行榜
最热
最新

相关电子书

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