qushaowei
2024-01-11 240c74ffb2b98faddf76648116ca9eeb61ee2cde
src/views/eam/ABC/StreamList.vue
@@ -1,16 +1,20 @@
<template>
  <a-card :bordered="false">
  <a-card
    title='ABC评分'
    :bordered="false"
  >
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
      <a-form
        layout="inline"
        @keyup.enter.native="searchQuery"
      >
        <a-row :gutter="24">
          <a-col
          :span="6"
          >
            <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="单据号"
          <a-col :span="6">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="单据号"
            >
              <a-input
                placeholder="请输入单据号查询"
@@ -34,7 +38,12 @@
        @click="searchReset"
        icon="reload"
      >重置</a-button>
      <a-button @click="handleAdd" type="primary" icon="plus" v-if="nodeSort===1">新增</a-button>
      <a-button
        @click="handleAdd"
        type="primary"
        icon="plus"
        v-if="nodeSort===1"
      >新增</a-button>
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('设备ABC评价')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
@@ -45,9 +54,15 @@
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
      <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>
        <a
          style="margin-left: 24px"
          @click="onClearSelected"
        >清空</a>
      </div>
      <a-table
@@ -56,300 +71,350 @@
        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">
        @change="handleTableChange"
      >
        <!-- :scroll="{x:true}" -->
        <template slot="htmlSlot" slot-scope="text">
        <template
          slot="htmlSlot"
          slot-scope="text"
        >
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        <template
          slot="imgSlot"
          slot-scope="text,record"
        >
          <span
            v-if="!text"
            style="font-size: 12px;font-style: italic;"
          >无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            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>
        <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)">
            @click="downloadFile(text)"
          >
            下载
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
        <span
          slot="action"
          slot-scope="text, record"
        >
          <div v-if="nodeValue===record.status">
            <a @click="handleStreamNext(record)" :disabled="nodeSort===1&&nodeValue!==record.status" v-if="button1!={}">{{button1.name}}</a>
          <a-divider type="vertical" v-if="button2!={}"/>
            <a @click="handleStreamLast(record)" :disabled="nodeSort===1" v-if="button2!={}" >{{button2.name}}</a>
         </div>
         <div v-if="nodeSort===1&&nodeValue===record.status">
          <a-divider type="vertical" />
          <a-dropdown>
            <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-item>
                <a @click="handleEdit(record)">编辑</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
         </div>
            <a
              @click="handleStreamNext(record)"
              :disabled="nodeSort===1&&nodeValue!==record.status"
              v-if="button1!={}"
            >{{button1.name}}</a>
            <a-divider
              type="vertical"
              v-if="button2!={}"
            />
            <a
              @click="handleStreamLast(record)"
              :disabled="nodeSort===1"
              v-if="button2!={}"
            >{{button2.name}}</a>
          </div>
          <div v-if="nodeSort===1&&nodeValue===record.status">
            <a-divider type="vertical" />
            <a-dropdown>
              <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-item>
                  <a @click="handleEdit(record)">编辑</a>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
          </div>
        </span>
      </a-table>
    </div>
    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="操作记录" key="1" >
      <a-tab-pane
        tab="操作记录"
        key="1"
      >
        <StreamOperationList :mainId="streamOperationMainId" />
      </a-tab-pane>
      <a-tab-pane tab="ABC评分" key="2" forceRender>
      <a-tab-pane
        tab="ABC评分"
        key="2"
        forceRender
      >
        <ABCAssessmentList :mainId="aBCAssessmentMainId" />
      </a-tab-pane>
    </a-tabs>
    <stream-modal ref="modalForm" @ok="modalFormOk"></stream-modal>
    <node-model ref="nodeModel" @ok="modalFormOk"></node-model>
    <stream-modal
      ref="modalForm"
      @ok="modalFormOk"
    ></stream-modal>
    <node-model
      ref="nodeModel"
      @ok="modalFormOk"
    ></node-model>
  </a-card>
</template>
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import StreamModal from './modules/StreamModal'
  import { getAction } from '@/api/manage'
  import StreamOperationList from './StreamOperationList'
  import ABCAssessmentList from './ABCAssessmentList'
  import '@/assets/less/TableExpand.less'
  import NodeModel from './modules/NodeModel.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import StreamModal from './modules/StreamModal'
import { getAction } from '@/api/manage'
import StreamOperationList from './StreamOperationList'
import ABCAssessmentList from './ABCAssessmentList'
import '@/assets/less/TableExpand.less'
import NodeModel from './modules/NodeModel.vue'
  export default {
    name: "StreamList",
    mixins:[JeecgListMixin],
    components: {
      StreamOperationList,
      ABCAssessmentList,
      StreamModal,
        NodeModel
export default {
  name: "StreamList",
  mixins: [JeecgListMixin],
  components: {
    StreamOperationList,
    ABCAssessmentList,
    StreamModal,
    NodeModel
  },
  data() {
    return {
      description: '设备ABC评价管理页面',
      // 表头
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '单据号',
          align: "center",
          dataIndex: 'num',
        },
        {
          title: '当前节点',
          align: "center",
          dataIndex: 'status_dictText',
        },
        {
          title: '单据类型',
          align: "center",
          dataIndex: 'type_dictText',
        },
        {
          title: '发起时间',
          align: "center",
          dataIndex: 'createTime',
        },
        // width: 300
        {
          title: '发起人',
          align: "center",
          dataIndex: 'createBy_dictText'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: { customRender: 'action' },
        }
        // fixed: "right",
      ],
      url: {
        list: "/eam/stream/list",
        delete: "/eam/stream/delete",
        deleteBatch: "/eam/stream/deleteBatch",
        exportXlsUrl: "/eam/stream/exportXls",
        importExcelUrl: "eam/stream/importExcel",
        getPreInfo: "eam/stream/getPreInfo"
      },
      dictOptions: {
      },
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 20,
        pageSizeOptions: ['5', '10', '20', '50'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      selectedMainId: '',
      superFieldList: [],
      streamOperationMainId: '',
      aBCAssessmentMainId: '',
      button1: {},
      button2: {},
      nodeSort: 0,
      nodeValue: ''
    }
  },
  created() {
    this.getSuperFieldList();
  },
  mounted() {
    this.getPreInfo();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    initDictConfig() {
    },
    data () {
    clickThenSelect(record) {
      return {
        description: '设备ABC评价管理页面',
        // 表头
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
          wrapperCol: {
            xs: { span: 24 },
            sm: { span: 16 },
        },
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'单据号',
            align:"center",
            dataIndex: 'num',
            width:400
          },
          {
            title:'当前节点',
            align:"center",
            dataIndex: 'status_dictText',
            width:300
          },
          {
            title:'单据类型',
            align:"center",
            dataIndex: 'type_dictText',
            width:300
          },
          {
            title:'发起时间',
            align:"center",
            dataIndex: 'createTime',
            width:300
          },
          {
            title:'发起人',
            align:"center",
            dataIndex: 'createBy_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:200,
            scopedSlots: { customRender: 'action' },
        on: {
          click: () => {
            this.onSelectChange(record.id.split(","), [record]);
          }
        ],
        url: {
          list: "/eam/stream/list",
          delete: "/eam/stream/delete",
          deleteBatch: "/eam/stream/deleteBatch",
          exportXlsUrl: "/eam/stream/exportXls",
          importExcelUrl: "eam/stream/importExcel",
          getPreInfo:"eam/stream/getPreInfo"
        },
        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:[],
        streamOperationMainId: '',
        aBCAssessmentMainId: '',
        button1:{},
        button2:{},
        nodeSort:0,
        nodeValue:''
        }
      }
    },
    created() {
      this.getSuperFieldList();
    },
    mounted(){
      this.getPreInfo();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    handleStreamNext(record) {
      var step = {
        name: this.button1.name,
        value: this.button1.value,
        opType: 'next',
        nodeSort: this.nodeSort,
        node: this.nodeValue,
        streamId: record.id
      }
      this.$refs.nodeModel.title = this.button1.name + "操作";
      this.$refs.nodeModel.edit(step);
    },
    methods: {
      initDictConfig(){
      },
      clickThenSelect(record) {
        return {
          on: {
            click: () => {
              this.onSelectChange(record.id.split(","), [record]);
            }
          }
        }
      },
      handleStreamNext(record){
        var step = {
          name:this.button1.name,
          value:this.button1.value,
          opType:'next',
          nodeSort:this.nodeSort,
          node:this.nodeValue,
          streamId:record.id
        }
        this.$refs.nodeModel.title = this.button1.name+"操作";
        this.$refs.nodeModel.edit(step);
      },
      handleStreamLast(record){
        var step = {
          name:this.button2.name,
          value:this.button2.value,
          opType:'last',
          nodeSort:this.nodeSort,
          node:this.nodeValue,
          streamId:record.id
        }
        this.$refs.nodeModel.title = this.button2.name+"操作";
        this.$refs.nodeModel.edit(step);
      },
      onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
        this.selectedMainId=''
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        if(selectedRowKeys.length===1){
          this.selectedMainId=selectedRowKeys[0]
          this.streamOperationMainId = selectionRows[0]['id']
          this.aBCAssessmentMainId = selectionRows[0]['id']
        }else{
          this.selectedMainId=''
          this.streamOperationMainId = ''
          this.aBCAssessmentMainId = ''
        }
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
      },
      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;
        })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'num',text:'num',dictCode:''})
        fieldList.push({type:'string',value:'status',text:'status',dictCode:''})
        fieldList.push({type:'string',value:'type',text:'单据类型',dictCode:''})
        this.superFieldList = fieldList
      },
      getPreInfo(){
        getAction(this.url.getPreInfo).then(res=>{
            if(res.result.msg==='ok'){
              this.button1 = res.result.buttons[0];
              if(res.result.buttons.length===2){
                this.button2 = res.result.buttons[1];
              }
              this.nodeSort = res.result.nodeSort;
              this.nodeValue = res.result.nodeValue;
            }
        })
    handleStreamLast(record) {
      var step = {
        name: this.button2.name,
        value: this.button2.value,
        opType: 'last',
        nodeSort: this.nodeSort,
        node: this.nodeValue,
        streamId: record.id
      }
      this.$refs.nodeModel.title = this.button2.name + "操作";
      this.$refs.nodeModel.edit(step);
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
      this.selectedMainId = ''
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      if (selectedRowKeys.length === 1) {
        this.selectedMainId = selectedRowKeys[0]
        this.streamOperationMainId = selectionRows[0]['id']
        this.aBCAssessmentMainId = selectionRows[0]['id']
      } else {
        this.selectedMainId = ''
        this.streamOperationMainId = ''
        this.aBCAssessmentMainId = ''
      }
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    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;
      })
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'num', text: 'num', dictCode: '' })
      fieldList.push({ type: 'string', value: 'status', text: 'status', dictCode: '' })
      fieldList.push({ type: 'string', value: 'type', text: '单据类型', dictCode: '' })
      this.superFieldList = fieldList
    },
    getPreInfo() {
      getAction(this.url.getPreInfo).then(res => {
        if (res.result.msg === 'ok') {
          this.button1 = res.result.buttons[0];
          if (res.result.buttons.length === 2) {
            this.button2 = res.result.buttons[1];
          }
          this.nodeSort = res.result.nodeSort;
          this.nodeValue = res.result.nodeValue;
        }
      })
    }
  }
}
</script>
<style scoped>
  @import '~@assets/less/common.less'
@import '~@assets/less/common.less';
</style>