chenlu
2024-03-12 855f1ab0148cbfc26bc365a8c46ab8b7d427c01e
north-glass-erp/northglass-erp/src/views/pp/processCard/ProductionScheduling.vue
@@ -12,7 +12,9 @@
import BasicTable from '@/components/basic/BasicTable.vue'
import {VXETable} from "vxe-table";
import useUserInfoStore from "@/stores/userInfo";
import {changeFilterEvent,filterChanged} from "@/hook"
import {changeFilterEvent, filterChanged} from "@/hook"
import {addListener,toolbarButtonClickEvent} from "@/hook/mouseMove";
let router = useRouter()
const userStore = useUserInfoStore()
@@ -32,8 +34,9 @@
  }
}
//工序
const value = ref('')
const value = ref('切割')
//排产状态
@@ -119,21 +122,32 @@
  return [start, end]
}
onMounted(()=>{
  //启用表格拖动选中
  addListener(xGrid.value,gridOptions)
})
//第一次加载获取近七天时间和默认状态
form.date1 = getNowTime()
let startTime = form.date1[0]
let endTime = form.date1[1]
let selectProcesses = value.value
let inputVal = form.orderId
if (inputVal == '') {
  inputVal = null
}
if (selectProcesses == '') {
  selectProcesses = null
}
//第一次加载数据
request.post(`/productionScheduling/selectLastScheduling/${startTime}/${endTime}`, filterData.value).then((res) => {
request.post(`/productionScheduling/selectLastScheduling/${startTime}/${endTime}/${selectProcesses}/${inputVal}`, filterData.value).then((res) => {
  if (res.code == 200) {
    pageTotal.value = res.data.total
    produceList = produceList.value.concat(deepClone(res.data.data))
    titleSelectJson.value.processType=res.data.process
    titleSelectJson.value.processType = res.data.process
    xGrid.value.reloadData(produceList)
    gridOptions.loading = false
    console.log(res.data)
    //禁用删除、保存按钮
    gridOptions.toolbarConfig.buttons[0].disabled = true
    gridOptions.toolbarConfig.buttons[1].disabled = true
@@ -157,13 +171,13 @@
  }
  if (inputVal == null && selectState == 1) {
    //根据时间查询未排产数据
    request.post(`/productionScheduling/selectLastScheduling/${startTime}/${endTime}`, filterData.value).then((res) => {
    request.post(`/productionScheduling/selectLastScheduling/${startTime}/${endTime}/${selectProcesses}/${inputVal}`, filterData.value).then((res) => {
      if (res.code == 200) {
        pageTotal.value = res.data.total
        xGrid.value.loadData(res.data.data)
        gridOptions.loading = false
        //禁用删除、保存按钮
        //禁用删除、审核按钮
        gridOptions.toolbarConfig.buttons[0].disabled = true
        gridOptions.toolbarConfig.buttons[1].disabled = true
        //启用保存
@@ -172,16 +186,14 @@
        ElMessage.warning(res.msg)
      }
    })
  } else
    if (inputVal != null && selectState == 1) {
  } else if (inputVal != null && selectState == 1) {
    //根据工序查询未排产数据
    request.post(`/productionScheduling/selectScheduling/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
      if (res.code == 200) {
        pageTotal.value = res.data.total
        xGrid.value.loadData(res.data.data)
        gridOptions.loading = false
        //禁用删除、保存按钮
        //禁用删除、审核按钮
        gridOptions.toolbarConfig.buttons[0].disabled = true
        gridOptions.toolbarConfig.buttons[1].disabled = true
        //启用保存
@@ -192,13 +204,12 @@
    })
  } else if (inputVal == null && selectState == 2) {
    //根据时间查询已排产数据
    console.log(startTime, endTime, selectProcesses, selectState)
    request.post(`/productionScheduling/selectScheduling/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
      if (res.code == 200) {
        pageTotal.value = res.data.total
        xGrid.value.loadData(res.data.data)
        gridOptions.loading = false
        //启用删除、保存按钮
        //启用删除、审核按钮
        gridOptions.toolbarConfig.buttons[0].disabled = false
        gridOptions.toolbarConfig.buttons[1].disabled = false
        //禁用保存
@@ -214,7 +225,7 @@
        pageTotal.value = res.data.total
        xGrid.value.loadData(res.data.data)
        gridOptions.loading = false
        //启用删除、保存按钮
        //启用删除、审核按钮
        gridOptions.toolbarConfig.buttons[0].disabled = false
        gridOptions.toolbarConfig.buttons[1].disabled = false
        //禁用保存
@@ -228,6 +239,12 @@
}
/*后端返回结果多层嵌套展示*/
const hasDecimal = (value) => {
  const regex = /\./; // 定义正则表达式,查找小数点
  return regex.test(value); // 返回true/false
}
//子组件接收参数
const xGrid = ref()
@@ -236,7 +253,7 @@
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 50},//鼠标移动或选择高亮
  rowConfig: {isCurrent: true, isHover: true, height: 30},//鼠标移动或选择高亮
  id: 'CustomerList',
  showFooter: true,//显示脚
  printConfig: {},
@@ -249,16 +266,29 @@
    useKey: true
  },
  filterConfig: {   //筛选配置项
    // remote: true
                    // remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },//表头参数
  },
  menuConfig: {
    body: {
      options: [
        [
          { code: 'copyChecked', name: '选中相同', prefixIcon: 'vxe-icon-copy', visible: true, disabled: false },
          { code: 'copyAll', name: '之后相同', prefixIcon: 'vxe-icon-feedback', visible: true, disabled: false },
          { code: 'clearChecked', name: '清除选中', prefixIcon: 'vxe-icon-indicator', visible: true, disabled: false },
        ]
      ]
    }
  },
  //表头参数
  columns: [
    {type: 'expand', fixed: "left", slots: {content: 'content'}, width: 50},
    {type: 'checkbox', fixed: "left", title: '选择', width: 80},
@@ -276,13 +306,62 @@
      title: '计划结束时间'
    },
    // {field: '排产编号', title: '排产编号',  width: 120 },
    {field: 'order_id', title: '销售单号', filters: [{data: ''}], slots: {filter: 'num1_filter'}, width: 100,filterMethod:filterChanged},
    {field: 'customer_name', title: '客户名称', width: 110, filters: [{data: ''}], slots: {filter: 'num1_filter'},filterMethod:filterChanged},
    {field: 'project', title: '项目名称', width: 100, filters: [{data: ''}], slots: {filter: 'num1_filter'},filterMethod:filterChanged},
    {field: 'order_number', title: '序号', filters: [{data: ''}], slots: {filter: 'num1_filter'}, width: 70,filterMethod:filterChanged},
    {field: 'width', title: '宽', width: 60,filters: [{data: ''}],slots: {filter: 'num1_filter'},filterMethod:filterChanged},
    {field: 'height', title: '高', width: 60,filters: [{data: ''}],slots: {filter: 'num1_filter'},filterMethod:filterChanged},
    {
      field: 'order_id',
      title: '销售单号',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      width: 100,
      filterMethod: filterChanged
    },
    {
      field: 'customer_name',
      title: '客户名称',
      width: 110,
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'project',
      title: '项目名称',
      width: 100,
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'order_number',
      title: '序号',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      width: 70,
      filterMethod: filterChanged
    },
    {
      field: 'technology_number',
      title: '小片顺序',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      width: 70,
      filterMethod: filterChanged
    },
    {
      field: 'child_width',
      title: '宽',
      width: 60,
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'child_height',
      title: '高',
      width: 60,
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {field: 'quantity', title: '订单数量', width: 70},
    {field: 'area', title: '订单面积', width: 90},
    {
@@ -298,10 +377,10 @@
    {field: 'productionScheduledArea', title: '已排产面积', width: 120},
    {field: 'review_status', title: '审核状态', width: 140},
    {field: 'reviewer', title: '审核人', width: 140},
    {field: 'product_name', title: '产品名称', width: 140},
    {field: 'glass_child', title: '产品名称', width: 140},
    {field: 'shape', title: '形状', width: 80},
    {field: 'notes', title: '备注', editRender: {name: 'input', attrs: {placeholder: ''}}, width: 120},
    {field: 'scheduling_id', title: '排产编号',width: 120},
    {field: 'scheduling_id', title: '排产编号', width: 120},
  ],//表头按钮
  toolbarConfig: {
@@ -335,9 +414,7 @@
})
//删除
//表格按钮
const gridEvents = {
  async toolbarButtonClick({code}) {
    const $grid = xGrid.value
@@ -372,12 +449,21 @@
              processes: selectProcesses,//工序
              userName: username//审核人
            })
            //禁用保存
            gridOptions.toolbarConfig.buttons[2].disabled = true
            //保存排产数据
            request.post("/productionScheduling/addScheduling", schedulingData.value).then((res) => {
              if (res.code == 200) {
                ElMessage.success("保存成功")
                location.reload();
                // 启用保存
                gridOptions.toolbarConfig.buttons[2].disabled = false
                router.push({
                  path: '/main/processCard/ProductionScheduling',
                  query: { random: Math.random()}
                })
              } else {
                // 启用保存
                gridOptions.toolbarConfig.buttons[2].disabled = false
                ElMessage.warning(res.msg)
              }
@@ -402,7 +488,7 @@
                scheduling: selectRecords,
              })
              request.post("/productionScheduling/deleteScheduling",schedulingData.value).then((res) => {
              request.post("/productionScheduling/deleteScheduling", schedulingData.value).then((res) => {
                if (res.code == 200) {
                  ElMessage.success("删除成功")
                  location.reload();
@@ -427,7 +513,7 @@
              scheduling: selectRecords,
              userName: username//审核人
            })
            request.post("/productionScheduling/examineScheduling",schedulingData.value).then((res) => {
            request.post("/productionScheduling/examineScheduling", schedulingData.value).then((res) => {
              if (res.code == 200) {
                ElMessage.success("审核成功")
                location.reload();
@@ -443,15 +529,63 @@
      }
    }
  },
  menuClick ({ menu, row, column }) {
    const $grid = xGrid.value
    if ($grid) {
      switch (menu.code) {
        case 'copyChecked' :{
          let result = toolbarButtonClickEvent()
          if(result){
            const dataList = xGrid.value.getTableData().visibleData
            const val = dataList[result.start][result.cell]
            dataList.forEach((item,index) =>{
              if(index>=result.start && index<=result.end){
                item[result.cell] = val
              }
            })
          }
          gridOptions.menuConfig.body.options[0][5].disabled=false
          break
        }
        case 'copyAll' :{
          let result = toolbarButtonClickEvent()
          if(result){
            const dataList = xGrid.value.getTableData().visibleData
            const val = dataList[result.start][result.cell]
            dataList.forEach((item,index) =>{
              if(index>=result.start ){
                item[result.cell] = val
              }
            })
          }
          gridOptions.menuConfig.body.options[0][5].disabled=false
          break
        }
        case 'clearChecked' :{
          let result = toolbarButtonClickEvent()
          if(result){
            const dataList = xGrid.value.getTableData().visibleData
            dataList.forEach((item,index) =>{
              if(index>=result.start && index<=result.end){
                item[result.cell] = ''
              }
            })
          }
          gridOptions.menuConfig.body.options[0][5].disabled=false
          break
        }
      }
    }
  },
}
const determineNum = () => {
  const $grid = xGrid.value
  const table = $grid.getTableData().fullData
  const selectRecords = $grid.getCheckboxRecords()
  let selectState = stateValue.value
  table.forEach((selectRecords) => {
    if (selectRecords.scheduling_quantity > selectRecords.pendingProductionQuantity) {
    if (selectRecords.scheduling_quantity > selectRecords.pendingProductionQuantity && selectState==1) {
      ElMessage.warning("排产数量不能大于待排产数量")
      //禁用保存按钮
      //gridOptions.toolbarConfig.buttons[2].disabled = true
@@ -460,8 +594,6 @@
  })
}
</script>
@@ -481,9 +613,9 @@
        />
        &nbsp;&nbsp;
        <el-input v-model="form.orderId" placeholder="销售单号" clearable style="width: 110px"></el-input>
        <el-input v-model="form.orderId" clearable placeholder="销售单号" style="width: 110px"></el-input>
        &nbsp;
        <el-select v-model="value" clearable placeholder="请选择工序" style="width: 120px">
        <el-select v-model="value" clearable default-value="default_city" style="width: 120px">
          <el-option
              v-for="item in titleSelectJson['processType']"
              :key="item.id"
@@ -512,8 +644,8 @@
    <vxe-grid
        ref="xGrid"
        class="mytable-scrollbar"
        max-height="100%"
        height="100%"
        max-height="100%"
        v-bind="gridOptions"
        v-on="gridEvents"
        @filter-change="filterChanged"
@@ -542,6 +674,11 @@
    </vxe-grid>
  </div>
  <div class="vxe-table--cell-area" ref="cellArea" >
    <span  class="vxe-table--cell-main-area"  ></span>
    <span class="vxe-table--cell-active-area"  ></span>
  </div>
</template>
<style scoped>
@@ -555,4 +692,11 @@
  height: 6%;
  text-align: center;
}
.vxe-grid {
  /* 禁用浏览器默认选中 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
</style>