electronicSignature.vue 16 KB

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