倚楼听风雨 3 yıl önce
ebeveyn
işleme
2dc3e82d70

+ 8 - 3
README.md

@@ -1,8 +1,8 @@
 <!--
  * @Author: 倚楼听风雨 18408246387@163.com
  * @Date: 2022-09-16 17:54:29
- * @LastEditors: 倚楼听风雨 18408246387@163.com
- * @LastEditTime: 2022-09-16 18:20:42
+ * @LastEditors: Please set LastEditors
+ * @LastEditTime: 2022-09-16 23:19:27
  * @FilePath: \cool-admin-3.x\README.md
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 -->
@@ -29,4 +29,9 @@ yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass
 
 ```shell
 yarn dev
-```
+```
+
+//表编码格式不一致导致报错解决办法
+//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;

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

@@ -1,9 +1,9 @@
 /*
  * @Author: YKH
  * @Date: 2022-09-01 20:41:58
- * @LastEditTime: 2022-09-02 22:57:45
+ * @LastEditTime: 2022-09-16 22:09:01
  * @Description: file content
- * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_computer.ts
+ * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\entity\rent_computer.ts
  */
 import { EntityModel } from '@midwayjs/orm';
 import { Column,Index } from 'typeorm';
@@ -49,7 +49,7 @@ export class ShuyouRentComputerEntity extends BaseEntity {
   rent_price_used: number;
 
   @Column({ comment: '租赁人', nullable: true })
-  rent_person: string;
+  rent_person_id: number;
   
   // 任务ID列表,映射使用人列表
   taskIdList: string[];

+ 75 - 22
cool-admin-midway-master/src/app/modules/shuyou/service/rent_computer.ts

@@ -1,9 +1,9 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-09-15 23:14:10
+ * @LastEditTime: 2022-09-16 23:31:48
  * @Description:
- * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
+ * @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';
@@ -28,7 +28,7 @@ export class ShuyouRentComputerService extends BaseService {
    */
   async add(param) {
     const existsTask = await this.ShuyouRentComputerEntity.findOne({
-      pc_num: param.pc_num,
+      pc_num: param.pc_num
     });
     if (!_.isEmpty(existsTask)) {
       throw new CoolCommException('已存在相同编号的租机');
@@ -54,23 +54,76 @@ export class ShuyouRentComputerService extends BaseService {
       }
     }
   }
-  // /**
-  // * 重写分页查询
-  // * @param query
-  // */
-  // async page(query) {
-  //   const { pc_name, is_rent, shop_name, is_abnormal } = query;
-  //   const sql = `
-  //         SELECT
-  //           *
-  //         FROM
-  //           shuyou_game_computer
-  //         WHERE 1 = 1
-  //           ${this.setSql(pc_name, 'and pc_name LIKE ?', [`%${pc_name}%`])}
-  //           ${this.setSql(is_rent, 'and is_rent = ?', [is_rent])}
-  //           ${this.setSql(shop_name, 'and shop_name LIKE ?', [`%${shop_name}%`])}
-  //           ${this.setSql(is_abnormal, 'and is_abnormal = ?', [is_abnormal])}
-  //       `;
-  //   return this.sqlRenderPage(sql, query);
-  // }
+
+  //表编码格式不一致导致报错解决办法
+      //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 
+          a.task_id,
+          b.task_name
+        from 
+          shuyou_rent_computer_usage a
+          LEFT JOIN shuyou_game_task b ON a.task_id = b.id
+        where a.pc_num = ?`,
+        [info.pc_num]
+      );
+      if (taskIds) {
+        info.taskIdList = taskIds.map(e => {
+          // item.id+' [ '+item.task_name+' ] '
+          return (e.task_id);
+          // return (e.task_id +' [ '+e.task_name+' ] ');
+        });
+      }
+    }
+    return info;
+  }
+
+  /**
+   * 修改
+   * @param param 数据
+   */
+   async update(param) {
+    // console.log(param)
+    const taskInfo = await this.ShuyouRentComputerEntity.findOne({ id: param.id });
+    if (!taskInfo) {
+      throw new CoolCommException('租机不存在');
+    }
+    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
+          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
+          WHERE 1 = 1
+            ${this.setSql(pc_num, 'and pc_num = ?', [pc_num])}
+          GROUP BY a.id
+        `;
+    return this.sqlRenderPage(sql, query);
+  }
+
+
+
 }

+ 8 - 3
cool-admin-vue-vue3-ts-vite/src/cool/modules/shuyou/components/shuyouGameTaskName-select.vue

@@ -1,13 +1,18 @@
 <!--
  * @Author: YKH
  * @Date: 2022-09-05 20:50:57
- * @LastEditTime: 2022-09-08 21:56:59
+ * @LastEditTime: 2022-09-16 23:31:58
  * @Description: file content
- * @FilePath: \cool-admin\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\components\shuyouGameTaskName-select.vue
+ * @FilePath: \cool-admin-3.x\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\components\shuyouGameTaskName-select.vue
 -->
 <template>
-	<el-select v-model="value" v-bind="props" filterable  multiple @change="onChange">
+	<!-- <el-select v-model="value" v-bind="props" filterable  multiple @change="onChange">
 		<el-option v-for="(item, index) in list" :key="index" :value="item.id" :label="item.id+' [ '+item.task_name+' ] '" />
+	</el-select> -->
+	<el-select v-model="value" v-bind="props" filterable multiple @change="onChange"
+		placeholder="可搜索">
+		<el-option v-for="(item, index) in list" :key="index" :value="item.id"
+			:label="item.id" />
 	</el-select>
 </template>
 

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

@@ -107,7 +107,7 @@ export default defineComponent({
 					}
 				},
 				{
-					prop: "rent_person",
+					prop: "rent_person_id",
 					label: "租赁人",
 					span: 8,
 					component: {
@@ -121,7 +121,6 @@ export default defineComponent({
 					prop: "shop_id",
 					label: "供应商",
 					span: 8,
-					group: "base",
 					component: {
 						name: "shuyouRentComputerShopSelect",
 						props: {
@@ -288,7 +287,7 @@ export default defineComponent({
 					sortable: "true",
 					headerAlign: "left",
 					align: "left",
-					minWidth: 100,
+					minWidth: 180,
 				},
 				{
 					prop: "pc_num",
@@ -355,7 +354,7 @@ export default defineComponent({
 					minWidth: 120
 				},
 				{
-					prop: "rent_person",
+					prop: "rent_person_name",
 					label: "租赁人",
 					headerAlign: "left",
 					align: "left",