“linengliang”
2023-09-18 2b45e5b3c7dbfb14aee6de42013a3caad8d486ba
设备备件
已添加4个文件
已修改1个文件
913 ■■■■■ 文件已修改
src/views/eam/EquipmentList.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/modules/equipmentNew/EquipmentSpareParts.vue 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/modules/equipmentNew/EquipmentSparePartsModal.vue 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/modules/equipmentNew/edit/EquipmentSparePartsForm.vue 331 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/modules/equipmentNew/serach/SparePartsList.vue 306 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/EquipmentList.vue
@@ -404,6 +404,9 @@
            <a-menu-item  v-has="'equipmentAccount:add&delete&import&Edit'">
              <a @click="handleEdit(record)" >编辑</a>
            </a-menu-item>
            <a-menu-item  v-has="'equipmentAccount:add&delete&import&Edit'">
              <a @click="handleEditSpareParts(record)" >编辑备件</a>
            </a-menu-item>
            <a-menu-item>
              <a-popconfirm
                title="确定删除吗?"
@@ -438,10 +441,13 @@
      <a-tab-pane tab="设备文档" key="3" forceRender>
        <EquipmentDocumentList :mainId="selectedMainId" />
      </a-tab-pane>
      <a-tab-pane tab="ABC标识变更记录" key="4" forceRender>
      <a-tab-pane tab="备件" key="4" forceRender>
        <EquipmentSpareParts :mainId="selectedMainId" />
      </a-tab-pane>
      <a-tab-pane tab="ABC标识变更记录" key="5" forceRender>
        <equipment-update-ABC-list :mainId="selectedMainId" />
      </a-tab-pane>
      <a-tab-pane tab="质保期变更记录" key="5" forceRender>
      <a-tab-pane tab="质保期变更记录" key="6" forceRender>
        <equipment-update-warranty-list :mainId="selectedMainId" />
      </a-tab-pane>
    </a-tabs>
@@ -450,6 +456,7 @@
    <precision-edit-model ref ="precisionEditModel"></precision-edit-model>
    <aBC-update-edit-model @ok="modalFormOk" :updateList="selectionRows" ref="updateABC"></aBC-update-edit-model>
    <warranty-update-model  :updateList="selectionRows"  ref="updateWarranty"></warranty-update-model>
    <EquipmentSparePartsModal ref="modalFormSpareParts" @ok="modalFormOk" />
  </a-card>
</template>
@@ -469,12 +476,10 @@
  import PrecisionEditModel from './modules/equipmentNew/edit/PrecisionEditModel'
  import EquipmentUpdateABCList from './modules/equipmentNew/EquipmentUpdateABCList.vue'
  import EquipmentUpdateWarrantyList from './modules/equipmentNew/EquipmentUpdateWarrantyList.vue'
import ABCUpdateEditModel from './modules/equipmentNew/edit/ABCUpdateEditModel.vue'
import WarrantyUpdateModel from './modules/equipmentNew/edit/WarrantyUpdateModel.vue'
  import ABCUpdateEditModel from './modules/equipmentNew/edit/ABCUpdateEditModel.vue'
  import WarrantyUpdateModel from './modules/equipmentNew/edit/WarrantyUpdateModel.vue'
  import EquipmentSpareParts from './modules/equipmentNew/EquipmentSpareParts.vue'
  import EquipmentSparePartsModal from './modules/equipmentNew/EquipmentSparePartsModal'
  export default {
    name: "EquipmentList",
    mixins:[JeecgListMixin,mixinDevice],
@@ -484,13 +489,15 @@
      EquipmentPrecisionParametersList,
      EquipmentModal,
      EquipmentResumeDrawer,
        JSearchSelectTag,
      JSearchSelectTag,
        ProcessEditModel,
        PrecisionEditModel,
        EquipmentUpdateABCList ,
        EquipmentUpdateWarrantyList,
        ABCUpdateEditModel,
        WarrantyUpdateModel,
        EquipmentSpareParts,
        EquipmentSparePartsModal
    },
    data () {
      return {
@@ -893,6 +900,9 @@
    },
    handleUpdateWarranty(){
      this.$refs.updateWarranty.add();
    },
    handleEditSpareParts(record){
      this.$refs.modalFormSpareParts.edit(record);
    }
    }
src/views/eam/modules/equipmentNew/EquipmentSpareParts.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,189 @@
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- æŸ¥è¯¢åŒºåŸŸ-END -->
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator" v-if="mainId">
      <a-button
      @click="handleAdd"
      type="primary"
      icon="plus"
      v-if="mainId !='' && isAdd "
      >新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" -->
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            ä¸‹è½½
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record" >
          <a @click="handleEdit(record)" v-if="addStatus" >编辑</a>
          <a-divider type="vertical"  v-if="addStatus" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)" >
            <a v-if="addStatus">删除</a>
          </a-popconfirm>
          <a style="font-size: 12px;font-style: italic;" v-if="!addStatus">该状态不可操作</a>
        </span>
      </a-table>
    </div>
  </a-card>
</template>
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  export default {
    name: "EquipmentSpareParts",
    mixins:[JeecgListMixin],
    components: {},
    props:{
      mainId:{
        type:String,
        default:'',
        required:false
      },
      isEdit: {
        type: Boolean,
        default: false
      },
      isAdd: {
        type: Boolean,
        default: false
      },
      isDel: {
        type: Boolean,
        default: false
      }
    },
    watch:{
      mainId:{
        immediate: true,
        handler(val) {
          if(!this.mainId){
            this.clearList()
          }else{
            this.queryParam['equipmentId'] = val
            this.loadData(1);
          }
        }
      }
    },
    data () {
      return {
        disableMixinCreated:true,
        repairOrderSelectionRows:[],
        // è¡¨å¤´
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'备件编码',
            align:"center",
            dataIndex: 'num',
            width:200
          },
          {
            title:'备件名称',
            align:"center",
            dataIndex: 'name',
            width:200
          },
          {
            title:'规格',
            align:"center",
            dataIndex: 'specification',
            width:200
          },
          {
            title:'型号',
            align:"center",
            dataIndex: 'model',
            width:200
          },
          // {
          //   title:'数量',
          //   align:"center",
          //   dataIndex: 'quantity',
          //   width:200
          // },
          {
            title:'计量单位',
            align:"center",
            dataIndex: 'unitId_dictText',
            width:200
          },
        ],
        url: {
          list: "/eam/equipmentSpares/myPage",
        },
        dictOptions:{
        }
      }
    },
    created() {
    },
    computed: {
      importExcelUrl(){
        return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`;
      }
    },
    methods: {
      clearList(){
        this.dataSource=[]
        this.selectedRowKeys=[]
        this.ipagination.current = 1
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
src/views/eam/modules/equipmentNew/EquipmentSparePartsModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
<template>
  <j-modal
    :title="'备件编辑'"
    :width='2000'
    :visible='visible'
    :maskClosable='false'
    :fullscreen="true"
    switchFullscreen
    @ok='handleOk'
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel='handleCancel'>
    <equipment-spare-parts-form ref='realForm' @ok='submitCallback' :disabled='disableSubmit' />
  </j-modal>
</template>
<script>
import EquipmentSparePartsForm from './edit/EquipmentSparePartsForm'
export default {
  name: 'EquipmentSparePartsModal',
  components: {
    EquipmentSparePartsForm
  },
  data() {
    return {
      title: '',
      width: 800,
      visible: false,
      disableSubmit: false
    }
  },
  methods: {
    add() {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.add()
      })
    },
    edit(record) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.edit(record)
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.$refs.realForm.handleOk()
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>
src/views/eam/modules/equipmentNew/edit/EquipmentSparePartsForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,331 @@
<template>
  <a-spin :spinning='confirmLoading'>
    <!-- ä¸»è¡¨å•区域 -->
    <a-form-model ref='form' :model='model' :rules='validatorRules'>
      <a-row>
        <a-col :span='12'>
          <a-form-model-item label='统一编码' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='num'>
            <a-input v-model='model.num' placeholder='系统自动生成' :disabled = "true"></a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span='12'>
          <a-form-model-item label='设备名称' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='name'>
            <a-input v-model='model.name' placeholder='系统自动生成' :disabled = "true"></a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span='12'>
          <a-form-model-item label='规格' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='specification'>
            <a-input v-model='model.specification' placeholder='系统自动生成' :disabled = "true"></a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span='12'>
          <a-form-model-item label='型号' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='model'>
            <a-input v-model='model.model' placeholder='系统自动生成' :disabled = "true"></a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <!-- å­è¡¨å•区域 -->
    <a-tabs v-model='activeKey' @change='handleChangeTabs'>
      <a-tab-pane tab='备件' :key='refKeys[0]' :forceRender='true'>
        <j-vxe-table
          keep-source
          :ref='refKeys[0]'
          highlight-current-row
          :loading='sparePartsVxeTable.loading'
          :columns='sparePartsVxeTable.columns'
          :dataSource='sparePartsVxeTable.dataSource'
          :maxHeight='300'
          :disabled='formDisabled'
          :rowNumber='true'
          :rowSelection='true'
          @pageChange='handleTable1PageChange'
          :pagination='sparePartsVxeTable.pagination'
          :toolbar='true'
          :toolbarConfig='toolbarConfig'
        >
          <template slot='toolbarPrefix'>
            <a-button type='primary' @click='equipmentSparesSelect' :disabled="formDisabled">选择备件
            </a-button>
          </template>
        </j-vxe-table>
      </a-tab-pane>
    </a-tabs>
    <spare-parts-list @selectionRows='selectionRows' ref='SparePartsSelectModal' :categories="model.toolingCategoryFlag"></spare-parts-list>
  </a-spin>
</template>
<script>
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import { getRefPromise, VALIDATE_FAILED } from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
import JFormContainer from '@/components/jeecg/JFormContainer'
import { getAction } from '@api/manage'
import { filterObj } from '@/utils/util'
import SparePartsList from '../serach/SparePartsList'
export default {
  name: 'EquipmentSparePartsForm',
  mixins: [JVxeTableModelMixin],
  components: {
    JFormContainer,
    SparePartsList
  },
  data() {
    return {
      type: '',
      disableSubmit: false,
      documentTypeStr: '',
      dataList: [],
      detailList: [],
      isShow: true,
      company: '',
      queryParam: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      toolbarConfig: {
        // prefix å‰ç¼€ï¼›suffix åŽç¼€
        slot: ['prefix', 'suffix'],
        // add æ–°å¢žæŒ‰é’®ï¼›remove åˆ é™¤æŒ‰é’®ï¼›clearSelection æ¸…空选择按钮
        btn: ['remove', 'clearSelection']
      },
      model: {},
      // æ–°å¢žæ—¶å­è¡¨é»˜è®¤æ·»åŠ å‡ è¡Œç©ºæ•°æ®
      addDefaultRowNum: 0,
      validatorRules: {
      },
      refKeys: ['sparePartsCowsVagina'],
      tableKeys: ['sparePartsCowsVagina'],
      activeKey: 'sparePartsCowsVagina',
      sparePartsVxeTable: {
        loading: false,
        pagination: { current: 1, pageSize: 1000, pageSizeOptions: ['1000', '2000'], total: 0 },
        dataSource: [],
        columns: [
          {
            title: '备件编码',
            key: 'num',
            type: JVXETypes.normal,
            width: '200px',
            align: 'center',
            placeholder: '请输入${title}',
          },
          {
            title: '备件名称',
            key: 'name',
            type: JVXETypes.normal,
            width: '200px',
            align: 'center',
            placeholder: '请输入${title}',
          },
          {
            title: '规格',
            key: 'specification',
            type: JVXETypes.normal,
            width: '200px',
            align: 'center',
          },
          {
            title: '型号',
            key: 'model',
            align: 'center',
            type: JVXETypes.normal,
            width: '150px',
          },
          {
            title: '单位',
            key: 'unitName',
            align: 'center',
            type: JVXETypes.normal,
            width: '150px',
          },
        ]
      },
      result: Array,
      url: {
        list: '/tooling/toolingStockTaking/getToolingList',
        add: '/tooling/toolingStockTaking/add',
        edit: '/eam/equipmentSpares/editByEquipment',
        queryById: '/tooling/toolingStockTaking/queryById',
        sparePartsCowsVagina: {
          list: '/eam/equipmentSpares/myList'
        }
      }
    }
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    }
  },
  methods: {
    selectionRows(data) {
      // å¢žåŠ é€‰ä¸­çš„è®¾å¤‡åˆ°åˆ—è¡¨ä¸­
      this.addSelectedEquipments(data)
    },
    changeBtn() {
      this.addSelectedEquipments(this.dataList)
    },
    getData() {
      // å°è£…查询条件
      let params = {
        pageNo: this.sparePartsVxeTable.pagination.current,
        pageSize: this.sparePartsVxeTable.pagination.pageSize,
        id: this.model.id
      }
      // è°ƒç”¨æŸ¥è¯¢æ•°æ®æŽ¥å£
      this.sparePartsVxeTable.loading = true
      this.requestSubTableData(this.url.sparePartsCowsVagina.list, params, this.sparePartsVxeTable)
    },
    handleTable1PageChange(event) {
      // é‡æ–°èµ‹å€¼
      this.sparePartsVxeTable.pagination.current = event.current
      this.sparePartsVxeTable.pagination.pageSize = event.pageSize
      // æŸ¥è¯¢æ•°æ®
      this.getData()
    },
    //选择设备
    equipmentSparesSelect() {
      let ids = []
      let tableData = this.$refs.sparePartsCowsVagina.getTableData()
      let deleteData = this.$refs.sparePartsCowsVagina.getDeleteData()
      for (let i = 0; i < tableData.length; i++) {
        ids.push(tableData[i].sparePartId)
      }
      this.$refs.SparePartsSelectModal.showModals(ids)
      this.$refs.SparePartsSelectModal.title = '选择备件'
      this.$refs.SparePartsSelectModal.disableSubmit = false
    },
    addSelectedEquipments(data) {
      let tableData = this.$refs.sparePartsCowsVagina.getTableData()
      var tableStr = JSON.stringify(tableData)
      const addRows = []
      console.log(data)
      console.log(tableStr)
      for (let i = 0; i < data.length; i++) {
        var sparePartsCowsVagina = {}
        if (tableStr.indexOf(data[i].id) == -1) {
          sparePartsCowsVagina = {
            sparePartId:data[i].id,
            num : data[i].num,
            name: data[i].name,
            model: data[i].model,
            specification: data[i].specification,
            unitId:data[i].mainUnitId,
            unitName: data[i].mainUnitId_dictText,
            delFlag: 0
          }
        }
        addRows.push(sparePartsCowsVagina)
      }
      this.$refs.sparePartsCowsVagina.pushRows(addRows)
    },
    addBefore() {
      this.sparePartsVxeTable.dataSource = []
    },
    getAllTable() {
      let values = this.tableKeys.map(key => getRefPromise(this, key))
      return Promise.all(values)
    },
    /** è°ƒç”¨å®Œedit()方法之后会自动调用此方法 */
    editAfter() {
      this.$nextTick(() => {
      })
      // åŠ è½½å­è¡¨æ•°æ®
      if (this.model.id) {
        let params = {
          pageNo: this.sparePartsVxeTable.pagination.current,
        pageSize: this.sparePartsVxeTable.pagination.pageSize,
        id: this.model.id
       }
        this.requestSubTableData(this.url.sparePartsCowsVagina.list, params, this.sparePartsVxeTable)
      }
    },
    //校验所有一对一子表表单
    validateSubForm(allValues) {
      return new Promise((resolve, reject) => {
        Promise.all([]).then(() => {
          resolve(allValues)
        }).catch(e => {
          if (e.error === VALIDATE_FAILED) {
            // å¦‚果有未通过表单验证的子表,就自动跳转到它所在的tab
            this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
          } else {
            console.error(e)
          }
        })
      })
    },
    /** æ•´ç†æˆformData */
    classifyIntoFormData(allValues) {
      let main = Object.assign(this.model, allValues.formValue)
      return {
        ...main, // å±•å¼€
        equipmentSparesList: allValues.tablesValue[0].tableData
      }
    },
    validateError(msg) {
      this.$message.error(msg)
    },
    requestSubTableData(url, params, tab, success) {
      tab.loading = true
      getAction(url, params).then(res => {
        let { result } = res
        let dataSource = []
        if (result) {
          if (Array.isArray(result)) {
            dataSource = result
          } else if (Array.isArray(result.records)) {
            dataSource = result.records
          }
        }
        tab.dataSource = dataSource
        if (res.result.total) {
            this.sparePartsVxeTable.pagination.total = res.result.total
        } else {
            this.sparePartsVxeTable.pagination.total = 0
        }
        typeof success === 'function' ? success(res) : ''
      }).finally(() => {
        tab.loading = false
      })
    },
    cleanData(){
      this.$refs.sparePartsCowsVagina.remove();
    }
  }
}
</script>
<style scoped>
</style>
src/views/eam/modules/equipmentNew/serach/SparePartsList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,306 @@
<template>
  <!--支持全屏缩放-->
  <a-modal :visible='visible' :title='title' switchFullscreen @ok='handleSubmit' @cancel='close' style='top:50px'
           cancelText='关闭' :width='1950'>
    <a-card :bordered='false'>
      <div class='table-page-search-wrapper'>
        <a-form layout='inline' @keyup.enter.native='searchQuery'>
          <a-row :gutter='24'>
            <a-col :md='6' :sm='4'>
              <a-form-item label='备件编码'>
                <j-input
                 placeholder='请输入备件编码'
                 v-model='queryParam.num'
                 @pressEnter="handlePressEnter"
                 >
                 <a-icon slot="prefix" type="barcode" />
                </j-input>
              </a-form-item>
            </a-col>
            <a-col :md='6' :sm='4'>
              <a-form-item label='备件名称'>
                <j-input placeholder='请输入备件名称' v-model='queryParam.name'/>
              </a-form-item>
            </a-col>
            <a-col :md='3'>
              <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
                <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
                <a-button @click='searchReset' icon='reload' style='margin-left: 10px'>重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <a-row :gutter='24'>
        <a-col :md='24' :sm='12'>
          <a-table ref='table' :scroll='{ x: true }' size='middle' rowKey='id' bordered :columns='columns'
                   :dataSource='dataSource' :pagination='ipagination' :rowSelection='rowSelection' :loading='loading'
                   @change='handleTableChange'>
                   <template slot="takingInfo" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;color: #126ee7;">/</span>
                    <span v-if="text" style="font-size: 12px;font-style: italic;">{{text}}</span>
                  </template>
          </a-table>
        </a-col>
      </a-row>
    </a-card>
  </a-modal>
</template>
<script>
import { filterObj } from '@/utils/util'
import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'SparePartsList',
  mixins: [JeecgListMixin],
  components: {},
  props: {
    categories:{
      type:String,
      default:'',
      required:false
    }
  },
  data() {
    return {
      queryParam: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'备件编码',
            align:"center",
            dataIndex: 'num',
            width:200
          },
          {
            title:'备件名称',
            align:"center",
            dataIndex: 'name',
            width:200
          },
          {
            title:'规格',
            align:"center",
            dataIndex: 'specification',
            width:200
          },
          {
            title:'型号',
            align:"center",
            dataIndex: 'model',
            width:200
          },
          {
            title:'计量单位',
            align:"center",
            dataIndex: 'mainUnitId_dictText',
            width:200
          },
      ],
      selectedRowKeys: [],
      oldSelectRows: [],
      scrollTrigger: {},
      dataSource: [],
      selectSource: [],
      selectionRows: [],
      title: '选择刀工量',
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['5', '10', '30', '50', '100'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' å…±' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      isorter: {
        column: 'num',
        order: 'desc'
      },
      visible: false,
      loading: false,
      url: {
        list: '/eam/equipmentSpares/sparePartlist'
      },
      numFake: '',
      nameFake: ''
    }
  },
  computed: {
    rowSelection() {
      const { selectedRowKeys } = this
      return {
        type: 'checkbox',
        onChange: this.onSelectChange,
        getCheckboxProps: record => ({
          props: {
            disabled: record.distable
          }
        }),
        selectedRowKeys
      }
    }
  },
  methods: {
    deleteSelectRowkey(key) {
      this.selectedRowKeys = this.selectedRowKeys.filter(item => item != key.id)
      this.selectSource = this.selectSource.filter(item => item != key)
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      if (selectedRowKeys.length === selectedRows.length) {
        this.selectedRows = selectedRows
      } else {
        this.selectedRows = selectedRowKeys.map(key => (
          this.selectedRows.find(row => row.id === key) || selectedRows.find(row => row.id === key)//必在两者之中
        ))
      }
      this.selectSource = [...this.selectedRows]
    },
    async loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1
      }
      this.loading = true
      this.queryParam.categories = this.categories;
      let params = this.getQueryParams()//查询条件
      await getAction(this.url.list, params).then((res) => {
        if (res.success) {
          for (let i = 0; i < res.result.records.length; i++) {
            if (this.oldSelectRows.indexOf(res.result.records[i].id) > -1) {
              res.result.records[i].distable = true
            } else {
              res.result.records[i].distable = false
            }
          }
          this.dataSource = res.result.records
          this.$emit('change', this.dataSource);
          console.log(this.dataSource)
          this.ipagination.total = res.result.total
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
    showModals(oldSelectRows) {
      this.oldSelectRows = oldSelectRows
      this.visible = true
      this.loadData(1)
    },
    getQueryParams() {
      let param = Object.assign({}, this.queryParam, this.isorter)
      param.field = this.getQueryField()
      param.pageNo = this.ipagination.current
      param.pageSize = this.ipagination.pageSize
      return filterObj(param)
    },
    //查询条件处理
    getQueryField() {
      let str = 'id,'
      for (let a = 0; a < this.columns.length; a++) {
        str += ',' + this.columns[a].dataIndex
      }
      return str
    },
    searchReset(num) {
      this.queryParam = []
      this.numFake = ''
      this.nameFake = ''
      if (num !== 0) {
        this.loadData(1)
      }
      this.selectborrowIds = []
    },
    close() {
      this.searchReset(0)
      this.selectedRowKeys = []
      this.selectSource = []
      this.visible = false
    },
    handleTableChange(pagination, filters, sorter) {
      //TODO ç­›é€‰
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field
        this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc'
      }
      this.ipagination = pagination
      this.loadData()
    },
    handleSubmit() {
      this.$emit('selectionRows', this.selectSource)
      this.searchReset(0)
      this.close()
    },
    searchQuery() {
      this.loadData(1)
    },
    handlePressEnter(event) {
      that.queryParam.toolingNum = ''
      const that = this
      let invCode = event.target.value.trim()
      if (invCode.length == 0 || invCode == '' || invCode == null || invCode == undefined) {
        that.$message.warning('存货编码不能为空');
      }
      else{
        this.searchReset()
        that.queryParam.toolingNum = invCode
      }
    },
    handlePressEnterCode(event) {
      that.queryParam.toolingCode = ''
      const that = this
      let toolingCode = event.target.value.trim()
      if (toolingCode == 0 || toolingCode == '' || toolingCode == null || toolingCode == undefined) {
        that.$message.warning('量具条码不能为空');
      }
      else{
        that.queryParam.toolingCode = toolingCode
      }
    },
  }
}
</script>
<style scoped>
.ant-table-tbody .ant-table-row td {
  padding-top: 10px;
  padding-bottom: 10px;
}
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}
</style>