edit.vue 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144
  1. <template>
  2. <basic-container>
  3. <div class="flex flex-d-c h-100p">
  4. <div class="box-dashed flex jc-sb">
  5. <div class="flex">
  6. <div class="retain-box">
  7. <el-checkbox v-model="isRetain"></el-checkbox>
  8. <span>保留</span>
  9. <el-input-number
  10. v-model="retainNum"
  11. :step="1"
  12. :min="0" :max="5"
  13. :disabled="!isRetain"
  14. size="small"
  15. ></el-input-number>
  16. <span class="retain">位</span>
  17. </div>
  18. <div class="retain-box">
  19. <el-button size="mini" style="margin:10px;margin-top:16px;" @click="deviationRange.show = !deviationRange.show">允许偏差值范围</el-button>
  20. </div>
  21. <div>
  22. <el-menu
  23. :default-active="activeIndex"
  24. class="el-menu-demo"
  25. mode="horizontal"
  26. @select="handleSelect"
  27. >
  28. <el-submenu v-for="(value,key,index) in formulaList" :key="key" :index="key">
  29. <template slot="title">
  30. <span>{{key}}</span>
  31. </template>
  32. <el-menu-item v-for="(item2,index2) in value" :key="index2" :index="(index+1) +'-' + (index2+1)">{{item2.name}}</el-menu-item>
  33. </el-submenu>
  34. </el-menu>
  35. </div>
  36. </div>
  37. <div>
  38. <el-button size="small" @click="handwrit">手写模式</el-button>
  39. </div>
  40. </div>
  41. <div class="box-dashed">
  42. <div class="mg-b-20">函数公式..(节点公式)</div>
  43. <div class="edit-text">
  44. <span>
  45. <formula-item
  46. v-for="(item,index) in resultFormula" :key="index"
  47. :item="item" @click="obj => equationClick(obj,index,'resultFormula')"
  48. >
  49. </formula-item>
  50. </span>
  51. <span style="margin-left: 5px;margin-right: 5px;">=</span>
  52. <span v-for="(item,index) in processFormula" :key="index">
  53. <el-tooltip class="item" effect="light" placement="top-start" :disabled="item.type!=='Element'">
  54. <div slot="content">{{item.tableName }}</div>
  55. <formula-item
  56. :getname="getItemTableName(item)"
  57. :item="item" @click="obj => equationClick(obj,index,'processFormula')"
  58. >
  59. </formula-item>
  60. </el-tooltip>
  61. </span>
  62. </div>
  63. <div class="flex jc-sb">
  64. <div></div>
  65. <div><el-button type="info" size="small" @click="operationEdit">重置函数</el-button></div>
  66. </div>
  67. </div>
  68. <div v-show="operationVisible" class="operation-box flex1 flex flex-d-c ov-hidden">
  69. <div>选择参数设置</div>
  70. <div class="flex flex-d-c flex1 ov-hidden">
  71. <el-row :gutter="20" class="flex1 ov-hidden">
  72. <el-col :span="8" class="h-100p">
  73. <el-card shadow="never" v-loading="treeLoad" class="h-100p ov-auto">
  74. <el-scrollbar style="height: 100%">
  75. <!-- <el-tree
  76. class="filter-tree"
  77. lazy
  78. :load="loadNode"
  79. @node-click="getNodeDetail"
  80. :props="defaultProps"
  81. :expand-on-click-node="false"
  82. highlight-current
  83. node-key="id"
  84. ref="tree"
  85. >
  86. </el-tree> -->
  87. <el-tree
  88. class="filter-tree"
  89. :data="treeData"
  90. :default-expanded-keys="defaultExpanded"
  91. @node-click="getNodeDetail"
  92. :props="defaultProps"
  93. :expand-on-click-node="false"
  94. highlight-current
  95. node-key="id"
  96. ref="tree"
  97. >
  98. </el-tree>
  99. </el-scrollbar>
  100. </el-card>
  101. </el-col>
  102. <el-col :span="16" class="h-100p flex flex-d-c ov-hidden">
  103. <div class="flex" style="justify-content: space-between;width:100%">
  104. <el-select v-model="eleTableId" @change="getTableEle" placeholder="请选择元素表1" style="width:45%">
  105. <el-option v-if="paramDataList.length" label="选择节点参数2" value="选择节点参数"></el-option>
  106. <el-option v-for="item in eleTableList" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)?item.pkeyId:item.id"></el-option>
  107. </el-select>
  108. <!-- 搜索元素下拉框 -->
  109. <el-select v-model="input3" filterable clearable placeholder="搜索元素字段" @change="getInput" style="width:45%">
  110. <el-option
  111. v-for="item in eleList1"
  112. :key="item.id"
  113. :label="item.eName"
  114. :value="item.eName">
  115. </el-option>
  116. </el-select>
  117. </div>
  118. <div class="mg-t-10 no-mb-col flex1 ov-hidden">
  119. <el-scrollbar style="height: 100%">
  120. <el-row v-loading="eleListable" v-if="eleList.length>0">
  121. <el-col :span="6" v-for="item in eleList" :key="item.id" >
  122. <div class="ele-box">
  123. <span v-if="item.k">{{item.name}}</span>
  124. <span v-else>{{item.eName}}</span>
  125. <el-checkbox v-model="item.checked" @change="value => eleChang(value,item)"></el-checkbox>
  126. </div>
  127. </el-col>
  128. </el-row>
  129. <el-row v-else style="text-align: center;line-height: 328px;border:1px solid #bbb">暂无数据</el-row>
  130. </el-scrollbar>
  131. </div>
  132. <div class="flex jc-sb">
  133. <!-- <div>定位数据位置:</div> -->
  134. <div class="icon-box">
  135. <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelect"></el-link>
  136. <el-link :underline="false" type="primary" @click="addOperator('+')" icon="el-icon-circle-plus-outline"></el-link>
  137. <el-link :underline="false" type="primary" @click="addOperator('-')" icon="el-icon-remove-outline"></el-link>
  138. <el-link :underline="false" type="primary" @click="addOperator('*')" icon="el-icon-circle-close"></el-link>
  139. <el-link :underline="false" type="primary" @click="addOperator('%')">÷</el-link>
  140. </div>
  141. <div>
  142. <!-- <el-link :underline="false" type="primary" class="mg-r-20" @click="eleAddFormula">元素添加到公式</el-link> -->
  143. <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets('(',false)">(</el-link>
  144. <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets(')',true)">)</el-link>
  145. <!-- <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets('[',false)">【</el-link>
  146. <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets(']',true)">】</el-link> -->
  147. <el-link :underline="false" type="primary" @click="addText">输入值</el-link>
  148. </div>
  149. </div>
  150. <div class="border-grey sele-ele-box" style="height:50px">
  151. <draggable v-model="selectEleFormula">
  152. <formula-item
  153. v-for="(item,index) in selectEleFormula" :key="index"
  154. :item="item" @click="obj => eleFormulaClick(obj,index)"
  155. >
  156. </formula-item>
  157. </draggable>
  158. </div>
  159. </el-col>
  160. </el-row>
  161. <div class="text-align-c">
  162. <el-button size="small" @click="operationHandle" type="primary">保存</el-button>
  163. <el-button size="small" @click="canceloperationVisible ">取消</el-button>
  164. </div>
  165. </div>
  166. </div>
  167. <div v-show="!operationVisible && !showFunDetail && !deviationRange.show">
  168. <div class="box-dashed">
  169. <div class="mg-b-20">函数公式运算执行溯源</div>
  170. <div>
  171. <el-select
  172. v-model="projectId"
  173. @change="projectChange"
  174. placeholder="请选择项目"
  175. style="width: 380px"
  176. >
  177. <el-option
  178. v-for="item in projectList"
  179. :key="item.id"
  180. :label="item.projectName"
  181. :value="item.id"
  182. ></el-option>
  183. </el-select>
  184. <el-select v-model="contractId" placeholder="请选择合同段">
  185. <el-option
  186. v-for="item in contractList"
  187. :key="item.id"
  188. :label="item.contractName"
  189. :value="item.id"
  190. ></el-option>
  191. </el-select>
  192. <el-button type="info">查询</el-button>
  193. </div>
  194. </div>
  195. </div>
  196. <div v-if="!operationVisible && showFunDetail" class="flex1">
  197. <el-tabs v-model="actiFunIndex" closable @tab-remove="removeFun" :before-leave="funLeave">
  198. <el-tab-pane v-for="(item,index) in equationSelectEle.children" :key="index" :label="item.name" :name="index.toString()">
  199. <template v-if="!componentMap[item.name]">
  200. <formula-template ref="dynamiccomponent" :formulainfo="item" :curele="equationSelectEle" @sele-ele-handle="showChooseEle">
  201. </formula-template>
  202. </template>
  203. <template v-else>
  204. <div class="flex" >
  205. <div class=" flex-d-c" style="width:40%">
  206. <component ref="dynamiccomponent"
  207. v-bind:is="componentMap[item.name]"
  208. :formulainfo="item"
  209. :curele="equationSelectEle"
  210. :formulamap="formulaMap"
  211. :map="formulaDetailMap"
  212. @uncheck="unCheckEleComp"
  213. class="flex1"
  214. :moreConditions="moreConditions"
  215. :isMore="isMore"
  216. :isGetData="isGetData"
  217. :dataListGet="dataListGet"
  218. :isDataChange="isDataChange"
  219. :dataForm="dataForm"
  220. :remark="remark"
  221. >
  222. </component>
  223. <div class="flex1" v-show="item.showSelectEle" style="margin-top:10px;margin-bottom:30px">
  224. <el-scrollbar style="height: 400px">
  225. <el-tree
  226. class="filter-tree"
  227. :data="treeData"
  228. :default-expanded-keys="defaultExpanded"
  229. @node-click="getNodeDetailComp"
  230. :props="defaultProps"
  231. :expand-on-click-node="false"
  232. highlight-current
  233. node-key="id"
  234. ref="tree"
  235. >
  236. </el-tree>
  237. </el-scrollbar>
  238. </div>
  239. </div>
  240. <div v-show="item.showSelectEle" style="width:60%">
  241. <div class="flex" style="justify-content: space-between;width:100%">
  242. <el-select v-model="eleTableIdComp" @change="getTableEleComp" placeholder="请选择元素表" style="width:45%">
  243. <el-option v-if="paramDataList.length" label="选择节点参数" value="选择节点参数"></el-option>
  244. <!-- <el-option v-for="item in eleTableListComp" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)"></el-option> -->
  245. <el-option v-for="item in eleTableListComp" :key="item.id" :label="item.tableName" :value="item.pkeyId"></el-option>
  246. </el-select>
  247. <!-- 搜索元素下拉框 -->
  248. <el-select v-model="input3" filterable placeholder="搜索元素字段" @change="getInput1" style="width:45%">
  249. <el-option
  250. v-for="item in eleListComp1"
  251. :key="item.id"
  252. :label="item.eName"
  253. :value="item.eName">
  254. </el-option>
  255. </el-select>
  256. </div>
  257. <div class="mg-t-10 mg-b-10 no-mb-col" style="width:100%">
  258. <el-scrollbar style="height:520px;">
  259. <el-row>
  260. <el-col :span="6" v-for="item in eleListComp" :key="item.id">
  261. <div class="ele-box">
  262. <span v-if="item.k">{{item.name}}</span>
  263. <span v-else>{{item.eName}}</span>
  264. <el-checkbox v-model="item.checked" @change="value => setComponentEle(value,item,index)"></el-checkbox>
  265. </div>
  266. </el-col>
  267. </el-row>
  268. </el-scrollbar>
  269. </div>
  270. </div>
  271. </div>
  272. </template>
  273. </el-tab-pane>
  274. </el-tabs>
  275. </div>
  276. <!-- 允许偏差值范围 -->
  277. <div v-if="!operationVisible && !showFunDetail && deviationRange.show" class="flex1">
  278. <div class="flex">
  279. <div class=" flex-d-c" style="width:40%">
  280. <deviation-range ref="deviationrange" :formulainfo="deviationRange" :formulamap="formulaMap" @uncheck="unCheckEleComp" class="flex1"></deviation-range>
  281. <div class="flex1" v-show="deviationRange.showSelectEle" style="margin-top:10px;margin-bottom:30px">
  282. <el-scrollbar style="height: 400px">
  283. <el-tree
  284. class="filter-tree"
  285. :data="treeData"
  286. :default-expanded-keys="defaultExpanded"
  287. @node-click="getNodeDetailComp"
  288. :props="defaultProps"
  289. :expand-on-click-node="false"
  290. highlight-current
  291. node-key="id"
  292. ref="tree"
  293. >
  294. </el-tree>
  295. </el-scrollbar>
  296. </div>
  297. </div>
  298. <div v-show="deviationRange.showSelectEle" style="width:60%">
  299. <div class="flex" style="justify-content: space-between;width:100%">
  300. <el-select v-model="eleTableIdComp" @change="getTableEleComp" placeholder="请选择元素表" style="width:45%">
  301. <el-option v-if="paramDataList.length" label="选择节点参数" value="选择节点参数"></el-option>
  302. <el-option v-for="item in eleTableListComp" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)"></el-option>
  303. </el-select>
  304. <!-- 搜索元素下拉框 -->
  305. <el-select v-model="input3" filterable clearable placeholder="搜索元素字段" @change="getInput1" style="width:45%">
  306. <el-option
  307. v-for="item in eleListComp1"
  308. :key="item.id"
  309. :label="item.eName"
  310. :value="item.eName">
  311. </el-option>
  312. </el-select>
  313. </div>
  314. <div class="mg-t-10 mg-b-10 no-mb-col" style="width:100%">
  315. <el-scrollbar style="height:520px;">
  316. <el-row>
  317. <el-col :span="6" v-for="item in eleListComp" :key="item.id">
  318. <div class="ele-box">
  319. <span v-if="item.k">{{item.name}}</span>
  320. <span v-else>{{item.eName}}</span>
  321. <el-checkbox v-model="item.checked" @change="value => setDeviationRangeEle(value,item)"></el-checkbox>
  322. </div>
  323. </el-col>
  324. </el-row>
  325. </el-scrollbar>
  326. </div>
  327. </div>
  328. </div>
  329. </div>
  330. <div class="text-align-c" v-show="!operationVisible">
  331. <el-button type="warning" @click="$emit('hideDialog')">取消</el-button>
  332. <el-button type="primary" @click="saveFormula">保存</el-button>
  333. </div>
  334. </div>
  335. <el-dialog title="输入值" :visible.sync="inputVisible" width="300px" append-to-body :close-on-click-modal="false">
  336. <el-input v-model="inputText" placeholder="请输入内容"></el-input>
  337. <div class="text-align-c mg-t-10">
  338. <el-button size="small" @click="addTextHandle" type="primary">保存</el-button>
  339. <el-button size="small" @click="inputVisible = false">取消</el-button>
  340. </div>
  341. </el-dialog>
  342. <el-dialog title="选择元素" :visible.sync="chooseEleVisible" width="70%" append-to-body :close-on-click-modal="false">
  343. <div>
  344. <el-row :gutter="20">
  345. <el-col :span="8">
  346. <el-card shadow="never">
  347. <el-scrollbar style="height: 460px">
  348. <el-tree
  349. class="filter-tree"
  350. :data="treeData"
  351. :default-expanded-keys="defaultExpanded"
  352. @node-click="getNodeDetail"
  353. :props="defaultProps"
  354. :expand-on-click-node="false"
  355. highlight-current
  356. node-key="id"
  357. ref="tree"
  358. >
  359. </el-tree>
  360. </el-scrollbar>
  361. </el-card>
  362. </el-col>
  363. <el-col :span="16">
  364. <div class="flex" style="justify-content: space-between;width:100%">
  365. <el-select v-model="eleTableId" @change="getTableEle" placeholder="请选择元素表">
  366. <el-option v-if="paramDataList.length" label="选择节点参数3" value="选择节点参数"></el-option>
  367. <!-- <template v-if="pid">
  368. <el-option v-for="item in eleTableList" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)"></el-option>
  369. </template> -->
  370. <template>
  371. <!-- <el-option v-for="item in eleTableList" :key="item.pkeyId" :label="item.tableName" :value="item.pkeyId"></el-option> -->
  372. <el-option v-for="item in eleTableList" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)?item.pkeyId:item.id"></el-option>
  373. </template>
  374. </el-select>
  375. <!-- 搜索元素下拉框 -->
  376. <el-select v-model="input3" filterable clearable placeholder="搜索元素字段" @change="getInput" style="width:45%">
  377. <el-option
  378. v-for="item in eleList1"
  379. :key="item.id"
  380. :label="item.eName"
  381. :value="item.eName">
  382. </el-option>
  383. </el-select>
  384. </div>
  385. <div class="mg-t-10 mg-b-10 no-mb-col">
  386. <el-scrollbar style="height: 460px">
  387. <el-row v-loading="eleListable" v-if="eleList.length>0">
  388. <el-col :span="6" v-for="item in eleList" :key="item.id">
  389. <div class="ele-box">
  390. <span v-if="item.k">{{item.name}}</span>
  391. <span v-else>{{item.eName}}</span>
  392. <el-checkbox v-model="item.checked" @change="value => eleCheckHandle(value,item)"></el-checkbox>
  393. </div>
  394. </el-col>
  395. </el-row>
  396. <el-row v-else style="text-align: center;line-height: 328px;border:1px solid #bbb">暂无数据</el-row>
  397. </el-scrollbar>
  398. </div>
  399. </el-col>
  400. </el-row>
  401. <div class="text-align-c">
  402. <el-button size="small" @click="chooseEleHandle" type="primary">保存</el-button>
  403. <el-button size="small" @click="chooseEleVisible = false">取消</el-button>
  404. </div>
  405. </div>
  406. </el-dialog>
  407. <el-dialog title="手写模式" :visible.sync="handwritVisible" width="900px" append-to-body :close-on-click-modal="false">
  408. <div class="font-c-warning">tips:手写模式不保证能转换成配置模式!!即使能转换也不保证正确!!!</div>
  409. <div class="mg-b-20 font-c-warning">无法在手写模式手写加入新的元素!新的节点参数!</div>
  410. <editor v-model="handwritText" @init="editorInit" lang="javascript" theme="github" width="100%" height="200"></editor>
  411. <!-- <el-input
  412. type="textarea"
  413. :autosize="{ minRows: 5,}"
  414. placeholder="请输入内容"
  415. v-model="handwritText">
  416. </el-input> -->
  417. <span slot="footer" class="dialog-footer">
  418. <el-button @click="handwritVisible = false">取 消</el-button>
  419. <el-button type="primary" @click="handwritTransform">转 换</el-button>
  420. </span>
  421. </el-dialog>
  422. </basic-container>
  423. </template>
  424. <script>
  425. import { getLazytree,selectFormElements,getAlltree,getNodeTabAndParam} from "@/api/manager/wbstree";
  426. import { getProjectList,findProjectTree } from "@/api/manager/projectinfo";
  427. import { findContractByProjectId } from "@/api/manager/contractinfo";
  428. import { getDetail as getEleDeatil } from "@/api/manager/wbsformelement";
  429. import { getTypeMap,saveFormula,formulaDetail,updateFormula } from "@/api/formula/formula";
  430. import { getNodeTabAndParam as wbsPrivateGetNodeTabAndParam } from "@/api/manager/wbsprivate";
  431. import {mapGetters} from "vuex";
  432. import formulaItem from "./component/formulaItem"
  433. import formulaTemplate from "./component/formulaTemplate"
  434. import dateDeviation from "./component/funComponent/dateDeviation"
  435. import dateFormat from "./component/funComponent/dateFormat"
  436. import datasRepeat from "./component/funComponent/datasRepeat"
  437. import datasReme from "./component/funComponent/datasReme"
  438. import datasGetlist from "./component/funComponent/datasGetlist"
  439. import datasJoin from "./component/funComponent/datasJoin"
  440. import ifelse from "./component/funComponent/ifelse"
  441. import deviationRange from "./component/deviationRange/deviationRange"
  442. import {rangeToString} from "./component/deviationRange/rangeToString"
  443. import {formulaArrayToString} from "./formulaArrayToString"
  444. import {formulaStringToArray} from "./formulaStringToArray"
  445. import draggable from 'vuedraggable'
  446. import {formatArrayMore,restoreArrayMore,generateResult} from './component/funComponent/multiIfElseTools'
  447. import dataChange from "./component/funComponent/dataChange"
  448. export default {
  449. components: {
  450. draggable,
  451. formulaItem,
  452. formulaTemplate,
  453. editor: require('vue2-ace-editor'),
  454. dateDeviation,
  455. dateFormat,
  456. datasRepeat,
  457. datasReme,
  458. datasGetlist,
  459. datasJoin,
  460. ifelse,
  461. deviationRange,
  462. dataChange
  463. },
  464. props: {
  465. wbsid:{
  466. type:String,
  467. default:''
  468. },
  469. eleid:{
  470. type:String,
  471. default:''
  472. },
  473. globaltype:{
  474. type:Number,
  475. default:10
  476. },
  477. nodeid:{
  478. type:String,
  479. default:''
  480. },
  481. pid:{
  482. type:String,
  483. default:''
  484. },
  485. fromcurNode:{
  486. type:Object,
  487. default:() => ({})
  488. },
  489. iswbstype:{//是否是公共wbs
  490. type:String,
  491. default:''
  492. }
  493. },
  494. data() {
  495. return {
  496. // wbsid: "", //从哪个wbs树过来的
  497. // eleid: "", //元素id
  498. // nodeid:'',//所在树节点id
  499. // pid:'',//项目id 私有树才有
  500. formulaid:'',
  501. treeData:[],//树节点
  502. treeLoad:false,
  503. defaultExpanded:[],//默认展开节点
  504. isRetain: false, //是否保留小数
  505. retainNum: 2, //保留几位小数
  506. formulaList:{},
  507. formulaMap:{},
  508. activeIndex: "1-1", //当前选择的公式
  509. itemList:[],
  510. projectList: [], //项目备选列表
  511. projectId: "", //溯源的项目ID
  512. curProjiect: {}, //当前项目对象
  513. contractList: [], //合同段备选列表
  514. contractId: "", //合同段id
  515. operationVisible: false, //基础运算弹窗
  516. defaultProps: {
  517. children: "children",
  518. label: "title",
  519. isLeaf: function (data) {
  520. return !data.hasChildren || (data.isExistForm==1);
  521. },
  522. },
  523. eleTableId:'',//选中的元素表id
  524. eleTableList:[],
  525. eleList:[],
  526. eleChecks:[],//勾选的元素列表
  527. selectEleFormula:[],
  528. curSeleEleIndex:-1,//公式文字里面选中的元素索引
  529. inputVisible:false,//输入弹窗
  530. inputText:"",//输入值
  531. deleEleIndex:-1,//删除元素的位置,如果下次添加元素,先加到这个位置
  532. resultFormula:[],//=等号左边的数组
  533. processFormula:[],//=等号右边的数组
  534. rightDict:[],//等号右边元素的字典
  535. processType:'',//选中的元素在等号哪边
  536. processSelectIndex:0,//选中的索引
  537. actiFunIndex:0,//元素下挂载的计算式的索引
  538. chooseEleVisible:false,//选择元素弹窗
  539. argumenObj:{},
  540. checkGsId:'',//选中的元素表id
  541. symbolReg:/(\+|-|\*|\/)(.+)/,
  542. operatorReg : /^\+|-|\*|%/,//加减乘除
  543. startFCRegExp : /^FC\.([a-zA-Z0-9]+)\(/,// 匹配开始的FC.xxx(
  544. componentMap:{
  545. '日期偏移':'date-deviation',
  546. '日期格式化':'date-format',
  547. // '去重':'datas-repeat',
  548. // '去空':'datas-reme',
  549. '下标取数':'datas-getlist',
  550. // '数组转字符串':"datas-join",
  551. '判断':'ifelse',
  552. '数据自变':'data-change'
  553. },
  554. eleListComp:[],//方法下面元素列表
  555. eleTableListComp:[],//方法下面元素表列表
  556. eleTableIdComp:'',//方法下面元素表id
  557. handwritVisible:false,//手写弹框
  558. handwritText:'',//文本
  559. handwritEleMap:'',//元素map
  560. paramDataList:[],//节点参数数组
  561. deviationRange:{
  562. show:false,//显示
  563. showSelectEle:false,//显示选择元素
  564. datas:{
  565. symbol:'【min,max】',
  566. model:'1',
  567. arguments1:'',
  568. arguments2:'',
  569. },
  570. },//允许偏差值范围
  571. version:1,//版本号,以后可能会有不兼容旧公式的改动,留作以后可能用来判断
  572. input3:'',//搜索元素字段
  573. eleListable:false,
  574. isMore:false,//是否是多条件判断
  575. moreConditions:[],//多条件判断数组
  576. formulaDetailMap:{},//公式详情map
  577. dataListGet:'',
  578. isGetData:false,//是否获取数据
  579. isDataChange:false,//是否数据自变
  580. dataForm:'',
  581. remark:'',//备注
  582. };
  583. },
  584. computed: {
  585. ...mapGetters(["userInfo"]),
  586. // selectEleFormulaText:function(){
  587. // let text = '';
  588. // this.selectEleFormula.forEach((Element)=>{
  589. // text+=Element.name;
  590. // })
  591. // return text
  592. // }
  593. //等式中选中的元素
  594. equationSelectEle:function(){
  595. if(this.processType){
  596. return this[this.processType][this.processSelectIndex];
  597. }else{
  598. return null;
  599. }
  600. },
  601. //是否显示元素下挂载的计算式信息
  602. showFunDetail:function(){
  603. if(this.equationSelectEle && this.equationSelectEle.children && this.equationSelectEle.children.length>0){
  604. return true;
  605. }else{
  606. return false;
  607. }
  608. }
  609. },
  610. created() {
  611. // this.wbsid = this.$route.query.wbsid;
  612. // this.eleid = this.$route.query.eleid;
  613. // this.nodeid = this.$route.query.nodeid;
  614. this.pid = this.$route.query.pid;//项目id 私有树才有
  615. this.init();
  616. },
  617. methods: {
  618. async init() {
  619. this.getEleDeatil();
  620. this.getProjectList();
  621. this.geTreeData();
  622. await this.getTypeMap();
  623. this.formulaStringToArray();
  624. },
  625. geTreeData(){
  626. this.treeLoad = true;
  627. if(this.pid){
  628. findProjectTree(this.pid, this.wbsid).then((res) => {
  629. this.treeLoad = false;
  630. this.treeData = res.data.data;
  631. this.defaultExpanded = [this.nodeid];
  632. this.$nextTick(()=>{
  633. let isArray = Array.isArray(this.$refs.tree)
  634. if (isArray) {
  635. // 根据 id 获取节点信息
  636. this.$refs.tree[0].setCurrentKey(this.nodeid);
  637. } else {
  638. this.$refs.tree.setCurrentKey(this.nodeid);
  639. }
  640. this.getNodeDetail(this.fromcurNode)
  641. this. getNodeDetailComp(this.fromcurNode)
  642. })
  643. })
  644. }else{
  645. getAlltree(this.userInfo.tenant_id, 1, this.wbsid).then((res) => {
  646. this.treeLoad = false;
  647. this.treeData = res.data.data;
  648. this.defaultExpanded = [this.nodeid];
  649. console.log(this.$refs.tree,'tree');
  650. this.$nextTick(()=>{
  651. let isArray = Array.isArray(this.$refs.tree)
  652. if (isArray) {
  653. // 根据 id 获取节点信息
  654. this.$refs.tree[0].setCurrentKey(this.nodeid);
  655. } else {
  656. this.$refs.tree.setCurrentKey(this.nodeid);
  657. }
  658. this.getNodeDetail(this.fromcurNode)
  659. this. getNodeDetailComp(this.fromcurNode)
  660. })
  661. })
  662. }
  663. },
  664. //懒加载树
  665. loadNode(node, resolve) {
  666. let pid = 0;
  667. if (node.level != 0) {
  668. pid = node.data.id;
  669. }
  670. getLazytree(this.wbsid, pid, this.userInfo.tenant_id).then((res) => {
  671. let arr = [];
  672. if (Array.isArray(res.data.data)) {
  673. arr = res.data.data;
  674. }
  675. return resolve(arr);
  676. });
  677. },
  678. //获取项目列表
  679. getProjectList() {
  680. getProjectList(1, 999).then((res) => {
  681. this.projectList = res.data.data.records;
  682. });
  683. },
  684. //选择公式处理
  685. handleSelect(index,indexPath) {
  686. //console.log(index,'index')
  687. //console.log(indexPath,'indexPath')
  688. if(this.operationVisible){
  689. this.openerationSelect(index,indexPath)
  690. }else{
  691. this.equationSelect(index,indexPath)
  692. }
  693. },
  694. //在选择元素模式下点选计算式
  695. openerationSelect(index,indexPath){
  696. if(indexPath[0]!='基础运算'){
  697. this.$message({
  698. type: "warning",
  699. message: "当前只能使用基础运算"
  700. });
  701. return;
  702. }
  703. let formulaindex = Number(indexPath[1].split('-')[1])-1;
  704. this.eleAddFormulaHandle(this.formulaList[indexPath[0]][formulaindex]);
  705. },
  706. //溯源项目id切换
  707. projectChange(id) {
  708. for (let i = 0; i < this.projectList.length; i++) {
  709. if (id == this.projectList[i].id) {
  710. this.curProjiect = this.projectList[i];
  711. //根据项目id获取合同段列表
  712. findContractByProjectId(this.curProjiect.id).then((res) => {
  713. this.contractList = res.data.data;
  714. this.contractId = "";
  715. });
  716. return;
  717. }
  718. }
  719. },
  720. operationEdit(){
  721. this.selectEleFormula= JSON.parse(JSON.stringify(this.processFormula));
  722. this.operationVisible = true;
  723. },
  724. eleAddFormula(){
  725. for (let i = 0; i < this.eleList.length; i++) {
  726. if (this.eleList[i].checked) {
  727. this.eleAddFormulaHandle(this.eleList[i]);
  728. break;
  729. }
  730. }
  731. },
  732. // eleChang(value,item){
  733. // //console.log(value)
  734. // //console.log(item)
  735. // if(value){
  736. // //简单语法判断
  737. // if(this.selectEleFormula.length != 0 && this.deleEleIndex < 0){
  738. // let lastEle = this.selectEleFormula[this.selectEleFormula.length-1];
  739. // if(lastEle.type == 'Element'){
  740. // this.$message({
  741. // type: "warning",
  742. // message: "元素无法连续出现在元素后面"
  743. // });
  744. // item.checked = false;
  745. // return;
  746. // }
  747. // if(lastEle.type == 'Text'){
  748. // this.$message({
  749. // type: "warning",
  750. // message: "元素无法连续出现在输入值后面"
  751. // });
  752. // item.checked = false;
  753. // return;
  754. // }
  755. // if(lastEle.type == 'Brackets' && lastEle.name == ')'){
  756. // this.$message({
  757. // type: "warning",
  758. // message: "元素无法连续出现在右括号后面"
  759. // });
  760. // item.checked = false;
  761. // return;
  762. // }
  763. // }
  764. // this.eleAddFormulaHandle(item);
  765. // }else{
  766. // let index = -1;
  767. // for (let i = 0; i < this.selectEleFormula.length; i++) {
  768. // if(this.selectEleFormula[i].id == item.id){
  769. // index = i;
  770. // break;
  771. // }
  772. // }
  773. // if(index>-1){
  774. // this.selectEleFormula.splice(index,1);
  775. // }
  776. // }
  777. // },
  778. eleChang(value,item){
  779. if(value){
  780. //简单语法判断
  781. if(this.itemList.length != 0 && this.deleEleIndex < 0){
  782. let lastEle = this.itemList[this.itemList.length-1];
  783. if(lastEle.type == 'Text'){
  784. this.$message({
  785. type: "warning",
  786. message: "元素无法连续出现在输入值后面"
  787. });
  788. item.checked = false;
  789. return;
  790. }
  791. if(lastEle.type == 'Brackets' && lastEle.name == ')'){
  792. this.$message({
  793. type: "warning",
  794. message: "元素无法连续出现在右括号后面"
  795. });
  796. item.checked = false;
  797. return;
  798. }
  799. }
  800. let lastEle = this.selectEleFormula[this.selectEleFormula.length-1];
  801. if(this.selectEleFormula.length == 0 || lastEle.type == 'Operator' || lastEle.type == 'Brackets' || lastEle.name == '('){ /* 存在运算符 */
  802. this.eleAddFormulaHandle(item);
  803. } else {
  804. this.itemList.push(item);
  805. }
  806. }else{
  807. let index = -1;
  808. for (let i = 0; i < this.itemList.length; i++) {
  809. if(this.itemList[i].id == item.id){
  810. index = i;
  811. break;
  812. }
  813. }
  814. if(index>-1){
  815. this.itemList.splice(index,1);
  816. }
  817. }
  818. },
  819. //快捷添加运算符号
  820. // addOperator(operator){
  821. // this.eleAddFormulaHandle(this.formulaMap[operator]);
  822. // },
  823. randomaddOperator(ele){
  824. //type 是true 表示在元素右边插入
  825. let item={
  826. type:'Operator',
  827. name:this.symbolReg.exec(ele.name)[1],
  828. selected:false,
  829. template:ele.template
  830. }
  831. let index = Number(this.curSeleEleIndex);
  832. let currentName = this.selectEleFormula[index]
  833. if (currentName.type === 'Operator') { /* 选择的符号的时候,直接替换 */
  834. this.selectEleFormula.splice(index,1, item)
  835. }
  836. else { /* 选择元素的时候,如果下一个是符号则替换,如果下一个是元素则添加 */
  837. let size = index + 1;
  838. let lastName = this.selectEleFormula[size]
  839. if (lastName.type === 'Operator') { /* 是符号,替换 */
  840. this.selectEleFormula.splice(size,1, item)
  841. }
  842. else { /* 是元素,添加 */
  843. this.selectEleFormula.splice(size,0, item)
  844. }
  845. }
  846. },
  847. addOperator(operator){
  848. if( this.itemList.length>0){
  849. this.itemList.forEach(e => {
  850. let lastEle = this.selectEleFormula[this.selectEleFormula.length-1];
  851. if(this.selectEleFormula.length != 0 && lastEle.type != 'Operator' && lastEle.type != 'Brackets' && lastEle.name != '('){ /* 不存在运算符 */
  852. this.eleAddFormulaHandle(this.formulaMap[operator]);
  853. }
  854. this.eleAddFormulaHandle(e);
  855. })
  856. }else{
  857. if(this.curSeleEleIndex===-1 || this.curSeleEleIndex === this.selectEleFormula.length - 1){ /* 没选择值或者选择最后一个的时候直接添加符号 */
  858. this.eleAddFormulaHandle(this.formulaMap[operator]);
  859. }else{ /* 选择中间的值,如果下一个是符号这替换,反之则在指定的位置添加 */
  860. this.randomaddOperator(this.formulaMap[operator])
  861. }
  862. }
  863. this.itemList=[];
  864. },
  865. canceloperationVisible(){
  866. this.operationVisible=false;
  867. this.allTreeShow=false;
  868. this.filterText=''
  869. this.treeId=''
  870. this.itemList=[];
  871. this.eleList.forEach((ele)=>{
  872. this.$set(ele,'checked',false);
  873. //ele.checked = false;
  874. })
  875. console.log('取消');
  876. },
  877. //把元素加到公式里
  878. eleAddFormulaHandle(ele){
  879. if(ele.tableElementKey){
  880. console.log(ele,'ele');
  881. //元素
  882. if(this.deleEleIndex > -1 && this.selectEleFormula.length-1 >= this.deleEleIndex){
  883. //删除元素的位置,如果下次添加元素,先加到这个位置
  884. this.selectEleFormula.splice(this.deleEleIndex,0,{
  885. type:'Element',
  886. name:ele.eName,
  887. id:ele.id,
  888. selected:false,
  889. tableElementKey:ele.tableElementKey,
  890. children:[],
  891. })
  892. this.deleEleIndex = -1;
  893. }else{
  894. this.selectEleFormula.push({
  895. type:'Element',
  896. name:ele.eName,
  897. id:ele.id,
  898. selected:false,
  899. tableElementKey:ele.tableElementKey,
  900. children:[],
  901. })
  902. this.deleEleIndex = -1;
  903. }
  904. }else if(ele.template && ele.example){
  905. //简单语法判断
  906. if(this.selectEleFormula.length == 0){
  907. this.$message({
  908. type: "warning",
  909. message: "公式开头不能是运算符号"
  910. });
  911. return;
  912. }else{
  913. let lastEle = this.selectEleFormula[this.selectEleFormula.length-1];
  914. if(lastEle.type == 'Operator'){
  915. this.$message({
  916. type: "warning",
  917. message: "运算符号无法连续出现在运算符号后面"
  918. });
  919. return;
  920. }
  921. if(lastEle.type == 'Brackets' && lastEle.name == '('){
  922. this.$message({
  923. type: "warning",
  924. message: "运算符号无法连续出现在左括号后面"
  925. });
  926. return;
  927. }
  928. }
  929. //运算符号
  930. this.selectEleFormula.push({
  931. type:'Operator',
  932. name:this.symbolReg.exec(ele.name)[1],
  933. selected:false,
  934. template:ele.template
  935. })
  936. }else if(ele.type == 'Brackets'){
  937. //括号
  938. this.selectEleFormula.splice(ele.selectIndex,0,{
  939. type:'Brackets',
  940. name:ele.name,
  941. selected:false,
  942. })
  943. }else if(ele.type == 'Text'){
  944. //输入值
  945. this.selectEleFormula.push({
  946. type:'Text',
  947. name:ele.name,
  948. selected:false,
  949. })
  950. }else if(ele.k){
  951. //节点参数
  952. this.selectEleFormula.push({
  953. type:'ParamData',
  954. name:ele.name,
  955. selected:false,
  956. id:ele.id,
  957. v:ele.v,
  958. k:ele.k,
  959. children:[],
  960. })
  961. }
  962. },
  963. //添加括号
  964. addBrackets(text,type){
  965. //type 是true 表示在元素右边插入
  966. if(this.curSeleEleIndex == Number(this.curSeleEleIndex)){
  967. this.eleAddFormulaHandle({
  968. type:'Brackets',
  969. name:text,
  970. selectIndex:type?Number(this.curSeleEleIndex)+1:this.curSeleEleIndex
  971. })
  972. //如果在左边插入index要增1
  973. if(!type){
  974. this.curSeleEleIndex = Number(this.curSeleEleIndex)+1;
  975. }
  976. }
  977. },
  978. addText(){
  979. this.inputVisible = true;
  980. },
  981. //添加输入值
  982. addTextHandle(){
  983. //简单语法判断
  984. if(this.selectEleFormula.length != 0){
  985. let lastEle = this.selectEleFormula[this.selectEleFormula.length-1];
  986. if(lastEle.type == 'Element'){
  987. this.$message({
  988. type: "warning",
  989. message: "输入值无法连续出现在元素后面"
  990. });
  991. return;
  992. }
  993. if(lastEle.type == 'Text'){
  994. this.$message({
  995. type: "warning",
  996. message: "输入值无法连续出现在输入值后面"
  997. });
  998. return;
  999. }
  1000. if(lastEle.type == 'Brackets' && lastEle.name == ')'){
  1001. this.$message({
  1002. type: "warning",
  1003. message: "输入值无法连续出现在右括号后面"
  1004. });
  1005. return;
  1006. }
  1007. }
  1008. this.eleAddFormulaHandle({
  1009. type:'Text',
  1010. name:this.inputText
  1011. })
  1012. this.inputVisible = false;
  1013. },
  1014. //勾选元素
  1015. // eleCheckHandle(checked,item){
  1016. // if(checked){
  1017. // this.eleList.forEach((ele)=>{
  1018. // this.$set(ele,'checked',false);
  1019. // //ele.checked = false;
  1020. // })
  1021. // item.checked = true;
  1022. // }
  1023. // },
  1024. //勾选元素多选
  1025. eleCheckHandle(checked,item){
  1026. if(checked){
  1027. this.eleChecks.push(item);
  1028. }else{
  1029. for (let i = 0; i < this.eleChecks.length; i++) {
  1030. if(this.eleChecks[i].id == item.id){
  1031. this.eleChecks.splice(i,1);
  1032. break;
  1033. }
  1034. }
  1035. }
  1036. },
  1037. //点选公式中的元素
  1038. eleFormulaClick({selected,item},index){
  1039. if(selected){
  1040. this.selectEleFormula.forEach((ele)=>{
  1041. ele.selected = false;
  1042. })
  1043. item.selected = true;
  1044. this.curSeleEleIndex = index;
  1045. }else{
  1046. this.curSeleEleIndex = -1;
  1047. }
  1048. },
  1049. //取消勾选
  1050. unCheckEleFormulac(eleId){
  1051. for (let i = 0; i < this.eleList.length; i++) {
  1052. if(this.eleList[i].id == eleId){
  1053. this.eleList[i].checked = false;
  1054. }
  1055. }
  1056. },
  1057. //删除点选公式中的元素
  1058. removeSelect(){
  1059. if(this.curSeleEleIndex > -1 && this.curSeleEleIndex <= this.selectEleFormula.length-1){
  1060. if(this.selectEleFormula[this.curSeleEleIndex].type == 'Element'){
  1061. //删除元素的位置,如果下次添加元素,先加到这个位置
  1062. this.deleEleIndex = this.curSeleEleIndex;
  1063. this.unCheckEleFormulac(this.selectEleFormula[this.curSeleEleIndex].id)
  1064. }
  1065. this.selectEleFormula.splice(this.curSeleEleIndex,1);
  1066. //this.curSeleEleIndex = -1;
  1067. }
  1068. },
  1069. //赋值给等号右边的数组
  1070. operationHandle(){
  1071. //检测左右括号数量是否相等
  1072. let lBracketNum = 0;
  1073. let rBracketNum = 0;
  1074. this.selectEleFormula.forEach((ele)=>{
  1075. if(ele.type == 'Brackets'){
  1076. if(ele.name == '('){
  1077. lBracketNum++;
  1078. }else if(ele.name == ')'){
  1079. rBracketNum++;
  1080. }
  1081. }
  1082. })
  1083. if(lBracketNum != rBracketNum){
  1084. this.$message({
  1085. type: "warning",
  1086. message: "左右括号数量不相等,请先检查是否正确"
  1087. });
  1088. return;
  1089. }
  1090. this.processFormula = JSON.parse(JSON.stringify(this.selectEleFormula));
  1091. this.operationVisible = false;
  1092. },
  1093. //点选等式中的元素
  1094. equationClick({selected,item},index,arrName){
  1095. this.checkGsId=item.id
  1096. if(selected){
  1097. this.resultFormula.forEach((ele)=>{
  1098. ele.selected = false;
  1099. })
  1100. this.processFormula.forEach((ele)=>{
  1101. ele.selected = false;
  1102. })
  1103. this.processSelectIndex = index;
  1104. this.processType = arrName;
  1105. item.selected = true;
  1106. if(this.showFunDetail){
  1107. //切到第一个
  1108. this.actiFunIndex = '0';
  1109. }
  1110. }else{
  1111. this.processType = '';
  1112. }
  1113. },
  1114. //获取当前元素的表名
  1115. getItemTableName(item){
  1116. if(item.type==="Element"){
  1117. this.rightDict.forEach((ele)=>{
  1118. if(ele.ekey===item.tableElementKey){
  1119. item.tableName= ele.tableName
  1120. }
  1121. })
  1122. }
  1123. },
  1124. //在等式模式下点选计算式
  1125. equationSelect(index,indexPath){
  1126. if(!this.equationSelectEle ||(this.equationSelectEle && !(this.equationSelectEle.type == 'Element' || this.equationSelectEle.type == 'ParamData')) ){
  1127. this.$message({
  1128. type: "warning",
  1129. message: "请先选中元素"
  1130. });
  1131. return;
  1132. }
  1133. let formulaindex = Number(indexPath[1].split('-')[1])-1;
  1134. let expression = this.formulaList[indexPath[0]][formulaindex];
  1135. if(expression.type ==1){
  1136. return;
  1137. }
  1138. //console.log(JSON.parse(expression.template));
  1139. let obj = Object.assign({}, expression);
  1140. //obj.template = JSON.parse(obj.template);
  1141. obj.arguments = new Array(obj.template.args.length);
  1142. let ele = {};
  1143. if(this.equationSelectEle.type == 'ParamData'){
  1144. ele = {
  1145. type:'ParamData',
  1146. name:this.equationSelectEle.name,
  1147. id:this.equationSelectEle.id,
  1148. selected:false,
  1149. v:this.equationSelectEle.v,
  1150. k:this.equationSelectEle.k,
  1151. }
  1152. }else{
  1153. ele = {
  1154. id:this.equationSelectEle.id,
  1155. name:this.equationSelectEle.name,
  1156. selected:false,
  1157. tableElementKey:this.equationSelectEle.tableElementKey,
  1158. type:"Element",
  1159. };
  1160. }
  1161. obj.arguments[0] = ele;
  1162. this.equationSelectEle.children.push(obj);
  1163. //跳转到最新的标签
  1164. this.actiFunIndex = (this.equationSelectEle.children.length-1).toString();
  1165. },
  1166. //选择元素
  1167. // chooseEleHandle(){
  1168. // for (let i = 0; i < this.eleList.length; i++) {
  1169. // if (this.eleList[i].checked) {
  1170. // let ele = this.eleList[i];
  1171. // let obj = {};
  1172. // if(ele.k){
  1173. // obj = {
  1174. // type:'ParamData',
  1175. // name:ele.name,
  1176. // id:ele.id,
  1177. // selected:false,
  1178. // v:ele.v,
  1179. // k:ele.k,
  1180. // children:[],
  1181. // }
  1182. // }else{
  1183. // obj = {
  1184. // type:'Element',
  1185. // name:ele.eName,
  1186. // id:ele.id,
  1187. // selected:false,
  1188. // tableElementKey:ele.tableElementKey,
  1189. // children:[],
  1190. // }
  1191. // }
  1192. // this.$set(this.argumenObj.arguments,this.argumenObj.index,obj);
  1193. // this.chooseEleVisible = false;
  1194. // break;
  1195. // }
  1196. // }
  1197. // },
  1198. //选择元素多选
  1199. chooseEleHandle(){
  1200. this.eleChecks.forEach((element,index) => {
  1201. this.setEleToArgumen(element,index+this.argumenObj.index);
  1202. });
  1203. this.chooseEleVisible = false;
  1204. this.clearEleListCheck();
  1205. },
  1206. //设置元素到指定位置参数
  1207. setEleToArgumen(ele,index){
  1208. let obj = {};
  1209. if(ele.k){
  1210. obj = {
  1211. type:'ParamData',
  1212. name:ele.name,
  1213. id:ele.id,
  1214. selected:false,
  1215. v:ele.v,
  1216. k:ele.k,
  1217. children:[],
  1218. }
  1219. }else{
  1220. obj = {
  1221. type:'Element',
  1222. name:ele.eName,
  1223. id:ele.id,
  1224. selected:false,
  1225. tableElementKey:ele.tableElementKey,
  1226. children:[],
  1227. }
  1228. }
  1229. if(index < this.argumenObj.arguments.length){
  1230. this.$set(this.argumenObj.arguments,index,obj);
  1231. }
  1232. },
  1233. //清理元素列表的勾选
  1234. clearEleListCheck(){
  1235. this.eleChecks = [];
  1236. this.eleList.forEach((item)=>{
  1237. item.checked = false;
  1238. })
  1239. },
  1240. //显示选择元素弹窗
  1241. showChooseEle(argumenObj){
  1242. this.argumenObj = argumenObj;
  1243. this.chooseEleVisible = true;
  1244. },
  1245. //移除挂载的函数
  1246. removeFun(name){
  1247. //console.log(name)
  1248. this.equationSelectEle.children.splice(Number(name), 1);
  1249. },
  1250. //切换公式tab标签
  1251. funLeave(activeName, oldActiveName){
  1252. if(oldActiveName){
  1253. let formula = this.equationSelectEle.children[Number(oldActiveName)];
  1254. if(formula){
  1255. return this.checkFormulaLegal(formula);
  1256. }
  1257. }
  1258. },
  1259. //检测公式合法
  1260. checkFormulaLegal(formula){
  1261. if(!formula.arguments){
  1262. return false;
  1263. }
  1264. //当前选中的元素
  1265. let curEle = this.equationSelectEle;
  1266. let isIn = false;
  1267. for (let i = 0; i < formula.arguments.length; i++) {
  1268. if(Array.isArray(formula.arguments[i])){
  1269. for(let j=0;j<formula.arguments[i].length;j++){
  1270. if(formula.arguments[i][j] && formula.arguments[i][j].id ==curEle.id){
  1271. isIn = true;
  1272. break;
  1273. }
  1274. }
  1275. if(isIn){
  1276. break;
  1277. }
  1278. }else if(formula.arguments[i] && formula.arguments[i].id ==curEle.id){
  1279. isIn = true;
  1280. break;
  1281. }
  1282. }
  1283. if(!isIn){
  1284. this.$message({
  1285. type: "warning",
  1286. message: "参数必须有一个值是当前元素"
  1287. });
  1288. return false;
  1289. }
  1290. return true;
  1291. },
  1292. //保存公式
  1293. saveFormula(){
  1294. console.log('保存',this.pid);
  1295. console.log(this.processFormula,'this.processFormula1111111112333');
  1296. console.log(this.resultFormula,'this.resultFormula1111111112333');
  1297. console.log(this.$refs.dynamiccomponent,'this.$refs.dynamiccomponent');
  1298. if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].symbol=='more'){
  1299. //多条件保存公式
  1300. console.log('this.$refs.conditionList[0]',this.$refs.dynamiccomponent[0].conditionList);
  1301. let resMore=formatArrayMore(this.$refs.dynamiccomponent[0].conditionList);
  1302. const resJson=generateResult(this.$refs.dynamiccomponent[0].conditionList);
  1303. let remark=this.$refs.dynamiccomponent[0].result;
  1304. console.log(remark,'remark');
  1305. console.log(resJson,'resJson');
  1306. if(this.formulaid){
  1307. updateFormula({
  1308. id:this.formulaid,
  1309. formula:'',
  1310. formulas:resMore,
  1311. remark:remark,
  1312. nodeId:this.nodeid,
  1313. elementId:this.eleid,
  1314. scale:this.isRetain?this.retainNum:'',
  1315. number:number,
  1316. map:JSON.stringify(resJson),
  1317. scope:this.globaltype,
  1318. // projectId:this.curProjiect.id||this.projectId,
  1319. projectId:this.curProjiect.id||this.pid,
  1320. dev:deviationRangeText
  1321. }).then(()=>{
  1322. this.formulaStringToArray();
  1323. this.$message({
  1324. type: "success",
  1325. message: "修改成功"
  1326. });
  1327. })
  1328. }else{
  1329. saveFormula({
  1330. formula:'',
  1331. formulas:resMore,
  1332. remark:remark,
  1333. nodeId:this.nodeid,
  1334. elementId:this.eleid,
  1335. scale:this.isRetain?this.retainNum:'',
  1336. number:number,
  1337. map:JSON.stringify(resJson),
  1338. scope:this.globaltype,
  1339. dev:deviationRangeText,
  1340. // projectId:this.curProjiect.id||this.projectId,
  1341. projectId:this.curProjiect.id||this.pid,
  1342. ver:this.version
  1343. }).then((res)=>{
  1344. if(res.data.data){
  1345. this.formulaid = res.data.data;
  1346. }
  1347. this.formulaStringToArray();
  1348. this.$message({
  1349. type: "success",
  1350. message: "保存成功"
  1351. });
  1352. })
  1353. }
  1354. return;
  1355. }else if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].symbol=='getData'){
  1356. //数据获取保存公式
  1357. const dataRes = this.$refs.dynamiccomponent[0].getDataConditionData();
  1358. console.log(dataRes,'dataRes');
  1359. const result =dataRes.result;
  1360. const mapEle = JSON.stringify(dataRes.mapEle);
  1361. console.log(mapEle,'mapEle');
  1362. if(this.formulaid){
  1363. updateFormula({
  1364. id:this.formulaid,
  1365. formula:"FC.switchCase"+'('+result+')',
  1366. remark:'',
  1367. nodeId:this.nodeid,
  1368. elementId:this.eleid,
  1369. scale:this.isRetain?this.retainNum:'',
  1370. number:number,
  1371. map:mapEle,
  1372. scope:this.globaltype,
  1373. // projectId:this.curProjiect.id||this.projectId,
  1374. projectId:this.curProjiect.id||this.pid,
  1375. dev:deviationRangeText
  1376. }).then(()=>{
  1377. this.formulaStringToArray();
  1378. this.$message({
  1379. type: "success",
  1380. message: "修改成功"
  1381. });
  1382. })
  1383. }else{
  1384. saveFormula({
  1385. formula:"FC.switchCase" +'('+result+')',
  1386. remark:'',
  1387. nodeId:this.nodeid,
  1388. elementId:this.eleid,
  1389. scale:this.isRetain?this.retainNum:'',
  1390. number:number,
  1391. map:mapEle,
  1392. scope:this.globaltype,
  1393. dev:deviationRangeText,
  1394. // projectId:this.curProjiect.id||this.projectId,
  1395. projectId:this.curProjiect.id||this.pid,
  1396. ver:this.version
  1397. }).then((res)=>{
  1398. if(res.data.data){
  1399. this.formulaid = res.data.data;
  1400. }
  1401. this.formulaStringToArray();
  1402. this.$message({
  1403. type: "success",
  1404. message: "保存成功"
  1405. });
  1406. })
  1407. }
  1408. return;
  1409. }else if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].formData){
  1410. console.log(this.$refs.dynamiccomponent[0],'this.$refs.dynamiccomponent[0');
  1411. const resForm=this.$refs.dynamiccomponent[0].getDataChangeList();
  1412. console.log(resForm,'resForm');
  1413. //数据自变保存
  1414. if(this.formulaid){
  1415. updateFormula({
  1416. id:this.formulaid,
  1417. formula:resForm.test,
  1418. remark:'',
  1419. nodeId:this.nodeid,
  1420. elementId:this.eleid,
  1421. scale:this.isRetain?this.retainNum:'',
  1422. number:number,
  1423. map:JSON.stringify(resForm.map),
  1424. scope:this.globaltype,
  1425. // projectId:this.curProjiect.id||this.projectId,
  1426. projectId:this.curProjiect.id||this.pid,
  1427. dev:deviationRangeText
  1428. }).then(()=>{
  1429. this.formulaStringToArray();
  1430. this.$message({
  1431. type: "success",
  1432. message: "修改成功"
  1433. });
  1434. })
  1435. }else{
  1436. saveFormula({
  1437. formula:resForm.test,
  1438. remark:'',
  1439. nodeId:this.nodeid,
  1440. elementId:this.eleid,
  1441. scale:this.isRetain?this.retainNum:'',
  1442. number:number,
  1443. map:JSON.stringify(resForm.map),
  1444. scope:this.globaltype,
  1445. dev:deviationRangeText,
  1446. // projectId:this.curProjiect.id||this.projectId,
  1447. projectId:this.curProjiect.id||this.pid,
  1448. ver:this.version
  1449. }).then((res)=>{
  1450. if(res.data.data){
  1451. this.formulaid = res.data.data;
  1452. }
  1453. this.formulaStringToArray();
  1454. this.$message({
  1455. type: "success",
  1456. message: "保存成功"
  1457. });
  1458. })
  1459. }
  1460. return
  1461. }
  1462. let arr=JSON.parse(JSON.stringify(this.processFormula));
  1463. let filteredArr = arr.filter(item => item.id ===this.checkGsId);
  1464. let obj
  1465. let obj2
  1466. obj = formulaArrayToString(this.processFormula,this.resultFormula);
  1467. obj2 = formulaArrayToString(filteredArr,this.resultFormula);
  1468. console.log(obj,'obj');
  1469. console.log(obj2,'obj2');
  1470. // 判断 obj2.text 是否包含 FC.ifelse
  1471. if (obj2.text && (obj2.text.includes('FC.ifelse'))|| obj2.text.includes("''")) {
  1472. obj = obj2; // 如果包含 FC.ifelse,使用 obj2
  1473. }
  1474. console.log(obj.text,'最终的公式');
  1475. let deviationRangeText = rangeToString(this.deviationRange.datas,obj.eleMap);
  1476. obj.eleMap.deviationRangeJson = JSON.stringify(this.deviationRange.datas);
  1477. //console.log(obj.eleMap)
  1478. //return;
  1479. //特殊公式会有number
  1480. let number = '';
  1481. for (let i = 0; i < this.processFormula.length; i++) {
  1482. if(this.processFormula[i].children){
  1483. for (let j = 0; j < this.processFormula[i].children.length; j++) {
  1484. if(this.processFormula[i].children[j].number){
  1485. number = this.processFormula[i].children[j].number;
  1486. break;
  1487. }
  1488. }
  1489. }
  1490. if(number){
  1491. break;
  1492. }
  1493. }
  1494. if(number === ''){
  1495. for (let i = 0; i < this.resultFormula.length; i++) {
  1496. if(this.resultFormula[i].children){
  1497. for (let j = 0; j < this.resultFormula[i].children.length; j++) {
  1498. if(this.resultFormula[i].children[j].number){
  1499. number = this.resultFormula[i].children[j].number;
  1500. break;
  1501. }
  1502. }
  1503. }
  1504. if(number){
  1505. break;
  1506. }
  1507. }
  1508. }
  1509. //console.log(text);
  1510. if(this.formulaid){
  1511. updateFormula({
  1512. id:this.formulaid,
  1513. formula:obj.text,
  1514. remark:'',
  1515. nodeId:this.nodeid,
  1516. elementId:this.eleid,
  1517. scale:this.isRetain?this.retainNum:'',
  1518. number:number,
  1519. map:JSON.stringify(obj.eleMap),
  1520. scope:this.globaltype,
  1521. // projectId:this.curProjiect.id||this.projectId,
  1522. projectId:this.curProjiect.id||this.pid,
  1523. dev:deviationRangeText
  1524. }).then(()=>{
  1525. this.formulaStringToArray();
  1526. this.$message({
  1527. type: "success",
  1528. message: "修改成功"
  1529. });
  1530. })
  1531. }else{
  1532. saveFormula({
  1533. formula:obj.text,
  1534. remark:'',
  1535. nodeId:this.nodeid,
  1536. elementId:this.eleid,
  1537. scale:this.isRetain?this.retainNum:'',
  1538. number:number,
  1539. map:JSON.stringify(obj.eleMap),
  1540. scope:this.globaltype,
  1541. dev:deviationRangeText,
  1542. // projectId:this.curProjiect.id||this.projectId,
  1543. projectId:this.curProjiect.id||this.pid,
  1544. ver:this.version
  1545. }).then((res)=>{
  1546. if(res.data.data){
  1547. this.formulaid = res.data.data;
  1548. }
  1549. this.formulaStringToArray();
  1550. this.$message({
  1551. type: "success",
  1552. message: "保存成功"
  1553. });
  1554. })
  1555. }
  1556. },
  1557. //把公式文本还原数组
  1558. async formulaStringToArray(){
  1559. let detail = (await formulaDetail({elementId:this.eleid,scope:this.globaltype,nodeId:this.nodeid,projectId:this.curProjiect.id||this.pid})).data.data;
  1560. console.log(detail,'detail');
  1561. this.remark = detail.remark;
  1562. if(detail&&detail.formula.includes('FC.ifelseMulti')){
  1563. detail.formula = detail.formula.replace('FC.ifelseMulti','FC.ifelse');
  1564. this.isMore = true;
  1565. this.formulaDetailMap = detail.map;
  1566. this.moreConditions = restoreArrayMore(detail.formulas,this.formulaDetailMap,detail.remark||'1')
  1567. }else if(detail&&detail.formula.includes('FC.switchCase')){
  1568. //数据获取
  1569. this.formulaDetailMap = detail.map;
  1570. detail.formula = detail.formula.replace('FC.switchCase','FC.ifelse');
  1571. this.isGetData = true;
  1572. this.dataListGet=detail.formula
  1573. console.log( this.dataListGet,' this.dataListGet');
  1574. }else if(detail&&detail.formula.includes('FC.dataChange')){
  1575. //数据自变
  1576. this.formulaDetailMap = detail.map;
  1577. this.isDataChange = true;
  1578. this.dataForm=detail.formula
  1579. console.log( this.dataForm,' this.dataListGet');
  1580. }
  1581. else{
  1582. this.isMore = false;
  1583. this.moreConditions = []
  1584. this.formulaDetailMap ={}
  1585. this.isGetData = false;
  1586. this.dataListGet=''
  1587. this.isDataChange = false;
  1588. this.dataForm='';
  1589. }
  1590. if(detail&&detail.id){
  1591. //获取右边元素的字典
  1592. let dictMap=detail.dict
  1593. let dictArr=[]
  1594. //遍历:
  1595. for(let i in dictMap){
  1596. dictArr.push(dictMap[i])
  1597. }
  1598. this.rightDict=dictArr
  1599. console.log( this.rightDict,' this.rightDict');
  1600. this.formulaid = detail.id;
  1601. //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);
  1602. let formula = formulaStringToArray(detail.formula,detail.map,this.formulaMap);
  1603. console.log(formula,'formula');
  1604. this.processFormula = formula.processFormula;
  1605. formula.resultFormula[0].id = this.resultFormula[0].id;
  1606. formula.resultFormula[0].name = this.resultFormula[0].name;
  1607. formula.resultFormula[0].tableElementKey = this.resultFormula[0].tableElementKey;
  1608. this.resultFormula[0].children = formula.resultFormula[0].children;
  1609. //允许偏差值范围
  1610. let mapObj = JSON.parse(detail.map);
  1611. if(mapObj.deviationRangeJson){
  1612. this.deviationRange.datas = JSON.parse(mapObj.deviationRangeJson);
  1613. }
  1614. }
  1615. if (detail&&detail.scale!=null&&detail.scale>=0){
  1616. this.isRetain = true;
  1617. this.retainNum = detail.scale;
  1618. }else{
  1619. this.isRetain = false;
  1620. this.retainNum=2
  1621. }
  1622. },
  1623. //设置动态组件里面的元素
  1624. setComponentEle(value,item,index){
  1625. if(value){
  1626. //console.log(this.$refs.dynamiccomponent[index])
  1627. this.$refs.dynamiccomponent[index].setELe(item);
  1628. }
  1629. },
  1630. //设置动态组件里面的元素
  1631. setDeviationRangeEle(value,item){
  1632. if(value){
  1633. //console.log(this.$refs.dynamiccomponent[index])
  1634. this.$refs.deviationrange.setELe(item);
  1635. }
  1636. },
  1637. getNodeDetail(data) {
  1638. if(this.pid){
  1639. this.eleListable=true;
  1640. console.log(data.id,'data.id');
  1641. wbsPrivateGetNodeTabAndParam(data.id, this.pid, this.wbsid).then((res) => {
  1642. if(res.data.data.tabData.length){
  1643. this.eleTableList = res.data.data.tabData;
  1644. this.eleListable=false;
  1645. // 获取点击节点的第一张表
  1646. console.log(this.eleTableList[0],'this.eleTableList[0]');
  1647. // let tabId= this.eleTableList[0].initTableId; pkeyId
  1648. let tabId= this.eleTableList[0].pkeyId!==-1&&this.eleTableList[0].pkeyId!==null?this.eleTableList[0].pkeyId:this.eleTableList[0].id;
  1649. console.log("wbsPrivateGetNodeTabAndParam")
  1650. this.getTableEle(tabId);
  1651. setTimeout(() => {
  1652. // 启动这个指令的DOM结构点击事件
  1653. this.eleTableId = tabId;
  1654. },1000); // 默认1秒
  1655. }else{
  1656. this.eleTableList = [];
  1657. this.eleTableId = '';
  1658. this.eleList = [];
  1659. }
  1660. if(res.data.data.paramData.length){
  1661. this.paramDataList = res.data.data.paramData;
  1662. }else{
  1663. this.paramDataList = [];
  1664. }
  1665. })
  1666. }else{
  1667. this.eleListable=true;
  1668. getNodeTabAndParam(data.id).then((res)=>{
  1669. if(res.data.data.tabData.length){
  1670. this.eleTableList = res.data.data.tabData;
  1671. this.eleListable=false;
  1672. // let tabId= this.eleTableList[0].initTableId;
  1673. let tabId= this.eleTableList[0].pkeyId!==-1&&this.eleTableList[0].pkeyId!==null?this.eleTableList[0].pkeyId:this.eleTableList[0].id;
  1674. console.log(this.eleTableList[0],'this.eleTableList[0]');
  1675. console.log("getNodeTabAndParam",tabId);
  1676. this.getTableEle(tabId);
  1677. setTimeout(() => {
  1678. // 启动这个指令的DOM结构点击事件
  1679. this.eleTableId = tabId;
  1680. },1000); // 默认1秒
  1681. }else{
  1682. this.eleTableList = [];
  1683. this.eleTableId = '';
  1684. this.eleList = [];
  1685. this.eleListable=false;
  1686. }
  1687. if(res.data.data.paramData.length){
  1688. this.paramDataList = res.data.data.paramData;
  1689. }else{
  1690. this.paramDataList = [];
  1691. }
  1692. })
  1693. }
  1694. },
  1695. getEleDeatil(){
  1696. getEleDeatil(this.eleid).then((res)=>{
  1697. let ele = res.data.data;
  1698. this.resultFormula = [{
  1699. type:'Element',
  1700. name:ele.eName,
  1701. id:ele.id,
  1702. selected:false,
  1703. tableElementKey:ele.tableElementKey,
  1704. children:[],
  1705. }]
  1706. })
  1707. },
  1708. getTableEle(tableId){
  1709. console.log("getTableEle",tableId);
  1710. this.input3=''
  1711. if(tableId === '选择节点参数'){
  1712. this.eleList = this.paramDataList;
  1713. this.eleList1 = this.paramDataList;
  1714. }else{
  1715. selectFormElements(tableId,{nodeId:this.nodeid,type:this.iswbstype}).then((res)=>{
  1716. this.eleList = res.data.data;
  1717. this.eleList1 = res.data.data;
  1718. })
  1719. }
  1720. },
  1721. getInput(tableId){
  1722. if(tableId.length>0){
  1723. let arr=[]
  1724. arr=this.eleList1.filter((item)=>{
  1725. if(item.eName===tableId){
  1726. return item
  1727. }
  1728. })
  1729. this.eleList=arr;
  1730. }else{
  1731. this.eleList=this.eleList1
  1732. }
  1733. },
  1734. getInput1(tableId){
  1735. if(tableId.length>0){
  1736. let arr=[]
  1737. arr=this.eleListComp1.filter((item)=>{
  1738. if(item.eName===tableId){
  1739. return item
  1740. }
  1741. })
  1742. this.eleListComp=arr;
  1743. }else{
  1744. this.eleListComp=this.eleListComp1;
  1745. }
  1746. },
  1747. //方法下面的点击树节点
  1748. getNodeDetailComp(data) {
  1749. console.log(data.id,'data.id111111111');
  1750. if(this.pid){
  1751. wbsPrivateGetNodeTabAndParam(data.id, this.pid, this.wbsid).then((res) => {
  1752. if(res.data.data.tabData.length){
  1753. this.eleTableListComp = res.data.data.tabData;
  1754. // this.eleTableIdComp = this.eleTableListComp[0].initTableId;
  1755. this.eleTableIdComp = this.eleTableListComp[0].pkeyId;
  1756. this.getTableEleComp(this.eleTableIdComp);
  1757. }else{
  1758. this.eleTableListComp = [];
  1759. this.eleTableIdComp = '';
  1760. this.eleListComp = [];
  1761. }
  1762. if(res.data.data.paramData.length){
  1763. this.paramDataList = res.data.data.paramData;
  1764. }else{
  1765. this.paramDataList = [];
  1766. }
  1767. })
  1768. }else{
  1769. getNodeTabAndParam(data.id).then((res)=>{
  1770. if(res.data.data.tabData.length){
  1771. this.eleTableListComp = res.data.data.tabData;
  1772. this.eleTableIdComp = this.eleTableListComp[0].initTableId;
  1773. let tabId= this.eleTableList[0].pkeyId!==-1&&this.eleTableList[0].pkeyId!==null?this.eleTableList[0].pkeyId:this.eleTableList[0].id;
  1774. this.getTableEleComp(tabId);
  1775. }else{
  1776. this.eleTableListComp = [];
  1777. this.eleTableIdComp = '';
  1778. this.eleListComp = [];
  1779. }
  1780. if(res.data.data.paramData.length){
  1781. this.paramDataList = res.data.data.paramData;
  1782. }else{
  1783. this.paramDataList = [];
  1784. }
  1785. })
  1786. }
  1787. },
  1788. //方法下面的查询元素
  1789. getTableEleComp(tableId){
  1790. this.input3=''
  1791. console.log(this.iswbstype,'this.iswbstype');
  1792. if(tableId === '选择节点参数'){
  1793. this.eleListComp = this.paramDataList;
  1794. this.eleListComp1 = this.paramDataList;
  1795. }else{
  1796. selectFormElements(tableId,{nodeId:this.nodeid,type:this.iswbstype}).then((res)=>{
  1797. this.eleListComp = res.data.data;
  1798. this.eleListComp1 = res.data.data;
  1799. })
  1800. }
  1801. },
  1802. //取消方法下面 元素勾选
  1803. unCheckEleComp(eleId){
  1804. //console.log(eleId)
  1805. for (let i = 0; i < this.eleListComp.length; i++) {
  1806. if(this.eleListComp[i].id == eleId){
  1807. this.eleListComp[i].checked = false;
  1808. }
  1809. }
  1810. },
  1811. //手写模式
  1812. handwrit(){
  1813. try {
  1814. let obj = formulaArrayToString(this.processFormula,this.resultFormula);
  1815. this.handwritText = obj.text;
  1816. this.handwritEleMap = JSON.stringify(obj.eleMap);
  1817. this.handwritVisible = true;
  1818. } catch (error) {
  1819. console.error(error)
  1820. this.$message({
  1821. type: "error",
  1822. message: "生成公式文本失败,"+error
  1823. });
  1824. }
  1825. },
  1826. //转成配置用的数组
  1827. handwritTransform(){
  1828. try {
  1829. let formula = formulaStringToArray(this.handwritText,this.handwritEleMap,this.formulaMap);
  1830. this.processFormula = formula.processFormula;
  1831. formula.resultFormula[0].id = this.resultFormula[0].id;
  1832. formula.resultFormula[0].name = this.resultFormula[0].name;
  1833. formula.resultFormula[0].tableElementKey = this.resultFormula[0].tableElementKey;
  1834. this.resultFormula[0].children = formula.resultFormula[0].children;
  1835. this.handwritVisible = false;
  1836. } catch (error) {
  1837. console.error(error)
  1838. this.$message({
  1839. type: "error",
  1840. message: "转成配置用的数组失败,"+error
  1841. });
  1842. }
  1843. },
  1844. editorInit: function (editor) {
  1845. console.log('editorInit')
  1846. require('brace/ext/searchbox') //添加搜索功能
  1847. require('brace/ext/language_tools') //language extension prerequsite...
  1848. require('brace/mode/javascript') //language
  1849. require('brace/theme/github')
  1850. require('brace/snippets/javascript') //snippet
  1851. editor.session.setUseWrapMode(true);//切换自动换行
  1852. editor.setHighlightActiveLine(false);//设置行高亮显示
  1853. editor.setShowPrintMargin(false);
  1854. editor.setOptions({
  1855. enableLiveAutocompletion:true,//语法提示和补全
  1856. showInvisibles:true,//显示隐藏,空格,回车等
  1857. fontSize:'16px'
  1858. })
  1859. },
  1860. getTypeMap(){
  1861. return new Promise((resolve)=>{
  1862. getTypeMap().then((res)=>{
  1863. //console.log(res)
  1864. this.formulaList = res.data.data;
  1865. //生成map,方便查找
  1866. for (let key in this.formulaList) {
  1867. if(typeof(this.formulaList[key]) == 'object'){
  1868. this.formulaList[key].forEach((formula)=>{
  1869. formula.template = JSON.parse(formula.template);
  1870. if(this.operatorReg.test(formula.template.ft)){
  1871. this.formulaMap[formula.template.ft] = formula;
  1872. }else if(this.startFCRegExp.test(formula.template.ft)){
  1873. let regRes = formula.template.ft.match(this.startFCRegExp);
  1874. this.formulaMap[regRes[0]] = formula;
  1875. }
  1876. })
  1877. }
  1878. }
  1879. }).finally(() => {
  1880. resolve();
  1881. })
  1882. })
  1883. }
  1884. },
  1885. };
  1886. </script>
  1887. <style scoped lang="scss">
  1888. .box-dashed {
  1889. border: 1px dashed #bbbbbb;
  1890. border-radius: 6px;
  1891. padding: 10px;
  1892. margin-bottom: 10px;
  1893. }
  1894. .retain-box {
  1895. border-right: 1px dashed #bbbbbb;
  1896. }
  1897. .retain {
  1898. line-height: 50px;
  1899. margin-right: 10px;
  1900. }
  1901. .edit-text {
  1902. font-size: 26px;
  1903. margin-left: 20px;
  1904. }
  1905. .el-menu--popup .el-menu-item.is-active {
  1906. background-color: #fff;
  1907. }
  1908. .ele-box{
  1909. //border: 1px solid #bbb;
  1910. //height: 26px;
  1911. display: flex;
  1912. justify-content: space-between;
  1913. align-items: center;
  1914. padding: 6px;
  1915. height: 100%;
  1916. box-sizing: border-box;
  1917. overflow: hidden;
  1918. }
  1919. .no-mb-col .el-col{
  1920. margin-bottom: 0px;
  1921. border: 1px solid #bbb;
  1922. height: 100px;
  1923. }
  1924. .sele-ele-box{
  1925. height: 160px;
  1926. padding: 20px;
  1927. // margin-top: 10px;
  1928. }
  1929. .icon-box .el-link{
  1930. font-size: 14px;
  1931. margin-right: 10px;
  1932. }
  1933. </style>
  1934. <style lang="scss">
  1935. .basic-container.h-basic-full {
  1936. height: calc(100% - 30px);
  1937. overflow: auto;
  1938. .el-card, .el-card .el-card__body {
  1939. height: 100%;
  1940. }
  1941. }
  1942. .operation-box-inset{
  1943. display: flex;
  1944. flex-direction: column;
  1945. }
  1946. </style>
  1947. <style scoped>
  1948. .operation-symbol-box{
  1949. display: flex;
  1950. align-items: center;
  1951. border: 1px solid rgb(229, 231, 235);
  1952. background-color: #F9FAFB;
  1953. padding: 10px 10px;
  1954. border-radius: 5px 5px 0px 0px;
  1955. margin-top: 10px;
  1956. }
  1957. .sele-ele-box1{
  1958. padding: 10px;
  1959. border: 1px solid rgb(229, 231, 235);
  1960. border-radius: 0px 0px 5px 5px;
  1961. height: 50px;
  1962. }
  1963. .text-sm{
  1964. font-size: 14px;
  1965. margin-right: 10px;
  1966. }
  1967. </style>