倚楼听风雨 лет назад: 3
Родитель
Сommit
1360e07393

+ 1 - 1
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-23 18:46:02
+ * @LastEditTime: 2022-09-26 17:06:22
  * @Description: file content
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_computer.ts
  */

+ 2 - 2
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-23 18:47:09
+ * @LastEditTime: 2022-09-26 18:25:10
  * @Description:
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
  */
@@ -279,7 +279,7 @@ export class ShuyouRentComputerService extends BaseService {
     // console.log('剩余天数:' + surplus_day);
     // 2022-09-20,租机编号1退租,剩余时长10天,编号2加5天,编号3加5天
     var remark =
-      this.utils.formatDate(new Date()) +
+      this.utils.formatDate(queryObject.rent_end) +
       ',租机编号' +
       queryObject.pc_num +
       '退租,剩余' +

+ 51 - 6
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_computer.vue

@@ -40,12 +40,20 @@
 					<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="switchRentingOut(scope.row)"
+					<el-button
+						v-if="scope.row.is_expire != 1"
+						type="text"
+						size="mini"
+						@click="switchRentingOut(scope.row)"
 						>退租</el-button
 					>
 				</template>
 				<template #slot-replace-num="{ scope }">
-					<el-button type="text" size="mini" @click="switchReplaceNum(scope.row)"
+					<el-button
+						v-if="scope.row.is_expire != 1"
+						type="text"
+						size="mini"
+						@click="switchReplaceNum(scope.row)"
 						>换编号</el-button
 					>
 				</template>
@@ -67,7 +75,7 @@
 				<el-date-picker
 					v-model="scope.rent_start"
 					type="date"
-					:@change="calculateRentDuration(scope)"
+					@change="calculateRentDuration(scope)"
 					placeholder="选择租机日期"
 				>
 				</el-date-picker>
@@ -112,6 +120,7 @@
 						</el-col>
 					</el-form-item>
 				</el-row>
+				<el-divider />
 				<el-form-item>
 					<el-button size="small" @click="visible_replaceNum = false">取消</el-button>
 					<el-button type="primary" size="small" @click="replaceNum(replaceNumForm)"
@@ -148,11 +157,25 @@
 								:style="{ width: '100%' }"
 								placeholder="请选择日期"
 								clearable
+								@change="calculateRentDay(rentingOutForm)"
 							></el-date-picker>
 						</el-col>
 					</el-form-item>
 				</el-row>
-				<el-row><el-button size="small" @click="addCardMsg()">匀时间</el-button></el-row>
+				<el-row>
+					<el-form-item label="剩余天数" prop="">
+						<el-col :span="24">
+							<el-tag :key="rentingOutForm.day" type="warning" effect="light">
+								{{ rentingOutForm.day }}
+							</el-tag>
+						</el-col>
+					</el-form-item>
+				</el-row>
+				<el-row
+					><el-col :span="12" style="margin-left: 30px"
+						><el-button size="small" @click="addCardMsg()">匀时间</el-button></el-col
+					></el-row
+				>
 				<el-row>
 					<div class="container-scrollbar">
 						<el-scrollbar max-height="200px">
@@ -180,7 +203,7 @@
 						</el-scrollbar>
 					</div>
 				</el-row>
-
+				<el-divider />
 				<el-form-item>
 					<el-button size="small" @click="visible_rentingOut = false">取消</el-button>
 					<el-button type="primary" size="small" @click="rentingOut(rentingOutForm)"
@@ -200,6 +223,7 @@ import shuyouRentComputerListSelect from "../components/shuyouRentComputerList-s
 import dayjs from "dayjs";
 import { ElMessage } from "element-plus";
 import { useRefs } from "/@/core";
+import { floor } from "lodash";
 
 export default defineComponent({
 	name: "rent-computer",
@@ -233,12 +257,14 @@ export default defineComponent({
 		const rentingOutForm = reactive<any>({
 			pc_num: "",
 			pc_id: 0,
+			day: 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 rent_end = ref<string>("");
 
 		// 新增、编辑配置
 		const upsert = reactive<Upsert>({
@@ -670,6 +696,21 @@ export default defineComponent({
 					1 * 24 * 60 * 60 * 1000 * (parseInt(scope.rent_duration) - 1)
 			);
 		}
+		// 计算退租剩余时间
+		function calculateRentDay(scope: { day: number; rent_end: string }) {
+			if (Date.parse(rent_end.value) < Date.parse(scope.rent_end)) {
+				scope.rent_end = rent_end.value;
+				ElMessage.error("退租时间不能大于到期时间");
+			}
+			scope.day = Math.ceil(
+				parseInt(
+					(Date.parse(rent_end.value) - Date.parse(scope.rent_end)) /
+						(24 * 60 * 60 * 1000) +
+						""
+				)
+			);
+			// console.log(scope.day);
+		}
 		// 续费
 		async function renew(rowData) {}
 		// 拉起退租弹窗
@@ -678,6 +719,8 @@ export default defineComponent({
 			rentingOutForm.pc_num = rowData.pc_num;
 			rentingOutForm.pc_id = rowData.id;
 			rentingOutForm.rent_end = rowData.rent_end;
+			rentingOutForm.day = 0;
+			rent_end.value = rowData.rent_end;
 			if (visible_rentingOut.value == false) {
 				visible_rentingOut.value = true;
 			}
@@ -800,6 +843,7 @@ export default defineComponent({
 			table,
 			onLoad,
 			calculateRentDuration,
+			calculateRentDay,
 			renew,
 			rentingOut,
 			replaceNum,
@@ -819,8 +863,9 @@ export default defineComponent({
 </script>
 <style lang="scss" scoped>
 .container-scrollbar {
-	border: 1px solid #dcdde0;
+	// border: 1px solid #dcdde0;
 	padding-top: 20px;
 	border-radius: 3px;
+	margin-left: 30px;
 }
 </style>