AddCertificateManagement.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="reply" ref = "replyModal">
  3. <a-modal
  4. :getContainer ='()=>$refs.replyModal'
  5. :title="(defult == 'add')?'新增':'编辑'"
  6. width="75%"
  7. :closable="true"
  8. @cancel="close"
  9. @ok="handleSubmit"
  10. :visible="visible"
  11. destroyOnClose
  12. >
  13. <div class="table-page-search-wrapper">
  14. <a-form-model layout="inline" ref="form" :model="formState" :rules="validatorRules">
  15. <a-row :gutter="24">
  16. <a-col :md="8" :sm="8">
  17. <a-form-model-item label="证件名称" prop="name">
  18. <a-input placeholder="请输入" v-model="formState.name" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="8" :sm="8">
  22. <a-form-model-item label="证件所有人" prop="userId" >
  23. <j-search-select-tag v-model="formState.userId" placeholder="请选择用户名称"
  24. dict="sys_user,realname,username" @search="searchName" />
  25. </a-form-model-item>
  26. <!-- <a-form-model-item label="证件所有人" prop="userId" >
  27. <j-search-select-tag v-model="formState.userId" placeholder="请选择用户名称"
  28. dict="sys_user,realname,username" @search="searchName" style="width:71%" v-if="inputMethod =='select'"/>
  29. <a-input placeholder="请输入" v-model="formState.name" style="width:71%" v-if="inputMethod =='input'"/>
  30. <a-button type="primary" style="margin-left: 8%;" v-model="formState.name" @click="changeInputMethod">切换</a-button>
  31. </a-form-model-item> -->
  32. </a-col>
  33. <a-col :md="8" :sm="8">
  34. <a-form-model-item label="证件编号" prop="code">
  35. <a-input placeholder="请输入" v-model="formState.code"/>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="8" :sm="8">
  39. <a-form-model-item label="起始日期" prop="beginDate" >
  40. <a-date-picker
  41. style="width: 100%"
  42. placeholder="请选择起始时间"
  43. v-model="formState.beginDate"
  44. />
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="8" :sm="8">
  48. <a-form-model-item label="到期时间" prop="endDate">
  49. <a-date-picker
  50. style="width: 100%"
  51. placeholder="请选择到期时间"
  52. v-model="formState.endDate"
  53. />
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :md="8" :sm="8">
  57. <a-form-model-item label="管理人" prop="manageId">
  58. <j-search-select-tag v-model="formState.manageId" placeholder="请选择用户名称"
  59. dict="sys_user,realname,username"/>
  60. <!-- <a-input placeholder="请输入" v-model="formState.manageId"/> -->
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col :md="8" :sm="8">
  64. <a-form-model-item label="提前通知时间/月" prop="noticeMonth">
  65. <a-input placeholder="请输入" v-model="formState.noticeMonth"/>
  66. </a-form-model-item>
  67. </a-col>
  68. <!-- <a-col :md="8" :sm="8">
  69. <a-form-model-item label="是否邮件通知" prop="isMessage">
  70. <a-select v-model="formState.isMessage">
  71. <a-select-option value="1">是</a-select-option>
  72. <a-select-option value="0">否</a-select-option>
  73. </a-select>
  74. </a-form-model-item>
  75. </a-col> -->
  76. </a-row>
  77. <a-row :gutter="24">
  78. <a-col :md="24" :sm="8">
  79. <a-form-item label="附件上传" class="upload">
  80. <a-upload :action="url.fileUpload" @change="aaa" :default-file-list="fileList" list-type="picture" :beforeUpload="beforeFileUpload">
  81. <a-button>
  82. <a-icon type="upload"/>上传
  83. </a-button>
  84. <div v-if="defult == 'edit'">
  85. <a @click="downloadFile">{{formState.enclosure}}</a>
  86. </div>
  87. </a-upload>
  88. </a-form-item>
  89. <!-- <a-form-model-item label="附件上传">
  90. <j-upload v-model="formState.enclosure">上传</j-upload>
  91. </a-form-model-item> -->
  92. </a-col>
  93. </a-row>
  94. <a-row :gutter="24">
  95. <a-col :md="24" :sm="8">
  96. <a-form-model-item label="备注信息" class="nresume" style="height:100px !important">
  97. <a-input type="textarea" placeholder="请输入" v-model="formState.remarks"/>
  98. </a-form-model-item>
  99. </a-col>
  100. </a-row>
  101. </a-form-model>
  102. </div>
  103. </a-modal>
  104. </div>
  105. </template>
  106. <script>
  107. import {
  108. managementAdd,
  109. managementEdit
  110. } from '@api/oa/cd-certificate-management'
  111. import JUpload from '@/components/jeecg/JUpload'
  112. import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
  113. import moment from 'moment'
  114. import { downFile } from '@/api/manage'
  115. export default {
  116. name: 'AddCertificateManagement',
  117. components: {
  118. moment,
  119. JUpload,
  120. JSearchSelectTag
  121. },
  122. data () {
  123. return {
  124. visible:false,
  125. defult:'add',
  126. formState:{
  127. endDate:'',
  128. beginDate:'',
  129. isMessage:'1'
  130. },
  131. inputMethod:'select',
  132. fileList:[],
  133. confirmLoading: false,
  134. validatorRules: {
  135. name:[{required: true, message: '证件名称不能为空!'}],
  136. userId:[{required: true, message: '证件所有人不能为空!'}],
  137. noticeMonth:[{required: true, message: '提前通知时间不能为空!'},{ pattern: new RegExp(/^([0-9]{1,2}|100)$/, "g"), message: '只能输入正整数!'}],
  138. code:[{required: true, message: '证件编号不能为空!'}],
  139. manageId:[{required: true, message: '管理人不能为空!'}],
  140. isMessage:[{required: true, message: '是否邮件通知不能为空!'}],
  141. beginDate:[{required: true, message: '起始日期不能为空!'}],
  142. endDate:[{required: true, message: '到期时间不能为空!'}],
  143. },
  144. url: {
  145. fileUpload: window._CONFIG['domianURL'] + "/sys/common/upload",
  146. dowfile:window._CONFIG['domianURL'] +"/sys/common/static/"
  147. }
  148. }
  149. },
  150. created () {
  151. },
  152. computed: {
  153. },
  154. methods: {
  155. //下载
  156. downloadFile(){
  157. window.location.href =this.url.dowfile + this.formState.enclosure;
  158. },
  159. beforeFileUpload(file, fileList){
  160. if(fileList.lenght >1 || this.fileList.length>=1){
  161. this.$message.error('只可上传一个文件');
  162. }
  163. },
  164. aaa(info) {
  165. if(info.file.status !=='error'){
  166. this.formState.enclosure = info.file.response.message
  167. this.fileList.push(info.file.response.message)
  168. }else{
  169. this.formState.enclosure = ''
  170. }
  171. },
  172. close(){
  173. this.visible = false
  174. this.formState={}
  175. this.defult='add',
  176. this.enDate=''
  177. this.beDate=''
  178. this.fileList =[]
  179. },
  180. changeInputMethod(){
  181. if(this.inputMethod == 'select'){
  182. this.inputMethod = 'input'
  183. }else{
  184. this.inputMethod = 'select'
  185. }
  186. },
  187. handleSubmit(){
  188. this.$refs.form.validate(valid => {
  189. if(valid){
  190. // this.formState.isMessage = '是'
  191. var newobj = this.formState
  192. newobj.beginDate = moment(this.formState.beginDate).format('YYYY-MM-DD');
  193. newobj.endDate = moment(this.formState.endDate).format('YYYY-MM-DD');
  194. if(this.defult == 'add'){
  195. managementAdd(newobj).then(res => {
  196. if (res.success) {
  197. this.$message.success('新增成功');
  198. this.close()
  199. this.$emit('close')
  200. }else{
  201. this.$message.error(res.message);
  202. }
  203. })
  204. }else {
  205. managementEdit(newobj).then(res => {
  206. if (res.success) {
  207. this.$message.success('编辑成功');
  208. this.close()
  209. this.$emit('close')
  210. }else{
  211. this.$message.error(res.message);
  212. this.$message.error(res.message);
  213. }
  214. })
  215. }
  216. }
  217. })
  218. }
  219. }
  220. }
  221. </script>
  222. <style scoped lang="less">
  223. // /deep/.ant-form{
  224. // display: flex;
  225. // width: 100%;
  226. // flex-wrap: wrap;
  227. // justify-content: start;
  228. // }
  229. // /deep/ .ant-form-item{
  230. // display: flex;
  231. // width: 32%;
  232. // justify-content: start;
  233. // }
  234. // /deep/ .ant-form-item-label{
  235. // width: 37%;
  236. // }
  237. // .nresume{
  238. // width: 100% !important;
  239. // }
  240. // /deep/ .nresume .ant-form-item-label{
  241. // width: 12% !important;
  242. // }
  243. // /deep/ .nresume .ant-form-item-control-wrapper{
  244. // width: 82% !important;
  245. // }
  246. /deep/ .nresume .ant-input{
  247. height: 100px !important;
  248. }
  249. /deep/ .upload .ant-form-item-control{
  250. display: contents !important;
  251. }
  252. </style>