zss
2024-03-01 2473f4ce35cda8dcd1194618c5d22c2e5b0354e3
Merge remote-tracking branch 'origin/master'
已修改2个文件
823 ■■■■■ 文件已修改
src/views/common/ztt-table.vue 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/plan/productionschedul/index.vue 771 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/common/ztt-table.vue
@@ -568,6 +568,11 @@
        return 'id'
      }
    },
    //需要合并的字段集合
    mergeSpanArr: {
        type: Array,
        default: []
    },
    toolbarMaxLength: {
      type: Number,
      default: 5,
@@ -928,22 +933,41 @@
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (this.options.tableCellMerge) {
        let result = ''
        this.$emit(
          'objectSpanMethod',
          row,
          column,
          rowIndex,
          columnIndex,
          (val) => {
            if (val) {
              result = val
        const propName = column.property
        if (propName) {
            if(this.mergeSpanArr.includes(propName)){
                if (rowIndex > 0 && row[propName] === this.tableData[rowIndex - 1][propName]) {
                    return { rowspan: 0, colspan: 0 };
                } else {
                    let rowspan = 1;
                    for (let i = rowIndex + 1; i < this.tableData.length; i++) {
                        if (this.tableData[i][propName] === row[propName]) {
                            rowspan++;
                        } else {
                            break;
                        }
                    }
                    return { rowspan: rowspan, colspan: 1 };
                }
            }
          }
        )
        if (result) {
          return result
        }
        // let result = ''
        // this.$emit(
        //   'objectSpanMethod',
        //   row,
        //   column,
        //   rowIndex,
        //   columnIndex,
        //   (val) => {
        //     console.log(val);
        //     if (val) {
        //       result = val
        //     }
        //   }
        // )
        // if (result) {
        //   return result
        // }
      }
    },
    getDataList(selectedId) {
src/views/plan/productionschedul/index.vue
@@ -1,87 +1,31 @@
<template>
  <div class="mod-config">
    <basic-container>
      <el-row>
        <el-col :span="24">
          <el-row style="padding:0px 10px;">
            <el-col :span="24" style="margin: 0;">
              <div style="display:flex;height:36px;justify-content: space-between;align-items:center;">
                <div>
                    <el-dropdown @command="changeTable">
                        <span :style="dropdownTitleStyle" class="el-dropdown-link">
                            {{dropdownTitle}}<i class="el-icon-arrow-down el-icon--right"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item command="undone">待完成调度</el-dropdown-item>
                            <el-dropdown-item command="done">已完成调度</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
                <div>
                  <el-button @click="tagFinished" v-if="showUnDownTable" size="mini" round type="success">标记已完成</el-button>
                  <el-button size="mini" round type="primary"
                  v-if="permissions.plan_productionschedul_edit_line && showUnDownTable"
                  @click="openEditDialog">编辑时间线</el-button>
                  <el-tooltip content="刷新">
                    <el-button circle icon="el-icon-refresh" @click="getDataList"></el-button>
                  </el-tooltip>
                </div>
              </div>
              <!-- 待完成调度表格 -->
              <avue-crud
              v-if="showUnDownTable"
              class="unfinished-crud"
              :data="tableData"
              ref="unfinished"
              :option="option"
              :span-method="spanMethod"
              @refresh-change="getDataList"
              @current-change="handleCurrentChange"
              @size-change="handleSizeChange"
              @cell-click="handleClickCell"
              :page="page"
              @selection-change="selectionRow"
              :table-loading="loading">
                <template slot="product" slot-scope="scope">
                    <el-link type="primary">{{ scope.row.product }}</el-link>
                </template>
                <template #menu="{ row, index }">
                    <el-button
                    v-if="permissions.plan_productionschedul_edit"
                    type="text"
                    icon="el-icon-edit"
                    size="small"
                    @click="editHandle(row, index)">编辑</el-button>
                    <el-button
                    v-if="permissions.plan_productionschedul_del"
                    type="text"
                    icon="el-icon-delete"
                    size="small"
                    @click="deleteHandle(row, index)">删除</el-button>
                </template>
              </avue-crud>
              <!-- 已完成调度表格 -->
              <avue-crud
              v-else
              class="finished-crud"
              :data="finishedTableData"
              ref="finished"
              :option="finishedOption"
              :span-method="spanMethod"
              @refresh-change="getFinishedData"
              @current-change="handleCurrentChange"
              @cell-click="handleClickCell"
              @size-change="handleSizeChange"
              :page="finishedPage"
              @selection-change="selectionFinishedRow">
                <template slot="product" slot-scope="scope">
                    <el-link type="primary">{{ scope.row.product }}</el-link>
                </template>
              </avue-crud>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <ttable
        :rowKey="'mid'"
        :table="table"
        :prelang="prelang"
        :options="options"
        @handleSelectionChange="selectionRow"
        :ajaxFun="ajaxFun"
        :paramObj="queryParams"
        :mergeSpanArr="spanArr"
        ref="ttable">
        <template #toolbar>
            <el-dropdown @command="changeTable">
                <span :style="dropdownTitleStyle" class="el-dropdown-link">
                    {{dropdownTitle}}<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item command="undone">待完成调度</el-dropdown-item>
                    <el-dropdown-item command="done">已完成调度</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
            <el-button v-if="showUnDownTable" @click="tagFinished" type="success">标记已完成</el-button>
            <el-button v-if="permissions.plan_productionschedul_edit_line && showUnDownTable"
            @click="openEditDialog" type="primary">编辑时间线</el-button>
        </template>
      </ttable>
    </basic-container>
    <!-- 编辑时间线 -->
    <el-dialog
@@ -172,7 +116,7 @@
                <el-timeline-item
                    placement="top"
                    :color="(item.actualTime) ? '#34BD66' :null"
                    :icon="(item.actualTime) ? 'el-icon-circle-check' :null"
                    :icon="(item.planTime || item.actualTime) ? 'el-icon-circle-check' :null"
                    v-for="(item, index) in scheduleList"
                    :key="index"
                    :timestamp="item.title">
@@ -205,9 +149,193 @@
} from '@/api//plan/productionschedul'
import ttable from '@/views/common/ztt-table.vue'
import { mapGetters } from 'vuex'
import { remote } from '@/api/admin/dict'
export default {
    data() {
    return {
      queryParams: {
        state: false
      },
      ajaxFun: fetchScheduleList,
      prelang: 'productSchedul',
      options: {
        height: 300, // 默认高度-为了表头固定
        stripe: true, // 是否为斑马纹 table
        highlightCurrentRow: false, // 是否要高亮当前行
        border: true, // 是否有纵向边框
        lazy: false, // 是否需要懒加载
        fit: true, // 列的宽度是否自撑开
        multiSelect: true, //
        seqNo: true,
        isRefresh: true, // 是否显示刷新按钮
        isShowHide: true, // 是否显示显影按钮H
        isSearch: true, // 高级查询按钮
        defaultOrderBy: { column: 'createdTime', direction: 'desc' },
        cancelRunCreated: false,
        tableCellMerge: true
      },
      table: {
        total: 0,
        currentPage: 1,
        pageSize: 20,
        data: [],
        // 标题
        column: [
            {
                minWidth: 120,
                prop: 'projectName',
                label: '项目名称',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            },
            {
                minWidth: 100,
                prop: 'contractNo',
                label: '合同号',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            },
            {
                minWidth: 120,
                prop: 'orderTime',
                label: '接单日期',
                sort: true,
                isTrue: true,
                isSearch: true,
                searchInfoType: 'date',
                format: (row,columnValue)=> this.formatDate(row,columnValue)
            },
            {
                minWidth: 120,
                prop: 'customerName',
                label: '客户名称',
                isTrue: true,
                searchInfoType: 'text',
                isSearch: true,
            },
            {
                minWidth: 120,
                prop: 'deliveryDate',
                label: '交货日期',
                isTrue: true,
                sort: true,
                isSearch: true,
                searchInfoType: 'date',
                format: (row,columnValue)=> this.formatDate(row,columnValue)
            },
            {
                minWidth: 120,
                prop: 'productType',
                label: '产品类型',
                isTrue: true,
                searchInfoType: 'text',
                isSearch: true,
            },
            {
                minWidth: 120,
                prop: 'product',
                label: '产品名',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
                render: { fun: this.handleClickCell }
            },
            {
                minWidth: 120,
                prop: 'status',
                label: '当前状态',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'select',
                optList: ()=>{
                    return [
                    { label: '文件签发', value: '文件签发' },
                    { label: '下达物料需求', value: '下达物料需求' },
                    { label: '采购询价+合同签订', value: '采购询价+合同签订' },
                    { label: '物料采购到货', value: '物料采购到货' },
                    { label: '物料到货检验', value: '物料到货检验' },
                    { label: '领料、装箱入库', value: '领料、装箱入库' },
                ]
                }
            },
            {
                minWidth: 120,
                prop: 'time',
                label: '临期时间',
                isTrue: true,
                sort: true,
                isSearch: true,
                searchInfoType: 'date',
                format: (row,columnValue)=> this.formatDate(row,columnValue)
            },
            {
                minWidth: 120,
                prop: 'specs',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
                label: '规格型号',
            },
            {
                minWidth: 120,
                prop: 'unit',
                label: '单位',
                searchInfoType: 'text',
                isTrue: true,
                isSearch: true,
            },
            {
                minWidth: 120,
                prop: 'number',
                label: '数量',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            },
            {
                minWidth: 120,
                prop: 'productionStatus',
                label: '生产情况',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            },
            {
                minWidth: 120,
                prop: 'productionRoutine',
                label: '生产程度',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            },
            {
                minWidth: 120,
                prop: 'projectLeader',
                label: '项目负责人',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            },
            {
                minWidth: 150,
                prop: 'remark',
                label: '备注',
                isTrue: true,
                isSearch: true,
                searchInfoType: 'text',
            }
        ],
        toolbar: [],
        operator: null,
        operatorConfig: {
            fixed: 'right',
            label: '操作',
            width: 100,
            minWidth: 100
        }
      },
      dropdownTitleStyle: {
        color: '#E84738',
        fontWeight: 'bold'
@@ -224,285 +352,9 @@
      dialogVisible: false,
      scheduleList: [],
      scheduleEditList: [],
      typeOptions: [],
      multipleSelection: [],
      loading: true,
      tableData: [],
      finishedTableData: [],
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
        pagerCount: 5
      },
      finishedPage: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
        pagerCount: 5
      },
      option: {
        defaultSort:{
          prop:'id',
          order:'descending'
        },
        height: 530,
        selection: true,
        columnBtn: false,
        index: true,
        indexFixed: false,
        selectionFixed: false,
        rowKey: 'mid',
        indexLabel: '序号',
        menuAlign: 'center',
        menuWidth: 130,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        border: true,
        align: 'center',
        column: [
          {
            minWidth: 120,
            prop: 'projectName',
            label: '项目名称',
            overHidden: true,
          },
          {
            minWidth: 100,
            prop: 'contractNo',
            label: '合同号',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'orderTime',
            label: '接单日期',
            overHidden: true,
            formatter: (row,columnValue)=> this.formatDate(row,columnValue)
          },
          {
            minWidth: 120,
            prop: 'customerName',
            label: '客户名称',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'deliveryDate',
            label: '交货日期',
            overHidden: true,
            formatter: (row,columnValue)=> this.formatDate(row,columnValue)
          },
          {
            minWidth: 120,
            prop: 'productType',
            label: '产品类型',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'product',
            label: '产品名',
            overHidden: true,
            slot: true
          },
          {
            minWidth: 120,
            prop: 'status',
            label: '当前状态',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'time',
            label: '临期时间',
            overHidden: true,
            formatter: (row,columnValue)=> this.formatDate(row,columnValue)
          },
          {
            minWidth: 120,
            prop: 'specs',
            label: '规格型号',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'unit',
            label: '单位',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'number',
            label: '数量',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'productionStatus',
            label: '生产情况',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'productionRoutine',
            label: '生产程度',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'projectLeader',
            label: '项目负责人',
            overHidden: true,
          },
          {
            minWidth: 150,
            prop: 'remark',
            label: '备注',
            overHidden: true,
          }
        ],
      },
      finishedOption: {
        refreshBtn: false, // 是否显示刷新按钮
        defaultSort:{
          prop:'id',
          order:'descending'
        },
        height: 230,
        selection: true,
        columnBtn: false,
        index: true,
        indexFixed: false,
        selectionFixed: false,
        rowKey: 'mid',
        indexLabel: '序号',
        menu: false,
        menuAlign: 'center',
        menuWidth: 130,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        border: true,
        align: 'center',
        column: [
          {
            minWidth: 120,
            prop: 'projectName',
            label: '项目名称',
            overHidden: true,
          },
          {
            minWidth: 100,
            prop: 'contractNo',
            label: '合同号',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'orderTime',
            label: '接单日期',
            overHidden: true,
            formatter: (row,columnValue)=> this.formatDate(row,columnValue)
          },
          {
            minWidth: 120,
            prop: 'customerName',
            label: '客户名称',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'deliveryDate',
            label: '交货日期',
            overHidden: true,
            formatter: (row,columnValue)=> this.formatDate(row,columnValue)
          },
          {
            minWidth: 120,
            prop: 'productType',
            label: '产品类型',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'product',
            label: '产品名',
            overHidden: true,
            slot: true
          },
          {
            minWidth: 120,
            prop: 'specs',
            label: '规格型号',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'unit',
            label: '单位',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'number',
            label: '数量',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'productionStatus',
            label: '生产情况',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'productionRoutine',
            label: '生产程度',
            overHidden: true,
          },
          {
            minWidth: 120,
            prop: 'projectLeader',
            label: '项目负责人',
            overHidden: true,
          },
          {
            minWidth: 150,
            prop: 'remark',
            label: '备注',
            overHidden: true,
          }
        ],
      },
      spanArr: [{
        prop: 'id',
        span: []
      },{
        prop: 'projectName',
        span: []
      }, {
        prop: 'contractNo',
        span: []
      },
      {
        prop: 'orderTime',
        span: []
      },
      {
        prop: 'customerName',
        span: []
      },
      {
        prop: 'deliveryDate',
        span: []
      },
      {
        prop: 'productType',
        span: []
      },
    ],
      spanArr: ['id','projectName', 'contractNo','orderTime','customerName','deliveryDate','productType'],
    }
  },
  components: {
@@ -512,19 +364,8 @@
    ...mapGetters(['permissions']),
  },
  created(){
    if(!this.permissions.plan_productionschedul_edit && !this.permissions.plan_productionschedul_del){
      this.option.menu = false
    }
    this.showOperator()
    this.loading = true
    this.getUnFinishedData()
    this.getFinishedData()
    this.getParamType()
    // this.rowSort()
    this.rowCalc()
  },
  beforeUpdate() {
    // this.rowSort()
    this.rowCalc()
  },
  watch:{
    editDialogVisible(newVal){
@@ -542,25 +383,73 @@
      }
    }
  },
  mounted() {},
  beforeDestroy() {},
  methods: {
    handleClickCell(row, column, cell, event){
        if(column.label === '产品名'){
            this.getScheduleById(row.mid)
            this.showTimeLineDialog = true
    getProductionSchedulStaffDict(){
        const _than = this
        remote('productionschedul_staff').then((response) => {
            if (response.status === 200) {
                response.data.data.map((ele)=>{
                    _than.productionSchedulStaffOptions.push(ele.value)
                })
            } else {
                _than.productionSchedulStaffOptions = []
            }
        })
    },
    showOperator(){
        if(this.showUnDownTable){
            if(this.permissions.plan_productionschedul_edit){
                this.table.operator = [{
                    text: '编辑',
                    type: 'text',
                    size: 'small',
                    fun: this.editHandle
                }]
            }
            if(this.permissions.plan_productionschedul_del){
                if(this.table.operator == null){
                    this.table.operator = [{
                        text: '删除',
                        type: 'text',
                        size: 'small',
                        fun: this.deleteHandle
                    }]
                }else{
                    this.table.operator.push({
                        text: '删除',
                        type: 'text',
                        size: 'small',
                        fun: this.deleteHandle
                    })
                }
            }
        }else{
            this.table.operator = null
        }
    },
    handleClickCell(row){
        this.getScheduleById(row.mid)
        this.showTimeLineDialog = true
    },
    changeTable(command){
        const _than = this
        if(command === 'undone'){
            this.dropdownTitle = '待完成调度'
            this.dropdownTitleStyle = {color:'#E84738',fontWeight: 'bold'}
            this.showUnDownTable = true
            this.queryParams.state = false
        }else if(command === 'done'){
            this.dropdownTitle = '已完成调度'
            this.dropdownTitleStyle = {color:'#34BD66',fontWeight: 'bold'}
            this.showUnDownTable = false
            this.table.operator = null
            this.queryParams.state = true
        }
        this.$nextTick(()=>{
            _than.showOperator()
            _than.getDataList()
        })
    },
    tagFinished(){
      if(this.multipleSelection.length < 1){
@@ -647,8 +536,8 @@
        }else{
            _than.$message.error("更新失败")
        }
        // _than.getScheduleById(orderObj.id)
        _than.dialogVisible = false
        _than.getDataList()
      }).catch(error=>{
        console.error(error);
      })
@@ -703,20 +592,6 @@
    },
    selectionRow(val){
      this.multipleSelection = val
    //   if(this.multipleSelection.length>0){
    //       this.getScheduleById(val[val.length-1].mid)
    //       this.showTimeLineDialog = true
    //   }
    },
    selectionFinishedRow(val){
      if (val.length > 1) {
        const preVal = val.shift();
        this.$refs.finished.toggleRowSelection(preVal, false);
      }
      else{
        this.scheduleList=[]
      }
      this.getScheduleById(val[0].mid)
    },
    formatDate(row, cellValue){
      if (cellValue) {
@@ -727,55 +602,9 @@
      }
      return ''
    },
    handleSizeChange(val){
      if(val){
        this.page.pageSize=val
        this.getUnFinishedData()
      }
    },
    handleCurrentChange(val){
      if(val){
        this.page.currentPage=val
        this.getUnFinishedData()
      }
    },
    // 获取数据列表
    getDataList(){
      this.getUnFinishedData()
      this.getFinishedData()
      this.$nextTick(()=>{
          this.rowCalc()
      })
    },
    getUnFinishedData() {
      this.loading = true
      let param = {
        size: this.page.pageSize,
        current: this.page.currentPage,
        state: false
      }
      fetchScheduleList(param).then((res) => {
        this.tableData = res.data.data.records
        this.page.total = res.data.data.total
        this.page.currentPage = res.data.data.records.pages
        this.scheduleList = []
      })
      this.loading = false
    },
    getFinishedData() {
      this.loading = true
      let param = {
        size: this.finishedPage.pageSize,
        current: this.finishedPage.currentPage,
        state: true
      }
      fetchScheduleList(param).then((res) => {
        this.finishedTableData = res.data.data.records
        this.finishedPage.total = res.data.data.total
        this.finishedPage.currentPage = res.data.data.records.pages
        this.scheduleList = []
      })
      this.loading = false
        this.$refs.ttable.getDataList()
    },
    // 删除
    deleteHandle(row,index) {
@@ -795,70 +624,6 @@
        })
      })
    },
    //动态合并方法
    rowCalc() {
      this.spanArr.forEach((ele, index) => {
        let parent
        if (index !== 0) parent = this.spanArr[ele.parent || index - 1].span
        ele.span = this.rowSpan(ele.prop, parent)
      })
    },
    rowSort() {
      let propList = this.spanArr.map(ele => ele.prop)
      this.spanArr.forEach((ele, index) => {
        let key = ele.prop
        this.tableData = this.tableData.sort((a, b) => {
          let flag = true;
          for (let i = 0; i < index; i++) {
            let prop = this.spanArr[i].prop
            flag = flag && a[prop] == b[prop]
          }
          if (flag) {
            if (a[key] < b[key]) { return 1; }
            else if (a[key] > b[key]) { return -1; }
            return 0;
          }
          return 0;
        })
      })
    },
    rowSpan(key, parent) {
      let list = [];
      let position = 0;
      this.tableData.forEach((item, index) => {
        if (index === 0) {
          list.push(1)
          let position = 0;
        } else {
          if (this.tableData[index][key] === this.tableData[index - 1][key]) {
            if (parent && parent[index] !== 0) {
              list.push(1)
              position = index
            } else {
              list[position] += 1;
              list.push(0)
            }
          } else {
            list.push(1)
            position = index
          }
        }
      })
      return list
    },
    spanMethod({ row, column, rowIndex, columnIndex }) {
      for (let i = 0; i < this.spanArr.length; i++) {
        const ele = this.spanArr[i]
        if (column.property == ele.prop) {
          const _row = ele.span[rowIndex];
          const _col = _row > 0 ? 1 : 0;
          return {
            rowspan: _row,
            colspan: _col
          }
        }
      }
    }
  }
}
</script>