华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
6.5 KiB

  1. G<template>
  2. <div>
  3. <!-- 新增试验间弹窗 -->
  4. <el-dialog :title="$t('page.business.study.studyMethod.scff')" :visible.sync="open" width="400px" append-to-body
  5. :close-on-click-modal="false">
  6. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  7. <div class="sbzdtcma"> <input type="text"> <input type="password" show-password> </div>
  8. <el-row>
  9. <el-col :span="24">
  10. <el-form-item :label="$t('page.business.study.studyMethod.mc')" prop="ffmc">
  11. <el-input type="text" v-model="form.ffmc" maxlength="20"
  12. :placeholder="$t('form.placeholderInput')" />
  13. </el-form-item>
  14. </el-col>
  15. </el-row>
  16. <el-row>
  17. <!-- 方法 -->
  18. <el-col :span="24">
  19. <el-form-item :label="$t('page.business.study.studyMethod.ff')" prop="fileUlr">
  20. <el-upload class="upload-demo" :before-upload="handleBeforeUpload" :on-error="handleUploadError"
  21. :on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="true" :headers="headers"
  22. :on-remove="handleRemove" :action="uploadFileUrl" accept=".pdf" :limit="1" :file-list="fileList">
  23. <el-button size="small" type="primary">{{ $t('page.business.study.studyMethod.scwj') }}</el-button>
  24. <div slot="tip" class="el-upload__tip">{{ $t('page.business.study.studyMethod.wjm') }}</div>
  25. </el-upload>
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. <el-row>
  30. <el-col :span="24">
  31. <el-form-item :label="$t('form.qmyy')" prop="qmyy">
  32. <el-input type="text" :value="form.qmyy" maxlength="50" disabled
  33. :placeholder="$t('form.placeholderInput')" />
  34. </el-form-item>
  35. </el-col>
  36. </el-row>
  37. <el-row>
  38. <el-col :span="24">
  39. <el-form-item :label="$t('form.remark')" prop="qmbz">
  40. <el-input type="textarea" v-model="form.qmbz" :rows="2" maxlength="500"
  41. :placeholder="$t('form.placeholderInput')">
  42. </el-input>
  43. </el-form-item>
  44. </el-col>
  45. </el-row>
  46. <el-row>
  47. <el-col :span="24">
  48. <el-form-item :label="$t('form.signer')">
  49. <el-input type="text" v-model="nickName" maxlength="50" disabled
  50. :placeholder="$t('form.placeholderInput')" />
  51. </el-form-item>
  52. </el-col>
  53. </el-row>
  54. <el-row>
  55. <el-col :span="24">
  56. <el-form-item :label="$t('form.password')" prop="qmrmm">
  57. <div class="sbzdtcma"> <input type="text"></div>
  58. <el-input type="password" v-model="form.qmrmm" maxlength="20" show-password
  59. :placeholder="$t('form.placeholderInput')" />
  60. </el-form-item>
  61. </el-col>
  62. </el-row>
  63. </el-form>
  64. <div slot="footer" class="dialog-footer">
  65. <el-button type="primary" @click="save">{{ $t('form.confirm') }}</el-button>
  66. <el-button @click="cancel">{{ $t('form.cancel') }}</el-button>
  67. </div>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import { studyMethod_save } from "@/api/business/study/studyMethod"
  73. import { mapGetters } from 'vuex'
  74. import { getToken } from "@/utils/auth"
  75. export default {
  76. name: "XzSyj",
  77. components: {},
  78. data() {
  79. return {
  80. open: false,
  81. form: {
  82. mc: '',
  83. fileUrl: '',
  84. fileName: ''
  85. },
  86. uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload",
  87. headers: {
  88. Authorization: "Bearer " + getToken(),
  89. },
  90. fileList: [],
  91. rules: {
  92. ffmc: [{
  93. required: true,
  94. message: ' ',
  95. trigger: 'blur'
  96. }],
  97. fileUrl: [{
  98. required: true,
  99. message: ' ',
  100. trigger: 'blur'
  101. }],
  102. qmrmm: [{
  103. required: true,
  104. message: ' ',
  105. trigger: 'blur'
  106. }],
  107. }
  108. }
  109. },
  110. computed: {
  111. ...mapGetters([
  112. 'nickName','name'
  113. ]),
  114. },
  115. created() {
  116. },
  117. methods: {
  118. cancel() {
  119. this.open = false
  120. },
  121. reset() {
  122. this.form = {
  123. ffmc: null,
  124. fileUrl: '',
  125. fileName: '',
  126. qmrmm: null,
  127. kssyyl: '',
  128. qmyy: '上传文件',
  129. bjbz: ''
  130. }
  131. this.fileList = []
  132. this.resetForm("form")
  133. },
  134. show(study) {
  135. this.reset()
  136. this.form.studyId = study.id
  137. this.form.studySubjectId = study.studySubjectId
  138. this.open = true
  139. },
  140. save() {
  141. this.$refs["form"].validate(valid => {
  142. if (valid) {
  143. studyMethod_save(this.form).then(response => {
  144. this.open = false
  145. this.$emit('callback')
  146. })
  147. }
  148. })
  149. },
  150. // 上传前校检格式和大小
  151. handleBeforeUpload(file) {
  152. let fileType = ['pdf']
  153. // 校检文件类型
  154. if (fileType) {
  155. const fileName = file.name.split('.')
  156. const fileExt = fileName[fileName.length - 1]
  157. const isTypeOk = fileType.indexOf(fileExt) >= 0
  158. if (!isTypeOk) {
  159. this.$modal.msgError('文件格式不正确,请上传pdf格式文件!')
  160. return false
  161. }
  162. }
  163. // 校检文件名是否包含特殊字符
  164. if (file.name.includes(',')) {
  165. this.$modal.msgError('文件名不正确,不能包含英文逗号!')
  166. return false
  167. }
  168. this.$modal.loading("正在上传文件,请稍候...")
  169. this.number++
  170. return true
  171. },
  172. // 文件个数超出
  173. handleExceed() {
  174. this.$modal.msgError('上传文件数量不能超过1个!')
  175. },
  176. // 上传失败
  177. handleUploadError(err) {
  178. this.$modal.msgError("上传文件失败,请重试")
  179. this.$modal.closeLoading()
  180. },
  181. // 上传成功回调
  182. handleUploadSuccess(res, file) {
  183. console.log(file)
  184. if (res.code === 200) {
  185. this.form.fileUrl = res.data.url
  186. this.form.fileName = res.data.name
  187. const fileName = file.name.split('.')
  188. const fileExt = fileName[fileName.length - 1]
  189. this.form.ffmc = file.name.replace('.' + fileExt, '')
  190. this.fileList.push({ name: res.data.name, url: res.data.url })
  191. this.$modal.closeLoading()
  192. } else {
  193. this.number--
  194. this.$modal.closeLoading()
  195. this.$modal.msgError(res.msg)
  196. this.$refs.fileUpload.handleRemove(file)
  197. }
  198. },
  199. handleRemove() {
  200. this.form.fileUrl = ''
  201. this.form.fileName = ''
  202. this.fileList = []
  203. }
  204. }
  205. }
  206. </script>