electronicSignature.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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. data.colKey = "__" + this.htmlData1.tr + "_" + this.htmlData1.td;
  363. data.tabId = this.pkeyId1;
  364. data.colName = this.htmlData1.name;
  365. data.pyzbx = this.pyzbx;
  366. data.pyzby = this.pyzby;
  367. //签字时间
  368. const times = this.timesTimeElement
  369. data.timeState = times.timeState || 2;
  370. data.timeName = times.timeName;
  371. data.timeColKey = times.timeColKey;
  372. if (data.timeState === 1 && (!data.timeName || data.timeName === '')) {
  373. this.$message({type: "error", message: "请先配置签字时间"});
  374. return;
  375. }
  376. try {
  377. this.setsignaTable.forEach(val => {
  378. if (val.sigRoleId == data.sigRoleId && val.colName == data.colName) {
  379. this.$message({
  380. type: "error",
  381. message: "一个位置只能配置一个岗位"
  382. });
  383. isadd = false;
  384. }
  385. })
  386. if (isadd) {
  387. data.show = false
  388. data.colKey = this.htmlData1.keyname
  389. this.setsignaTable.push(data);
  390. }
  391. } catch (e) {
  392. throw e;
  393. }
  394. },
  395. async editClick(item) {
  396. console.log(item, 'item222');
  397. this.setsignaTable.forEach((ele) => {
  398. ele.show = false
  399. })
  400. item.show = true
  401. console.log(this.htmlData1, 'htmlData222');
  402. const {data: res} = await getSignDetail({id: item.id, tabId: this.pkeyId1})
  403. if (res.code === 200) {
  404. console.log(res, 'res');
  405. this.htmlData1.obj = res.data
  406. debugger
  407. let obj = this.htmlData1.obj
  408. console.log(obj, 'opbj');
  409. if (obj) {
  410. console.log(obj, 'obj');
  411. this.htmlData1.name = obj.colName;
  412. this.htmlData1.keyname = obj.colKey;
  413. this.signType = obj.type.toString()
  414. this.pyzbx = obj.pyzbx
  415. this.pyzby = obj.pyzby
  416. this.sigRoleId = obj.sigRoleId
  417. this.sigRoleName = obj.sigRoleName
  418. this.colKey = obj.colKey
  419. this.colName = obj.colName
  420. this.signId = obj.id
  421. this.isDeleted = obj.isDeleted
  422. if (obj.type == 2) {
  423. this.radio = obj.parentRoleId
  424. await this.roleTypeChang()
  425. } else {
  426. this.radio = ''
  427. await this.signTypeChang()
  428. this.signInfo = obj.sigRoleId
  429. this.options.forEach((ele) => {
  430. if (ele.dictKey === this.signInfo) {
  431. this.sigRoleName = ele.dictValue
  432. }
  433. })
  434. }
  435. //签字时间
  436. this.timesTimeElement = {
  437. timeState: obj.timeState || 2,
  438. timeName: obj.timeName,
  439. timeColKey: obj.timeColKey
  440. }
  441. } else {
  442. this.radio = ''
  443. this.roleInfo = ''
  444. this.signInfo = ''
  445. this.signType = ''
  446. this.pyzbx = 0
  447. this.pyzby = 0
  448. //签字时间
  449. this.timesTimeElement = {
  450. timeState: 2,
  451. timeName: '',
  452. timeColKey: ''
  453. }
  454. }
  455. }
  456. console.log(this.htmlData1, ' this.htmlData1111');
  457. this.$emit('edit', true)
  458. },
  459. saveClick(item) {
  460. console.log('保存');
  461. debugger;
  462. this.editRoleInfo(item)
  463. },
  464. async editRoleInfo() {
  465. let obj = {}
  466. obj.colKey = this.colKey
  467. obj.colName = this.colName
  468. obj.sigRoleName = this.sigRoleName
  469. obj.tabId = this.pkeyId1
  470. obj.excelId = this.excelId
  471. obj.type = this.signType
  472. obj.pyzbx = this.pyzbx
  473. obj.pyzby = this.pyzby
  474. obj.id = this.signId
  475. obj.isDeleted = this.isDeleted
  476. const times = this.timesTimeElement
  477. obj.timeState = times.timeState || 2
  478. obj.timeName = times.timeName
  479. obj.timeColKey = times.timeColKey
  480. if (this.signType == 2) {
  481. obj.parentRoleId = this.radio
  482. obj.sigRoleId = this.sigRoleId
  483. } else {
  484. obj.sigRoleId = this.signInfo
  485. }
  486. let arr = this.setsignaTable
  487. arr.forEach((ele) => {
  488. if (obj.id == ele.id) {
  489. ele.colKey = this.colKey
  490. ele.excelId = obj.excelId
  491. ele.pyzbx = obj.pyzbx
  492. ele.pyzby = obj.pyzby
  493. ele.sigRoleId = obj.sigRoleId
  494. ele.sigRoleName = obj.sigRoleName
  495. ele.type = obj.type
  496. ele.tabId = obj.tabId
  497. ele.show = false
  498. ele.colName = this.htmlData1.name
  499. ele.timeState = obj.timeState
  500. ele.timeName = obj.timeName
  501. ele.timeColKey = obj.timeColKey
  502. }
  503. })
  504. this.$nextTick(() => {
  505. this.setsignaTable = arr
  506. })
  507. this.$forceUpdate()
  508. console.log(this.setsignaTable, 'this.setsignaTable');
  509. // this.saveSingInfo()
  510. this.$emit('edit', false)
  511. },
  512. async deleteTableSig(key, id, item) {//删除数据
  513. console.log(item, 'item');
  514. this.setsignaTable.splice(key, 1);
  515. this.isCansave = true
  516. // this.saveSingInfo();
  517. // const {data: res} = await saveSig({dataInfo: this.setsignaTable,tabId:this.pkeyId1})
  518. if (id) {
  519. const {data: res} = await remove(id, this.pkeyId1)
  520. if (res.code === 200) {
  521. //console.log(this.$parent)
  522. this.isCansave = false
  523. this.$parent.getExcelHtml(this.pkeyId1);
  524. this.getSingInfo()
  525. this.$message({
  526. type: "success",
  527. message: "操作成功"
  528. });
  529. }
  530. }
  531. this.$emit('edit', false)
  532. },
  533. async saveSingInfo() {
  534. console.log(this.setsignaTable, 'this.setsignaTable');
  535. if (this.setsignaTable.length === 0) {
  536. this.$message.warning('请先选择数据')
  537. return
  538. }
  539. this.saveLoaing = true
  540. setTimeout(() => {
  541. this.saveLoaing = false
  542. }, 1500);
  543. const {data: res} = await saveSig({dataInfo: this.setsignaTable, tabId: this.pkeyId1})
  544. if (res.code === 200) {
  545. //console.log(this.$parent)
  546. this.$parent.getExcelHtml(this.pkeyId1);
  547. this.getSingInfo()
  548. this.$message({
  549. type: "success",
  550. message: "操作成功"
  551. });
  552. }
  553. },
  554. async getSingInfo() {
  555. console.log(this.excelId, 'this.excelId1111111');
  556. const {data: res} = await getSigList(
  557. {
  558. current: 0,
  559. size: 100,
  560. tabId: this.pkeyId1,
  561. type: 2,
  562. excelId: this.excelId
  563. }
  564. )
  565. if (res.code === 200) {
  566. this.setsignaTable = res.data.records;
  567. this.setsignaTable.forEach((ele) => {
  568. ele.show = false
  569. })
  570. }
  571. },
  572. timeElementFocus() {
  573. this.isTimeElement = true
  574. this.$emit('timeFocus', true)
  575. },
  576. timeElementFinish() {
  577. this.isTimeElement = false
  578. this.$emit('timeFocus', false)
  579. },
  580. },
  581. created() {
  582. this.getRoleType(); //获取文本类型接口
  583. this.getSingInfo();
  584. this.setsignaTable = [];
  585. console.log(this.htmlData1, 'html1');
  586. },
  587. }
  588. </script>
  589. <style lang="scss" scoped>
  590. .table {
  591. margin-top: 20px;
  592. border-radius: 5px;
  593. color: #101010;
  594. font-size: 14px;
  595. }
  596. .dianqian {
  597. width: 90%;
  598. height: 100%;
  599. }
  600. .copyTable td {
  601. user-select: initial !important;
  602. }
  603. </style>