addList.vue 16 KB

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