electronicSignature.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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. console.log(val,'val');
  162. setTimeout(async() => {
  163. if(val.obj){
  164. let obj=val.obj
  165. console.log(obj,'obj');
  166. this.signType=obj.type.toString()
  167. this.pyzbx=obj.pyzbx
  168. this.pyzby=obj.pyzby
  169. this.sigRoleId=obj.sigRoleId
  170. this.colKey=obj.colKey
  171. this.colName=obj.colName
  172. this.signId=obj.id
  173. this.isDeleted=obj.isDeleted
  174. if(obj.type==2){
  175. this.radio=obj.parentRoleId
  176. await this.roleTypeChang()
  177. }else{
  178. this.radio=''
  179. await this.signTypeChang()
  180. this.signInfo=obj.sigRoleId
  181. this.options.forEach((ele)=>{
  182. if(ele.dictKey=== this.signInfo){
  183. this.sigRoleName=ele.dictValue
  184. }
  185. })
  186. }
  187. }else{
  188. let isEdit= this.setsignaTable.some(element => element.show === true);
  189. if(!isEdit){
  190. this.radio=''
  191. this.roleInfo=''
  192. this.signInfo=''
  193. this.signType=''
  194. this.pyzbx=0
  195. this.pyzby=0
  196. }
  197. this.colKey=val.keyname
  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. this.colName=obj.colName
  364. this.signId=obj.id
  365. this.isDeleted=obj.isDeleted
  366. if(obj.type==2){
  367. this.radio=obj.parentRoleId
  368. await this.roleTypeChang()
  369. }else{
  370. this.radio=''
  371. await this.signTypeChang()
  372. this.signInfo=obj.sigRoleId
  373. this.options.forEach((ele)=>{
  374. if(ele.dictKey=== this.signInfo){
  375. this.sigRoleName=ele.dictValue
  376. }
  377. })
  378. }
  379. }else{
  380. this.radio=''
  381. this.roleInfo=''
  382. this.signInfo=''
  383. this.signType=''
  384. this.pyzbx=0
  385. this.pyzby=0
  386. }
  387. }
  388. console.log( this.htmlData1,' this.htmlData1111');
  389. },
  390. saveClick(item){
  391. console.log('保存');
  392. this.editRoleInfo(item)
  393. },
  394. async editRoleInfo(){
  395. let obj={}
  396. obj.colKey=this.colKey
  397. obj.colName=this.colName
  398. obj.sigRoleName=this.sigRoleName
  399. obj.tabId=this.pkeyId1
  400. obj.excelId=this.excelId
  401. obj.type=this.signType
  402. obj.pyzbx=this.pyzbx
  403. obj.pyzby=this.pyzby
  404. obj.id=this.signId
  405. obj.isDeleted=this.isDeleted
  406. if(this.signType==2){
  407. obj.parentRoleId=this.radio
  408. obj.sigRoleId=this.sigRoleId
  409. }else{
  410. obj.sigRoleId=this.signInfo
  411. }
  412. let arr=this.setsignaTable
  413. arr.forEach((ele)=>{
  414. if(obj.id==ele.id){
  415. ele.colKey=this.colKey
  416. ele.excelId=obj.excelId
  417. ele.pyzbx=obj.pyzbx
  418. ele.pyzby=obj.pyzby
  419. ele.sigRoleId=obj.sigRoleId
  420. ele.sigRoleName=obj.sigRoleName
  421. ele.type=obj.type
  422. ele.tabId=obj.tabId
  423. ele.show=false
  424. ele.colName=this.htmlData1.name
  425. }
  426. })
  427. this.$nextTick(()=>{
  428. this.setsignaTable=arr
  429. })
  430. this.$forceUpdate()
  431. console.log(this.setsignaTable,'this.setsignaTable');
  432. // this.saveSingInfo()
  433. },
  434. async deleteTableSig (key,id,item) {//删除数据
  435. console.log(item,'item');
  436. this.setsignaTable.splice(key,1);
  437. this.isCansave=true
  438. // this.saveSingInfo();
  439. // const {data: res} = await saveSig({dataInfo: this.setsignaTable,tabId:this.pkeyId1})
  440. if(id){
  441. const {data: res} = await remove(id)
  442. if (res.code === 200) {
  443. //console.log(this.$parent)
  444. this.isCansave=false
  445. this.$parent.getExcelHtml(this.pkeyId1);
  446. this.getSingInfo()
  447. this.$message({
  448. type: "success",
  449. message: "操作成功"
  450. });
  451. }
  452. }
  453. },
  454. async saveSingInfo() {
  455. console.log(this.setsignaTable,'this.setsignaTable');
  456. if(this.setsignaTable.length===0){
  457. this.$message.warning('请先选择数据')
  458. return
  459. }
  460. this.saveLoaing=true
  461. setTimeout(() => {
  462. this.saveLoaing=false
  463. }, 1500);
  464. const {data: res} = await saveSig({dataInfo: this.setsignaTable,tabId:this.pkeyId1})
  465. if (res.code === 200) {
  466. //console.log(this.$parent)
  467. this.$parent.getExcelHtml(this.pkeyId1);
  468. this.getSingInfo()
  469. this.$message({
  470. type: "success",
  471. message: "操作成功"
  472. });
  473. }
  474. },
  475. async getSingInfo() {
  476. console.log(this.excelId,'this.excelId1111111');
  477. const {data: res} = await getSigList(
  478. {
  479. current: 0,
  480. size: 100,
  481. tabId: this.pkeyId1,
  482. type:2,
  483. excelId:this.excelId
  484. }
  485. )
  486. if (res.code === 200) {
  487. this.setsignaTable = res.data.records;
  488. this.setsignaTable.forEach((ele)=>{
  489. ele.show=false
  490. })
  491. }
  492. }
  493. },
  494. created () {
  495. this.getRoleType(); //获取文本类型接口
  496. this.getSingInfo();
  497. this.setsignaTable=[];
  498. console.log(this.htmlData1,'html1');
  499. },
  500. }
  501. </script>
  502. <style lang="scss" scoped>
  503. .table {
  504. margin-top: 20px;
  505. border-radius: 5px;
  506. color: #101010;
  507. font-size: 14px;
  508. }
  509. .dianqian{
  510. width: 90%;
  511. height: 100%;
  512. }
  513. .copyTable td{
  514. user-select:initial !important;
  515. }
  516. </style>