倚楼听风雨 3 rokov pred
rodič
commit
bfb9dadf31
21 zmenil súbory, kde vykonal 1122 pridanie a 517 odobranie
  1. 19 25
      cool-admin-midway-master/README.md
  2. 2 1
      cool-admin-midway-master/package.json
  3. 158 52
      cool-admin-midway-master/src/app/modules/shuyou/controller/admin/game_account.ts
  4. 69 43
      cool-admin-midway-master/src/app/modules/shuyou/controller/admin/idcard.ts
  5. 61 1
      cool-admin-midway-master/src/app/modules/shuyou/controller/admin/rent_computer.ts
  6. 5 7
      cool-admin-midway-master/src/app/modules/shuyou/controller/admin/rent_ledger_computer.ts
  7. 8 1
      cool-admin-midway-master/src/app/modules/shuyou/entity/rent_computer.ts
  8. 30 5
      cool-admin-midway-master/src/app/modules/shuyou/entity/rent_ledger_computer.ts
  9. 126 7
      cool-admin-midway-master/src/app/modules/shuyou/service/rent_computer.ts
  10. 32 115
      cool-admin-midway-master/src/app/modules/shuyou/service/rent_ledger_computer.ts
  11. 69 4
      cool-admin-midway-master/src/app/modules/task/service/rent_computer.ts
  12. 20 15
      cool-admin-midway-master/src/app/modules/task/service/shuyou.ts
  13. 3 3
      cool-admin-midway-master/src/welcome.ts
  14. 68 0
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/adv-search-computer.vue
  15. 14 26
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/adv-search-ledgerComputer.vue
  16. 16 16
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/index.ts
  17. 24 0
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/service/rent_computer.ts
  18. 4 4
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/idcard.vue
  19. 263 21
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_computer.vue
  20. 127 164
      cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_ledger_computer.vue
  21. 4 7
      cool-admin-vue-vue3-ts-vite/src/views/home/components/person-tab.vue

+ 19 - 25
cool-admin-midway-master/README.md

@@ -1,36 +1,38 @@
 <!--
  * @Author: YKH
  * @Date: 2021-12-08 10:23:31
- * @LastEditTime: 2022-09-16 17:56:39
- * @Description: 
+ * @LastEditTime: 2022-09-29 15:01:04
+ * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\README.md
 -->
-shuyou_game_complete添加字段:remark
 
- 
-## Node版后台基础框架基于Egg.js
+## Node 版后台基础框架基于 Egg.js
 
 # 基础:egg.js
+
 # 数据:typeorm
+
 # 缓存:egg-redis
+
 # 鉴权:egg-jwt
+
 # 网络:axios
 
 #### 修改数据库配置,配置文件位于`src/config/config.local.ts`
 
-数据库为mysql(`>=5.7版本`),node版本(`>=12.x`),首次启动会自动初始化并导入数据
+数据库为 mysql(`>=5.7版本`),node 版本(`>=12.x`),首次启动会自动初始化并导入数据
 
 ```js
 config.orm = {
-    type: 'mysql',
-    host: '127.0.0.1',
-    port: 3306,
-    username: 'root',
-    password: 'root',
-    database: 'cool-admin',
-    synchronize: true,
-    logging: true,
-}
+  type: 'mysql',
+  host: '127.0.0.1',
+  port: 3306,
+  username: 'root',
+  password: 'root',
+  database: 'cool-admin',
+  synchronize: true,
+  logging: true,
+};
 ```
 
 #### 安装依赖并运行
@@ -43,7 +45,6 @@ $ open http://localhost:8001/
 
 注: `npm i`如果安装失败可以尝试使用[cnpm](https://developer.aliyun.com/mirror/NPM?from=tnpm),或者切换您的镜像源
 
-
 ### 部署
 
 rm -rf node_modules
@@ -51,10 +52,8 @@ rm package-lock.json
 npm cache clear --force
 npm install
 
-
 npm run build
 
-
 ```bash
 $ npm start
 $ npm stop
@@ -65,26 +64,22 @@ $ npm stop
 - 使用 `npm run lint` 来做代码风格检查。
 - 使用 `npm test` 来执行单元测试。
 
-
 [midway]: https://midwayjs.org
 
-
 ## 个人记录
+
 - rm -rf node_modules
 - rm package-lock.json
 - npm cache clear --force
 - npm install
 
-
-
 - npm run start
 - lsof -i:8001
 - netstat -tunlp | grep 8001
 
 - curl 'http://127.0.0.1:8001'
 
-
-- SERVER需要单独安装axios
+- SERVER 需要单独安装 axios
 - cd /home/cool/server
 - npm i axios
 - // npm install qiniu
@@ -93,4 +88,3 @@ $ npm stop
 - // yarn add spark-md5
 - // yarn add sha1-file-web
 - yarn add qiniu-js
-

+ 2 - 1
cool-admin-midway-master/package.json

@@ -27,6 +27,7 @@
         "midwayjs-cool-wxpay": "^1.0.12",
         "mini-svg-data-uri": "^1.4.3",
         "mysql2": "^2.3.0",
+        "node-xlsx": "^0.21.0",
         "qiniu": "^7.4.0",
         "qrcode-reader": "^1.0.4",
         "svg-captcha": "^1.4.0",
@@ -89,4 +90,4 @@
     },
     "author": "cool-js.com",
     "license": "MIT"
-}
+}

+ 158 - 52
cool-admin-midway-master/src/app/modules/shuyou/controller/admin/game_account.ts

@@ -8,7 +8,7 @@ import { ILogger } from '@midwayjs/logger';
 import { ShuyouGameAccountService } from '../../service/game_account';
 import { ShuyouGameAccountTempService } from '../../service/game_account_temp';
 // import { ShuyouIdCardUsageEntity } from '../../entity/idcard_usage';
-const fs = require('fs')
+const fs = require('fs');
 
 /**
  * 商品
@@ -31,11 +31,11 @@ const fs = require('fs')
   before: ctx => {
     //前段数据转JSON格式
     const data = ctx.request.body;
-    if (data.id_name == "") {
-      data.id_name = null
+    if (data.id_name == '') {
+      data.id_name = null;
     }
-    if (data.id_number == "") {
-      data.id_number = null
+    if (data.id_number == '') {
+      data.id_number = null;
     }
     ctx.request.body.data = JSON.stringify(data);
   },
@@ -73,7 +73,6 @@ const fs = require('fs')
   },
 })
 export class ShuyouAdminGameAccountController extends BaseController {
-
   @Inject()
   logger: ILogger;
 
@@ -88,26 +87,25 @@ export class ShuyouAdminGameAccountController extends BaseController {
    */
   @Post('/batchAdd')
   async batchAdd(@Body(ALL) queryObject) {
-
     const { fileaddress, type_id, status, remark } = queryObject;
-    const filename = fileaddress._value.split("uploads")[1]
+    const filename = fileaddress._value.split('uploads')[1];
     // console.log(filename)
-    let reqmsg
+    let reqmsg;
     // 定义读取文件函数
     var readFile = function (fileName) {
       return new Promise(function (resolve, reject) {
         fs.readFile(fileName, function (error, data) {
           if (error) return reject(error);
-          var chrom = "";
+          var chrom = '';
           let idcardArr = [];
           chrom = data.toString();
-          const accounts = chrom.split(/[\r\n]+/);//按照换行符分割成数组
+          const accounts = chrom.split(/[\r\n]+/); //按照换行符分割成数组
           accounts.forEach((item, index) => {
             if (item) {
-              var data1 = item.split('----')
+              var data1 = item.split('----');
               if (data1.length < 2) {
-                console.log(index + "文件格式错误")
-                resolve({ code: -1, message: index + '文件格式错误' })
+                console.log(index + '文件格式错误');
+                resolve({ code: -1, message: index + '文件格式错误' });
               }
               let obj = {
                 account_text: data1[0],
@@ -123,74 +121,177 @@ export class ShuyouAdminGameAccountController extends BaseController {
                 mac: data1[10],
                 type_id: type_id,
                 status: status,
-                remark: remark
-              }
-              idcardArr.push(obj)
+                remark: remark,
+              };
+              idcardArr.push(obj);
             }
-          })
+          });
           resolve({ code: 1, data: idcardArr });
         });
       });
     };
-    let composeText
-    composeText = await readFile("public/uploads" + filename);
+    let composeText;
+    composeText = await readFile('public/uploads' + filename);
     if (composeText.code == -1) {
       return this.ok({ code: -1, message: '文件格式错误' });
     }
     //======================================================插入临时表开始======================================================
     // 将文件拆分为1万一个,一次上传1万条,防止数据库报错
-    let idcard_text_temp
+    let idcard_text_temp;
     await ykhForeach(composeText.data, async (item, index) => {
       if (index % 10000 == 0) {
         if (index != 0) {
           await this.ShuyouGameAccountTempService.batchAdd(idcard_text_temp);
         }
-        idcard_text_temp = `('` + item.account_text + `',` + `'` + item.password_text + `',` + `'` + item.remark + `')`
+        idcard_text_temp =
+          `('` +
+          item.account_text +
+          `',` +
+          `'` +
+          item.password_text +
+          `',` +
+          `'` +
+          item.remark +
+          `')`;
       } else {
-        idcard_text_temp += `,('` + item.account_text + `',` + `'` + item.password_text + `',` + `'` + item.remark + `')`
+        idcard_text_temp +=
+          `,('` +
+          item.account_text +
+          `',` +
+          `'` +
+          item.password_text +
+          `',` +
+          `'` +
+          item.remark +
+          `')`;
         if (index == composeText.data.length - 1) {
           await this.ShuyouGameAccountTempService.batchAdd(idcard_text_temp);
         }
       }
-
     });
     //======================================================插入临时表结束======================================================
     //对比临时表和账号表,找出账号表中已存在的数据
     let repeat = await this.ShuyouGameAccountTempService.contrastData(type_id);
-    this.logger.info(repeat.length)
+    this.logger.info(repeat.length);
     //清空临时表数据
     await this.ShuyouGameAccountTempService.deleteAll();
     // 将文件拆分为1万一个,一次上传1万条,防止数据库报错
-    let idcard_text
-    let sumaccAll = 0
-    let duplicatesAll = 0
-    let affectedRowsAll = 0
+    let idcard_text;
+    let sumaccAll = 0;
+    let duplicatesAll = 0;
+    let affectedRowsAll = 0;
     await ykhForeach(composeText.data, async (item, index) => {
       if (index % 10000 == 0) {
         if (index != 0) {
           reqmsg = await this.ShuyouGameAccountService.batchAdd(idcard_text);
-          // this.logger.info(reqmsg)
-          let str = reqmsg.message.toString();
+          this.logger.info(reqmsg);
+          let str = reqmsg.info.toString();
           let duplicates;
-          duplicates = str.substring(str.indexOf('Duplicates') + 12, str.indexOf('Warnings') - 1);
+          duplicates = str.substring(
+            str.indexOf('Duplicates') + 12,
+            str.indexOf('Warnings') - 1
+          );
           // let sumacc = parseInt(reqmsg.warningCount + reqmsg.affectedRows) - parseInt(reqmsg.changedRows);
           // sumaccAll += sumacc;
           duplicatesAll += parseInt(duplicates);
           affectedRowsAll += parseInt(reqmsg.affectedRows);
         }
-        idcard_text = `('` + item.account_text + `',` + `'` + item.password_text + `',` + `'` + item.vpn_text + `',` + `'` + item.manufacturer
-          + `',` + `'` + item.model + `',` + `'` + item.pnumber + `',` + `'` + item.imei + `',` + `'` + item.imsi + `',` + `'` + item.simserial
-          + `',` + `'` + item.androidid + `',` + `'` + item.mac + `',` + `'` + item.type_id + `',` + `'` + item.status + `',` + `'` + item.remark + `')`
+        idcard_text =
+          `('` +
+          item.account_text +
+          `',` +
+          `'` +
+          item.password_text +
+          `',` +
+          `'` +
+          item.vpn_text +
+          `',` +
+          `'` +
+          item.manufacturer +
+          `',` +
+          `'` +
+          item.model +
+          `',` +
+          `'` +
+          item.pnumber +
+          `',` +
+          `'` +
+          item.imei +
+          `',` +
+          `'` +
+          item.imsi +
+          `',` +
+          `'` +
+          item.simserial +
+          `',` +
+          `'` +
+          item.androidid +
+          `',` +
+          `'` +
+          item.mac +
+          `',` +
+          `'` +
+          item.type_id +
+          `',` +
+          `'` +
+          item.status +
+          `',` +
+          `'` +
+          item.remark +
+          `')`;
       } else {
-        idcard_text += `,('` + item.account_text + `',` + `'` + item.password_text + `',` + `'` + item.vpn_text + `',` + `'` + item.manufacturer
-          + `',` + `'` + item.model + `',` + `'` + item.pnumber + `',` + `'` + item.imei + `',` + `'` + item.imsi + `',` + `'` + item.simserial
-          + `',` + `'` + item.androidid + `',` + `'` + item.mac + `',` + `'` + item.type_id + `',` + `'` + item.status + `',` + `'` + item.remark + `')`
+        idcard_text +=
+          `,('` +
+          item.account_text +
+          `',` +
+          `'` +
+          item.password_text +
+          `',` +
+          `'` +
+          item.vpn_text +
+          `',` +
+          `'` +
+          item.manufacturer +
+          `',` +
+          `'` +
+          item.model +
+          `',` +
+          `'` +
+          item.pnumber +
+          `',` +
+          `'` +
+          item.imei +
+          `',` +
+          `'` +
+          item.imsi +
+          `',` +
+          `'` +
+          item.simserial +
+          `',` +
+          `'` +
+          item.androidid +
+          `',` +
+          `'` +
+          item.mac +
+          `',` +
+          `'` +
+          item.type_id +
+          `',` +
+          `'` +
+          item.status +
+          `',` +
+          `'` +
+          item.remark +
+          `')`;
         if (index == composeText.data.length - 1) {
           reqmsg = await this.ShuyouGameAccountService.batchAdd(idcard_text);
-          // this.logger.info(reqmsg)
-          let str = reqmsg.message.toString();
+          this.logger.info(reqmsg);
+          let str = reqmsg.info.toString();
           let duplicates;
-          duplicates = str.substring(str.indexOf('Duplicates') + 12, str.indexOf('Warnings') - 1);
+          duplicates = str.substring(
+            str.indexOf('Duplicates') + 12,
+            str.indexOf('Warnings') - 1
+          );
           // let sumacc = parseInt(reqmsg.warningCount + reqmsg.affectedRows) - parseInt(reqmsg.changedRows);
           // sumaccAll += sumacc;
           duplicatesAll += parseInt(duplicates);
@@ -200,19 +301,25 @@ export class ShuyouAdminGameAccountController extends BaseController {
     });
     //删除上传的txt
     //================
-    if (fs.existsSync("public/uploads" + filename)) {
-      fs.unlinkSync("public/uploads" + filename);
+    if (fs.existsSync('public/uploads' + filename)) {
+      fs.unlinkSync('public/uploads' + filename);
     }
     //================
-    sumaccAll = duplicatesAll + affectedRowsAll
-    return this.ok({ code: 1, repeat: repeat, duplicatesAll: duplicatesAll, message: '本次上传账号共计' + sumaccAll + '条, 成功上传' + affectedRowsAll + '条, 重复数据' + duplicatesAll + '条' });
-
+    sumaccAll = duplicatesAll + affectedRowsAll;
+    return this.ok({
+      code: 1,
+      repeat: repeat,
+      duplicatesAll: duplicatesAll,
+      message:
+        '本次上传账号共计' +
+        sumaccAll +
+        '条, 成功上传' +
+        affectedRowsAll +
+        '条, 重复数据' +
+        duplicatesAll +
+        '条',
+    });
   }
-
-
-
-
-
 }
 
 // foreach加上async/await
@@ -229,4 +336,3 @@ const ykhForeach = async (arr, callback) => {
     k++;
   }
 };
-

+ 69 - 43
cool-admin-midway-master/src/app/modules/shuyou/controller/admin/idcard.ts

@@ -7,7 +7,7 @@ import * as _ from 'lodash';
 import { ILogger } from '@midwayjs/logger';
 import { ShuyouIdCardService } from '../../service/idcard';
 // import { ShuyouIdCardUsageEntity } from '../../entity/idcard_usage';
-const fs = require('fs')
+const fs = require('fs');
 
 /**
  * 商品
@@ -30,11 +30,11 @@ const fs = require('fs')
   before: ctx => {
     //前段数据转JSON格式
     const data = ctx.request.body;
-    if (data.id_name == "") {
-      data.id_name = null
+    if (data.id_name == '') {
+      data.id_name = null;
     }
-    if (data.id_number == "") {
-      data.id_number = null
+    if (data.id_number == '') {
+      data.id_number = null;
     }
     ctx.request.body.data = JSON.stringify(data);
   },
@@ -72,7 +72,6 @@ const fs = require('fs')
   },
 })
 export class ShuyouAdminIdCardController extends BaseController {
-
   @Inject()
   logger: ILogger;
 
@@ -84,35 +83,34 @@ export class ShuyouAdminIdCardController extends BaseController {
    */
   @Post('/batchAdd')
   async batchAdd(@Body(ALL) queryObject) {
-
     const { fileaddress, flag } = queryObject;
     // console.log(uploadtime)
     // console.log(fileaddress._value)
-    const filename = fileaddress._value.split("uploads")[1]
+    const filename = fileaddress._value.split('uploads')[1];
     // console.log(filename)
-    let flagstr = ''
+    let flagstr = '';
     if (flag) {
-      flagstr = flag
+      flagstr = flag;
     }
-    let reqmsg
+    let reqmsg;
     // var data =fs.readFileSync("public/uploads"+filename);
     // 定义读取文件函数
     var readFile = function (fileName) {
       return new Promise(function (resolve, reject) {
         fs.readFile(fileName, function (error, data) {
           if (error) return reject(error);
-          var chrom = "";
+          var chrom = '';
           let idcardArr = [];
           chrom = data.toString();
-          const accounts = chrom.split(/[\r\n]+/);//按照换行符分割成数组
+          const accounts = chrom.split(/[\r\n]+/); //按照换行符分割成数组
           // console.log(accounts.length)
           accounts.forEach((item, index) => {
             if (item) {
-              var data1 = item.split('----')
+              var data1 = item.split('----');
               if (data1.length < 2) {
                 // console.log(item)
-                console.log(index + "文件格式错误")
-                resolve({ code: -1, message: index + '文件格式错误' })
+                console.log(index + '文件格式错误');
+                resolve({ code: -1, message: index + '文件格式错误' });
               }
               // if (index == 0) {
               //   idcard_text = `('` + data1[0] + `',` + `'` + data1[1] + `',` + `'` + flagstr + `')`
@@ -122,49 +120,73 @@ export class ShuyouAdminIdCardController extends BaseController {
               let obj = {
                 id_name: data1[0],
                 id_number: data1[1],
-                flag: flagstr
-              }
-              idcardArr.push(obj)
+                flag: flagstr,
+              };
+              idcardArr.push(obj);
             }
-          })
+          });
           resolve({ code: 1, data: idcardArr });
         });
       });
     };
-    let composeText
-    composeText = await readFile("public/uploads" + filename);
+    let composeText;
+    composeText = await readFile('public/uploads' + filename);
     if (composeText.code == -1) {
       return await this.ok({ code: -1, message: '文件格式错误' });
     }
     // 将文件拆分为1万一个,一次上传1万条,防止数据库报错
-    let idcard_text
-    let sumaccAll = 0
-    let duplicatesAll = 0
-    let affectedRowsAll = 0
+    let idcard_text;
+    let sumaccAll = 0;
+    let duplicatesAll = 0;
+    let affectedRowsAll = 0;
     await ykhForeach(composeText.data, async (item, index) => {
       if (index % 10000 == 0) {
         if (index != 0) {
           reqmsg = await this.ShuyouIdCardService.batchAdd(idcard_text);
           //   logger.info(reqmsg)
-          let str = reqmsg.message.toString();
+          let str = reqmsg.info.toString();
           let duplicates;
-          duplicates = str.substring(str.indexOf('Duplicates') + 12, str.indexOf('Warnings') - 1);
+          duplicates = str.substring(
+            str.indexOf('Duplicates') + 12,
+            str.indexOf('Warnings') - 1
+          );
           let sumacc = parseInt(reqmsg.warningCount + reqmsg.affectedRows);
           sumaccAll += sumacc;
           duplicatesAll += parseInt(duplicates);
           affectedRowsAll += parseInt(reqmsg.affectedRows);
         }
-        idcard_text = ``
-        idcard_text = `('` + item.id_name + `',` + `'` + item.id_number + `',` + `'` + item.flag + `')`
+        idcard_text = ``;
+        idcard_text =
+          `('` +
+          item.id_name +
+          `',` +
+          `'` +
+          item.id_number +
+          `',` +
+          `'` +
+          item.flag +
+          `')`;
       } else {
-        idcard_text += `,('` + item.id_name + `',` + `'` + item.id_number + `',` + `'` + item.flag + `')`
+        idcard_text +=
+          `,('` +
+          item.id_name +
+          `',` +
+          `'` +
+          item.id_number +
+          `',` +
+          `'` +
+          item.flag +
+          `')`;
       }
       if (index == composeText.data.length - 1) {
         reqmsg = await this.ShuyouIdCardService.batchAdd(idcard_text);
         //   logger.info(reqmsg)
-        let str = reqmsg.message.toString();
+        let str = reqmsg.info.toString();
         let duplicates;
-        duplicates = str.substring(str.indexOf('Duplicates') + 12, str.indexOf('Warnings') - 1);
+        duplicates = str.substring(
+          str.indexOf('Duplicates') + 12,
+          str.indexOf('Warnings') - 1
+        );
         let sumacc = parseInt(reqmsg.warningCount + reqmsg.affectedRows);
         sumaccAll += sumacc;
         duplicatesAll += parseInt(duplicates);
@@ -173,19 +195,23 @@ export class ShuyouAdminIdCardController extends BaseController {
     });
     //删除上传的txt
     //================
-    if (fs.existsSync("public/uploads" + filename)) {
-      fs.unlinkSync("public/uploads" + filename);
+    if (fs.existsSync('public/uploads' + filename)) {
+      fs.unlinkSync('public/uploads' + filename);
     }
     //================
-    return this.ok({ code: 1, message: '本次上传身份信息共计' + sumaccAll + '条, 成功上传' + affectedRowsAll + '条, 重复数据' + duplicatesAll + '条' });
-
-
+    return this.ok({
+      code: 1,
+      message:
+        '本次上传身份信息共计' +
+        sumaccAll +
+        '条, 成功上传' +
+        affectedRowsAll +
+        '条, 重复数据' +
+        duplicatesAll +
+        '条',
+    });
   }
 
-
-
-
-
   /**
    * 其他接口
    */
@@ -208,4 +234,4 @@ const ykhForeach = async (arr, callback) => {
     }
     k++;
   }
-};
+};

+ 61 - 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-23 15:22:44
+ * @LastEditTime: 2022-09-29 15:24:19
  * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\rent_computer.ts
  */
@@ -10,6 +10,8 @@ import { CoolController, BaseController } from 'midwayjs-cool-core';
 import { ShuyouRentComputerEntity } from '../../entity/rent_computer';
 import { ShuyouRentComputerService } from '../../service/rent_computer';
 import { ILogger } from '@midwayjs/logger';
+// import xlsx from 'node-xlsx';
+// import fs from 'fs';
 
 /**
  * 租机
@@ -88,4 +90,62 @@ export class ShuyouRentComputerController extends BaseController {
     let list = await this.ShuyouRentComputerService.rentComputerList();
     return await this.ok({ code: 1, data: list });
   }
+  // 租机续费
+  @Post('/renew')
+  async renew(@Body(ALL) queryObject) {
+    // this.logger.info(queryObject);
+    let reqmsg = await this.ShuyouRentComputerService.renew(queryObject);
+    if (reqmsg.code == 1000) {
+      return await this.ok({ code: 1, message: reqmsg.data });
+    } else {
+      return await this.fail(reqmsg.data, -1);
+    }
+  }
+  // 租机下架
+  @Post('/offShelf')
+  async offShelf(@Body(ALL) queryObject) {
+    this.logger.info(queryObject);
+    let reqmsg = await this.ShuyouRentComputerService.offShelf(queryObject);
+    if (reqmsg.code == 1000) {
+      return await this.ok({ code: 1, message: reqmsg.data });
+    } else {
+      return await this.fail(reqmsg.data, -1);
+    }
+  }
+  @Post('/batchImport')
+  async batchImport(@Body(ALL) queryObject) {
+    console.log(queryObject);
+
+    // const { fileaddress } = queryObject;
+    // console.log(fileaddress._value);
+    // const filename = fileaddress._value.split('uploads')[1];
+    // console.log(filename);
+
+    // const filename = fileaddress.split('uploads')[1];
+    // 解析文件
+    // const data = xlsx.parse(filename);
+    // console.log(data);
+
+    // 以 buffer 形式导入
+    // const workSheetsFromBuffer = xlsx.parse(fs.readFileSync(filename));
+    // console.log(JSON.stringify(workSheetsFromBuffer, null, 2));
+
+    // 以文件形式导入
+    // const workSheetsFromFile = xlsx.parse(
+    //   'F:/project/cool-admin-3.x/cool-admin-midway-master/public/uploads/20220928/187a94f0-3f00-11ed-b595-3fe20740ebd9.xls'
+    // );
+    // console.log(JSON.stringify(workSheetsFromFile, null, 2));
+
+    // try {
+    //   // 解析文件
+    //   const data = xlsx.parse(file.filepath);
+    //   console.log(data);
+
+    //   // xlsx包使用方式
+    //   //  const data = XLSX.readFile(file.filepath, {});
+    //   //  const json = XLSX.utils.sheet_to_json(data.Sheets['Sheet1']);
+    // } finally {
+    //   fs.unlinkSync(file.filepath);
+    // }
+  }
 }

+ 5 - 7
cool-admin-midway-master/src/app/modules/shuyou/controller/admin/rent_ledger_computer.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-20 14:07:34
- * @Description: 
+ * @LastEditTime: 2022-09-27 18:27:43
+ * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\rent_computer.ts
  */
 import { Provide } from '@midwayjs/decorator';
@@ -32,8 +32,8 @@ import { ShuyouRentLedgerComputerService } from '../../service/rent_ledger_compu
   before: ctx => {
     //前段数据转JSON格式
     const data = ctx.request.body;
-    if (data.pc_num == "") {
-      data.pc_num = null
+    if (typeof data.new_date == 'undefined') {
+      data.new_date = [new Date(), new Date()];
     }
     ctx.request.body.data = JSON.stringify(data);
   },
@@ -50,6 +50,4 @@ import { ShuyouRentLedgerComputerService } from '../../service/rent_ledger_compu
     },
   },
 })
-export class ShuyouRentLedgerComputerController extends BaseController {
-
-}
+export class ShuyouRentLedgerComputerController extends BaseController {}

+ 8 - 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-26 17:06:22
+ * @LastEditTime: 2022-09-27 16:57:15
  * @Description: file content
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_computer.ts
  */
@@ -94,4 +94,11 @@ export class ShuyouRentComputerEntity extends BaseEntity {
 
   @Column({ comment: '备注', nullable: true })
   remark: string;
+
+  @Column({
+    comment: '是否下架 0:否 1:是',
+    default: 0,
+    type: 'tinyint',
+  })
+  is_offShelf: number;
 }

+ 30 - 5
cool-admin-midway-master/src/app/modules/shuyou/entity/rent_ledger_computer.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-01 20:41:58
- * @LastEditTime: 2022-09-23 11:49:24
+ * @LastEditTime: 2022-09-27 16:44:39
  * @Description: file content
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_ledger_computer.ts
  */
@@ -15,10 +15,21 @@ import { BaseEntity } from 'midwayjs-cool-core';
 @EntityModel('shuyou_rent_ledger_computer')
 export class ShuyouRentLedgerComputerEntity extends BaseEntity {
   @Index()
+  @Column({ type: 'date', comment: '台账日期' })
+  new_date: Date;
+
+  @Index()
   @Column({ comment: '电脑编号', length: 100 })
   pc_num: string;
 
   @Index()
+  @Column({ comment: '机房电脑名称', length: 100 })
+  pc_name: string;
+
+  @Column({ comment: '租机店铺ID' })
+  shop_id: number;
+
+  @Index()
   @Column({ comment: '套餐', length: 100, nullable: true })
   set_meal: string;
 
@@ -57,6 +68,20 @@ export class ShuyouRentLedgerComputerEntity extends BaseEntity {
   rent_price_day: number;
 
   @Column({
+    comment: '结算方式 0:先付后用 1:先用后付 2:其他方式',
+    default: 0,
+    type: 'tinyint',
+  })
+  pay_method: number;
+
+  @Column({
+    comment: '是否到期 0:否 1:是 2:明日到期',
+    default: 0,
+    type: 'tinyint',
+  })
+  is_expire: number;
+
+  @Column({
     type: 'decimal',
     comment: '当前租赁期内已产生多少租金',
     precision: 10,
@@ -65,11 +90,11 @@ export class ShuyouRentLedgerComputerEntity extends BaseEntity {
   })
   rent_price_used_then: number;
 
-  @Column({ comment: '游戏任务,多个游戏以英文逗号隔开', nullable: true })
-  taskNameList_then: string;
+  // @Column({ comment: '游戏任务,多个游戏以英文逗号隔开', nullable: true })
+  // taskNameList_then: string;
 
-  @Column({ comment: '负责人,多个负责人以英文逗号隔开', nullable: true })
-  directorNameList_then: string;
+  // @Column({ comment: '负责人,多个负责人以英文逗号隔开', nullable: true })
+  // directorNameList_then: string;
 
   @Column({ comment: '备注', nullable: true })
   remark: string;

+ 126 - 7
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-26 18:25:10
+ * @LastEditTime: 2022-09-29 18:17:45
  * @Description:
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
  */
@@ -128,7 +128,7 @@ export class ShuyouRentComputerService extends BaseService {
    * @param query
    */
   async page(query) {
-    const { pc_num, is_expire, set_meal } = query;
+    const { pc_num, is_expire, set_meal, shop_id } = query;
     const sql = `
           SELECT
             a.*,
@@ -142,10 +142,11 @@ export class ShuyouRentComputerService extends BaseService {
             LEFT JOIN shuyou_rent_computer_usage d ON a.pc_num = d.pc_num
             LEFT JOIN shuyou_game_task e ON e.id = d.task_id
             LEFT JOIN shuyou_game_director f ON f.id = e.directorId
-          WHERE 1 = 1
+          WHERE is_offShelf = 0
             ${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])}
+            ${this.setSql(set_meal, 'and a.set_meal LIKE ?', [`%${set_meal}%`])}
+            ${this.setSql(shop_id, 'and a.shop_id = ?', [shop_id])}
           GROUP BY a.id
         `;
     return this.sqlRenderPage(sql, query);
@@ -164,6 +165,7 @@ export class ShuyouRentComputerService extends BaseService {
             LEFT JOIN shuyou_rent_computer_shop b ON a.shop_id = b.id
           WHERE
             is_expire != 1
+            and is_offShelf = 0
           ORDER BY a.pc_num
         `;
     return this.nativeQuery(sql);
@@ -197,11 +199,23 @@ export class ShuyouRentComputerService extends BaseService {
       queryObject.pc_num_old +
       '更换为租机编号' +
       queryObject.pc_num_new;
+    const res_remark = remark;
+    let new_rent_duration = Math.ceil(
+      parseInt(
+        (Date.parse(queryObject.rent_end) -
+          Date.parse(
+            this.utils.formatDate(this.utils.getNextDate(new Date(), 1)) +
+              ' 00:00:00'
+          )) /
+          (24 * 60 * 60 * 1000) +
+          ''
+      )
+    );
     let object_new = {
       pc_num: queryObject.pc_num_new,
       pc_name: queryObject.pc_num_new,
       shop_id: queryObject.shop_id,
-      rent_duration: queryObject.rent_duration,
+      rent_duration: new_rent_duration,
       rent_end: queryObject.rent_end,
       set_meal: queryObject.set_meal,
       price_type: queryObject.price_type,
@@ -221,11 +235,20 @@ export class ShuyouRentComputerService extends BaseService {
     } else {
       remark = info.remark + ';' + remark;
     }
+    let old_rent_duration = Math.ceil(
+      parseInt(
+        (Date.parse(this.utils.formatDate(new Date()) + ' 23:59:59') -
+          Date.parse(this.utils.formatDate(info.rent_start))) /
+          (24 * 60 * 60 * 1000) +
+          ''
+      )
+    );
     let object_old = {
       updateTime: new Date(),
       pc_num: queryObject.pc_num_old,
       rent_end: this.utils.formatDate(new Date()) + ' 23:59:59',
       remark: remark,
+      rent_duration: old_rent_duration,
     };
 
     let updateResult = await this.ShuyouRentComputerEntity.createQueryBuilder()
@@ -248,7 +271,7 @@ export class ShuyouRentComputerService extends BaseService {
           .execute();
       }
     }
-    return { code: 1000, data: remark };
+    return { code: 1000, data: res_remark };
   }
 
   /**
@@ -322,7 +345,7 @@ export class ShuyouRentComputerService extends BaseService {
             ),
             rent_duration: info2.rent_duration + parseInt(item.add_day),
           };
-          const a = await this.ShuyouRentComputerEntity.createQueryBuilder()
+          await this.ShuyouRentComputerEntity.createQueryBuilder()
             .update()
             .set(object_new)
             .where('id = :id', {
@@ -350,6 +373,102 @@ export class ShuyouRentComputerService extends BaseService {
       .execute();
     return { code: 1000, data: res };
   }
+  /**
+   * 续费
+   * @param queryObject
+   * @returns
+   */
+  async renew(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: '要续费的机器已到期' };
+    // }
+    // 2022-09-20,租机编号1续费7天,续费至2022-09-27
+    var remark =
+      this.utils.formatDate(new Date()) +
+      ',租机编号' +
+      queryObject.pc_num +
+      '续费' +
+      queryObject.day +
+      '天,续费至' +
+      this.utils.formatDate(queryObject.rent_renew);
+
+    let is_expire = 0;
+    if (Date.parse(queryObject.rent_renew) < new Date().getTime()) {
+      is_expire = 1;
+    } else if (
+      Date.parse(queryObject.rent_renew) - new Date().getTime() <=
+      24 * 60 * 60 * 1000
+    ) {
+      is_expire = 2;
+    }
+    if (info.remark != '' && info.remark != null) {
+      remark = info.remark + ';' + remark;
+    }
+    let object = {
+      updateTime: new Date(),
+      rent_end: queryObject.rent_renew,
+      rent_duration: info.rent_duration + queryObject.day,
+      is_expire: is_expire,
+      remark: remark,
+    };
+
+    let updateResult = await this.ShuyouRentComputerEntity.createQueryBuilder()
+      .update()
+      .set(object)
+      .where('id = :id', {
+        id: queryObject.pc_id,
+      })
+      .execute();
+    if (updateResult.affected >= 1) {
+      return { code: 1000, data: remark };
+    } else {
+      return { code: 1000, data: '该租机无变化' };
+    }
+  }
+  /**
+   * 下架
+   * @param queryObject
+   * @returns
+   */
+  async offShelf(queryObject) {
+    console.log(queryObject);
+
+    const info = await this.ShuyouRentComputerEntity.findOne({
+      id: queryObject.pc_id,
+    });
+    if (!info) {
+      return { code: -1, data: '要下架的机器编号不存在' };
+    }
+    var remark = '下架时间:' + this.utils.formatDate(new Date());
+
+    if (info.remark != '' && info.remark != null) {
+      remark = info.remark + ';' + remark;
+    }
+    let updateResult = await this.ShuyouRentComputerEntity.createQueryBuilder()
+      .update()
+      .set({
+        is_offShelf: 1,
+        remark: remark,
+        pc_num: 'offShelf_' + info.pc_num,
+      })
+      .where('id = :id', {
+        id: queryObject.pc_id,
+      })
+      .execute();
+    if (updateResult.affected >= 1) {
+      return { code: 1000, data: '租机编号' + info.pc_num + '已下架' };
+    } else {
+      return { code: 1000, data: '该租机无变化' };
+    }
+  }
 }
 
 // foreach加上async/await

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

@@ -1,17 +1,18 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-23 16:22:23
+ * @LastEditTime: 2022-09-29 15:24:36
  * @Description:
  * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
  */
-import { Provide } from '@midwayjs/decorator';
-import { BaseService, CoolCommException } from 'midwayjs-cool-core';
+import { Provide, Inject } from '@midwayjs/decorator';
+import { BaseService } from 'midwayjs-cool-core';
 import { InjectEntityModel } from '@midwayjs/orm';
 import { Repository } from 'typeorm';
 import * as _ from 'lodash';
 import { ShuyouRentLedgerComputerEntity } from '../entity/rent_ledger_computer';
 import { ShuyouRentComputerUsageEntity } from '../entity/rent_computer_game_record';
+import { Utils } from '../../../comm/utils';
 
 /**
  * 租机
@@ -22,116 +23,32 @@ export class ShuyouRentLedgerComputerService extends BaseService {
   ShuyouRentLedgerComputerEntity: Repository<ShuyouRentLedgerComputerEntity>;
   @InjectEntityModel(ShuyouRentComputerUsageEntity)
   ShuyouRentComputerUsageEntity: Repository<ShuyouRentComputerUsageEntity>;
-
-  // /**
-  //  * 重写新增接口
-  //  */
-  // async add(param) {
-  //   const existsTask = await this.ShuyouRentComputerEntity.findOne({
-  //     pc_num: param.pc_num,
-  //   });
-  //   if (!_.isEmpty(existsTask)) {
-  //     throw new CoolCommException('已存在相同编号的租机');
-  //   }
-  //   param.createTime = new Date();
-  //   param.updateTime = new Date();
-  //   param.rent_price_day = parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
-
-  //   console.log('rent_price_day');
-  //   console.log(param.rent_price_day);
-
-  //   await this.updateTaskGame(param);
-  //   return super.add(param);
-  // }
-
-  // /**
-  //  * 更新租机-任务关系
-  //  * @param pc_task
-  //  */
-  // async updateTaskGame(pc_task) {
-  //   await this.ShuyouRentComputerUsageEntity.delete({ pc_num: pc_task.pc_num });
-  //   if (pc_task.taskIdList) {
-  //     for (const task_id of pc_task.taskIdList) {
-  //       // console.log(task_id)
-  //       await this.ShuyouRentComputerUsageEntity.save({
-  //         pc_num: pc_task.pc_num,
-  //         task_id,
-  //       });
-  //     }
-  //   }
-  // }
-
-  // //表编码格式不一致导致报错解决办法
-  // //SHOW CREATE TABLE shuyou_rent_computer_usage;
-  // //ALTER TABLE shuyou_rent_computer_usage DEFAULT CHARACTER SET utf8mb4 COLLATE=utf8mb4_german2_ci;
-  // // ALTER TABLE shuyou_rent_computer_usage CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci;
-  // /**
-  //  * 根据ID获得信息
-  //  * @param id
-  //  */
-  // public async info(id) {
-  //   const info = await this.ShuyouRentComputerEntity.findOne({ id });
-  //   if (info) {
-  //     const taskIds = await this.nativeQuery(
-  //       `select
-  //         task_id
-  //       from
-  //         shuyou_rent_computer_usage
-  //       where pc_num = ?`,
-  //       [info.pc_num]
-  //     );
-  //     if (taskIds) {
-  //       info.taskIdList = taskIds.map(e => {
-  //         return e.task_id;
-  //       });
-  //     }
-  //   }
-  //   return info;
-  // }
-
-  // /**
-  //  * 修改
-  //  * @param param 数据
-  //  */
-  // async update(param) {
-  //   // console.log(param)
-  //   const taskInfo = await this.ShuyouRentComputerEntity.findOne({
-  //     id: param.id,
-  //   });
-  //   if (!taskInfo) {
-  //     throw new CoolCommException('租机不存在');
-  //   }
-  //   param.rent_price_day = parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
-
-  //   console.log('rent_price_day');
-  //   console.log(param.rent_price_day);
-
-  //   await this.ShuyouRentComputerEntity.save(param);
-  //   await this.updateTaskGame(param);
-  // }
-  // /**
-  //  * 重写分页查询
-  //  * @param query
-  //  */
-  // async page(query) {
-  //   const { pc_num } = query;
-  //   const sql = `
-  //         SELECT
-  //           a.*,
-  //           b.name as shop_name,c.name as rent_person_name,
-  //           GROUP_CONCAT(d.task_id) AS taskIdList,
-  //           GROUP_CONCAT(DISTINCT f.name) AS directorNameList
-  //         FROM
-  //           shuyou_rent_computer a
-  //           LEFT JOIN shuyou_rent_computer_shop b ON a.shop_id = b.id
-  //           LEFT JOIN shuyou_game_director c ON a.rent_person_id = c.id
-  //           LEFT JOIN shuyou_rent_computer_usage d ON a.pc_num = d.pc_num
-  //           LEFT JOIN shuyou_game_task e ON e.id = d.task_id
-  //           LEFT JOIN shuyou_game_director f ON f.id = e.directorId
-  //         WHERE 1 = 1
-  //           ${this.setSql(pc_num, 'and a.pc_num = ?', [pc_num])}
-  //         GROUP BY a.id
-  //       `;
-  //   return this.sqlRenderPage(sql, query);
-  // }
+  @Inject()
+  utils: Utils;
+  /**
+   * 重写分页查询
+   * @param query
+   */
+  async page(query) {
+    const { pc_num, new_date, shop_id } = query;
+    const sql = `
+          SELECT
+            a.id,DATE_FORMAT(a.new_date,'%Y-%m-%d') AS new_date,a.pc_num,a.pc_name,a.shop_id,a.set_meal,a.rent_start_then,a.rent_duration_then,
+            a.rent_end_then,a.price_type,a.rent_price_then,a.rent_price_day,a.pay_method,a.is_expire,a.rent_price_used_then,a.remark,
+            a.updateTime,
+            b.name as shop_name
+          FROM
+            shuyou_rent_ledger_computer a
+            LEFT JOIN shuyou_rent_computer_shop b ON a.shop_id = b.id
+          WHERE 1 = 1
+            ${this.setSql(pc_num, 'and a.pc_num = ?', [pc_num])}
+            ${this.setSql(shop_id, 'and a.shop_id = ?', [shop_id])}
+            ${this.setSql(new_date, 'and a.new_date >= ? and a.new_date <= ?', [
+              this.utils.formatDate(new Date(new_date[0])),
+              this.utils.formatDate(new Date(new_date[1])),
+            ])}
+          GROUP BY a.id
+        `;
+    return this.sqlRenderPage(sql, query);
+  }
 }

+ 69 - 4
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-23 10:32:43
+ * @LastEditTime: 2022-09-27 18:03:18
  * @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
  */
@@ -16,6 +16,8 @@ import { Repository } from 'typeorm';
 // import { ShuyouUtilsService } from '../../shuyou/service/utils';
 import { ShuyouRentComputerEntity } from '../../shuyou/entity/rent_computer';
 import { ShuyouRentComputerService } from '../../shuyou/service/rent_computer';
+import { ShuyouRentLedgerComputerEntity } from '../../shuyou/entity/rent_ledger_computer';
+// import { ShuyouRentLedgerComputerService } from '../../shuyou/service/rent_ledger_computer';
 
 /**
  * 租机定时任务
@@ -34,6 +36,12 @@ export class RentComputerTaskService extends BaseService {
   @Inject()
   ShuyouRentComputerService: ShuyouRentComputerService;
 
+  @InjectEntityModel(ShuyouRentLedgerComputerEntity)
+  ShuyouRentLedgerComputerEntity: Repository<ShuyouRentLedgerComputerEntity>;
+
+  // @Inject()
+  // ShuyouRentLedgerComputerService: ShuyouRentLedgerComputerService;
+
   /**
    * 检查是否有电脑到期,修改租机状态
    * @memberof RentComputerTaskService
@@ -72,12 +80,69 @@ export class RentComputerTaskService extends BaseService {
   }
 
   /***
-   * 定时生成日租机台账表(财务)
+   * 定时生成日租机台账表(财务)
    */
   async updateRentLedger() {
-    let updateTime = new Date();
+    let updateTime = this.utils.formatDateTime(new Date());
     this.logger.info('updateRentLedger>>>' + updateTime);
-
+    const sql = `
+          SELECT
+            a.pc_num,a.pc_name, a.shop_id,a.set_meal,a.rent_start,a.rent_duration,a.rent_end,a.price_type,a.rent_price,a.rent_price_day,
+            a.pay_method,a.is_expire,a.rent_price_used,a.remark,
+            b.name as shop_name
+          FROM
+            shuyou_rent_computer a
+            LEFT JOIN shuyou_rent_computer_shop b ON a.shop_id = b.id
+          WHERE
+            a.is_expire != 1
+            and a.is_offShelf = 0
+          ORDER BY a.pc_num
+  `;
+    // console.log(sql)
+    const computerList = await this.nativeQuery(sql);
+    await ykhForeach(computerList, async (item, index) => {
+      // this.logger.info(item.pc_num);
+      let ledger_object = {
+        new_date: this.utils.formatDate(new Date()),
+        pc_num: item.pc_num,
+        pc_name: item.pc_name,
+        shop_id: item.shop_id,
+        set_meal: item.set_meal,
+        rent_start_then: item.rent_start,
+        rent_duration_then: item.rent_duration,
+        rent_end_then: item.rent_end,
+        price_type: item.price_type,
+        rent_price_then: item.rent_price,
+        rent_price_day: item.rent_price_day,
+        pay_method: item.pay_method,
+        is_expire: item.is_expire,
+        rent_price_used_then: 0,
+        remark: item.remark,
+      };
+      const ShuyouRentLedgerComputerEntity =
+        await this.ShuyouRentLedgerComputerEntity.findOne({
+          pc_num: item.pc_num,
+          new_date: this.utils.formatDate(new Date()),
+          shop_id: item.shop_id,
+        });
+      if (!ShuyouRentLedgerComputerEntity) {
+        const yesterdayInfo = await this.ShuyouRentLedgerComputerEntity.findOne(
+          {
+            pc_num: item.pc_num,
+            new_date: this.utils.getNextDate(new Date(), -1),
+            shop_id: item.shop_id,
+          }
+        );
+        if (yesterdayInfo) {
+          ledger_object.rent_price_used_then =
+            parseFloat(yesterdayInfo.rent_price_used_then + '') +
+            parseFloat(item.rent_price_day);
+        } else {
+          ledger_object.rent_price_used_then = parseFloat(item.rent_price_day);
+        }
+        await this.ShuyouRentLedgerComputerEntity.insert(ledger_object);
+      }
+    });
     return 'updateRentLedger  SUCCESS>>>' + updateTime;
   }
 }

+ 20 - 15
cool-admin-midway-master/src/app/modules/task/service/shuyou.ts

@@ -18,6 +18,7 @@ import { ShuyouTargetFlagService } from './flag';
 import { ShuyouTargetFlagEntity } from '../entity/flag';
 import { ShuyouGameCompleteHandEntity } from '../../shuyou/entity/game_complete_hand';
 import { ShuyouData23Entity } from '../../shuyou/entity/data_23';
+// import { parse } from 'path';
 
 /**
  * 描述
@@ -570,9 +571,9 @@ export class TaskShuyouService extends BaseService {
       }
       //查询手动完成end=========================================
       if (
-        complete_new >= e.target_new &&
-        complete_pay >= e.target_pay &&
-        complete_active >= e.target_active
+        complete_new >= parseInt(e.target_new) &&
+        complete_pay >= parseInt(e.target_pay) &&
+        complete_active >= parseInt(e.target_active)
       ) {
         is_complete = 1;
       }
@@ -1060,9 +1061,9 @@ export class TaskShuyouService extends BaseService {
         e.target_active_low = e.target_active;
       }
       //=======================================================
-      let incomplete_new = e.target_new_low - complete_new;
-      let incomplete_pay = e.target_pay_low - complete_pay;
-      let incomplete_active = e.target_active_low - complete_active;
+      let incomplete_new = parseInt(e.target_new_low) - complete_new;
+      let incomplete_pay = parseInt(e.target_pay_low) - complete_pay;
+      let incomplete_active = parseInt(e.target_active_low) - complete_active;
       if (incomplete_new < 0) {
         incomplete_new = 0;
       }
@@ -1073,14 +1074,15 @@ export class TaskShuyouService extends BaseService {
         incomplete_active = 0;
       }
       if (
-        complete_new >= e.target_new_low &&
-        complete_pay >= e.target_pay_low &&
-        complete_active >= e.target_active_low
+        complete_new >= parseInt(e.target_new_low) &&
+        complete_pay >= parseInt(e.target_pay_low) &&
+        complete_active >= parseInt(e.target_active_low)
       ) {
         is_complete = 1;
       } else {
         is_complete = 0;
       }
+      //===========
       //此处添加新功能:
       //如果检查到完成结果全是0,那么就查询数据库之前记录是否为0,若不为0,则此次完成情况数据不覆盖
       //************************************************** */
@@ -1400,16 +1402,19 @@ export class TaskShuyouService extends BaseService {
       let target_pay = 0;
       let target_active = 0;
       target_new = Math.floor(
-        Math.random() * (e.target_new_high - e.target_new_low + 1) +
-          e.target_new_low
+        Math.random() *
+          (parseInt(e.target_new_high) - parseInt(e.target_new_low) + 1) +
+          parseInt(e.target_new_low)
       );
       target_pay = Math.floor(
-        Math.random() * (e.target_pay_high - e.target_pay_low + 1) +
-          e.target_pay_low
+        Math.random() *
+          (parseInt(e.target_pay_high) - parseInt(e.target_pay_low) + 1) +
+          parseInt(e.target_pay_low)
       );
       target_active = Math.floor(
-        Math.random() * (e.target_active_high - e.target_active_low + 1) +
-          e.target_active_low
+        Math.random() *
+          (parseInt(e.target_active_high) - parseInt(e.target_active_low) + 1) +
+          parseInt(e.target_active_low)
       );
       let targetObj = {
         task_id: e.id,

+ 3 - 3
cool-admin-midway-master/src/welcome.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:26
- * @LastEditTime: 2022-08-02 15:08:55
- * @Description: 
+ * @LastEditTime: 2022-09-29 13:50:50
+ * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\src\welcome.ts
  */
 import { Get, Inject, Provide } from '@midwayjs/decorator';
@@ -20,6 +20,6 @@ export class WelcomeController extends BaseController {
 
   @Get('/')
   public async welcome() {
-    await this.ctx.render('welcome', { text: 'HELLO COOL-ADMIN 3.5.1' });
+    await this.ctx.render('welcome', { text: 'HELLO COOL-ADMIN 3.5.2' });
   }
 }

+ 68 - 0
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/adv-search-computer.vue

@@ -0,0 +1,68 @@
+<!--
+ * @Author: 倚楼听风雨 18408246387@163.com
+ * @Date: 2022-09-27 18:25:51
+ * @LastEditors: 倚楼听风雨 18408246387@163.com
+ * @LastEditTime: 2022-09-28 09:29:07
+ * @FilePath: \cool-admin-3.x\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\components\adv-search-computer.vue
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+-->
+<template>
+	<div class="demo-adv-computer-search">
+		<cl-adv-btn>筛选</cl-adv-btn>
+		<cl-adv-search :items="items" :op-list="opList" />
+	</div>
+</template>
+
+<script lang="ts">
+import { AdvSearchItem } from "cl-admin-crud-vue3/types";
+import { defineComponent, ref } from "vue";
+
+export default defineComponent({
+	setup() {
+		const items = ref<AdvSearchItem[]>([
+			{
+				prop: "shop_id",
+				label: "供应商",
+				span: 12,
+				component: {
+					name: "shuyouRentComputerShopSelect",
+					props: {
+						placeholder: "请选择供应商"
+					}
+				}
+			},
+			{
+				label: "是否到期",
+				prop: "is_expire",
+				value: 0,
+				component: {
+					name: "el-radio-group",
+					options: [
+						{
+							label: "到期未续",
+							value: 1
+						},
+						{
+							label: "在租期中",
+							value: 0
+						},
+						{
+							label: "即将到期",
+							value: 2
+						}
+					]
+				}
+			}
+		]);
+
+		const opList = ref<string[]>(["search", "reset", "clear", "close"]);
+
+		return {
+			items,
+			opList
+		};
+	}
+});
+</script>
+
+<style lang="scss" scoped></style>

+ 14 - 26
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/adv-search-ledgerComputer.vue

@@ -34,37 +34,26 @@ export default defineComponent({
 			},
 			{
 				prop: "shop_id",
-				label: "供应商",
-				span: 12,
+				label: "供应商",
+				span: 18,
 				component: {
 					name: "shuyouRentComputerShopSelect",
 					props: {
 						placeholder: "请选择供应商"
 					}
 				}
+			},
+			{
+				label: "租机编号",
+				prop: "pc_num",
+				span: 18,
+				component: {
+					name: "el-input",
+					attrs: {
+						placeholder: "不填查询所有"
+					}
+				}
 			}
-			// {
-			// 	label: "运行状态",
-			// 	prop: "is_run",
-			// 	value: -1,
-			// 	component: {
-			// 		name: "el-radio-group",
-			// 		options: [
-			// 			{
-			// 				label: "运行",
-			// 				value: 1
-			// 			},
-			// 			{
-			// 				label: "停止",
-			// 				value: 0
-			// 			},
-			// 			{
-			// 				label: "所有",
-			// 				value: -1
-			// 			}
-			// 		]
-			// 	}
-			// }
 		]);
 
 		const opList = ref<string[]>(["search", "reset", "clear", "close"]);
@@ -77,5 +66,4 @@ export default defineComponent({
 });
 </script>
 
-<style lang="scss" scoped>
-</style>
+<style lang="scss" scoped></style>

+ 16 - 16
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/index.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:29:23
- * @LastEditTime: 2022-09-20 14:21:16
- * @Description: 
+ * @LastEditTime: 2022-09-28 14:04:22
+ * @Description:
  * @FilePath: \cool-admin\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\components\index.ts
  */
 import shuyouGameAgentselect from "./shuyouGameAgent-select.vue";
@@ -17,20 +17,20 @@ import shuyouGameDirectorNameselect from "./shuyouGameDirectorName-select.vue";
 import shuyouGameListSelect from "./shuyouGameList-select.vue";
 import specialAccountTypeselect from "./specialAccountType-select.vue";
 import shuyouRentComputerShopSelect from "./shuyouRentComputerShop-select.vue";
-import shuyouledgerComputerSelect from "./adv-search-ledgerComputer.vue";
+// import shuyouledgerComputerSelect from "./adv-search-ledgerComputer.vue";
 
 export default {
-    shuyouGameAgentselect,
-    shuyouAccountTypeselect,
-    shuyouGameDirectorselect,
-    shuyouLoModeselect,
-    shuyouProblemTypeselect,
-    shuyouGameTaskselect,
-    shuyouGameComputerselect,
-    shuyouGameDirectorNameselect,
-    shuyouGameListSelect,
-    specialAccountTypeselect,
-    shuyouRentComputerShopSelect,
-    shuyouGameTaskNameselect,
-    shuyouledgerComputerSelect
+	shuyouGameAgentselect,
+	shuyouAccountTypeselect,
+	shuyouGameDirectorselect,
+	shuyouLoModeselect,
+	shuyouProblemTypeselect,
+	shuyouGameTaskselect,
+	shuyouGameComputerselect,
+	shuyouGameDirectorNameselect,
+	shuyouGameListSelect,
+	specialAccountTypeselect,
+	shuyouRentComputerShopSelect,
+	shuyouGameTaskNameselect
+	// shuyouledgerComputerSelect
 };

+ 24 - 0
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/service/rent_computer.ts

@@ -33,6 +33,30 @@ class ShuyouRentComputer extends BaseService {
 			data
 		});
 	}
+	@Permission("renew")
+	renew(data: any) {
+		return this.request({
+			url: "/renew",
+			method: "POST",
+			data
+		});
+	}
+	@Permission("offShelf")
+	offShelf(data: any) {
+		return this.request({
+			url: "/offShelf",
+			method: "POST",
+			data
+		});
+	}
+	@Permission("batchImport")
+	batchImport(data: any) {
+		return this.request({
+			url: "/batchImport",
+			method: "POST",
+			data
+		});
+	}
 }
 
 export default ShuyouRentComputer;

+ 4 - 4
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/idcard.vue

@@ -58,8 +58,8 @@
 			<div class="el-div">
 				<h3 class="v-line-icon">上传身份信息</h3>
 				<el-scrollbar>
+					<!-- :model="" -->
 					<el-form
-						:model="ruleForm"
 						ref="ruleForm"
 						label-width="100px"
 						size="mini"
@@ -143,11 +143,11 @@
 
 <script lang="ts">
 import { CrudLoad, Table, Upsert } from "cl-admin-crud-vue3/types";
-import { computed, defineComponent, inject, reactive, ref, toRefs } from "vue";
+import { defineComponent, inject, reactive, ref, toRefs } from "vue";
 import { useRouter } from "vue-router";
 import { useRefs } from "/@/core";
-import { ElMessage, ElLoading, ElMessageBox } from "element-plus";
-import { ElFile } from "element-plus/lib/el-upload/src/upload.type";
+import { ElLoading, ElMessageBox } from "element-plus";
+// import { ElFile } from "element-plus/lib/el-upload/src/upload.type";
 
 export default defineComponent({
 	name: "sys-idcard",

+ 263 - 21
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_computer.vue

@@ -3,6 +3,9 @@
 		<el-row type="flex">
 			<cl-refresh-btn />
 			<cl-add-btn />
+			<!-- <el-button type="primary" size="mini" @click="visible_import = true"
+				>批量导入</el-button
+			> -->
 			<cl-multi-delete-btn />
 			<demo-query-is_expire />
 			<cl-flex1 />
@@ -20,6 +23,7 @@
 					}
 				]"
 			></cl-search-key>
+			<demo-adv-computer-search />
 		</el-row>
 
 		<el-row>
@@ -37,7 +41,9 @@
 				</template>
 
 				<template #slot-renew="{ scope }">
-					<el-button type="text" size="mini" @click="renew(scope.row)">续费</el-button>
+					<el-button type="text" size="mini" @click="switchRenew(scope.row)"
+						>续费</el-button
+					>
 				</template>
 				<template #slot-renting-out="{ scope }">
 					<el-button
@@ -58,9 +64,7 @@
 					>
 				</template>
 				<template #slot-delete="{ scope }">
-					<el-button type="text" size="mini" @click="deleteNum(scope.row)"
-						>下架</el-button
-					>
+					<el-button type="text" size="mini" @click="offShelf(scope.row)">下架</el-button>
 				</template>
 			</cl-table>
 		</el-row>
@@ -212,6 +216,108 @@
 				</el-form-item>
 			</el-form>
 		</cl-dialog>
+		<cl-dialog title="租机续费" v-model="visible_renew">
+			<el-form ref="elForm" :model="renewForm" 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="renewForm.pc_num"
+								placeholder="租机编号"
+								disabled="true"
+							></el-input>
+						</el-col>
+					</el-form-item>
+					<el-form-item label="续费时间" prop="rent_renew">
+						<el-col>
+							<el-date-picker
+								v-model="renewForm.rent_renew"
+								format="YYYY-MM-DD HH:mm:ss"
+								type="datetime"
+								:style="{ width: '100%' }"
+								placeholder="请选择日期"
+								clearable
+								@change="calculateRenewDay(renewForm)"
+							></el-date-picker>
+						</el-col>
+					</el-form-item>
+				</el-row>
+				<el-row>
+					<el-form-item label="续费天数" prop="">
+						<el-col :span="24">
+							<el-tag :key="renewForm.day" type="warning" effect="light">
+								{{ renewForm.day }}
+							</el-tag>
+						</el-col>
+					</el-form-item>
+				</el-row>
+				<el-divider />
+				<el-form-item>
+					<el-button size="small" @click="visible_renew = false">取消</el-button>
+					<el-button type="primary" size="small" @click="renew(renewForm)"
+						>提交</el-button
+					>
+				</el-form-item>
+			</el-form>
+		</cl-dialog>
+		<cl-dialog
+			title="批量导入租机信息"
+			v-model="visible_import"
+			:props="{
+				modal: true,
+				customClass: 'cl-chat__dialog',
+				'append-to-body': true,
+				'close-on-click-modal': false,
+				'close-on-press-escape': false
+			}"
+		>
+			<div class="el-div">
+				<h3 class="v-line-icon">批量导入租机信息</h3>
+				<el-form
+					ref="elForm"
+					:model="importForm"
+					size="mini"
+					label-width="100px"
+					:disabled="saving"
+				>
+					<el-form-item label="选择文件" prop="">
+						<el-col :span="12">
+							<cl-upload
+								v-model="importForm.urls"
+								accept=".xls,.xlsx"
+								list-type="text"
+								:limi="1"
+								limit-size="10"
+							>
+								<el-button size="small" type="primary">点击上传</el-button>
+								<div slot="tip" class="el-upload__tip" style="color: #ff4200">
+									Tips: 只能上传.xls,.xlsx文件,且不超过10M
+								</div>
+								<!-- <el-alert :title="reqFlag.error" v-if="reqFlag.errorTips" type="error" show-icon :closable="false"> </el-alert> -->
+							</cl-upload>
+						</el-col>
+					</el-form-item>
+					<el-form-item>
+						<el-button
+							size="mini"
+							type="primary"
+							:disabled="saving"
+							@click="batchImport"
+						>
+							确定导入
+							<i class="el-icon-upload el-icon--right"></i>
+						</el-button>
+					</el-form-item>
+				</el-form>
+			</div>
+		</cl-dialog>
 	</cl-crud>
 </template>
 
@@ -221,16 +327,17 @@ 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 { ElMessage, ElMessageBox, ElLoading } from "element-plus";
 import { useRefs } from "/@/core";
-import { floor } from "lodash";
+import AdvSearch from "../components/adv-search-computer.vue";
 
 export default defineComponent({
 	name: "rent-computer",
 
 	components: {
 		"demo-query-is_expire": QueryIsExpire,
-		"demo-select-rentComputerList": shuyouRentComputerListSelect
+		"demo-select-rentComputerList": shuyouRentComputerListSelect,
+		"demo-adv-computer-search": AdvSearch
 	},
 
 	setup() {
@@ -240,6 +347,10 @@ export default defineComponent({
 		const form = reactive<any>({
 			relevance: 1
 		});
+		const importForm = reactive<any>({
+			urls: ""
+		});
+		const saving = ref<boolean>(false);
 		// 表单值
 		const replaceNumForm = reactive<any>({
 			pc_num_old: "",
@@ -261,8 +372,16 @@ export default defineComponent({
 			rent_end: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
 			addList: []
 		});
+		const renewForm = reactive<any>({
+			pc_num: "",
+			pc_id: 0,
+			day: 0,
+			rent_renew: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
+		});
 		const visible_replaceNum = ref<boolean>(false);
 		const visible_rentingOut = ref<boolean>(false);
+		const visible_renew = ref<boolean>(false);
+		const visible_import = ref<boolean>(false);
 		let cardList = ref<any[]>([]);
 		const rent_end = ref<string>("");
 
@@ -373,6 +492,7 @@ export default defineComponent({
 					prop: "rent_end",
 					label: "到期时间",
 					span: 8,
+					value: new Date(),
 					component: {
 						name: "el-date-picker",
 						props: {
@@ -604,14 +724,14 @@ export default defineComponent({
 					align: "left",
 					minWidth: 120
 				},
-				{
-					prop: "rent_price_used",
-					label: "已产生租金",
-					sortable: "true",
-					headerAlign: "left",
-					align: "left",
-					minWidth: 120
-				},
+				// {
+				// 	prop: "rent_price_used",
+				// 	label: "已产生租金",
+				// 	sortable: "true",
+				// 	headerAlign: "left",
+				// 	align: "left",
+				// 	minWidth: 120
+				// },
 				{
 					prop: "directorNameList",
 					label: "使用人",
@@ -693,7 +813,7 @@ export default defineComponent({
 		}) {
 			scope.rent_end = new Date(
 				Date.parse(scope.rent_start) +
-					1 * 24 * 60 * 60 * 1000 * (parseInt(scope.rent_duration) - 1)
+					1 * 24 * 60 * 60 * 1000 * parseInt(scope.rent_duration)
 			);
 		}
 		// 计算退租剩余时间
@@ -711,8 +831,56 @@ export default defineComponent({
 			);
 			// console.log(scope.day);
 		}
+		// 计算续费时间
+		function calculateRenewDay(scope: { rent_renew: string; day: number }) {
+			if (Date.parse(rent_end.value) >= Date.parse(scope.rent_renew)) {
+				scope.rent_renew = rent_end.value;
+				ElMessage.error("续费时间不能小于到期时间");
+			}
+			scope.day = Math.ceil(
+				parseInt(
+					(Date.parse(scope.rent_renew) - Date.parse(rent_end.value)) /
+						(24 * 60 * 60 * 1000) +
+						""
+				)
+			);
+		}
+		// 拉起续费弹窗
+		async function switchRenew(rowData: any) {
+			renewForm.pc_num = rowData.pc_num;
+			renewForm.pc_id = rowData.id;
+			renewForm.rent_renew = rowData.rent_end;
+			renewForm.day = 0;
+			rent_end.value = rowData.rent_end;
+			if (visible_renew.value == false) {
+				visible_renew.value = true;
+			}
+		}
 		// 续费
-		async function renew(rowData) {}
+		async function renew(rowData: { pc_num: any; pc_id: any; rent_renew: any; day: any }) {
+			let doForm = {
+				pc_num: rowData.pc_num,
+				pc_id: rowData.pc_id,
+				rent_renew: rowData.rent_renew,
+				day: rowData.day
+			};
+			service.shuyouRentComputer
+				.renew(doForm)
+				.then((data: any) => {
+					// console.log(data);
+					if (data.code == 1) {
+						visible_renew.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 switchRentingOut(rowData: any) {
 			cardList.value = [];
@@ -756,7 +924,7 @@ export default defineComponent({
 			service.shuyouRentComputer
 				.rentingOut(doForm)
 				.then((data: any) => {
-					console.log(data);
+					// console.log(data);
 					if (data.code == 1) {
 						visible_rentingOut.value = false;
 						ElMessage.success(data.message);
@@ -820,7 +988,73 @@ export default defineComponent({
 				});
 		}
 		// 删除/下架
-		async function deleteNum(rowData) {}
+		async function offShelf(rowData: { is_expire: number; pc_num: string; id: any }) {
+			if (rowData.is_expire != 1) {
+				ElMessage.warning("机器未到期,禁止下架!!!");
+				return;
+			}
+			let doForm = {
+				pc_id: rowData.id
+			};
+			console.log(doForm);
+			ElMessageBox.confirm("确定要下架编号为" + rowData.pc_num + "的租机吗?", "租机下架", {
+				dangerouslyUseHTMLString: true,
+				type: "warning"
+			})
+				.then(() => {
+					service.shuyouRentComputer
+						.offShelf(doForm)
+						.then((data: any) => {
+							// console.log(data);
+							if (data.code == 1) {
+								ElMessage.success(data.message);
+							} else {
+								ElMessage.error(data.message);
+							}
+							refs.value.crud.refresh();
+						})
+						.catch((err: string) => {
+							ElMessage.error(err);
+						});
+				})
+				.catch(() => null);
+		}
+		// 批量导入
+		async function batchImport() {
+			saving.value = true;
+			const loading = ElLoading.service({
+				lock: true,
+				text: "上传中,请勿关闭此页面...",
+				spinner: "el-icon-loading",
+				background: "rgba(0, 0, 0, 0.7)"
+			});
+			console.log(importForm.urls);
+			const params = {
+				fileaddress: importForm.urls
+			};
+			await service.shuyouRentComputer
+				.batchImport(params)
+				.then((data) => {
+					console.log(data);
+					visible_import.value = false;
+					loading.close();
+					// if (data.code == -1) {
+					// 	ElMessage.success(data.message);
+					// } else {
+					// 	ElMessage.success(data.message);
+					// }
+					// ElMessageBox.alert(data.message, "提示", {
+					// 	confirmButtonText: "关闭"
+					// });
+				})
+				.catch((err: string) => {
+					loading.close();
+					ElMessageBox.alert(err, "提示", {
+						confirmButtonText: "关闭"
+					});
+				});
+			saving.value = false;
+		}
 		// 监听
 		// watch(
 		// 	() => form,
@@ -847,7 +1081,7 @@ export default defineComponent({
 			renew,
 			rentingOut,
 			replaceNum,
-			deleteNum,
+			offShelf,
 			switchReplaceNum,
 			switchRentingOut,
 			visible_replaceNum,
@@ -856,7 +1090,15 @@ export default defineComponent({
 			rentingOutForm,
 			addCardMsg,
 			deleteCardMsg,
-			cardList
+			cardList,
+			visible_renew,
+			renewForm,
+			switchRenew,
+			calculateRenewDay,
+			visible_import,
+			importForm,
+			saving,
+			batchImport
 		};
 	}
 });

+ 127 - 164
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/views/rent_ledger_computer.vue

@@ -2,9 +2,10 @@
 	<cl-crud @load="onLoad">
 		<el-row type="flex">
 			<cl-refresh-btn />
-			<cl-add-btn />
+			<!-- <cl-add-btn /> -->
 			<cl-multi-delete-btn />
 			<cl-flex1 />
+			<cl-export-btn :columns="table.columns"></cl-export-btn>
 			<cl-search-key
 				field="pc_num"
 				:field-list="[
@@ -18,15 +19,21 @@
 		</el-row>
 
 		<el-row>
-			<cl-table v-bind="table" >
-				<!-- <template #column-pc_position="{ scope }">
-					<span v-if="scope.row.is_rent == 0">{{
-						scope.row.pc_position
-					}}</span>
-					<span v-if="scope.row.is_rent == 1">
-						{{scope.row.pc_position}}({{scope.row.shop_name}})
-					</span>
-				</template> -->
+			<cl-table v-bind="table">
+				<template #column-rent_price_then="{ scope }">
+					<span v-if="scope.row.price_type == 0"
+						>{{ scope.row.rent_price_then }}元&nbsp;/&nbsp;天</span
+					>
+					<span v-if="scope.row.price_type == 1"
+						>{{ scope.row.rent_price_then }}元&nbsp;/&nbsp;周</span
+					>
+					<span v-if="scope.row.price_type == 2"
+						>{{ scope.row.rent_price_then }}元&nbsp;/&nbsp;月</span
+					>
+				</template>
+				<template #column-remark="{ scope }">
+					<span v-copy="scope.row.remark">{{ scope.row.remark }}</span>
+				</template>
 			</cl-table>
 		</el-row>
 
@@ -35,25 +42,13 @@
 			<cl-pagination />
 		</el-row>
 
-		<cl-upsert v-model="form" v-bind="upsert">
-			<template #slot-rent_start="{ scope }">
-				<el-date-picker
-					v-model="scope.rent_start"
-					type="date"
-					:@change="calculateRentDuration(scope)"
-					placeholder="选择租机日期">
-				</el-date-picker>
-			</template>
-			<template #slot-rent_duration="{ scope }">
-				<el-input v-model="scope.rent_duration" placeholder="租机时长(天)" @change="calculateRentDuration(scope)"></el-input>
-			</template>
-		</cl-upsert>
+		<cl-upsert v-model="form" v-bind="upsert"> </cl-upsert>
 	</cl-crud>
 </template>
 
 <script lang="ts">
 import { CrudLoad, Table, Upsert } from "cl-admin-crud-vue3/types";
-import { defineComponent, inject, reactive,watch } from "vue";
+import { defineComponent, inject, reactive, watch } from "vue";
 import QueryIsAbnormal from "../components/query-is_abnormal.vue";
 import AdvSearch from "../components/adv-search-ledgerComputer.vue";
 
@@ -62,7 +57,7 @@ export default defineComponent({
 
 	components: {
 		"demo-query-isabnormal": QueryIsAbnormal,
-		"demo-adv-ledgerComputer-search":AdvSearch
+		"demo-adv-ledgerComputer-search": AdvSearch
 	},
 
 	setup() {
@@ -109,17 +104,6 @@ export default defineComponent({
 					}
 				},
 				{
-					prop: "rent_person_id",
-					label: "租赁人",
-					span: 8,
-					component: {
-						name: "shuyouGameDirectorselect",
-						props: {
-							placeholder: "租赁人"
-						}
-					}
-				},
-				{
 					prop: "shop_id",
 					label: "供应商",
 					span: 8,
@@ -134,98 +118,65 @@ export default defineComponent({
 						message: "供应商不能为空"
 					}
 				},
+
 				// {
-				// 	prop: "taskIdList",
-				// 	label: "游戏任务",
-				// 	span: 24,
+				// 	prop: "rent_start_then",
+				// 	label: "起租时间",
+				// 	span: 12,
+				// 	value: Date(),
+				// 	component: {
+				// 		name: "el-date-picker",
+				// 		props: {
+				// 			type: "date",
+				// 			readonly: true,
+				// 			placeholder: "起租时间"
+				// 		}
+				// 	},
+				// 	rules: {
+				// 		required: true,
+				// 		message: "起租时间不能为空"
+				// 	}
+				// },
+				// {
+				// 	prop: "rent_duration_then",
+				// 	label: "租机时长",
+				// 	value: 1,
+				// 	span: 12,
 				// 	component: {
 				// 		name: "el-input",
 				// 		props: {
-				// 			placeholder: "游戏任务"
+				// 			placeholder: "租机时长"
 				// 		}
 				// 	},
 				// 	rules: {
 				// 		required: true,
-				// 		message: "游戏任务不能为空"
+				// 		message: "租机时长不能为空"
+				// 	}
+				// },
+				// {
+				// 	prop: "rent_end_then",
+				// 	label: "到期时间",
+				// 	span: 12,
+				// 	component: {
+				// 		name: "el-date-picker",
+				// 		props: {
+				// 			type: "date",
+				// 			readonly: true,
+				// 			placeholder: "选择到期时间"
+				// 		}
 				// 	}
 				// },
 				{
-					prop: "taskIdList",
-					label: "游戏任务",
-					span: 24,
-					value: [],
-					component: {
-						name: "shuyouGameTaskNameselect",
-						props: {
-							props: {
-								// "multiple-limit": 3
-							}
-						}
-					},
-					rules: {
-						required: true,
-						message: "游戏任务不能为空"
-					}
-				},
-				{
-					prop: "rent_start",
-					label: "起租时间",
-					span: 12,
-					value: Date(),
-					component: {
-						name: "slot-rent_start"
-						// name: "el-date-picker",
-						// props: {
-						// 	type: "date",
-						// 	placeholder: "选择租机日期"
-						// }
-					},
-					rules: {
-						required: true,
-						message: "起租时间不能为空"
-					}
-				},
-				{
-					prop: "rent_duration",
-					label: "租机时长",
-					value: 1,
-					span: 12,
-					component: {
-						name: "slot-rent_duration"
-					},
-					rules: {
-						required: true,
-						message: "租机时长不能为空"
-					}
-				},
-				{
-					prop: "rent_end",
-					label: "到期时间",
-					span: 12,
-					component: {
-						name: "el-date-picker",
-						props: {
-							type: "date",
-							readonly: true,
-							placeholder: "选择到期时间"
-						}
-					}
-				},
-				{
-					label: "租机价格",
-					prop: "rent_price",
-					value: 0.00,
+					label: "已产生租金",
+					prop: "rent_price_used_then",
+					value: 0.0,
 					span: 12,
 					component: {
-						name: "el-input-number",
-						props: {
-							precision: "2",
-							step: "1"
-						}
+						name: "el-input"
 					},
 					rules: {
 						required: true,
-						message: "租机价格不能为空"
+						message: "已产生租金不能为空"
 					}
 				},
 				{
@@ -264,7 +215,7 @@ export default defineComponent({
 							}
 						]
 					}
-				},
+				}
 			]
 		});
 
@@ -272,7 +223,7 @@ export default defineComponent({
 		const table = reactive<Table>({
 			props: {
 				"default-sort": {
-					prop: "pc_num",
+					prop: "new_date,id",
 					order: "descending"
 				}
 			},
@@ -284,12 +235,20 @@ export default defineComponent({
 					width: 40
 				},
 				{
+					prop: "new_date",
+					label: "日期",
+					sortable: "true",
+					headerAlign: "left",
+					align: "left",
+					minWidth: 100
+				},
+				{
 					prop: "shop_name",
 					label: "供应商",
 					sortable: "true",
 					headerAlign: "left",
 					align: "left",
-					minWidth: 180,
+					minWidth: 180
 				},
 				{
 					prop: "pc_num",
@@ -297,18 +256,25 @@ export default defineComponent({
 					sortable: "true",
 					headerAlign: "left",
 					align: "left",
-					minWidth: 100,
+					minWidth: 100
 				},
 				{
 					prop: "pc_name",
-					label: "电脑名称",
-					sortable: "true",
+					label: "机房名称",
 					headerAlign: "left",
 					align: "left",
 					minWidth: 120
 				},
 				{
-					prop: "rent_start",
+					prop: "set_meal",
+					label: "套餐",
+					sortable: "true",
+					headerAlign: "left",
+					align: "left",
+					minWidth: 150
+				},
+				{
+					prop: "rent_start_then",
 					label: "起租时间",
 					sortable: "true",
 					headerAlign: "left",
@@ -316,7 +282,7 @@ export default defineComponent({
 					minWidth: 150
 				},
 				{
-					prop: "rent_end",
+					prop: "rent_end_then",
 					label: "到期时间",
 					sortable: "true",
 					headerAlign: "left",
@@ -324,7 +290,7 @@ export default defineComponent({
 					minWidth: 150
 				},
 				{
-					prop: "rent_duration",
+					prop: "rent_duration_then",
 					label: "租机时常",
 					sortable: "true",
 					headerAlign: "left",
@@ -332,9 +298,30 @@ export default defineComponent({
 					minWidth: 120
 				},
 				{
-					prop: "rent_price",
-					label: "租机价格",
-					sortable: "true",
+					prop: "is_expire",
+					label: "是否到期",
+					minWidth: 80,
+					dict: [
+						{
+							label: "在租期中",
+							value: 0,
+							type: "success"
+						},
+						{
+							label: "到期未续",
+							value: 1,
+							type: "info"
+						},
+						{
+							label: "即将到期",
+							value: 2,
+							type: "danger"
+						}
+					]
+				},
+				{
+					prop: "rent_price_then",
+					label: "价格标准",
 					headerAlign: "left",
 					align: "left",
 					minWidth: 120
@@ -342,28 +329,18 @@ export default defineComponent({
 				{
 					prop: "rent_price_day",
 					label: "折算天租金",
-					sortable: "true",
 					headerAlign: "left",
 					align: "left",
 					minWidth: 120
 				},
 				{
-					prop: "rent_price_used",
+					prop: "rent_price_used_then",
 					label: "已产生租金",
-					sortable: "true",
 					headerAlign: "left",
 					align: "left",
 					minWidth: 120
 				},
 				{
-					prop: "directorNameList",
-					label: "使用人",
-					headerAlign: "left",
-					align: "left",
-					sortable: "custom",
-					minWidth: 100
-				},
-				{
 					prop: "pay_method",
 					label: "结算方式",
 					minWidth: 80,
@@ -386,19 +363,12 @@ export default defineComponent({
 					]
 				},
 				{
-					prop: "rent_person_name",
-					label: "租赁人",
-					headerAlign: "left",
-					align: "left",
-					sortable: "custom",
-					minWidth: 100
-				},
-				{
 					prop: "remark",
 					label: "备注",
 					headerAlign: "left",
 					align: "left",
-					minWidth: 100
+					minWidth: 300,
+					showOverflowTooltip: true
 				},
 				{
 					prop: "updateTime",
@@ -421,31 +391,24 @@ export default defineComponent({
 			ctx.service(service.shuyouRentLedgerComputer).done();
 			app.refresh();
 		}
-		// 计算租机到期时间
-		function calculateRentDuration(scope: { rent_end: Date; rent_start: string; rent_duration: string; }) {
-			scope.rent_end = new Date(Date.parse(scope.rent_start) + 1 * 24 * 60 * 60 * 1000 * (parseInt(scope.rent_duration) - 1 ))
-		}
-		// 监听
-		watch(
-			() => form,
-			(newVal, oldValue) => {
-				// console.log(newVal, oldValue);
-				if(form.is_rent == 1){
-					form.pc_position = "租机"
-				}
-			},
-			{
-				deep: true,
-				immediate: true
-			}
-		);
+
 		return {
 			form,
 			upsert,
 			table,
-			onLoad,
-			calculateRentDuration
+			onLoad
 		};
 	}
 });
 </script>
+<style lang="scss" scoped>
+.el-tooltip__popper {
+	max-width: 20%;
+}
+.el-tooltip__popper,
+.el-tooltip__popper.is-dark {
+	background: rgb(48, 65, 86) !important;
+	color: #fff !important;
+	line-height: 24px;
+}
+</style>

+ 4 - 7
cool-admin-vue-vue3-ts-vite/src/views/home/components/person-tab.vue

@@ -7,7 +7,7 @@
 					<span class="name">{{ userInfo.nickName }}</span>
 				</span>
 				<span class="value" style="margin: 20px 0px; padding: 20px 0px; font-size: 28px">{{
-						timeState
+					timeState
 				}}</span>
 			</div>
 			<!-- <p class="label">今日晴,0℃ - 10℃,天气寒冷,注意添加衣物。</p> -->
@@ -70,14 +70,11 @@ export default defineComponent({
 		const timeState = ref<string>("");
 		onMounted(async () => {
 			ElNotification.success({
-				title: "更新公告V3.3.5",
+				title: "更新公告V3.5.2",
 				dangerouslyUseHTMLString: true,
 				message: `<strong>
-					<p>#修复了魅族游戏未完成显示BUG</p>
-					<p>#添加手动魅族加币</p>
-					<p>#增加了QQ卡提醒</p>
-					<p>#增加了云点提醒</p>
-					<p>#异常率查询速度提升</p>
+					<p>#修复了已知BUG</p>
+					<p>#增加租机台账</p>
 					</strong>`,
 				position: "bottom-left",
 				showClose: false,