WwCraftHeaderList.vue 11.6 KB
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <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="id">
              <a-input placeholder="请输入id" v-model="queryParam.id"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="供应商代码">
              <a-input placeholder="请输入供应商代码" v-model="queryParam.suppilerCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="供应商名称">
              <a-input placeholder="请输入供应商名称" v-model="queryParam.suppilerName"></a-input>
              <a-input placeholder="请输入供应商名称" v-model="queryParam.type" style="display:none"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="图号">
              <a-input placeholder="请输入图号" v-model.trim="queryParam.drawoNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="推送状态">
              <j-dict-select-tag v-model="queryParam.flag" placeholder="请选择"
                                 dictCode="tstatus"/>
            </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="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('委外头')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
                @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal"
                     @handleSuperQuery="handleSuperQuery"></j-super-query>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio'}"
        :customRow="clickThenSelect"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" 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 v-if="record.flag==0||record.flag==2" @click="handleEdit(record)">编辑</a>
          <a-divider v-if="record.flag==0||record.flag==2" type="vertical"/>
          <a v-if="record.flag==0||record.flag==2" @click="sendReceiptToT100(record)">推送t100</a>
          <a-divider v-if="record.flag==0||record.flag==2" type="vertical"/>
           <a v-if="record.flag==1" @click="sendWwDelToT100(record)">取消推送</a>
           <a-divider v-if="record.flag==1" type="vertical"/>
          <a-dropdown v-if="record.flag==0||record.flag==2">
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

        <span slot="flag" slot-scope="flag">
           <a-tag :key="flag" :color="solutionColor(flag)">
            {{ statusText(flag) }}
          </a-tag>
        </span>
      </a-table>
    </div>

    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="委外明细" key="1">
        <WwDetailList :mainId="selectedMainId" :flag="flag"/>
      </a-tab-pane>
    </a-tabs>

    <wwHeader-modal ref="modalForm" @ok="modalFormOk"></wwHeader-modal>
  </a-card>
</template>

<script>

import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import WwHeaderModal from './modules/WwHeaderModal'
import {getAction} from '@/api/manage'
import WwDetailList from './WwDetailList'
import '@/assets/less/TableExpand.less'
import {sendWwDel, sendWwReceipt} from "../../api/schedulerApi";

export default {
  name: "WwHeaderList",
  mixins: [JeecgListMixin],
  components: {
    WwDetailList,
    WwHeaderModal
  },
  data() {
    return {
      description: '委外审核(工艺)',
      queryParam: {
        type: "1", // 设置默认值为 0
      },
      // 表头
      columns: [
        {
          title: 'id',
          align: "center",
          dataIndex: 'id'
        },
        {
          title: '供应商代码',
          align: "center",
          dataIndex: 'suppilerCode'
        },
        {
          title: '供应商名称',
          align: "center",
          dataIndex: 'suppilerName'
        },
        {
          title: '是否推送',
          align: "center",
          dataIndex: 'flag',
          scopedSlots: {customRender: 'flag'},
        },
        {
          title: '创建人',
          align: "center",
          dataIndex: 'createBy'
        },
        {
          title: '操作时间',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '备注',
          align: "center",
          dataIndex: 'remark'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: 'action'},
        }
      ],
      url: {
        list: "/ww/wwHeader/list",
        delete: "/ww/wwHeader/delete",
        deleteBatch: "/ww/wwHeader/deleteBatch",
        exportXlsUrl: "/ww/wwHeader/exportXls",
        importExcelUrl: "ww/wwHeader/importExcel",
      },
      flag: 0,
      dictOptions: {},
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '50'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      selectedMainId: '',
      superFieldList: [],
    }
  },
  created() {

    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    initDictConfig() {
    },
    clickThenSelect(record) {
      return {
        on: {
          click: () => {
            this.flag = record.flag
            this.onSelectChange(record.id.split(","), [record]);
          }
        }
      }
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
      this.selectedMainId = ''
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedMainId = selectedRowKeys[0]
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    sendReceiptToT100(record) {
      record.flag = 3
      let params = {
        'id': record.id
      }
      sendWwReceipt(params).then((res) => {
        alert(JSON.stringify(res))
        this.loadData();
      })
    },
    statusText(value) {
      var actions = []
      if (value == '1') {
        actions.push('已推送')
      }
      if (value == '2') {
        actions.push('推送失败')
      }
      if (value == '0') {
        actions.push('未推送')
      }
      if (value == '3') {
        actions.push('推送中')
      }
      return actions.join('')
    },
    solutionColor(value) {
      var actions = ''
      if (value == '1') {
        actions = 'green'
      }
      if (value == '2') {
        actions = 'red'
      }
      if (value == '0') {
        actions = 'blue'
      }
      if (value == '3') {
        actions = 'RoyalBlue'
      }
      return actions
    },
    sendWwDelToT100(record) {
      record.flag = 3;
      let params = {
        'id': record.id
      }
      sendWwDel(params).then((res) => {
        alert(JSON.stringify(res))
        this.loadData();
      })
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      this.onClearSelected()
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total;
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false;
      })
    },
    searchReset() {
      this.queryParam.type = 1;
      this.queryParam.suppilerCode = '';
      this.queryParam.suppilerName = '';
      this.queryParam.drawoNo = '';
      this.queryParam.flag = '';
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'suppilerCode', text: '供应商代码', dictCode: ''})
      fieldList.push({type: 'string', value: 'suppilerName', text: '供应商名称', dictCode: ''})
      fieldList.push({type: 'BigDecimal', value: 'qty', text: '数量', dictCode: ''})
      fieldList.push({type: 'int', value: 'flag', text: '是否推送', dictCode: 'yn'})
      fieldList.push({type: 'int', value: 'type', text: '新老数据(0:老,1新)', dictCode: ''})
      fieldList.push({type: 'string', value: 'remark', text: '备注', dictCode: ''})
      this.superFieldList = fieldList
    },

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>