zhaowei
昨天 c182a210e2e5ab812e104c63c2fbb1a16e91afae
src/views/eam/base/modules/EamMaintenanceStandardDetailList.vue
@@ -1,27 +1,9 @@
<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="detailTable"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">
      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
  <a-table ref="detailTable" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
           :pagination="ipagination" :loading="loading" class="j-table-force-nowrap" @change="handleTableChange"/>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
@@ -33,51 +15,100 @@
      type: String,
      required: true,
      default: '-1'
    },
    pageSelectionRow: {
      type: Object,
      default: () => {
      }
    },
    filterKey: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      description: '保养标准明细管理页面',
      // 表头
      columns: [
      columns: [],
      inspectionColumns: [
        {
          title: '序号',
          align: 'center',
          dataIndex: 'itemCode',
          width: 60,
          width: 60
        },
        {
          title: '部位',
          title: '保养项分类',
          align: 'center',
          dataIndex: 'itemPart',
          width: 200,
          ellipsis: true,
          dataIndex: 'itemCategory_dictText',
          width: 150
        },
        {
          title: '保养项',
          align: 'center',
          title: '保养项目',
          headerAlign: 'center',
          align: 'left',
          dataIndex: 'itemName',
          ellipsis: true,
          ellipsis: true
        },
        {
          title: '保养要求',
          align: 'center',
          dataIndex: 'itemDemandAlias',
          ellipsis: true,
        },
        {
          title: '检查标准或要求',
          align: 'center',
          title: '保养规范或要求',
          headerAlign: 'center',
          align: 'left',
          dataIndex: 'itemDemand',
          ellipsis: true,
        },
        {
          title: '检查方法',
          align: 'center',
          dataIndex: 'checkMethod',
          ellipsis: true,
          ellipsis: true
        }
      ],
      secondMaintenanceColumns: [
        {
          title: '序号',
          align: 'center',
          dataIndex: 'itemCode',
          width: 60
        },
        {
          title: '保养项分类',
          align: 'center',
          dataIndex: 'itemCategory_dictText',
          width: 150
        },
        {
          title: '保养项目',
          headerAlign: 'center',
          align: 'left',
          dataIndex: 'itemName',
          ellipsis: true
        }
      ],
      thirdMaintenanceColumns: [
        {
          title: '序号',
          align: 'center',
          dataIndex: 'itemCode',
          width: 60
        },
        {
          title: '保养部位',
          align: 'center',
          dataIndex: 'itemPart',
          ellipsis: true
        },
        {
          title: '保养内容',
          headerAlign: 'center',
          align: 'left',
          dataIndex: 'itemName',
          ellipsis: true
        },
        {
          title: '验收标准',
          headerAlign: 'center',
          align: 'left',
          dataIndex: 'itemDemand',
          ellipsis: true
        }
      ],
      disableMixinCreated: true,
      url: {
        list: '/eam/eamMaintenanceStandardDetail/list'
      }
@@ -87,28 +118,32 @@
    standardId: {
      immediate: true,
      handler(val) {
        if(val) {
        if (val) {
          this.loadData(1)
        }else {
          this.clearList();
        } else {
          this.clearList()
        }
      }
    },
    pageSelectionRow: {
      immediate: true,
      handler(val) {
        switch (val.maintenanceCategory) {
          case 'POINT_INSPECTION':
            this.columns = this.inspectionColumns
            break
          case 'SECOND_MAINTENANCE':
            this.columns = this.secondMaintenanceColumns
            break
          case 'THIRD_MAINTENANCE':
            this.columns = this.thirdMaintenanceColumns
            break
        }
      }
    }
  },
  created() {
  },
  computed: {
  },
  methods: {
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      if(this.standardId && this.standardId === '-1'){
        this.clearList();
        return;
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
@@ -119,33 +154,53 @@
      }
      this.dataSource = []
      params.standardId = this.standardId
      params.itemCategory = this.filterKey
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          // console.log(res)
          //update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
          this.dataSource = res.result.records || res.result
          if (res.result.total) {
            this.ipagination.total = res.result.total
      console.log('----------------------', this.filterKey)
      getAction(this.url.list, params)
        .then((res) => {
          if (res.success) {
            this.dataSource = res.result.records
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
          } else {
            this.ipagination.total = 0
            this.$notification.warning({
              message: '消息',
              description: res.message
            })
          }
          //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
        })
        .finally(() => {
          this.loading = false
        })
    },
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    },
      this.clearSelected()
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
<style scoped lang="less">
/* 表头全部居中 */
::v-deep .ant-table-thead > tr > th {
  text-align: center !important;
}
/* 表体:序号、保养项分类、保养部位的内容居中 */
::v-deep .ant-table-tbody > tr > td[data-col="itemCode"],
::v-deep .ant-table-tbody > tr > td[data-col="itemCategory_dictText"],
::v-deep .ant-table-tbody > tr > td[data-col="itemPart"] {
  text-align: center !important;
}
/* 表体:保养项目、保养内容、验收标准的内容左对齐 */
::v-deep .ant-table-tbody > tr > td[data-col="itemName"],
::v-deep .ant-table-tbody > tr > td[data-col="itemDemand"] {
  text-align: left !important;
}
</style>