dynamicExcel.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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'"> <electronicSignature :pkeyId1='pkeyId' :htmlData1="htmlData" :excelId="excelId" /> </span>
  36. <span v-else-if="type.prop==='tab3'"> <setFormula :pkeyId1='pkeyId' :htmlData1="htmlData" /> </span>
  37. <span v-else-if="type.prop==='tab4'"> <editDefault :pkeyId1='pkeyId' :htmlData1="htmlData" /> </span>
  38. <span v-else-if="type.prop==='tab5'"> <promptSettings :pkeyId1='pkeyId' :htmlData1="htmlData" /> </span>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import setInputTPT from './template/setInputTPT.vue'
  45. import electronicSignature from './template/electronicSignature.vue'
  46. import setFormula from './template/setFormula.vue'
  47. import editDefault from './template/editDefault.vue'
  48. import promptSettings from './template/promptSettings.vue'
  49. import Vue from 'vue'
  50. import {getExcelHtml } from '@/api/exctab/excelmodel'
  51. import {getSignDetail} from "@/api/manager/AdjustForm";
  52. export default {
  53. props: ['pkeyId','excelId'],
  54. data () {
  55. return {
  56. setUptype: 0,//右侧显示的类型1
  57. htmlData: {
  58. name: '',
  59. tr: '',
  60. td: ''
  61. },
  62. type:{},
  63. option:{
  64. column: [{
  65. label: '设置输入框',
  66. prop: 'tab1',
  67. width: 10,
  68. }, {
  69. label: '电签位置配置',
  70. prop: 'tab2',
  71. }, {
  72. label: '设置公式开放条件',
  73. prop: 'tab3',
  74. }, {
  75. label: '编辑默认信息',
  76. prop: 'tab4',
  77. }, {
  78. label: '提示设置',
  79. prop: 'tab5',
  80. }
  81. ]
  82. },
  83. checkList:[],
  84. checkNameList:[],
  85. }
  86. },
  87. mounted () {
  88. this.cop()
  89. this.type = this.option.column[0];
  90. console.log(111);
  91. },
  92. methods: {
  93. change(){
  94. this.checkList=[]
  95. this.checkNameList=[]
  96. },
  97. GoBack () {//返回上一级
  98. this.$emit('remove')
  99. },
  100. handleChange(column) {
  101. this.type = column;
  102. },
  103. async getExcelHtml (pkeyId) {
  104. const { data: res } = await getExcelHtml({ pkeyId })
  105. console.log(res);
  106. if (res.code === 200) {
  107. localStorage.setItem('excelHtml', res.data)
  108. this.copss();
  109. }
  110. },
  111. async cop () {
  112. let _that = this
  113. var MyComponent = await Vue.extend({
  114. template: localStorage.getItem('excelHtml'),
  115. data () {
  116. return {
  117. formData: {},
  118. getTokenHeader: {},
  119. dap_site_data:{}
  120. }
  121. },
  122. methods: {
  123. contextmenuClick(tr, td, x1, x2, y1, y2, event) {},
  124. getInformation (name, tr, td) {//鼠标右键事件
  125. _that.getInformation(name, tr, td)
  126. },
  127. formUploadSuccess(){},
  128. formUploadExceed(){},
  129. formUploadLoading(){},
  130. delTableFormFile(){},
  131. formUploadError(){},
  132. uploadprogress(){},
  133. formRemoteMethod(){},
  134. getRegularExpression(){},
  135. checkboxGroupChange(){},
  136. formRemoteChange(){},
  137. dateKeydown(){},
  138. keyupShiftUp() {},
  139. keyupShiftDown() {},
  140. keyupShiftLeft() {},
  141. keyupShiftRight() {},
  142. inputLeftClick() {},
  143. }
  144. })
  145. var component = new MyComponent().$mount()
  146. document.getElementById('parent').appendChild(component.$el);
  147. },
  148. async copss () {
  149. let _that = this
  150. var MyComponent = await Vue.extend({
  151. template: localStorage.getItem('excelHtml'),
  152. data () {
  153. return {
  154. formData: {},
  155. getTokenHeader: {},
  156. dap_site_data:{}
  157. }
  158. },
  159. methods: {
  160. contextmenuClick(tr, td, x1, x2, y1, y2, event) {},
  161. getInformation (name, tr, td) {//鼠标右键事件
  162. _that.getInformation(name, tr, td)
  163. },
  164. formUploadSuccess(){},
  165. formUploadExceed(){},
  166. formUploadLoading(){},
  167. delTableFormFile(){},
  168. formUploadError(){},
  169. uploadprogress(){},
  170. getRegularExpression(){},
  171. formRemoteMethod(){},
  172. checkboxGroupChange(){},
  173. formRemoteChange(){},
  174. dateKeydown(){},
  175. keyupShiftUp() {},
  176. keyupShiftDown() {},
  177. keyupShiftLeft() {},
  178. keyupShiftRight() {},
  179. inputLeftClick() {},
  180. }
  181. })
  182. var component = new MyComponent().$mount()
  183. let na = document.getElementById('parent')
  184. na.innerHTML = `<div
  185. class='parent'
  186. id='parent'
  187. ></div>`
  188. document.getElementById('parent').appendChild(component.$el);
  189. },
  190. domss () {
  191. this.copss()
  192. },
  193. getInformation (name, tr, td) {//鼠标点击事件
  194. console.log(name,'name')
  195. let tdEle = null;
  196. //获取TD元素
  197. if(event.target.nodeName == "TD"){
  198. tdEle = event.target
  199. }else{
  200. tdEle = this.getParentTD(event.target);
  201. }
  202. let moreObj = {};
  203. if(tdEle){
  204. moreObj = this.getWidget(tdEle);
  205. }
  206. this.htmlData = Object.assign({
  207. name,
  208. tr,
  209. td
  210. },moreObj)
  211. },
  212. //excel父节点点击检测
  213. async parentClick(e){
  214. let target = e.target;
  215. const{metaKey,ctrlKey}=e
  216. console.log(target,'target')
  217. let bgs = document.querySelectorAll("#parent .oldlace-bg")
  218. //console.log(bgs)
  219. for (let i = 0; i < bgs.length; i++) {
  220. bgs[i].classList.remove("oldlace-bg");
  221. }
  222. //console.log(target.getAttribute('trindex'))
  223. let tdEle = this.getParentTD(target);
  224. console.log(tdEle,'tdEle');
  225. console.log(tdEle.getAttribute('dqid'),'dianqianid');
  226. this.htmlData.dqid=tdEle.getAttribute('dqid')
  227. // const {data: res} = await getSignDetail({id: this.htmlData.dqid})
  228. // console.log(res,'res');
  229. if( this.htmlData.dqid){
  230. const {data: res} = await getSignDetail({id: this.htmlData.dqid})
  231. if(res.code===200){
  232. console.log(res,'res');
  233. this.htmlData.obj=res.data
  234. }
  235. }
  236. let target1
  237. if(tdEle){
  238. let mydiv=tdEle.getElementsByTagName('div')
  239. target1=mydiv[0]
  240. }else{
  241. tdEle=target
  242. let mydiv=tdEle.getElementsByTagName('div')
  243. target=mydiv[0]
  244. }
  245. this.htmlData.keyname=target.getAttribute('keyname')||target1.getAttribute('keyname')
  246. if(target.getAttribute('trindex') !== null && target.getAttribute('tdindex')||target1.getAttribute('trindex') !== null && target1.getAttribute('tdindex')){
  247. let tdEle = this.getParentTD(target);
  248. if(tdEle){
  249. //橙色背景
  250. target.classList.add("oldlace-bg");
  251. if(metaKey||ctrlKey){
  252. target.classList.add("select-td");
  253. this.checkNameList.push(this.htmlData)
  254. this.checkList.push({
  255. tr:target.getAttribute('trindex')||target1.getAttribute('trindex'),
  256. td:target.getAttribute('tdindex')||target1.getAttribute('tdindex'),
  257. })
  258. }else{
  259. target.classList.remove("select-td");
  260. this.checkList.forEach((ele,index)=>{
  261. if(ele.tr===target.getAttribute('trindex')||ele.tr===target1.getAttribute('trindex')){
  262. this.checkList.splice(index,1)
  263. }
  264. })
  265. this.checkNameList.forEach((ele,index)=>{
  266. if(this.htmlData.tr===ele.tr){
  267. this.checkNameList.splice(index,1)
  268. }
  269. })
  270. }
  271. }
  272. }
  273. },
  274. getParentTD(ele){
  275. let targetParent = ele.parentNode;
  276. while (targetParent.nodeName !== "TD") {
  277. if(targetParent.id == 'parent'){
  278. return null;
  279. }
  280. targetParent = targetParent.parentNode;
  281. }
  282. return targetParent;
  283. },
  284. //获取控件信息
  285. getWidget(tdEle){
  286. let checkLabels = tdEle.querySelectorAll('.el-checkbox-group span.el-checkbox__label');
  287. //console.log(checkLabels)
  288. if(checkLabels.length > 0){
  289. let checkLabelDatas = [];
  290. for (let i = 0; i < checkLabels.length; i++) {
  291. //console.dir(checkLabels[i])
  292. checkLabelDatas.push({
  293. dictValue:checkLabels[i].innerText
  294. });
  295. }
  296. return {
  297. type:'checkbox',
  298. checkLabelDatas
  299. }
  300. }
  301. let radioLabels = tdEle.querySelectorAll('.el-radio .el-radio__label');
  302. if(radioLabels.length > 0){
  303. let radioDatas = [];
  304. for (let i = 0; i < radioLabels.length; i++) {
  305. radioDatas.push({
  306. dictValue:radioLabels[i].innerText
  307. });
  308. }
  309. return {
  310. type:'radio',
  311. radioDatas
  312. }
  313. }
  314. let elSelect = tdEle.querySelectorAll('.el-select');
  315. //console.dir(elSelect[0])
  316. if(elSelect.length){
  317. let options = elSelect[0].__vue__.options;
  318. let selectDatas = [];
  319. for (let i = 0; i < options.length; i++) {
  320. selectDatas.push({
  321. dictValue:options[i].label
  322. });
  323. }
  324. return {
  325. type:'select',
  326. selectDatas
  327. }
  328. }
  329. return {};
  330. },
  331. },
  332. components: {
  333. setInputTPT,
  334. electronicSignature,
  335. setFormula,
  336. editDefault,
  337. promptSettings
  338. }
  339. }
  340. </script>
  341. <style lang="scss" scoped>
  342. .excelHtnl {
  343. margin: 0 0 0 10px;
  344. background-color: #fff;
  345. box-sizing: border-box;
  346. padding: 0 20px 100px 20px;
  347. height: 100%;
  348. .header {
  349. border-radius: 4px;
  350. box-sizing: border-box;
  351. width: calc(100% - 20px);
  352. background-color: #fff;
  353. display: flex;
  354. justify-content: space-between;
  355. z-index: 99;
  356. height: 50px;
  357. align-items: center;
  358. .GoBack {
  359. color: rgba(0, 82, 216, 1);
  360. text-decoration: underline;
  361. display: flex;
  362. align-items: center;
  363. font-family: SourceHanSansSC;
  364. cursor: pointer;
  365. }
  366. }
  367. .excelBox {
  368. margin-top: 10px;
  369. display: flex;
  370. justify-content: flex-start;
  371. .excelRight {
  372. flex-grow: 1;
  373. box-sizing: border-box;
  374. padding: 20px 0px 0px 30px;
  375. }
  376. }
  377. }
  378. // 设置图片样式
  379. .hc-upload-table-form {
  380. position: relative;
  381. height: 100%;
  382. display: flex;
  383. justify-content: center;
  384. align-items: center;
  385. }
  386. .hc-upload-table-form .el-upload {
  387. position: relative;
  388. flex: 1;
  389. height: 100%;
  390. color: #ccc;
  391. }
  392. .hc-upload-table-form .el-upload .hc-table-form-icon {
  393. font-size: 24px;
  394. font-weight: 100;
  395. }
  396. .hc-upload-table-form .el-upload .hc-table-form-img {
  397. width: 100%;
  398. height: 100%;
  399. }
  400. .excelBox{
  401. /deep/ .oldlace-bg{
  402. background-color: oldlace;
  403. }
  404. /deep/ .select-td{
  405. border-width: 4px;
  406. border-color: #E6A23C;
  407. border-style: solid;
  408. }
  409. }
  410. </style>