From a4831debee63c7071a261c5f6ecfa62fd535b2ab Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Thu, 25 Jan 2024 16:21:18 +0800
Subject: [PATCH] 分页修改

---
 src/views/list/Unit.vue |  647 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 323 insertions(+), 324 deletions(-)

diff --git a/src/views/list/Unit.vue b/src/views/list/Unit.vue
index 68bb462..06d199a 100644
--- a/src/views/list/Unit.vue
+++ b/src/views/list/Unit.vue
@@ -159,400 +159,399 @@
 </template>
 
 <script lang="tsx">
-import {
-    Component,
-    Prop,
-    Vue,
-    Model,
-    Watch,
-} from 'vue-property-decorator';
-import moment from 'moment';
+import { Component, Prop, Vue, Model, Watch } from "vue-property-decorator";
+import moment from "moment";
 import { get, post } from "@/util/request";
-import * as _ from 'lodash';
+import * as _ from "lodash";
 @Component({
-  components: {
-  },
+  components: {},
 })
 export default class QueryList extends Vue {
- //������������
+  //������������
   private rules: any = {
-    unitName:[
-      { required: true, message: '������������������', trigger: 'blur' },
-      { message: '������������������������20������', max: 19 },
+    unitName: [
+      { required: true, message: "������������������", trigger: "blur" },
+      { message: "������������������������20������", max: 19 },
     ],
-    parentCode:[{ required: true, message: '������������' }],
-    areaCode:[{ required: true, message: '������������' }],
-    state:[{ required: true, message: '������������' }]
-  }
-    private formLayout = {
-      labelCol: {
-        span: 5,
-      },
-      wrapperCol: {
-        span: 15,
-      },
-    };
-    private serch:any = {
-        name:'',
-        parentCode: [],
-        areaCode:''
-    }
-    private editForm: any = {
-        unitName:'',
-        parentCode: [],
-        areaCode:'',
-        state:'0',
-    }
-
-  private pagination:any={
-    total:0,
-    current:1,
-    pageSize:10,
-    showSizeChanger: true,
-    showQuickJumper: true,
-    pageSizeOptions: ['10', '30', '60', '100'],
-    showTotal: (total:number) => `������ ${this.pagination.total} ���������`,  //���������������������������
+    parentCode: [{ required: true, message: "������������" }],
+    areaCode: [{ required: true, message: "������������" }],
+    state: [{ required: true, message: "������������" }],
+  };
+  private formLayout = {
+    labelCol: {
+      span: 5,
+    },
+    wrapperCol: {
+      span: 15,
+    },
+  };
+  private serch: any = {
+    name: "",
+    parentCode: [],
+    areaCode: "",
+  };
+  private editForm: any = {
+    unitName: "",
+    parentCode: [],
+    areaCode: "",
+    state: "0",
   };
 
-    @Watch('serch.name')
-    private watchsearchInform(newVal:string,oldval:string){
-      if (newVal !== '' && oldval === '') {
-        this.pagination.current = 1
-      }
-        this.handleSearch()
+  private pagination: any = {
+    total: 0,
+    current: 1,
+    pageSize: 10,
+    showSizeChanger: true,
+    showQuickJumper: true,
+    pageSizeOptions: ["10", "30", "60", "100"],
+    showTotal: (total: number) => `������ ${this.pagination.total} ���������`, //���������������������������
+  };
+
+  @Watch("serch.name")
+  private watchsearchInform(newVal: string, oldval: string) {
+    if (newVal !== "" && oldval === "") {
+      this.pagination.current = 1;
     }
+    this.handleSearch();
+  }
 
-    private expandForm: boolean = false;
+  private expandForm: boolean = false;
 
-    private selectedRows: any[] = [];
-    
-    private parentListOptions: any[] = [];
-    private newParentListOptions: any[] = [];
+  private selectedRows: any[] = [];
 
-    private tableLoading: boolean = false;
-    private visibleInvalidityModal: boolean = false;
+  private parentListOptions: any[] = [];
+  private newParentListOptions: any[] = [];
 
-    private moment: any = moment;
-    private pageState: String = 'add';
+  private tableLoading: boolean = false;
+  private visibleInvalidityModal: boolean = false;
 
-    private dataSource: any[] = [];
-    
-    private areaCodeList: any[] = [];
-    
-    private newAreaCodeList: any[] = [];
+  private moment: any = moment;
+  private pageState: String = "add";
 
-    private visibleCreateModal: boolean = false;
+  private dataSource: any[] = [];
+
+  private areaCodeList: any[] = [];
+
+  private newAreaCodeList: any[] = [];
+
+  private visibleCreateModal: boolean = false;
 
   private createForm: any = null;
-    
-    private title: any = null;
+
+  private title: any = null;
 
   private columns: any[] = [
-      {
+    {
       title: "������",
       dataIndex: "key",
       key: "key",
       align: "center",
-      customRender: (text,record,index) => `${index+1}`,
+      customRender: (text, record, index) => `${index + 1}`,
       width: 60,
     },
     {
-      title: '������',
-             align: "center",
-            dataIndex: 'unitName',
-        },
-        {
-          title: '������������',
-             align: "center",
-            dataIndex: 'parentName',
-        },
-        {
-          title: '������������',
-             align: "center",
-            dataIndex: 'areaName',
-        },
-        {
-            title: '������������',
-            dataIndex: 'updateTime',
-        },
-        {
-          title: '���������',
-             align: "center",
-            dataIndex: 'createName',
-        },
-        {
-            title: '������',
-          dataIndex: 'state',
-             align: "center",
-            customRender: this.progressStateRender,
+      title: "������",
+      align: "center",
+      dataIndex: "unitName",
     },
-            {
-            title: '������������',
-          dataIndex: 'isInvalid',
-             align: "center",
-            customRender: this.progressIsInvalidRender,
-        },
-        {
-          title: '������',
-             align: "center",
-            customRender: this.opRender,
-        },
-    ];
+    {
+      title: "������������",
+      align: "center",
+      dataIndex: "parentName",
+    },
+    {
+      title: "������������",
+      align: "center",
+      dataIndex: "areaName",
+    },
+    {
+      title: "������������",
+      dataIndex: "updateTime",
+    },
+    {
+      title: "���������",
+      align: "center",
+      dataIndex: "createName",
+    },
+    {
+      title: "������",
+      dataIndex: "state",
+      align: "center",
+      customRender: this.progressStateRender,
+    },
+    {
+      title: "������������",
+      dataIndex: "isInvalid",
+      align: "center",
+      customRender: this.progressIsInvalidRender,
+    },
+    {
+      title: "������",
+      align: "center",
+      customRender: this.opRender,
+    },
+  ];
 
-
-    private handleModalVisible(isVisible: boolean): void {
-      this.visibleCreateModal = isVisible;
-      this.pageState='add'
-      this.title='������������������'
-    }
+  private handleModalVisible(isVisible: boolean): void {
+    this.visibleCreateModal = isVisible;
+    this.pageState = "add";
+    this.title = "������������������";
+  }
 
   private handleSearch(): void {
-    console.log(this.serch)
-       const data = this.serch.parentCode
-        let code =data[data.length-1]
-        
-        get("unit/selectUint",{
-            name:this.serch.name,
-            parentCode:code,
-            parentCodeList:this.serch.parentCode,
-            areaCode:this.serch.areaCode,
-            page:this.pagination.current,
-            size: this.pagination.pageSize
-        }).then(res=>{
-          this.dataSource = res.data.data.item
-          this.pagination.total = res.data.data.total
-        })
-        .catch(err=>{
-            console.log(err);
-        })
-    }
+    console.log(this.serch);
+    const data = this.serch.parentCode;
+    let code = data[data.length - 1];
+
+    get("unit/selectUint", {
+      name: this.serch.name,
+      parentCode: code,
+      parentCodeList: this.serch.parentCode,
+      areaCode: this.serch.areaCode,
+      page: this.pagination.current,
+      size: this.pagination.pageSize,
+    })
+      .then((res) => {
+        this.dataSource = res.data.data.item;
+        this.pagination.total = res.data.data.total;
+      })
+      .catch((err) => {
+        console.log(err);
+      });
+  }
 
   private handlerTableChange(pagination: any, filter: any, sorter: any): void {
-      console.log('pagination',pagination)
-      this.pagination.current = pagination.current
-      this.pagination.pageSize = pagination.pageSize
-      this.pagination.total = pagination.total
-      this.handleSearch()
-    }
+    console.log("pagination", pagination);
+    this.pagination.current = pagination.current;
+    this.pagination.pageSize = pagination.pageSize;
+    this.pagination.total = pagination.total;
+    this.handleSearch();
+  }
 
   private handleCreateModalOk() {
-    let api ='unit/insert'
-    if (this.pageState === 'edit') {
-      api='unit/update'
+    let api = "unit/insert";
+    if (this.pageState === "edit") {
+      api = "unit/update";
     }
     this.$refs.ruleForm.validate((valid: any) => {
       console.log(valid);
       if (valid) {
-        const data = this.editForm.parentCode
-        let code =data[data.length-1]
+        const data = this.editForm.parentCode;
+        let code = data[data.length - 1];
         console.log(this.editForm);
         // ������������
         post(api, {
-            unitId: this.editForm.unitId,
-            unitName:this.editForm.unitName,
-            parentCode: code,
-            parentCodeList:this.editForm.parentCode,
-            areaCode: this.editForm.areaCode,
-            state:parseInt(this.editForm.state)
-        }).then((res: any) => {
-           this.handleSearch()
-          this.visibleCreateModal = false
-          this.editForm = {
-            unitName:'',
-            parentCode: [],
-            areaCode:'',
-            state: '0',
-            parentCodeList:[]
-          }
-        }).catch((err)=>{
-            console.log(err);
+          unitId: this.editForm.unitId,
+          unitName: this.editForm.unitName,
+          parentCode: code,
+          parentCodeList: this.editForm.parentCode,
+          areaCode: this.editForm.areaCode,
+          state: parseInt(this.editForm.state),
         })
+          .then((res: any) => {
+            this.handleSearch();
+            this.visibleCreateModal = false;
+            this.editForm = {
+              unitName: "",
+              parentCode: [],
+              areaCode: "",
+              state: "0",
+              parentCodeList: [],
+            };
+          })
+          .catch((err) => {
+            console.log(err);
+          });
       } else {
-        console.log('error submit!!');
+        console.log("error submit!!");
         return false;
       }
     });
 
-      console.log('editForm',this.editForm)
-    }
+    console.log("editForm", this.editForm);
+  }
 
-    private handleCreateModalCancel(): any {
-      this.visibleCreateModal = false;
-      this.editForm = {
-        unitName:'',
-        parentCode: [],
-        areaCode:'',
-        state: '0',
-        parentCodeList:[]
-      }
-    }
+  private handleCreateModalCancel(): any {
+    this.visibleCreateModal = false;
+    this.editForm = {
+      unitName: "",
+      parentCode: [],
+      areaCode: "",
+      state: "0",
+      parentCodeList: [],
+    };
+  }
   private handleInvalidityModalCancel(): any {
-      this.editForm = {
-        unitName:'',
-        parentCode: [],
-        areaCode:'',
-        state: '0',
-        parentCodeList:[]
-      }
-      this.visibleInvalidityModal = false;
-    }
+    this.editForm = {
+      unitName: "",
+      parentCode: [],
+      areaCode: "",
+      state: "0",
+      parentCodeList: [],
+    };
+    this.visibleInvalidityModal = false;
+  }
 
-    private cityData() {
-        get("system/area/queryCity",{
-          
-        }).then(res => {
-          console.log('00000000000000', res);
-          let org = res.data.data;
-          let lists = JSON.stringify(org);
+  private cityData() {
+    get("system/area/queryCity", {})
+      .then((res) => {
+        console.log("00000000000000", res);
+        let org = res.data.data;
+        let lists = JSON.stringify(org);
 
-          lists = lists.replace(/"areaCode"/g, '"value"');
+        lists = lists.replace(/"areaCode"/g, '"value"');
 
-          lists = lists.replace(/"areaName"/g, '"label"');
+        lists = lists.replace(/"areaName"/g, '"label"');
 
-          const treeLists = JSON.parse(lists)
-          this.parentListOptions = JSON.parse(JSON.stringify(treeLists))
-          this.newParentListOptions = JSON.parse(JSON.stringify(treeLists))
-        })
-        .catch(err=>{
-            console.log(err);
-        })
-    }
+        const treeLists = JSON.parse(lists);
+        this.parentListOptions = JSON.parse(JSON.stringify(treeLists));
+        this.newParentListOptions = JSON.parse(JSON.stringify(treeLists));
+      })
+      .catch((err) => {
+        console.log(err);
+      });
+  }
 
-  private  positionLevel(val: any) {
-    this.serch.areaCode = ''
-    this.editForm.areaCode = ''
-     let code =val[val.length-1]
-        get("system/area/code",{
-          code:code
-        }).then(res => {
-          console.log('00000000000000', res);
-          this.areaCodeList= res.data.data;
-          this.newAreaCodeList= res.data.data;
-        })
-        .catch(err=>{
-            console.log(err);
-        })
-    }
+  private positionLevel(val: any) {
+    this.serch.areaCode = "";
+    this.editForm.areaCode = "";
+    let code = val[val.length - 1];
+    get("system/area/code", {
+      code: code,
+    })
+      .then((res) => {
+        console.log("00000000000000", res);
+        this.areaCodeList = res.data.data;
+        this.newAreaCodeList = res.data.data;
+      })
+      .catch((err) => {
+        console.log(err);
+      });
+  }
 
-    private mounted() {
+  private mounted() {
+    this.handleSearch();
+    this.cityData();
+  }
+
+  private updatedAtRender(text: string) {
+    return <span> {moment(text).format("YYYY-MM-DD HH:mm:ss")} </span>;
+  }
+
+  private handleAssert(record: any) {
+    get("unit/state", {
+      unitId: record.unitId,
+    })
+      .then((res) => {
         this.handleSearch();
-        this.cityData()
-    }
+        this.$message.success("������������");
+      })
+      .catch((err) => {
+        console.log(err);
+      });
+  }
+  private recordTableData: any = null;
+  private handleInvalidity(record: any) {
+    this.visibleInvalidityModal = true;
+    this.recordTableData = record;
+  }
 
-    private updatedAtRender(text: string) {
-        return <span> {
-            moment(text).format('YYYY-MM-DD HH:mm:ss')
-        } </span>;
-    }
-
-    private handleAssert(record: any){
-       get("unit/state",{
-         unitId: record.unitId,
-          
-       }).then(res => {
-           this.handleSearch()
-           this.$message.success('������������')
-        })
-        .catch(err=>{
-            console.log(err);
-        })
-    }
-    private recordTableData: any = null;
-    private handleInvalidity(record: any) {
-      this.visibleInvalidityModal = true
-       this.recordTableData=record
-    }
-  
   private handleInvalidityModalOk(record: any) {
-       this.createForm.validateFields((err: any, fieldsValue: any) => {
-            if (err) {
-                return;
-            }
-            get("unit/invalid",{
-              unitId: this.recordTableData.unitId,
-              invalidReason:this.createForm.getFieldValue('code')
-            }).then(res => { 
-              this.$message.success('������������')
-              this.visibleInvalidityModal = false
-              this.handleSearch()
-            })
-            .catch(err=>{
-                console.log(err);
-            })
+    this.createForm.validateFields((err: any, fieldsValue: any) => {
+      if (err) {
+        return;
+      }
+      get("unit/invalid", {
+        unitId: this.recordTableData.unitId,
+        invalidReason: this.createForm.getFieldValue("code"),
+      })
+        .then((res) => {
+          this.$message.success("������������");
+          this.visibleInvalidityModal = false;
+          this.handleSearch();
+        })
+        .catch((err) => {
+          console.log(err);
         });
+    });
   }
-    
+
   private progressIsInvalidRender(text: Number) {
-        if (text === 0) {
-            return <a-badge status = 'success' text = '���������' />;
-        }
-        return <a-badge status = 'error' text = '���������' />;
+    if (text === 0) {
+      return <a-badge status="success" text="���������" />;
+    }
+    return <a-badge status="error" text="���������" />;
   }
-  
+
   private progressStateRender(text: string) {
-        if (text === '0') {
-            return <a-badge status = 'success' text = '������' />;
-        }
-        return <a-badge status = 'processing' text = '���������' />;
+    if (text === "0") {
+      return <a-badge status="success" text="������" />;
+    }
+    return <a-badge status="processing" text="���������" />;
   }
-    private async handleUpdateModalVisible(visible: boolean, record: any): void {
-      this.visibleCreateModal = true;
-      await this.positionLevel(record.parentCodeList)
-      this.title = '������������������'
-      let params = _.cloneDeep(record)
-      console.log(params)
-      params.parentCode=record.parentCodeList
-      this.editForm = params 
-      this.pageState='edit'
-      console.log('editForm',record)
-    }
-    private async handleDetailModalVisible(visible: boolean, record: any): void {
-      this.visibleCreateModal = true;
-      await this.positionLevel(record.parentCodeList)
-      this.title = '������������������'
-       let params = _.cloneDeep(record)
-      console.log(params)
-      params.parentCode=record.parentCodeList
-      this.editForm = params 
-      this.pageState='view'
-    }
+  private async handleUpdateModalVisible(visible: boolean, record: any): void {
+    this.visibleCreateModal = true;
+    await this.positionLevel(record.parentCodeList);
+    this.title = "������������������";
+    let params = _.cloneDeep(record);
+    console.log(params);
+    params.parentCode = record.parentCodeList;
+    this.editForm = params;
+    this.pageState = "edit";
+    console.log("editForm", record);
+  }
+  private async handleDetailModalVisible(visible: boolean, record: any): void {
+    this.visibleCreateModal = true;
+    await this.positionLevel(record.parentCodeList);
+    this.title = "������������������";
+    let params = _.cloneDeep(record);
+    console.log(params);
+    params.parentCode = record.parentCodeList;
+    this.editForm = params;
+    this.pageState = "view";
+  }
   private opRender(text: string, record: any, index: number) {
     // ������console
-    console.log('record',record)
-    if (record.state === '0') {
+    console.log("record", record);
+    if (record.state === "0") {
       if (Number(record.isInvalid) === 0) {
-        return <div>
-              <a onClick = {
-                () => this.handleDetailModalVisible(true, record)
-            } > ������ </a>
-            <a-divider type = 'vertical' />
-            <a  onClick = {
-                () => this.handleInvalidity(record)
-            } >������</a>
-            </div>
+        return (
+          <div>
+            <a onClick={() => this.handleDetailModalVisible(true, record)}>
+              {" "}
+              ������{" "}
+            </a>
+            <a-divider type="vertical" />
+            <a onClick={() => this.handleInvalidity(record)}>������</a>
+          </div>
+        );
       } else {
-         return <div>
-              <a onClick = {
-                () => this.handleDetailModalVisible(true, record)
-            } > ������ </a>
-            </div>
+        return (
+          <div>
+            <a onClick={() => this.handleDetailModalVisible(true, record)}>
+              {" "}
+              ������{" "}
+            </a>
+          </div>
+        );
       }
-        } else {
-           return   <div>
-              <a onClick = {
-                () => this.handleDetailModalVisible(true, record)
-            } > ������ </a>
-            <a-divider type='vertical' />
-             <a onClick = {
-                () => this.handleUpdateModalVisible(true, record)
-            } > ������ </a>
-            </div>
-        }
-      this.handleSearch();
+    } else {
+      return (
+        <div>
+          <a onClick={() => this.handleDetailModalVisible(true, record)}>
+            {" "}
+            ������{" "}
+          </a>
+          <a-divider type="vertical" />
+          <a onClick={() => this.handleUpdateModalVisible(true, record)}>
+            {" "}
+            ������{" "}
+          </a>
+        </div>
+      );
     }
-
+  }
 }
 </script>
 
-<style lang="less" scoped>
-</style>
+<style lang="less" scoped></style>

--
Gitblit v1.8.0