editElement.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  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. contextmenuClick(event) {
  492. event.preventDefault();
  493. },
  494. //鼠标右键事件
  495. RightClick (tr, td, x1, x2, y1, y2) {
  496. _that.RightClick2(tr, td, x1, x2, y1, y2)
  497. },
  498. getInformation (a, b, c) {
  499. _that.getInformation2(a, b, c)
  500. },
  501. getRegularExpression(){},
  502. dateKeydown(){},
  503. formUploadSuccess(){},
  504. formUploadExceed(){},
  505. formUploadLoading(){},
  506. delTableFormFile(){},
  507. formUploadError(){},
  508. uploadprogress(){},
  509. formRemoteMethod(){},
  510. formRemoteChange(){},
  511. checkboxGroupChange(){},
  512. keyupShiftUp() {},
  513. keyupShiftDown() {},
  514. keyupShiftLeft() {},
  515. keyupShiftRight() {},
  516. inputLeftClick() {},
  517. }
  518. })
  519. var component = new MyComponent().$mount()
  520. document.getElementById('parent').appendChild(component.$el);
  521. },
  522. async copss () {
  523. let _that = this
  524. console.log("44")
  525. var MyComponent = await Vue.extend({
  526. template: localStorage.getItem('editElement'),
  527. data () {
  528. return {
  529. formData: {},
  530. getTokenHeader: {},
  531. dap_site_data:{}
  532. }
  533. },
  534. methods: {
  535. contextmenuClick(event) {
  536. event.preventDefault();
  537. },
  538. //鼠标右键事件
  539. RightClick (tr, td, x1, x2, y1, y2) {
  540. _that.RightClick2(tr, td, x1, x2, y1, y2)
  541. },
  542. getInformation (a, b, c) {
  543. _that.getInformation2(a, b, c)
  544. },
  545. getRegularExpression(){},
  546. dateKeydown(){},
  547. formUploadSuccess(){},
  548. formUploadExceed(){},
  549. formUploadLoading(){},
  550. delTableFormFile(){},
  551. formUploadError(){},
  552. uploadprogress(){},
  553. formRemoteMethod(){},
  554. formRemoteChange(){},
  555. checkboxGroupChange(){},
  556. keyupShiftUp() {},
  557. keyupShiftDown() {},
  558. keyupShiftLeft() {},
  559. keyupShiftRight() {},
  560. inputLeftClick() {},
  561. }
  562. })
  563. var component = new MyComponent().$mount()
  564. let na = document.getElementById('parent')
  565. na.innerHTML = `<div
  566. class='parent'
  567. id='parent'
  568. ></div>`
  569. document.getElementById('parent').appendChild(component.$el);
  570. },
  571. async dictionarydataType () {
  572. const { data: res } = await dictionarydataType()
  573. console.log(res);
  574. if (res.code == 200) {
  575. this.dataType = res.data
  576. }
  577. },
  578. returns () {
  579. this.$router.push({
  580. path: '/project/tree',
  581. query: {
  582. pid: this.pid,
  583. wbsid: this.wbsid,
  584. }
  585. })
  586. },
  587. //#region 左侧替换元素
  588. cancelReplace () {//替换元素取消按钮
  589. this.AddNewElementField = ''
  590. this.$refs.cascader.clearCheckedNodes()//调用方法无效
  591. },
  592. saveReplace () {//保存按钮
  593. if (this.value) {
  594. this.tag = true
  595. this.submit({
  596. tabId: this.pkeyId,
  597. tdIndex: this.table.td,
  598. trIndex: this.table.tr,
  599. colName: "",
  600. htmlType: this.value
  601. })
  602. } else {
  603. this.$message({
  604. type: "error",
  605. message: "请选择要替换的元素"
  606. })
  607. }
  608. },
  609. async getElementInfoByTabId () {//获取字段信息
  610. const { data: res } = await getElementInfoByTabId({ tabId: this.initTableId })
  611. console.log(res);
  612. if (res.code === 200) {
  613. this.options = res.data
  614. }
  615. },
  616. async submit (da) {//保存替换元素
  617. const { data: res } = await submit(da)
  618. console.log(res);
  619. if (res.code == 200) {
  620. const { data: res } = await getExcelHtml({ pkeyId: this.pkeyId })
  621. console.log(res);
  622. if (res.code === 200) {
  623. this.tag = false
  624. this.value = ''
  625. this.options = []
  626. localStorage.setItem('editElement', res.data)
  627. this.getElementInfoByTabId()
  628. this.copss()
  629. }
  630. }
  631. },
  632. //#endregion
  633. //#region 弹框事件
  634. handleClose () {
  635. console.log('取消');
  636. this.tableData = []
  637. this.AddNewElementField = ''
  638. },
  639. addyuansu () {//新增元素
  640. this.tableData.unshift({ eName: '', eType: '' })
  641. },
  642. deleteziduan (key) {//删除新增元素弹框字段
  643. this.tableData.splice(key, 1)
  644. },
  645. pushNewElementField () {//确定添加按钮
  646. if (this.tableData.length > 0) {
  647. let tag = true
  648. this.tableData.forEach(val => {
  649. if (!(val.eName && val.eType)) {
  650. tag = false
  651. }
  652. })
  653. if (tag) {
  654. this.submitBatch({
  655. projectId: this.pid,
  656. initTableName: this.initTableName,
  657. id: this.pkeyId,
  658. listData: this.tableData,
  659. })
  660. } else {
  661. this.$message({
  662. type: 'error',
  663. message: '请填写所有字段'
  664. });
  665. }
  666. }
  667. },
  668. async submitBatch (da) {
  669. const { data: res } = await submitBatch(da)
  670. console.log(res);
  671. if (res.code == 200) {
  672. this.$message({
  673. type: 'success',
  674. message: '添加成功'
  675. })
  676. this.AddNewElementField = ''
  677. //更新下拉列表s
  678. this.getElementInfoByTabId()
  679. }
  680. },
  681. //#endregion
  682. //跳转到公式配置页面
  683. toFormulaEdit () {
  684. let eleid = null;
  685. if(this.table.ekey){
  686. for (let i = 0; i < this.options.length; i++) {
  687. if(this.options[i].ekey == this.table.ekey){
  688. eleid = this.options[i].id;
  689. break;
  690. }
  691. }
  692. }
  693. if(eleid == null){
  694. this.$message({
  695. type: "warning",
  696. message: "找不到元素id"
  697. })
  698. this.$refs.cascader.clearCheckedNodes()//调用方法无效
  699. return;
  700. }
  701. // this.$router.push({
  702. // path: '/formula/edit',
  703. // query: {
  704. // wbsid: this.wbsid,
  705. // eleid: eleid,
  706. // nodeid:this.nodeid,
  707. // projectid:this.pid
  708. // }
  709. // });
  710. this.eleid = eleid;
  711. if (this.globaltype===10) {
  712. this.formulaCompVisible = true;
  713. }else{
  714. this.formulaCompVisible1 = true;
  715. }
  716. this.$refs.cascader.clearCheckedNodes()
  717. },
  718. // 返回上一页
  719. toBack(){
  720. // this.$router.go(-1);
  721. this.$emit('hideDialog')
  722. },
  723. eleDelete(index){
  724. this.eleData[index].tdEle.classList.remove('select-td');
  725. this.eleData.splice(index,1);
  726. },
  727. clearSelect(){
  728. this.eleData.forEach((data)=>{
  729. data.tdEle.classList.remove('select-td');
  730. })
  731. },
  732. multipleChange(value){
  733. if(!value && this.eleData.length > 1){
  734. let last = this.eleData[this.eleData.length-1];
  735. this.clearSelect();
  736. this.eleData = [last];
  737. this.eleData[0].tdEle.classList.add('select-td');
  738. }
  739. },
  740. //excel父节点点击检测
  741. parentClick(e){
  742. let target = e.target;
  743. let bgs = document.querySelectorAll("#parent .oldlace-bg")
  744. //console.log(bgs)
  745. for (let i = 0; i < bgs.length; i++) {
  746. bgs[i].classList.remove("oldlace-bg");
  747. }
  748. //console.log(target.getAttribute('trindex'))
  749. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')){
  750. let tdEle = this.getParentTD(target);
  751. if(tdEle){
  752. target.classList.add("oldlace-bg");
  753. }
  754. }
  755. },
  756. getParentTD(ele){
  757. let targetParent = ele.parentNode;
  758. while (targetParent.nodeName !== "TD") {
  759. if(targetParent.id == 'parent'){
  760. return null;
  761. }
  762. targetParent = targetParent.parentNode;
  763. }
  764. return targetParent;
  765. },
  766. },
  767. watch: {
  768. 'options' () {
  769. if (this.options) {
  770. this.options2 = [{
  771. value: '编辑元素字段',
  772. label: '编辑元素字段',
  773. children: [{
  774. value: '替换元素',
  775. label: '替换元素'
  776. }, {
  777. value: '新增元素',
  778. label: '新增元素'
  779. }, {
  780. value: '删除文本信息',
  781. label: '删除文本信息'
  782. }]
  783. }, {
  784. value: '公式配置',
  785. label: '公式配置',
  786. }]
  787. } else {
  788. this.options2 = [{
  789. value: '编辑元素字段',
  790. label: '编辑元素字段',
  791. children: [{
  792. value: '新增元素',
  793. label: '新增元素'
  794. }, {
  795. value: '删除文本信息',
  796. label: '删除文本信息'
  797. }]
  798. }, {
  799. value: '公式配置',
  800. label: '公式配置',
  801. }]
  802. }
  803. },
  804. 'value' (values) {
  805. if (values) {
  806. this.options.forEach(val => {
  807. if (val.id == values) {
  808. this.names = val.eName
  809. }
  810. })
  811. }
  812. },
  813. // 'cascaderPanel'(val){
  814. // this.AddNewElementField = '替换元素'
  815. // }
  816. }
  817. }
  818. </script>
  819. <style lang="scss" scoped>
  820. .editElement {
  821. padding-bottom: 40px !important;
  822. .header {
  823. color: rgb(240, 114, 10);
  824. }
  825. .tihuan {
  826. margin-top: 15px;
  827. margin-bottom: 10px;
  828. font-family: SourceHanSansSC;
  829. font-weight: 400;
  830. font-size: 14px;
  831. color: rgb(16, 16, 16);
  832. font-style: normal;
  833. letter-spacing: 0px;
  834. line-height: 20px;
  835. text-decoration: none;
  836. }
  837. }
  838. .parent{
  839. /deep/ .select-td{
  840. border-width: 4px;
  841. border-color: #E6A23C;
  842. border-style: solid;
  843. }
  844. /deep/ .oldlace-bg{
  845. background-color: oldlace;
  846. }
  847. }
  848. .full-dialog{
  849. /deep/ .el-dialog__body{
  850. padding-bottom: 0;
  851. padding-top: 0;
  852. }
  853. /deep/ .basic-container{
  854. height: calc(100vh - 60px);
  855. }
  856. }
  857. </style>