倚楼听风雨 3 yıl önce
ebeveyn
işleme
1451e734ca

+ 21 - 1
cool-admin-midway-master/src/app/modules/shuyou/controller/admin/rent_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-20 17:50:34
+ * @LastEditTime: 2022-09-23 15:22:44
  * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\rent_computer.ts
  */
@@ -58,6 +58,7 @@ export class ShuyouRentComputerController extends BaseController {
   @Inject()
   ShuyouRentComputerService: ShuyouRentComputerService;
 
+  // 换编
   @Post('/replaceNum')
   async replaceNum(@Body(ALL) queryObject) {
     // this.logger.info(queryObject);
@@ -68,4 +69,23 @@ export class ShuyouRentComputerController extends BaseController {
       return await this.fail(reqmsg.data, -1);
     }
   }
+
+  // 退租
+  @Post('/rentingOut')
+  async rentingOut(@Body(ALL) queryObject) {
+    // this.logger.info(queryObject);
+    let reqmsg = await this.ShuyouRentComputerService.rentingOut(queryObject);
+    if (reqmsg.code == 1000) {
+      return await this.ok({ code: 1, message: reqmsg.data });
+    } else {
+      return await this.fail(reqmsg.data, -1);
+    }
+  }
+
+  // 获取租机列表
+  @Post('/rentComputerList')
+  async rentComputerList() {
+    let list = await this.ShuyouRentComputerService.rentComputerList();
+    return await this.ok({ code: 1, data: list });
+  }
 }

+ 13 - 2
cool-admin-midway-master/src/app/modules/shuyou/entity/rent_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-01 20:41:58
- * @LastEditTime: 2022-09-22 15:51:45
+ * @LastEditTime: 2022-09-23 18:46:02
  * @Description: file content
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_computer.ts
  */
@@ -25,6 +25,10 @@ export class ShuyouRentComputerEntity extends BaseEntity {
   @Column({ comment: '租机店铺ID' })
   shop_id: number;
 
+  @Index()
+  @Column({ comment: '套餐', length: 100, nullable: true })
+  set_meal: string;
+
   @Column({ type: 'datetime', comment: '起租时间' })
   rent_start: Date;
 
@@ -35,7 +39,14 @@ export class ShuyouRentComputerEntity extends BaseEntity {
   rent_end: Date;
 
   @Column({
-    comment: '租机价格',
+    comment: '价格套餐 0:天卡 1:周卡 2:月卡',
+    default: 0,
+    type: 'tinyint',
+  })
+  price_type: number;
+
+  @Column({
+    comment: '价格标准',
     type: 'decimal',
     precision: 10,
     scale: 2,

+ 37 - 11
cool-admin-midway-master/src/app/modules/shuyou/entity/rent_ledger_computer.ts

@@ -1,12 +1,12 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-01 20:41:58
- * @LastEditTime: 2022-09-19 18:00:20
+ * @LastEditTime: 2022-09-23 11:49:24
  * @Description: file content
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_ledger_computer.ts
  */
 import { EntityModel } from '@midwayjs/orm';
-import { Column,Index } from 'typeorm';
+import { Column, Index } from 'typeorm';
 import { BaseEntity } from 'midwayjs-cool-core';
 
 /**
@@ -14,28 +14,55 @@ import { BaseEntity } from 'midwayjs-cool-core';
  */
 @EntityModel('shuyou_rent_ledger_computer')
 export class ShuyouRentLedgerComputerEntity extends BaseEntity {
-
-
   @Index()
   @Column({ comment: '电脑编号', length: 100 })
   pc_num: string;
-  
-  @Column({ type:'datetime', comment: '当时的起租时间' , nullable: true})
+
+  @Index()
+  @Column({ comment: '套餐', length: 100, nullable: true })
+  set_meal: string;
+
+  @Column({ type: 'datetime', comment: '当时的起租时间', nullable: true })
   rent_start_then: Date;
 
   @Column({ comment: '当时租机时常(天)', nullable: true })
   rent_duration_then: number;
 
-  @Column({  type:'datetime', comment: '当时的到期时间', nullable: true })
+  @Column({ type: 'datetime', comment: '当时的到期时间', nullable: true })
   rent_end_then: Date;
 
-  @Column({ type: "decimal",comment: '当时的租机价格', precision: 10, scale: 2, default: 0})
+  @Column({
+    comment: '价格套餐 0:天卡 1:周卡 2:月卡',
+    default: 0,
+    type: 'tinyint',
+  })
+  price_type: number;
+
+  @Column({
+    type: 'decimal',
+    comment: '当时的租机价格标准',
+    precision: 10,
+    scale: 2,
+    default: 0,
+  })
   rent_price_then: number;
 
-  @Column({ type: "decimal",comment: '当天租金', precision: 10, scale: 5, default: 0})
+  @Column({
+    type: 'decimal',
+    comment: '当天租金',
+    precision: 10,
+    scale: 5,
+    default: 0,
+  })
   rent_price_day: number;
 
-  @Column({ type: "decimal",comment: '当前租赁期内已产生多少租金', precision: 10, scale: 5, default: 0})
+  @Column({
+    type: 'decimal',
+    comment: '当前租赁期内已产生多少租金',
+    precision: 10,
+    scale: 5,
+    default: 0,
+  })
   rent_price_used_then: number;
 
   @Column({ comment: '游戏任务,多个游戏以英文逗号隔开', nullable: true })
@@ -46,5 +73,4 @@ export class ShuyouRentLedgerComputerEntity extends BaseEntity {
 
   @Column({ comment: '备注', nullable: true })
   remark: string;
-
 }

+ 154 - 8
cool-admin-midway-master/src/app/modules/shuyou/service/rent_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-22 14:57:04
+ * @LastEditTime: 2022-09-23 18:47:09
  * @Description:
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
  */
@@ -37,11 +37,16 @@ export class ShuyouRentComputerService extends BaseService {
     }
     param.createTime = new Date();
     param.updateTime = new Date();
-    param.rent_price_day =
-      parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
+    if (param.price_type == 0) {
+      param.rent_price_day = parseFloat(param.rent_price) / 1; // 折算天租金
+    } else if (param.price_type == 1) {
+      param.rent_price_day = parseFloat(param.rent_price) / 7; // 折算天租金
+    } else if (param.price_type == 2) {
+      param.rent_price_day = parseFloat(param.rent_price) / 30; // 折算天租金
+    }
 
-    console.log('rent_price_day');
-    console.log(param.rent_price_day);
+    // console.log('rent_price_day');
+    // console.log(param.rent_price_day);
 
     await this.updateTaskGame(param);
     return super.add(param);
@@ -104,8 +109,13 @@ export class ShuyouRentComputerService extends BaseService {
     if (!taskInfo) {
       throw new CoolCommException('租机不存在');
     }
-    param.rent_price_day =
-      parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
+    if (param.price_type == 0) {
+      param.rent_price_day = parseFloat(param.rent_price) / 1; // 折算天租金
+    } else if (param.price_type == 1) {
+      param.rent_price_day = parseFloat(param.rent_price) / 7; // 折算天租金
+    } else if (param.price_type == 2) {
+      param.rent_price_day = parseFloat(param.rent_price) / 30; // 折算天租金
+    }
 
     // console.log('rent_price_day');
     // console.log(param.rent_price_day);
@@ -118,7 +128,7 @@ export class ShuyouRentComputerService extends BaseService {
    * @param query
    */
   async page(query) {
-    const { pc_num, is_expire } = query;
+    const { pc_num, is_expire, set_meal } = query;
     const sql = `
           SELECT
             a.*,
@@ -135,11 +145,30 @@ export class ShuyouRentComputerService extends BaseService {
           WHERE 1 = 1
             ${this.setSql(pc_num, 'and a.pc_num = ?', [pc_num])}
             ${this.setSql(is_expire, 'and a.is_expire = ?', [is_expire])}
+            ${this.setSql(set_meal, 'and a.set_meal = ?', [set_meal])}
           GROUP BY a.id
         `;
     return this.sqlRenderPage(sql, query);
   }
 
+  /***
+   * rentComputerList
+   */
+  async rentComputerList() {
+    const sql = `
+          SELECT
+            a.id,a.pc_num,
+            b.name as shop_name
+          FROM
+            shuyou_rent_computer a
+            LEFT JOIN shuyou_rent_computer_shop b ON a.shop_id = b.id
+          WHERE
+            is_expire != 1
+          ORDER BY a.pc_num
+        `;
+    return this.nativeQuery(sql);
+  }
+
   /**
    * 更换租机编号
    * @param queryObject
@@ -174,6 +203,8 @@ export class ShuyouRentComputerService extends BaseService {
       shop_id: queryObject.shop_id,
       rent_duration: queryObject.rent_duration,
       rent_end: queryObject.rent_end,
+      set_meal: queryObject.set_meal,
+      price_type: queryObject.price_type,
       rent_price: queryObject.rent_price,
       rent_price_day: queryObject.rent_price_day,
       pay_method: queryObject.pay_method,
@@ -219,4 +250,119 @@ export class ShuyouRentComputerService extends BaseService {
     }
     return { code: 1000, data: remark };
   }
+
+  /**
+   * 退租
+   * @param queryObject
+   * @returns
+   */
+  async rentingOut(queryObject) {
+    // console.log(queryObject);
+
+    const info = await this.ShuyouRentComputerEntity.findOne({
+      id: queryObject.pc_id,
+    });
+    if (!info) {
+      return { code: -1, data: '要退租的机器编号不存在' };
+    }
+    if (info.is_expire == 1) {
+      return { code: -1, data: '要退租的机器已到期' };
+    }
+
+    // console.log(info.rent_end);
+    // console.log(queryObject.rent_end);
+    // console.log(this.utils.formatDateTime(new Date(queryObject.rent_end)));
+    let surplus_day = this.utils.dateDiff(
+      this.utils.formatDate(new Date(info.rent_end)),
+      this.utils.formatDate(new Date(queryObject.rent_end))
+    );
+    // console.log('剩余天数:' + surplus_day);
+    // 2022-09-20,租机编号1退租,剩余时长10天,编号2加5天,编号3加5天
+    var remark =
+      this.utils.formatDate(new Date()) +
+      ',租机编号' +
+      queryObject.pc_num +
+      '退租,剩余' +
+      surplus_day +
+      '天';
+    const addList = queryObject.addList;
+    let object_old = {
+      updateTime: new Date(),
+      rent_end: queryObject.rent_end,
+      rent_duration: info.rent_duration - surplus_day,
+    };
+
+    let updateResult = await this.ShuyouRentComputerEntity.createQueryBuilder()
+      .update()
+      .set(object_old)
+      .where('id = :id', {
+        id: queryObject.pc_id,
+      })
+      .execute();
+    if (updateResult.affected >= 1) {
+      await ykhForeach(addList, async (item, index) => {
+        // console.log(item.pc_id[0]);
+        // console.log(item.add_day);
+        const info2 = await this.ShuyouRentComputerEntity.findOne({
+          id: item.pc_id[0],
+        });
+        if (info2) {
+          remark =
+            remark +
+            ',编号' +
+            info2.pc_num +
+            '加' +
+            parseInt(item.add_day) +
+            '天';
+          let object_new = {
+            updateTime: new Date(),
+            rent_end: new Date(
+              Date.parse(info2.rent_end + '') +
+                1 * 24 * 60 * 60 * 1000 * parseInt(item.add_day)
+            ),
+            rent_duration: info2.rent_duration + parseInt(item.add_day),
+          };
+          const a = await this.ShuyouRentComputerEntity.createQueryBuilder()
+            .update()
+            .set(object_new)
+            .where('id = :id', {
+              id: info2.id,
+            })
+            .execute();
+          // console.log('受影响' + a.affected);
+        }
+      });
+    }
+    const res = remark;
+    if (info.remark == '' || info.remark == null) {
+      remark = remark;
+    } else {
+      remark = info.remark + ';' + remark;
+    }
+    await this.ShuyouRentComputerEntity.createQueryBuilder()
+      .update()
+      .set({
+        remark: remark,
+      })
+      .where('id = :id', {
+        id: queryObject.pc_id,
+      })
+      .execute();
+    return { code: 1000, data: res };
+  }
 }
+
+// foreach加上async/await
+const ykhForeach = async (arr, callback) => {
+  const length = arr.length;
+  const O = Object(arr);
+  let k = 0;
+  while (k < length) {
+    if (k in O) {
+      // console.log('doing foreach...');
+      const kValue = O[k];
+      await callback(kValue, k, O);
+    }
+    k++;
+  }
+};

+ 3 - 3
cool-admin-midway-master/src/app/modules/shuyou/service/rent_ledger_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-20 14:05:31
+ * @LastEditTime: 2022-09-23 16:22:23
  * @Description:
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
  */
@@ -73,9 +73,9 @@ export class ShuyouRentLedgerComputerService extends BaseService {
   //   const info = await this.ShuyouRentComputerEntity.findOne({ id });
   //   if (info) {
   //     const taskIds = await this.nativeQuery(
-  //       `select 
+  //       `select
   //         task_id
-  //       from 
+  //       from
   //         shuyou_rent_computer_usage
   //       where pc_num = ?`,
   //       [info.pc_num]

+ 12 - 2
cool-admin-midway-master/src/app/modules/task/service/rent_computer.ts

@@ -2,7 +2,7 @@
  * @Author: 倚楼听风雨 18408246387@163.com
  * @Date: 2022-09-22 14:50:54
  * @LastEditors: 倚楼听风雨 18408246387@163.com
- * @LastEditTime: 2022-09-22 18:01:13
+ * @LastEditTime: 2022-09-23 10:32:43
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\task\service\rent_computer.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -40,7 +40,7 @@ export class RentComputerTaskService extends BaseService {
    */
   async checkIsExpire() {
     let updateTime = new Date();
-    this.logger.info('checkOccupyOverTime>>>' + updateTime);
+    this.logger.info('checkIsExpire>>>' + updateTime);
     const sql = `
       SELECT pc_num,rent_start,rent_end,is_expire FROM shuyou_rent_computer
     `;
@@ -70,6 +70,16 @@ export class RentComputerTaskService extends BaseService {
 
     return 'checkIsExpire  SUCCESS>>>' + updateTime;
   }
+
+  /***
+   * 定时生成昨日租机台账表(财务)
+   */
+  async updateRentLedger() {
+    let updateTime = new Date();
+    this.logger.info('updateRentLedger>>>' + updateTime);
+
+    return 'updateRentLedger  SUCCESS>>>' + updateTime;
+  }
 }
 
 //==========================================================================================

+ 80 - 0
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/shuyouRentComputerList-select.vue

@@ -0,0 +1,80 @@
+<!--
+ * @Author: YKH
+ * @Date: 2021-12-23 17:04:33
+ * @LastEditTime: 2022-09-23 14:53:01
+ * @Description: 
+ * @FilePath: \cool-admin\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\components\shuyouGameList-select.vue
+-->
+<template>
+	<el-select
+		v-model="value"
+		v-bind="props"
+		filterable
+		multiple
+		multiple-limit="1"
+		@change="onChange"
+		placeholder="可搜索"
+	>
+		<el-option
+			v-for="(item, index) in list"
+			:key="index"
+			:value="item.id"
+			:label="'[' + item.shop_name + '] ' + item.pc_num"
+		/>
+	</el-select>
+</template>
+
+<script lang="ts">
+import { defineComponent, inject, onMounted, ref, watch } from "vue";
+import { isArray } from "/@/core/utils";
+
+export default defineComponent({
+	name: "shuyouRentComputerList",
+
+	props: {
+		modelValue: [String, Number, Array],
+		props: Object
+	},
+
+	emits: ["update:modelValue"],
+
+	setup(props, { emit }) {
+		// 请求服务
+		const service = inject<any>("service");
+
+		// 数据列表
+		const list = ref<any[]>([]);
+
+		// 绑定值
+		const value = ref<any>();
+
+		// 绑定值回调
+		function onChange(val: any) {
+			emit("update:modelValue", val);
+		}
+
+		// 解析值
+		watch(
+			() => props.modelValue,
+			(val: any) => {
+				// value.value = val;
+				value.value = (isArray(val) ? val : [val]).filter(Boolean);
+			},
+			{
+				immediate: true
+			}
+		);
+
+		onMounted(async () => {
+			let aa = await service.shuyouRentComputer.rentComputerList();
+			list.value = aa.data;
+		});
+
+		return {
+			list,
+			value,
+			onChange
+		};
+	}
+});
+</script>

+ 17 - 1
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/service/rent_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-02 19:24:43
- * @LastEditTime: 2022-09-20 16:29:59
+ * @LastEditTime: 2022-09-23 14:20:32
  * @Description: file content
  * @FilePath: \cool-admin\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\service\rent_computer.ts
  */
@@ -17,6 +17,22 @@ class ShuyouRentComputer extends BaseService {
 			data
 		});
 	}
+	@Permission("rentComputerList")
+	rentComputerList(data: any) {
+		return this.request({
+			url: "/rentComputerList",
+			method: "POST",
+			data
+		});
+	}
+	@Permission("rentingOut")
+	rentingOut(data: any) {
+		return this.request({
+			url: "/rentingOut",
+			method: "POST",
+			data
+		});
+	}
 }
 
 export default ShuyouRentComputer;

+ 236 - 46
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_computer.vue

@@ -13,6 +13,10 @@
 					{
 						label: '电脑编号',
 						value: 'pc_num'
+					},
+					{
+						label: '套餐',
+						value: 'set_meal'
 					}
 				]"
 			></cl-search-key>
@@ -20,11 +24,23 @@
 
 		<el-row>
 			<cl-table v-bind="table">
+				<template #column-rent_price="{ scope }">
+					<span v-if="scope.row.price_type == 0"
+						>{{ scope.row.rent_price }}元&nbsp;/&nbsp;天</span
+					>
+					<span v-if="scope.row.price_type == 1"
+						>{{ scope.row.rent_price }}元&nbsp;/&nbsp;周</span
+					>
+					<span v-if="scope.row.price_type == 2"
+						>{{ scope.row.rent_price }}元&nbsp;/&nbsp;月</span
+					>
+				</template>
+
 				<template #slot-renew="{ scope }">
 					<el-button type="text" size="mini" @click="renew(scope.row)">续费</el-button>
 				</template>
 				<template #slot-renting-out="{ scope }">
-					<el-button type="text" size="mini" @click="rentingOut(scope.row)"
+					<el-button type="text" size="mini" @click="switchRentingOut(scope.row)"
 						>退租</el-button
 					>
 				</template>
@@ -66,7 +82,7 @@
 			</template>
 		</cl-upsert>
 
-		<cl-dialog title="租机编号更换" v-model="visible">
+		<cl-dialog title="租机编号更换" v-model="visible_replaceNum">
 			<el-form ref="elForm" :model="replaceNumForm" size="medium" label-width="100px">
 				<el-row>
 					<el-form-item label="警告:" prop="">
@@ -97,13 +113,82 @@
 					</el-form-item>
 				</el-row>
 				<el-form-item>
-					<el-button size="small" @click="visible = false">取消</el-button>
+					<el-button size="small" @click="visible_replaceNum = false">取消</el-button>
 					<el-button type="primary" size="small" @click="replaceNum(replaceNumForm)"
 						>提交</el-button
 					>
 				</el-form-item>
 			</el-form>
 		</cl-dialog>
+		<cl-dialog title="租机退租" v-model="visible_rentingOut">
+			<el-form ref="elForm" :model="rentingOutForm" size="medium" label-width="100px">
+				<el-row>
+					<el-form-item label="警告:" prop="">
+						<el-col :span="24">
+							<p style="color: red; font-size: larger">请勿随意操作!!!</p>
+						</el-col>
+					</el-form-item>
+				</el-row>
+				<el-row>
+					<el-form-item label="租机编号" prop="pc_num">
+						<el-col :span="12">
+							<el-input
+								v-model="rentingOutForm.pc_num"
+								placeholder="租机编号"
+								disabled="true"
+							></el-input>
+						</el-col>
+					</el-form-item>
+					<el-form-item label="退租时间" prop="rent_end">
+						<el-col>
+							<el-date-picker
+								v-model="rentingOutForm.rent_end"
+								format="YYYY-MM-DD HH:mm:ss"
+								type="datetime"
+								:style="{ width: '100%' }"
+								placeholder="请选择日期"
+								clearable
+							></el-date-picker>
+						</el-col>
+					</el-form-item>
+				</el-row>
+				<el-row><el-button size="small" @click="addCardMsg()">匀时间</el-button></el-row>
+				<el-row>
+					<div class="container-scrollbar">
+						<el-scrollbar max-height="200px">
+							<el-row :gutter="24" v-for="(item, index) in cardList" :key="index">
+								<el-col :span="10">
+									<el-form-item label="租机编号">
+										<demo-select-rentComputerList v-model="item.pc_id" />
+									</el-form-item>
+								</el-col>
+								<el-col :span="8">
+									<el-form-item label="增加天数">
+										<el-input v-model="item.add_day"></el-input>
+									</el-form-item>
+								</el-col>
+								<el-col :span="2" v-if="cardList.length !== 1">
+									<el-button
+										@click="deleteCardMsg(index)"
+										class="el-icon-delete"
+										size="mini"
+										circle
+									>
+									</el-button>
+								</el-col>
+							</el-row>
+						</el-scrollbar>
+					</div>
+				</el-row>
+
+				<el-form-item>
+					<el-button size="small" @click="visible_rentingOut = false">取消</el-button>
+					<el-button type="primary" size="small" @click="rentingOut(rentingOutForm)"
+						>提交</el-button
+					>
+				</el-form-item>
+			</el-form>
+		</cl-dialog>
 	</cl-crud>
 </template>
 
@@ -111,6 +196,7 @@
 import { CrudLoad, Table, Upsert } from "cl-admin-crud-vue3/types";
 import { defineComponent, inject, reactive, ref } from "vue";
 import QueryIsExpire from "../components/query-is_expire.vue";
+import shuyouRentComputerListSelect from "../components/shuyouRentComputerList-select.vue";
 import dayjs from "dayjs";
 import { ElMessage } from "element-plus";
 import { useRefs } from "/@/core";
@@ -119,7 +205,8 @@ export default defineComponent({
 	name: "rent-computer",
 
 	components: {
-		"demo-query-is_expire": QueryIsExpire
+		"demo-query-is_expire": QueryIsExpire,
+		"demo-select-rentComputerList": shuyouRentComputerListSelect
 	},
 
 	setup() {
@@ -136,12 +223,22 @@ export default defineComponent({
 			shop_id: 0,
 			rent_duration: 0,
 			rent_end: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
+			set_meal: "",
+			price_type: 0,
 			rent_price: 0,
 			rent_price_day: 0,
 			pay_method: 0,
 			rent_person_id: ""
 		});
-		const visible = ref<boolean>(false);
+		const rentingOutForm = reactive<any>({
+			pc_num: "",
+			pc_id: 0,
+			rent_end: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
+			addList: []
+		});
+		const visible_replaceNum = ref<boolean>(false);
+		const visible_rentingOut = ref<boolean>(false);
+		let cardList = ref<any[]>([]);
 
 		// 新增、编辑配置
 		const upsert = reactive<Upsert>({
@@ -191,7 +288,7 @@ export default defineComponent({
 				},
 				{
 					prop: "shop_id",
-					label: "供应商",
+					label: "供应商",
 					span: 8,
 					component: {
 						name: "shuyouRentComputerShopSelect",
@@ -204,39 +301,21 @@ export default defineComponent({
 						message: "供应商不能为空"
 					}
 				},
-				// {
-				// 	prop: "taskIdList",
-				// 	label: "游戏任务",
-				// 	span: 24,
-				// 	component: {
-				// 		name: "el-input",
-				// 		props: {
-				// 			placeholder: "游戏任务"
-				// 		}
-				// 	},
-				// 	rules: {
-				// 		required: true,
-				// 		message: "游戏任务不能为空"
-				// 	}
-				// },
 				{
-					prop: "taskIdList",
-					label: "游戏任务",
-					span: 24,
-					value: [],
+					prop: "set_meal",
+					label: "套餐名",
+					span: 12,
 					component: {
-						name: "shuyouGameTaskNameselect",
+						name: "el-input",
 						props: {
-							props: {
-								// "multiple-limit": 3
-							}
+							placeholder: "示例:无忧套餐1"
 						}
 					}
 				},
 				{
 					prop: "rent_start",
 					label: "起租时间",
-					span: 12,
+					span: 8,
 					value: Date(),
 					component: {
 						name: "slot-rent_start"
@@ -255,7 +334,7 @@ export default defineComponent({
 					prop: "rent_duration",
 					label: "租机时长",
 					value: 1,
-					span: 12,
+					span: 8,
 					component: {
 						name: "slot-rent_duration"
 					},
@@ -267,7 +346,7 @@ export default defineComponent({
 				{
 					prop: "rent_end",
 					label: "到期时间",
-					span: 12,
+					span: 8,
 					component: {
 						name: "el-date-picker",
 						props: {
@@ -278,7 +357,30 @@ export default defineComponent({
 					}
 				},
 				{
-					label: "租机价格",
+					prop: "price_type",
+					label: "价格套餐",
+					value: 0,
+					span: 12,
+					component: {
+						name: "el-radio-group",
+						options: [
+							{
+								label: "天卡",
+								value: 0
+							},
+							{
+								label: "周卡",
+								value: 1
+							},
+							{
+								label: "月卡",
+								value: 2
+							}
+						]
+					}
+				},
+				{
+					label: "价格标准",
 					prop: "rent_price",
 					value: 0.0,
 					span: 12,
@@ -295,10 +397,23 @@ export default defineComponent({
 					}
 				},
 				{
+					prop: "taskIdList",
+					label: "游戏任务",
+					span: 24,
+					value: [],
+					component: {
+						name: "shuyouGameTaskNameselect",
+						props: {
+							props: {
+								// "multiple-limit": 3
+							}
+						}
+					}
+				},
+				{
 					prop: "remark",
 					label: "备注",
 					span: 24,
-					group: "base_msg",
 					component: {
 						name: "el-input",
 						props: {
@@ -312,7 +427,6 @@ export default defineComponent({
 					prop: "pay_method",
 					label: "结算方式",
 					value: 0,
-					group: "base_msg",
 					component: {
 						name: "el-radio-group",
 						options: [
@@ -335,7 +449,6 @@ export default defineComponent({
 					prop: "is_expire",
 					label: "是否到期",
 					value: 0,
-					group: "base_msg",
 					component: {
 						name: "el-radio-group",
 						options: [
@@ -378,7 +491,15 @@ export default defineComponent({
 					sortable: "true",
 					headerAlign: "left",
 					align: "left",
-					minWidth: 180
+					minWidth: 100
+				},
+				{
+					prop: "set_meal",
+					label: "套餐",
+					sortable: "true",
+					headerAlign: "left",
+					align: "left",
+					minWidth: 100
 				},
 				{
 					prop: "pc_num",
@@ -437,14 +558,13 @@ export default defineComponent({
 				{
 					prop: "rent_duration",
 					label: "租机时常",
-					sortable: "true",
 					headerAlign: "left",
 					align: "left",
-					minWidth: 120
+					minWidth: 80
 				},
 				{
 					prop: "rent_price",
-					label: "租机价格",
+					label: "价格标准",
 					sortable: "true",
 					headerAlign: "left",
 					align: "left",
@@ -552,20 +672,75 @@ export default defineComponent({
 		}
 		// 续费
 		async function renew(rowData) {}
+		// 拉起退租弹窗
+		async function switchRentingOut(rowData: any) {
+			cardList.value = [];
+			rentingOutForm.pc_num = rowData.pc_num;
+			rentingOutForm.pc_id = rowData.id;
+			rentingOutForm.rent_end = rowData.rent_end;
+			if (visible_rentingOut.value == false) {
+				visible_rentingOut.value = true;
+			}
+		}
+		function addCardMsg() {
+			let hasFlag = false;
+			for (let i = 0; i < cardList.value.length; i++) {
+				if (cardList.value[i].pc_id == "" || cardList.value[i].add_day == "") {
+					hasFlag = true;
+					break;
+				}
+			}
+			if (hasFlag == true) {
+				ElMessage.error("有未填写项");
+			} else {
+				cardList.value.push({
+					pc_id: "",
+					add_day: ""
+				});
+			}
+		}
+		function deleteCardMsg(index: number) {
+			cardList.value.splice(index, 1);
+		}
 		// 退租
-		async function rentingOut(rowData: any) {}
+		async function rentingOut(rowData: any) {
+			let doForm = {
+				pc_num: rowData.pc_num,
+				pc_id: rowData.pc_id,
+				rent_end: rowData.rent_end,
+				addList: cardList.value
+			};
+			service.shuyouRentComputer
+				.rentingOut(doForm)
+				.then((data: any) => {
+					console.log(data);
+					if (data.code == 1) {
+						visible_rentingOut.value = false;
+						ElMessage.success(data.message);
+					} else {
+						ElMessage.error(data.message);
+					}
+					// console.log('刷新页面')
+					refs.value.crud.refresh();
+				})
+				.catch((err: string) => {
+					ElMessage.error(err);
+				});
+		}
 		// 拉起换编号弹窗
 		async function switchReplaceNum(rowData: any) {
 			replaceNumForm.pc_num_old = rowData.pc_num;
 			replaceNumForm.shop_id = rowData.shop_id;
 			replaceNumForm.rent_duration = rowData.rent_duration;
 			replaceNumForm.rent_end = rowData.rent_end;
+			replaceNumForm.set_meal = rowData.set_meal;
+			replaceNumForm.price_type = rowData.price_type;
 			replaceNumForm.rent_price = rowData.rent_price;
 			replaceNumForm.rent_price_day = rowData.rent_price_day;
 			replaceNumForm.pay_method = rowData.pay_method;
 			replaceNumForm.rent_person_id = rowData.rent_person_id;
-			if (visible.value == false) {
-				visible.value = true;
+			if (visible_replaceNum.value == false) {
+				visible_replaceNum.value = true;
 			}
 		}
 		// 换编
@@ -576,6 +751,8 @@ export default defineComponent({
 				shop_id: rowData.shop_id,
 				rent_duration: rowData.rent_duration,
 				rent_end: rowData.rent_end,
+				set_meal: rowData.set_meal,
+				price_type: rowData.price_type,
 				rent_price: rowData.rent_price,
 				rent_price_day: rowData.rent_price_day,
 				pay_method: rowData.pay_method,
@@ -587,7 +764,7 @@ export default defineComponent({
 				.then((data: any) => {
 					// console.log(data);
 					if (data.code == 1) {
-						visible.value = false;
+						visible_replaceNum.value = false;
 						ElMessage.success(data.message);
 					} else {
 						ElMessage.error(data.message);
@@ -628,9 +805,22 @@ export default defineComponent({
 			replaceNum,
 			deleteNum,
 			switchReplaceNum,
-			visible,
-			replaceNumForm
+			switchRentingOut,
+			visible_replaceNum,
+			visible_rentingOut,
+			replaceNumForm,
+			rentingOutForm,
+			addCardMsg,
+			deleteCardMsg,
+			cardList
 		};
 	}
 });
 </script>
+<style lang="scss" scoped>
+.container-scrollbar {
+	border: 1px solid #dcdde0;
+	padding-top: 20px;
+	border-radius: 3px;
+}
+</style>