Code Monkey home page Code Monkey logo

Comments (2)

cq-panda avatar cq-panda commented on May 13, 2024

数据字典中定义为查询语句时上传excel会有问题,做了如下修改,你看看怎么改

private static List<CellOptions> GetExportColumnInfo(string tableName, bool temlate = false, bool filterKeyValue = true)
        {
            //&& x.IsDisplay == 1&&x.IsReadDataset==0只导出代码生器中设置为显示并且不是只读的列,可根据具体业务设置导出列
            List<CellOptions> cellOptions = DBServerProvider.DbContext.Set<Sys_TableColumn>()
              .Where(x => x.TableName == tableName && x.IsDisplay == 1 && x.IsReadDataset == 0).Select(c => new CellOptions()
              {
                  ColumnName = c.ColumnName,
                  ColumnCNName = c.ColumnCnName,
                  DropNo = c.DropNo,
                  Requierd = c.IsNull > 0 ? false : true,
                  ColumnWidth = c.ColumnWidth ?? 90
              }).ToList();

            if (temlate) return cellOptions;

            var dicNos = cellOptions.Where(x => !string.IsNullOrEmpty(x.DropNo)).Select(c => c.DropNo);

            if (dicNos.Count() == 0) return cellOptions;

            List<Sys_Dictionary> dictionaries = DictionaryManager.GetDictionaries(dicNos);
            //获取绑定字典数据源下拉框的值
            foreach (string dicNo in dicNos.Distinct())
            {
                Dictionary<string, string> keyValues = null;

                if (dictionaries.Find(p => p.DicNo == dicNo).DbSql != string.Empty)//通过查询语句
                {
                    var data = DBServerProvider.SqlDapper.QueryList<KeyValueDto>(dictionaries
                        .Find(p => p.DicNo == dicNo).DbSql, null).ToList();
                    if (filterKeyValue)
                    {
                        keyValues = data
                            .Where(w => w.key != w.value)? //key==value相同的则不处理
                            .ToDictionary(r => r.key, r => r.value);
                    }
                    else
                    {
                        keyValues = data.ToDictionary(r => r.key, r => r.value);
                    }
                }
                else//通过数据字典
                {
                    var query = dictionaries
                       .Where(x => x.DicNo == dicNo && x.Sys_DictionaryList != null)
                       .Select(s => s.Sys_DictionaryList);
                    //   .FirstOrDefault()
                    //.Where(w => (filterKeyValue && w.DicName != w.DicValue)|| !filterKeyValue) //key==value相同的则不处理
                    //   .ToDictionary(r => r.DicValue, r => r.DicName);
                    if (filterKeyValue)
                    {
                        keyValues = query.FirstOrDefault()?
                         .Where(w => w.DicName != w.DicValue)? //key==value相同的则不处理
                          .ToDictionary(r => r.DicValue, r => r.DicName);
                    }
                    else
                    {
                        keyValues = query.FirstOrDefault()?.ToDictionary(r => r.DicValue, r => r.DicName);
                    }
                }
                foreach (CellOptions options in cellOptions.Where(x => x.DropNo == dicNo))
                {
                    options.KeyValues = keyValues;
                }
            }
            return cellOptions;
        }
    }

  public class KeyValueDto
    {
        public string key { get; set; }
        public string value { get; set; }
    }

你的理解是对的,这个导入时自定义sql校验数据源我们目前还没实际用到所以功能一直没处理,因为还要考虑其他一些细节,没有按你的方式写,你获取下,另外能否把你动态修改表单组件添加的datetime类型这个代码截图下,我这里测试没有发现异常

from vue.netcore.

lvchaoin avatar lvchaoin commented on May 13, 2024

多谢!

from vue.netcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.