小小儁爺
2024-08-12 8ff18ada93d1e3a6174a28f9339bec8221f03e6a
src/views/produceManager/workOrder.vue
@@ -289,16 +289,7 @@
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            prop="route_name"-->
          <!--            label="关联工艺路线"-->
          <!--            min-width="110"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <i v-if="row.route_name" class="el-icon-share" @click="routeClick(row)" />-->
          <!--              <i v-else style="color:rgb(180 ,181, 185)" class="el-icon-share" @click="routeClick(row)" />-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            prop="plan_startdate"
            label="计划开始时间"
@@ -1945,26 +1936,26 @@
        </div>
      </div>
      <el-divider />
      <div>
        <i class="el-icon-s-operation" style="color:#42b983;" /> 默认工艺路线
      </div>
      <div style="margin-top: 20px">
        <el-select
          v-model="defaultroute_code"
          filterable
          style="width: 200px;"
          placeholder="请选择"
          class="defaultroute_code"
        >
          <el-option
            v-for="item in defaultroute_codeArr"
            :key="item.code"
            :label="item.name"
            :value="item.code"
          />
        </el-select>
      </div>
      <!--      <el-divider />-->
      <!--      <div>-->
      <!--        <i class="el-icon-s-operation" style="color:#42b983;" /> 默认工艺路线-->
      <!--      </div>-->
      <!--      <div style="margin-top: 20px">-->
      <!--        <el-select-->
      <!--          v-model="defaultroute_code"-->
      <!--          filterable-->
      <!--          style="width: 200px;"-->
      <!--          placeholder="请选择"-->
      <!--          class="defaultroute_code"-->
      <!--        >-->
      <!--          <el-option-->
      <!--            v-for="item in defaultroute_codeArr"-->
      <!--            :key="item.code"-->
      <!--            :label="item.name"-->
      <!--            :value="item.code"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </div>-->
      <el-divider />
      <div style="margin-bottom: 10px">
        <i class="el-icon-s-operation" style="color:#42b983;" /> 工序列表
@@ -2034,12 +2025,15 @@
      @close="handleClose3"
    >
      <div style="height: 600px;padding-right: 20px;overflow: auto">
      <div style="height: 30px;width: 100%;margin-bottom: 10px;">
        <el-alert
          v-if="multipleSelection.length-formData3.length>0"
          :title="'当前选中'+multipleSelection.length+'个工单,有'+(multipleSelection.length-formData3.length)+'个工单未指定工艺路线,已过滤!'"
          v-if="formData3.filter(i => i.routecode==='').length>0"
          :title="'当前选中'+multipleSelection.length+'个工单,有'+(formData3.filter(i => i.routecode==='').length)+'个工单未指定工艺路线,请指定!'"
          type="error"
        />
      </div>
      <div style="height: 600px;padding-right: 20px;overflow: auto">
        <div v-for="(i,index) in formData3" :key="index">
          <el-divider content-position="left">第{{ index+1 }}个工单</el-divider>
@@ -2047,6 +2041,7 @@
            ref="dialogForm"
            inline
            :model="i"
            style="margin-bottom: 20px"
            label-width="110px"
          >
            <el-form-item
@@ -2164,7 +2159,7 @@
              <!--              </el-select>-->
            </el-form-item>
            <el-form-item label="工艺路线" prop="routecode">
            <el-form-item label="工艺路线">
              <el-select
                v-model="i.routecode"
                filterable
@@ -2182,18 +2177,24 @@
              </el-select>
            </el-form-item>
            <el-form-item label="工价管控" required>
              <div style="display: flex;align-items: center;justify-content: space-between;width: 200px;">
              <el-switch
                v-model="i.is_steprice"
                active-color="#13ce66"
                inactive-color="#eee"
                  style="width: 60px;"
                @change="routecodeChange2(i)"
              />
                <el-button type="primary" @click="routeClick(i,routeIndex=index)">工艺选择</el-button>
              </div>
            </el-form-item>
          </el-form>
          <div style="display: flex;justify-content: flex-end;margin-top: -50px;margin-right: 50px">
            {{ i.children.find(it=>it.routecode===i.routecode).stepname }}
            {{ i.children.length>0? i.children.find(it=>it.routecode===i.routecode).stepname:'' }}
          </div>
        </div>
      </div>
@@ -2203,7 +2204,6 @@
          <el-button v-waves @click="dialogVisible3=false">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :disabled="submitButtonIsDisabled"
            @click="dialogVisibleConfirm3"
@@ -2503,8 +2503,14 @@
      dialogVisible3: false,
      multipleSelection: [],
      formData3: []
      formData3: [],
      routeIndex: ''
      // dialogFormRules2: {
      //   routecode: [
      //     { required: true, message: '请选择工艺路线', trigger: ['blur', 'change'] }
      //   ]
      // }
    }
  },
  created() {
@@ -3288,14 +3294,20 @@
    },
    /* 关联工艺路线模块*/
    // 关联工艺路线
    async routeClick(row) {
      console.log(row)
      // this.defaultroute_code = row.default_route
      this.dialogFormRoute.projectCode = row.partcode
      this.dialogFormRoute.projectName = row.partname
    async routeClick(i) {
      // console.log(row)
      // // this.defaultroute_code = row.default_route
      this.dialogFormRoute.projectCode = i.partcode
      this.dialogFormRoute.projectName = i.partname
      const { data: res } = await InventoryFileAssociationRoute({ partcode: i.partcode })
      this.dialogFormRoute.routeOperationArr = res.filter(j => j.wkshopcode === i.wkshopcode)
      if (this.dialogFormRoute.routeOperationArr.length === 0) {
        return this.$message.info('此车间下无工艺路线!')
      }
      this.dialogVisibleRoute = true
      const { data: res } = await InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode })
      this.dialogFormRoute.routeOperationArr = res
      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
        item.isSelected1 = false
@@ -3307,7 +3319,7 @@
        if (item.flag === 'Y') {
          item.isSelected2 = true
          this.$nextTick(() => {
            $('input:checkbox').eq(index).prop('checked', true)
            $('.myCheckboxInput').eq(index).prop('checked', true)
          })
        }
      })
@@ -3327,23 +3339,36 @@
    },
    // 确定
    async routeDialogVisibleConfirm() {
      const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
      if (this.defaultroute_code === '' && temp.length > 0) {
        return this.$message.info('默认工艺路线不能为空!')
      if (!this.dialogFormRoute.routeOperationArr.find(i => i.isSelected2)) {
        return this.$message.info('请先选择工艺路线!')
      }
      // const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
      // if (this.defaultroute_code === '' && temp.length > 0) {
      //   return this.$message.info('默认工艺路线不能为空!')
      // }
      // 提交格式
      const data = []
      this.formData3[this.routeIndex].children = []
      this.dialogFormRoute.routeOperationArr.forEach(item => {
        if (item.isSelected2) {
          data.push({ code: item.code, name: item.name })
          // console.log(item, 8)
          data.push({ code: item.code, name: item.name, wkshopcode: this.formData3[this.routeIndex].wkshopcode, stepname: item.Data.map(i => { if (i.enable === 'Y') { return i.stepname } }).join(',') })
          this.formData3[this.routeIndex].children.push({
            routecode: item.code,
            routename: item.name,
            stepname: item.Data.map(i => { if (i.enable === 'Y') { return i.stepname } }).join(',')
          })
        }
      })
      const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
      if (res.code === '200') {
        this.$message.success('保存成功!')
        await this.getMesOrderSearch()
        this.formData3[this.routeIndex].routecode = this.formData3[this.routeIndex].children[0].routecode
        this.formData3[this.routeIndex].stepname = this.formData3[this.routeIndex].children[0].stepname
        this.dialogVisibleRoute = false
      }
    },
@@ -3453,7 +3478,8 @@
      this.formData3 = []
      this.multipleSelection.forEach((item, index) => {
        item.stepname = res[index].children.length > 0 ? res[index].children[0].stepname : ''
        if (item.stepname) {
        console.log(item.stepname)
        // if (item.stepname) {
          this.formData3.push({
            'mesorderstus': item.status,
            'sourceorder': item.m_po,
@@ -3469,13 +3495,13 @@
            'planstartdate': item.plan_startdate,
            'planenddate': item.plan_enddate,
            'orderlev': item.piroque,
            children: res[index].children,
          children: res[index].children.length > 0 ? res[index].children : [],
            is_steprice: false,
            'is_aps': '',
            'bom_id': ''
          })
        }
        // }
      })
      if (this.formData3.length === 0) {
@@ -3486,6 +3512,10 @@
    },
    // 批量派发确定事件
    async dialogVisibleConfirm3() {
      if (this.formData3.filter(i => i.routecode === '').length > 0) {
        return this.$message.info('还有' + this.formData3.filter(i => i.routecode === '').length + '个工单未指定!')
      }
      const data = []
      this.formData3.forEach(i => {
        data.push({
@@ -3539,6 +3569,7 @@
        })
      }
    }
  }
}
</script>