CycleCountDetailList.vue 13.3 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('盘点明细表')">
        导出
      </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"
      >
        <span slot="enableStatus_dictText" slot-scope="enableStatus_dictText">
            <a-tag :key="enableStatus_dictText" :color="getStatusColor(enableStatus_dictText)">
              {{ enableStatus_dictText }}
            </a-tag>
        </span>
        <template slot="locationCode" slot-scope="text, record">
          <a-tag color="#87d068" v-if="!record.locationCode">?</a-tag>
          <span v-else>{{ record.locationCode }}</span>
        </template>
        <template slot="containerCode" slot-scope="text, record">
          <a-tag color="#87d068" v-if="!record.containerCode">?</a-tag>
          <span v-else>{{ record.containerCode }}</span>
        </template>
        <template slot="systemQty" slot-scope="text, record">
          <a-tag color="#87d068" v-if="record.systemQty == null">?</a-tag>
          <span v-else>{{ record.systemQty }}</span>
        </template>
        <template slot="gapQty" slot-scope="text, record">
          <a-tag color="#87d068" v-if="record.gapQty == null">?</a-tag>
          <span v-else>{{ record.gapQty }}</span>
        </template>
        <!-- 内嵌table区域 begin -->
        <template slot="expandedRowRender" slot-scope="record">
          <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
              <a-row :gutter="24">
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
                  <a-form-item label="物料编码">
                    <a-input placeholder="请输入物料编码" v-model="queryParam.code"></a-input>
                  </a-form-item>
                </a-col>
                <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery2" icon="search">查询</a-button> 
            </span>
                </a-col>
              </a-row>
            </a-form>
          </div>
          <a-tabs tabPosition="top">
            <a-tab-pane tab="物料详情表" key="cycleCountDetailChild" forceRender>
              <cycle-count-detail-child-sub-table ref="childRef" :record="record"/>
            </a-tab-pane>
          </a-tabs>
        </template>
        <!-- 内嵌table区域 end -->
        <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">
          <a v-if="record.enableStatus <= 15" v-has="'cycleCountDetail:add'" @click="createMany(record)">新增</a>
          <a-divider v-if="record.enableStatus <= 15" type="vertical"/>
          <!--          <a v-if="record.enableStatus === 1"  @click="selectPort(record)">生成盘点任务</a>-->
          <a v-if="record.enableStatus <= 15 && record.enableStatus > 1" @click="completeTakeStock(record)">完成盘点</a>
          <a-divider v-if="record.enableStatus === 1" type="vertical"/>
<!--          <a @click="loadDatas(record.cycleCountHeadId)"><a-icon type="sync"/>刷新</a>-->
          <a v-if="record.enableStatus === 1" v-has="'cycleCountDetail:delete'">
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record)">
              <a>删除</a>
            </a-popconfirm>
          </a>
        </template>
      </a-table>
    </div>
    <!-- table区域 end -->
    <!-- 表单区域 -->
    <cycle-count-detail-child-modal ref="cycleCountDetailChildModal" @ok="modalFormOk" :id="record.id"/>
    <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 {deleteAction, 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 CycleCountDetailChildModal from "./modules/CycleCountDetailChiIdModal";

export default {
  name: 'CycleCountDetailList',
  mixins: [JeecgListMixin],
  components: {
    CycleCountDetailModal,
    CycleCountDetailChildSubTable,
    CycleCountSelectModal,
    CycleCountDetailChildModal,
  },
  props: {
    record: {
      type: Object,
      default: null,
    },
    isLoad: {
      type: Boolean,
      default: false,
    }
  },
  data() {
    return {
      description: '盘点明细表列表管理页面',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '盘点主单编码',
          align: 'center',
          dataIndex: 'cycleCountHeadCode',
        },
        {
          title: '库位',
          align: 'center',
          dataIndex: 'locationCode',
          scopedSlots: {customRender: 'locationCode'},
        },
        {
          title: '容器',
          align: 'center',
          dataIndex: 'containerCode',
          scopedSlots: {customRender: 'containerCode'},
        },
        {
          title: '系统数量',
          align: 'center',
          dataIndex: 'systemQty',
          scopedSlots: {customRender: 'systemQty'},
        },
        {
          title: '实盘数量',
          align: 'center',
          dataIndex: 'countedQty',
        },
        {
          title: '差异数量',
          align: 'center',
          dataIndex: 'gapQty',
          scopedSlots: {customRender: 'gapQty'},
        },
        /*{
          title: '失败原因',
          align: 'center',
          dataIndex: 'rejectionNote',
        },*/
        {
          title: '完成用户',
          align: 'center',
          dataIndex: 'completedBy',
        },
        {
          title: '完成时间',
          align: 'center',
          dataIndex: 'completedAt',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'enableStatus_dictText',
          scopedSlots: {customRender: 'enableStatus_dictText'}
        },
        {
          title: '操作',
          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',
        completeTakeStock: '/cycleCountDetail/cycleCountDetail/completeTakeStock',
      },
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  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 !== undefined && this.record != null) {
          this.loadData(this.record)
        }
      }
    }
  },
  methods: {
    searchQuery2(){ 
      this.$refs.childRef.loadData(this.record,this.queryParam.code);
    },
    loadData(record) { 
      this.loading = true
      this.dataSource = []
      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 = "选择出库口";
    },
    loadDatas(cycleCountHeadId) {
      this.loading = true
      this.dataSource = []
      getAction(this.url.list, {
        cycleCountHeadId: cycleCountHeadId
      }).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
        }
      }).finally(() => {
        this.loading = false
      })
    },
    methodB(data) {
      let _this = this;
      _this.loadDatas(data);
    },
    initDictConfig() {
    },
    handleExpand(expanded, record) {
      this.expandedRowKeys = []
      if (expanded === true) {
        this.expandedRowKeys.push(record.id)
      }
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'cycleCountHeadId', text: '盘点主单id', dictCode: ''})
      fieldList.push({type: 'string', value: 'cycleCountHeadCode', text: '盘点主单code', dictCode: ''})
      fieldList.push({type: 'string', value: 'taskHeaderId', text: '任务表头', dictCode: ''})
      fieldList.push({type: 'string', value: 'taskDetailId', text: '任务明细头', dictCode: ''})
      fieldList.push({type: 'string', value: 'warehouseCode', text: '仓库', dictCode: ''})
      fieldList.push({type: 'string', value: 'companyCode', text: '货主', dictCode: ''})
      fieldList.push({type: 'string', value: 'inventoryDetailId', text: '库存明细头', dictCode: ''})
      fieldList.push({type: 'string', value: 'locationCode', text: '库位', dictCode: ''})
      fieldList.push({type: 'string', value: 'containerCode', text: '容器', dictCode: ''})
      fieldList.push({type: 'string', value: 'inventorySts', text: '库存状态', dictCode: ''})
      fieldList.push({type: 'string', value: 'systemQty', text: '系统数量', dictCode: ''})
      fieldList.push({type: 'string', value: 'countedQty', text: '实盘数量', dictCode: ''})
      fieldList.push({type: 'string', value: 'gapQty', text: '差异数量', dictCode: ''})
      fieldList.push({type: 'string', value: 'rejectionNote', text: '失败原因', dictCode: ''})
      fieldList.push({type: 'string', value: 'completedBy', text: '完成用户', dictCode: ''})
      fieldList.push({type: 'string', value: 'completedAt', text: '完成时间', dictCode: ''})
      fieldList.push({type: 'string', value: 'enableStatus', text: '盘点明细状态', dictCode: ''})
      this.superFieldList = fieldList
    },
    createMany(record) {
      this.$refs.cycleCountDetailChildModal.edit(record);
      this.$refs.cycleCountDetailChildModal.title = "实盘登记";
    },
    completeTakeStock(record) {
      this.loading = true
      getAction(this.url.completeTakeStock, {cycleCountDetailId: record.id}).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.$message.success(res.message);
          this.loadDatas(record.cycleCountHeadId);
          Utils.$emit("refreshCycleCountHeader");
        } else {
          this.$message.warning(res.message);
        }
      }).finally(() => {
        this.loading = false
      })
    },
    handleDelete: function (record) {
      if (!this.url.delete) {
        this.$message.error("请设置url.delete属性!")
        return
      }
      let that = this;
      deleteAction(that.url.delete, {id: record.id}).then((res) => {
        if (res.success) {
          //重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message);
          Utils.$emit('refreshCycleCountHeader');
        } else {
          that.$message.warning(res.message);
        }
      });
    },
    getStatusColor(status) {
      const colors = {
        '新建': 'green',
        '已登记': 'orange',
        '盘点完成': 'grey',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
</style>