src/views/mdc/base/modules/EquipmentList/DeviceListModal.vue
@@ -6,13 +6,13 @@
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="7" :sm="7">
            <a-col :md="9" :sm="9">
              <a-form-item label="统一编码">
                <a-input placeholder="请输入统一编码检索" v-model="queryParam.equipmentid"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="7" :sm="7">
            <a-col :md="9" :sm="9">
              <a-form-item label="设备名称">
                <a-input placeholder="请输入设备名称检索" v-model="queryParam.equipmentname"></a-input>
              </a-form-item>
@@ -21,7 +21,7 @@
            <a-col :md="3" :sm="3">
              <a-space>
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
              </a-space>
            </a-col>
          </a-row>
@@ -30,8 +30,8 @@
      <!-- table区域-begin -->
      <div>
        <a-table ref="table" size="middle" bordered rowKey="id" :scroll="{  y: 300 }" :columns="columns"
                 :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        <a-table bordered rowKey="equipmentid" :scroll="{  y: 300 }" :columns="columns"
                 :dataSource="dataSource" :pagination="ipagination" :loading="loading" :customRow="customRow"
                 :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio'}"
                 @change="handleTableChange">
        </a-table>
@@ -42,215 +42,106 @@
</template>
<script>
  import {
    ajaxGetSelectItems
  } from '@/api/api'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'
  import {
    deleteAction,
    requestPut,
    getAction
  } from '@/api/manage'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  import JEllipsis from '@/components/jeecg/JEllipsis'
  import Tooltip from 'ant-design-vue/es/tooltip'
  import JDate from '@/components/jeecg/JDate'
  import moment from 'moment'
  import { filterObj } from '@/utils/util';
  import { getAction } from '@/api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  export default {
    name: 'DeviceListModel',
    mixins: [JeecgListMixin],
    components: {
      JDictSelectTag,
      JEllipsis,
      JInput,
      Tooltip,
      JDate
    },
    props: {
      status: {
        type: Number,
        default: 1
      }
    },
    data() {
      return {
        title:'',
        title: '',
        visible: false,
        disableMixinCreated: true,
        queryParam: {},
        columns: [{
          title: '统一编码',
          align: 'center',
          dataIndex: 'equipmentid',
        },
        columns: [
          {
            title: '统一编码',
            align: 'center',
            dataIndex: 'equipmentid'
          },
          {
            title: '设备名称',
            align: 'center',
            dataIndex: 'equipmentname',
            dataIndex: 'equipmentname'
          },
          {
            title: '设备型号',
            align: 'center',
            dataIndex: 'equipmentmodel',
            dataIndex: 'equipmentmodel'
          },
          // {
          //   title: '设备类型',
          //   align: 'center',
          //   dataIndex: 'equipmentType',
          // },
          {
            title: '机床IP',
            align: 'center',
            dataIndex: 'equipmentip',
            dataIndex: 'equipmentip'
          },
          {
            title: '驱动类型',
            align: 'center',
            dataIndex: 'drivetype',
            dataIndex: 'drivetype'
          },
          {
            title: '端口',
            align: 'center',
            dataIndex: 'dataport',
            dataIndex: 'dataport'
          },
          {
            title: '数控系统',
            align: 'center',
            dataIndex: 'controlsystem',
            dataIndex: 'controlsystem'
          }
        ],
        url: {
          list: '/mdc/equipment/list',
        /* 排序参数 */
        isorter: {
          column: '',
          order: ''
        },
        url: {
          list: '/mdc/equipment/list'
        }
      }
    },
    created() {
    },
    methods: {
      openPage() {
        this.visible = true
        this.onClearSelected()
        this.dataSource = [];
        // this.queryParam = {
        //   status: this.status
        // };
        this.loadData();
        this.dataSource = []
        this.loadData()
      },
      getQueryParams() {
        //获取查询条件
        let sqp = {}
        if(this.superQueryParams){
          sqp['superQueryParams']=encodeURI(this.superQueryParams)
          sqp['superQueryMatchType'] = this.superQueryMatchType
        }
        var param = Object.assign(sqp, this.queryParam);
        // param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        //获取用户定制的参数属性
        // if (this.getCustomQueryParams) {
        //   param = this.getCustomQueryParams(param);
        //   if(!param){
        //     return false;
        //   }
        // }
        return filterObj(param);
      },
      loadData(arg) {
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        if(!params){
          return false;
        }
        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;
      /**
       * 自定义表格行
       * @param record 表格行信息
       * @returns {{style: {cursor: string}, on: {click: on.click}}}
       */
      customRow(record) {
        return {
          style: {
            cursor: 'pointer'
          },
          on: {
            click: () => {
              this.onSelectChange([record.equipmentid], [record])
            }
            //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
          }else{
            // this.$message.warning(res.message)
            this.$notification.warning({
              message:'消息',
              description:res.message
            });
          }
        }).finally(() => {
          this.loading = false
        })
        }
      },
      getQueryField() {
        //TODO 字段权限控制
        // var str = "";
        // this.columns.forEach(function (value) {
        //   str +=  value.dataIndex +"," ;
        // });
        // return str;
      },
      modalFormOk(val) {
        // 新增/修改 成功时,重载列表
        this.loadData();
        this.selectedRowKeys = [val.id];
      },
      searchQuery() {
        this.loadData();
        this.onClearSelected()
      },
      searchReset() {
        this.queryParam = {}
        this.loadData();
        this.onClearSelected()
      },
      close() {
        this.$emit('close')
        this.visible = false
      },
      handleCancel() {
        this.close()
      },
      handleOk() {
        this.$emit('sendSelectionRows', this.selectionRows[0])
        this.close()
      },
    },
      }
    }
  }
</script>
<style>
  @import '~@assets/less/common.less';
  .frozenRowClass {
    color: #c9c9c9;
  }
  .success {
    color: green;
  }
  .error {
    color: red;
  }
</style>