editElement.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. <template>
  2. <div
  3. style="height:100%;"
  4. ref="heights"
  5. >
  6. <basic-container class="editElement" style="height:900px">
  7. <div class="flex" style="position:fixed;left:30px;top:0;">
  8. <h2 class="mg-r-10">编辑元素</h2>
  9. <el-link type="primary" @click="toBack">返回上一级</el-link>
  10. </div>
  11. <div
  12. class="header"
  13. style="padding-bottom:20px;"
  14. >
  15. 提示:鼠标右键功能:更换匹配元素字段、新增元素字段、删除匹配元素字段、公式配置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 红色:代表匹配不成功、蓝色代表推荐匹配元素字段、绿色代表匹配成功
  16. </div>
  17. <el-row
  18. :gutter="20"
  19. :style="{height:heights-150+'px',}"
  20. >
  21. <el-col :span="16">
  22. <div
  23. class='parent'
  24. id='parent'
  25. @click="parentClick($event)"
  26. >
  27. </div>
  28. </el-col>
  29. <el-col
  30. :span="7"
  31. style="position: fixed;right: 13px;"
  32. >
  33. <div v-show="AddNewElementField == '替换元素'">
  34. <!-- <div>
  35. <el-checkbox v-model="isMultiple" @change="multipleChange">多选模式</el-checkbox>
  36. </div> -->
  37. <el-table
  38. :data="eleData" height="300px"
  39. border size="small" v-show="isMultiple"
  40. style="width: 100%;margin-bottom:10px;">
  41. <el-table-column
  42. label="td_tr" width="100px" align="center">
  43. <template slot-scope="scope">
  44. <span>{{scope.row.td}}_{{scope.row.tr}}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. prop="name"
  49. label="名称">
  50. </el-table-column>
  51. <el-table-column label="操作" width="100px" align="center">
  52. <template slot-scope="scope">
  53. <el-button
  54. size="mini"
  55. type="danger"
  56. @click="eleDelete(scope.$index, scope.row)">删除</el-button>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <el-select
  61. style="width:300px;"
  62. v-model="value"
  63. filterable
  64. placeholder="请选择"
  65. >
  66. <el-option
  67. v-for="item in options"
  68. :key="item.id"
  69. :label="item.eName"
  70. :value="item.id"
  71. >
  72. </el-option>
  73. </el-select>
  74. <div class="tihuan">替换为:</div>
  75. <el-input
  76. style="width:95%;"
  77. :disabled="true"
  78. type="textarea"
  79. :rows="4"
  80. placeholder="请输入内容"
  81. v-model="names"
  82. >
  83. </el-input>
  84. <div class="martop20">
  85. <el-button
  86. type="info"
  87. @click="cancelReplace()"
  88. >取消</el-button>
  89. <el-button
  90. type="primary"
  91. :disabled="tag"
  92. @click="saveReplace()"
  93. >保存</el-button>
  94. </div>
  95. </div>
  96. <div
  97. v-show="AddNewElementField ==''"
  98. style="width:160px;position: fixed;bottom: 50px; right:20px;"
  99. >
  100. <el-button type="info" @click="toBack">取消</el-button>
  101. <el-button type="primary">保存</el-button>
  102. </div>
  103. </el-col>
  104. </el-row>
  105. <!-- 弹框 -->
  106. <!-- <div
  107. @mouseout="mouseout22"
  108. @mousemove="mousemove22"
  109. v-if="cascaderPanel"
  110. >
  111. <el-cascader-panel
  112. :style="{width:'360px',position: 'absolute',top:top+'px',left:left+'px','background-color':'#fff',margin:'40px',}"
  113. :props="{ expandTrigger: 'hover' }"
  114. :options="options2"
  115. @change="takuangchangge"
  116. ></el-cascader-panel>
  117. </div> -->
  118. <el-dialog append-to-body :show-close="false" width="360px" :modal='false' class="cascader-dialog" top="0"
  119. :visible.sync="cascaderPanel" :style="{position: 'absolute',top:top+'px',left:left+'px'}">
  120. <el-cascader-panel
  121. :props="{ expandTrigger: 'hover' }"
  122. :options="options2"
  123. @change="takuangchangge"
  124. ref="cascader"
  125. ></el-cascader-panel>
  126. </el-dialog>
  127. <el-dialog
  128. title="添加新元素字段"
  129. :visible="AddNewElementField=='新增元素'"
  130. width="60%"
  131. :before-close="handleClose"
  132. :modal-append-to-body="false"
  133. style="z-index: 999999;"
  134. >
  135. <div>
  136. <i
  137. @click="addyuansu"
  138. class="el-icon-circle-plus marbottom10"
  139. style="color:red; font-size:24px; float: right;cursor: pointer;"
  140. ></i>
  141. <el-table
  142. :data="tableData"
  143. height="250"
  144. border
  145. style="width: 100%"
  146. >
  147. <el-table-column
  148. prop="date"
  149. label="清表元素名称"
  150. >
  151. <template slot-scope="scope">
  152. <el-input
  153. v-model="scope.row.eName"
  154. placeholder="请输入内容"
  155. ></el-input>
  156. </template>
  157. </el-table-column>
  158. <el-table-column
  159. prop="date"
  160. label="元素数据类型"
  161. >
  162. <template slot-scope="scope">
  163. <el-select
  164. style="width:100%;"
  165. v-model="scope.row.eType"
  166. placeholder="请选择"
  167. >
  168. <el-option
  169. v-for="item in dataType"
  170. :key="item.dictKey"
  171. :label="item.dictValue"
  172. :value="item.dictKey"
  173. >
  174. </el-option>
  175. </el-select>
  176. </template>
  177. </el-table-column>
  178. <!-- <el-table-column
  179. prop="date"
  180. label="长度"
  181. align="center"
  182. >
  183. <template slot-scope="scope">
  184. <el-input
  185. v-model="scope.row.date"
  186. placeholder="请输入内容"
  187. ></el-input>
  188. </template>
  189. </el-table-column> -->
  190. <el-table-column
  191. prop="date"
  192. align="center"
  193. width="120"
  194. label="操作"
  195. >
  196. <template slot-scope="scope">
  197. <el-button
  198. type="danger"
  199. size="mini"
  200. @click="deleteziduan(scope.$index)"
  201. >删除</el-button>
  202. </template>
  203. </el-table-column>
  204. </el-table>
  205. </div>
  206. <span
  207. slot="footer"
  208. class="dialog-footer"
  209. >
  210. <el-button @click="handleClose()">取 消</el-button>
  211. <el-button
  212. type="primary"
  213. v-throttle='2000'
  214. :disabled="tableData.length===0"
  215. @click="pushNewElementField()"
  216. >确 定</el-button>
  217. </span>
  218. </el-dialog>
  219. <!-- 公式 -->
  220. <el-dialog title="元素公式" :visible.sync="formulaCompVisible" fullscreen append-to-body class="full-dialog">
  221. <FormulaEdit :wbsid="wbsid" :nodeid="nodeid" :eleid="eleid" :projectid="pid" @hideDialog="formulaCompVisible = false" v-if="formulaCompVisible"
  222. :globaltype="globaltype" :fromcurNode="editElementQuery"></FormulaEdit>
  223. </el-dialog>
  224. <el-dialog title="" :visible.sync="formulaCompVisible1" fullscreen append-to-body class="full-dialog">
  225. <FormulaEditone :wbsid="wbsid" :nodeid="nodeid" :eleid="eleid" :elementType="elementType" :projectid="pid" :fromcurNode="curEleTable"
  226. :globaltype="globaltype" @hideDialog="formulaCompVisible1 = false"
  227. v-if="formulaCompVisible1">
  228. </FormulaEditone>
  229. </el-dialog>
  230. </basic-container>
  231. </div>
  232. </template>
  233. <script>
  234. import FormulaEdit from '@/views/formula/edit.vue'
  235. import FormulaEditone from '@/views/formula/edit1.vue'
  236. import { getExcelHtml } from '@/api/exctab/excelmodel'
  237. import { getElementInfoByTabId, submit, dictionarydataType, submitBatch } from '@/api/exctab/editelement'
  238. import Vue from 'vue'
  239. export default {
  240. components:{
  241. FormulaEdit,
  242. FormulaEditone
  243. },
  244. props: {
  245. pkeyId:{
  246. type:String,
  247. default:''
  248. },
  249. excelId:{
  250. type:String,
  251. default:''
  252. },
  253. id:{
  254. type:String,
  255. default:''
  256. },
  257. initTableName:{
  258. type:String,
  259. default:''
  260. },
  261. initTableId:{
  262. type:String,
  263. default:''
  264. },
  265. pid:{
  266. type:String,
  267. default:''
  268. },
  269. wbsid:{
  270. type:String,
  271. default:''
  272. },
  273. nodeid:{
  274. type:String,
  275. default:''
  276. },
  277. globaltype:{
  278. type:Number,
  279. default:10
  280. },
  281. elementType:{
  282. type:Boolean,
  283. default:false
  284. },
  285. curEleTable:{
  286. type:Object,
  287. default:{}
  288. },
  289. editElementQuery:{
  290. type:Object,
  291. default:{}
  292. }
  293. },
  294. data () {
  295. return {
  296. heights: '',
  297. dataType: [],//数据类型
  298. tag: false,
  299. table: {
  300. },//table表鼠标右键事件
  301. AddNewElementField: '',
  302. setTimeout: '',
  303. top: 0,
  304. left: 0,
  305. cascaderPanel: false,
  306. options: [],
  307. value: '',
  308. names: '',//替换元素得值
  309. tableData: [],//table表
  310. options2: [{
  311. value: '编辑元素字段',
  312. label: '编辑元素字段',
  313. children: [{
  314. value: '替换元素',
  315. label: '替换元素'
  316. }, {
  317. value: '新增元素',
  318. label: '新增元素'
  319. }, {
  320. value: '删除文本信息',
  321. label: '删除文本信息'
  322. }]
  323. }, {
  324. value: '公式配置',
  325. label: '公式配置',
  326. }],
  327. ekeyReg:/(key_\d+)/,
  328. isMultiple:false,
  329. eleData:[],
  330. formulaCompVisible:false,//公式弹框节点公式
  331. formulaCompVisible1:false,//公式弹框全局公式
  332. eleid:'',//当前元素
  333. }
  334. },
  335. mounted () {
  336. this.cop()
  337. this.heights = this.$refs.heights.clientHeight
  338. },
  339. created () {
  340. this.getElementInfoByTabId()
  341. },
  342. methods: {
  343. takuangchangge (value) {//切换事件
  344. if (value[value.length - 1] == '替换元素') {
  345. this.AddNewElementField = '替换元素'
  346. this.cascaderPanel = false
  347. clearTimeout(this.setTimeout)
  348. } else if (value[value.length - 1] == '新增元素') {
  349. if (this.dataType.length == 0) {
  350. this.dictionarydataType()
  351. }
  352. this.tableData = []
  353. this.AddNewElementField = '新增元素'//打开新增元素弹框
  354. this.cascaderPanel = false
  355. clearTimeout(this.setTimeout)
  356. } else if (value[value.length - 1] == '删除文本信息') {
  357. this.deleteelement()
  358. this.cascaderPanel = false
  359. clearTimeout(this.setTimeout)
  360. } else if (value[value.length - 1] == '公式配置') {
  361. this.cascaderPanel = false
  362. clearTimeout(this.setTimeout)
  363. this.toFormulaEdit();
  364. }
  365. },
  366. mouseout22 () {//鼠标移出事件
  367. clearTimeout(this.setTimeout)
  368. this.setTimeout = setTimeout(() => {
  369. this.cascaderPanel = false
  370. }, 500)
  371. },
  372. mousemove22 () {//鼠标移入事件
  373. clearTimeout(this.setTimeout)
  374. this.setTimeout = setTimeout(() => {
  375. this.cascaderPanel = true
  376. }, 500)
  377. },
  378. RightClick2 (tr, td, x1, x2, y1, y2) {
  379. //console.log(event.target.getAttribute("keyname"))
  380. let targetkeyname = event.target.getAttribute("keyname");
  381. //console.log(event.target)
  382. let ekey = null;
  383. if(this.ekeyReg.test(targetkeyname)){
  384. ekey = targetkeyname.match(this.ekeyReg)[1]
  385. }
  386. this.table = {
  387. tr,
  388. td,
  389. ekey
  390. }
  391. this.left = window.event.clientX - 80
  392. let Y = window.event.clientY -54
  393. if (window.outerHeight - Y > 200) {
  394. this.top = window.event.clientY - 80 + 65
  395. } else {
  396. this.top = window.event.clientY - 270 + 65
  397. }
  398. this.cascaderPanel = true
  399. clearTimeout(this.setTimeout)
  400. this.setTimeout = setTimeout(() => {
  401. this.cascaderPanel = false
  402. }, 3000)
  403. let curTdEle = this.getTd(event.target);
  404. if(this.isMultiple){
  405. //是否已经存在了
  406. for (let i = 0; i < this.eleData.length; i++) {
  407. if(this.eleData[i].tr == tr && this.eleData[i].td == td){
  408. //存在就移除
  409. this.eleData[i].tdEle.classList.remove('select-td');
  410. this.eleData.splice(i,1);
  411. return;
  412. }
  413. }
  414. //添加
  415. this.eleData.push({
  416. tr,
  417. td,
  418. tdEle:curTdEle,
  419. name:curTdEle.getAttribute("title")
  420. })
  421. }else{
  422. this.clearSelect();
  423. this.eleData = [{
  424. tr,
  425. td,
  426. tdEle:curTdEle,
  427. name:curTdEle.getAttribute("title")
  428. }]
  429. }
  430. curTdEle.classList.add('select-td')
  431. this.$nextTick(()=>{
  432. //隐藏日期弹框
  433. let pickers = document.querySelectorAll('.el-date-picker__header')
  434. for (let i = 0; i < pickers.length; i++) {
  435. pickers[i].parentNode.parentNode.parentNode.style.display = 'none'
  436. }
  437. })
  438. },
  439. getTd(ele){
  440. while(ele.tagName.toLowerCase() != 'td' && ele.id != 'parent'){
  441. ele = ele.parentNode;
  442. //console.log(ele);
  443. }
  444. if(ele.id == 'parent'){
  445. return null;
  446. }else{
  447. return ele;
  448. }
  449. },
  450. deleteelement () {//删除元素提示
  451. let _that = this
  452. this.$confirm('确认删除该元素?', '提示', {
  453. confirmButtonText: '确定',
  454. cancelButtonText: '取消',
  455. type: 'warning'
  456. }).then(() => {
  457. _that.submit({
  458. colName: '/',
  459. tabId: this.pkeyId,
  460. tdIndex: this.table.td,
  461. trIndex: this.table.tr,
  462. })
  463. }).catch(() => {
  464. _that.$message({
  465. type: 'info',
  466. message: '已取消删除'
  467. });
  468. });
  469. },
  470. getInformation2 (a, b, c) {
  471. if (this.AddNewElementField) {
  472. this.table = {
  473. tr: b,
  474. td: c
  475. }
  476. }
  477. },
  478. async cop () {
  479. let _that = this
  480. console.log("33")
  481. var MyComponent = await Vue.extend({
  482. template: localStorage.getItem('editElement'),
  483. data () {
  484. return {
  485. formData: {},
  486. getTokenHeader: {},
  487. dap_site_data:{}
  488. }
  489. },
  490. methods: {
  491. RightClick (tr, td, x1, x2, y1, y2) {//鼠标右键事件
  492. _that.RightClick2(tr, td, x1, x2, y1, y2)
  493. },
  494. getInformation (a, b, c) {
  495. _that.getInformation2(a, b, c)
  496. },
  497. getRegularExpression(){},
  498. dateKeydown(){},
  499. formUploadSuccess(){},
  500. formUploadExceed(){},
  501. formUploadLoading(){},
  502. delTableFormFile(){},
  503. formUploadError(){},
  504. uploadprogress(){},
  505. formRemoteMethod(){},
  506. formRemoteChange(){},
  507. checkboxGroupChange(){}
  508. }
  509. })
  510. var component = new MyComponent().$mount()
  511. document.getElementById('parent').appendChild(component.$el);
  512. },
  513. async copss () {
  514. let _that = this
  515. console.log("44")
  516. var MyComponent = await Vue.extend({
  517. template: localStorage.getItem('editElement'),
  518. data () {
  519. return {
  520. formData: {},
  521. getTokenHeader: {},
  522. dap_site_data:{}
  523. }
  524. },
  525. methods: {
  526. RightClick (tr, td, x1, x2, y1, y2) {//鼠标右键事件
  527. _that.RightClick2(tr, td, x1, x2, y1, y2)
  528. },
  529. getInformation (a, b, c) {
  530. _that.getInformation2(a, b, c)
  531. },
  532. getRegularExpression(){},
  533. dateKeydown(){},
  534. formUploadSuccess(){},
  535. formUploadExceed(){},
  536. formUploadLoading(){},
  537. delTableFormFile(){},
  538. formUploadError(){},
  539. uploadprogress(){},
  540. formRemoteMethod(){},
  541. formRemoteChange(){},
  542. checkboxGroupChange(){}
  543. }
  544. })
  545. var component = new MyComponent().$mount()
  546. let na = document.getElementById('parent')
  547. na.innerHTML = `<div
  548. class='parent'
  549. id='parent'
  550. ></div>`
  551. document.getElementById('parent').appendChild(component.$el);
  552. },
  553. async dictionarydataType () {
  554. const { data: res } = await dictionarydataType()
  555. console.log(res);
  556. if (res.code == 200) {
  557. this.dataType = res.data
  558. }
  559. },
  560. returns () {
  561. this.$router.push({
  562. path: '/project/tree',
  563. query: {
  564. pid: this.pid,
  565. wbsid: this.wbsid,
  566. }
  567. })
  568. },
  569. //#region 左侧替换元素
  570. cancelReplace () {//替换元素取消按钮
  571. this.AddNewElementField = ''
  572. this.$refs.cascader.clearCheckedNodes()//调用方法无效
  573. },
  574. saveReplace () {//保存按钮
  575. if (this.value) {
  576. this.tag = true
  577. this.submit({
  578. tabId: this.pkeyId,
  579. tdIndex: this.table.td,
  580. trIndex: this.table.tr,
  581. colName: "",
  582. htmlType: this.value
  583. })
  584. } else {
  585. this.$message({
  586. type: "error",
  587. message: "请选择要替换的元素"
  588. })
  589. }
  590. },
  591. async getElementInfoByTabId () {//获取字段信息
  592. const { data: res } = await getElementInfoByTabId({ tabId: this.initTableId })
  593. console.log(res);
  594. if (res.code === 200) {
  595. this.options = res.data
  596. }
  597. },
  598. async submit (da) {//保存替换元素
  599. const { data: res } = await submit(da)
  600. console.log(res);
  601. if (res.code == 200) {
  602. const { data: res } = await getExcelHtml({ pkeyId: this.pkeyId })
  603. console.log(res);
  604. if (res.code === 200) {
  605. this.tag = false
  606. this.value = ''
  607. this.options = []
  608. localStorage.setItem('editElement', res.data)
  609. this.getElementInfoByTabId()
  610. this.copss()
  611. }
  612. }
  613. },
  614. //#endregion
  615. //#region 弹框事件
  616. handleClose () {
  617. console.log('取消');
  618. this.tableData = []
  619. this.AddNewElementField = ''
  620. },
  621. addyuansu () {//新增元素
  622. this.tableData.unshift({ eName: '', eType: '' })
  623. },
  624. deleteziduan (key) {//删除新增元素弹框字段
  625. this.tableData.splice(key, 1)
  626. },
  627. pushNewElementField () {//确定添加按钮
  628. if (this.tableData.length > 0) {
  629. let tag = true
  630. this.tableData.forEach(val => {
  631. if (!(val.eName && val.eType)) {
  632. tag = false
  633. }
  634. })
  635. if (tag) {
  636. this.submitBatch({
  637. projectId: this.pid,
  638. initTableName: this.initTableName,
  639. id: this.pkeyId,
  640. listData: this.tableData,
  641. })
  642. } else {
  643. this.$message({
  644. type: 'error',
  645. message: '请填写所有字段'
  646. });
  647. }
  648. }
  649. },
  650. async submitBatch (da) {
  651. const { data: res } = await submitBatch(da)
  652. console.log(res);
  653. if (res.code == 200) {
  654. this.$message({
  655. type: 'success',
  656. message: '添加成功'
  657. })
  658. this.AddNewElementField = ''
  659. //更新下拉列表s
  660. this.getElementInfoByTabId()
  661. }
  662. },
  663. //#endregion
  664. //跳转到公式配置页面
  665. toFormulaEdit () {
  666. let eleid = null;
  667. if(this.table.ekey){
  668. for (let i = 0; i < this.options.length; i++) {
  669. if(this.options[i].ekey == this.table.ekey){
  670. eleid = this.options[i].id;
  671. break;
  672. }
  673. }
  674. }
  675. if(eleid == null){
  676. this.$message({
  677. type: "warning",
  678. message: "找不到元素id"
  679. })
  680. this.$refs.cascader.clearCheckedNodes()//调用方法无效
  681. return;
  682. }
  683. // this.$router.push({
  684. // path: '/formula/edit',
  685. // query: {
  686. // wbsid: this.wbsid,
  687. // eleid: eleid,
  688. // nodeid:this.nodeid,
  689. // projectid:this.pid
  690. // }
  691. // });
  692. this.eleid = eleid;
  693. if (this.globaltype===10) {
  694. this.formulaCompVisible = true;
  695. }else{
  696. this.formulaCompVisible1 = true;
  697. }
  698. this.$refs.cascader.clearCheckedNodes()
  699. },
  700. // 返回上一页
  701. toBack(){
  702. // this.$router.go(-1);
  703. this.$emit('hideDialog')
  704. },
  705. eleDelete(index){
  706. this.eleData[index].tdEle.classList.remove('select-td');
  707. this.eleData.splice(index,1);
  708. },
  709. clearSelect(){
  710. this.eleData.forEach((data)=>{
  711. data.tdEle.classList.remove('select-td');
  712. })
  713. },
  714. multipleChange(value){
  715. if(!value && this.eleData.length > 1){
  716. let last = this.eleData[this.eleData.length-1];
  717. this.clearSelect();
  718. this.eleData = [last];
  719. this.eleData[0].tdEle.classList.add('select-td');
  720. }
  721. },
  722. //excel父节点点击检测
  723. parentClick(e){
  724. let target = e.target;
  725. let bgs = document.querySelectorAll("#parent .oldlace-bg")
  726. //console.log(bgs)
  727. for (let i = 0; i < bgs.length; i++) {
  728. bgs[i].classList.remove("oldlace-bg");
  729. }
  730. //console.log(target.getAttribute('trindex'))
  731. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
  732. let tdEle = this.getParentTD(target);
  733. if(tdEle){
  734. target.classList.add("oldlace-bg");
  735. }
  736. }
  737. },
  738. getParentTD(ele){
  739. let targetParent = ele.parentNode;
  740. while (targetParent.nodeName !== "TD") {
  741. if(targetParent.id == 'parent'){
  742. return null;
  743. }
  744. targetParent = targetParent.parentNode;
  745. }
  746. return targetParent;
  747. },
  748. },
  749. watch: {
  750. 'options' () {
  751. if (this.options) {
  752. this.options2 = [{
  753. value: '编辑元素字段',
  754. label: '编辑元素字段',
  755. children: [{
  756. value: '替换元素',
  757. label: '替换元素'
  758. }, {
  759. value: '新增元素',
  760. label: '新增元素'
  761. }, {
  762. value: '删除文本信息',
  763. label: '删除文本信息'
  764. }]
  765. }, {
  766. value: '公式配置',
  767. label: '公式配置',
  768. }]
  769. } else {
  770. this.options2 = [{
  771. value: '编辑元素字段',
  772. label: '编辑元素字段',
  773. children: [{
  774. value: '新增元素',
  775. label: '新增元素'
  776. }, {
  777. value: '删除文本信息',
  778. label: '删除文本信息'
  779. }]
  780. }, {
  781. value: '公式配置',
  782. label: '公式配置',
  783. }]
  784. }
  785. },
  786. 'value' (values) {
  787. if (values) {
  788. this.options.forEach(val => {
  789. if (val.id == values) {
  790. this.names = val.eName
  791. }
  792. })
  793. }
  794. },
  795. // 'cascaderPanel'(val){
  796. // this.AddNewElementField = '替换元素'
  797. // }
  798. }
  799. }
  800. </script>
  801. <style lang="scss" scoped>
  802. .editElement {
  803. padding-bottom: 40px !important;
  804. .header {
  805. color: rgb(240, 114, 10);
  806. }
  807. .tihuan {
  808. margin-top: 15px;
  809. margin-bottom: 10px;
  810. font-family: SourceHanSansSC;
  811. font-weight: 400;
  812. font-size: 14px;
  813. color: rgb(16, 16, 16);
  814. font-style: normal;
  815. letter-spacing: 0px;
  816. line-height: 20px;
  817. text-decoration: none;
  818. }
  819. }
  820. .parent{
  821. /deep/ .select-td{
  822. border-width: 4px;
  823. border-color: #E6A23C;
  824. border-style: solid;
  825. }
  826. /deep/ .oldlace-bg{
  827. background-color: oldlace;
  828. }
  829. }
  830. .full-dialog{
  831. /deep/ .el-dialog__body{
  832. padding-bottom: 0;
  833. padding-top: 0;
  834. }
  835. /deep/ .basic-container{
  836. height: calc(100vh - 60px);
  837. }
  838. }
  839. </style>