addList.vue 13 KB

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