customer-remarks-add .vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card" style="margin: 10px auto">
  4. <div class="refund-item">
  5. <el-form ref="dataForm" :model="params" :rules="rules" label-width="120px">
  6. <el-row :gutter="24" class="box-row">
  7. <el-form-item label="备注:" prop="remarks">
  8. <el-input
  9. v-model.trim="params.note"
  10. type="textarea"
  11. show-word-limit
  12. placeholder="请输入备注文字,200字以内"
  13. maxlength="200"
  14. :autosize="{ minRows: 5, maxRows: 6 }"
  15. style="width: 600px"
  16. />
  17. </el-form-item>
  18. <el-form-item label="图片:" prop="logImage">
  19. <div class="form-el-upload">
  20. <el-upload
  21. :class="{ hide: hideImg }"
  22. :action="actionUrl"
  23. :headers="getToken"
  24. list-type="picture-card"
  25. :before-upload="beforeUploadImg"
  26. :on-remove="handleRemove"
  27. :on-success="handleSuccess"
  28. :limit="5"
  29. >
  30. <div slot="tip" class="el-upload__tip">请上传jgp,jpeg,png格式的图片,每张不超过5M</div>
  31. <i class="el-icon-plus"></i>
  32. </el-upload>
  33. </div>
  34. </el-form-item>
  35. <el-form-item>
  36. <div class="filter-container" style="text-align: left; margin-top: 20px">
  37. <el-button type="primary" @click="handlerConfirm">保存</el-button>
  38. <el-button plain @click="backToList">返回</el-button>
  39. </div>
  40. </el-form-item>
  41. </el-row>
  42. </el-form>
  43. </div>
  44. </el-card>
  45. </div>
  46. </template>
  47. <script>
  48. import { saveInformation } from '@/api/user/customer/customer'
  49. export default {
  50. name: 'AddRemarks',
  51. filters: {},
  52. data() {
  53. return {
  54. params: {
  55. images: [], // 备注图片
  56. note: '',
  57. informationId: ''
  58. },
  59. fileImageList: [], // 上传图片列表
  60. fileUrl: process.env.VUE_APP_BASE_API + '/order/cmOrderRemark/upload/remark',
  61. fileList: [], // 上传文件列表
  62. rules: {
  63. note: [
  64. {
  65. required: true,
  66. message: '请输入备注信息',
  67. trigger: 'blur'
  68. }
  69. ]
  70. },
  71. hideImg: false, // 上传图片隐藏
  72. hideFile: false // 上传文件隐藏
  73. }
  74. },
  75. computed: {
  76. getToken() {
  77. return {
  78. token: this.$store.getters.token
  79. }
  80. },
  81. actionUrl() {
  82. return process.env.VUE_APP_BASE_API + '/formData/MultiPictareaddData'
  83. }
  84. },
  85. created() {
  86. this.params.informationId = this.$route.query.informationId * 1
  87. },
  88. methods: {
  89. // 保存
  90. handlerConfirm() {
  91. this.$refs['dataForm'].validate((valid) => {
  92. if (valid) {
  93. this.saveInformation()
  94. }
  95. })
  96. },
  97. // 保存备注
  98. async saveInformation() {
  99. try {
  100. await saveInformation(this.params)
  101. this.$message.success('添加成功')
  102. this.backToList()
  103. } catch (error) {
  104. console.log(error)
  105. }
  106. },
  107. isImage(file) {
  108. return (
  109. file.type === 'image/png' ||
  110. file.type === 'image/jpeg' ||
  111. file.type === 'image/jpg' ||
  112. file.type === 'image/webp'
  113. )
  114. },
  115. // 上传图片事件
  116. handleSuccess(res, file, fileList) {
  117. this.params.images.push(res.data)
  118. this.handleChange()
  119. },
  120. // 上传文件
  121. handleFileSuccess(res, file, fileList) {
  122. this.params.ossFiles.push(res.data.ossFiles)
  123. this.handleFileChange()
  124. },
  125. // 删除图片事件
  126. handleRemove(file, fileList) {
  127. this.params.images = fileList.map((e) => e.response.data)
  128. this.handleChange()
  129. },
  130. // 删除文件
  131. handlerFileRemove(file, fileList) {
  132. this.params.ossFiles = fileList.map((e) => e.response.data.ossFiles)
  133. this.handleFileChange()
  134. },
  135. // 文件限制
  136. beforeUploadImg(file) {
  137. const isUpload = file.size / 1024 / 1024 < 5
  138. if (this.isImage(file)) {
  139. if (isUpload) {
  140. return true
  141. } else {
  142. this.$message.error('文件过大,请重新上传!')
  143. return false
  144. }
  145. } else {
  146. this.$message.error('请上传jgp,jpeg,png格式的图片!')
  147. return false
  148. }
  149. },
  150. beforeUploadFile(file) {
  151. const whiteList = ['pdf', 'doc', 'docx', 'xlsx']
  152. const isUpload = file.size / 1024 / 1024 < 5
  153. if (whiteList.indexOf(file.name.substring(file.name.lastIndexOf('.') + 1)) === -1) {
  154. this.$message.error('请上传 pdf、doc、docx、xlsx格式的文件!')
  155. return false
  156. }
  157. if (isUpload) {
  158. return true
  159. } else {
  160. this.$message.error('文件过大,请重新上传!')
  161. return false
  162. }
  163. },
  164. // 文件数量判断
  165. handleChange(file, fileList) {
  166. this.hideImg = this.params.images.length >= 5
  167. },
  168. // 文件数量判断
  169. handleFileChange(file, fileList) {
  170. this.hideFile = this.params.ossFiles.length >= 5
  171. },
  172. backToList() {
  173. this.$store.dispatch('tagsView/delView', this.$route).then(() => {
  174. this.$nextTick(() => {
  175. this.$router.replace({
  176. path: '/user/customer/customer-remarks',
  177. query: {
  178. id: this.params.informationId
  179. }
  180. })
  181. })
  182. })
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. ::v-deep .el-upload-list {
  189. display: inline-flex !important;
  190. }
  191. ::v-deep .el-upload--picture-card {
  192. width: 148px !important;
  193. height: 148px !important;
  194. }
  195. ::v-deep .el-upload__tip {
  196. position: static !important;
  197. }
  198. ::v-deep .hide .el-upload--picture-card {
  199. display: none;
  200. }
  201. .fileUpload {
  202. ::v-deep .el-upload-list {
  203. flex-direction: column !important;
  204. }
  205. }
  206. .app-title {
  207. line-height: 36px;
  208. font-size: 26px;
  209. font-weight: bold;
  210. color: #409eff;
  211. text-align: center;
  212. margin: 0;
  213. }
  214. .box-card {
  215. margin-top: 20px;
  216. font-size: 14px;
  217. }
  218. .box-row {
  219. padding: 10px 0;
  220. }
  221. .box-row .dropdown {
  222. margin-top: -10px;
  223. }
  224. .refund-item {
  225. padding: 10px 0;
  226. }
  227. .order-item {
  228. background: #f7f7f7;
  229. margin-bottom: 20px;
  230. padding: 10px 15px;
  231. border-radius: 5px;
  232. }
  233. .product-row {
  234. padding: 10px 0;
  235. background: #ebeef5;
  236. border-top: 1px dashed #dcdfe6;
  237. }
  238. .avatar-uploader .el-upload {
  239. border: 1px dashed #d9d9d9;
  240. border-radius: 6px;
  241. cursor: pointer;
  242. position: relative;
  243. overflow: hidden;
  244. }
  245. .avatar-uploader .el-upload:hover {
  246. border-color: #409eff;
  247. }
  248. .avatar-uploader-icon {
  249. font-size: 28px;
  250. color: #8c939d;
  251. width: 148px;
  252. height: 148px;
  253. line-height: 148px;
  254. text-align: center;
  255. }
  256. .avatar {
  257. width: 148px;
  258. height: 148px;
  259. display: block;
  260. }
  261. .avatar img {
  262. width: 148px;
  263. height: 148px;
  264. display: block;
  265. }
  266. .el-form-item__label {
  267. text-align: right !important;
  268. }
  269. .el-upload__tip {
  270. line-height: 20px;
  271. color: red;
  272. text-align: left;
  273. }
  274. .span_tip {
  275. font-size: 12px;
  276. color: red;
  277. margin-left: 5px;
  278. }
  279. .filter-item-temp {
  280. width: 100px;
  281. }
  282. .op-item {
  283. padding: 5px 0;
  284. }
  285. .el-span-warning {
  286. color: #e6a23c;
  287. }
  288. .el-span-success {
  289. color: #67c23a;
  290. }
  291. .el-span-danger {
  292. color: #f56c6c;
  293. }
  294. </style>