addList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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:100%;"
  14. >
  15. <el-radio-group v-model="form.certificateType">
  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="certificateUserName"
  23. style="width:45%;"
  24. >
  25. <el-input
  26. v-model="form.certificateUserName"
  27. style="width:400px;"
  28. placeholder="请输入内容"
  29. ></el-input>
  30. </el-form-item>
  31. <el-form-item
  32. label="所持证书者身份证ID"
  33. prop="certificateId"
  34. v-if="form.certificateType==1"
  35. style="width:45%;"
  36. >
  37. <el-input
  38. v-model="form.certificateId"
  39. style="width:400px;"
  40. placeholder="请输入内容"
  41. ></el-input>
  42. </el-form-item>
  43. <el-form-item
  44. label="企业统一社会信用代码"
  45. style="width:45%;"
  46. prop="enterpriseUnifiedCode"
  47. v-else
  48. >
  49. <el-input
  50. v-model="form.enterpriseUnifiedCode"
  51. style="width:400px;"
  52. placeholder="请输入内容"
  53. ></el-input>
  54. </el-form-item>
  55. <el-form-item
  56. label="证书编号"
  57. prop="certificateNumber"
  58. style="width:45%;"
  59. >
  60. <el-input
  61. v-model="form.certificateNumber"
  62. style="width:400px;"
  63. placeholder="请输入内容"
  64. ></el-input>
  65. </el-form-item>
  66. <el-form-item
  67. label="证书密码"
  68. prop="certificatePassword"
  69. style="width:45%;"
  70. >
  71. <el-input
  72. v-model="form.certificatePassword"
  73. style="width:400px;"
  74. placeholder="请输入内容"
  75. ></el-input>
  76. </el-form-item>
  77. <el-form-item
  78. label="证书文件"
  79. style="width:45%;"
  80. prop="certificateFileUrl"
  81. >
  82. <el-upload
  83. class="upload-demo"
  84. action="#"
  85. multiple
  86. :limit="2"
  87. :auto-upload="false"
  88. accept='.pfx'
  89. :file-list="form.certificateFileUrl"
  90. :before-remove="beforeRemove"
  91. :on-change="changecertificateFileUrl"
  92. >
  93. <el-button
  94. size="small"
  95. type="primary"
  96. >上传文件</el-button>
  97. <div
  98. slot="tip"
  99. class="el-upload__tip"
  100. >支持上传文件格式为pfx文件</div>
  101. </el-upload>
  102. </el-form-item>
  103. <el-form-item
  104. label="关联用户"
  105. style="width:45%;"
  106. prop="certificateUserId"
  107. v-if="form.certificateType==1"
  108. >
  109. <el-select
  110. filterable
  111. v-model="form.certificateUserId"
  112. style="width:400px;"
  113. placeholder="请选择"
  114. @change="selectUser"
  115. >
  116. <el-option
  117. v-for="item in userData"
  118. :key="item.id"
  119. :label="item.name"
  120. :value="item.id"
  121. >
  122. </el-option>
  123. </el-select>
  124. </el-form-item>
  125. <el-form-item
  126. label="签章类型"
  127. style="width:45%;"
  128. prop="pfxType"
  129. v-else
  130. >
  131. <el-select
  132. v-model="form.pfxType"
  133. style="width:400px;"
  134. placeholder="请选择"
  135. >
  136. <el-option
  137. v-for="item in pfxType"
  138. :key="item.dictKey"
  139. :label="item.dictValue"
  140. :value="item.dictKey"
  141. >
  142. </el-option>
  143. </el-select>
  144. </el-form-item>
  145. <el-form-item
  146. label="签名体图片"
  147. style="width:100%;"
  148. prop="signatureFileUrl"
  149. >
  150. <el-upload
  151. class="upload-demo"
  152. action="#"
  153. multiple
  154. :limit="2"
  155. :auto-upload="false"
  156. accept='.jpg,.png'
  157. :file-list="form.signatureFileUrl"
  158. :before-remove="beforeRemove2"
  159. :on-change="changecertificateFileUrl2"
  160. >
  161. <el-button
  162. size="small"
  163. type="primary"
  164. >上传文件</el-button>
  165. <div
  166. slot="tip"
  167. class="el-upload__tip"
  168. >支持上传文件格式为JPG/PNG</div>
  169. </el-upload>
  170. </el-form-item>
  171. <el-form-item
  172. label="关联项目"
  173. tyle="width:100%;"
  174. prop="signPfxDeputieList"
  175. v-if="form.certificateType==2"
  176. >
  177. <i
  178. class="el-icon-circle-plus"
  179. style="color:red;font-size:24px;line-height:40px;cursor: pointer;"
  180. @click="pushSignPfxDeputieList"
  181. ></i>
  182. <div
  183. v-for="(item,key) in form.signPfxDeputieList"
  184. :key='key'
  185. >
  186. <!-- 项目 -->
  187. <el-select
  188. style="width:300px;"
  189. class="martop20"
  190. v-model="form.signPfxDeputieList[key].projectId"
  191. placeholder="请选择"
  192. @change="changeProjectId(key)"
  193. >
  194. <el-option
  195. v-for="item in projectMeiju"
  196. :key="item.id"
  197. :label="item.name"
  198. :value="item.id"
  199. >
  200. </el-option>
  201. </el-select>
  202. <!-- 合同段 -->
  203. <el-select
  204. style="width:300px;"
  205. class="marleft20 martop20"
  206. @focus="focusContractSection(form.signPfxDeputieList[key].projectId,key)"
  207. :disabled='!form.signPfxDeputieList[key].projectId'
  208. v-model="form.signPfxDeputieList[key].contractId"
  209. placeholder="请选择"
  210. @change="checkRoleRepeat(key)"
  211. >
  212. <el-option
  213. v-for="item in form.signPfxDeputieList[key].contractList"
  214. :key="item.id"
  215. :label="item.name"
  216. :value="item.id"
  217. >
  218. </el-option>
  219. </el-select>
  220. <el-select
  221. class="marleft20 martop20"
  222. style="width:300px;"
  223. v-model="form.signPfxDeputieList[key].roleId"
  224. placeholder="请选择参建方"
  225. @change="checkRoleRepeat(key)"
  226. >
  227. <el-option
  228. v-for="item in ParticipationConstruction"
  229. :key="item.id"
  230. :label="item.roleName"
  231. :value="item.id"
  232. >
  233. </el-option>
  234. </el-select>
  235. <i
  236. class="el-icon-error marleft10"
  237. @click="deleteSignPfxDeputie(key)"
  238. style="fontSize:20px;color:#F0630A;cursor: pointer;"
  239. ></i>
  240. </div>
  241. <!-- signPfxDeputieList -->
  242. </el-form-item>
  243. </el-form>
  244. <div class="flexCenter">
  245. <el-button @click="cancel">取消</el-button>
  246. <el-button
  247. class="marleft30"
  248. type="primary"
  249. v-throttle='2000'
  250. @click="savess()"
  251. >保存</el-button>
  252. </div>
  253. </basic-container>
  254. </template>
  255. <script>
  256. import { save, getById, findUserByName, queryRole, queryProjectAndContract, addFileInfo, update, findPfxType } from "@/api/certificate/list";
  257. export default {
  258. data () {
  259. return {
  260. form: {
  261. certificateType: 1,
  262. certificateUserName: '',
  263. certificateId: '',//所持证书者身份证ID
  264. enterpriseUnifiedCode: '',//企业统一社会信用代码
  265. certificateNumber: '',
  266. certificatePassword: '',
  267. certificateUserId: '',
  268. pfxType: '',
  269. certificateFileUrl: [],//证书文件
  270. certificateFileName: '',//证书文件名称
  271. signatureFileUrl: [],//签名体图片
  272. signatureFileName: '',//签名体图片文件名称
  273. signPfxDeputieList: [],
  274. },
  275. rules: {
  276. certificateType: [{ required: true, message: '请选择', trigger: 'change' }],
  277. certificateUserName: [{ required: true, message: '请输入证书所有者', trigger: 'blur' }],
  278. // certificateId: [{ required: true, message: '请输入所持证书者身份ID', trigger: 'blur' }],
  279. enterpriseUnifiedCode: [{ required: true, message: '请输入企业统一社会信用代码', trigger: 'blur' }],
  280. // certificateNumber: [{ required: true, message: '请输入证书编号', trigger: 'blur' }],
  281. // certificatePassword: [{ required: true, message: '请输入证书密码', trigger: 'blur' }],
  282. certificateUserId: [{ required: true, message: '请选择关联用户', trigger: 'change' }],
  283. // certificateFileUrl: [{ required: true, message: '请选择证书文件', trigger: 'change' }],
  284. // signatureFileUrl: [{ required: true, message: '请选择签名体图片', trigger: 'change', }],
  285. signPfxDeputieList: [{ required: true, message: '请设置关联项目', trigger: 'change', }],
  286. pfxType: [{ required: true, message: '请选择签章类型', trigger: 'change', }],
  287. },
  288. ParticipationConstruction: [],//参见项目方
  289. projectMeiju: [],//项目
  290. ContractSection: [],//合同段
  291. userData: [],//关联用户
  292. pfxType: []//
  293. }
  294. },
  295. methods: {
  296. selectUser(){
  297. let _this = this;
  298. this.userData.forEach(vo => {
  299. if(_this.form.certificateUserId == vo.id){
  300. _this.form.certificateId = vo.idNumber;
  301. }
  302. });
  303. },
  304. async init () {
  305. if (this.$route.query.id != 0) {
  306. await this.getById()
  307. }
  308. this.queryProjectAndContract()//获取项目和合同段
  309. },
  310. //#region
  311. cancel () {//取消按钮
  312. this.$router.push('/certificate/list')
  313. },
  314. savess () {//保存按钮
  315. this.$refs.form.validate(async valid => {
  316. if (valid) {
  317. let fromData = {
  318. certificateType: this.form.certificateType,
  319. certificateUserName: this.form.certificateUserName,
  320. certificateNumber: this.form.certificateNumber,
  321. certificatePassword: this.form.certificatePassword,
  322. certificateId: this.form.certificateId,
  323. pfxType: this.form.pfxType
  324. }
  325. if (this.form.certificateFileUrl[0].name && this.form.certificateFileUrl[0].status === "ready") {
  326. let fileData = await this.addFileInfo(this.form.certificateFileUrl[0].raw);
  327. fromData.certificateFileUrl = fileData.link;
  328. fromData.certificateFileName = fileData.originalName;
  329. } else {
  330. fromData.certificateFileUrl = this.form.certificateFileUrl[0].raw
  331. }
  332. if (this.form.signatureFileUrl[0].name && this.form.signatureFileUrl[0].status === "ready") {
  333. let fileData = await this.addFileInfo(this.form.signatureFileUrl[0].raw);
  334. fromData.signatureFileUrl = fileData.link;
  335. fromData.signatureFileName = fileData.originalName;
  336. } else {
  337. fromData.signatureFileUrl = this.form.signatureFileUrl[0].raw
  338. }
  339. let tag = true
  340. let enterpriseUnifiedCode = ''
  341. if (this.form.certificateType == 1) {
  342. fromData.certificateUserId = this.form.certificateUserId//关联用户
  343. } else {
  344. this.form.signPfxDeputieList.forEach(val => {
  345. if (!val.projectId || !val.contractId || !val.roleId) {
  346. tag = false
  347. return
  348. } else {
  349. if (enterpriseUnifiedCode) {
  350. enterpriseUnifiedCode += ','
  351. }
  352. enterpriseUnifiedCode += `${val.projectId}-${val.contractId}-${val.roleId}`
  353. }
  354. })
  355. fromData.projectContractRole = enterpriseUnifiedCode //关联项目
  356. fromData.enterpriseUnifiedCode = this.form.enterpriseUnifiedCode
  357. }
  358. if (tag) {
  359. if (this.$route.query.id == 0) {
  360. this.save(fromData)//新增接口
  361. } else {
  362. fromData.id = this.form.id
  363. this.update(fromData)//编辑接口
  364. }
  365. } else {
  366. this.$message({
  367. type: 'error',
  368. message: "请填写完整关联项目!"
  369. })
  370. }
  371. }
  372. })
  373. },
  374. deleteSignPfxDeputie (key) {//删除关联项目
  375. this.form.signPfxDeputieList.splice(key, 1)
  376. },
  377. //#endregion
  378. //#region 上传文件得方法
  379. beforeRemove (file, fileList) {//证书文件删除回调
  380. this.form.certificateFileUrl = []
  381. },
  382. changecertificateFileUrl (file) {//证书文件变化回调
  383. this.form.certificateFileUrl = [file]
  384. },
  385. beforeRemove2 (file, fileList) {//签名体图片删除回调
  386. this.form.signatureFileUrl = []
  387. },
  388. changecertificateFileUrl2 (file) {//签名体图片变化回调
  389. this.form.signatureFileUrl = [file]
  390. },
  391. pushSignPfxDeputieList () {//添加关联项目
  392. // this.form.signPfxDeputieList.unshift({
  393. // projectId: '',
  394. // contractId: '',
  395. // roleId: '',
  396. // })
  397. this.form.signPfxDeputieList.push({
  398. projectId: '',
  399. contractId: '',
  400. roleId: '',
  401. contractList: []
  402. })
  403. },
  404. focusContractSection (projectId, key) {//获取合同段数据
  405. this.projectMeiju.forEach(val => {
  406. if (val.id == projectId) {
  407. // this.ContractSection[key] = val.contractInfoList
  408. this.form.signPfxDeputieList[key].contractList = val.contractInfoList
  409. }
  410. })
  411. },
  412. changeProjectId (key) {//项目id发生改变
  413. this.form.signPfxDeputieList[key].contractId = ''
  414. },
  415. //#endregion
  416. //#region //接口
  417. async getById () {//获取详细信息
  418. const { data: res } = await getById({ id: this.$route.query.id })
  419. console.log(res);
  420. if (res.code == 200) {
  421. this.form = res.data
  422. this.form.certificateFileUrl = [{ raw: res.data.certificateFileUrl, name: this.form.certificateFileName }]
  423. this.form.signatureFileUrl = [{ raw: res.data.signatureFileUrl, name: this.form.signatureFileName }]
  424. }
  425. },
  426. async save (da) {//新增
  427. const { data: res } = await save(da)
  428. if (res.code == 200) {
  429. this.$message({
  430. type: 'success',
  431. message: '新增电签成功!'
  432. })
  433. this.$router.push('/certificate/list')
  434. }
  435. },
  436. async findUserByName () { //关联用户
  437. const { data: res } = await findUserByName()
  438. if (res.code == 200) {
  439. this.userData = res.data
  440. }
  441. },
  442. async queryRole () { //获取角色方
  443. const { data: res } = await queryRole()
  444. if (res.code == 200) {
  445. this.ParticipationConstruction = res.data
  446. }
  447. },
  448. async queryProjectAndContract () {//获取项目和合同段
  449. const { data: res } = await queryProjectAndContract()
  450. console.log(res);
  451. if (res.code == 200) {
  452. this.projectMeiju = res.data
  453. // this.form.signPfxDeputieList.forEach((val, key) => {
  454. // this.ContractSection.push(res.data[key].contractInfoList)
  455. // })
  456. if(this.form.signPfxDeputieList.length > 0){
  457. this.form.signPfxDeputieList.forEach((val, key) => {
  458. this.projectMeiju.forEach((project, key) => {
  459. if(val.projectId == project.id){
  460. val.contractList = project.contractInfoList;
  461. }
  462. })
  463. })
  464. }
  465. console.log(this.form.signPfxDeputieList);
  466. }
  467. },
  468. async findPfxType () {
  469. const { data: res } = await findPfxType({ typeOrStatus: 'pfx_type' })
  470. if (res.code == 200) {
  471. this.pfxType = res.data;
  472. }
  473. },
  474. async addFileInfo (file) {//上传图片
  475. let fromData = new FormData();
  476. fromData.append('file', file);
  477. const { data: res } = await addFileInfo(fromData)
  478. if (res.code == 200) {
  479. return res.data;
  480. }
  481. },
  482. async update (da) {//编辑保存接口
  483. const { data: res } = await update(da)
  484. if (res.code == 200) {
  485. this.$message({
  486. type: 'success',
  487. message: '修改电签成功!'
  488. })
  489. this.$router.push('/certificate/list')
  490. }
  491. },
  492. //#endregion
  493. //检测参建方是否重复
  494. checkRoleRepeat(index){
  495. let cur = this.form.signPfxDeputieList[index];
  496. if(!cur.roleId){
  497. return;
  498. }
  499. this.form.signPfxDeputieList.forEach((info,i)=>{
  500. if(i === index){
  501. return;
  502. }
  503. if(info.contractId == cur.contractId && info.roleId == cur.roleId){
  504. this.$message({
  505. message: "关联的项目参见方不可重复",
  506. type: 'error'
  507. });
  508. this.form.signPfxDeputieList[index].roleId = '';
  509. }
  510. })
  511. }
  512. },
  513. created () {
  514. this.init()
  515. this.queryRole()//获取角色方
  516. this.findUserByName()//关联用户
  517. this.findPfxType();//查询企业签章类型
  518. },
  519. mounted () {
  520. }
  521. }
  522. </script>
  523. <style lang="scss" scoped>
  524. </style>