imgAduit.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <!--
  2. * @Description: 打款凭证弹框
  3. -->
  4. <template>
  5. <el-dialog :title="title" :visible.sync="open" width="600" append-to-body :close-on-click-modal="false"
  6. @close="cancel">
  7. <div class="dialog" v-if="form">
  8. <div v-loading="loading" element-loading-text="加载详情中...">
  9. <!-- 对公支付信息 -->
  10. <el-form :model="form" ref="form" :rules="rules" label-width="120px">
  11. <el-form-item label="打款凭证:" prop="voucherImg">
  12. <el-upload
  13. ref="upload"
  14. list-type="picture-card"
  15. :limit="2"
  16. :file-list="form.voucherImg"
  17. :action="uploadObj.url"
  18. :headers="uploadObj.headers"
  19. :before-upload="beforeAvatarUpload"
  20. :on-success="handleAvatarSuccess"
  21. :on-progress="handleAvatarProgress"
  22. :disabled="actionUrlLoading"
  23. :on-error="handleAvatarError"
  24. :on-remove="handleRemove"
  25. >
  26. <i class="el-icon-plus"></i>
  27. </el-upload>
  28. <!-- <div style="width: 100px; height: 100px;margin-top: 5px;" v-if="!form.voucherImg || form.voucherImg.length < 15"
  29. v-loading="actionUrlLoading" element-loading-text="上传中..." element-loading-spinner="el-icon-loading"
  30. element-loading-background="rgba(0, 0, 0, 0.8)">
  31. <el-upload
  32. class="avatar-uploader"
  33. :action="uploadObj.url"
  34. :headers="uploadObj.headers"
  35. :show-file-list="false"
  36. :before-upload="beforeAvatarUpload"
  37. :on-success="handleAvatarSuccess"
  38. :on-progress="handleAvatarProgress"
  39. :disabled="actionUrlLoading"
  40. :on-error="handleAvatarError">
  41. <i class="el-icon-plus"></i>
  42. </el-upload>
  43. </div> -->
  44. </el-form-item>
  45. <el-form-item label="备注:" prop="remark">
  46. <el-input v-model="form.remark" type="textarea" placeholder="请输入备注"></el-input>
  47. </el-form-item>
  48. </el-form>
  49. </div>
  50. </div>
  51. <span slot="footer" class="dialog-footer">
  52. <el-button @click="cancel">取消</el-button>
  53. <el-button type="primary" @click="handleWithdrawAudit()" :loading="loading">
  54. <span v-if="loading">提交中...</span>
  55. <span v-else>保存</span>
  56. </el-button>
  57. </span>
  58. </el-dialog>
  59. </template>
  60. <script>
  61. // import { getSelectById, updateCorporateApi } from '@/api/order/groupBuyingMr'
  62. import {
  63. withdrawAudit
  64. } from '@/api/distribution/Withdrawl'
  65. import { getToken } from "@/utils/auth";
  66. export default {
  67. name: "imgAduit",
  68. data() {
  69. return {
  70. title: "上传打款凭证",
  71. model: "EDIT",
  72. open: false,
  73. loading: false,
  74. form: {
  75. withdrawLogId: undefined,
  76. voucherImg: [],
  77. remark: null,
  78. },
  79. rules: {
  80. voucherImg: [{ required: true, message: "请上传凭证", trigger: ["change","blur"] }],
  81. remark: [
  82. { required: true, message: '请输入备注', trigger: ['change','blur' ]}
  83. ],
  84. },
  85. loading_form: false,// 加载表单
  86. uploadObj: {
  87. url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
  88. Headers: { Authorization: "Bearer " + getToken() },
  89. },
  90. actionUrlLoading:false,
  91. };
  92. },
  93. methods: {
  94. // 打开弹框
  95. async openDialog(title, obj) {
  96. this.title = title
  97. this.open = true;
  98. if(obj.voucherImg){
  99. if(obj.voucherImg.indexOf(',') > -1){
  100. let img_list = obj.voucherImg.split(',');
  101. let img_list_new = [];
  102. img_list.forEach((item, index) => {
  103. img_list_new.push({
  104. url: item,
  105. })
  106. });
  107. this.$set(this.form, 'voucherImg', img_list_new);
  108. } else {
  109. this.$set(this.form, 'voucherImg', [{url: obj.voucherImg}]);
  110. }
  111. } else {
  112. this.$set(this.form, 'voucherImg', []);
  113. }
  114. this.$set(this.form, 'withdrawLogId', obj.id);
  115. this.$set(this.form, 'remark', obj.remark);
  116. this.$nextTick(() => {
  117. this.$refs["form"].clearValidate();
  118. });
  119. },
  120. /** 保存打款凭证 */
  121. async handleWithdrawAudit() {
  122. this.$refs["form"].validate(async (valid) => {
  123. if (valid) {
  124. try {
  125. if(this.form.voucherImg.length==0) {
  126. this.$message.error("请上传打款凭证!");
  127. }
  128. this.loading = true
  129. let param = JSON.parse(JSON.stringify(this.form))
  130. let imgStr = ''
  131. if(param.voucherImg.length != 0){
  132. param.voucherImg.forEach((item, index) => {
  133. if(index < param.voucherImg.length - 1) {
  134. imgStr += item.url + ","
  135. } else {
  136. imgStr += item.url
  137. }
  138. })
  139. }
  140. param.voucherImg = imgStr
  141. console.log(param,'param111')
  142. let res = await withdrawAudit(param)
  143. if(res.code == 200) {
  144. this.$message.success("操作成功!");
  145. this.loading = false
  146. this.$emit("getList");
  147. this.cancel()
  148. }else {
  149. this.loading = false
  150. }
  151. } catch (error) {
  152. console.error(error)
  153. this.loading = false
  154. }
  155. }
  156. })
  157. },
  158. cancel() {
  159. this.open = false;
  160. },
  161. /** 上传图片 单张 */
  162. handleAvatarSuccess(response, file, fileList) {
  163. console.log("res, file",response, file, fileList)
  164. this.actionUrlLoading = false
  165. if(response.code == 200) {
  166. this.form.voucherImg.push({url: response.data.url})
  167. }
  168. this.$refs.form.validateField('voucherImg')
  169. },
  170. beforeAvatarUpload(file) {
  171. const isLt2M = file.size / 1024 / 1024 <= 100;
  172. let testmsg = file.name.substring(file.name.lastIndexOf('.')+1)
  173. let typeList = ['png','jepg','jpg','gif']
  174. const isJPG = typeList.includes(testmsg);
  175. if (!isJPG) {
  176. this.$message.error(`上传图片图片只能是 ${typeList} 格式!`);
  177. }
  178. if (!isLt2M) {
  179. this.$message.error('上传图片图片大小不能超过 100MB!');
  180. }
  181. return isJPG && isLt2M;
  182. },
  183. handleAvatarProgress(){
  184. this.actionUrlLoading = true
  185. },
  186. handleAvatarError() {
  187. this.actionUrlLoading = false
  188. },
  189. handleRemove(file, fileList) {
  190. console.log(file,'qqq');
  191. this.form.voucherImg.forEach((item, index) => {
  192. if(item.url == file.url){
  193. this.form.voucherImg.splice(index, 1)
  194. }
  195. })
  196. },
  197. },
  198. };
  199. </script>
  200. <style lang="scss" scoped>
  201. .dialog {
  202. width: 100%;
  203. }
  204. .dialog {
  205. padding: 0 30px;
  206. .upload-btn {
  207. width: 100px;
  208. height: 100px;
  209. background-color: #fbfdff;
  210. border: dashed 1px #c0ccda;
  211. border-radius: 5px;
  212. i {
  213. font-size: 30px;
  214. margin-top: 20px;
  215. }
  216. &-text {
  217. margin-top: -10px;
  218. }
  219. }
  220. .avatar {
  221. cursor: pointer;
  222. }
  223. .title-class{
  224. font-size: 16px;
  225. font-weight: bold;
  226. color: black;
  227. margin-bottom: 20px;
  228. margin-top: 20px;
  229. }
  230. .item-class{
  231. margin-bottom: 20px;
  232. }
  233. }
  234. .voucher-list{
  235. display: grid;
  236. grid-template-columns: repeat(4, 1fr);
  237. gap: 24rpx;
  238. }
  239. .pay-type-remark{
  240. margin:14px 0;
  241. }
  242. .dialog-bbb {
  243. width: 100%;
  244. display: flex;
  245. --widdd: 700px;
  246. >div:first-child {
  247. width: var(--widdd);
  248. flex-shrink: 0;
  249. overflow-y: auto;
  250. padding: 0 0 10px 0;
  251. margin-right: 10px;
  252. }
  253. .dialog-bbb_2 {
  254. width: calc(100% - var(--widdd));
  255. height: 100%;
  256. }
  257. }
  258. </style>