dct 1 miesiąc temu
rodzic
commit
79eb0a540d

+ 30 - 0
src/api/order.js

@@ -65,6 +65,36 @@ export function reviewOrder(id, isApproved, remark) {
   });
 }
 
+export function cancelOrder(id, detailIDs, remark) {
+  return request({
+    url: `/TourOrder/${id}/Cancel`,
+    method: 'post',
+    data: {
+      remark: remark || '',
+      detailIDs: detailIDs || [],
+      detailCancelQuantities: {},
+    },
+  });
+}
+
+export function getOrderRefundInfo(id) {
+  return request({
+    url: `/TourOrderRefund/ByOrder/${id}`,
+    method: 'get'
+  });
+}
+
+export function reviewRefundOrder(refundId, isApproved, remark) {
+  return request({
+    url: `/TourOrder/Refund/${refundId}`,
+    method: 'post',
+    data: {
+      isApproved: !!isApproved,
+      auditRemark: remark || ''
+    }
+  });
+}
+
 export function getScheduleByOrderId(id) {
   return request({
     url: `/TourOrderDailySchedule/ByOrder/${id}`,

+ 66 - 12
src/views/order/index.vue

@@ -24,6 +24,7 @@
             <el-option label="已确认" value="Confirmed"></el-option>
             <el-option label="处理中" value="Processing"></el-option>
             <el-option label="已完成" value="Completed"></el-option>
+            <el-option label="取消中" value="Cancelling"></el-option>
             <el-option label="已取消" value="Cancelled"></el-option>
             <el-option label="已驳回" value="Rejected"></el-option>
           </el-select>
@@ -116,15 +117,21 @@
 
       <el-table-column fixed="right" label="操作" width="320">
         <template #default="scope">
-          <!-- <el-button type="primary" link size="small" @click="edit(scope.row)">编辑</el-button> -->
-          <!-- <el-button type="success" link size="small" @click="audit(scope.row)">审核</el-button> -->
-          <el-button type="info" link size="small" @click="attachment(scope.row)">附件</el-button>
-          <el-button type="warning" v-if="userAccountId === 'testuser' && orderCanPay(scope.row)" link size="small"
-            @click="payment(scope.row)">收款</el-button>
-          <el-button type="info" link size="small" @click="editSchedule(scope.row)">行程</el-button>
-          <el-button type="primary" link size="small" @click="editTourists(scope.row)">游客</el-button>
-          <el-button v-if="scope.row.status === 'Submitted'" type="danger" link size="small"
-            @click="del(scope.row)">删除</el-button>
+          <div>
+            <!-- <el-button type="primary" link size="small" @click="edit(scope.row)">编辑</el-button> -->
+            <!-- <el-button type="success" link size="small" @click="audit(scope.row)">审核</el-button> -->
+            <el-button type="info" link size="small" @click="attachment(scope.row)">附件</el-button>
+            <el-button type="info" link size="small" @click="editSchedule(scope.row)">行程</el-button>
+            <el-button type="primary" link size="small" @click="editTourists(scope.row)">游客</el-button>
+          </div>
+          <div>
+            <el-button v-if="userAccountId === 'testuser' && orderCanPay(scope.row)" type="warning" link size="small"
+              @click="payment(scope.row)">收款</el-button>
+            <el-button v-if="!['Completed', 'Cancelled'].includes(scope.row.status)" type="primary" link size="small"
+              @click="cancel(scope.row)">取消</el-button>
+            <el-button v-if="scope.row.status === 'Submitted'" type="danger" link size="small"
+              @click="del(scope.row)">删除</el-button>
+          </div>
         </template>
       </el-table-column>
     </el-table>
@@ -414,6 +421,7 @@
                       <el-option label="已确认" value="Confirmed"></el-option>
                       <el-option label="处理中" value="Processing"></el-option>
                       <el-option label="已完成" value="Completed"></el-option>
+                      <el-option label="取消中" value="Cancelling"></el-option>
                       <el-option label="已取消" value="Cancelled"></el-option>
                       <el-option label="已驳回" value="Rejected"></el-option>
                     </el-select>
@@ -851,10 +859,17 @@
         <el-form-item label="收款方式" prop="method">
           <el-radio-group v-model="paymentForm.method">
             <el-radio-button label="Online">在线支付</el-radio-button>
-            <el-radio-button label="Balance">余额扣款</el-radio-button>
-            <el-radio-button label="Offline">线下支付</el-radio-button>
+            <!-- <el-radio-button label="Balance">余额扣款</el-radio-button>
+            <el-radio-button label="Offline">线下支付</el-radio-button> -->
           </el-radio-group>
         </el-form-item>
+        <el-form-item label="支付方式" prop="paymentMethod" v-if="paymentForm.method === 'Online'">
+          <el-radio-group v-model="paymentForm.paymentMethod">
+            <el-radio-button label="WeChat">微信支付</el-radio-button>
+            <!-- <el-radio-button label="Alipay">支付宝支付</el-radio-button> -->
+          </el-radio-group>
+        </el-form-item>
+
 
         <el-form-item label="收款金额" prop="amount">
           <el-input-number v-model.number="paymentForm.amount" disabled :min="0" :precision="2" style="width:200px" />
@@ -907,6 +922,7 @@ import store from "@/store";
 import {
   getOrders,
   getOrderNo,
+  cancelOrder,
   delOrder,
   createOrder,
   updateOrder,
@@ -1121,8 +1137,10 @@ export default {
       fileList: [],
       paymentDialogVisible: false,
       paymentForm: {
+        id: '',
         amount: null,
         method: 'Online',
+        paymentMethod: 'WeChat',
         orderNo: '',
       },
       onlinePaymentDialogVisible: false,
@@ -1302,14 +1320,18 @@ export default {
     async payment(row) {
       const res = await getPayParams(row.id);
       console.log('---pay params---', res);
+      this.paymentForm.id = row.id;
       this.paymentForm.orderNo = row.orderNo;
       this.paymentForm.amount = row.totalAmount;
+      this.paymentForm.paymentMethod = 'WeChat';
       this.paymentDialogVisible = true;
     },
     cancelPayment() {
       this.paymentForm = {
+        id: '',
         amount: null,
         method: 'Online',
+        paymentMethod: 'WeChat',
         orderNo: '',
       };
     },
@@ -1354,11 +1376,41 @@ export default {
       this.onlinePaymentDialogVisible = false;
       document.getElementById('payment-qr-code').innerHTML = '';
     },
-    submitOnlinePayment() {
+    async submitOnlinePayment() {
+      const { id } = this.paymentForm;
+      const res = await getOrderDetailById(id);
+      if (res.data?.order?.status !== 'Paid') {
+        this.$message.error('支付未完成,请确认已支付');
+        return;
+      }
       this.$message.success('支付成功');
       this.onlinePaymentDialogVisible = false;
+      this.paymentDialogVisible = false;
       this.getOrderList();
     },
+    async cancel(row) {
+      const res = await getOrderDetailById(row.id);
+      const details = res.data?.details || [];
+      let cancelRemark = '';
+      this.$prompt("请输入取消原因", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        inputPattern: /^.{1,100}$/,
+        inputErrorMessage: "请输入1-100个字符",
+      }).then(({ value }) => {
+        cancelRemark = value;
+        cancelOrder(row.id, map(details, item => item.id), cancelRemark).then((res) => {
+          if (res.code === 200) {
+            this.$message({
+              type: "success",
+              message: "订单已取消",
+            });
+            this.getOrderList();
+          }
+        });
+      }).catch(() => {
+      });
+    },
     del(row) {
       this.$confirm("此操作将删除选择数据, 是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", })
         .then(() => {
@@ -1385,6 +1437,7 @@ export default {
         'Processing': 'warning',
         'Completed': 'success',
         'Cancelled': 'danger',
+        'Cancelling': 'warning',
         'Rejected': 'danger'
       }
       return types[status] || 'info'
@@ -1560,6 +1613,7 @@ export default {
         'Processing': '处理中',
         'Completed': '已完成',
         'Cancelled': '已取消',
+        'Cancelling': '取消中',
         'Rejected': '已驳回'
       }
       return texts[status] || status

+ 53 - 5
src/views/order/review.vue

@@ -119,7 +119,7 @@
 </template>
 <script>
 import request from '@/utils/request'
-import { getOrders, reviewOrder } from '@/api/order';
+import { getOrders, reviewOrder, getOrderRefundInfo, reviewRefundOrder } from '@/api/order';
 import { cloneDeep, groupBy } from 'lodash-es';
 import moment from 'moment/moment';
 import { ProductTypes } from '@/constant';
@@ -153,10 +153,20 @@ export default {
           }
         ],
         filters: [
+          {
+            name: "paymentStatus",
+            operate: 0, // 0 等于; 1 不等于; 2 like; 3 not like
+            value: 'Paid',
+          },
           {
             name: "status",
             operate: 1, // 0 等于; 1 不等于; 2 like; 3 not like
-            value: 'Paid',
+            value: 'Cancelled',
+          },
+          {
+            name: "auditStatus",
+            operate: 0, // 0 等于; 1 不等于; 2 like; 3 not like
+            value: 'Pending',
           }
         ],
         page: 1,
@@ -168,6 +178,7 @@ export default {
       formDialogVisible: false,
       formData: {
         id: '',
+        status: '',
         isApproved: true,
         remark: '',
       },
@@ -199,10 +210,17 @@ export default {
     },
     audit(row) {
       this.formData.id = row.id;
+      this.formData.status = row.status;
       this.formDialogVisible = true;
     },
     close() {
       this.$refs.formRef.resetFields();
+      this.formData = {
+        id: '',
+        status: '',
+        isApproved: true,
+        remark: '',
+      };
     },
     getOrderList() {
       getOrders(this.forms || {}).then((res) => {
@@ -212,9 +230,24 @@ export default {
     },
     submitReviewOrder() {
       this.$refs.formRef.validate((valid) => {
-        if (!valid) return;
-        const { id, isApproved, remark } = this.formData;
-        reviewOrder(id, isApproved, remark).then((res) => {
+        const { id, isApproved, remark, status } = this.formData;
+        if (!valid || !id) return;
+        if (status === 'Cancelling') {
+          this.reviewCancelOrder(id, isApproved, remark);
+        } else {
+          this.reviewNormalOrder(id, isApproved, remark);
+        }
+      });
+    },
+    reviewCancelOrder(orderId, isApproved, remark) {
+      getOrderRefundInfo(orderId).then((res) => {
+        const refundInfo = res.data || {};
+        const refundId = refundInfo.refundList?.[0]?.id || '';
+        if (!refundId) {
+          this.$message.error('未找到退款信息,无法审核取消订单');
+          return;
+        }
+        reviewRefundOrder(refundId, isApproved, remark).then((res) => {
           if (res.code === 200) {
             this.$message({
               type: "success",
@@ -227,6 +260,19 @@ export default {
         });
       });
     },
+    reviewNormalOrder(orderId, isApproved, remark) {
+      reviewOrder(orderId, isApproved, remark).then((res) => {
+        if (res.code === 200) {
+          this.$message({
+            type: "success",
+            message: "审核成功",
+          });
+          this.formDialogVisible = false;
+
+          this.getOrderList();
+        }
+      });
+    },
     toggleRowExpand() {
       let that = this;
       this.tableData.forEach(function (row) {
@@ -260,6 +306,7 @@ export default {
         'Processing': 'warning',
         'Completed': 'success',
         'Cancelled': 'danger',
+        'Cancelling': 'warning',
         'Rejected': 'danger'
       }
       return types[status] || 'info'
@@ -274,6 +321,7 @@ export default {
         'Processing': '处理中',
         'Completed': '已完成',
         'Cancelled': '已取消',
+        'Cancelling': '取消中',
         'Rejected': '已驳回'
       }
       return texts[status] || status

+ 24 - 30
src/views/sys/department/index.vue

@@ -124,7 +124,9 @@
   </el-dialog>
 </template>
 <script>
-import { submitDepartment, delDepartment } from "@/api/basic";
+import { submitDepartment, delDepartment, getCompanyTree } from "@/api/basic";
+import { cloneDeep } from 'lodash-es';
+
 export default {
   name: "Department",
   components: {},
@@ -152,7 +154,8 @@ export default {
   methods: {
     edit(row) {
       this.formDialogVisible = true;
-      this.formData = row;
+      this.formData = cloneDeep(row);
+      this.formData.companyID = this.forms.companyID;
     },
     add(row) {
       //const res=await  this.$http.post('url',this.formData)
@@ -167,84 +170,75 @@ export default {
       this.$refs.formRef.resetFields();
     },
     getTree(companyId) {
-      var that = this;
-
       // this.$kaung.departments(companyId).then((res) => {
-      //   that.treeData = res;
-      //   that.parentSelect = res;
+      //   this.treeData = res;
+      //   this.parentSelect = res;
       // });
       this.$kaung.fetch({
         url: '/BaseDepartment/Tree?companyId=' + companyId + '&v=' + Math.random(),
         method: 'get'
       }).then((res) => {
-        that.treeData = res.data;
-        that.parentSelect = res.data;
+        this.treeData = res.data;
+        this.parentSelect = res.data;
       });
     },
     submit() {
-      let that = this;
-
       this.$refs.formRef.validate((valid) => {
         if (!valid) return;
 
         submitDepartment(this.formData).then((res) => {
           if (res.code === 200) {
-            that.$message({
+            this.$message({
               type: "success",
               message: res.content,
             });
-            that.formDialogVisible = false;
+            this.formDialogVisible = false;
 
-            that.getTree(that.forms.companyID);
+            this.getTree(this.forms.companyID);
           }
         });
       });
     },
     toggleRowExpand() {
-      let that = this;
-      this.treeData.forEach(function (row) {
-        that.$refs.table.toggleRowExpansion(row);
+      this.treeData.forEach((row) => {
+        this.$refs.table.toggleRowExpansion(row);
       });
     },
 
     del(row) {
-      let that = this;
       this.$confirm("此操作将删除本页选择数据, 是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", })
         .then(() => {
           delDepartment(row.id).then((res) => {
             if (res.code === 200) {
-              that.$message({
+              this.$message({
                 type: "success",
                 message: "删除成功",
               });
-              that.getTree(that.forms.companyID);
+              this.getTree(this.forms.companyID);
             }
           });
         })
         .catch(() => {
-          that.$message({ type: "info", message: "删除失败", });
+          this.$message({ type: "info", message: "删除失败", });
         });
     },
     search() {
-      let that = this;
-      that.getTree(that.forms.companyID);
+      this.getTree(this.forms.companyID);
     }
   },
   mounted() {
-    let that = this;
-
     this.$kaung.fetch({
       url: '/BaseCompany/Tree?v=' + Math.random(),
       method: 'get'
     }).then((res) => {
-      that.companys = res.data;
-      that.forms.companyID = res.data[0].id;
-      that.getTree(that.forms.companyID);
+      this.companys = res.data;
+      this.forms.companyID = res.data[0].id;
+      this.getTree(this.forms.companyID);
     });
     // this.$kaung.companys().then((res) => {
-    //   that.companys = res;
-    //   that.forms.companyID = res[0].id;
-    //   that.getTree(that.forms.companyID);
+    //   this.companys = res;
+    //   this.forms.companyID = res[0].id;
+    //   this.getTree(this.forms.companyID);
     // });
 
   },

+ 9 - 4
src/views/sys/user/index.vue

@@ -180,6 +180,7 @@ import StaticTable from "@/components/static-table.vue";
 import resetPwdDialog from "@/views/sys/user/reset.vue";
 import roleSelect from "@/views/sys/role/select.vue";
 import store from "@/store";
+import { cloneDeep } from 'lodash-es';
 
 export default {
   name: "User",
@@ -216,6 +217,12 @@ export default {
       forms: {},
       labelWidth: "90px",
       rules: {
+        companyID: [
+          { required: true, message: "请选择公司", trigger: "blur" },
+        ],
+        departmentID: [
+          { required: true, message: "请选择部门", trigger: "blur" },
+        ],
         account: [
           { required: true, message: "请输入账户名称", trigger: "blur" },
         ],
@@ -250,15 +257,13 @@ export default {
   methods: {
     //this.$refs.dialog.**
     edit(row) {
-      this.forms = { ...row }; //JSON.parse(JSON.stringify(row));
-
+      this.forms = cloneDeep(row); //JSON.parse(JSON.stringify(row));
       this.companyChange(this.forms.companyID);
 
       this.$refs.dialog.toggle();
     },
     add() {
-      this.forms = { sortCode: 1, gender: "无" };
-
+      this.forms = { sortCode: 1, gender: "无", isEnabled: true };
       this.$refs.dialog.toggle();
     },
     del() {