electronicSignature.vue 20 KB

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