AddCertificateManagement.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="reply" ref = "replyModal">
  3. <a-modal
  4. :getContainer ='()=>$refs.replyModal'
  5. :title="(defult == 'add')?'新增':'编辑'"
  6. width="55%"
  7. :closable="true"
  8. @cancel="close"
  9. @ok="handleSubmit"
  10. :visible="visible"
  11. >
  12. <div class="table-page-search-wrapper">
  13. <a-form-model layout="inline" ref="form" :model="formState" :rules="validatorRules">
  14. <a-row :gutter="24">
  15. <a-col :md="8" :sm="8">
  16. <a-form-model-item label="证件名称" prop="name">
  17. <a-input placeholder="请输入" v-model="formState.name" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="8" :sm="8">
  21. <a-form-model-item label="证件所有人" prop="userId">
  22. <a-input placeholder="请输入" v-model="formState.userId"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="8" :sm="8">
  26. <a-form-model-item label="证件编号" prop="code">
  27. <a-input placeholder="请输入" v-model="formState.code"/>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="8" :sm="8">
  31. <a-form-model-item label="起始日期" >
  32. <a-date-picker
  33. style="width: 100%"
  34. placeholder="请选择起始时间"
  35. v-model="beDate"
  36. />
  37. </a-form-model-item>
  38. </a-col>
  39. <a-col :md="8" :sm="8">
  40. <a-form-model-item label="到期时间" >
  41. <a-date-picker
  42. style="width: 100%"
  43. placeholder="请选择到期时间"
  44. v-model="enDate"
  45. />
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="8" :sm="8">
  49. <a-form-model-item label="管理人" >
  50. <a-input placeholder="请输入" v-model="formState.manageId"/>
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :md="8" :sm="8">
  54. <a-form-model-item label="提前通知时间/月" prop="noticeMonth">
  55. <a-input placeholder="请输入" v-model="formState.noticeMonth"/>
  56. </a-form-model-item>
  57. </a-col>
  58. </a-row>
  59. <a-row :gutter="24">
  60. <a-col :md="24" :sm="8">
  61. <a-form-model-item label="备注信息" :labelCol="labelCol" :wrapperCol="wrapperCol" class="nresume" style="height:100px !important">
  62. <a-input type="textarea" placeholder="请输入" v-model="formState.remarks"/>
  63. </a-form-model-item>
  64. </a-col>
  65. </a-row>
  66. </a-form-model>
  67. </div>
  68. </a-modal>
  69. </div>
  70. </template>
  71. <script>
  72. import {
  73. managementAdd,
  74. managementEdit
  75. } from '@api/oa/cd-certificate-management'
  76. import moment from 'moment'
  77. export default {
  78. name: 'AddCertificateManagement',
  79. components: {
  80. moment
  81. },
  82. data () {
  83. return {
  84. visible:false,
  85. defult:'add',
  86. formState:{
  87. endDate:'',
  88. beginDate:''
  89. },
  90. confirmLoading: false,
  91. enDate:'',
  92. beDate:'',
  93. validatorRules: {
  94. name:[{required: true, message: '证件名称不能为空!'}],
  95. userId:[{required: true, message: '证件所有人不能为空!'}],
  96. noticeMonth:[ { pattern: new RegExp(/^([0-9]{1,2}|100)$/, "g"), message: '只能输入正整数!'}],
  97. code:[{required: true, message: '使用者不能为空!'}],
  98. },
  99. }
  100. },
  101. created () {
  102. },
  103. computed: {
  104. },
  105. methods: {
  106. close(){
  107. this.visible = false
  108. this.formState={}
  109. this.defult='add',
  110. this.enDate=''
  111. this.beDate=''
  112. },
  113. handleSubmit(){
  114. this.$refs.form.validate(valid => {
  115. if(valid){
  116. if(this.beDate == '' || !this.beDate){
  117. this.$message.error('请选择起始时间');
  118. return;
  119. }
  120. if(this.enDate == '' || !this.enDate){
  121. this.$message.error('请选择结束时间');
  122. return;
  123. }
  124. this.formState.beginDate = moment(this.beDate).format('YYYY-MM-DD');
  125. this.formState.endDate = moment(this.enDate).format('YYYY-MM-DD');
  126. if(this.defult == 'add'){
  127. managementAdd(this.formState).then(res => {
  128. if (res.success) {
  129. this.$message.success('新增成功');
  130. this.close()
  131. this.$emit('close')
  132. }else{
  133. this.$message.error(res.message);
  134. }
  135. })
  136. }else {
  137. managementEdit(this.formState).then(res => {
  138. if (res.success) {
  139. this.$message.success('编辑成功');
  140. this.close()
  141. this.$emit('close')
  142. }else{
  143. this.$message.error(res.message);
  144. this.$message.error(res.message);
  145. }
  146. })
  147. }
  148. }
  149. })
  150. }
  151. }
  152. }
  153. </script>
  154. <style scoped lang="less">
  155. // /deep/.ant-form{
  156. // display: flex;
  157. // width: 100%;
  158. // flex-wrap: wrap;
  159. // justify-content: start;
  160. // }
  161. // /deep/ .ant-form-item{
  162. // display: flex;
  163. // width: 32%;
  164. // justify-content: start;
  165. // }
  166. // /deep/ .ant-form-item-label{
  167. // width: 37%;
  168. // }
  169. // .nresume{
  170. // width: 100% !important;
  171. // }
  172. // /deep/ .nresume .ant-form-item-label{
  173. // width: 12% !important;
  174. // }
  175. // /deep/ .nresume .ant-form-item-control-wrapper{
  176. // width: 82% !important;
  177. // }
  178. /deep/ .nresume .ant-input{
  179. height: 100px !important;
  180. }
  181. </style>