addList.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. <template>
  2. <basic-container class="addList">
  3. <el-form
  4. ref="form"
  5. :model="form"
  6. :rules="rules"
  7. label-width="170px"
  8. :inline="true"
  9. >
  10. <el-form-item
  11. label="证书类型"
  12. prop="certificateType"
  13. style="width:45%;"
  14. >
  15. <el-radio-group v-model="form.certificateType" @change="changeCertificateType">
  16. <el-radio :label="1">个人证书</el-radio>
  17. <el-radio :label="2">企业证书</el-radio>
  18. </el-radio-group>
  19. </el-form-item>
  20. <el-form-item
  21. label="签字公司"
  22. prop="company"
  23. style="width:45%;"
  24. v-if="form.certificateType===2"
  25. >
  26. <el-select
  27. v-model="form.company"
  28. placeholder="请选择"
  29. style="width: 400px;"
  30. clearable
  31. @visible-change="changeCompany"
  32. >
  33. <el-option
  34. v-for="item in options"
  35. :key="item.id"
  36. :label="item.dictValue"
  37. :value="item.dictKey"
  38. ></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item
  42. label="证书所有者"
  43. prop="certificateUserName"
  44. style="width:45%;"
  45. >
  46. <el-input
  47. v-model="form.certificateUserName"
  48. style="width:400px;"
  49. placeholder="请输入内容"
  50. ></el-input>
  51. </el-form-item>
  52. <el-form-item
  53. label="所持证书者身份证ID"
  54. prop="certificateId"
  55. v-if="form.certificateType==1&&form.company!=3"
  56. style="width:45%;"
  57. >
  58. <el-input
  59. v-model="form.certificateId"
  60. style="width:400px;"
  61. placeholder="请输入内容"
  62. ></el-input>
  63. </el-form-item>
  64. <el-form-item
  65. label="企业统一社会信用代码"
  66. style="width:45%;"
  67. prop="enterpriseUnifiedCode"
  68. v-if="form.certificateType!==1&&form.company!=3"
  69. >
  70. <el-input
  71. v-model="form.enterpriseUnifiedCode"
  72. style="width:400px;"
  73. placeholder="请输入内容"
  74. ></el-input>
  75. </el-form-item>
  76. <el-form-item
  77. label="证书编号"
  78. prop="certificateNumber"
  79. style="width:45%;"
  80. >
  81. <el-input
  82. v-model="form.certificateNumber"
  83. style="width:400px;"
  84. placeholder="请输入内容"
  85. ></el-input>
  86. </el-form-item>
  87. <el-form-item
  88. label="证书密码"
  89. prop="certificatePassword"
  90. style="width:45%;"
  91. v-if="form.company!=3"
  92. >
  93. <el-input
  94. v-model="form.certificatePassword"
  95. style="width:400px;"
  96. placeholder="请输入内容"
  97. ></el-input>
  98. </el-form-item>
  99. <el-form-item
  100. label="签章类型"
  101. style="width:45%;"
  102. prop="pfxType"
  103. >
  104. <el-select
  105. v-model="form.pfxType"
  106. style="width:400px;"
  107. placeholder="请选择"
  108. >
  109. <el-option
  110. v-for="item in pfxType"
  111. :key="item.dictKey"
  112. :label="item.dictValue"
  113. :value="item.dictKey"
  114. >
  115. </el-option>
  116. </el-select>
  117. </el-form-item>
  118. <el-form-item
  119. label="关联用户"
  120. style="width:45%;"
  121. prop="certificateUserId"
  122. v-if="form.certificateType==1"
  123. >
  124. <el-select
  125. filterable
  126. v-model="form.certificateUserId"
  127. style="width:400px;"
  128. placeholder="请选择"
  129. @change="selectUser"
  130. >
  131. <el-option
  132. v-for="item in userData"
  133. :key="item.id"
  134. :label="item.name"
  135. :value="item.id"
  136. >
  137. </el-option>
  138. </el-select>
  139. </el-form-item>
  140. <el-form-item
  141. label="证书文件"
  142. style="width:100%;"
  143. prop="certificateFileUrl"
  144. v-if="form.company!=3"
  145. >
  146. <el-upload
  147. class="upload-demo" action="#" multiple :limit="1" :auto-upload="false" accept='.pfx'
  148. :file-list="form.certificateFileUrl" :before-remove="beforeRemove" :on-change="changecertificateFileUrl"
  149. >
  150. <el-button size="small" type="primary">上传文件</el-button>
  151. <div slot="tip" class="el-upload__tip">支持上传文件格式为pfx文件</div>
  152. </el-upload>
  153. </el-form-item>
  154. <el-form-item label="签名体图片" style="width:100%;" prop="signatureFileUrl" v-if="form.company!=3">
  155. <el-upload
  156. class="upload-demo" action="#" multiple :limit="1" :auto-upload="false" accept='.jpg,.png'
  157. :file-list="form.signatureFileUrl" :before-remove="beforeRemove2" :on-change="changecertificateFileUrl2"
  158. >
  159. <div style="position: relative; display: flex; align-items: center;">
  160. <el-button size="small" type="primary">上传文件</el-button>
  161. <div style="position: relative; display: flex;align-items: center; color: #1A1A1A; cursor: default;" @click.stop="stopClick">
  162. <el-input v-model="form.wide" style="width:60px; margin-left: 24px;" placeholder="宽度" size="small" :disabled="form.signatureFileUrl.length<=0"></el-input>
  163. <div style="display: inline-block; margin-left: 8px;">x</div>
  164. <el-input v-model="form.high" style="width:60px; margin-left: 8px;" placeholder="高度" size="small" :disabled="form.signatureFileUrl.length<=0"></el-input>
  165. <el-button size="small" type="warning" style="margin-left: 12px" :disabled="form.signatureFileUrl.length <= 0 " @click.stop="signaturePreview">预览</el-button>
  166. </div>
  167. </div>
  168. <div
  169. slot="tip"
  170. class="el-upload__tip"
  171. >支持上传文件格式为JPG/PNG</div>
  172. </el-upload>
  173. </el-form-item>
  174. <el-form-item
  175. label="关联项目"
  176. tyle="width:100%;"
  177. prop="signPfxDeputieList"
  178. v-if="form.certificateType==2"
  179. >
  180. <i
  181. class="el-icon-circle-plus"
  182. style="color:red;font-size:24px;line-height:40px;cursor: pointer;"
  183. @click="pushSignPfxDeputieList"
  184. ></i>
  185. <div
  186. v-for="(item,key) in form.signPfxDeputieList"
  187. :key='key'
  188. >
  189. <!-- 项目 -->
  190. <el-select
  191. style="width:300px;"
  192. class="martop20"
  193. v-model="form.signPfxDeputieList[key].projectId"
  194. placeholder="请选择"
  195. @change="changeProjectId(key)"
  196. >
  197. <el-option
  198. v-for="item in projectMeiju"
  199. :key="item.id"
  200. :label="item.name"
  201. :value="item.id"
  202. >
  203. </el-option>
  204. </el-select>
  205. <!-- 合同段 -->
  206. <el-select
  207. style="width:300px;"
  208. class="marleft20 martop20"
  209. @focus="focusContractSection(form.signPfxDeputieList[key].projectId,key)"
  210. :disabled='!form.signPfxDeputieList[key].projectId'
  211. v-model="form.signPfxDeputieList[key].contractId"
  212. placeholder="请选择"
  213. @change="checkRoleRepeat(key)"
  214. >
  215. <el-option
  216. v-for="item in form.signPfxDeputieList[key].contractList"
  217. :key="item.id"
  218. :label="item.name"
  219. :value="item.id"
  220. >
  221. </el-option>
  222. </el-select>
  223. <el-select
  224. class="marleft20 martop20"
  225. style="width:300px;"
  226. v-model="form.signPfxDeputieList[key].roleId"
  227. placeholder="请选择参建方"
  228. @change="checkRoleRepeat(key)"
  229. >
  230. <el-option
  231. v-for="item in ParticipationConstruction"
  232. :key="item.id"
  233. :label="item.roleName"
  234. :value="item.id"
  235. >
  236. </el-option>
  237. </el-select>
  238. <i
  239. class="el-icon-error marleft10"
  240. @click="deleteSignPfxDeputie(key)"
  241. style="fontSize:20px;color:#F0630A;cursor: pointer;"
  242. ></i>
  243. </div>
  244. <!-- signPfxDeputieList -->
  245. </el-form-item>
  246. </el-form>
  247. <div class="flexCenter">
  248. <el-button @click="cancel">取消</el-button>
  249. <el-button
  250. class="marleft30"
  251. type="primary"
  252. v-throttle='2000'
  253. @click="savess()"
  254. >保存</el-button>
  255. <el-button
  256. class="marleft30"
  257. type="warning"
  258. v-if="fromId!=0"
  259. @click="nextClick()"
  260. >下一个</el-button>
  261. </div>
  262. </basic-container>
  263. </template>
  264. <script>
  265. import { save, getById, findUserByName, queryRole, queryProjectAndContract, addFileInfo, update, findPfxType, picPresave, prePicture, compressAndUpload } from "@/api/certificate/list";
  266. import {getDictionary as getDictbiz} from "@/api/system/dictbiz";
  267. import {
  268. listpage,
  269. } from "@/api/certificate/list";
  270. export default {
  271. data () {
  272. return {
  273. form: {
  274. certificateType: 1,
  275. certificateUserName: '',
  276. certificateId: '',//所持证书者身份证ID
  277. enterpriseUnifiedCode: '',//企业统一社会信用代码
  278. certificateNumber: '',
  279. certificatePassword: '123456',
  280. certificateUserId: '',
  281. pfxType: '',
  282. certificateFileUrl: [],//证书文件
  283. certificateFileName: '',//证书文件名称
  284. signatureFileUrl: [],//签名体图片
  285. signatureFileName: '',//签名体图片文件名称
  286. signPfxDeputieList: [],
  287. company:2,
  288. wide: '',
  289. high: ''
  290. },
  291. rules: {
  292. company:[{ required: false, message: '请选择', trigger: 'change' }],
  293. certificateType: [{ required: true, message: '请选择', trigger: 'change' }],
  294. certificateUserName: [{ required: true, message: '请输入证书所有者', trigger: 'blur' }],
  295. certificateId: [{ required: true, message: '请输入所持证书者身份ID', trigger: 'blur' }],
  296. enterpriseUnifiedCode: [{ required: true, message: '请输入企业统一社会信用代码', trigger: 'blur' }],
  297. // certificateNumber: [{ required: true, message: '请输入证书编号', trigger: 'blur' }],
  298. certificateNumber:[],
  299. certificatePassword: [{ required: true, message: '请输入证书密码', trigger: 'blur' }],
  300. certificateUserId: [{ required: true, message: '请选择关联用户', trigger: 'change' }],
  301. certificateFileUrl: [{ required: true, message: '请选择证书文件', trigger: 'change' }],
  302. signatureFileUrl: [{ required: true, message: '请选择签名体图片', trigger: 'change', }],
  303. signPfxDeputieList: [{ required: true, message: '请设置关联项目', trigger: 'change', }],
  304. pfxType: [{ required: true, message: '请选择签章类型', trigger: 'change', }],
  305. },
  306. ParticipationConstruction: [],//参见项目方
  307. projectMeiju: [],//项目
  308. ContractSection: [],//合同段
  309. userData: [],//关联用户
  310. pfxType: [],//
  311. options:[],
  312. signatureId: '',
  313. fromId: '',
  314. tableData:[],
  315. pageindex: 1,
  316. total: 0,
  317. currentPage:1
  318. }
  319. },
  320. methods: {
  321. // 根据条件动态设置 dependentField 的验证规则
  322. updateDependentFieldValidation() {
  323. const conditionFieldValue = this.form.company;
  324. console.log(conditionFieldValue,'conditionFieldValue');
  325. // 清空 dependentField 的验证规则
  326. this.rules.certificateNumber = [];
  327. // 根据条件字段的值来决定是否必填
  328. if (conditionFieldValue === 3) {
  329. // 设置为必填项
  330. this.rules.certificateNumber.push({ required: true, message: 'Dependent Field 是必填项', trigger: 'change' });
  331. }else{
  332. this.rules.certificateNumber = [];
  333. }
  334. },
  335. //获取签字公司
  336. getOptions() {
  337. getDictbiz({
  338. code: 'es_type_name'
  339. }).then((res) => {
  340. this.options = res.data.data;
  341. this.options.forEach((ele)=>{
  342. ele.dictKey=Number(ele.dictKey)
  343. })
  344. })
  345. console.log( this.options,' this.options');
  346. },
  347. selectUser(){
  348. let _this = this;
  349. this.userData.forEach(vo => {
  350. if(_this.form.certificateUserId == vo.id){
  351. _this.form.certificateId = vo.idNumber;
  352. console.log(vo,'vo');
  353. _this.form.certificateUserName=vo.realName
  354. }
  355. });
  356. },
  357. changeCompany(){
  358. this.$forceUpdate()
  359. this.updateDependentFieldValidation()
  360. },
  361. async init () {
  362. this.fromId = this.$route.query.id;
  363. if (this.$route.query.id != 0) {
  364. await this.getById(this.fromId)
  365. }
  366. this.queryProjectAndContract()//获取项目和合同段
  367. },
  368. //#region
  369. cancel() {
  370. const { value, certificateTypeValue, searchinput, pageindex, pagesize } = this.$route.query;
  371. this.$router.push({
  372. path: '/certificate/list',
  373. query: {
  374. value,
  375. certificateTypeValue,
  376. searchinput,
  377. pageindex,
  378. pagesize
  379. }
  380. });
  381. },
  382. savess () {//保存按钮
  383. this.$refs.form.validate(async valid => {
  384. if (valid) {
  385. let fromData = {
  386. certificateType: this.form.certificateType,
  387. certificateUserName: this.form.certificateUserName,
  388. certificateNumber: this.form.certificateNumber,
  389. certificatePassword: this.form.certificatePassword,
  390. certificateId: this.form.certificateId,
  391. pfxType: this.form.pfxType,
  392. wide: this.form.wide,
  393. high: this.form.high,
  394. }
  395. if (this.form.certificateFileUrl[0]&&this.form.certificateFileUrl[0].name&&this.form.certificateFileUrl[0].raw && this.form.certificateFileUrl[0].status === "ready") {
  396. let fileData = await this.addFileInfo(this.form.certificateFileUrl[0].raw);
  397. fromData.certificateFileUrl = fileData.link;
  398. fromData.certificateFileName = fileData.originalName;
  399. } else {
  400. // fromData.certificateFileUrl = this.form.certificateFileUrl[0].raw
  401. if(this.form.certificateFileUrl&&this.form.certificateFileUrl[0]&&this.form.certificateFileUrl[0].raw){
  402. fromData.certificateFileUrl = this.form.certificateFileUrl[0].raw
  403. }
  404. console.log(this.form.certificateFileUrl,'this.form.certificateFileUrl');
  405. }
  406. if (this.form.signatureFileUrl[0]&&this.form.signatureFileUrl[0].name && this.form.signatureFileUrl[0].status === "ready") {
  407. const url = await this.prePictureApi()
  408. if (url) {
  409. fromData.wide = this.form.wide
  410. fromData.high = this.form.high
  411. }
  412. let fileData = await this.compressAndUploadApi(this.form.signatureFileUrl[0].raw, fromData.wide, fromData.high);
  413. fromData.signatureFileUrl = fileData.link;
  414. fromData.signatureFileName = fileData.originalName;
  415. } else {
  416. if(this.form.signatureFileUrl&&this.form.signatureFileUrl[0]&&this.form.signatureFileUrl[0].raw){
  417. const url = await this.prePictureApi()
  418. if (url) {
  419. fromData.wide = this.form.wide
  420. fromData.high = this.form.high
  421. }
  422. fromData.signatureFileUrl = this.form.signatureFileUrl[0].raw
  423. }
  424. }
  425. let tag = true
  426. let enterpriseUnifiedCode = ''
  427. if (this.form.certificateType == 1) {
  428. fromData.certificateUserId = this.form.certificateUserId//关联用户
  429. } else {
  430. this.form.signPfxDeputieList.forEach(val => {
  431. if (!val.projectId || !val.contractId || !val.roleId) {
  432. tag = false
  433. return
  434. } else {
  435. if (enterpriseUnifiedCode) {
  436. enterpriseUnifiedCode += ','
  437. }
  438. enterpriseUnifiedCode += `${val.projectId}-${val.contractId}-${val.roleId}`
  439. }
  440. })
  441. fromData.projectContractRole = enterpriseUnifiedCode //关联项目
  442. fromData.enterpriseUnifiedCode = this.form.enterpriseUnifiedCode
  443. }
  444. console.log(fromData,'fromData');
  445. console.log(this.form,'fromData');
  446. if(this.form.company=='3'){
  447. fromData.certificateType=3
  448. }
  449. if (tag) {
  450. if (this.$route.query.id == 0) {
  451. this.save(fromData)//新增接口
  452. } else {
  453. fromData.id = this.form.id
  454. this.update(fromData)//编辑接口
  455. }
  456. } else {
  457. this.$message({
  458. type: 'error',
  459. message: "请填写完整关联项目!"
  460. })
  461. }
  462. }
  463. })
  464. },
  465. async compressAndUploadApi(file, wide, high) {
  466. let fromData = new FormData();
  467. fromData.append('file', file);
  468. fromData.append('wide', wide);
  469. fromData.append('high', high);
  470. const { data: res } = await compressAndUpload(fromData)
  471. if (res.code == 200) {
  472. return res.data;
  473. }
  474. },
  475. deleteSignPfxDeputie (key) {//删除关联项目
  476. this.form.signPfxDeputieList.splice(key, 1)
  477. },
  478. //#endregion
  479. //#region 上传文件得方法
  480. beforeRemove (file, fileList) {//证书文件删除回调
  481. this.form.certificateFileUrl = []
  482. },
  483. changecertificateFileUrl (file) {//证书文件变化回调
  484. this.form.certificateFileUrl = [file]
  485. },
  486. beforeRemove2 (file, fileList) {//签名体图片删除回调
  487. this.form.signatureFileUrl = []
  488. },
  489. changecertificateFileUrl2 (file) {//签名体图片变化回调
  490. this.form.signatureFileUrl = [file]
  491. this.form.wide = ''
  492. this.form.high = ''
  493. },
  494. pushSignPfxDeputieList () {//添加关联项目
  495. // this.form.signPfxDeputieList.unshift({
  496. // projectId: '',
  497. // contractId: '',
  498. // roleId: '',
  499. // })
  500. this.form.signPfxDeputieList.push({
  501. projectId: '',
  502. contractId: '',
  503. roleId: '',
  504. contractList: []
  505. })
  506. },
  507. focusContractSection (projectId, key) {//获取合同段数据
  508. this.projectMeiju.forEach(val => {
  509. if (val.id == projectId) {
  510. // this.ContractSection[key] = val.contractInfoList
  511. this.form.signPfxDeputieList[key].contractList = val.contractInfoList
  512. }
  513. })
  514. },
  515. changeProjectId (key) {//项目id发生改变
  516. this.form.signPfxDeputieList[key].contractId = ''
  517. },
  518. //#endregion
  519. //#region //接口
  520. async getById (id) {//获取详细信息
  521. const { data: res } = await getById({ id: id })
  522. console.log(res);
  523. if (res.code == 200) {
  524. this.form = res.data
  525. if(res.data.certificateType!==1){
  526. this.form.company=res.data.certificateType
  527. this.form.certificateType=2
  528. }
  529. if(res.data.certificateFileUrl&&this.form.certificateFileName){
  530. this.form.certificateFileUrl = [{ raw: res.data.certificateFileUrl, name: this.form.certificateFileName }]
  531. }else{
  532. this.form.certificateFileUrl=[]
  533. }
  534. if(res.data.signatureFileUrl&&this.form.signatureFileName){
  535. this.form.signatureFileUrl = [{ raw: res.data.signatureFileUrl, name: this.form.signatureFileName }]
  536. }else{
  537. this.form.signatureFileUrl = []
  538. }
  539. //宽度
  540. this.form.wide = res.data.wide ? res.data.wide : ''
  541. //高度
  542. this.form.high = res.data.high ? res.data.high : ''
  543. }
  544. },
  545. async save (da) {//新增
  546. const { data: res } = await save(da)
  547. if (res.code == 200) {
  548. this.$message({
  549. type: 'success',
  550. message: '新增电签成功!'
  551. })
  552. // this.$router.push('/certificate/list')
  553. this.$router.push({
  554. path: '/certificate/list',
  555. query: {
  556. value: this.$route.query.value,
  557. certificateTypeValue: this.$route.query.certificateTypeValue,
  558. searchinput: this.$route.query.searchinput,
  559. pageindex: this.$route.query.pageindex,
  560. pagesize: this.$route.query.pagesize
  561. }
  562. });
  563. }
  564. },
  565. async findUserByName () { //关联用户
  566. const { data: res } = await findUserByName()
  567. if (res.code == 200) {
  568. this.userData = res.data
  569. }
  570. },
  571. async queryRole () { //获取角色方
  572. const { data: res } = await queryRole()
  573. if (res.code == 200) {
  574. this.ParticipationConstruction = res.data
  575. }
  576. },
  577. async queryProjectAndContract () {//获取项目和合同段
  578. const { data: res } = await queryProjectAndContract()
  579. console.log(res);
  580. if (res.code == 200) {
  581. this.projectMeiju = res.data
  582. // this.form.signPfxDeputieList.forEach((val, key) => {
  583. // this.ContractSection.push(res.data[key].contractInfoList)
  584. // })
  585. if(this.form.signPfxDeputieList.length > 0){
  586. this.form.signPfxDeputieList.forEach((val, key) => {
  587. this.projectMeiju.forEach((project, key) => {
  588. if(val.projectId == project.id){
  589. val.contractList = project.contractInfoList;
  590. }
  591. })
  592. })
  593. }
  594. console.log(this.form.signPfxDeputieList);
  595. }
  596. },
  597. async findPfxType () {
  598. const { data: res } = await findPfxType({ typeOrStatus: 'pfx_type' })
  599. if (res.code == 200) {
  600. this.pfxType = res.data;
  601. }
  602. },
  603. async addFileInfo (file) {//上传图片
  604. let fromData = new FormData();
  605. fromData.append('file', file);
  606. const { data: res } = await addFileInfo(fromData)
  607. if (res.code == 200) {
  608. return res.data;
  609. }
  610. },
  611. async update (da) {//编辑保存接口
  612. const { data: res } = await update(da)
  613. if (res.code == 200) {
  614. this.$message({
  615. type: 'success',
  616. message: '修改电签成功!'
  617. })
  618. // this.$router.push('/certificate/list')
  619. this.$router.push({
  620. path: '/certificate/list',
  621. query: {
  622. value: this.$route.query.value,
  623. certificateTypeValue: this.$route.query.certificateTypeValue,
  624. searchinput: this.$route.query.searchinput,
  625. pageindex: this.$route.query.pageindex,
  626. pagesize: this.$route.query.pagesize
  627. }
  628. });
  629. }
  630. },
  631. //#endregion
  632. //检测参建方是否重复
  633. checkRoleRepeat(index){
  634. let cur = this.form.signPfxDeputieList[index];
  635. if(!cur.roleId){
  636. return;
  637. }
  638. this.form.signPfxDeputieList.forEach((info,i)=>{
  639. if(i === index){
  640. return;
  641. }
  642. if(info.contractId == cur.contractId && info.roleId == cur.roleId){
  643. this.$message({
  644. message: "关联的项目参见方不可重复",
  645. type: 'error'
  646. });
  647. this.form.signPfxDeputieList[index].roleId = '';
  648. }
  649. })
  650. },
  651. //改变证书类型
  652. changeCertificateType(val){
  653. if(val==1){
  654. console.log(this.form.company,'公司');
  655. this.form.company=2
  656. this.$forceUpdate();//强制刷新视图
  657. this.updateDependentFieldValidation()
  658. }
  659. },
  660. //预览
  661. async signaturePreview() {
  662. const form = this.form
  663. const isImg = form.signatureFileUrl.length <= 0
  664. if (isImg) {
  665. this.$message({
  666. message: '请先上传签名图片',
  667. type: 'error'
  668. })
  669. return false
  670. }
  671. const file = form.signatureFileUrl[0].raw
  672. if (!file) {
  673. this.$message({
  674. message: '请重新上传签名文件',
  675. type: 'error'
  676. })
  677. return false
  678. }
  679. const url = await this.prePictureApi()
  680. if (!url) return
  681. window.open(url, '_blank')
  682. },
  683. async prePictureApi() {
  684. const form = this.form
  685. const file = form.signatureFileUrl[0].raw
  686. if (!file) return false
  687. let fromData = new FormData();
  688. if (typeof file === 'object') {
  689. fromData.append('file', file);
  690. fromData.append('fileStr', '');
  691. } else {
  692. fromData.append('file', '');
  693. fromData.append('fileStr', file);
  694. }
  695. fromData.append('wide', form.wide);
  696. fromData.append('high', form.high);
  697. const { data: res } = await prePicture(fromData)
  698. const data = res.data;
  699. if (!data.preUrl) return false
  700. this.form.wide = data.wide //宽度
  701. this.form.high = data.high //高度
  702. return data.preUrl
  703. },
  704. stopClick() {},
  705. async nextClick() {
  706. let nextId = this.$route.query.nextId;
  707. // 处理需要加载下一页的情况
  708. if (nextId === 'nextPage') {
  709. nextId = await this.getNextPageData();
  710. }
  711. if (nextId) {
  712. // 获取下一条记录的详细信息
  713. await this.getById(nextId);
  714. // 更新当前ID和下一条ID参数
  715. const currentIndex = this.tableData.findIndex(row => row.id === nextId);
  716. let newNextId = null;
  717. if (currentIndex === this.tableData.length - 1) {
  718. newNextId = 'nextPage';
  719. } else {
  720. const nextRow = this.tableData[currentIndex + 1];
  721. newNextId = nextRow ? nextRow.id : null;
  722. }
  723. // 更新URL中的参数,保持浏览器历史正确
  724. this.$router.replace({
  725. query: {
  726. ...this.$route.query,
  727. id: nextId,
  728. nextId: newNextId,
  729. pageindex: nextId === 'nextPage'?this.currentPage+1:this.currentPage, // 更新当前页码
  730. }
  731. });
  732. } else {
  733. this.$message({
  734. type: 'info',
  735. message: '已经是最后一条记录'
  736. });
  737. }
  738. },
  739. // 在编辑页添加获取列表数据的方法,用于计算下一条
  740. async getTableData() {
  741. const { data: res } = await listpage({
  742. current: this.$route.query.pageindex || 1,
  743. size: this.$route.query.pagesize || 20,
  744. projectId: this.$route.query.value,
  745. certificateUserName: this.$route.query.searchinput,
  746. certificateType: this.$route.query.certificateTypeValue,
  747. });
  748. if (res.code === 200) {
  749. this.tableData = res.data.records;
  750. this.total = res.data.total;
  751. this.currentPage = res.data.current;
  752. }
  753. },
  754. async getNextPageData() {
  755. // 从路由参数中获取当前分页信息
  756. const currentPage = Number(this.$route.query.pageindex) || 1;
  757. const pageSize = Number(this.$route.query.pagesize) || 20;
  758. console.log(currentPage,'currentPage');
  759. // 调用列表接口查询下一页数据
  760. const { data: res } = await listpage({
  761. current: currentPage + 1, // 下一页
  762. size: pageSize,
  763. projectId: this.$route.query.value,
  764. certificateUserName: this.$route.query.searchinput,
  765. certificateType: this.$route.query.certificateTypeValue,
  766. });
  767. if (res.code === 200 && res.data.records.length > 0) {
  768. // 返回下一页第一条记录的ID
  769. return res.data.records[0].id;
  770. }
  771. return null; // 没有下一页数据
  772. },
  773. },
  774. created () {
  775. this.getOptions()
  776. this.init()
  777. this.queryRole()//获取角色方
  778. this.findUserByName()//关联用户
  779. this.findPfxType();//查询企业签章类型
  780. this.getTableData(); // 添加这行,获取列表数据用于计算下一条
  781. },
  782. mounted () {
  783. this.updateDependentFieldValidation();
  784. }
  785. }
  786. </script>
  787. <style lang="scss" scoped>
  788. </style>