zenglf
2023-09-18 92ff846fb659c62037a32b1d8c15eae9df9d9b54
src/views/spare/modules/sparePartOutbound/SparePartOutboundDetail.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,249 @@
<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
            title="点击确认后,将直接出库修改库存?"
            @confirm="() => handleOutbound(record)"
          >
            <a v-if="record.outboundStatus === '2' && record.status ==='0'">出库</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'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import Vue from 'vue'
import { getFileAccessHttpUrl } from '@/api/manage';
export default {
  name: "SparePartOutboundDetail",
  mixins: [JeecgListMixin],
  components: {
    Tooltip,
  },
  props: {
    sparePartOutboundId: {
      type: String,
      default: '-1',
      required: false
    }
  },
  watch: {
    sparePartOutboundId: {
      immediate: true,
      handler(val) {
        if (!this.sparePartOutboundId) {
          this.clearList()
        } else {
          this.queryParam['sparePartOutboundId'] = 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: 'outboundMainQuantity',
        },
        {
          title: '库区',
          align: "center",
          dataIndex: 'warehouseAreaName',
        },
        {
          title: '库位',
          align: "center",
          dataIndex: 'warehouseLocationNum',
        },
        // {
        //   title: '辅单位',
        //   align: "center",
        //   dataIndex: 'auxiliaryUnitName',
        // },
        // {
        //   title: '出库辅数量',
        //   align: "center",
        //   dataIndex: 'outboundAuxiliaryUnitName',
        // },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          scopedSlots: { customRender: 'action' },
          width: 150,
        }
      ],
      url: {
        list: "/spare/sparePartOutboundDetail/getSparePartOutboundDetailsById",
        outbound: "/spare/sparePartOutboundDetail/sparePartOutbound",
      },
    }
  },
  created() {
  },
  computed: {
  },
  methods: {
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    },
    handleOutbound(record) {
      const that = this;
      requestPut(that.url.outbound, record).then((res) => {
        if (res.success) {
          that.$message.success("出库成功!")
          that.$bus.$emit('outboundSuccess', 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>