electronicSignature.vue 18 KB

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