electronicSignature.vue 19 KB

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