|
@@ -1,31 +1,36 @@
|
|
|
<template>
|
|
|
<basic-container>
|
|
|
- <div class="box-dashed flex">
|
|
|
- <div class="retain-box">
|
|
|
- <el-checkbox v-model="isRetain"></el-checkbox>
|
|
|
- <span>保留</span>
|
|
|
- <el-input-number
|
|
|
- v-model="retainNum"
|
|
|
- :step="1"
|
|
|
- :disabled="!isRetain"
|
|
|
- size="small"
|
|
|
- ></el-input-number>
|
|
|
- <span class="retain">位</span>
|
|
|
+ <div class="box-dashed flex jc-sb">
|
|
|
+ <div class="flex">
|
|
|
+ <div class="retain-box">
|
|
|
+ <el-checkbox v-model="isRetain"></el-checkbox>
|
|
|
+ <span>保留</span>
|
|
|
+ <el-input-number
|
|
|
+ v-model="retainNum"
|
|
|
+ :step="1"
|
|
|
+ :disabled="!isRetain"
|
|
|
+ size="small"
|
|
|
+ ></el-input-number>
|
|
|
+ <span class="retain">位</span>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <el-menu
|
|
|
+ :default-active="activeIndex"
|
|
|
+ class="el-menu-demo"
|
|
|
+ mode="horizontal"
|
|
|
+ @select="handleSelect"
|
|
|
+ >
|
|
|
+ <el-submenu v-for="(value,key,index) in formulaList" :key="key" :index="key">
|
|
|
+ <template slot="title">
|
|
|
+ <span>{{key}}</span>
|
|
|
+ </template>
|
|
|
+ <el-menu-item v-for="(item2,index2) in value" :key="index2" :index="(index+1) +'-' + (index2+1)">{{item2.name}}</el-menu-item>
|
|
|
+ </el-submenu>
|
|
|
+ </el-menu>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div>
|
|
|
- <el-menu
|
|
|
- :default-active="activeIndex"
|
|
|
- class="el-menu-demo"
|
|
|
- mode="horizontal"
|
|
|
- @select="handleSelect"
|
|
|
- >
|
|
|
- <el-submenu v-for="(value,key,index) in formulaList" :key="key" :index="key">
|
|
|
- <template slot="title">
|
|
|
- <span>{{key}}</span>
|
|
|
- </template>
|
|
|
- <el-menu-item v-for="(item2,index2) in value" :key="index2" :index="(index+1) +'-' + (index2+1)">{{item2.name}}</el-menu-item>
|
|
|
- </el-submenu>
|
|
|
- </el-menu>
|
|
|
+ <!-- <el-button size="small" @click="handwrit">手写模式</el-button> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="box-dashed">
|
|
@@ -274,6 +279,23 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <el-dialog title="手写模式" :visible.sync="handwritVisible" width="900px" append-to-body :close-on-click-modal="false">
|
|
|
+ <div class="font-c-warning">tips:手写模式不保证能转换成配置模式!!即使能转换也不保证正确!!!</div>
|
|
|
+ <div class="mg-b-20 font-c-warning">无法在手写模式手写加入新的元素!</div>
|
|
|
+ <editor v-model="handwritText" @init="editorInit" lang="javascript" theme="github" width="100%" height="200"></editor>
|
|
|
+ <!-- <el-input
|
|
|
+ type="textarea"
|
|
|
+ :autosize="{ minRows: 5,}"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ v-model="handwritText">
|
|
|
+ </el-input> -->
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="handwritVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handwritTransform">转 换</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
</basic-container>
|
|
|
</template>
|
|
|
|
|
@@ -304,6 +326,8 @@ export default {
|
|
|
formulaItem,
|
|
|
formulaTemplate,
|
|
|
|
|
|
+ editor: require('vue2-ace-editor'),
|
|
|
+
|
|
|
dateDeviation,
|
|
|
dateFormat,
|
|
|
datasRepeat,
|
|
@@ -376,6 +400,10 @@ export default {
|
|
|
eleListComp:[],//方法下面元素列表
|
|
|
eleTableListComp:[],//方法下面元素表列表
|
|
|
eleTableIdComp:'',//方法下面元素表id
|
|
|
+
|
|
|
+ handwritVisible:false,//手写弹框
|
|
|
+ handwritText:'',//文本
|
|
|
+ handwritEleMap:'',//元素map
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -894,7 +922,10 @@ export default {
|
|
|
wbsId:this.wbsid,
|
|
|
elementId:this.eleid,
|
|
|
map:JSON.stringify(obj.eleMap)
|
|
|
- }).then(()=>{
|
|
|
+ }).then((res)=>{
|
|
|
+ if(res.data.id){
|
|
|
+ this.formulaid = res.data.id;
|
|
|
+ }
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: "保存成功"
|
|
@@ -911,7 +942,6 @@ export default {
|
|
|
if(detail.id){
|
|
|
this.formulaid = detail.id;
|
|
|
//let formula = formulaStringToArray('FC.sum(FC.repeat(E[测试测试_222]))+FC.ifelse(3<E[测试测试_333]&&E[测试测试_333]<10,E[测试测试_222]+E[测试测试_333],E[测试测试_333])',detail.map,this.formulaMap);
|
|
|
- detail.formula = detail.formula.replace(/</g,"<").replace(/&/g,"&");
|
|
|
let formula = formulaStringToArray(detail.formula,detail.map,this.formulaMap);
|
|
|
this.processFormula = formula.processFormula;
|
|
|
formula.resultFormula[0].id = this.resultFormula[0].id;
|
|
@@ -1018,6 +1048,60 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ //手写模式
|
|
|
+ handwrit(){
|
|
|
+ try {
|
|
|
+ let obj = formulaArrayToString(this.processFormula,this.resultFormula);
|
|
|
+ this.handwritText = obj.text;
|
|
|
+ this.handwritEleMap = JSON.stringify(obj.eleMap);
|
|
|
+ this.handwritVisible = true;
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "生成公式文本失败,"+error
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ //转成配置用的数组
|
|
|
+ handwritTransform(){
|
|
|
+ try {
|
|
|
+ let formula = formulaStringToArray(this.handwritText,this.handwritEleMap,this.formulaMap);
|
|
|
+ this.processFormula = formula.processFormula;
|
|
|
+ formula.resultFormula[0].id = this.resultFormula[0].id;
|
|
|
+ formula.resultFormula[0].name = this.resultFormula[0].name;
|
|
|
+ formula.resultFormula[0].tableElementKey = this.resultFormula[0].tableElementKey;
|
|
|
+ this.resultFormula[0].children = formula.resultFormula[0].children;
|
|
|
+ this.handwritVisible = false;
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "转成配置用的数组失败,"+error
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ editorInit: function (editor) {
|
|
|
+ console.log('editorInit')
|
|
|
+ require('brace/ext/searchbox') //添加搜索功能
|
|
|
+ require('brace/ext/language_tools') //language extension prerequsite...
|
|
|
+ require('brace/mode/javascript') //language
|
|
|
+ require('brace/theme/github')
|
|
|
+ require('brace/snippets/javascript') //snippet
|
|
|
+
|
|
|
+ editor.session.setUseWrapMode(true);//切换自动换行
|
|
|
+ editor.setHighlightActiveLine(false);//设置行高亮显示
|
|
|
+ editor.setShowPrintMargin(false);
|
|
|
+ editor.setOptions({
|
|
|
+ enableLiveAutocompletion:true,//语法提示和补全
|
|
|
+ showInvisibles:true,//显示隐藏,空格,回车等
|
|
|
+ fontSize:'16px'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
getTypeMap(){
|
|
|
return new Promise((resolve)=>{
|
|
|
getTypeMap().then((res)=>{
|