quanyawei
2023-11-13 d6833c760d1f00082555bbe55feb05b41e761e6c
src/views/list/Unit.vue
@@ -80,6 +80,7 @@
          <a-cascader
            v-model="editForm.parentCode"
            placeholder="请选择"
            change-on-select
            :options="newParentListOptions"
            @change="positionLevel"
            :disabled="pageState === 'view'"
@@ -200,15 +201,17 @@
        unitName:'',
        parentCode: [],
        areaCode:'',
        state:Number,
        state:'0',
    }
  private pagination:any={
    total:0,
    current:1,
    pageSize:5,
    showSizeChanger: false,
    showQuickJumper: false,
    pageSize:10,
    showSizeChanger: true,
    showQuickJumper: true,
    pageSizeOptions: ['10', '30', '60', '100'],
    showTotal: (total:number) => `共有 ${this.pagination.total} 条数据`,  //分页中显示总的数据
  };
    @Watch('serch.name')
@@ -244,16 +247,28 @@
    
    private title: any = null;
    private columns: any[] = [{
            title: '名称',
  private columns: any[] = [
      {
      title: "序号",
      dataIndex: "key",
      key: "key",
      align: "center",
      customRender: (text,record,index) => `${index+1}`,
      width: 60,
    },
    {
      title: '名称',
             align: "center",
            dataIndex: 'unitName',
        },
        {
            title: '上级区域',
          title: '上级区域',
             align: "center",
            dataIndex: 'parentName',
        },
        {
            title: '所属区域',
          title: '所属区域',
             align: "center",
            dataIndex: 'areaName',
        },
        {
@@ -261,16 +276,25 @@
            dataIndex: 'updateTime',
        },
        {
            title: '操作人',
          title: '操作人',
             align: "center",
            dataIndex: 'createName',
        },
        {
            title: '状态',
            dataIndex: 'state',
          dataIndex: 'state',
             align: "center",
            customRender: this.progressStateRender,
    },
            {
            title: '是否作废',
          dataIndex: 'isInvalid',
             align: "center",
            customRender: this.progressIsInvalidRender,
        },
        {
            title: '操作',
          title: '操作',
             align: "center",
            customRender: this.opRender,
        },
    ];
@@ -286,24 +310,27 @@
    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,
            current: this.pagination.current,
            page:1,
            size: 20
            page:this.pagination.current,
            size: this.pagination.pageSize
        }).then(res=>{
          this.dataSource =res.data.data.item
          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 {
  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()
    }
@@ -326,7 +353,7 @@
            parentCode: code,
            parentCodeList:this.editForm.parentCode,
            areaCode: this.editForm.areaCode,
            state:this.editForm.state
            state:parseInt(this.editForm.state)
        }).then((res: any) => {
           this.handleSearch()
          this.visibleCreateModal = false
@@ -334,7 +361,7 @@
            unitName:'',
            parentCode: [],
            areaCode:'',
            state: Number,
            state: '0',
            parentCodeList:[]
          }
        }).catch((err)=>{
@@ -350,10 +377,24 @@
    }
    private handleCreateModalCancel(): any {
        this.visibleCreateModal = false;
      this.visibleCreateModal = false;
      this.editForm = {
        unitName:'',
        parentCode: [],
        areaCode:'',
        state: '0',
        parentCodeList:[]
      }
    }
    private handleInvalidityModalCancel(): any {
        this.visibleInvalidityModal = false;
  private handleInvalidityModalCancel(): any {
      this.editForm = {
        unitName:'',
        parentCode: [],
        areaCode:'',
        state: '0',
        parentCodeList:[]
      }
      this.visibleInvalidityModal = false;
    }
    private cityData() {
@@ -377,7 +418,7 @@
        })
    }
  private positionLevel(val: any) {
  private  positionLevel(val: any) {
    this.serch.areaCode = ''
    this.editForm.areaCode = ''
     let code =val[val.length-1]
@@ -406,10 +447,11 @@
    private handleAssert(record: any){
       get("unit/state",{
         id: record.unitId,
         unitId: record.unitId,
          
        }).then(res => {
          <a-alert message="生效成功" type="success" />
       }).then(res => {
           this.handleSearch()
           this.$message.success('操作成功')
        })
        .catch(err=>{
            console.log(err);
@@ -430,8 +472,9 @@
              unitId: this.recordTableData.unitId,
              invalidReason:this.createForm.getFieldValue('code')
            }).then(res => { 
              <a-alert message="已作废" type="success" />
              this.visibleInvalidityModal=false
              this.$message.success('操作成功')
              this.visibleInvalidityModal = false
              this.handleSearch()
            })
            .catch(err=>{
                console.log(err);
@@ -439,16 +482,22 @@
        });
  }
    
    private progressStateRender(text: string) {
  private progressIsInvalidRender(text: Number) {
        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 = '未生效' />;
  }
    private handleUpdateModalVisible(visible: boolean, record: any): void {
    private async handleUpdateModalVisible(visible: boolean, record: any): void {
      this.visibleCreateModal = true;
      this.positionLevel(record.parentCodeList)
      await this.positionLevel(record.parentCodeList)
      this.title = '编辑责任单位'
      let params = _.cloneDeep(record)
      console.log(params)
@@ -457,78 +506,49 @@
      this.pageState='edit'
      console.log('editForm',record)
    }
    private handleDetailModalVisible(visible: boolean, record: any): void {
    private async handleDetailModalVisible(visible: boolean, record: any): void {
      this.visibleCreateModal = true;
      await this.positionLevel(record.parentCodeList)
      this.title = '责任单位详情'
      this.editForm = record
       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('1111',text)
    console.log('2222',record)
    console.log('333', index)
      if (record.state==='1') {
        if (record.isInvalid ===0) {
       return   <div>
            <a onClick = {
                () => this.handleUpdateModalVisible(true, record)
            } > 编辑 </a>
          <a-divider type='vertical' />
    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 v-show="record.state !=='1'" onClick={ () => this.handleAssert(record)
              } >生效</a>
            <a-divider type = 'vertical' />
            <a v-show="record.isInvalid !=='0'" onClick = {
            <a  onClick = {
                () => this.handleInvalidity(record)
            } >作废</a>
            </div>
        } else {
           return   <div>
            <a onClick = {
                () => this.handleUpdateModalVisible(true, record)
            } > 编辑 </a>
          <a-divider type='vertical' />
              <a onClick = {
                () => this.handleDetailModalVisible(true, record)
            } > 详情 </a>
            <a-divider type = 'vertical'  / >
            <a v-show="record.state !=='1'" onClick={ () => this.handleAssert(record)
              } >生效</a>
            </div>
        }
      } else {
          if (record.isInvalid ===0) {
       return   <div>
            <a onClick = {
                () => this.handleUpdateModalVisible(true, record)
            } > 编辑 </a>
          <a-divider type='vertical' />
         return <div>
              <a onClick = {
                () => this.handleDetailModalVisible(true, record)
            } > 详情 </a>
            <a-divider type = 'vertical' />
            <a v-show="record.isInvalid !=='0'" onClick = {
                () => this.handleInvalidity(record)
            } >作废</a>
            </div>
      }
        } else {
           return   <div>
            <a onClick = {
                () => this.handleUpdateModalVisible(true, record)
            } > 编辑 </a>
          <a-divider type='vertical' />
              <a onClick = {
                () => this.handleDetailModalVisible(true, record)
            } > 详情 </a>
            <a-divider type = 'vertical'  / >
            <a-divider type='vertical' />
             <a onClick = {
                () => this.handleUpdateModalVisible(true, record)
            } > 编辑 </a>
            </div>
        }
      }
      this.handleSearch();
    }
}