CycleCountDetailList.vue 9.47 KB
<template>
  <a-card class="j-inner-table-wrapper" :bordered="false">
    <!-- 查询区域 begin -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域 end -->
    <!-- 操作按钮区域 begin -->
    <div class="table-operator">
      <a-button v-has="'cycleCountHeader:export'" type="primary" icon="download" @click="handleExportXls('盘点明细表')">{{
          $t('button.export')
        }}
      </a-button>
      <!-- 高级查询区域 -->
    </div>
    <!-- 操作按钮区域 end -->
    <!-- table区域 begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :loading="loading"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :expandedRowKeys="expandedRowKeys"
        :rowSelection="{selectedRowKeys, onChange: onSelectChange}"
        @expand="handleExpand"
        @change="handleTableChange"
      >
        <!-- 内嵌table区域 begin -->
        <template slot="expandedRowRender" slot-scope="record">
          <a-tabs tabPosition="top">
            <a-tab-pane :tab="$t('inventory.materialDetails')" key="cycleCountDetailChild" forceRender>
              <cycle-count-detail-child-sub-table :record="record"/>
            </a-tab-pane>
          </a-tabs>
        </template>
        <!-- 内嵌table区域 end -->

        <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText">
          <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)">
            {{ inventoryStatus_dictText }}
          </a-tag>
        </span>

        <span slot="enableStatus_dictText" slot-scope="enableStatus_dictText">
          <a-tag :key="enableStatus_dictText" :color="getStatusColor(enableStatus_dictText)">
            {{ enableStatus_dictText }}
          </a-tag>
        </span>

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <template slot="imgSlot" slot-scope="text">
          <div style="font-size: 12px;font-style: italic;">
            <span v-if="!text">无图片</span>
            <img v-else :src="getImgView(text)" alt="" style="max-width:80px;height:25px;"/>
          </div>
        </template>

        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else ghost type="primary" icon="download" size="small" @click="downloadFile(text)">
            <span>下载</span>
          </a-button>
        </template>

        <template slot="action" slot-scope="text, record">
          <cycle-count-detail-chi-id-modal ref="adjustmentModal" @ok="modalFormOk" :id="record.id"/>
          <a @click="createMany()">{{ $t('button.new') }}</a>
          <a-divider type="vertical"/>
          <a v-if="record.enableStatus == '1'" @click="selectPort(record)">{{ $t('inventory.createTask') }}</a>
          <a-divider v-if="record.enableStatus == '1'" type="vertical"/>
          <a @click="loadDatas(record.cycleCountHeadId)">
            <a-icon type="sync"/>&nbsp;{{ $t('button.refresh') }}</a>
        </template>

      </a-table>
    </div>
    <!-- table区域 end -->

    <!-- 表单区域 -->

    <cycle-count-select-modal ref="modalForm2"></cycle-count-select-modal>
    <cycle-count-detail-modal ref="modalForm" @ok="modalFormOk"/>

  </a-card>
</template>

<script>

import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getAction} from '@api/manage'
import CycleCountDetailModal from './modules/CycleCountDetailModal'
import CycleCountSelectModal from './modules/CycleCountSelectModal'
import CycleCountDetailChildSubTable from './subTables/CycleCountDetailChildSubTable'
import '@/assets/less/TableExpand.less'
import Utils from "@/components/jeecgbiz/JButtonBizComponent/util.js"
import CycleCountDetailChiIdModal from "./modules/CycleCountDetailChiIdModal";

export default {
  name: 'CycleCountDetailList',
  cycleCountDetailId: '',
  mixins: [JeecgListMixin],
  components: {
    CycleCountDetailModal,
    CycleCountDetailChildSubTable,
    CycleCountSelectModal,
    CycleCountDetailChiIdModal,
  },
  props: {
    record: {
      type: Object,
      default: null,
    },
    isLoad: {
      type: Boolean,
      default: false,
    }
  },
  data() {
    return {
      description: '盘点明细表列表管理页面',
      // 表头
      columns: [
        /*{
          title: 'ID',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: (t, r, index) => parseInt(index) + 1
        },
        {
          title: '盘点主单id',
          align: 'center',
          dataIndex: 'cycleCountHeadId',
        },*/
        {
          title: this.$t('inventory.mainCheckCode'),
          align: 'center',
          dataIndex: 'cycleCountHeadCode',
        },
        /*{
          title: '任务表头',
          align: 'center',
          dataIndex: 'taskHeaderId',
        },
        {
          title: '任务明细头',
          align: 'center',
          dataIndex: 'taskDetailId',
        },
        {
          title: '仓库',
          align: 'center',
          dataIndex: 'warehouseCode',
        },
        {
          title: '货主',
          align: 'center',
          dataIndex: 'companyCode',
        },
        {
          title: '库存明细头',
          align: 'center',
          dataIndex: 'inventoryDetailId',
        },*/
        {
          title: this.$t('inventory.location'),
          align: 'center',
          dataIndex: 'locationCode',
        },
        {
          title: this.$t('inventory.container'),
          align: 'center',
          dataIndex: 'containerCode',
        },
        {
          title: this.$t('inventory.inventoryStatus'),
          align: 'center',
          dataIndex: 'inventorySts_dictText' + this.$ls.get('language'),
          scopedSlots: {customRender: 'inventoryStatus_dictText'}
        },
        {
          title: this.$t('inventory.systemQty'),
          align: 'center',
          dataIndex: 'systemQty',
        },
        {
          title: this.$t('inventory.actualQty'),
          align: 'center',
          dataIndex: 'countedQty',
        },
        {
          title: this.$t('inventory.discrepancyQty'),
          align: 'center',
          dataIndex: 'gapQty',
        },
        {
          title: this.$t('inventory.reasonForFailure'),
          align: 'center',
          dataIndex: 'rejectionNote',
        },
        {
          title: this.$t('inventory.completer'),
          align: 'center',
          dataIndex: 'completedBy',
        },
        {
          title: this.$t('inventory.completionTime'),
          align: 'center',
          dataIndex: 'completedAt',
        },
        {
          title: this.$t('system.status'),
          align: 'center',
          dataIndex: 'enableStatus_dictText' + this.$ls.get('language'),
          scopedSlots: {customRender: 'enableStatus_dictText'}
        },
        {
          title: this.$t('system.options'),
          dataIndex: 'action',
          align: 'center',
          width: 147,
          scopedSlots: {customRender: 'action'},
        },
      ],
      // 字典选项
      dictOptions: {},
      // 展开的行test
      expandedRowKeys: [],
      url: {
        list: '/cycleCountDetail/cycleCountDetail/list',
        delete: '/cycleCountDetail/cycleCountDetail/delete',
        deleteBatch: '/cycleCountDetail/cycleCountDetail/deleteBatch',
        exportXlsUrl: '/cycleCountDetail/cycleCountDetail/exportXls',
        importExcelUrl: '/cycleCountDetail/cycleCountDetail/importExcel',
      },
    }
  },
  created() {
  },
  mounted() {
    let _this = this;
    Utils.$on('methodB', (data) => {
      _this.methodB(data);
    })
  },
  computed: {
    importExcelUrl() {
      return window._CONFIG['domianURL'] + this.url.importExcelUrl
    }
  },

  watch: {
    record: {
      immediate: true,
      handler() {
        if (this.record != null) {
          this.loadData(this.record)
        }
      }
    }
  },
  methods: {
    loadData(record) {
      this.loading = true
      this.dataSource = []
      if (record == undefined) {
        this.loading = false
        return
      }
      getAction(this.url.list, {
        cycleCountHeadId: record.id
      }).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
        }
      }).finally(() => {
        this.loading = false
      })

    },
    selectPort(record) {
      this.$refs.modalForm2.edit(record);
      this.$refs.modalForm2.title = this.$t('inventory.selectOutboundPort2');
    },
    loadDatas(record) {
      this.loading = true
      this.dataSource = []
      getAction(this.url.list, {
        cycleCountHeadId: record
      }).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
        }
      }).finally(() => {
        this.loading = false
      })
    },
    methodB(data) {
      var _this = this;
      _this.loadDatas(data);
    },
    initDictConfig() {
    },
    handleExpand(expanded, record) {
      this.expandedRowKeys = []
      if (expanded === true) {
        this.expandedRowKeys.push(record.id)
      }
    },
    createMany() {
      this.$refs.adjustmentModal.edit();
      this.$refs.adjustmentModal.title = this.$t('inventory.inventoryRegistration');
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
</style>