Просмотр исходного кода

派单增加时间计算规则

jingshuyong 11 месяцев назад
Родитель
Сommit
e06e0618bb

+ 18 - 5
src/views/workOrder/components/releaseDialog.vue

@@ -409,8 +409,8 @@
 </template>
 
 <script>
-import releaseMixin from '../mixins/release'; 
-
+  import releaseMixin from '../mixins/release';
+  import { parameterGetByCode } from '@/api/mainData/index';
   export default {
     components: {},
     props: {
@@ -423,7 +423,7 @@ import releaseMixin from '../mixins/release';
         default: false
       }
     },
-    mixins:[releaseMixin],
+    mixins: [releaseMixin],
     data() {
       return {
         processId: '',
@@ -470,7 +470,8 @@ import releaseMixin from '../mixins/release';
         orderDis: false, // 生产订单派单
         singleDis: false, // 单个报工
         batchDis: false, // 批量报工
-        isDispatchRow: {}
+        isDispatchRow: {}, // 查询是否派单数据
+        time_calc_code: '0' // 是否进行时间赋值 0 否 1 是
       };
     },
     computed: {
@@ -611,13 +612,25 @@ import releaseMixin from '../mixins/release';
     },
     watch: {},
     created() {
+      // 时间计算规则code
+      this.getCode();
       this.workCenterData(); // 查询工作中心
       this.getClassesData(); // 查询班次
       this.queryCheckExists(); // 查询是否派单
       this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
       this.dateValue = this.getFormattedDate();
     },
-    methods: {}
+    methods: {
+      getCode() {
+        parameterGetByCode({
+          code: 'time_calculation_rules'
+        }).then((res) => {
+          if (res) {
+            this.time_calc_code = res.value || '0';
+          }
+        });
+      }
+    }
   };
 </script>
 

+ 604 - 597
src/views/workOrder/index.vue

@@ -44,8 +44,8 @@
             type="primary"
             v-if="$hasPermission('aps:batchReleaseWorkOrder:release')"
             @click="batchDispatch"
-          >批量派单
-        <!--  -->
+            >批量派单
+            <!--  -->
           </el-button>
         </template>
         <template v-slot:selection="{ row }">
@@ -153,101 +153,101 @@
         </template>
       </ele-pro-table>
     </el-card>
-<!--    <el-dialog :visible.sync="visible" title="派单" width="500px">-->
-<!--      <el-form-->
-<!--        ref="form"-->
-<!--        :model="form"-->
-<!--        :rules="rules"-->
-<!--        label-position="left"-->
-<!--        label-width="100px"-->
-<!--      >-->
-<!--        <el-form-item label="报工类型:" prop="singleReport">-->
-<!--          <el-radio-group v-model="form.singleReport">-->
-<!--            <el-radio v-if="clientEnvironmentId != 2" :label="1"-->
-<!--            >单件报工-->
-<!--            </el-radio>-->
-<!--            <el-radio :label="0">批量报工</el-radio>-->
-<!--          </el-radio-group>-->
-<!--        </el-form-item>-->
-
-<!--        <el-form-item label="指定:" prop="assignType">-->
-<!--          <el-radio-group-->
-<!--            v-model="form.assignType"-->
-<!--            size="mini"-->
-<!--            @change="assignTypeFn"-->
-<!--          >-->
-<!--            <el-radio-button :label="1">工位</el-radio-button>-->
-<!--            <el-radio-button :label="2">人员</el-radio-button>-->
-<!--          </el-radio-group>-->
-<!--        </el-form-item>-->
-
-<!--        <el-form-item label="班组:" prop="teamId">-->
-<!--          <el-select-->
-<!--            v-model="form.teamId"-->
-<!--            class="ele-block"-->
-<!--            filterable-->
-<!--            placeholder="请选择班组"-->
-<!--            size="mini"-->
-<!--            @change="stationChange"-->
-<!--          >-->
-<!--            <el-option-->
-<!--              v-for="item in teamsList"-->
-<!--              :key="item.id"-->
-<!--              :label="item.name + '(' + item.code + ')'"-->
-<!--              :value="item.id"-->
-<!--            >-->
-<!--            </el-option>-->
-<!--          </el-select>-->
-<!--        </el-form-item>-->
-
-<!--        <el-form-item-->
-<!--          v-if="form.assignType == 1"-->
-<!--          label="工位:"-->
-<!--          prop="workstationIds"-->
-<!--        >-->
-<!--          <el-select-->
-<!--            v-model="form.workstationIds"-->
-<!--            class="ele-block"-->
-<!--            filterable-->
-<!--            multiple-->
-<!--            placeholder="请选择工位"-->
-<!--            size="mini"-->
-<!--          >-->
-<!--            <el-option-->
-<!--              v-for="item in stationList"-->
-<!--              :key="item.id"-->
-<!--              :label="item.name + '(' + item.code + ')'"-->
-<!--              :value="item.id"-->
-<!--            >-->
-<!--            </el-option>-->
-<!--          </el-select>-->
-<!--        </el-form-item>-->
-
-<!--        <el-form-item v-if="form.assignType == 2" label="人员:" prop="crewIds">-->
-<!--          <el-select-->
-<!--            v-model="form.crewIds"-->
-<!--            class="ele-block"-->
-<!--            filterable-->
-<!--            multiple-->
-<!--            placeholder="请选择人员"-->
-<!--            size="mini"-->
-<!--          >-->
-<!--            <el-option-->
-<!--              v-for="item in crewList"-->
-<!--              :key="item.id"-->
-<!--              :label="item.name"-->
-<!--              :value="item.id"-->
-<!--            >-->
-<!--            </el-option>-->
-<!--          </el-select>-->
-<!--        </el-form-item>-->
-<!--      </el-form>-->
-
-<!--      <div slot="footer" class="footer">-->
-<!--        <el-button @click="close">取消</el-button>-->
-<!--        <el-button v-click-once type="primary" @click="confirm">确定</el-button>-->
-<!--      </div>-->
-<!--    </el-dialog>-->
+    <!--    <el-dialog :visible.sync="visible" title="派单" width="500px">-->
+    <!--      <el-form-->
+    <!--        ref="form"-->
+    <!--        :model="form"-->
+    <!--        :rules="rules"-->
+    <!--        label-position="left"-->
+    <!--        label-width="100px"-->
+    <!--      >-->
+    <!--        <el-form-item label="报工类型:" prop="singleReport">-->
+    <!--          <el-radio-group v-model="form.singleReport">-->
+    <!--            <el-radio v-if="clientEnvironmentId != 2" :label="1"-->
+    <!--            >单件报工-->
+    <!--            </el-radio>-->
+    <!--            <el-radio :label="0">批量报工</el-radio>-->
+    <!--          </el-radio-group>-->
+    <!--        </el-form-item>-->
+
+    <!--        <el-form-item label="指定:" prop="assignType">-->
+    <!--          <el-radio-group-->
+    <!--            v-model="form.assignType"-->
+    <!--            size="mini"-->
+    <!--            @change="assignTypeFn"-->
+    <!--          >-->
+    <!--            <el-radio-button :label="1">工位</el-radio-button>-->
+    <!--            <el-radio-button :label="2">人员</el-radio-button>-->
+    <!--          </el-radio-group>-->
+    <!--        </el-form-item>-->
+
+    <!--        <el-form-item label="班组:" prop="teamId">-->
+    <!--          <el-select-->
+    <!--            v-model="form.teamId"-->
+    <!--            class="ele-block"-->
+    <!--            filterable-->
+    <!--            placeholder="请选择班组"-->
+    <!--            size="mini"-->
+    <!--            @change="stationChange"-->
+    <!--          >-->
+    <!--            <el-option-->
+    <!--              v-for="item in teamsList"-->
+    <!--              :key="item.id"-->
+    <!--              :label="item.name + '(' + item.code + ')'"-->
+    <!--              :value="item.id"-->
+    <!--            >-->
+    <!--            </el-option>-->
+    <!--          </el-select>-->
+    <!--        </el-form-item>-->
+
+    <!--        <el-form-item-->
+    <!--          v-if="form.assignType == 1"-->
+    <!--          label="工位:"-->
+    <!--          prop="workstationIds"-->
+    <!--        >-->
+    <!--          <el-select-->
+    <!--            v-model="form.workstationIds"-->
+    <!--            class="ele-block"-->
+    <!--            filterable-->
+    <!--            multiple-->
+    <!--            placeholder="请选择工位"-->
+    <!--            size="mini"-->
+    <!--          >-->
+    <!--            <el-option-->
+    <!--              v-for="item in stationList"-->
+    <!--              :key="item.id"-->
+    <!--              :label="item.name + '(' + item.code + ')'"-->
+    <!--              :value="item.id"-->
+    <!--            >-->
+    <!--            </el-option>-->
+    <!--          </el-select>-->
+    <!--        </el-form-item>-->
+
+    <!--        <el-form-item v-if="form.assignType == 2" label="人员:" prop="crewIds">-->
+    <!--          <el-select-->
+    <!--            v-model="form.crewIds"-->
+    <!--            class="ele-block"-->
+    <!--            filterable-->
+    <!--            multiple-->
+    <!--            placeholder="请选择人员"-->
+    <!--            size="mini"-->
+    <!--          >-->
+    <!--            <el-option-->
+    <!--              v-for="item in crewList"-->
+    <!--              :key="item.id"-->
+    <!--              :label="item.name"-->
+    <!--              :value="item.id"-->
+    <!--            >-->
+    <!--            </el-option>-->
+    <!--          </el-select>-->
+    <!--        </el-form-item>-->
+    <!--      </el-form>-->
+
+    <!--      <div slot="footer" class="footer">-->
+    <!--        <el-button @click="close">取消</el-button>-->
+    <!--        <el-button v-click-once type="primary" @click="confirm">确定</el-button>-->
+    <!--      </div>-->
+    <!--    </el-dialog>-->
 
     <unpackDialog ref="unpackRef" @success="createSuccess" />
     <releaseDialog
@@ -262,549 +262,556 @@
 </template>
 
 <script>
-import { getList, releaseWorkOrder, updatePriority } from "@/api/workOrder/index.js";
-import { listByFirstTaskId, listByWorkCenterId, listUserByIds } from "@/api/mainData/index.js";
-import OrderSearch from "./components/order-search.vue";
-import unpackDialog from "./components/unpackDialog.vue";
-import releaseDialog from "./components/releaseDialog.vue";
-import { fieldModel } from "@/api/saleOrder";
-import { debounce } from "lodash";
-import PlanStatistics from "@/components/statistics/PlanStatistics.vue";
-import tabMixins from "@/mixins/tableColumnsMixin";
-import BatchDialog  from "@/views/workOrder/components/batchDialog.vue";
-export default {
-  mixins: [tabMixins],
-  components: {
-    PlanStatistics,
-    OrderSearch,
-    unpackDialog,
-    releaseDialog,
-    BatchDialog
-  },
-  data() {
-    return {
-      visible: false,
-      loading: false,
-      form: {
-        assignType: 1,
-        crewIds: '',
-        workstationIds: '',
-        teamId: '',
-        singleReport: ''
+  import {
+    getList,
+    releaseWorkOrder,
+    updatePriority
+  } from '@/api/workOrder/index.js';
+  import {
+    listByFirstTaskId,
+    listByWorkCenterId,
+    listUserByIds
+  } from '@/api/mainData/index.js';
+  import OrderSearch from './components/order-search.vue';
+  import unpackDialog from './components/unpackDialog.vue';
+  import releaseDialog from './components/releaseDialog.vue';
+  import { fieldModel } from '@/api/saleOrder';
+  import { debounce } from 'lodash';
+  import PlanStatistics from '@/components/statistics/PlanStatistics.vue';
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import BatchDialog from '@/views/workOrder/components/batchDialog.vue';
+  export default {
+    mixins: [tabMixins],
+    components: {
+      PlanStatistics,
+      OrderSearch,
+      unpackDialog,
+      releaseDialog,
+      BatchDialog
+    },
+    data() {
+      return {
+        visible: false,
+        loading: false,
+        form: {
+          assignType: 1,
+          crewIds: '',
+          workstationIds: '',
+          teamId: '',
+          singleReport: ''
+        },
+        rules: {
+          singleReport: [
+            {
+              required: true,
+              message: '请选择报工类型',
+              trigger: ['blur', 'change']
+            }
+          ],
+          workstationIds: [
+            {
+              required: true,
+              message: '请选择工位',
+              trigger: ['blur']
+            }
+          ],
+          teamId: [
+            {
+              required: true,
+              message: '请选择班组',
+              trigger: ['blur']
+            }
+          ]
+        },
+        teamList: [],
+        statusOpt: [
+          { label: '待生产', value: 4 },
+          { label: '生产中', value: 5 },
+          { label: '待下达', value: 8 }
+        ],
+        newColumns: [],
+        stationList: [],
+        teamsList: [],
+        crewList: [],
+        current: null,
+        cacheKeyUrl: '3cbbdff9-aps-workOrder',
+        columnsVersion: 1,
+        dispatchRow: {},
+        dispatchVisible: false,
+        selectionMap: {}
+      };
+    },
+    computed: {
+      dispatchPermission() {
+        return (row) => {
+          if (!row.firstTaskId) {
+            return false;
+          }
+          return (
+            (row.isSplit != 1 &&
+              this.clientEnvironmentId != '4' &&
+              row.status == 8) ||
+            (this.clientEnvironmentId == '4' &&
+              !row.productName.includes('板材') &&
+              row.status == 8)
+          );
+        };
+      },
+      teamId() {
+        return this.$store.state.user.info.teamId;
       },
-      rules: {
-        singleReport: [
+      clientEnvironmentId() {
+        return this.$store.state.user.info.clientEnvironmentId;
+      },
+      // 表格列配置
+      columns() {
+        // const num = this.columnsVersion;
+        return [
           {
-            required: true,
-            message: '请选择报工类型',
-            trigger: ['blur', 'change']
-          }
-        ],
-        workstationIds: [
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            slot: 'selection',
+            fixed: 'left'
+            // selectable: (row, index) => {
+            //   if (row.children) {
+            //   }
+            //   return this.dispatchPermission(row);
+            // }
+          },
           {
-            required: true,
-            message: '请选择工位',
-            trigger: ['blur']
-          }
-        ],
-        teamId: [
+            columnKey: 'index',
+            slot: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
           {
-            required: true,
-            message: '请选择班组',
-            trigger: ['blur']
-          }
-        ]
-      },
-      teamList: [],
-      statusOpt: [
-        { label: '待生产', value: 4 },
-        { label: '生产中', value: 5 },
-        { label: '待下达', value: 8 }
-      ],
-      newColumns: [],
-      stationList: [],
-      teamsList: [],
-      crewList: [],
-      current: null,
-      cacheKeyUrl: '3cbbdff9-aps-workOrder',
-      columnsVersion: 1,
-      dispatchRow: {},
-      dispatchVisible: false,
-      selectionMap: {},
-    };
-  },
-  computed: {
-    dispatchPermission() {
-      return (row) => {
-        if (!row.firstTaskId) {
-          return false;
-        }
-        return (
-          (row.isSplit != 1 &&
-            this.clientEnvironmentId != '4' &&
-            row.status == 8) ||
-          (this.clientEnvironmentId == '4' &&
-            !row.productName.includes('板材') &&
-            row.status == 8)
-        );
-      };
-    },
-    teamId() {
-      return this.$store.state.user.info.teamId;
-    },
-    clientEnvironmentId() {
-      return this.$store.state.user.info.clientEnvironmentId;
-    },
-    // 表格列配置
-    columns() {
-      // const num = this.columnsVersion;
-      return [
-        {
-          width: 45,
-          type: 'selection',
-          columnKey: 'selection',
-          align: 'center',
-          slot: 'selection',
-          fixed: 'left'
-          // selectable: (row, index) => {
-          //   if (row.children) {
-          //   }
-          //   return this.dispatchPermission(row);
-          // }
-        },
-        {
-          columnKey: 'index',
-          slot: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-        {
-          slot: 'code',
-          label: '生产订单号',
-          align: 'center',
-          minWidth: 210,
-          sortable: true
-        },
-        {
-          prop: 'productionPlanCode',
-          label: '计划编号',
-          align: 'center',
-          minWidth: 150
-        },
-        {
-          prop: 'produceRoutingName',
-          label: '工艺路线',
-          align: 'center',
-          minWidth: 170
-        },
-        {
-          prop: 'productCode',
-          label: '编码',
-          align: 'center',
-          minWidth: 120
-        },
-        {
-          prop: 'productName',
-          label: '名称',
-          align: 'center',
-          minWidth: 170
-        },
-        {
-          prop: 'productionCodes',
-          label: '生产编号',
-          align: 'center',
-          minWidth: 150,
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'brandNo',
-          label: '牌号',
-          align: 'center'
-        },
+            slot: 'code',
+            label: '生产订单号',
+            align: 'center',
+            minWidth: 210,
+            sortable: true
+          },
+          {
+            prop: 'productionPlanCode',
+            label: '计划编号',
+            align: 'center',
+            minWidth: 150
+          },
+          {
+            prop: 'produceRoutingName',
+            label: '工艺路线',
+            align: 'center',
+            minWidth: 170
+          },
+          {
+            prop: 'productCode',
+            label: '编码',
+            align: 'center',
+            minWidth: 120
+          },
+          {
+            prop: 'productName',
+            label: '名称',
+            align: 'center',
+            minWidth: 170
+          },
+          {
+            prop: 'productionCodes',
+            label: '生产编号',
+            align: 'center',
+            minWidth: 150,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNo',
+            label: '牌号',
+            align: 'center'
+          },
 
-        {
-          prop: 'batchNo',
-          label: '批次号',
-          align: 'center',
-          minWidth: 100,
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'model',
-          label: '型号',
-          align: 'center',
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            minWidth: 100,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'model',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'priority',
-          label: '优先级',
-          align: 'center',
-          minWidth: 120,
-          slot: 'priority',
-          sortable: 'custom'
-        },
+          {
+            prop: 'priority',
+            label: '优先级',
+            align: 'center',
+            minWidth: 120,
+            slot: 'priority',
+            sortable: 'custom'
+          },
 
-        {
-          prop: 'formingNum',
-          label: '要求生产数量',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'formingWeight',
-          label: '要求生产重量',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          slot: 'formingWeight'
-        },
-        {
-          prop: 'planStartTime',
-          label: '计划开始时间',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
+          {
+            prop: 'formingNum',
+            label: '要求生产数量',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'formingWeight',
+            label: '要求生产重量',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'formingWeight'
+          },
+          {
+            prop: 'planStartTime',
+            label: '计划开始时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
 
-        {
-          prop: 'planCompleteTime',
-          label: '计划结束时间',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
+          {
+            prop: 'planCompleteTime',
+            label: '计划结束时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
 
-        {
-          prop: 'workCenterName',
-          label: '工作中心',
-          align: 'center',
-          minWidth: 110,
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'workCenterName',
+            label: '工作中心',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'firstTaskName',
-          label: '首工序',
-          align: 'center',
-          minWidth: 110,
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'firstTaskName',
+            label: '首工序',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'createTime',
-          label: '创建时间',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          sortable: 'custom'
-        },
-        {
-          slot: 'status',
-          label: '状态',
-          align: 'center',
-          formatter: (row) => {
-            const obj = this.statusOpt.find((i) => i.value == row.status);
-            return obj && obj.label;
-          }
-        },
-        {
-          prop: 'customerName',
-          label: '客户名称',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'serialNo',
-          label: '客户代号',
-          align: 'center',
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            sortable: 'custom'
+          },
+          {
+            slot: 'status',
+            label: '状态',
+            align: 'center',
+            formatter: (row) => {
+              const obj = this.statusOpt.find((i) => i.value == row.status);
+              return obj && obj.label;
+            }
+          },
+          {
+            prop: 'customerName',
+            label: '客户名称',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'serialNo',
+            label: '客户代号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'simpleName',
-          label: '客户简称',
-          align: 'center',
-          showOverflowTooltip: true
-        }
-      ];
-    },
+          {
+            prop: 'simpleName',
+            label: '客户简称',
+            align: 'center',
+            showOverflowTooltip: true
+          }
+        ];
+      },
 
-    checkRowData() {
-      return (row) => {
-        return row.checkedata ? true : false;
-      };
-    }
-  },
-  created() {
-    this.getFieldModel();
-  },
-
-  methods: {
-    // 单选数据
-    selectRow(e, row) {
-      if (e) {
-        this.selectionMap[row.id] = {
-          id: row.id,
-          firstTaskId: row.firstTaskId,
-          productName: row.productName,
-          productCode: row.productCode,
-          code: row.code,
-          productionPlanCode: row.productionPlanCode,
-          batchNo: row.batchNo,
-          formingNum: row.formingNum
+      checkRowData() {
+        return (row) => {
+          return row.checkedata ? true : false;
         };
-      } else {
-        delete this.selectionMap[row.id];
-      }
-    },
-
-    // 批量派单
-    batchDispatch() {
-      let list = Object.values(this.selectionMap);
-      if (list.length === 0) {
-        this.$message.warning('请至少选择一条派单的数据');
-      }
-      this.$refs.batchRef.open(list);
-    },
-    assignTypeFn(e) {
-    },
-    statusFormatter(status) {
-      const obj = this.statusOpt.find((i) => i.value == status);
-      return obj && obj.label;
-    },
-    /* 表格数据源 */
-    datasource({ page, limit, where }) {
-      this.selectionMap = {};
-      if (where.status) {
-        where.statusList = [];
-        where.statusList.push(where.status);
       }
-      return getList({
-        pageNum: page,
-        size: limit,
-        ...where,
-        ...this.sort
-      });
     },
-
-    /* 数据转为树形结构 */
-    parseData(data) {
-      const obj = {
-        ...data,
-        list: this.$util.toTreeData({
-          data: data.list,
-          count: data.total,
-
-          idField: 'code',
-          parentIdField: 'originalCode'
-        })
-      };
-      return obj;
+    created() {
+      this.getFieldModel();
     },
 
-    getFieldModel() {
-      fieldModel({ fieldModel: 't_main_category' }).then((res) => {
-        const privateColumn = [
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 120,
-            align: 'center',
-            resizable: false,
-            fixed: 'right',
-            slot: 'action'
-          }
-        ];
-
-        let newRes = res.map((m) => {
-          return {
-            prop: 'extField.' + m.prop,
-            label: m.label,
-            align: 'center',
-            showOverflowTooltip: true
+    methods: {
+      // 单选数据
+      selectRow(e, row) {
+        this.$set(row, 'checkedata', e);
+        if (e) {
+          this.selectionMap[row.id] = {
+            id: row.id,
+            firstTaskId: row.firstTaskId,
+            productName: row.productName,
+            productCode: row.productCode,
+            code: row.code,
+            productionPlanCode: row.productionPlanCode,
+            batchNo: row.batchNo,
+            formingNum: row.formingNum
           };
+        } else {
+          delete this.selectionMap[row.id];
+        }
+      },
+
+      // 批量派单
+      batchDispatch() {
+        let list = Object.values(this.selectionMap);
+        if (list.length === 0) {
+          this.$message.warning('请至少选择一条派单的数据');
+        }
+        this.$refs.batchRef.open(list);
+      },
+      assignTypeFn(e) {},
+      statusFormatter(status) {
+        const obj = this.statusOpt.find((i) => i.value == status);
+        return obj && obj.label;
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where }) {
+        this.selectionMap = {};
+        if (where.status) {
+          where.statusList = [];
+          where.statusList.push(where.status);
+        }
+        return getList({
+          pageNum: page,
+          size: limit,
+          ...where,
+          ...this.sort
         });
+      },
 
-        this.newColumns = [...this.columns, ...newRes, ...privateColumn];
+      /* 数据转为树形结构 */
+      parseData(data) {
+        const obj = {
+          ...data,
+          list: this.$util.toTreeData({
+            data: data.list,
+            count: data.total,
 
-        this.$forceUpdate();
-      });
-    },
+            idField: 'code',
+            parentIdField: 'originalCode'
+          })
+        };
+        return obj;
+      },
 
-    // 下达
-    toRelease(row) {
-      this.current = row;
-      this.visible = true;
-      this.FirstTaskIdFn();
-      this.WorkCenterIdFn();
-      this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
-    },
-    // 下达
-    confirm() {
-      this.$refs.form.validate((valid) => {
-        if (valid) {
-          const loading = this.$loading({ text: '加载中...' });
-
-          if (this.form.assignType * 1 == 2) {
-            this.form.workstationIds = [];
-          } else {
-            this.form.crewIds = [];
-          }
+      getFieldModel() {
+        fieldModel({ fieldModel: 't_main_category' }).then((res) => {
+          const privateColumn = [
+            {
+              columnKey: 'action',
+              label: '操作',
+              width: 120,
+              align: 'center',
+              resizable: false,
+              fixed: 'right',
+              slot: 'action'
+            }
+          ];
+
+          let newRes = res.map((m) => {
+            return {
+              prop: 'extField.' + m.prop,
+              label: m.label,
+              align: 'center',
+              showOverflowTooltip: true
+            };
+          });
+
+          this.newColumns = [...this.columns, ...newRes, ...privateColumn];
+
+          this.$forceUpdate();
+        });
+      },
 
-          releaseWorkOrder({
-            id: this.current.id,
-            ...this.form
-          })
-            .then((res) => {
-              if (res) {
-                this.$message.success('成功');
-
-                this.reData();
-                this.reload();
-                this.visible = false;
-              }
+      // 下达
+      toRelease(row) {
+        this.current = row;
+        this.visible = true;
+        this.FirstTaskIdFn();
+        this.WorkCenterIdFn();
+        this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
+      },
+      // 下达
+      confirm() {
+        this.$refs.form.validate((valid) => {
+          if (valid) {
+            const loading = this.$loading({ text: '加载中...' });
+
+            if (this.form.assignType * 1 == 2) {
+              this.form.workstationIds = [];
+            } else {
+              this.form.crewIds = [];
+            }
+
+            releaseWorkOrder({
+              id: this.current.id,
+              ...this.form
             })
-            .finally(() => {
-              loading.close();
-            });
-        }
-      });
-    },
-    close() {
-      this.visible = false;
-      this.reData();
-    },
-    reData() {
-      this.form = {
-        assignType: 1,
-        crewIds: '',
-        workstationIds: '',
-        teamId: '',
-        singleReport: this.clientEnvironmentId == 2 ? 0 : 1
-      };
-    },
+              .then((res) => {
+                if (res) {
+                  this.$message.success('成功');
+
+                  this.reData();
+                  this.reload();
+                  this.visible = false;
+                }
+              })
+              .finally(() => {
+                loading.close();
+              });
+          }
+        });
+      },
+      close() {
+        this.visible = false;
+        this.reData();
+      },
+      reData() {
+        this.form = {
+          assignType: 1,
+          crewIds: '',
+          workstationIds: '',
+          teamId: '',
+          singleReport: this.clientEnvironmentId == 2 ? 0 : 1
+        };
+      },
 
-    /* 刷新表格 */
-    reload(where) {
-      this.$nextTick(() => {
-        this.$refs.table.reload({ page: 1, where });
-      });
-    },
+      /* 刷新表格 */
+      reload(where) {
+        this.$nextTick(() => {
+          this.$refs.table.reload({ page: 1, where });
+        });
+      },
 
-    onSortChange(e) {
-      let sort = {
-        orderBy: e.order,
-        sortName: e.prop
-      };
-      this.sort = sort;
-      this.reload();
-    },
+      onSortChange(e) {
+        let sort = {
+          orderBy: e.order,
+          sortName: e.prop
+        };
+        this.sort = sort;
+        this.reload();
+      },
 
-    sortTop(row) {
-      row.priority = Number(row.priority) + 1;
-      this.priorityChange(row);
-    },
-    sortBottom(row) {
-      if (row.priority <= 1) {
-        return;
-      }
-      row.priority = Number(row.priority) - 1;
-      this.priorityChange(row);
-    },
+      sortTop(row) {
+        row.priority = Number(row.priority) + 1;
+        this.priorityChange(row);
+      },
+      sortBottom(row) {
+        if (row.priority <= 1) {
+          return;
+        }
+        row.priority = Number(row.priority) - 1;
+        this.priorityChange(row);
+      },
 
-    FirstTaskIdFn() {
-      listByFirstTaskId(this.current.firstTaskId).then((res) => {
-        this.stationList = res;
-      });
-    },
+      FirstTaskIdFn() {
+        listByFirstTaskId(this.current.firstTaskId).then((res) => {
+          this.stationList = res;
+        });
+      },
 
-    WorkCenterIdFn() {
-      listByWorkCenterId(this.current.workCenterId).then((res) => {
-        this.teamsList = res;
+      WorkCenterIdFn() {
+        listByWorkCenterId(this.current.workCenterId).then((res) => {
+          this.teamsList = res;
 
-        this.$nextTick(() => {
-          if (this.teamId) {
-            this.$set(this.form, 'teamId', this.teamId);
-            this.stationChange();
-          }
+          this.$nextTick(() => {
+            if (this.teamId) {
+              this.$set(this.form, 'teamId', this.teamId);
+              this.stationChange();
+            }
 
-          // this.$refs.form.clearValidate();
+            // this.$refs.form.clearValidate();
+          });
         });
-      });
-    },
+      },
 
-    // 拆分
-    toUnpack(row) {
-      this.$refs.unpackRef.open(row);
-    },
-    //派单
-    toReleaseOpen(row) {
-      this.dispatchRow = { ...row };
-      this.dispatchRow.initialWeight = row.formingWeight
-        ? row.formingWeight + row.newWeightUnit
-        : '';
-      this.dispatchVisible = true;
-      // getTaskIdByInstanceId(row.firstTaskId)
-      //   .then((res) => {
-      //     if (res) {
-      // }
-      // })
-      // .catch((err) => {
-      //   this.$message.error(err.message);
-      // });
-    },
+      // 拆分
+      toUnpack(row) {
+        this.$refs.unpackRef.open(row);
+      },
+      //派单
+      toReleaseOpen(row) {
+        this.dispatchRow = { ...row };
+        this.dispatchRow.initialWeight = row.formingWeight
+          ? row.formingWeight + row.newWeightUnit
+          : '';
+        this.dispatchVisible = true;
+        // getTaskIdByInstanceId(row.firstTaskId)
+        //   .then((res) => {
+        //     if (res) {
+        // }
+        // })
+        // .catch((err) => {
+        //   this.$message.error(err.message);
+        // });
+      },
 
-    createSuccess() {
-      this.reload();
-    },
+      createSuccess() {
+        this.reload();
+      },
 
-    stationChange() {
-      this.crewList = [];
-      this.crewIds = [];
+      stationChange() {
+        this.crewList = [];
+        this.crewIds = [];
 
-      listUserByIds([this.form.teamId]).then((res) => {
-        this.crewList = res;
-      });
-    },
+        listUserByIds([this.form.teamId]).then((res) => {
+          this.crewList = res;
+        });
+      },
 
-    priorityChange(row) {
-      if (row.priority > 10) {
-        row.priority = 10; // 如果大于 10,则设置为 10
-      } else if (row.priority < 0) {
-        row.priority = 0; // 如果小于 0,则设置为 0
-      }
+      priorityChange(row) {
+        if (row.priority > 10) {
+          row.priority = 10; // 如果大于 10,则设置为 10
+        } else if (row.priority < 0) {
+          row.priority = 0; // 如果小于 0,则设置为 0
+        }
 
-      this.priorityFn(row);
-    },
+        this.priorityFn(row);
+      },
 
-    priorityFn: debounce(function(row) {
-      let params = {
-        id: row.id,
-        priority: row.priority
-      };
-      updatePriority(params).then((res) => {
-      });
-    }, 800)
-  }
-};
+      priorityFn: debounce(function (row) {
+        let params = {
+          id: row.id,
+          priority: row.priority
+        };
+        updatePriority(params).then((res) => {});
+      }, 800)
+    }
+  };
 </script>
 
 <style lang="scss" scoped>
-// ::v-deep .el-table__row {
-//   height: 51px !important;
-// }
-
-::v-deep thead {
-  .cell {
-    .el-checkbox {
-      display: none;
+  // ::v-deep .el-table__row {
+  //   height: 51px !important;
+  // }
+
+  ::v-deep thead {
+    .cell {
+      .el-checkbox {
+        display: none;
+      }
     }
   }
-}
 </style>

+ 16 - 4
src/views/workOrder/mixins/release.js

@@ -815,7 +815,10 @@ export default {
             this.$message.info(
               `开始时间不能小于前面工序${frontName}的结束时间${time}`
             );
-            row.startTime = time;
+            // 判断是否 配置时间更改规则
+            if (this.time_calc_code == '1') {
+              row.startTime = time;
+            }
             return;
           }
         }
@@ -832,7 +835,10 @@ export default {
           this.$message.info(
             `开始时间不能大于后面工序${latterName}的开始时间${time}`
           );
-          row.startTime = '';
+          // 判断是否 配置时间更改规则
+          if (this.time_calc_code == '1') {
+            row.startTime = '';
+          }
           return;
         }
       }
@@ -885,7 +891,10 @@ export default {
           this.$message.info(
             `结束时间不能大于后面工序${latterName}的开始时间${time}`
           );
-          row.endTime = time;
+          // 判断是否 配置时间更改规则
+          if (this.time_calc_code == '1') {
+            row.endTime = time;
+          }
           return;
         }
       }
@@ -901,7 +910,10 @@ export default {
           this.$message.info(
             `结束时间不能小于前面工序${frontName}的结束时间${time}`
           );
-          row.endTime = '';
+          // 判断是否 配置时间更改规则
+          if (this.time_calc_code == '1') {
+            row.endTime = '';
+          }
           return;
         }
       }