zenglf
2023-09-18 92ff846fb659c62037a32b1d8c15eae9df9d9b54
src/views/spare/modules/sparePartCancellingStocks/SparePartCancellingStocksDetailList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,245 @@
<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>
    <div>
      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :scroll="{ x: 'calc(1400px + 50%)', y: 900 }"
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        @change='handleTableChange'
      >
        <span
          slot='status'
          slot-scope='text, record'
        >
          <span v-if="record.status == '0'">未入库</span>
          <span
            v-if="record.status == '1'"
            style='color: red'
          >已入库</span>
        </span>
        <span slot='action' slot-scope='text, record'>
                <a-popconfirm v-if="record.cancellingStatus === '2' && record.status == 0" title='点击确认后,将直接上架修改库存?'
                              @confirm='() => handleGround(record)'>
                  <a>上架</a>
                </a-popconfirm>
        </span>
      </a-table>
    </div>
  </a-card>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, requestPut } from '@/api/manage'
import Tooltip from 'ant-design-vue/es/tooltip'
export default {
  name: 'SparePartCancellingStocksDetailList',
  mixins: [JeecgListMixin],
  components: {
    Tooltip
  },
  props: {
    sparePartCancellingId: {
      type: String,
      default: '-1',
      required: false
    }
  },
  watch: {
    sparePartCancellingId: {
      immediate: true,
      handler(val) {
        if (!this.sparePartCancellingId) {
          this.clearList()
        } else {
          this.queryParam['sparePartCancellingId'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' }
        },
        {
          title: '备件编码',
          align: 'center',
          dataIndex: 'num'
        },
        {
          title: '备件名称',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '型号',
          align: 'center',
          dataIndex: 'model'
        },
        {
          title: '规格',
          align: 'center',
          dataIndex: 'specification'
        },
        {
          title: '批次号',
          align: 'center',
          dataIndex: 'batchNum'
        },
        {
          title: '出厂日期',
          align: 'center',
          dataIndex: 'manufactureDate',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '供应商',
          align: 'center',
          dataIndex: 'supplierName'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'mainUnitName'
        },
       /*  {
          title: '辅单位',
          align: 'center',
          dataIndex: 'auxiliaryUnitName'
        }, */
        {
          title: '出库数量',
          align: 'center',
          dataIndex: 'outboundMainQuantity'
        },
        {
          title: '退库数量',
          align: 'center',
          dataIndex: 'mainQuantity'
        },
        {
          title: '库区',
          align: 'center',
          dataIndex: 'warehouseAreaName'
        },
        {
          title: '库位',
          align: 'center',
          dataIndex: 'warehouseLocationNum'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          scopedSlots: { customRender: 'action' },
          width: 150
        }
      ],
      url: {
        list: '/spare/sparePartCancellingStocks/getSparePartCancellingStocksDetailsById',
        ground: '/spare/sparePartCancellingStocks/sparePartGround'
      }
    }
  },
  created() {
  },
  computed: {},
  methods: {
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    },
    handleGround(record) {
      const that = this
      requestPut(that.url.ground, record).then((res) => {
        console.log(record)
        if (res.success) {
          that.$message.success('入库成功!')
          that.$bus.$emit('outGroundSuccess', 1)
          that.loadData()
        } else {
          that.$message.warning('入库失败!')
        }
      })
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 è‹¥ä¼ å…¥å‚æ•°1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams()//查询条件
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          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
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>