dynamicExcel.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <div class="excelHtnl">
  3. <div class="header" style=" position: absolute;left:10px;top:0">
  4. <div class="flexStar">
  5. <h2>编辑WBS库</h2>
  6. <div
  7. class="GoBack marleft20"
  8. @click="GoBack()"
  9. >
  10. 返回上一级
  11. </div>
  12. </div>
  13. <div style="width: 37%;">
  14. <avue-tabs :option="option" @change="handleChange"></avue-tabs>
  15. </div>
  16. </div>
  17. <div
  18. class="excelBox hc-excel-table-form"
  19. style="margin-top:40px;height: 100%;"
  20. @click="parentClick($event)"
  21. >
  22. <div style="width:60%;height: 100%;overflow: scroll;" class='parent' id='parent'></div>
  23. <div class="excelRight" style="width:30%;margin-left:4%;height: 100%;overflow: scroll;">
  24. <span v-if="type.prop==='tab1'">
  25. <setInputTPT
  26. v-if="type.prop==='tab1'"
  27. :pkeyId='pkeyId'
  28. @cop='domss'
  29. :htmlData="htmlData"
  30. :checkList="checkList"
  31. :checkNameList="checkNameList"
  32. @change="change"
  33. />
  34. </span>
  35. <span v-else-if="type.prop==='tab2'">
  36. <electronicSignature :pkeyId1='pkeyId' :htmlData1="htmlData" :excelId="excelId" :times="timesTimeElement" @edit="signatureEdit" @timeFocus="timeElementFocus"/>
  37. </span>
  38. <span v-else-if="type.prop==='tab3'"> <setFormula :pkeyId1='pkeyId' :htmlData1="htmlData"/> </span>
  39. <span v-else-if="type.prop==='tab4'"> <editDefault :pkeyId1='pkeyId' :htmlData1="htmlData"/> </span>
  40. <span v-else-if="type.prop==='tab5'"> <promptSettings :pkeyId1='pkeyId' :htmlData1="htmlData"/> </span>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import setInputTPT from './template/setInputTPT.vue'
  47. import electronicSignature from './template/electronicSignature.vue'
  48. import setFormula from './template/setFormula.vue'
  49. import editDefault from './template/editDefault.vue'
  50. import promptSettings from './template/promptSettings.vue'
  51. import Vue from 'vue'
  52. import {getExcelHtml} from '@/api/exctab/excelmodel'
  53. import {getSignDetail} from "@/api/manager/AdjustForm";
  54. export default {
  55. props: ['pkeyId', 'excelId'],
  56. data() {
  57. return {
  58. setUptype: 0,//右侧显示的类型1
  59. htmlData: {
  60. name: '',
  61. tr: '',
  62. td: ''
  63. },
  64. type: {},
  65. option: {
  66. column: [{
  67. label: '设置输入框',
  68. prop: 'tab1',
  69. width: 10,
  70. }, {
  71. label: '电签位置配置',
  72. prop: 'tab2',
  73. }, {
  74. label: '设置公式开放条件',
  75. prop: 'tab3',
  76. }, {
  77. label: '编辑默认信息',
  78. prop: 'tab4',
  79. }, {
  80. label: '提示设置',
  81. prop: 'tab5',
  82. }
  83. ]
  84. },
  85. checkList: [],
  86. checkNameList: [],
  87. isSignatureEdit: false,
  88. isTimeElement: false,
  89. timesTimeElement: {}
  90. }
  91. },
  92. mounted() {
  93. this.cop()
  94. this.type = this.option.column[0];
  95. console.log(111);
  96. },
  97. methods: {
  98. change() {
  99. this.checkList = []
  100. this.checkNameList = []
  101. },
  102. GoBack() {//返回上一级
  103. this.$emit('remove')
  104. },
  105. handleChange(column) {
  106. this.type = column;
  107. this.isSignatureEdit = false
  108. },
  109. async getExcelHtml(pkeyId) {
  110. const {data: res} = await getExcelHtml({pkeyId})
  111. console.log(res);
  112. if (res.code === 200) {
  113. localStorage.setItem('excelHtml', res.data)
  114. this.copss();
  115. }
  116. },
  117. async cop() {
  118. let _that = this
  119. var MyComponent = await Vue.extend({
  120. template: localStorage.getItem('excelHtml'),
  121. data() {
  122. return {
  123. formData: {},
  124. getTokenHeader: {},
  125. dap_site_data: {}
  126. }
  127. },
  128. methods: {
  129. contextmenuClick(tr, td, x1, x2, y1, y2, event) {
  130. },
  131. getInformation(name, tr, td) {//鼠标右键事件
  132. _that.getInformation(name, tr, td)
  133. },
  134. formUploadSuccess() {
  135. },
  136. formUploadExceed() {
  137. },
  138. formUploadLoading() {
  139. },
  140. delTableFormFile() {
  141. },
  142. formUploadError() {
  143. },
  144. uploadprogress() {
  145. },
  146. formRemoteMethod() {
  147. },
  148. getRegularExpression() {
  149. },
  150. checkboxGroupChange() {
  151. },
  152. formRemoteChange() {
  153. },
  154. dateKeydown() {
  155. },
  156. keyupShiftUp() {
  157. },
  158. keyupShiftDown() {
  159. },
  160. keyupShiftLeft() {
  161. },
  162. keyupShiftRight() {
  163. },
  164. inputLeftClick() {
  165. },
  166. }
  167. })
  168. var component = new MyComponent().$mount()
  169. document.getElementById('parent').appendChild(component.$el);
  170. },
  171. async copss() {
  172. let _that = this
  173. var MyComponent = await Vue.extend({
  174. template: localStorage.getItem('excelHtml'),
  175. data() {
  176. return {
  177. formData: {},
  178. getTokenHeader: {},
  179. dap_site_data: {}
  180. }
  181. },
  182. methods: {
  183. contextmenuClick(tr, td, x1, x2, y1, y2, event) {
  184. },
  185. getInformation(name, tr, td) {//鼠标右键事件
  186. _that.getInformation(name, tr, td)
  187. },
  188. formUploadSuccess() {
  189. },
  190. formUploadExceed() {
  191. },
  192. formUploadLoading() {
  193. },
  194. delTableFormFile() {
  195. },
  196. formUploadError() {
  197. },
  198. uploadprogress() {
  199. },
  200. getRegularExpression() {
  201. },
  202. formRemoteMethod() {
  203. },
  204. checkboxGroupChange() {
  205. },
  206. formRemoteChange() {
  207. },
  208. dateKeydown() {
  209. },
  210. keyupShiftUp() {
  211. },
  212. keyupShiftDown() {
  213. },
  214. keyupShiftLeft() {
  215. },
  216. keyupShiftRight() {
  217. },
  218. inputLeftClick() {
  219. },
  220. }
  221. })
  222. var component = new MyComponent().$mount()
  223. let na = document.getElementById('parent')
  224. na.innerHTML = `<div
  225. class='parent'
  226. id='parent'
  227. ></div>`
  228. document.getElementById('parent').appendChild(component.$el);
  229. },
  230. domss() {
  231. this.copss()
  232. },
  233. getInformation(name, tr, td) {//鼠标点击事件
  234. if (!this.isTimeElement) {
  235. let tdEle = null;
  236. //获取TD元素
  237. if (event.target.nodeName === "TD") {
  238. tdEle = event.target
  239. } else {
  240. tdEle = this.getParentTD(event.target);
  241. }
  242. let moreObj = {};
  243. if (tdEle) {
  244. moreObj = this.getWidget(tdEle);
  245. }
  246. this.htmlData = Object.assign({
  247. name,
  248. tr,
  249. td
  250. }, moreObj)
  251. } else {
  252. this.$set(this.timesTimeElement, 'colName', name)
  253. }
  254. },
  255. signatureEdit(data) {
  256. this.isSignatureEdit = data
  257. },
  258. //excel父节点点击检测
  259. async parentClick(e) {
  260. if (!this.isTimeElement) {
  261. let target = e.target;
  262. const {metaKey, ctrlKey} = e
  263. let bgs = document.querySelectorAll("#parent .oldlace-bg")
  264. //console.log(bgs)
  265. for (let i = 0; i < bgs.length; i++) {
  266. bgs[i].classList.remove("oldlace-bg");
  267. }
  268. //console.log(target.getAttribute('trindex'))
  269. let tdEle = this.getParentTD(target);
  270. this.htmlData.dqid = tdEle ? tdEle.getAttribute('dqid') : ''
  271. // const {data: res} = await getSignDetail({id: this.htmlData.dqid})
  272. // console.log(res,'res');
  273. if (this.htmlData.dqid) {
  274. if (this.type.prop === 'tab2' && this.isSignatureEdit) {
  275. this.htmlData.obj = null
  276. } else {
  277. const {data: res} = await getSignDetail({id: this.htmlData.dqid, tabId: this.pkeyId})
  278. if (res.code === 200) {
  279. this.htmlData.obj = res.data
  280. }
  281. }
  282. } else {
  283. this.htmlData.obj = null
  284. }
  285. let target1
  286. if (tdEle) {
  287. let mydiv = tdEle.getElementsByTagName('div')
  288. target1 = mydiv[0]
  289. } else {
  290. tdEle = target
  291. let mydiv = tdEle.getElementsByTagName('div')
  292. target = mydiv[0]
  293. }
  294. let keyname = ''
  295. try {
  296. keyname = target.getAttribute('keyname') || target1.getAttribute('keyname')
  297. // eslint-disable-next-line no-empty
  298. } catch {
  299. }
  300. console.log('keyname', keyname)
  301. this.htmlData.keyname = keyname
  302. if (target.getAttribute('trindex') !== null && target.getAttribute('tdindex') || target1.getAttribute('trindex') !== null && target1.getAttribute('tdindex')) {
  303. let tdEle = this.getParentTD(target);
  304. if (tdEle) {
  305. //橙色背景
  306. target.classList.add("oldlace-bg");
  307. if (metaKey || ctrlKey) {
  308. target.classList.add("select-td");
  309. this.checkNameList.push(this.htmlData)
  310. this.checkList.push({
  311. tr: target.getAttribute('trindex') || target1.getAttribute('trindex'),
  312. td: target.getAttribute('tdindex') || target1.getAttribute('tdindex'),
  313. })
  314. } else {
  315. target.classList.remove("select-td");
  316. this.checkList.forEach((ele, index) => {
  317. if (ele.tr === target.getAttribute('trindex') || ele.tr === target1.getAttribute('trindex')) {
  318. this.checkList.splice(index, 1)
  319. }
  320. })
  321. this.checkNameList.forEach((ele, index) => {
  322. if (this.htmlData.tr === ele.tr) {
  323. this.checkNameList.splice(index, 1)
  324. }
  325. })
  326. }
  327. }
  328. }
  329. } else {
  330. let target = e.target;
  331. let tdEle = this.getParentTD(target);
  332. let target1
  333. if (tdEle) {
  334. let mydiv = tdEle.getElementsByTagName('div')
  335. target1 = mydiv[0]
  336. } else {
  337. tdEle = target
  338. let mydiv = tdEle.getElementsByTagName('div')
  339. target = mydiv[0]
  340. }
  341. let keyname = ''
  342. try {
  343. keyname = target.getAttribute('keyname') || target1.getAttribute('keyname')
  344. } catch {}
  345. this.$set(this.timesTimeElement, 'keyname', keyname)
  346. console.log(this.timesTimeElement)
  347. }
  348. },
  349. getParentTD(ele) {
  350. let targetParent = ele.parentNode;
  351. while (targetParent.nodeName !== "TD") {
  352. if (targetParent.id == 'parent') {
  353. return null;
  354. }
  355. targetParent = targetParent.parentNode;
  356. }
  357. return targetParent;
  358. },
  359. //获取控件信息
  360. getWidget(tdEle) {
  361. let selectElement = tdEle.querySelectorAll('.el-select');
  362. let isMultiple = false
  363. if (selectElement.length) {
  364. // 遍历每个元素,检查是否包含 is-multiple 类名
  365. selectElement.forEach(element => {
  366. if (element.classList.contains('is-multiple')) {
  367. isMultiple = true;
  368. }
  369. });
  370. if (isMultiple) {
  371. let options = selectElement[0].__vue__.options;
  372. let selectDatas = [];
  373. for (let i = 0; i < options.length; i++) {
  374. selectDatas.push({
  375. dictValue: options[i].label
  376. });
  377. }
  378. return {
  379. type: 'selectBox',
  380. selectDatas
  381. }
  382. }
  383. }
  384. let checkLabels = tdEle.querySelectorAll('.el-checkbox-group span.el-checkbox__label');
  385. //console.log(checkLabels)
  386. if (checkLabels.length > 0) {
  387. let checkLabelDatas = [];
  388. for (let i = 0; i < checkLabels.length; i++) {
  389. //console.dir(checkLabels[i])
  390. checkLabelDatas.push({
  391. dictValue: checkLabels[i].innerText
  392. });
  393. }
  394. return {
  395. type: 'checkbox',
  396. checkLabelDatas
  397. }
  398. }
  399. let radioLabels = tdEle.querySelectorAll('.el-radio .el-radio__label');
  400. if (radioLabels.length > 0) {
  401. let radioDatas = [];
  402. for (let i = 0; i < radioLabels.length; i++) {
  403. radioDatas.push({
  404. dictValue: radioLabels[i].innerText
  405. });
  406. }
  407. return {
  408. type: 'radio',
  409. radioDatas
  410. }
  411. }
  412. let elSelect = tdEle.querySelectorAll('.el-select');
  413. //console.dir(elSelect[0])
  414. if (elSelect.length) {
  415. let options = elSelect[0].__vue__.options;
  416. let selectDatas = [];
  417. for (let i = 0; i < options.length; i++) {
  418. selectDatas.push({
  419. dictValue: options[i].label
  420. });
  421. }
  422. return {
  423. type: 'select',
  424. selectDatas
  425. }
  426. }
  427. return {};
  428. },
  429. //是否为时间元素选择模式
  430. timeElementFocus(val) {
  431. this.isTimeElement = val
  432. },
  433. },
  434. components: {
  435. setInputTPT,
  436. electronicSignature,
  437. setFormula,
  438. editDefault,
  439. promptSettings
  440. }
  441. }
  442. </script>
  443. <style lang="scss" scoped>
  444. .excelHtnl {
  445. margin: 0 0 0 10px;
  446. background-color: #fff;
  447. box-sizing: border-box;
  448. padding: 0 20px 100px 20px;
  449. height: 100%;
  450. .header {
  451. border-radius: 4px;
  452. box-sizing: border-box;
  453. width: calc(100% - 20px);
  454. background-color: #fff;
  455. display: flex;
  456. justify-content: space-between;
  457. z-index: 99;
  458. height: 50px;
  459. align-items: center;
  460. .GoBack {
  461. color: rgba(0, 82, 216, 1);
  462. text-decoration: underline;
  463. display: flex;
  464. align-items: center;
  465. font-family: SourceHanSansSC;
  466. cursor: pointer;
  467. }
  468. }
  469. .excelBox {
  470. margin-top: 10px;
  471. display: flex;
  472. justify-content: flex-start;
  473. .excelRight {
  474. flex-grow: 1;
  475. box-sizing: border-box;
  476. padding: 20px 0px 0px 30px;
  477. }
  478. }
  479. }
  480. // 设置图片样式
  481. .hc-upload-table-form {
  482. position: relative;
  483. height: 100%;
  484. display: flex;
  485. justify-content: center;
  486. align-items: center;
  487. }
  488. .hc-upload-table-form .el-upload {
  489. position: relative;
  490. flex: 1;
  491. height: 100%;
  492. color: #ccc;
  493. }
  494. .hc-upload-table-form .el-upload .hc-table-form-icon {
  495. font-size: 24px;
  496. font-weight: 100;
  497. }
  498. .hc-upload-table-form .el-upload .hc-table-form-img {
  499. width: 100%;
  500. height: 100%;
  501. }
  502. .excelBox {
  503. ::v-deep .oldlace-bg {
  504. background-color: oldlace;
  505. }
  506. ::v-deep .select-td {
  507. border-width: 4px;
  508. border-color: #E6A23C;
  509. border-style: solid;
  510. }
  511. }
  512. </style>