licp
2024-06-26 dd61d0f5d1176107de45e0d23e25cc0a761b7124
修改标准库
已修改3个文件
已添加1个文件
154 ■■■■■ 文件已修改
src/components/do/b1-inspect-order-plan/Inspection.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/view/b2-standard.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/util/excelFountion.js 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/do/b1-inspect-order-plan/Inspection.vue
@@ -482,6 +482,7 @@
<script>
  import ValueTable from '../../tool/value-table.vue'
  import file from '../../../util/file'
  import excelFountion from '../../../util/excelFountion'
  export default {
    props: ['sonLaboratory', 'orderId', 'state'],
    components: {
@@ -626,6 +627,7 @@
      this.componentData.entity.sonLaboratory = this.sonLaboratory;
      this.id = this.orderId;
      this.getUserInfo()
      // excelFountion.handel('SUM(MAX(SUM(A1,B1,C1),2,3)*2-MIN(A1:D3),1,2)')
    },
    mounted() {
      this.getTypeDicts()
@@ -1087,12 +1089,12 @@
              } else {
                this.param[b.i].resValue = b
              } */
              if (b.i !== undefined) {
              if (b.i !== undefined&&!this.param[b.i].resValue) {
                this.param[b.i].resValue = b
              }
            }
            if (b.v.ps != undefined && b.v.ps.value === '结论') {
              if (b.i !== undefined) {
              if (b.i !== undefined&&!this.param[b.i].insResult) {
                this.param[b.i].insResult = b
                conclusionList.forEach((n, i) => {
                  if (n.r == b.r && n.c == b.c) {
@@ -1235,6 +1237,7 @@
                } else {
                  item.v.v = 0
                }
                console.log(this.param)
                this.saveInsContext()
              }
            } else {
@@ -1304,7 +1307,6 @@
                  str = str.replaceAll('MAX', 'Math.max')
                  str = str.replaceAll('MIN', 'Math.min')
                  str = str.replaceAll(',', ',')
                  console.log(str)
                  try {
                    if(this.getInspectionValueType(item.i)==1){
                      comResult = eval(str)
src/components/view/b2-standard.vue
@@ -1289,7 +1289,7 @@
          })
        } else {
          this.$axios.post(this.$api.standardTree.upStandardProducts, {
            ids: this.moreSelects.map(a => a.id),
            ids: JSON.stringify(this.moreSelects.map(a => a.id)),
            standardProductList: {
              section: this.sectionRow.section,
              ask: this.sectionRow.ask,
src/main.js
@@ -15,17 +15,17 @@
Vue.prototype.PROJECT = '检测中心'
// Vue.prototype.PROJECT = '装备电缆'
//本地
// Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80";
Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80";
// const javaApi = 'http://127.0.0.1:8001';
// const javaApi = 'http://192.168.0.104:8001';
const javaApi = 'http://192.168.0.104:8001';
//云
// Vue.prototype.LOCATIONVUE = "http://114.132.189.42:8080";
// const javaApi = 'http://114.132.189.42:1234';
//检测中心正式库
Vue.prototype.LOCATIONVUE = "http://10.1.200.86:8080";
const javaApi = 'http://10.1.200.86:8001';
// Vue.prototype.LOCATIONVUE = "http://10.1.200.86:8080";
// const javaApi = 'http://10.1.200.86:8001';
//装备电缆测试库
// Vue.prototype.LOCATIONVUE = "http://10.16.173.59";
src/util/excelFountion.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,136 @@
let f = 'SUM(MAX(1,2,3)*2-MIN(1,2,3),1,2)'
function changeParameter(f){
  let regex = /[=\+\-\*\%\(\)\/\^\s]/g;
  let fouList = [
    "SUM",
    'MAX',
    'MIN'
  ]
  f = f.replace(regex, ',')
  fouList.forEach(item=>{
    f = f.replaceAll(item,',')
  })
  let arr = f.split(',').filter(item=>{
    return item&& /[a-zA-Z]/.test(item)
  });
  let arr2 = []
  arr.forEach(item=>{
    if(item.includes(':')){
      let r0 = getIdFromColumnName(item.split(':')[0]).r;
      let c0 = getIdFromColumnName(item.split(':')[0]).c;
      let r1 = getIdFromColumnName(item.split(':')[1]).r;
      let c1 = getIdFromColumnName(item.split(':')[1]).c;
      for (let i = Number(r0); i <= Number(r1); i++) {
        for (let u = Number(c0); u <= Number(c1); u++) {
          arr2.push({
            r: i,
            c: u
          })
        }
      }
    }else{
      arr2.push(getIdFromColumnName(item))
    }
  })
  return arr2;
}
function SUM(...val){
  let num = 0;
  if(val&&val.length>0){
    val.forEach(item=>{
      num+=item;
    })
  }
  console.log('SUM',num)
  return num;
}
function MAX(...val){
  let max = 0;
  if(val&&val.length>0){
    max = Math.max(...val)
  }
  console.log('MAX',max)
  return max;
}
function MIN(...val){
  let min = 0;
  if(val&&val.length>0){
    min = Math.min(...val)
  }
  console.log('MIN',min)
  return min;
}
function handel(f){
  console.log(changeParameter(f))
  // console.log(eval(f))
}
/**
 * æ ¹æ®åæ ‡èŽ·å–åˆ—å
 * @param {Object} cellId
 */
function getColumnNameFromId(cellId){
    if (! Array.isArray(cellId)) {
        cellId = cellId.split('-');
    }
    var i = cellId[0];
    var letter = '';
    if (i > 701) {
        letter += String.fromCharCode(64 + parseInt(i / 676));
        letter += String.fromCharCode(64 + parseInt((i % 676) / 26));
    } else if (i > 25) {
        letter += String.fromCharCode(64 + parseInt(i / 26));
    }
    letter += String.fromCharCode(65 + (i % 26));
    return letter + (parseInt(cellId[1]) + 1);
}
console.log("getColumnNameFromId",getColumnNameFromId([1,1]))//B2
/**
 * æ ¹æ®åˆ—名获取坐标
 * @param {Object} id
 * @param {Object} arr
 */
function getIdFromColumnName(id, arr) {
    // Get the letters
    var t = /^[a-zA-Z]+/.exec(id);
    if (t) {
        // Base 26 calculation
        var code = 0;
        for (var i = 0; i < t[0].length; i++) {
            code += parseInt(t[0].charCodeAt(i) - 64) * Math.pow(26, (t[0].length - 1 - i));
        }
        code--;
        // Make sure jexcel starts on zero
        if (code < 0) {
            code = 0;
        }
        // Number
        var number = parseInt(/[0-9]+$/.exec(id));
        if (number > 0) {
            number--;
        }
        if (arr == true) {
            id = [ code, number ];
        } else {
            // id = code + '-' + number;
      id = {
        c:code,
        r:number
      }
        }
    }
    return id;
}
console.log("getIdFromColumnName",getIdFromColumnName("B2",true))//[1,1]
export default {
  handel
}