payOrCredit.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <!--
  2. * @Description: 详情弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: gcz
  6. * @LastEditTime: 2025-03-20 15:37:39
  7. * @FilePath: \great_webui\src\views\order\groupBuyingMr\dialog\details.vue
  8. * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
  9. -->
  10. <template>
  11. <el-dialog :title="title" :visible.sync="open" width="500" append-to-body :close-on-click-modal="false"
  12. @close="cancel">
  13. <div class="dialog" v-if="form">
  14. <div v-loading="loading" element-loading-text="加载详情中...">
  15. <!-- 对公支付信息 -->
  16. <el-form :model="form" ref="form" size="mini" :rules="rules" label-width="150px">
  17. <el-form-item :label="ifTeamCredit == 1 ? '挂账支付凭证上传:' : '对公支付凭证上传:'" prop="voucherUrl">
  18. <div style="display: flex;flex-wrap: wrap;">
  19. <div v-for="(item, index) in form.voucherUrl" :key="index"
  20. style="width: 100px; height: 100px;margin-top: 5px; position: relative;border: 1px solid #999;border-radius: 5px;margin-right: 20px;">
  21. <el-image style="width: 100%; height: 100%" :src="item" :preview-src-list="form.voucherUrl">
  22. </el-image>
  23. <span @click="handleRemove(index)"
  24. style="position: absolute;top: -15px;right: -15px;color: red;font-size: 24px;z-index: 999;cursor: pointer;">
  25. <i class="el-icon-error"></i>
  26. </span>
  27. </div>
  28. <div style="width: 100px; height: 100px;margin-top: 5px;" v-if="!form.voucherUrl || form.voucherUrl.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 class="avatar-uploader" :action="uploadObj.url" :headers="uploadObj.headers"
  32. :show-file-list="false" :before-upload="beforeAvatarUpload" :on-success="handleAvatarSuccess"
  33. :on-progress="handleAvatarProgress" :disabled="actionUrlLoading" :on-error="handleAvatarError">
  34. <i class="el-icon-plus avatar-uploader-icon"></i>
  35. </el-upload>
  36. </div>
  37. </div>
  38. </el-form-item>
  39. <el-form-item label="备注:" prop="remark">
  40. <el-input v-model="form.remark" type="textarea" placeholder="请输入备注"></el-input>
  41. </el-form-item>
  42. </el-form>
  43. </div>
  44. </div>
  45. <span slot="footer" class="dialog-footer">
  46. <el-button type="primary" @click="cancel">关闭</el-button>
  47. <el-button type="primary" @click="updateCorporateFun()" :loading="loading">
  48. <span v-if="loading">提交中...</span>
  49. <span v-else>确认修改</span>
  50. </el-button>
  51. </span>
  52. </el-dialog>
  53. </template>
  54. <script>
  55. import { getSelectById, updateCorporateApi } from '@/api/order/groupBuyingMr'
  56. import { getToken } from "@/utils/auth";
  57. export default {
  58. name: "detailsDia11",
  59. data() {
  60. return {
  61. title: "订单详情",
  62. model: "EDIT",
  63. open: false,
  64. loading: false,
  65. form: {
  66. id: undefined
  67. },
  68. rules: {
  69. voucherUrl: [{ required: true, message: "请上传凭证", trigger: ["change","blur"] }],
  70. remark: [
  71. { required: true, message: '请输入备注', trigger: ['change','blur' ]}
  72. ],
  73. },
  74. loading_form: false,// 加载表单
  75. orderType: 'normal', // 订单类型 normal:没有新订单和原订单,new:有新订单,old:有原订单
  76. uploadObj: {
  77. url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
  78. Headers: { Authorization: "Bearer " + getToken() },
  79. },
  80. actionUrlLoading:false,
  81. ifTeamCredit: null,
  82. };
  83. },
  84. methods: {
  85. /**
  86. * 打开弹框
  87. * @date 2023-11-22
  88. * @param {any} obj
  89. * @returns {any}
  90. */
  91. async openDialog(title, obj, type) {
  92. this.orderType = type;
  93. this.ifTeamCredit = obj.ifTeamCredit;
  94. this.title = title
  95. this.open = true;
  96. await this.getSelectByIdApi(obj);
  97. this.$nextTick(() => {
  98. this.$refs["form"].clearValidate();
  99. });
  100. },
  101. /** 获取详情 */
  102. async getSelectByIdApi(row) {
  103. let id = row.id;
  104. try {
  105. this.loading = true
  106. let res = await getSelectById(id)
  107. this.seatSelectList = res.data.viewersOrderList
  108. this.resubmit = res.data.resubmit||{};
  109. this.form = {
  110. orderId: res.data.id,
  111. voucherUrl: [],
  112. remark: null,
  113. };
  114. console.log('this.form',this.form);
  115. this.form.payOrCredit = null
  116. if(res.data.corporate){
  117. this.form.payOrCredit = 1
  118. this.form.voucherUrl = res.data.corporate.voucherUrl.split(',')||[];
  119. this.form.remark = res.data.corporate.remark;
  120. }
  121. this.loading = false
  122. } catch (error) {
  123. this.loading = false
  124. }
  125. },
  126. /** 对公支付凭证修改 */
  127. async updateCorporateFun() {
  128. this.$refs["form"].validate(async (valid) => {
  129. if (valid) {
  130. try {
  131. if(this.form.voucherUrl.length==0) {
  132. this.$message.error("请上传凭证!");
  133. }
  134. this.loading = true
  135. let param = JSON.parse(JSON.stringify(this.form))
  136. param.voucherUrl = param.voucherUrl.join(',')
  137. let res = await updateCorporateApi(param)
  138. if(res.code == 200) {
  139. this.$message.success("操作成功!");
  140. this.loading = false
  141. this.$emit("getList");
  142. this.cancel()
  143. }else {
  144. this.loading = false
  145. }
  146. } catch (error) {
  147. console.error(error)
  148. this.loading = false
  149. }
  150. }
  151. })
  152. },
  153. /**
  154. * 关闭弹框
  155. * @date 2023-11-22
  156. * @returns {any}
  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.voucherUrl.push(response.data.url)
  167. }
  168. this.$refs.form.validateField('voucherUrl')
  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(index) {
  190. this.form.voucherUrl.splice(index,1)
  191. this.$refs.form.validateField('voucherUrl')
  192. },
  193. },
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. .dialog {
  198. width: 100%;
  199. }
  200. .dialog {
  201. padding: 0 30px;
  202. .upload-btn {
  203. width: 100px;
  204. height: 100px;
  205. background-color: #fbfdff;
  206. border: dashed 1px #c0ccda;
  207. border-radius: 5px;
  208. i {
  209. font-size: 30px;
  210. margin-top: 20px;
  211. }
  212. &-text {
  213. margin-top: -10px;
  214. }
  215. }
  216. .avatar {
  217. cursor: pointer;
  218. }
  219. .title-class{
  220. font-size: 16px;
  221. font-weight: bold;
  222. color: black;
  223. margin-bottom: 20px;
  224. margin-top: 20px;
  225. }
  226. .item-class{
  227. margin-bottom: 20px;
  228. }
  229. }
  230. .voucher-list{
  231. display: grid;
  232. grid-template-columns: repeat(4, 1fr);
  233. gap: 24rpx;
  234. }
  235. .pay-type-remark{
  236. margin:14px 0;
  237. }
  238. .dialog-bbb {
  239. width: 100%;
  240. display: flex;
  241. --widdd: 700px;
  242. >div:first-child {
  243. width: var(--widdd);
  244. flex-shrink: 0;
  245. overflow-y: auto;
  246. padding: 0 0 10px 0;
  247. margin-right: 10px;
  248. }
  249. .dialog-bbb_2 {
  250. width: calc(100% - var(--widdd));
  251. height: 100%;
  252. }
  253. }
  254. </style>