src/views/eam/base/modules/EamMaintenanceStandardDetailList.vue
@@ -21,131 +21,123 @@
</template>
<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
  import '@/assets/less/TableExpand.less'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@api/manage'
export default {
  name: 'EamMaintenanceStandardDetailList',
  mixins: [JeecgListMixin],
  props: {
    standardId: {
      type: String,
      required: true,
      default: '-1'
    }
  },
  data() {
    return {
      description: '保养标准明细管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          align: 'center',
          dataIndex: 'itemCode',
          width: 60,
        },
        {
          title: '部位',
          align: 'center',
          dataIndex: 'itemPart',
          width: 200,
          ellipsis: true,
        },
        {
          title: '保养项',
          align: 'center',
          dataIndex: 'itemName',
          ellipsis: true,
        },
        {
          title: '保养要求',
          align: 'center',
          dataIndex: 'itemDemandAlias',
          ellipsis: true,
        },
        {
          title: '检查标准或要求',
          align: 'center',
          dataIndex: 'itemDemand',
          ellipsis: true,
        },
        {
          title: '检查方法',
          align: 'center',
          dataIndex: 'checkMethod',
          ellipsis: true,
        }
      ],
      url: {
        list: '/eam/eamMaintenanceStandardDetail/list'
  export default {
    name: 'EamMaintenanceStandardDetailList',
    mixins: [JeecgListMixin],
    props: {
      standardId: {
        type: String,
        required: true,
        default: '-1'
      }
    }
  },
  watch: {
    standardId: {
      immediate: true,
      handler(val) {
        if(val) {
          this.loadData(1)
        }else {
          this.clearList();
    },
    data() {
      return {
        description: '保养标准明细管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            align: 'center',
            dataIndex: 'itemCode',
            width: 60
          },
          {
            title: '部位',
            align: 'center',
            dataIndex: 'itemPart',
            ellipsis: true
          },
          {
            title: '保养项分类',
            align: 'center',
            dataIndex: 'itemCategory_dictText',
            ellipsis: true
          },
          {
            title: '保养项目',
            align: 'center',
            dataIndex: 'itemName',
            ellipsis: true
          },
          {
            title: '保养规范或要求',
            align: 'center',
            dataIndex: 'itemDemand',
            ellipsis: true
          }
        ],
        url: {
          list: '/eam/eamMaintenanceStandardDetail/list'
        }
      }
    }
  },
  created() {
  },
  computed: {
  },
  methods: {
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
    },
    watch: {
      standardId: {
        immediate: true,
        handler(val) {
          if (val) {
            this.loadData(1)
          } else {
            this.clearList()
          }
        }
      }
      if(this.standardId && this.standardId === '-1'){
        this.clearList();
        return;
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
    },
    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
        }
        let params = this.getQueryParams()//查询条件
        if (!params) {
          return false
        }
        this.dataSource = []
        params.standardId = this.standardId
        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
            } else {
              this.ipagination.total = 0
            }
            //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      clearList() {
        this.dataSource = []
        this.selectedRowKeys = []
        this.ipagination.current = 1
      }
      let params = this.getQueryParams()//查询条件
      if (!params) {
        return false
      }
      this.dataSource = []
      params.standardId = this.standardId
      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
          } else {
            this.ipagination.total = 0
          }
          //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    },
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
  @import '~@assets/less/common.less';
</style>