electronicSignature.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <div>
  3. <div class="dianqian">
  4. <el-row :span="24">
  5. <el-col :span="3.3" style="line-height: 40px">
  6. 元素坐标:
  7. </el-col>
  8. <el-col :span="18">
  9. <avue-input v-model="htmlData1.name" placeholder="请点击坐标" :disabled='true' ></avue-input>
  10. </el-col>
  11. </el-row>
  12. <el-row :span="24">
  13. <el-col :span="3.3" style="line-height: 40px">
  14. 证书类型:
  15. </el-col>
  16. <el-col :span="18">
  17. <el-select v-model="signType" placeholder="请选择证书类型" @change="signTypeChang()">
  18. <el-option v-for="item in seloptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
  19. </el-select>
  20. </el-col>
  21. </el-row>
  22. <el-row :span="24" v-if="signType==2">
  23. <el-col :span="3.3">
  24. 所属方:
  25. </el-col>
  26. <el-col :span="18">
  27. <avue-radio v-model="radio" :dic="roleType" v-on:click="roleTypeChang()"></avue-radio>
  28. </el-col>
  29. </el-row>
  30. <el-row :span="24" v-if="signType==2">
  31. <el-col :span="3.3" style="line-height: 40px">
  32. 签字角色:
  33. </el-col>
  34. <el-col :span="18">
  35. <el-select v-model="roleInfo" placeholder="请选择签字岗位" filterable @change="changeRole">
  36. <el-option v-for="item in options" :key="item" :value="item" :label="item.label" ></el-option>
  37. </el-select>
  38. </el-col>
  39. </el-row>
  40. <el-row :span="24" v-if="signType==6">
  41. <el-col :span="3.3" style="line-height: 40px">
  42. 签章类型:
  43. </el-col>
  44. <el-col :span="18">
  45. <el-select v-model="signInfo" placeholder="请选择签章类型" @change="signInfoChang">
  46. <el-option v-for="item in options" :key="item.dictKey" :value="item.dictKey" :label="item.dictValue"></el-option>
  47. </el-select>
  48. </el-col>
  49. </el-row>
  50. <el-row :span="24">
  51. <el-col :span="3.3" style="line-height: 40px">
  52. 偏移位X:
  53. </el-col>
  54. <el-col :span="16">
  55. <avue-input v-model="pyzbx" placeholder="横坐标,负代表左移,正代表右移,偏移量50大概等于一厘米" type="number"></avue-input>
  56. </el-col>
  57. </el-row>
  58. <el-row :span="24">
  59. <el-col :span="3.3" style="line-height: 40px">
  60. 偏移位Y:
  61. </el-col>
  62. <el-col :span="16">
  63. <avue-input v-model="pyzby" placeholder="纵坐标,负代表下移,正代表上移,偏移量50大概等于一厘米" type="number"></avue-input>
  64. </el-col>
  65. </el-row>
  66. <el-row :span="24" style="text-align: center">
  67. <el-button type="warning"
  68. size="small"
  69. icon="el-icon-view"
  70. @click="previewClick()">预览</el-button> &nbsp;&nbsp;
  71. <el-button type="primary"
  72. size="small"
  73. icon="el-icon-circle-plus-outline"
  74. @click="addRoleInfo()">添加列表</el-button> &nbsp;&nbsp;
  75. </el-row>
  76. </div>
  77. <div
  78. style="border: 1px dotted rgb(187, 187, 187);box-sizing: border-box;padding: 0px 15px;"
  79. class="martop20 marbottom10"
  80. >
  81. <table @click
  82. class="table martop20 copyTable"
  83. width='100%'
  84. border='1px '
  85. bordercolor="#E5E5E5"
  86. cellpadding='2px'
  87. >
  88. <thead
  89. cellpadding='2px'
  90. height='40px'
  91. >
  92. <tr>
  93. <th width='30%'>元素位置</th>
  94. <th width='30%'>签字岗位</th>
  95. <th width='10%'>偏移x</th>
  96. <th width='10%'>偏移y</th>
  97. <th width='20%'>操作</th>
  98. </tr>
  99. </thead>
  100. <tbody height='36px'>
  101. <tr v-for="(item,key) in setsignaTable" :key="key" v-on:click="">
  102. <td>{{item.colName}}</td>
  103. <td>{{item.sigRoleName}}</td>
  104. <td>{{item.pyzbx}}</td>
  105. <td>{{item.pyzby}}</td>
  106. <td align="center">
  107. <span style="color:#409EFF;;cursor: pointer;margin-right: 5px;" @click="editClick(item)" v-if="item.show===false">编辑</span>
  108. <span style="color:green;;cursor: pointer;margin-right: 5px;" @click="saveClick(item)" v-else v-loading="isEditLoaing">保存</span>
  109. <span style="color:red;cursor: pointer;" v-on:click="deleteTableSig(key,item.id,item)">删除</span>
  110. </td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. <el-button type="primary"
  115. size="small"
  116. class="martop25"
  117. style="float:right;"
  118. icon="el-icon-circle-plus-outline"
  119. :loading="saveLoaing"
  120. @click="saveSingInfo()">保存入库</el-button> &nbsp;&nbsp;
  121. </div>
  122. </div>
  123. </template>
  124. <script>
  125. import {getRoleInfoByParentId, getRoleType, getSigList, saveSig,remove,updateDetail,getSignDetail} from "../../../../../api/manager/AdjustForm";
  126. import {findPfxType, getPriwbsPdf} from "../../../../../api/certificate/list";
  127. export default {
  128. props: ['pkeyId1', 'htmlData1','excelId'],
  129. data () {
  130. return {
  131. radio: '',
  132. roleType:[],
  133. options: [],
  134. roleInfo: '',
  135. signInfo: '',
  136. signInfoarr:[],
  137. signType: '2', // 证书类型
  138. pyzbx: 0.0,
  139. pyzby: 0.0 ,
  140. setsignaTable:[],
  141. seloptions : [
  142. {
  143. value: '2',
  144. label: '个人证书',
  145. },
  146. {
  147. value: '6',
  148. label: '企业证书',
  149. }
  150. ],
  151. isCansave:false,
  152. colKey:'',
  153. colName:'',
  154. signId:'',
  155. isDeleted:'',
  156. parentRoleId:'',
  157. isEditLoaing:false,
  158. sigRoleName:'',
  159. saveLoaing:false
  160. }
  161. },
  162. watch: {
  163. 'htmlData1': {
  164. handler(val) {
  165. setTimeout(async() => {
  166. if(val.obj){
  167. let obj=val.obj
  168. console.log(obj,'obj');
  169. this.signType=obj.type.toString()
  170. this.pyzbx=obj.pyzbx
  171. this.pyzby=obj.pyzby
  172. this.sigRoleId=obj.sigRoleId
  173. this.colKey=obj.colKey
  174. this.colName=obj.colName
  175. this.signId=obj.id
  176. this.isDeleted=obj.isDeleted
  177. if(obj.type==2){
  178. this.radio=obj.parentRoleId
  179. await this.roleTypeChang()
  180. }else{
  181. this.radio=''
  182. await this.signTypeChang()
  183. this.signInfo=obj.sigRoleId
  184. this.options.forEach((ele)=>{
  185. if(ele.dictKey=== this.signInfo){
  186. this.sigRoleName=ele.dictValue
  187. }
  188. })
  189. }
  190. }else{
  191. let isEdit= this.setsignaTable.some(element => element.show === true);
  192. if(!isEdit){
  193. this.radio=''
  194. this.roleInfo=''
  195. this.signInfo=''
  196. this.signType='2'
  197. this.pyzbx=0
  198. this.pyzby=0
  199. }
  200. this.colKey=val.keyname
  201. }
  202. }, 1000);
  203. // todo
  204. },
  205. deep: true
  206. },
  207. 'options':{
  208. handler(val){
  209. if(this.sigRoleId&&val.length>0&&this.radio.length>1){
  210. this.options.forEach((ele)=>{
  211. if(ele.value===this.sigRoleId){
  212. this.roleInfo=ele
  213. }
  214. })
  215. }
  216. }
  217. }
  218. },
  219. methods: {
  220. async getRoleType () {//获取角色类型
  221. const { data: res } = await getRoleType()
  222. if (res.code === 200) {
  223. this.roleType = res.data
  224. }
  225. },
  226. // 签证类型
  227. async signTypeChang(){
  228. setTimeout(async () => {
  229. if(this.signType==6){
  230. const {data: res} = await findPfxType({ typeOrStatus: 'pfx_type'})
  231. if (res.code === 200) {
  232. this.options = res.data
  233. }
  234. }
  235. }, 200);
  236. },
  237. // 单选按钮改变事件
  238. async roleTypeChang(){
  239. setTimeout(async () => {
  240. const {data: res} = await getRoleInfoByParentId({ParentId: this.radio})
  241. if (res.code === 200) {
  242. this.options = res.data
  243. }
  244. }, 200);
  245. },
  246. //签章类型改变e
  247. signInfoChang(e){
  248. console.log(e,'e');
  249. this.signInfoarr= this.options.filter(item=>{
  250. if(item.dictKey===e){
  251. return item
  252. }
  253. })
  254. this.options.forEach((ele)=>{
  255. if(ele.dictKey=== this.signInfo){
  256. this.sigRoleName=ele.dictValue
  257. }
  258. })
  259. },
  260. //角色改变
  261. changeRole(e){
  262. this.sigRoleName=e.label
  263. this.sigRoleId=e.value
  264. },
  265. //预览
  266. previewClick() {
  267. let _this = this
  268. console.log('预览', this.pkeyId1)
  269. getPriwbsPdf(this.pkeyId1).then(({data}) => {
  270. if (data.code === 200 && data.data) {
  271. window.open(data.data, '_blank')
  272. } else {
  273. _this.$message({
  274. type: "error",
  275. message: data.msg || "预览失败"
  276. });
  277. }
  278. })
  279. },
  280. async addRoleInfo(){
  281. var isadd = true;
  282. // 集合中添加数据
  283. var data = {};
  284. // 坐标位置
  285. if(this.htmlData1.name ===''){
  286. this.$message({
  287. type: "error",
  288. message: "请选坐标位置"
  289. });
  290. return;
  291. }else if(this.htmlData1.name === '警告' ){
  292. this.$message({
  293. type: "warning",
  294. message: "警告框不能配置电签"
  295. });
  296. return;
  297. }
  298. // 证书类型
  299. if(this.signType===''){
  300. this.$message({
  301. type: "error",
  302. message: "请选择证书类型"
  303. });
  304. return;
  305. }
  306. if (this.signType==2){
  307. if(this.roleInfo ==='') {
  308. this.$message({
  309. type: "error",
  310. message: "请选择签字岗位"
  311. });
  312. return;
  313. }
  314. data.sigRoleId = this.roleInfo.value;
  315. data.sigRoleName = this.roleInfo.label;
  316. data.type=2;
  317. }else if(this.signType==6){
  318. if(this.signInfo ===''){
  319. this.$message({
  320. type: "error",
  321. message: "请选择签章类型"
  322. });
  323. return;
  324. }
  325. // data.sigRoleId = this.signInfo.dictKey;
  326. // data.sigRoleName = this.signInfo.dictValue;
  327. data.sigRoleId = this.signInfoarr[0].dictKey;
  328. data.sigRoleName = this.signInfoarr[0].dictValue;
  329. data.type=6;
  330. }
  331. console.log(this.htmlData1,'this.htmlData11111');
  332. data.colKey="__"+this.htmlData1.tr+"_"+this.htmlData1.td;
  333. data.tabId = this.pkeyId1;
  334. data.colName= this.htmlData1.name;
  335. data.pyzbx = this.pyzbx;
  336. data.pyzby = this.pyzby;
  337. try {
  338. this.setsignaTable.forEach(val => {
  339. if(val.colName == this.htmlData1.name){ // 位置只能添加一个
  340. this.$message({
  341. type: "error",
  342. message: "位置只能配置一个电签"
  343. });
  344. isadd = false;
  345. throw new Error('位置只能配置一个电签')
  346. }
  347. if(val.colName === this.htmlData1.name && val.sigRoleId === this.roleInfo.value){
  348. this.$message({
  349. type: "error",
  350. message: "数据已添加列表中"
  351. });
  352. isadd = false;
  353. throw new Error('位置只能配置一个电签');
  354. }
  355. })
  356. if(isadd){
  357. data.show=false
  358. data.colKey=this.htmlData1.keyname
  359. this.setsignaTable.push(data);
  360. }
  361. }catch (e){
  362. throw e;
  363. }
  364. },
  365. async editClick (item){
  366. console.log(item,'item');
  367. this.setsignaTable.forEach((ele)=>{
  368. ele.show=false
  369. })
  370. item.show=true
  371. console.log(this.htmlData1,'htmlData1');
  372. const {data: res} = await getSignDetail({id: item.id,tabId:this.pkeyId1})
  373. if(res.code===200){
  374. console.log(res,'res');
  375. this.htmlData1.obj=res.data
  376. let obj=this.htmlData1.obj
  377. console.log(obj,'opbj');
  378. if(obj){
  379. console.log(obj,'obj');
  380. this.htmlData1.name=obj.colName;
  381. this.signType=obj.type.toString()
  382. this.pyzbx=obj.pyzbx
  383. this.pyzby=obj.pyzby
  384. this.sigRoleId=obj.sigRoleId
  385. this.sigRoleName=obj.sigRoleName
  386. this.colKey=obj.colKey
  387. this.colName=obj.colName
  388. this.signId=obj.id
  389. this.isDeleted=obj.isDeleted
  390. if(obj.type==2){
  391. this.radio=obj.parentRoleId
  392. await this.roleTypeChang()
  393. }else{
  394. this.radio=''
  395. await this.signTypeChang()
  396. this.signInfo=obj.sigRoleId
  397. this.options.forEach((ele)=>{
  398. if(ele.dictKey=== this.signInfo){
  399. this.sigRoleName=ele.dictValue
  400. }
  401. })
  402. }
  403. }else{
  404. this.radio=''
  405. this.roleInfo=''
  406. this.signInfo=''
  407. this.signType=''
  408. this.pyzbx=0
  409. this.pyzby=0
  410. }
  411. }
  412. console.log( this.htmlData1,' this.htmlData1111');
  413. },
  414. saveClick(item){
  415. console.log('保存');
  416. this.editRoleInfo(item)
  417. },
  418. async editRoleInfo(){
  419. let obj={}
  420. obj.colKey=this.colKey
  421. obj.colName=this.colName
  422. obj.sigRoleName=this.sigRoleName
  423. obj.tabId=this.pkeyId1
  424. obj.excelId=this.excelId
  425. obj.type=this.signType
  426. obj.pyzbx=this.pyzbx
  427. obj.pyzby=this.pyzby
  428. obj.id=this.signId
  429. obj.isDeleted=this.isDeleted
  430. if(this.signType==2){
  431. obj.parentRoleId=this.radio
  432. obj.sigRoleId=this.sigRoleId
  433. }else{
  434. obj.sigRoleId=this.signInfo
  435. }
  436. let arr=this.setsignaTable
  437. arr.forEach((ele)=>{
  438. if(obj.id==ele.id){
  439. ele.colKey=this.colKey
  440. ele.excelId=obj.excelId
  441. ele.pyzbx=obj.pyzbx
  442. ele.pyzby=obj.pyzby
  443. ele.sigRoleId=obj.sigRoleId
  444. ele.sigRoleName=obj.sigRoleName
  445. ele.type=obj.type
  446. ele.tabId=obj.tabId
  447. ele.show=false
  448. ele.colName=this.htmlData1.name
  449. }
  450. })
  451. this.$nextTick(()=>{
  452. this.setsignaTable=arr
  453. })
  454. this.$forceUpdate()
  455. console.log(this.setsignaTable,'this.setsignaTable');
  456. // this.saveSingInfo()
  457. },
  458. async deleteTableSig (key,id,item) {//删除数据
  459. console.log(item,'item');
  460. this.setsignaTable.splice(key,1);
  461. this.isCansave=true
  462. // this.saveSingInfo();
  463. // const {data: res} = await saveSig({dataInfo: this.setsignaTable,tabId:this.pkeyId1})
  464. if(id){
  465. const {data: res} = await remove(id,this.pkeyId1)
  466. if (res.code === 200) {
  467. //console.log(this.$parent)
  468. this.isCansave=false
  469. this.$parent.getExcelHtml(this.pkeyId1);
  470. this.getSingInfo()
  471. this.$message({
  472. type: "success",
  473. message: "操作成功"
  474. });
  475. }
  476. }
  477. },
  478. async saveSingInfo() {
  479. console.log(this.setsignaTable,'this.setsignaTable');
  480. if(this.setsignaTable.length===0){
  481. this.$message.warning('请先选择数据')
  482. return
  483. }
  484. this.saveLoaing=true
  485. setTimeout(() => {
  486. this.saveLoaing=false
  487. }, 1500);
  488. const {data: res} = await saveSig({dataInfo: this.setsignaTable,tabId:this.pkeyId1})
  489. if (res.code === 200) {
  490. //console.log(this.$parent)
  491. this.$parent.getExcelHtml(this.pkeyId1);
  492. this.getSingInfo()
  493. this.$message({
  494. type: "success",
  495. message: "操作成功"
  496. });
  497. }
  498. },
  499. async getSingInfo() {
  500. console.log(this.excelId,'this.excelId1111111');
  501. const {data: res} = await getSigList(
  502. {
  503. current: 0,
  504. size: 100,
  505. tabId: this.pkeyId1,
  506. type:2,
  507. excelId:this.excelId
  508. }
  509. )
  510. if (res.code === 200) {
  511. this.setsignaTable = res.data.records;
  512. this.setsignaTable.forEach((ele)=>{
  513. ele.show=false
  514. })
  515. }
  516. }
  517. },
  518. created () {
  519. this.getRoleType(); //获取文本类型接口
  520. this.getSingInfo();
  521. this.setsignaTable=[];
  522. console.log(this.htmlData1,'html1');
  523. },
  524. }
  525. </script>
  526. <style lang="scss" scoped>
  527. .table {
  528. margin-top: 20px;
  529. border-radius: 5px;
  530. color: #101010;
  531. font-size: 14px;
  532. }
  533. .dianqian{
  534. width: 90%;
  535. height: 100%;
  536. }
  537. .copyTable td{
  538. user-select:initial !important;
  539. }
  540. </style>